[P4-dev] Sending packets to controller - p4runtime

Lewis, Ben b.lewis at lancaster.ac.uk
Fri Feb 1 04:38:48 EST 2019

Hi Vivek,

The @packet_in and @packet_out headers are specified as annotations when writing your P4 header definitions. Make sure your de-parser can emit packet-in headers for the controller and if you’re sending packets back, that you can parse them correctly.

An example I can find on the web is part of the ONOS project’s P4 tutorials "https://github.com/opennetworkinglab/onos/blob/master/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4":
// Packet-in header. Prepended to packets sent to the controller and used to
// carry the original ingress port where the packet was received.
header packet_in_header_t {
bit<9> ingress_port;
// Packet-out header. Prepended to packets received by the controller and used
// to tell the switch on which port this packet should be forwarded.
header packet_out_header_t {
bit<9> egress_port;

If you are struggling with setting up the initial stream to the switch for communication, there is some useful code here https://github.com/opennetworkinglab/fabric-p4test/blob/master/tests/ptf/base_test.py#L261 as well as in the P4Runtime tutorial on https://github.com/p4lang/tutorials/tree/master/exercises/p4runtime The tutorial repo also includes some helper libraries for the P4Runtime which may be helpful with getting started.


On 1 Feb 2019, at 05:32, Vivek Gopalan <vivek.gopalan at yale.edu<mailto:vivek.gopalan at yale.edu>> wrote:

Hi All,
I'm having trouble utilizing p4runtime to send packets from switches to the controller for additional processing. I've come across the packet I/O stream messages & the need to configure it on the controller side however am unable to make much use of the provided documentation. I understand that within the p4 program headers need to be annotated with packet-in / packet-out but am unsure how to set fields for this using the runtime API. Can anyone provide any advice & any tools for receiving controller messages / using packet-in/packet-out within the p4runtime API? Thanks in advance.

P4-dev mailing list
P4-dev at lists.p4.org<mailto:P4-dev at lists.p4.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20190201/2dda2ce1/attachment-0001.html>

More information about the P4-dev mailing list