blob: 6f8638e26d287e25d03176aa7d46cf252dd9e106 [file] [log] [blame]
carlosmscabralf40ecd12013-02-01 18:15:58 -02001"""Custom topology example
2
3Two directly connected switches plus a host for each switch:
4
5 host --- switch --- switch --- host
6
7Adding the 'topos' dict with a key/value pair to generate our newly defined
8topology enables one to pass in '--topo=mytopo' from the command line.
9"""
10
11from mininet.topo import Topo
12
13class MyTopo( Topo ):
14 "Simple topology example."
15
16 def __init__( self ):
17 "Create custom topo."
18
19 # Initialize topology
20 Topo.__init__( self )
21
22 # Add hosts and switches
23 leftHost = self.addHost( 'h1' )
24 rightHost = self.addHost( 'h2' )
25 leftSwitch = self.addSwitch( 's3' )
26 rightSwitch = self.addSwitch( 's4' )
27
28 # Add links
29 self.addLink( leftHost, leftSwitch )
30 self.addLink( leftSwitch, rightSwitch )
31 self.addLink( rightSwitch, rightHost )
32
33
34topos = { 'mytopo': ( lambda: MyTopo() ) }