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! |
yes, probably the awk script is not perfect, or maybe the datafile has been corrupted.
|
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"; } |
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. |
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?
|
All times are GMT -5. The time now is 02:10 PM. |