我正在使用Scapy在网络中发送数据包,下面是发送数据包的代码:
for i in xrange(1000):
packets = Ether() / IP(dst = generateDestinationIP (start, end), src = generateSourceIP ()) / UDP(dport = 80, sport = 2)
print(repr(packets))
#rstrip() strips whitespace characters from the end of interface
sendp(packets, iface = interface.rstrip(), inter = 0.1)
现在,我要测量Src_byes和Dst_bytes(在单个连接中从目标传输到源的数据字节数,反之亦然)。另外,我想计算过去两秒内与当前连接相同的端口号的连接数。我该怎么办?