How to verify the functions of my P4 program?
hello, everyone!
I have suceed running my P4 program on simple_switch, but I have no idea how to verify the function. Specifically, I do not know how to send packet to the ports of simple_switch in runtime, also how to capture the packet from the output port. I appreciate your help!
This README walks through using Scapy to construct and send packets to a running simple_switch process, and how to run one tcpdump process per output port to show the contents of packets that are sent to those ports. You can also run tcpdump to record packets to a pcap file, rather than showing them 'live' as they appear on the ports, depending upon your preference.
https://github.com/jafingerhut/p4-guide/blob/master/demo1/README.md
The methods described in that document are reasonable for interactive testing of a P4 program. They are not intended for automated testing of a P4 program without human interaction. Tools like PTF can better serve that purpose, if that is what you want to do: https://github.com/p4lang/ptf. But I would recommend the interactive method first if you are just starting out testing a P4 program.
many many thanks ! I will try tomorrow!
@jafingerhut I see the README mentioned above. Now I have another question. For the function 'sendp(pkt, intf)', the pkt will be the input of the intf or the output of it. If the pkt is the output of the intf, how can this pkt be sent to the ingress path of the P4 simple_switch?
When you follow the directions in that README, the sendp() will cause the packet to be sent to the indicated 'veth
Please follow below steps in order the test your p4 program using simple switch:-
- create your on p4 pipeline.
- Compile it using p4c.
- Start simple_switch with number of veth interfaces along your p4 pipeline.
- Add the rules in your routing table.
- And then run the traffic on the veth ingress interfaces.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment, or this will be closed in 180 days