#!/usr/bin/python
import impacket, pcapy, re, sys
-import impacket.ImpactDecoder
+import impacket.ImpactDecoder, impacket.ImpactPacket
start_time = None
self.times = []
self.transfer_count = 0
Connection.counter += 1
+ self.last_id = 0
+ self.winscale = {1: 0, -1: 0}
def finish_transfer(self):
if len(self.times) > 0:
else:
direction = 0
+ for o in tcp.get_options():
+ if o.get_kind() == o.TCPOPT_WINDOW:
+ self.winscale[direction] = o.get_shift_cnt()
+ print "window scale for dir %d is %d" % (direction,
+ o.get_shift_cnt())
+
+ if direction < 0:
+ gap = (ip.get_ip_id() - self.last_id) & 0xffff
+ if 1 < gap < 256:
+ print "Gap of", gap, "packets on connection", self.endpoints
+ self.last_id = ip.get_ip_id()
+
seq = (tcp.get_th_seq(), tcp.get_th_seq() + datalen)
ack = tcp.get_th_ack()
self.times.append(((timestamp - self.starttime) / 1e6,
seq[1] - self.respseq))
+ if self.id == 21:
+ winsize = tcp.get_th_win()
+ if not tcp.get_SYN():
+ winsize <<= self.winscale[direction]
+ print "got packet, data=%d win=%d" % (datalen, winsize)
+
def handler(header, data):
global start_time
global pkt