示例#1
0
文件: __init__.py 项目: 09beeihaq/pox
  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
示例#2
0
  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
示例#3
0
 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
示例#4
0
文件: __init__.py 项目: 09beeihaq/pox
 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