Updated for new Topo API
This commit is contained in:
+12
-22
@@ -11,36 +11,26 @@ topology enables one to pass in '--topo=mytopo' from the command line.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
from mininet.node import Node
|
|
||||||
|
|
||||||
class MyTopo( Topo ):
|
class MyTopo( Topo ):
|
||||||
"Simple topology example."
|
"Simple topology example."
|
||||||
|
|
||||||
def __init__( self, enable_all = True ):
|
def __init__( self ):
|
||||||
"Create custom topo."
|
"Create custom topo."
|
||||||
|
|
||||||
# Add default members to class.
|
# Initialize topology
|
||||||
super( MyTopo, self ).__init__()
|
Topo.__init__( self )
|
||||||
|
|
||||||
# Set Node IDs for hosts and switches
|
# Add hosts and switches
|
||||||
leftHost = 1
|
leftHost = self.addHost( 'h1' )
|
||||||
leftSwitch = 2
|
rightHost = self.addHost( 'h2' )
|
||||||
rightSwitch = 3
|
leftSwitch = self.addSwitch( 's3' )
|
||||||
rightHost = 4
|
rightSwitch = self.addSwitch( 's4' )
|
||||||
|
|
||||||
# Add nodes
|
# Add links
|
||||||
self.addNode( leftSwitch, Node( isSwitch=True ) )
|
self.addLink( leftHost, leftSwitch )
|
||||||
self.addNode( rightSwitch, Node( isSwitch=True ) )
|
self.addLink( leftSwitch, rightSwitch )
|
||||||
self.addNode( leftHost, Node( isSwitch=False ) )
|
self.addLink( rightSwitch, rightHost )
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
topos = { 'mytopo': ( lambda: MyTopo() ) }
|
topos = { 'mytopo': ( lambda: MyTopo() ) }
|
||||||
|
|||||||
Reference in New Issue
Block a user