LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-17-2013, 09:52 AM   #1
NS2User2012
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Rep: Reputation: Disabled
Errors while using awk script for calculating average end to end delay in ns2


Hi,
always when I try to get results from my tracefile (simple_aodv.tr) I get several errors:
I want to calculate the average end to end delay of my tracefile.

I use the following command to start the calculation:

awk -f "e2edelay.awk" "simple_aodv.tr"

But I get only this message:
awk: e2edelay.awk:77: (FILENAME=simple_aodv.tr FNR=36530) Fatal:division by zero attempted

Has someone an idea why I get this Error: division by zero attempted? Is there an error in the awk script?


I used the same command for calculating the packet delivery rate and there it works.

awk -f "pdf.awk" "simple_aodv.tr"

Thx for your help!
 
Old 02-17-2013, 10:14 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,837

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
yes, probably the awk script is not perfect, or maybe the datafile has been corrupted.
 
Old 02-17-2013, 10:26 AM   #3
NS2User2012
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
What do you mean with the datafile is not correct? I used the same tracefile for calculating the packet delivery rate and the proctocol overhead, and it worked without errors. I get only errors when I try to calculate the end-to-end Delay!

That's the code for calculating the end-to-end Delay

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

# AWK Script for calculating:

# => Average End-to-End Delay.

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



BEGIN {

seqno = -1;
count = 0;

}

{

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

seqno = $6;

}

#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<=seqno; i++) {

if(delay[i] > 0) {

n_to_n_delay = n_to_n_delay + delay[i];

}

}

n_to_n_delay = n_to_n_delay/count;

printf "%.3f\n", n_to_n_delay*1000;
#print "Average End-to-End Delay = " n_to_n_delay * 1000 " ms";
}
 
Old 02-17-2013, 10:49 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,837

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
please use [COLOR="Blue"][code][/code][/COLOR] to keep formatting of your code.
The message: awk: e2edelay.awk:77: (FILENAME=simple_aodv.tr FNR=36530) Fatal:division by zero attempted means: the error occured in the line 77 of the script e2edelay.awk, and using the line 36530 of the tracefile. Probably that line contains invalid data, or it has invalid format, I cannot check it.
The code you posted does contain a division in line 77, the error message means the variable count is zero. The variable count is only modified in line 53, but only if the condition in line 49 was true (end_time[i] > 0). Looks like it never happened.
 
Old 02-17-2013, 11:20 AM   #5
NS2User2012
LQ Newbie
 
Registered: Feb 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Yes, there must be an error in the code. It's like you said, in line 77 it want to divide trough 0 and this is what makes the error. I found this .awk script for calculating the average end 2 end delay in the internet. I use it for a wireless scenario, perhaps this .awk script is only for wired scenarios? Can someone give me a working .awk script for calculating the end 2 end delay?
 
  


Reply

Tags
ns2+awk



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 error awk: line 2: missing } near end of file boscop Linux - Networking 2 04-08-2012 10:49 AM
Running a Crafted bash script yelds 'Unexpected end of file' at the end of the file MCLover1337 Linux - General 5 10-15-2011 08:29 AM
insertion of vbr and VBR end end delay more sam1354 Linux - Newbie 1 04-22-2011 04:32 PM
[SOLVED] awk syntax for calculating average and standard deviation vjramana Programming 6 04-21-2011 09:36 AM
Calculating average from Python Script stryker213 Programming 5 04-25-2010 04:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:19 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
Open Source Consulting | Domain Registration