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 update link delay & routing tables during runtime #34

Open QuinnRutherford opened 2 years ago

QuinnRutherford commented 2 years ago

I am using P4Utils to create a network topology where there are multiple (3) paths between 2 hosts. I would like to send packets to compute the fastest path and update the forwarding tables given to each switch during runtime.

The network topology is made using the p4utils.mininetlib.network_API module.

To do this I am struggling to figure out how to perform two functions:

  1. Change link delay between two switches during runtime: I am setting the link delay using the setDelay() function when creating the network. Is there a way to change the delay of a link during runtime?

  2. Update routing tables during runtime: The original routing table rules for each switch are defined in a sN-commands.txt file which I am feeding to each switch with net.setP4CliInput('sN', 'sN-commands.txt'). Is it possible to either, alter the text file during runtime to change the rules, or give the switch a new set of command for a different file during runtime?

Edit: A previous version asked about updating link bandwidth, this has been changed to ask about link delay.

edgar-costa commented 2 years ago

Hi!

  1. There is ways to change the delay during runtime, but there is not a direct API in mininet or p4-utils. You will have to write the code yourself. I will give you some pointers: Here you can find how network conditions are added to links: https://github.com/mininet/mininet/blob/master/mininet/link.py#L231. If you inspect this class you will see how mininet/p4-utils modify the interface delay. Basically it uses linux tc netem qdisc. You will need to find way to modify the interface netem memory on your own.

  2. Yes also provide a runtime controller to add rules dynamically. You can find many examples at the p4-learning repository, for example this one shows how to fill routing tables from a python controller: https://github.com/nsg-ethz/p4-learning/tree/master/exercises/08-Simple_Routing/thrift