Hi ns2 users,

I created my AWK-Script by copying a lof from other scrips.
So I created propably my own faiture.
It would be nice if someone could show me my mistake.

I get datas like this:
...
+ 0.2 0 2 ra 210 ------- 0 0.0 4.0 -1 8
- 0.2 0 2 ra 210 ------- 0 0.0 4.0 -1 8
+ 0.2 0 2 ra 210 ------- 0 0.0 4.0 -1 9
+ 0.2 1 2 cbr 1000 ------- 2 1.0 5.0 0 10
- 0.2 1 2 cbr 1000 ------- 2 1.0 5.0 0 10
+ 0.2 1 2 cbr 1000 ------- 2 1.0 5.0 1 11
...

and here is my AKW Script following, with this I like to calculate the Delay of 
the CBR Data
If I set  " if ( action == "r" && flow_id == 2 ) " to " if ( action == "r" && 
flow_id == 0 ) "
It works without problems by calculating delay for the RealAudio Applikation. 

BEGIN {
    highest_packet_id = 0;
    highest_packet_duration = 0;
    lowest_packet_duration = 9;
    hpd = 0;
    lpd = 0;
    apd = 0;
    i = 0;
}
{
   action = $1;
   time = $2;
   from = $3;
   to = $4;
   type = $5;
   pktsize = $6;
   flow_id = $8;
   src = $9;
   dst = $10;
   seq_no = $11;
   packet_id = $12;
 
   if ( packet_id > highest_packet_id )
         highest_packet_id = packet_id;
 
   if ( start_time[packet_id] == 0 ) 
        start_time[packet_id] = time;
 
   if ( action == "r" && flow_id == 2 ) {
        end_time[packet_id] = time;
    } 
    else {
          end_time[packet_id] = -1;
   }
} 
END {
    #printf("packet_id | type | start | end | packet_duration\n")

    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 ( packet_duration > highest_packet_duration )
        highest_packet_duration = packet_duration;
    if ( lowest_packet_duration > packet_duration && packet_duration > 0 )
        lowest_packet_duration = packet_duration;
    hpd = highest_packet_duration;# / i;
    lpd = lowest_packet_duration;# / i;
    apd = packet_duration;# / i;

   }    if (start < end ) printf("%f %f %f\n", hpd, lpd, apd );
}

thanks for helt
best regards Tom



      

Reply via email to