Hi All,

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.


In reply to Re^2: Program Hangs by anbarasans85
in thread Program Hangs by anbarasans85

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.