Hi, I am new to p4. I want to add a pmu layer to scapy in python(sender and receiver), and use p4 switch to process the packet.
I was able to send the packet with custom layer, but when i received the packet. The layer is shown Raw. I am not sure is something wrong with my receiver.py or parser in p4. Can someone help me with this issue? Thank you!
Left is Receiver and right is sender
Welcome to the forum!
Before I attempt to help you, please understand that this Forum is dedicated to P4 language, whereas it looks to me that you have a question about Scapy. In fact, you pretty much indicated this yourself in the subject line. While we do have plenty of people here who know Scapy and use it often, this is not the subject of this Forum.
Another important point is that when you are asking a question (and especially when you want to find out why some code does not behave correctly at runtime), you should at least provide all the source code so that people can recreate your issue. In your particular case, you neglected to provide:
- The Scapy code, where you defined the custom
- The code for your send and receive scripts
- The full code for your P4 program
- The configuration of your P4 tables and other objects
This is not a very good way to start, isn’t it?
As for your specific problem, you need to make sure that the byte stream can be correctly decoded, meaning that Scapy knows what should be parsed after the UDP layer. Typically this is done by calling the function
bind_layers(). There might be other issues, but that would be the first thing I’d check.
I am not sure why would you suspect your P4 program as long as you know that you received the correct packet and it was simply not correctly decoded by Scapy.