[P4-dev] A variable in the header

Andy Fingerhut andy.fingerhut at gmail.com
Tue Nov 21 16:55:35 EST 2017


P4_14 and P4_16 languages have the notion of a header stack, which is close
to the idea of an array in other languages.

As long as you can pick a maximum value for 'n' in your example that you
can live with, and compile with that maximum allowed value into your
program, the P4 language can implement that.

There are several examples of using P4 for Inband Network Telemetry (INT)
that have a similar header, with not only a switch id recorded in the
header at each switch, but also statistics like the current queue depth of
the queue that the packet went through, or a timestamp when the packet
arrived at or left that device.  You should be able to find some examples
of this in the repository https://github.com/p4lang/tutorials, but I don't
have a recommendation of which particular program to look at first in
there, although pick the most recent ones if you are interested in P4_16
source code, or somewhat older ones if you are interested in P4_14.

Andy

On Tue, Nov 21, 2017 at 7:03 AM, Roshan <sedar at oasis.uclouvain.be> wrote:

> Hi,
>
> I am trying the following to keep a variable in packet header per switch.
> I just want to know which way is the best way to do this. This could grow
> the header largely as it appears.
>
>
> header_type {
>
>       fields {
>
>             switch_1: 8;
>
>              switch_2: 8;
>
>             ............
>
>              switch_n: 8;
>
>     }
>
> }
>
>
> Thanks!
>
>
> Regards,
>
> Roshan.
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171121/be269cfc/attachment-0002.html>


More information about the P4-dev mailing list