Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set bandwidth on Mininet custom topology?

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?

like image 779
NWOWN Avatar asked May 28 '15 02:05

NWOWN


People also ask

How do I run custom topology in Mininet?

You can create your custom topology by writing a few lines of Python code. For example, Figure 1 shows a topology with two switches and four hosts. Figure 2 implements the topology using the Mininet Python API. The code consists of a class, named MyFirstTopo which extends the Topo class provided by the API.

What is xterm Mininet?

xterm is the command used to initiate an external and separate terminal. The command opens an xterm window, which is specific to a node in the network. Several functionalities specific to a node can be implemented on this window. In the example shown in Figure 14, the h1 xterm window is used to ping h2 (10.0.

What is controller Mininet?

A Controller is a Node that is running (or has execed?) an OpenFlow controller. More...


2 Answers

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

like image 186
Raviyo Andika Avatar answered Sep 21 '22 15:09

Raviyo Andika


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

like image 26
bilalba Avatar answered Sep 21 '22 15:09

bilalba