Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 1.14 KB | None | 0 0
  1. #This program is used to calculates the end-to-end delay and jitter of the CBR packets
  2.  
  3. BEGIN {
  4. # Initialization. Set two arrays. start_time and end_time
  5.     start_time[NR] = 0;
  6.     end_time[NR] = 0;
  7.     delay_time[NR] = 0; #will hold the delay time of packet i. we will use it in the end
  8.     last_calc = -1;     #temp var for jitter calculation
  9. }
  10. {
  11.    action = $1;
  12.    time = $2;
  13.    from = $3;
  14.    to = $4;
  15.    type = $5;
  16.    pktsize = $6;
  17.    flow_id = $8;
  18.    src = $9;
  19.    dst = $10;
  20.    seq_no = $11;
  21.    packet_id = $12;
  22.  
  23.     if (from==1 && action == "+")               #new packet was created
  24.         start_time[packet_id]=time;
  25.     if (from==2 && to==3 && type=="cbr" && action == "r")   #the packet arrived
  26.         end_time[packet_id]=time;
  27. }
  28. END {
  29.     for (i=0;i<NR;i=i+1)        #scan all the array's
  30.     {
  31.             if(end_time[i]>0)   #if the filed in the array represent cbr packet that arrived than calculate it
  32.             {
  33.                 delay_time[i]=end_time[i]-start_time[i];
  34.                 printf("time=%f delay=%f\n", start_time[i], delay_time[i])>"outD2.txt";
  35.                 if (last_calc>-1)  
  36.                     printf("time=%f jitter=%f\n", start_time[i], delay_time[i]-delay_time[last_calc])>"outJ2.txt";
  37.                 last_calc=i;
  38.             }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement