Reputation: 126
I'm writing a test P4 language in which I prepare to read the queueing state of the software switch bmv2 .There is no relevant content in the P4 program specification.But I found a mail in the mail list which is:
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, 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
I add the code mentioned in the mail to test whether it can work:
modify_field(ipv4.ttl,10);
add_to_field(ipv4.ttl,queueing_metadata.deq_qdepth);
But the result is It don't work,what should I do?Appreciate any help,thk.
Upvotes: 3
Views: 1758