77699a373f7728397f4aceb712a71761b17d1176
[affinity.git] / scripts / affinity-topo.py
1 #!/usr/bin/python
2
3 from mininet.topo import Topo
4 from mininet.net import Mininet
5 from mininet.link import TCLink
6
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
10
11 class CustomTopo(Topo):
12
13     def __init__(self, **opts):
14         Topo.__init__(self, **opts)
15
16         # Three switches
17         s1 = self.addSwitch('s1')
18         s2 = self.addSwitch('s2')
19         s3 = self.addSwitch('s3')
20
21         # Connect switches into tree
22         self.addLink(s2, s1)
23         self.addLink(s3, s1)
24
25         # Four hosts
26         h1 = self.addHost('h1')
27         h2 = self.addHost('h2')
28         h3 = self.addHost('h3')
29         h4 = self.addHost('h4')
30
31         # Connect hosts to switches
32         self.addLink(h1, s2, bw=10) # These two links get limited
33         self.addLink(h2, s2, bw=10)
34         self.addLink(h3, s3)
35         self.addLink(h4, s3)
36
37 topos = { 'affinity' : (lambda: CustomTopo()) }