Untitled
unknown
python
2 years ago
1.1 kB
8
Indexable
"""Custom topology example Two directly connected switches plus a host for each switch: host --- switch --- switch --- host Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command line. """ from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." def build( self ): # Create top-level switch top_switch = self.addSwitch('s1') # Create lower-level switches and connect them to the top-level switch lower_switches = [] for i in range(1, 5): lower_switch = self.addSwitch('s{}'.format(i + 1)) self.addLink(top_switch, lower_switch) lower_switches.append(lower_switch) # Create hosts and connect them to each lower-level switch for switch in lower_switches: for j in range(1, 9): host = self.addHost('h{}_{}'.format(switch[1:], j)) self.addLink(switch, host) topos = { 'mytopo': ( lambda: MyTopo() ) }
Editor is loading...