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