blob: 22d515b6ade923c924b341a97b570d2c30399700 [file] [log] [blame]
tombd8e9c82014-10-07 11:46:15 -07001#!/usr/bin/env python
Brian O'Connor580163d2014-10-30 21:03:43 -07002
Thomas Vachuska5767d592018-02-05 17:18:06 -08003"""
4"""
Brian O'Connor580163d2014-10-30 21:03:43 -07005from mininet.topo import Topo
tombd8e9c82014-10-07 11:46:15 -07006
Thomas Vachuska5767d592018-02-05 17:18:06 -08007class Tower( Topo ):
8 "Internet Topology Zoo Specimen."
tombd8e9c82014-10-07 11:46:15 -07009
Thomas Vachuska5767d592018-02-05 17:18:06 -080010 def addSwitch( self, name, **opts ):
11 kwargs = { 'protocols' : 'OpenFlow13' }
12 kwargs.update( opts )
13 return super(Tower, self).addSwitch( name, **kwargs )
tombd8e9c82014-10-07 11:46:15 -070014
Thomas Vachuska5767d592018-02-05 17:18:06 -080015 def __init__( self ):
16 "Create a topology."
17
18 # Initialize Topology
19 Topo.__init__( self )
20
Brian O'Connor580163d2014-10-30 21:03:43 -070021 spines = []
tombd8e9c82014-10-07 11:46:15 -070022
23 # Create the two spine switches
Thomas Vachuska5767d592018-02-05 17:18:06 -080024 spines.append(self.addSwitch( 's1' ))
25 spines.append(self.addSwitch( 's2' ))
tombd8e9c82014-10-07 11:46:15 -070026
tombd8e9c82014-10-07 11:46:15 -070027 # Now create the leaf switches, their hosts and connect them together
Thomas Vachuska5767d592018-02-05 17:18:06 -080028 for i in range(4):
29 sn = i + 1
30 leaf = self.addSwitch( 's1%d' % sn )
Brian O'Connor580163d2014-10-30 21:03:43 -070031 for spine in spines:
Thomas Vachuska5767d592018-02-05 17:18:06 -080032 self.addLink(leaf, spine)
tombd8e9c82014-10-07 11:46:15 -070033
Thomas Vachuska5767d592018-02-05 17:18:06 -080034 for j in range(5):
35 host = self.addHost( 'h%d%d' % (sn, j + 1) )
36 self.addLink( host, leaf )
tombd8e9c82014-10-07 11:46:15 -070037
Thomas Vachuska5767d592018-02-05 17:18:06 -080038topos = { 'tower': ( lambda: Tower() ) }
tombd8e9c82014-10-07 11:46:15 -070039
Brian O'Connor580163d2014-10-30 21:03:43 -070040if __name__ == '__main__':
Thomas Vachuska5767d592018-02-05 17:18:06 -080041 from onosnet import run
42 run( Tower() )