[P4-dev] Encapsulation of variable-length headers

cristina.dominicini at aluno.ufes.br cristina.dominicini at aluno.ufes.br
Thu Sep 20 20:48:00 EDT 2018

Hi all,

The parsing of variable-length headers is well documented in P4
language. There are examples as the source routing tutorial
and the implementation of TCP options in the P4 16 manual.

On the other hand, I could not find a way to add a variable-length
header to a packet using P4 16 and v1model. 

My goal was to extend the source routing tutorial in order to answer a
question of the "Food for thought" section: "How would you enhance your
program to let the first switch add the path, so that source routing
would be transparent to end-hosts?" 

Originally, this tutorial depends on a python script to generate the
source routing headers, and the p4 program deals only with the source
routing operation on headers that were already created by the hosts.

Imagine two examples of output port list for source routing:
{3 1} - which means switch 1 output port is 3, and switch 2 output port
is 1
{3 3 3 1} - which means switch 1 output port is 3, switch 2 output port
is 3, switch 3 output port is 3, and switch 4 output port is 1

So, depending on the path length, the size of the source routing list
changes, and, consequently, the total header length changes.

My start point was this very good documentation from Andy Fingerhut:

So, if no source routing header was found in the parsing stage, I can
add it in the ingress block by consulting a table, where the match
condition is the IP destination address, and the action is the content
of my source routing header for reaching that destination. However, to
do this I need to store the contents from the table in fixed size

I was only able to solve this problem if I consider a fixed-length
source routing header when reading the action column from the table.
Then, in the parsing stage, besides the useful source routing content, I
also parse a dummy source routing content for the remaining bits in the
header. In addition, I have to keep this dummy header during the routing
process. The routing works, but clearly it is not an optimal
implementation, since I have a header overhead that was not happening
when the headers were created by the python script in the hosts.

Does someone have a better idea on how to solve this type of problem
(encapsulation of variable-length headers)? Does the P4 16 language
support encapsulation of variable-length headers? Does the PSA
architecture (instead of v1model) offer more flexibility to solve this
type of problem? 

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20180920/2bb35332/attachment-0001.html>

More information about the P4-dev mailing list