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