p4lang / p4app

Apache License 2.0
112 stars 58 forks source link

Custom dynamic topology #64

Open jdarkf opened 5 years ago

jdarkf commented 5 years ago

Hi, I would like to use a dynamic topology with p4app, meaning that it depends on some inputs given by the user: number of hosts and switches, and the links to set. Thanks to a python script, the inputs are gathered, and nodes and links are created accordingly with the methods addSwitch(), addHost() and addLink() of the class AppTopo. The used manifest file is similar to the one in the example "p4app/examples/customtopo.p4app", however no link is defined in it since links are not known yet.

When running, all nodes and links defined as inputs seem to be created: the Mininet command "nodes" returns all nodes, and the command "net" returns all links. However, if "auto-control-plane" variable is set to True, or when trying to implement a controller module (with the class AppController), a KeyError is returned indicating that it doesn't find the node as a key in the dictionary "self.topo._host_links" when the node is a host. I guess it would give the same error for switches and the dictionary "self.topo._sw_links".

proof1

I guess I don't have to create an instance of the class Mininet as the "multiswitch" target is directly fed with the "topo_module" and the "controller_module" (identically to the "customtopo" example).

It seems to me as if the only way to populate the two mentioned dictionaries is by indicating the links in the manifest file, but the problem is that they're not known by the programmer.

Is there any method allowing to populate these dictionaries? Any help is welcome. Thanks a lot.