tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
Brian O'Connor | 580163d | 2014-10-30 21:03:43 -0700 | [diff] [blame] | 2 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 3 | """ |
4 | """ | ||||
Brian O'Connor | 580163d | 2014-10-30 21:03:43 -0700 | [diff] [blame] | 5 | from mininet.topo import Topo |
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 6 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 7 | class Tower( Topo ): |
8 | "Internet Topology Zoo Specimen." | ||||
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 9 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 10 | def addSwitch( self, name, **opts ): |
11 | kwargs = { 'protocols' : 'OpenFlow13' } | ||||
12 | kwargs.update( opts ) | ||||
13 | return super(Tower, self).addSwitch( name, **kwargs ) | ||||
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 14 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 15 | def __init__( self ): |
16 | "Create a topology." | ||||
17 | |||||
18 | # Initialize Topology | ||||
19 | Topo.__init__( self ) | ||||
20 | |||||
Brian O'Connor | 580163d | 2014-10-30 21:03:43 -0700 | [diff] [blame] | 21 | spines = [] |
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 22 | |
23 | # Create the two spine switches | ||||
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 24 | spines.append(self.addSwitch( 's1' )) |
25 | spines.append(self.addSwitch( 's2' )) | ||||
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 26 | |
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 27 | # Now create the leaf switches, their hosts and connect them together |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 28 | for i in range(4): |
29 | sn = i + 1 | ||||
30 | leaf = self.addSwitch( 's1%d' % sn ) | ||||
Brian O'Connor | 580163d | 2014-10-30 21:03:43 -0700 | [diff] [blame] | 31 | for spine in spines: |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 32 | self.addLink(leaf, spine) |
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 33 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 34 | for j in range(5): |
35 | host = self.addHost( 'h%d%d' % (sn, j + 1) ) | ||||
36 | self.addLink( host, leaf ) | ||||
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 37 | |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 38 | topos = { 'tower': ( lambda: Tower() ) } |
tom | bd8e9c8 | 2014-10-07 11:46:15 -0700 | [diff] [blame] | 39 | |
Brian O'Connor | 580163d | 2014-10-30 21:03:43 -0700 | [diff] [blame] | 40 | if __name__ == '__main__': |
Thomas Vachuska | 5767d59 | 2018-02-05 17:18:06 -0800 | [diff] [blame] | 41 | from onosnet import run |
42 | run( Tower() ) |