File: rtts.awk

package info (click to toggle)
ns2 2.35%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 79,396 kB
  • sloc: cpp: 172,923; tcl: 107,167; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 829; awk: 525; csh: 355
file content (40 lines) | stat: -rw-r--r-- 986 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This prints the RTT in seconds, and the fraction of packets with that RTT.
# Input file:
###########################################
# Distribution of RTTs, 10 ms bins
# 0 to 10 ms: fraction 0.003 number 488
# 160 to 170 ms: fraction 0.000 number 80
###########################################
{
if (NR==1) {
   thisbin = 0;
   binsize = 0;
   maxbin = 200;
}
if ($1=="Distribution"&&$3=="RTTs,") {
  binsize = $4;
  halfbin = binsize / 2;
}
if (binsize > 0) {
  if ($2=="to"&&$4=="ms:") {
     bin = $3;
     frac = $6;
     if (bin > 0) {
       for (i=thisbin; i<bin; i += binsize) {
    	 avertt = (i-halfbin)/1000; 
    	 if (avertt < 0) avertt = 0;
    	 printf "%4.3f 0.0\n", avertt;
       }
       avertt = (bin - halfbin)/1000;
       if (avertt < 0) avertt = 0;
       printf "%4.3f %5.3f\n", avertt, frac;
       thisbin = bin + binsize;
    }
  }
}
}
END{
  for (i=thisbin; i<=maxbin; i += binsize) {
     avertt = (i-halfbin)/1000;
     printf "%4.3f 0.0\n", avertt;
}}