in reply to Re: Program Hangs
in thread Program Hangs
The program is working fine. I modified it using PERL hash. It is fast and I am happy.
This is a very late reply but I thought i can share what I did.
The logic is:
1. Look for AGT events. Then make a hash key by combining event 's' or 'r' with packet id. ( hash_key = s<pktid> or r<pktid>) and store the corresponding time as hash value)
2. The above runs through all lines of the trace file and build hashtable.
3. then calculate delay for every packet_id.
while(<DATA>) { @x=split(' '); if($x[3] eq 'AGT') { $hash_key = $x[0].$x[5]; $hash_value = $x[1]; $hash_table{"$hash_key"} = $hash_value; if($x[5] gt $last_packet_id) { $last_packet_id = $x[5]; } } } $simulation_time = $x[1]; for($packet_id = 0;$packet_id<=$last_packet_id;$packet_id++) { $hash_key = "s".$packet_id; $enqueue_time = $hash_table{"$hash_key"}; $total_enqueue_count++; $hash_key = "r".$packet_id; if(exists($hash_table{$hash_key})) { $receive_time = $hash_table{"$hash_key"}; } else { $total_drop_count++; next; } $total_receive_count++; $delay = $receive_time - $enqueue_time; $sum_of_delay = $sum_of_delay + $delay; # $delay = $delay * 1000; # print("\nDelay:$delay"); }
Thanks a lot for your help.
|
---|