I have a topology consisting of multiple switches and one controller. I want the switches to send PacketIn to the controller, and then based on the the type of the PacketIn, I want to send some rules to the switch that the packet has come from. I have implemented everything including the packet communication, the P4 program, etc. But my question is how can I wait for PacketIns from multiple switches?
In my controller, I have a while true that is listening for packetIns from s1 for example. How can I get packetIns from all switches? and know what switch sent that packet?
Thank you in advance.
You can send control packets to the interface where the switch is connected to the controller. You can define your own control header end there put some information needed to find/recongnize your switch.
Thanks for the prompt reply.
I can send packets to the controller. I want to know if there is any way other than using threads in the controller to get packets from multiple switches at the same time.
And about the second part of my question. What I understand form your response is that there is no way I can get the incoming interface from the packet that I am processing and I have to add some data to the packets, right?
Hello @DavideS ,
Thank you so much. I think I have to use threading to get packets from multiple switches at the same time. Just to give an example of what I am looking for, in Python, you can define a list of ports to sniff packets from. sniff(iface=[eth0,eth1],…) I was wondering if we have such a thing in Controller like s1.PacketIn().
The second part answered my question completely.
I think that depens on how the controller that you are using (ONOS, TeraFlow,Opendaligth,etc). I guess that that kind of function/method is not avaiable in "general purpose"python libraies.
As an alternative to Python threads, you can use P4Runtime with asyncio.
The finsy python library can receive PacketIn’s from multiple switches. There are example programs showing how to construct a controller for multiple switches in Python.
I implemented an example that may be a solution for you:
There I have a controller and 3 switches. I hope that helps.