Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / tcpdump / examples / | server ip : 104.21.89.46 your ip : 108.162.241.149 H O M E |
Filename | /usr/share/doc/tcpdump/examples/packetdat.awk |
Size | 1.39 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:55 |
Last modified | 08-Nov-2013 07:22 |
Last accessed | 07-Jul-2025 15:11 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
BEGIN {
# we need to know (usual) packet size to convert byte numbers
# to packet numbers
if (packetsize <= 0)
packetsize = 512
}
$5 !~ /[SR]/ {
# print out per-packet data in the form:
# <packet #>
# <start sequence #>
# <1st send time>
# <last send time>
# <1st ack time>
# <last ack time>
# <# sends>
# <# acks>
n = split ($1,t,":")
tim = t[1]*3600 + t[2]*60 + t[3]
if ($6 != "ack") {
i = index($6,":")
strtSeq = substr($6,1,i-1)
id = 1.5 + (strtSeq - 1) / packetsize
id -= id % 1
if (maxId < id)
maxId = id
if (firstSend[id] == 0) {
firstSend[id] = tim
seqNo[id] = strtSeq
}
lastSend[id] = tim
timesSent[id]++
totalPackets++
} else {
id = 1 + ($7 - 2) / packetsize
id -= id % 1
timesAcked[id]++
if (firstAck[id] == 0)
firstAck[id] = tim
lastAck[id] = tim
totalAcks++
}
}
END {
print "# " maxId " chunks. " totalPackets " packets sent. " \
totalAcks " acks."
# for packets that were implicitly acked, make the ack time
# be the ack time of next explicitly acked packet.
for (i = maxId-1; i > 0; --i)
while (i > 0 && firstAck[i] == 0) {
lastAck[i] = firstAck[i] = firstAck[i+1]
--i
}
tzero = firstSend[1]
for (i = 1; i <= maxId; i++)
printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\
i, seqNo[i], \
firstSend[i] - tzero, lastSend[i] - tzero,\
firstAck[i] - tzero, lastAck[i] - tzero,\
timesSent[i], timesAcked[i]
}
# we need to know (usual) packet size to convert byte numbers
# to packet numbers
if (packetsize <= 0)
packetsize = 512
}
$5 !~ /[SR]/ {
# print out per-packet data in the form:
# <packet #>
# <start sequence #>
# <1st send time>
# <last send time>
# <1st ack time>
# <last ack time>
# <# sends>
# <# acks>
n = split ($1,t,":")
tim = t[1]*3600 + t[2]*60 + t[3]
if ($6 != "ack") {
i = index($6,":")
strtSeq = substr($6,1,i-1)
id = 1.5 + (strtSeq - 1) / packetsize
id -= id % 1
if (maxId < id)
maxId = id
if (firstSend[id] == 0) {
firstSend[id] = tim
seqNo[id] = strtSeq
}
lastSend[id] = tim
timesSent[id]++
totalPackets++
} else {
id = 1 + ($7 - 2) / packetsize
id -= id % 1
timesAcked[id]++
if (firstAck[id] == 0)
firstAck[id] = tim
lastAck[id] = tim
totalAcks++
}
}
END {
print "# " maxId " chunks. " totalPackets " packets sent. " \
totalAcks " acks."
# for packets that were implicitly acked, make the ack time
# be the ack time of next explicitly acked packet.
for (i = maxId-1; i > 0; --i)
while (i > 0 && firstAck[i] == 0) {
lastAck[i] = firstAck[i] = firstAck[i+1]
--i
}
tzero = firstSend[1]
for (i = 1; i <= maxId; i++)
printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\
i, seqNo[i], \
firstSend[i] - tzero, lastSend[i] - tzero,\
firstAck[i] - tzero, lastAck[i] - tzero,\
timesSent[i], timesAcked[i]
}