你应该使用Packet.haslayer('ICMPv6ND_NS')
...
>>> from scapy.all import rdpcap
>>> paks = rdpcap('ipv6.pcap')
>>> for idx, pak in enumerate(paks):
... if pak.haslayer('ICMPv6ND_NS'):
... print "Index %s: %s" % (idx, repr(pak))
...
Index 3: <Ether dst=00:21:a0:50:ce:00 src=00:02:55:7b:b2:f6 type=0x86dd |
<IPv6 version=6L tc=0L fl=0L plen=32 nh=ICMPv6 hlim=255
src=fe80::202:55ff:fe7b:b2f6 dst=fe80::221:a0ff:fe50:ce00 |
<ICMPv6ND_NS type=Neighbor Solicitation code=0 cksum=0x8b54 R=0L S=0L
O=0L res=0x0L tgt=fe80::221:a0ff:fe50:ce00 |<ICMPv6NDOptSrcLLAddr type=1
len=1 lladdr=00:02:55:7b:b2:f6 |>>>>
>>>
仅供参考,这些是 ipv6.pcap 中的数据包...
[mpenning@Bucksnort ~]$ tshark -r ipv6.pcap
1 0.000000 2000:fc50:1000:100:202:55ff:fe7b:b2f6 -> 2001:420:1101:1::a ICMPv6 Echo request
2 1.007475 2000:fc50:1000:100:202:55ff:fe7b:b2f6 -> 2001:420:1101:1::a ICMPv6 Echo request
3 2.014461 2000:fc50:1000:100:202:55ff:fe7b:b2f6 -> 2001:420:1101:1::a ICMPv6 Echo request
4 4.997348 fe80::202:55ff:fe7b:b2f6 -> fe80::221:a0ff:fe50:ce00 ICMPv6 Neighbor solicitation
5 4.998613 fe80::221:a0ff:fe50:ce00 -> fe80::202:55ff:fe7b:b2f6 ICMPv6 Neighbor advertisement
[mpenning@Bucksnort ~]$