Python dpkt ipv6扩展头
我正在尝试使用dpkt从pcap数据包中获取ipv6扩展头并将其打印出来。但由于某种原因,它没有起作用。我试过很多不同的方法。下面是导致问题的代码部分。有人知道如何解决这个问题吗? p、 s缺少关于ipv6的dpkt的示例代码Python dpkt ipv6扩展头,python,parsing,wireshark,pcap,dpkt,Python,Parsing,Wireshark,Pcap,Dpkt,我正在尝试使用dpkt从pcap数据包中获取ipv6扩展头并将其打印出来。但由于某种原因,它没有起作用。我试过很多不同的方法。下面是导致问题的代码部分。有人知道如何解决这个问题吗? p、 s缺少关于ipv6的dpkt的示例代码 # For each packet in the pcap process the contents for ts, buf in pcap: # Unpack the Ethernet frame (mac src/dst, ether
# For each packet in the pcap process the contents
for ts, buf in pcap:
# Unpack the Ethernet frame (mac src/dst, ethertype)
eth = dpkt.ethernet.Ethernet(buf)
# Make sure the Ethernet frame contains an IP packet
# EtherType (IP, ARP, PPPoE, IP6... see http://en.wikipedia.org/wiki/EtherType)
if eth.type != dpkt.ethernet.ETH_TYPE_IP6:
print 'Non IP Packet type not supported %s\n' % eth.data.__class__.__name__
continue
# Now unpack the data within the Ethernet frame (the IP packet)
# Pulling out src, dst, length, fragment info, TTL, and Protocol
ipv6 = eth.data
fh = dpkt.ip.IP_PROTO_FRAGMENT
ic = dpkt.ip.IP_PROTO_ICMP6
icmpv6 = ipv6.data
# get src and dst ip address
src_ip = socket.inet_ntop(AF_INET6, ipv6.src)
dst_ip = socket.inet_ntop(AF_INET6, ipv6.dst)
# Analyzing pcap file offline
#if packet.haslayer(IPv6) and pkt[IPv6].nh == 44 and dpkt.ip6.IP6FragmentHeader.nxt==60 and dpkt.ip6.IP6HopOptsHeader.nxt == 58:
if ipv6.v == 6 and ipv6.nxt==44:
print ipv6.IP6FragmentHeader.nxt
更新:当我使用dpkt.ip6.IP6FragmentHeader时,我得到了这个错误
AttributeError:“str”对象没有属性“IP6FragmentHeader”
我想从这个数据包(ICMPv6)中获取碎片头
我发现了问题,它与我正在使用的版本有关。我已经更新了版本,问题已经解决 问候