[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] how to reduce processing cost of an awk script ... or a different problem?



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); 
}

==================================================
�츮 ���ͳ�, Daum
��� ���� ���� E-mail �ּ� �Ѹ��ϳ�
������ �ѱ� �˻����� Daum FIREBALL
NO SPAM ķ����! : http://www.daum.net/event/nospam
http://www.daum.net