I am attempting to use Scapy to simulate an external server and send packets to a switch running within the Open P4 Studio (Tofino Model) environment. However, I am encountering two main issues that are preventing any traffic from reaching the switch, as indicated by the consistently zero RX/TX counters.
1. Scapy Packet Sending Failure (OSError: No such device)
I am running Scapy from a new terminal session (outside of the SDE’s specific shells) and attempting to send a packet to one of the virtual interfaces. The operation fails with an OSError: [Errno 19] No such device.
Attempted Command Example:
Python
p = Ether()/IP(dst="12.12.1.1")/UDP()
sendp(p, iface="veth1")
# Also tried with other veth interfaces, e.g., veth30
Error Encountered:
>>> sendp(p, iface="veth30")
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
...
OSError: [Errno 19] No such device
This error indicates that the network interface (e.g., veth30) is not recognized in the context where Scapy is running.
2. Interface Addition Failure During Model Startup
During the startup of the Tofino Model, the log shows repeated failures to add the virtual interfaces (veth*) to the switch ports:
Startup Log Snippet:
Adding interface veth0 as port 8
bmi_port_interface_add failed for port 8.
Adding interface veth2 as port 9
bmi_port_interface_add failed for port 9.
... (All veth interfaces failed)
Even though the port management (pm) interface inside P4 Studio shows the administrative and operational status of all ports (e.g., Port 1/0, 1/1, …, 33/3) as UP/ENB, the FRAMES RX/TX counters all remain at 0.
Questions
-
Scapy Context and Permissions: What is the correct methodology for injecting packets using Scapy into the Tofino Model environment?
-
Do I need to run Scapy from within the
bf_pythonshell or a specific SDE shell? -
Is it a permissions issue, and should I be running Scapy with
sudoto access thesevethinterfaces?
-
-
Root Cause of
bmi_port_interface_add failed: Is this error the fundamental reason why traffic cannot reach the switch? How can I ensure thevethinterfaces are properly created and successfully bound to the Tofino Model ports? Is this an issue with my test environment setup (e.g., netns/ip link configuration) or the model’s startup script?
Any guidance on the proper workflow and setup for external traffic generation against a Tofino model running in Open P4 Studio would be greatly appreciated. Thank you!