1BEGIN     {
2          # we need the number of bytes in a packet to do the output
3          # in packet numbers rather than byte numbers.
4          if (packetsize <= 0)
5                    packetsize = 512
6          expectNext = 1
7          lastwin = -1
8          }
9          {
10          # convert tcp trace to send/ack form.
11          n = split ($1,t,":")
12          tim = t[1]*3600 + t[2]*60 + t[3]
13          if (NR <= 1) {
14                    tzero = tim
15                    ltim = tim
16                    OFS = "\t"
17          }
18          if ($6 != "ack") {
19                    # we have a data packet record:
20                    # ignore guys with syn, fin or reset 'cause we
21                    # can't handle their sequence numbers.  Try to
22                    # detect and add a flag character for 'anomalies':
23                    #   * -> re-sent packet
24                    #   - -> packet after hole (missing packet(s))
25                    #   # -> odd size packet
26                    if ($5 !~ /[SFR]/) {
27                              i = index($6,":")
28                              j = index($6,"(")
29                              strtSeq = substr($6,1,i-1)
30                              endSeq = substr($6,i+1,j-i-1)
31                              len = endSeq - strtSeq
32                              id = endSeq
33                              if (! timeOf[id])
34                                        timeOf[id] = tim
35                              if (endSeq - expectNext < 0)
36                                        flag = "*"
37                              else {
38                                        if (strtSeq - expectNext > 0)
39                                                  flag = "-"
40                                        else if (len != packetsize)
41                                                  flag = "#"
42                                        else
43                                                  flag = " "
44                                        expectNext = endSeq
45                              }
46                              printf "%7.2f\t%7.2f\t%s send %s %d", tim-tzero, tim-ltim,\
47                                        flag, $5, strtSeq
48                              if (++timesSent[id] > 1)
49                                        printf "  (%.2f) [%d]", tim - timeOf[id], timesSent[id]
50                              if (len != packetsize)
51                                        printf " <%d>", len
52                    }
53          } else {
54                    id = $7
55
56                    printf "%7.2f\t%7.2f\t%s  ack %s %d", tim-tzero, tim-ltim,\
57                              flag, $5, id
58                    if ($9 != lastwin) {
59                              printf "  win %d", $9
60                              lastwin = $9
61                    }
62                    printf "  (%.2f)", tim - timeOf[id]
63                    if (++timesAcked[id] > 1)
64                              printf " [%d]", timesAcked[id]
65          }
66          printf "\n"
67          ltim = tim
68          }
69