0

How can you get a list of vlans if you have more than one, for example if i have this packet..

Layer ETH:
    Destination: 00:99:88:77:66:55 (00:99:88:77:66:55)
    .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Address: 00:99:88:77:66:55 (00:99:88:77:66:55)
    .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: 802.1Q Virtual LAN (0x8100)
    Source: 00:11:22:33:44:55 (00:11:22:33:44:55)
    .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Address: 00:11:22:33:44:55 (00:11:22:33:44:55)
    .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Layer VLAN:
    ...0 .... .... .... = CFI: Canonical (0)
    000. .... .... .... = Priority: Best Effort (default) (0)
    .... 0000 1100 1000 = ID: 200
    Type: 802.1Q Virtual LAN (0x8100)
Layer VLAN:
    Trailer: 8dbdde29
    ...0 .... .... .... = CFI: Canonical (0)
    000. .... .... .... = Priority: Best Effort (default) (0)
    .... 0000 0110 0100 = ID: 100
    Type: IP (0x0800)
Layer IP:
    ....
Layer UDP:
    ....

if I use pyshark i got only inner vlan.

>>> print cap[0]['vlan']
Layer VLAN:
    ...0 .... .... .... = CFI: Canonical (0)
    000. .... .... .... = Priority: Best Effort (default) (0)
    .... 0000 1100 1000 = ID: 200
    Type: 802.1Q Virtual LAN (0x8100)

I expect to get it the same as tshark :

tshark -r filename.pcap -T fields -e vlan.id

100,200
4

1 回答 1

0

在 github 上管理此讨论:https ://github.com/KimiNewt/pyshark/issues/80

获得双vlan的简单方法是:

vlan1, vlan2 = pkt[1], pkt[2]

或明确:

vlan1, vlan2 = pkt.layers[1], pkt.layers[2]
于 2016-01-24T14:07:39.843 回答