def build_packet(self, src_mac, dst_mac, src_ip, dst_ip, src_port, dst_port, seq, proto):
eth = Ether(src=src_mac, dst=dst_mac, type=0x800)
if proto == IP:
ip = IP(src=src_ip, dst=dst_ip)
elif proto == IPv6:
ip = IPv6(src=src_ip, dst=dst_ip)
else:
return str(eth) #if unknown L2 protocol, send back dud ether packet
tcp = TCP(sport=src_port, dport=dst_port, seq=seq, flags="R")
return str(eth/ip/tcp)
评论列表
文章目录