Revision 18aab5b7 examples/linuxrouter.py

View differences:

examples/linuxrouter.py
44 44
class NetworkTopo( Topo ):
45 45
    "A simple topology of a router with three subnets (one host in each)."
46 46

  
47
    def build( self, n=2, h=1, **opts ):
47
    def build( self, **opts ):
48 48
        router = self.addNode( 'r0', cls=LinuxRouter, ip='192.168.1.1/24' )
49
        h1 = self.addHost( 'h1', ip='192.168.1.100/24', defaultRoute='via 192.168.1.1' )
50
        h2 = self.addHost( 'h2', ip='172.16.0.100/12', defaultRoute='via 172.16.0.1' )
51
        h3 = self.addHost( 'h3', ip='10.0.0.100/8', defaultRoute='via 10.0.0.1' )
52
        self.addLink( h1, router, intfName2='r0-eth1', params2={ 'ip' : '192.168.1.1/24' } )
53
        self.addLink( h2, router, intfName2='r0-eth2', params2={ 'ip' : '172.16.0.1/12' } )
54
        self.addLink( h3, router, intfName2='r0-eth3', params2={ 'ip' : '10.0.0.1/8' } )
49
        h1 = self.addHost( 'h1', ip='192.168.1.100/24',
50
                           defaultRoute='via 192.168.1.1' )
51
        h2 = self.addHost( 'h2', ip='172.16.0.100/12',
52
                           defaultRoute='via 172.16.0.1' )
53
        h3 = self.addHost( 'h3', ip='10.0.0.100/8',
54
                           defaultRoute='via 10.0.0.1' )
55
        self.addLink( h1, router, intfName2='r0-eth1',
56
                      params2={ 'ip' : '192.168.1.1/24' } )
57
        self.addLink( h2, router, intfName2='r0-eth2',
58
                      params2={ 'ip' : '172.16.0.1/12' } )
59
        self.addLink( h3, router, intfName2='r0-eth3',
60
                      params2={ 'ip' : '10.0.0.1/8' } )
55 61

  
56 62
def run():
63
    "Test linux router"
57 64
    topo = NetworkTopo()
58 65
    net = Mininet( topo=topo, controller=None ) # no controller needed
59 66
    net.start()

Also available in: Unified diff