LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-10-2013, 12:46 PM   #1
ines8989
Member
 
Registered: Mar 2013
Posts: 62

Rep: Reputation: Disabled
awk script


Hi
i want to simulate an awk script to have throuĝhput graph for tcp connection ( my awk file is named linktcp) and has this format
BEGIN {
packet_size= 1500
total_throughput = 0
final = 0
time_ini = 1.0
count = 0
}
{
ackn = $5
event = $1
time = $2
node = 0
flowid= $8
from_node = $3
to_node= $4
#print(event)
#print(time)
#print(flowid)
#print(from_node)
#from node should be 2
if(event == "r" && flowid == "1" && from_node == "0" && time_ini >= time && ackn == "tcp" ) {
#remember always immediately after if there will be start of the { .not in next line
total_throughput = total_throughput + packet_size
++count
}
if(event == "r" && flowid == "1" && from_node == "0" && time_ini <= time &&ackn == "tcp") {
#print(count)
count = 0
final = total_throughput + final
#print(total_throughput)
total_throughput = (total_throughput *8)/1000
printf("%f\t%f\n" , time_ini , total_throughput )
total_throughput = 0
time_ini = time_ini + 1
}
}
END {

final = (((final *8)/1000 ) / time)
print("Total Throughput for TCP : " , final)
for (i = 1.00 ; i <= time_ini ; i++) printf("%f\t%f\n" , i , final )
}
to plot the graph of throughput :i wrote this little script below and i named it 'parametre1':
set title 'Tcp-Throughput'
set xlabel 'Time (s)'
set ylabel 'throughput (Mbs)'
set autoscale
plot 'linktcp' w linespoints title 'throughput-of-TCP'
But i tape in the terminal this command to plot the graph with gnuplot : i have this result
gnuplot> load 'parametre1'
"parametre1", line 5: warning: Skipping unreadable file "linktcp"
"parametre1", line 5: No data in plot

Help me please i don't understand what to do
Thanks for you
 
Old 04-10-2013, 12:50 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
You've made it very hard to read -- put code in brackets \[code\] ...\[/code\] (without the \ of course)

The result looks like:
Code:
   put code here
 
Old 04-10-2013, 01:08 PM   #3
ines8989
Member
 
Registered: Mar 2013
Posts: 62

Original Poster
Rep: Reputation: Disabled
awk script

My script for linktcp.awk file
------------------------------------------------------------------------
BEGIN {

packet_size= 1500
total_throughput = 0
final = 0
time_ini = 1.0
count = 0
}
{

ackn = $5
event = $1
time = $2
node = 0
flowid= $8
from_node = $3
to_node= $4

if(event == "r" && flowid == "1" && from_node == "0" && time_ini >= time && ackn == "tcp" ) {

total_throughput = total_throughput + packet_size
++count
}

if(event == "r" && flowid == "1" && from_node == "0" && time_ini <= time &&ackn == "tcp") {
#print(count)

count = 0
final = total_throughput + final

total_throughput = (total_throughput *8)/1000
printf("%f\t%f\n" , time_ini , total_throughput )
total_throughput = 0
time_ini = time_ini + 1
}
}
END {

final = (((final *8)/1000 ) / time)

print("Total Throughput for TCP : " , final)
for (i = 1.00 ; i <= time_ini ; i++) printf("%f\t%f\n" , i , final )
}

to plot the graph of throughput :i wrote this little script below and i named it 'parametre1':

-------------------------------------------------------------------------------------------------------
set title 'Tcp-Throughput'
set xlabel 'Time (s)'
set ylabel 'throughput (Mbs)'
set autoscale
plot 'linktcp' w linespoints title 'throughput-of-TCP'


when i tape in the terminal this command to plot the graph with gnuplot : i have this result

gnuplot> load 'parametre1'

"parametre1", line 5: warning: Skipping unreadable file "linktcp"
"parametre1", line 5: No data in plot

Help me please i don't understand what to do
Thanks for you
 
Old 04-10-2013, 02:29 PM   #4
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
It seems that the file 'linktcp' either does not exist or is unreadable or you are in the wrong directory
 
Old 04-10-2013, 03:20 PM   #5
ines8989
Member
 
Registered: Mar 2013
Posts: 62

Original Poster
Rep: Reputation: Disabled
awk script

But when i test the awk file it runs that's what i have :

iness@iness-VirtualBox ~/ns-allinone-2.35/bin/FirstCode $ gawk -f linktcp.awk out.tr

I have this result :


91.000000 1008.000000
92.000000 1020.000000
93.000000 1044.000000
94.000000 1044.000000
95.000000 1140.000000
96.000000 1068.000000
97.000000 996.000000
98.000000 1008.000000
99.000000 1020.000000
Total Throughput for TCP : 1014.25
1.000000 1014.247995
2.000000 1014.247995
3.000000 1014.247995
4.000000 1014.247995
5.000000 1014.247995
6.000000 1014.247995
7.000000 1014.247995
8.000000 1014.247995
9.000000 1014.247995
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[awk script] Help me delete lines in a file using script ? sieukid Programming 5 03-20-2012 02:23 PM
[SOLVED] call awk from bash script behaves differently to awk from CLI = missing newlines titanium_geek Programming 4 05-26-2011 10:06 PM
Bash script is enterpreting $1, $2 values in awk script ... praveen_218 Programming 4 09-14-2009 04:38 PM
what does this awk script do? sharathkv25 Programming 3 03-08-2007 04:10 PM
Passing variables from AWK script to my shell script BigLarry Programming 1 06-12-2004 05:32 AM


All times are GMT -5. The time now is 01:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration