Pages

Sunday, December 14, 2014

Custom topologies in Mininet : With and without the mn script

There are two ways to run custom mininet topologies.

Without the mn script:

One is without the mn script in the command line. In this case, we simply run the file just as we run a python file. If the custom topology is in a file named mytopo.py, the file should be run as follows.

mininet@mininet-vm:~$ sudo python mytopo.py

With the mn script:

 In this case, the topology named should be given the command line.

For eg.: If there is a custom topology in a python file named 'mytopo.py', there should be a line like below in the file.

topos = { 'mytopo': ( lambda: MyTopo() ) }

topos is a dictionary which stores a custom name as a key and the class name as the value.The name 'mytopo' here can be any name you want to give.It need NOT be same as the filename  MyTopo() is the class name that we have defined in the custom topology which is a sub-class of Topo class that needs to be imported as follows

from mininet.topo import Topo

The above file can be run as follows:

mininet@mininet-vm:~$ sudo mn --custom ~/mininet/custom/mytopo.py --topo mytopo --mac

Here mytopo is the key defined in topos dictionary and ~/mininet.custom/mytopo.py is the file location of the file.

No comments:

Post a Comment