Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This program is used to calculates the end-to-end delay and jitter of the CBR packets
- BEGIN {
- # Initialization. Set two arrays. start_time and end_time
- start_time[NR] = 0;
- end_time[NR] = 0;
- delay_time[NR] = 0; #will hold the delay time of packet i. we will use it in the end
- last_calc = -1; #temp var for jitter calculation
- }
- {
- 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 (from==1 && action == "+") #new packet was created
- start_time[packet_id]=time;
- if (from==2 && to==3 && type=="cbr" && action == "r") #the packet arrived
- end_time[packet_id]=time;
- }
- END {
- for (i=0;i<NR;i=i+1) #scan all the array's
- {
- if(end_time[i]>0) #if the filed in the array represent cbr packet that arrived than calculate it
- {
- delay_time[i]=end_time[i]-start_time[i];
- printf("time=%f delay=%f\n", start_time[i], delay_time[i])>"outD2.txt";
- if (last_calc>-1)
- printf("time=%f jitter=%f\n", start_time[i], delay_time[i]-delay_time[last_calc])>"outJ2.txt";
- last_calc=i;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement