blob: 07a167fb450ef07549c5ed08c0070c1f3c92e9dd [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 client = self.addHost( 'h1' )
24 client.setIP('1.0.0.1')
25 router = self.addHost( 'h2' )
26 client.setIP('1.0.1.1',intf='h1-eth0')
27 client.setIP('2.0.1.2',intf='h1-eth1')
28 server = self.addHost( 'h3' )
29 client.setIP('2.0.0.1')
30
31 #leftSwitch = self.addSwitch( 's3' )
32 #rightSwitch = self.addSwitch( 's4' )
33
34 # Add links
35 #self.addLink( leftHost, leftSwitch )
36 #self.addLink( leftHost, rightSwitch)
37 #self.addLink( leftSwitch, rightSwitch )
38 #self.addLink( rightSwitch, rightHost )
39 self.addLink( client, router )
40 self.addLink( server, router )
41
42
43topos = { 'mytopo': ( lambda: MyTopo() ) }