<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div style="text-align: left;" class="">Hi Vivek,</div>
<div style="text-align: left;" class=""><br class="">
</div>
<div style="text-align: left;" class="">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. </div>
<div style="text-align: left;" class=""><br class="">
</div>
<div style="text-align: left;" class="">An example I can find on the web is part of the ONOS project’s P4 tutorials "<a href="https://github.com/opennetworkinglab/onos/blob/master/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4" class="">https://github.com/opennetworkinglab/onos/blob/master/apps/p4-tutorial/pipeconf/src/main/resources/mytunnel.p4</a>":</div>
<div class="">
<div class="">// Packet-in header. Prepended to packets sent to the controller and used to</div>
<div class="">// carry the original ingress port where the packet was received.</div>
<div class="">@controller_header("packet_in")</div>
<div class="">header packet_in_header_t {</div>
<div class="">bit<9> ingress_port;</div>
<div class="">}</div>
<div class="">// Packet-out header. Prepended to packets received by the controller and used</div>
<div class="">// to tell the switch on which port this packet should be forwarded.</div>
<div class="">@controller_header("packet_out")</div>
<div class="">header packet_out_header_t {</div>
<div class="">bit<9> egress_port;</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">If you are struggling with setting up the initial stream to the switch for communication, there is some useful code here <a href="https://github.com/opennetworkinglab/fabric-p4test/blob/master/tests/ptf/base_test.py#L261" class="">https://github.com/opennetworkinglab/fabric-p4test/blob/master/tests/ptf/base_test.py#L261</a> as
 well as in the P4Runtime tutorial on <a href="https://github.com/p4lang/tutorials/tree/master/exercises/p4runtime" class="">https://github.com/p4lang/tutorials/tree/master/exercises/p4runtime</a> The tutorial repo also includes some helper libraries for the
 P4Runtime which may be helpful with getting started. </div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Ben</div>
<table class="js-file-line-container highlight tab-size" data-tab-size="8" style="text-align: center;">
<tbody class="">
<tr class="">
<td id="LC79" class="js-file-line blob-code-inner blob-code" style="text-align: left;">
</td>
</tr>
<tr class="">
</tr>
</tbody>
</table>
<div class=""><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 1 Feb 2019, at 05:32, Vivek Gopalan <<a href="mailto:vivek.gopalan@yale.edu" class="">vivek.gopalan@yale.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi All,
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">Vivek</div>
</div>
_______________________________________________<br class="">
P4-dev mailing list<br class="">
<a href="mailto:P4-dev@lists.p4.org" class="">P4-dev@lists.p4.org</a><br class="">
http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>