Skip to content
Snippets Groups Projects
Commit 35698385 authored by Bob Lantz's avatar Bob Lantz
Browse files

Updated for new Topo API

parent 8c7c4812
No related branches found
No related tags found
No related merge requests found
......@@ -11,36 +11,26 @@
"""
from mininet.topo import Topo
from mininet.node import Node
class MyTopo( Topo ):
"Simple topology example."
def __init__( self, enable_all = True ):
def __init__( self ):
"Create custom topo."
# Add default members to class.
super( MyTopo, self ).__init__()
# Initialize topology
Topo.__init__( self )
# Set Node IDs for hosts and switches
leftHost = 1
leftSwitch = 2
rightSwitch = 3
rightHost = 4
# Add hosts and switches
leftHost = self.addHost( 'h1' )
rightHost = self.addHost( 'h2' )
leftSwitch = self.addSwitch( 's3' )
rightSwitch = self.addSwitch( 's4' )
# Add nodes
self.addNode( leftSwitch, Node( isSwitch=True ) )
self.addNode( rightSwitch, Node( isSwitch=True ) )
self.addNode( leftHost, Node( isSwitch=False ) )
self.addNode( rightHost, Node( isSwitch=False ) )
# Add edges
self.add_edge( leftHost, leftSwitch )
self.add_edge( leftSwitch, rightSwitch )
self.add_edge( rightSwitch, rightHost )
# Consider all switches and hosts 'on'
self.enable_all()
# Add links
self.addLink( leftHost, leftSwitch )
self.addLink( leftSwitch, rightSwitch )
self.addLink( rightSwitch, rightHost )
topos = { 'mytopo': ( lambda: MyTopo() ) }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment