def _thread_func (self): while not self._quitting: pcapc.dispatch(self.pcap,100,self.callback,self) self.packets_received,self.packets_dropped = pcapc.stats(self.pcap) self._quitting = False self._thread = None
def _thread_func (self): while not self._quitting: pcapc.dispatch(self.pcap,100,self.callback,self,bool(self.use_bytearray),True) self.packets_received,self.packets_dropped = pcapc.stats(self.pcap) self._quitting = False self._thread = None
def cb(obj, data, sec, usec, length): global drop, total, bytes_got, bytes_real, bytes_diff #print ">>>",data t, d = pcapc.stats(obj.pcap) bytes_got += len(data) bytes_real += length nbd = bytes_real - bytes_got if nbd != bytes_diff: bytes_diff = nbd print "lost bytes:", nbd if t > total: total = t + 500 print t, "total" if d > drop: drop = d print d, "dropped" p = pkt.ethernet(data) ip = p.find('ipv4') if ip: print ip.srcip, "\t", ip.dstip, p
def cb (obj, data, sec, usec, length): global drop,total,bytes_got,bytes_real,bytes_diff #print ">>>",data t,d = pcapc.stats(obj.pcap) bytes_got += len(data) bytes_real += length nbd = bytes_real - bytes_got if nbd != bytes_diff: bytes_diff = nbd print "lost bytes:",nbd if t > total: total = t + 500 print t,"total" if d > drop: drop = d print d, "dropped" p = pkt.ethernet(data) ip = p.find('ipv4') if ip: print ip.srcip,"\t",ip.dstip, p