4 This example creates a multi-controller network from semi-scratch by
5 using the net.add*() API and manually starting the switches and controllers.
7 This is the "mid-level" API, which is an alternative to the "high-level"
8 Topo() API which supports parametrized topology classes.
10 Note that one could also create a custom switch class and pass it into
11 the Mininet() constructor.
15 from mininet.net import Mininet
16 from mininet.node import Controller, OVSSwitch
17 from mininet.cli import CLI
18 from mininet.log import setLogLevel, info
20 def multiControllerNet():
21 "Create a network from semi-scratch with multiple controllers."
23 net = Mininet( controller=Controller, switch=OVSSwitch )
25 info( "*** Creating (reference) controllers\n" )
26 c1 = net.addController( 'c1', port=6633 )
27 c2 = net.addController( 'c2', port=6634 )
29 info( "*** Creating switches\n" )
30 s1 = net.addSwitch( 's1' )
31 s2 = net.addSwitch( 's2' )
33 info( "*** Creating hosts\n" )
34 hosts1 = [ net.addHost( 'h%d' % n ) for n in ( 3, 4 ) ]
35 hosts2 = [ net.addHost( 'h%d' % n ) for n in ( 5, 6 ) ]
37 info( "*** Creating links\n" )
44 info( "*** Starting network\n" )
51 info( "*** Testing network\n" )
54 info( "*** Running CLI\n" )
57 info( "*** Stopping network\n" )
60 if __name__ == '__main__':
61 setLogLevel( 'info' ) # for CLI output