Skip to content
Permalink
Browse files

Replaced example topologies __init__ with build

  • Loading branch information...
None None
None authored and None committed Jan 17, 2019
1 parent cf6da39 commit fdc3156a915b22ddc47e3463c02d8ebb979ac70f
Showing with 5 additions and 17 deletions.
  1. +1 −4 custom/topo-2sw-2host.py
  2. +1 −2 examples/controlnet.py
  3. +1 −5 examples/linearbandwidth.py
  4. +1 −3 examples/multilink.py
  5. +1 −3 examples/natnet.py
@@ -13,12 +13,9 @@
class MyTopo( Topo ):
"Simple topology example."

def __init__( self ):
def build( self ):
"Create custom topo."

# Initialize topology
Topo.__init__( self )

# Add hosts and switches
leftHost = self.addHost( 'h1' )
rightHost = self.addHost( 'h2' )
@@ -100,10 +100,9 @@ def items( self ):

class ControlNetwork( Topo ):
"Control Network Topology"
def __init__( self, n, dataController=DataController, **kwargs ):
def build( self, n, dataController=DataController, **kwargs ):
"""n: number of data network controller nodes
dataController: class for data network controllers"""
Topo.__init__( self, **kwargs )
# Connect everything to a single switch
cs0 = self.addSwitch( 'cs0' )
# Add hosts which will serve as data network controllers
@@ -38,11 +38,7 @@
class LinearTestTopo( Topo ):
"Topology for a string of N hosts and N-1 switches."

def __init__( self, N, **params ):

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

def build( self, N, **params ):
# Create switches and hosts
hosts = [ self.addHost( 'h%s' % h )
for h in irange( 1, N ) ]
@@ -21,9 +21,7 @@ def runMultiLink():
class simpleMultiLinkTopo( Topo ):
"Simple topology with multiple links"

def __init__( self, n, **kwargs ):
Topo.__init__( self, **kwargs )

def build( self, n, **kwargs ):
h1, h2 = self.addHost( 'h1' ), self.addHost( 'h2' )
s1 = self.addSwitch( 's1' )

@@ -27,9 +27,7 @@

class InternetTopo(Topo):
"Single switch connected to n hosts."
def __init__(self, n=2, **opts):
Topo.__init__(self, **opts)

def build(self, n=2, **opts):
# set up inet switch
inetSwitch = self.addSwitch('s0')
# add inet host

0 comments on commit fdc3156

Please sign in to comment.
You can’t perform that action at this time.