2

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

enter image description here

Here's the directory the python file is in:

enter image description here

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() )} 
dj5
  • 83
  • 2
  • 4
  • 12
  • From the screenshots, it seems your folder where the Python file is placed (HOME\mininet\custom), and the expected location in mininet script (/home/mininet/mininet/custom) are different! Although, it can only be clear to us when we know more about the exact location mapping of H drive! – Am_I_Helpful Nov 30 '21 at 22:04

5 Answers5

1

The error is small:

While trying to run the custom topology, use this command:

sudo mn --custom ~/mininet/custom/project.py --topo=project

Hope this answer solves

DaveL17
  • 1,673
  • 7
  • 24
  • 38
Bhargavi
  • 11
  • 1
0

you can write the above code on a file with main python script and run it executing python file.

dside
  • 98
  • 7
0

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)

0

You can create a topology using miniedit. It is very convinient to create a custom topology using miniedit using graphical user interface.

wajid
  • 37
  • 2
  • 10
0

When it comes to a custom mininet python file, for me it works using the following commands.

  1. cd /to/the/python/file, then run the following
  2. sudo mn --custom expr.py --topo expr --mac --switch ovsk --controller remote,ip=127.0.0.1,port=6653,protocols=OpenFlow13

Where the expr.py is the python script that holds the mininet topology.

LW001
  • 2,452
  • 6
  • 27
  • 36