Search code examples
pythonipwiresharkscapyethernet

Why is the Priority Code Point (PCP) not modified within an IP packet using Scapy?


I am trying to do an application to generate traffic that includes a priority field. To do this, I want to include the 802.1Q tag within the Ethernet Frame and modify its PCP field. I generate and send the packet as follows:

pkt = IP(dst = "172.24.100.61")/Dot1Q(prio = 7)
send(pkt, iface='eth0')

The problem is that when I capture the traffic with Wireshark and check the Ethernet header fields, the 802.1Q tag does not appear:

Wireshark output

I understand that 802.1Q is related with Layer 2 of the TCP/IP stack and I am sending an IP packet but, why isn't the change reflected in Wireshark?

P.D: When I create an Ethernet frame and send it with the sendp instruction, the change is reflected, but I need to create an IP packet.


Solution

  • The layer Dot1Q is between the layer Ether and IP. in you case, the send is adding the Ether layer for you and send it to the interface.

    The following code work for me (meaning the wireshark doesn't complains).

    from scapy.all import send
    from scapy.layers.inet import IP
    from scapy.layers.l2 import Dot1Q
    
    pkt =  Dot1Q(prio = 7) /IP(dst = "172.24.100.61")
    send(pkt, iface='eth0')