8

I want to set bandwidth on Mininet custom topology.

The python code is:

#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel

class MyTopo( Topo ):
"Simple topology example."

    def __init__( self, **opts):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self, **opts )

        # Add hosts and switches
        h1 = self.addHost('h1')        
        h2 = self.addHost( 'h2' )

        s3 = self.addSwitch( 's3' )
        s1 = self.addSwitch( 's1' )
        s2 = self.addSwitch( 's2' )

        # Add links
        self.addLink(h1,s1,bw=10)
        self.addLink(h2,s3,bw=20)
        self.addLink(s3,s2,bw=10)
        self.addLink(s1,s3,bw=10)

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

But it has error

------------------------------------------------------------------
Caught exception. Cleaning up...
TypeError: __init__() got an unexpected keyword argument 'bw'
------------------------------------------------------------------

What can I do? How to set bandwidth on Mininet custom topology?

SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
NWOWN
  • 399
  • 1
  • 4
  • 17

5 Answers5

16

You should add cls=TCLink on the self.addLink(h1,s1,bw=10)

so the code will be self.addLink(h1,s1,cls=TCLink,bw=10)

Add to the other addLink to make it work

Maksymilian Wojakowski
  • 5,011
  • 3
  • 19
  • 14
Raviyo Andika
  • 161
  • 1
  • 2
4

When starting Mininet, add an additional argument --link=tc

bilalba
  • 783
  • 1
  • 7
  • 22
3

You should use --link argument. For example: sudo mn --topo tree,depth=2,fanout=5 --controller=remote,ip=10.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13, --link tc,bw=1,delay=10ms

I'll update with an example soon.

sinhayash
  • 2,693
  • 4
  • 19
  • 51
  • But what if your custom topology has several hundred links, all with different bandwidth requirements? This would be silly to enter on the command line, is there a way to specify it in the python file? – John Scolaro Sep 01 '17 at 07:37
  • @JohnScolaro Mininet cannot simulate such big network, You have to look for other solutions such as MiniNeXT. – sinhayash Feb 13 '20 at 06:43
  • Here bw=1 is equivalent to 1Mbps. How to set bw of a link to 1Gbps as it bw is taking values between 1-1000? – Vinay Oct 13 '20 at 07:35
  • Please ask a new question – sinhayash Oct 15 '20 at 05:32
1

If you are using CLI command mn to run Mininet, add --link=tc.
If you are using a run() function in the python script to start Mininet, use

net = Mininet(topo = MyTopo(), link = TCLink)
net.start()

to start with Mininet with TC links for bandwidth specification to work.

zz2492
  • 11
  • 3
0

State the bandwidth and the delays in the python file, but while running the file, add

--link=tc

in the command line and it will work fine.