3 from mininet.topo import Topo
4 from mininet.net import Mininet
5 from mininet.link import TCLink
7 # To use this topology, run:
8 # > sudo mn --custom affinity-topo.py --topo affinity --link tc
9 # Using spaces rather than '=' is very important, as is having the --link flag
11 class AffinityTopo(Topo):
13 def __init__(self, **opts):
14 Topo.__init__(self, **opts)
17 s1 = self.addSwitch('s1')
18 s2 = self.addSwitch('s2')
19 s3 = self.addSwitch('s3')
21 # Connect switches into tree
26 h1 = self.addHost('h1')
27 h2 = self.addHost('h2')
28 h3 = self.addHost('h3')
29 h4 = self.addHost('h4')
31 # Connect hosts to switches
32 self.addLink(h1, s2, bw=10) # These two links get limited
33 self.addLink(h2, s2, bw=10)
37 topos = { 'affinity' : (lambda: AffinityTopo()) }