python-2.7bindinglayerscapyieee

Binding custom layers in scapy


I have a python script which assembles and sends AVB (IEEE) packets into a network. The packets will be captured by wireshark. With an other python script I iterate through the capture file. But I can't access a few parameters in a few layers because scapy doesn't know them. So I have to add those layers to scapy.

Here's the packet in wireshark: enter image description here

I added the following code to the file "python2.7/dist-packages/scapy/layers/l2.py"

class ieee(Packet):
  name = "IEEE 1722 Packet"
  fields_desc=[ XByteField("subtype", 0x00),
                XByteField("svfield", 0x81),
                XByteField("verfield", 0x81)]

bind_layers(Dot1Q, ieee1722, type=0x22f0)

When I execute the python script which should grab the parameters in the new layer (IEEE 1722 Protocol), the following error occurs: "IndexError: Layer [ieee1722] not found"

What's wrong?


Solution

  • Ok, found the solution by editing the type value:

      bind_layers(Dot1Q, ieee1722, type=0x88f7) ---> works
    

    Dot1Q is the layer above the created ieee1722 layer (see wireshark). You can see the type value by clicking at the layer of a packet in wireshark.