[P4-dev] Parsing a Protocol via pcap file and extracting the behavior of the packet

Antonin Bas antonin at barefootnetworks.com
Fri Dec 2 14:34:17 EST 2016


Hi,

Still unsure what you are trying to do. For me, parsing the packet *is*
getting the information. If you need to store this information or process
it outside of the switch, there are different things you can do:
- you can store the information in stateful memories using the *register*
construct. There is an example about using P4 registers here:
https://github.com/p4lang/tutorials/tree/master/examples/register. The
control plane can also access these stateful memories (read or write).
- you can use learning to send the information to the CPU. Usually this is
used to learn mac addresses when implementing a L2 switch. Learning is
achieved in a P4 program using the generate_digest() action primitive.
There is an example for this as well:
https://github.com/p4lang/behavioral-model/blob/master/targets/l2_switch/l2_switch.p4.
When doing learning you need to implement a receiver which will process
these notifications. In the case of bmv2, there is an example of such a
receiver here:
https://github.com/p4lang/behavioral-model/blob/master/targets/l2_switch/learn_client/learn_client.cpp
- you can simply redirect the whole packet to CPU. This is usually how
protocol control packets (e.g. BGP) are processed (the control plane then
populates the dataplane tables appropriately so that traffic is forwarded
correctly). There is a basic example here:
https://github.com/p4lang/tutorials/tree/master/examples/copy_to_cpu

On Fri, Dec 2, 2016 at 1:06 AM, shubham bhardwaj <
bhardwajshubham2011 at gmail.com> wrote:

> Adding on, My last question was just simply how to give input of pcap file
> in switch and i am able to that now. now i am trying to extract information
> from that pcap file.
>
> Regards
>
> On Fri, Dec 2, 2016 at 10:02 AM, shubham bhardwaj <
> bhardwajshubham2011 at gmail.com> wrote:
>
>> Hi Antonin,
>>
>> I need to analyse information from a packet, for that I am using Modbus
>> protocol dumps. so basically i am parsing a Modbus Packet but as going
>> through examples and p4 spec I am only able to modify the packet. So i just
>> want to know is it possible to get the information from it and how. Is
>> there any tutorial or demo present online.
>>
>> Thanks & Regards
>> Shubham Bhardwaj
>>
>>
>>
>>  Sent with Mailtrack
>> <https://mailtrack.io/install?source=signature&lang=en&referral=bhardwajshubham2011@gmail.com&idSignature=22>
>>
>> On Wed, Nov 30, 2016 at 6:24 PM, Antonin Bas <
>> antonin at barefootnetworks.com> wrote:
>>
>>> Hi,
>>>
>>> I'm not sure I understand your question, or how it's different from the
>>> last question you asked to the mailing list:
>>> http://lists.p4.org/pipermail/p4-dev_lists.p4.org/2016-Novem
>>> ber/000573.html
>>> A little more details would be useful.
>>>
>>> Best,
>>>
>>> Antonin
>>>
>>> On Wed, Nov 30, 2016 at 5:14 AM, shubham bhardwaj <
>>> bhardwajshubham2011 at gmail.com> wrote:
>>>
>>>> Hello All,
>>>>
>>>> I want to check the behavior of a packet(wireshark dump), Is it
>>>> possible in P4. I have checked examples in the tutorial section and i
>>>> haven't found anything relatable.
>>>>
>>>> --
>>>> Thanks & Regards
>>>> Shubham Bhardwaj
>>>>
>>>>
>>>> _______________________________________________
>>>> P4-dev mailing list
>>>> P4-dev at lists.p4.org
>>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>>
>>>
>>>
>>>
>>> --
>>> Antonin
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Shubham Bhardwaj
>> *Technical University of Darmstadt*
>> +49 17641749766 <+49%20176%2041749766>
>>
>
>
>
> --
> Thanks & Regards
> Shubham Bhardwaj
> *Technical University of Darmstadt*
> +49 17641749766 <+49%20176%2041749766>
>



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


More information about the P4-dev mailing list