Simon Hunt | 12c79ed | 2017-09-12 11:58:44 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | """ |
| 5 | from mininet.topo import Topo |
| 6 | |
| 7 | class DualTopo( Topo ): |
| 8 | """Switches and Dual-homed host""" |
| 9 | |
| 10 | def __init__( self ): |
| 11 | """Create a topology.""" |
| 12 | |
| 13 | # Initialize Topology |
| 14 | Topo.__init__( self ) |
| 15 | |
| 16 | # add nodes, switches first... |
Simon Hunt | ac8f11f | 2017-09-12 13:11:11 -0700 | [diff] [blame] | 17 | SWA = self.addSwitch( 's1' ) |
| 18 | SWB = self.addSwitch( 's2' ) |
Simon Hunt | 12c79ed | 2017-09-12 11:58:44 -0700 | [diff] [blame] | 19 | |
| 20 | # ... and now hosts |
Simon Hunt | ac8f11f | 2017-09-12 13:11:11 -0700 | [diff] [blame] | 21 | HOSTX = self.addHost( 'h1' ) |
Simon Hunt | 12c79ed | 2017-09-12 11:58:44 -0700 | [diff] [blame] | 22 | |
| 23 | # add edges between switch and corresponding host |
Simon Hunt | ac8f11f | 2017-09-12 13:11:11 -0700 | [diff] [blame] | 24 | self.addLink( SWA, HOSTX ) |
| 25 | self.addLink( SWB, HOSTX ) |
Simon Hunt | 12c79ed | 2017-09-12 11:58:44 -0700 | [diff] [blame] | 26 | |
| 27 | # add edges between switches |
Simon Hunt | ac8f11f | 2017-09-12 13:11:11 -0700 | [diff] [blame] | 28 | self.addLink( SWA, SWB, bw=10, delay='1.0ms' ) |
Simon Hunt | 12c79ed | 2017-09-12 11:58:44 -0700 | [diff] [blame] | 29 | |
| 30 | |
| 31 | topos = { 'dual': ( lambda: DualTopo() ) } |
| 32 | |
| 33 | if __name__ == '__main__': |
| 34 | from onosnet import run |
| 35 | run( DualTopo() ) |