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

shubham bhardwaj bhardwajshubham2011 at gmail.com
Thu Dec 15 08:23:45 EST 2016


Hello,

Can i do logging in p4 (Not in switch). If yes and you do have some
information, please share.

Thanks & Regards
Shubham Bhardwaj




On Mon, Dec 12, 2016 at 8:29 PM, Antonin Bas <antonin at barefootnetworks.com>
wrote:

> I suggest you read the copy_to_cpu README (https://github.com/p4lang/
> tutorials/tree/master/examples/copy_to_cpu) as it contains all the
> information you need. For example, based on your logs, you didn't set a
> default action for the copy_to_cpu table.
> Once you configure the default action correctly and configure the
> mirroring session (see https://github.com/p4lang/tutorials/blob/master/
> examples/copy_to_cpu/commands.txt for an example), the packets that you
> are "copying to CPU" will be cloned out of the CPU port you have chosen. In
> our example we use port 3, which is veth7. We even provide a receiver
> script (receive.py) which captures packets on this interface and outputs
> them to stdout.
>
> On Mon, Dec 12, 2016 at 4:10 AM, shubham bhardwaj <
> bhardwajshubham2011 at gmail.com> wrote:
>
>> Hello Antonin,
>>
>> Thanks for your reply, now i am getting some results. i am using
>> copy_to_cpu method and i want to store this parsed information in a file.
>> so do i need to implement a receiver or there is some other method. I am
>> sharing a screenshot of the output.
>>
>> Regards
>>
>> On Fri, Dec 2, 2016 at 8:34 PM, Antonin Bas <antonin at barefootnetworks.com
>> > wrote:
>>
>>> 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/beha
>>> vioral-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/targe
>>> ts/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
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Shubham Bhardwaj
>> *Technical University of Darmstadt*
>> +49 17641749766 <+49%20176%2041749766>
>>
>
>
>
> --
> Antonin
>



-- 
Thanks & Regards
Shubham Bhardwaj
*Technical University of Darmstadt*
+49 17641749766
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20161215/edaa8f74/attachment-0002.html>


More information about the P4-dev mailing list