首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ipv6扩展头

ipv6扩展头
EN

Stack Overflow用户
提问于 2015-11-29 23:56:55
回答 1查看 1.5K关注 0票数 2

我正在尝试使用dpkt从packet中获取ipv6扩展头并打印出来。但出于某种原因,它不起作用。我尝试过许多不同的方法。下面是导致问题的部分代码。有没有人知道怎么解决这个问题?关于ipv6的dpkt缺乏示例代码

代码语言:javascript
复制
    # 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 wireshark包

EN

回答 1

Stack Overflow用户

发布于 2015-12-01 20:26:35

我发现了这个问题,这与我正在使用的版本有关。我更新了版本,问题解决了。

问候

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33989586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档