LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 04-09-2011, 05:27 PM   #1
mikes1313
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
awk scripts for trace file


Hi this is a sample of my trace file

s 5.000000000 _10_ AGT --- 0 cbr 50 [0 0 0 0] [energy 100.000000 ei 0.000 es 0.000 et 0.000 er 0.000] ------- [10:0 0:0 32 0] [0] 0 0
r 5.000000000 _10_ RTR --- 0 cbr 50 [0 0 0 0] [energy 100.000000 ei 0.000 es 0.000 et 0.000 er 0.000] ------- [10:0 0:0 32 0] [0] 0 0
s 5.000000000 _10_ RTR --- 0 AODV 48 [0 0 0 0] [energy 100.000000 ei 0.000 es 0.000 et 0.000 er 0.000] ------- [10:255 -1:255 30 0] [0x2 1 1 [0 0] [10 4]] (REQUEST)
N -t 5.002585 -n 0 -e 99.996369
N -t 5.002585 -n 8 -e 99.996369
N -t 5.002585 -n 95 -e 99.996369
r 5.005202005 _0_ RTR --- 0 AODV 48 [0 ffffffff a 800] [energy 99.996369 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [10:255 -1:255 30 0] [0x2 1 1 [0 0] [10 4]] (REQUEST)
s 5.005202005 _0_ RTR --- 0 AODV 44 [0 0 0 0] [energy 99.996369 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [0:255 10:255 30 10] [0x4 1 [0 4] 10.000000] (REPLY)
r 5.005202054 _8_ RTR --- 0 AODV 48 [0 ffffffff a 800] [energy 99.996369 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [10:255 -1:255 30 0] [0x2 1 1 [0 0] [10 4]] (REQUEST)
r 5.005202130 _95_ RTR --- 0 AODV 48 [0 ffffffff a 800] [energy 99.996369 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [10:255 -1:255 30 0] [0x2 1 1 [0 0] [10 4]] (REQUEST)
N -t 5.006807 -n 10 -e 99.996318
N -t 5.006807 -n 8 -e 99.996321
N -t 5.006807 -n 95 -e 99.996321
s 5.009520941 _95_ RTR --- 0 AODV 48 [0 ffffffff a 800] [energy 99.996321 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
N -t 5.009866 -n 8 -e 99.996251
N -t 5.009866 -n 28 -e 99.996364
N -t 5.009866 -n 68 -e 99.996364
N -t 5.009866 -n 0 -e 99.996245
N -t 5.009866 -n 10 -e 99.996248
s 5.012243695 _8_ RTR --- 0 AODV 48 [0 ffffffff a 800] [energy 99.996251 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [8:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
r 5.012483018 _8_ RTR --- 0 AODV 48 [0 ffffffff 5f 800] [energy 99.996251 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
r 5.012483028 _28_ RTR --- 0 AODV 48 [0 ffffffff 5f 800] [energy 99.996364 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
r 5.012483070 _68_ RTR --- 0 AODV 48 [0 ffffffff 5f 800] [energy 99.996364 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
r 5.012483070 _0_ RTR --- 0 AODV 48 [0 ffffffff 5f 800] [energy 99.996245 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
r 5.012483071 _10_ RTR --- 0 AODV 48 [0 ffffffff 5f 800] [energy 99.996226 ei 0.004 es 0.000 et 0.000 er 0.000] ------- [95:255 -1:255 29 0] [0x2 2 1 [0 0] [10 4]] (REQUEST)
N -t 5.013549 -n 0 -e 99.996175
N -t 5.013549 -n 10 -e 99.996155
N -t 5.013549 -n 95 -e 99.996178
N -t 5.013549 -n 28 -e 99.996294


I have used the following end to end delay awk script :

# ===================================================================

# AWK Script for calculating:

# => Send,

# => Received, and

# => Dropped packets, with packets

# => Delivery Ration and Average End-to-End Delay.

# ===================================================================



BEGIN {

seqno = -1;

droppedPackets = 0;

receivedPackets = 0;

count = 0;

}

{

#packet delivery ratio

if($4 == "AGT" && $1 == "s" && seqno < $6) {

seqno = $6;

} else if(($4 == "AGT") && ($1 == "r")) {

receivedPackets++;

} else if ($1 == "D" && $7 == "tcp" && $8 > 512){

droppedPackets++;

}

#end-to-end delay

if($4 == "AGT" && $1 == "s") {

start_time[$6] = $2;

} else if(($7 == "tcp") && ($1 == "r")) {

end_time[$6] = $2;

} else if($1 == "D" && $7 == "tcp") {

end_time[$6] = -1;

}

}



END {



for(i=0; i<=seqno; i++) {

if(end_time[i] > 0) {

delay[i] = end_time[i] - start_time[i];

count++;

}

else

{

delay[i] = -1;

}

}

for(i=0; i<count; i++) {

if(delay[i] > 0) {

n_to_n_delay = n_to_n_delay + delay[i];

}

}

n_to_n_delay = n_to_n_delay/count;



print "\n";

print "GeneratedPackets = " seqno+1;

print "ReceivedPackets = " receivedPackets;

print "Packet Delivery Ratio = " receivedPackets/(seqno+1)*100
"%";

print "Total Dropped Packets = " droppedPackets;

print "Average End-to-End Delay = " n_to_n_delay * 1000 " ms";

print "\n";

}

and I got this message : Average end to end delay = -nan ms

I can't really understand what is the problem.

Can somebody provide my scripts for energy consumption, e2edelay,throughput, sent-received-dropped packets, jitter that works for AODV routing protocol.

How can by an awk script extract an Xgraph.


Thanks a lot
MIKE
 
Old 04-10-2011, 02:59 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,195

Rep: Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796
So first of all, please use [code][/code] tags to enclose code so it is at least readable.

I am not sure that with the provided input this code was ever going to work.
On a quick look I see that end_time variable is only ever set when at least $7 == tcp. The problem here is that the string 'tcp' is not in the input at all??
Also the seqno is never any bigger than 0 so the loops in END related to this will only ever loop once.

Combining the above means that by the time you get to the following line:
Code:
n_to_n_delay = n_to_n_delay/count;
You will receive 0/0 which in itself is not going to work.

So we either need better data to look at or you need to rethink some of the logic.
 
Old 04-25-2012, 10:14 AM   #3
lucky89
LQ Newbie
 
Registered: Mar 2012
Posts: 19

Rep: Reputation: Disabled
hello sir
can you give me the script.tcl of this example, a want to learn how do you add the energy!
and do you see your problem of awk because i have the same probleme??
thanks in advance
 
Old 04-26-2012, 03:13 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
This thread is over a year old now and the opening poster never bothered to come back and reply after the first post. Do you really think you're going to get an answer?


If you have a similar problem of your own, it's generally better to start a new thread for it. You can link back to any older ones if appropriate. Don't reopen old threads unless you have something important to add to that discussion in particular.
 
Old 04-10-2013, 08:52 AM   #5
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, 09:29 AM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,195

Rep: Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796
Quote:
Help me please i don't understand what to do
The first thing you need to do is start your own question and not continue a question from last year.
 
Old 04-18-2013, 05:06 AM   #7
doussa
LQ Newbie
 
Registered: Feb 2013
Posts: 29

Rep: Reputation: Disabled
Unhappy

Hi friends,
Can anyone help me to integrate multi hops notion in leach protocol .
please I need your help as soon as possible and I will be grateful.
 
Old 04-18-2013, 05:11 PM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
Is anyone actually reading this thread?
 
  


Reply

Tags
awk, trace


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
awk scripts jdeeptir Linux - Newbie 9 06-09-2008 01:18 PM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 05:39 PM
Recursive trace of bash scripts needed CollieJim Linux - General 3 07-13-2007 10:56 AM
Value counting in awk scripts sarajevo Programming 9 10-20-2006 08:24 AM
Getting awk to extract scripts from a file jspaceman Programming 5 11-24-2002 06:37 PM


All times are GMT -5. The time now is 11:25 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration