How to Run Custom Topology in Mininet?
Andrew Henderson
I am attempting to create an SDN network from a python file I created, but it can't seem to find the directory. Is there anything I am doing wrong?
Here is the syntax I used:
sudo mn --custom ~/mininet/custom/project.py --topo project
Here's the directory the python file is in:
And just in case, I am also providing my code from my python file:
from mininet.topo import Topo
class Project( Topo ): def __init__( self ): # Initialize topology Topo.__init__( self ) # Add hosts h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') h5 = self.addHost('h5') h6 = self.addHost('h6') h7 = self.addHost('h7') h8 = self.addHost('h8') h9 = self.addHost('h9') h10 = self.addHost('h10') h11 = self.addHost('h11') h12 = self.addHost('h12') h13 = self.addHost('h13') h14 = self.addHost('h14') h15 = self.addHost('h15') h16 = self.addHost('h16') h17 = self.addHost('h17') h18 = self.addHost('h18') # Add switches s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') s7 = self.addSwitch('s7') s8 = self.addSwitch('s8') # Add links self.addLink(h1,s1) self.addLink(h2,s1) self.addLink(h3,s1) self.addLink(h4,s2) self.addLink(h5,s2) self.addLink(h6,s2) self.addLink(h7,s3) self.addLink(h8,s3) self.addLink(h9,s3) self.addLink(s1,s7) self.addLink(s2,s7) self.addLink(s3,s7) self.addLink(s7,s8) self.addLink(s8,s4) self.addLink(s8,s5) self.addLink(s8,s6) self.addLink(s4,h10) self.addLink(s4,h11) self.addLink(s4,h12) self.addLink(s5,h13) self.addLink(s5,h14) self.addLink(s5,h15) self.addLink(s6,h16) self.addLink(s6,h17) self.addLink(s6,h18)
topos = { 'project': ( lambda: Project() )} 1 4 Answers
The error is small:
While trying to run the custom topology, use this command:
sudo mn --custom ~/mininet/custom/project.py --topo=projectHope this answer solves
you can write the above code on a file with main python script and run it executing python file.
First of all is the topology (.py) in that directory?
Secondly I don't see your controller in your topology (you said SDN). Your switches need a SDN Controller. If you use a remote controller you should execute
sudo mn --custom ~/mininet/custom/project.py --topo project --remote controller
Also check if there is a problem with the capital P at topo project (or Project)
You can create a topology using miniedit. It is very convinient to create a custom topology using miniedit using graphical user interface.