117680SpstBEGIN	{
217680Spst	# we need to know (usual) packet size to convert byte numbers
317680Spst	# to packet numbers
417680Spst	if (packetsize <= 0)
517680Spst		packetsize = 512
617680Spst	}
717680Spst$5 !~ /[SR]/	{
817680Spst	# print out per-packet data in the form:
917680Spst	#  <packet #>
1017680Spst	#  <start sequence #>
1117680Spst	#  <1st send time>
1217680Spst	#  <last send time>
1317680Spst	#  <1st ack time>
1417680Spst	#  <last ack time>
1517680Spst	#  <# sends>
1617680Spst	#  <# acks>
1717680Spst
1817680Spst	n = split ($1,t,":")
1917680Spst	tim = t[1]*3600 + t[2]*60 + t[3]
2017680Spst	if ($6 != "ack") {
2117680Spst		i = index($6,":")
2217680Spst		strtSeq = substr($6,1,i-1)
2317680Spst		id = 1.5 + (strtSeq - 1) / packetsize
2417680Spst		id -= id % 1
2517680Spst		if (maxId < id)
2617680Spst			maxId = id
2717680Spst		if (firstSend[id] == 0) {
2817680Spst			firstSend[id] = tim
2917680Spst			seqNo[id] = strtSeq
3017680Spst		}
3117680Spst		lastSend[id] = tim
3217680Spst		timesSent[id]++
3317680Spst		totalPackets++
3417680Spst	} else {
3517680Spst		id = 1 + ($7 - 2) / packetsize
3617680Spst		id -= id % 1
3717680Spst		timesAcked[id]++
3817680Spst		if (firstAck[id] == 0)
3917680Spst			firstAck[id] = tim
4017680Spst		lastAck[id] = tim
4117680Spst		totalAcks++
4217680Spst	}
4317680Spst	}
4417680SpstEND	{
4517680Spst	print "# " maxId " chunks.  " totalPackets " packets sent.  " \
4617680Spst		totalAcks " acks."
4717680Spst	# for packets that were implicitly acked, make the ack time
4817680Spst	# be the ack time of next explicitly acked packet.
4917680Spst	for (i = maxId-1; i > 0; --i)
5017680Spst		while (i > 0 && firstAck[i] == 0) {
5117680Spst			lastAck[i] = firstAck[i] = firstAck[i+1]
5217680Spst			--i
5317680Spst		}
5417680Spst	tzero = firstSend[1]
5517680Spst	for (i = 1; i <= maxId; i++)
5617680Spst		printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\
5717680Spst			i, seqNo[i], \
5817680Spst			firstSend[i] - tzero, lastSend[i] - tzero,\
5917680Spst			firstAck[i] - tzero, lastAck[i] - tzero,\
6017680Spst			timesSent[i], timesAcked[i]
6117680Spst	}
62