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

Fix: interfaces of the switches did not have an IP address. #46

Open Vo-Alex opened 1 year ago

Vo-Alex commented 1 year ago

Hello, while doing the exercise 09-Traceroutable of p4-learning, I noticed that the interfaces of the switches did not have an IP address.

After inspecting the code, I deduced that the problem was due to indentation errors in the save_topology function

I hope I have helped

edgar-costa commented 1 year ago

Hi!

I believe that is not the reason. And without checking if the indentation of save_topology is correct or not. The reason why switches do not get IPs is the following:

When the network is created by mininet, all switches are placed into the same namespace (the root one). If you set IPs to those interfaces, all the IPs and interfaces will co-exist in the same namespace. What happens then is that routing and forwarding will be performed by the Linux kernel instead of the p4-switches, which are just C++ programs sniffing and sending packets to some bound interfaces.

As an example if you have: h1---S1(ip1)----S2-------S3(ip3)---h3

When you send a packet from h1 to h3, when the packet arrives to the root namespace at S1, it will be directly sent to S3 interface connected to h3 by the linux kernel... bypassing S2 and all the P4 programs.

Vo-Alex commented 1 year ago

Yes, I see, but the problem here is that when the mininet topology is written in JSON format by save_topology, the fake IP addresses given to the switch interfaces are not saved. This breaks the controller script.

edgar-costa commented 1 year ago

For the other thing, thanks. When I find time I will have a look at it, to make sure the change does not break anything.