[P4-dev] Get timestamp

Antonin Bas antonin at barefootnetworks.com
Mon Sep 26 13:46:07 EDT 2016


Hi,

I added your code to one of my simple L3 programs and nothing happened, the
switch kept processing packets as usual.
You should try running the switch in isolation and enable logging to see if
anything strange is happening.
Right now I don't have enough information to be able to help you. I would
need: a P4 program to reproduce this (as simple as possible), the
appropriate CLI commands to configure the dataplane and a packet I can send
through the switch (Scapy format would be nice: Ether(src=..., dst=...) /
IP(src=..., dst=...) / ...)

Best,

Antonin

On Sun, Sep 25, 2016 at 3:20 PM, Yuliang Li <yuliangl at usc.edu> wrote:

> Hi Antonin,
>
> I tried adding the following code:
>
> header_type intrinsic_metadata_t {
>     fields {
>         ingress_global_timestamp : 48;
>     }
> }
> metadata intrinsic_metadata_t intrinsic_metadata;
>
> However, the switch just does not work (it cannot forward packets). I even
> do not use any fields in the intrinsic_metadata. But if I remove the above
> code, the switch work again. Do you know if there is anything wrong with
> the intrinsic_metadata?
>
> Thanks,
> Yuliang
>
> On Mon, May 9, 2016 at 4:49 PM, Wei Bai <wbaiab at cse.ust.hk> wrote:
>
>> Hi Antonin,
>>
>> Thank you very much for the reply. queueing_metadata.deq_timedelta is
>> exactly what I want. I will try it. Thanks again.
>>
>> Regards,
>> Wei
>>
>>
>> 2016-05-10 4:36 GMT+08:00 Antonin Bas <antonin at barefootnetworks.com>:
>>
>>> Hi Wei,
>>>
>>> There is no standard way to get a timestamp in P4, as you can see in the
>>> spec.
>>> However if you are using the simple_switch bmv2 target (
>>> https://github.com/p4lang/behavioral-model
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_behavioral-2Dmodel&d=DQMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=-sjq3J2b6bOdupF1bsRuzQ&m=SpZAkqKoADlgRsBwUin34Q4v_d-qGCyuWXdL1Ryoytk&s=FoopmJ41sZ__LS2J3Cepecc6gUHQS35TVOFOssjzjdM&e=>),
>>> you can still have access to this information. You need to include the
>>> following in your P4 program:
>>>
>>> header_type intrinsic_metadata_t {
>>>     fields {
>>>         ingress_global_timestamp : 48;
>>>     }
>>> }
>>> metadata intrinsic_metadata_t intrinsic_metadata;
>>>
>>> header_type queueing_metadata_t {
>>>     fields {
>>>         enq_timestamp: 48;
>>>         enq_qdepth: 16;
>>>         deq_timedelta: 32;
>>>         deq_qdepth: 16;
>>>     }
>>> }
>>> metadata queueing_metadata_t queueing_metadata;
>>>
>>> All timestamps are in microseconds
>>> intrinsic_metadata.ingress_global_timestamp is the timestamp when the
>>> switch starts processing the packet
>>> queueing_metadata.enq_timestamp is the timestamp when the packet is
>>> enqueued (between the ingress and egress pipelines)
>>> queueing_metadata.deq_timedelta is the time the packet spent in the
>>> queue (I believe it is what you are after).
>>>
>>> It is important to understand that these metadata fields are specific to
>>> the simple_switch target, they are not standardized by P4. bmv2 will detect
>>> that they are defined in the P4 program and leverage them.
>>>
>>> Because bmv2 has a low throughput, I recommend rate-limiting your links
>>> to < 100Mbps. You can also use the "set_queue_rate" simple_switch CLI
>>> command to rate-limit the bmv2 queue. Please make sure that you compile
>>> bmv2 with O2 and without logging (./configure 'CXXFLAGS=-O2'
>>> --disable-logging-macros --disable-elogger), otherwise throughput will be
>>> really bad.
>>>
>>> Best,
>>>
>>> Antonin
>>>
>>> On Mon, May 9, 2016 at 1:04 PM, Wei Bai <wbaiab at cse.ust.hk> wrote:
>>>
>>>> Hi,
>>>>
>>>> I want to measure the total time a packet spends at a switch (a.k.a,
>>>> sojourn time). To achieve this, I need to attach a metadata for each packet
>>>> to record the enqueue timestamp. Does anyone know how to get current
>>>> timestamp from the local clock in P4 data plane? Thanks in advance.
>>>>
>>>> Regards,
>>>> Wei
>>>>
>>>> _______________________________________________
>>>> P4-dev mailing list
>>>> P4-dev at lists.p4.org
>>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.p4.org_mailman_listinfo_p4-2Ddev-5Flists.p4.org&d=DQMFaQ&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=-sjq3J2b6bOdupF1bsRuzQ&m=SpZAkqKoADlgRsBwUin34Q4v_d-qGCyuWXdL1Ryoytk&s=muiaApMdrVxmWUcj-B8N_YoEC74wHq2QrgGb9PgitM0&e=>
>>>>
>>>
>>>
>>>
>>> --
>>> Antonin
>>>
>>
>>
>> _______________________________________________
>> P4-dev mailing list
>> P4-dev at lists.p4.org
>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>
>
>


-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160926/408f333f/attachment-0002.html>


More information about the P4-dev mailing list