[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] how to reduce processing cost of an awk script ... or a different problem?
okay, these are only my 2c; but I think it should make it consumme less memory.
How much less is another issue...
e2e delay?
you can further reduce the file size by deleting events at intermediate nodes.
You can also have awk take a little bit less of memory, I think, by using
if (!(packet_id in start_time))
instead of
if (start_time[packet_id] == 0)
and then
for (packet_id in start_time) {
...
}
Also, if you are not using node_1_address, node_2_address, fid_; well no need to
allocate them.
>Hi,
>
>I am trying to calculate total packet delay(ms) and drop rate(%) of 5 flows on
a link using awk script...since the size of the tracefile is enormous, I have
filtered it to print only lines with ($1 == d || $1 == r)..
>
>My problem is that, despite the filtering, a memory allocation error occurs
when I run awk script:
>awk -f NCmyawkscript out_scenario1.tr > result1
>awk: NCmyawkscript:12: (FILENAME=out_scenario1.tr FNR=890944) fatal: newnode:
nextfree: can't allocate memory
>
>As it is quite impossible to make the tracefile any shorter, I think I should
modify my awk script (i.e. to reduce processing cost) but I can't figure out any
other methods to compute delay and drop rate than the ones I have already
used(shown below)..could anyone plz help me out on this? (it suddenly occurs to
me that it might even be a totally different problem from memory shortage)
>
>I would appreciate your help very much..thanks in advance!
>
>
>******* NCmyawkscript *******
>BEGIN {
># awk script to compute total packet loss (%) and average delay (ms)
>highest_packet_id = 0; total_duration = 0;
>num_drop = 0; num_rcvd = 0;
>}
>
>{
>action = $1;
>time = $2;
>node_1 = $3;
>node_2 = $4;
>src = $5;
>flow_id = $8;
>node_1_address = $9;
>node_2_address = $10;
>seq_no = $11;
>packet_id = $12;
>
>
>if ( packet_id > highest_packet_id ) highest_packet_id = packet_id;
>
># assume you're not starting
># traffic at 0.0.
>if ( start_time[packet_id] == 0 ) start_time[packet_id] = time;
>
># only useful for small unicast where packet_id doesn't wrap.
># checking receive means avoiding recording drops
>if ( action != "d" ) {
>if ( action == "r" ) {
># could test for receiving node_2_address or flow_id here.
>num_rcvd = num_rcvd + 1;
>end_time[packet_id] = time;
>}
>} else {
>num_drop = num_drop + 1;
>end_time[packet_id] = -1;
>}
>}
>END {
>for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) {
>start = start_time[packet_id];
>end = end_time[packet_id];
>packet_duration = end - start;
>if ( start < end ) total_duration = total_duration + packet_duration;
>}
>printf("Packet Loss = %.6f \% \n", (num_drop/(highest_packet_id+1))*100);
>printf("Average Delay = %.6f ms \n", total_duration/num_rcvd);
>}
>
-Tarik