[P4-dev] does P4 support get timestamp and create msg

Jeferson Santiago da Silva eng.jefersonsantiago at gmail.com
Sat May 13 20:21:38 EDT 2017

Hey Tony,

see inline

Date: Thu, 29 Dec 2016 07:49:02 +0000
> From: sundekui <sundekui at huawei.com>
> To: "p4-dev at lists.p4.org" <p4-dev at lists.p4.org>
> Cc: "Wuwenfu Wu(Wenfu)" <wuwenfu at huawei.com>, "Zhouhan (Joe)"
>         <joe.zhouhan at huawei.com>
> Subject: [P4-dev] does P4 support get timestamp and create msg
> Message-ID:
>         <EF69D35496B9DD429EDCAA2577AF664F52D91C at szxeml557-mbx.china.
> huawei.com>
> Content-Type: text/plain; charset="us-ascii"
> Hi
> Current I am doing research on P4. I have several questions as following:
> 1.    I want to get the timestamp when packets arrive and store it into
> register. For example, for a specified entry, I need to record/update the
> timestamp into the register when packet arrive. In other words the
> according register always stores the arrived time for the latest packet. I
> can't find any timestamp related actions but in p4 spec(1.0.3) I see the
> timestamp keyword(in page10, section 2.2). I guess this can be realized.
> But how to get the timestamp?
> P4 offers no native support for timestamping. It is totally
target-dependent. However, if you are using as target the behavior-model,
there is an intrinsic metadata ingress_global_timestamp accessible in P4.

> 2.    How to create totally new msg and send to controller? For example,
> for a specified entry, when the packet count or byte count exceeds a
> number, I want to create a msg and send to controller. I guess if I can
> create msg, I can simply set dest of the msg to controller ip addr and
> output it just like common packet. But how to create totally new msg?

The same here. There is no way in P4 to generate packets in the datapath
element. However, you could try to clone a regular incoming packet to the
CPU port. I haven't tried to modify the content a cloned packet though.
Check it out!

> 3.    I see that P4 frontend complier use thrift. So it means the api
> module generated by complier can be located on other location. And app can
> use the api and api to add/modify entry via ip network. Am I correct?
Cannot help here :(.

> Anyone can help me?
> Thanks
> Tony Sun

A recommendation: try to use P4-16.
I also recommend a nice article by Mihai Budiu from Vmware:


Jeferson Santiago da Silva, M.Sc.
Polytechnique Montréal
Ph.D. Candidate in Computer Engineering
Hardware and Programmable Logic Design Engineer
Phone: +1 (514) 581-1004
Skype: eng.jefersonsantiago
Montreal/QC - Canada
Lattes CV: http://lattes.cnpq.br/9568850258686622
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170513/5cd4b0e4/attachment-0002.html>

More information about the P4-dev mailing list