nsg-ethz / p4-utils

Extension to Mininet that makes P4 networks easier to build
GNU General Public License v2.0
175 stars 65 forks source link

How to run multiple controllers #54

Closed Master-COLLiDER closed 1 year ago

Master-COLLiDER commented 1 year ago

I want to run multiple controllers for same switch. such that one controllers will be embedded onto the switch and one will be in a remote location.

edgar-costa commented 1 year ago

That is possible. You can connect two controllers as long as the controller can send packets to the port the switch program is listening to.

Master-COLLiDER commented 1 year ago

That is possible. You can connect two controllers as long as the controller can send packets to the port the switch program is listening to.

When I tried to connect using p4utils's SimpleSwitchP4RuntimeAPI it shows:

CRITICAL:root:StreamChannel error, closing stream
CRITICAL:root:P4Runtime RPC error (INVALID_ARGUMENT): Election id already exists
CRITICAL:root:Failed to establish session with server

I tried changing the election_id to different tuple it works then. but i am sure it is wrong.

edgar-costa commented 1 year ago

Can you try with the thrift client? I guess you are using the P4runtime one. I am trying to recall this, but I believe I only attempted to connect to the same switch from multiple controllers using the thrift API. I, however, understand you do not want to use that deprecated API.

Master-COLLiDER commented 1 year ago

Can you try with the thrift client? I guess you are using the P4runtime one. I am trying to recall this, but I believe I only attempted to connect to the same switch from multiple controllers using the thrift API. I, however, understand you do not want to use that deprecated API.

Thank you @edgar-costa works when I use thrift API.

Also I have one more question, How to send some of the packets to embedded controller and some to remote controller. Currently all the packets are going to both controller.

in my p4 code I am using this

clone3(CloneType.I2E, 100, meta);

and in the controller this

self.controller.mirroring_add(100, self.cpu_port)

edgar-costa commented 1 year ago

Well, packets are received by using veth interfaces. If both controllers are listening to the same interface, they will receive the packet two times. You need to either, add 2 CPU ports (not directly supported by p4-utils) or you should add some sort of TAG to your packets so you can filter them at the controller.

Master-COLLiDER commented 1 year ago

Thanks @edgar-costa