This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fat3.py
78 lines (69 loc) · 2.5 KB
/
fat3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
mn.py:
Script for running our sample topology on mininet
and connect it into contorller on remote host.
Usage (example uses IP = 192.168.1.2):
From the command line:
sudo python mn.py --ip 192.168.1.2
"""
import argparse
from mininet.net import Mininet
from mininet.net import CLI
from mininet.log import setLogLevel
from mininet.node import RemoteController
from mininet.topo import Topo
from mininet.link import TCLink
class SampleTopo(Topo):
"""
Subclass of mininet Topo class for
creating fat-tree topology.
"""
def build(self, *args, **kwargs):
core1 = self.addSwitch(name='s1')
core2 = self.addSwitch(name='s2')
agg1 = self.addSwitch(name='s3')
agg2 = self.addSwitch(name='s4')
edge1 = self.addSwitch(name='s5')
edge2 = self.addSwitch(name='s6')
edge3 = self.addSwitch(name='s7')
edge4 = self.addSwitch(name='s8')
host1 = self.addHost(name='h1', mac="00:00:00:00:00:01")
host2 = self.addHost(name='h2', mac="00:00:00:00:00:02")
host3 = self.addHost(name='h3', mac="00:00:00:00:00:03")
host4 = self.addHost(name='h4', mac="00:00:00:00:00:04")
host5 = self.addHost(name='h5', mac="00:00:00:00:00:05")
host6 = self.addHost(name='h6', mac="00:00:00:00:00:06")
host7 = self.addHost(name='h7', mac="00:00:00:00:00:07")
host8 = self.addHost(name='h8', mac="00:00:00:00:00:08")
self.addLink(host1, edge1)
self.addLink(host2, edge1)
self.addLink(host3, edge2)
self.addLink(host4, edge2)
self.addLink(host5, edge3)
self.addLink(host6, edge3)
self.addLink(host7, edge4)
self.addLink(host8, edge4)
self.addLink(agg1, edge1)
self.addLink(agg1, edge2)
self.addLink(agg2, edge3)
self.addLink(agg2, edge4)
self.addLink(agg1, core1)
self.addLink(agg2, core1)
self.addLink(agg1, core2)
self.addLink(agg2, core2)
if __name__ == '__main__':
PARSER = argparse.ArgumentParser()
PARSER.add_argument('ips', metavar='ip',
help='POX Network Controllers IP Addresses',
default=['127.0.0.1'], type=str, nargs='*')
CLI_ARGS = PARSER.parse_args()
setLogLevel('info')
RCS = []
for ip in CLI_ARGS.ips:
RCS.append(RemoteController('POX-%s' % ip, ip=ip, port=6633))
NET = Mininet(topo=SampleTopo(), link=TCLink, autoSetMacs=True)
for rc in RCS:
NET.addController(rc)
NET.start()
CLI(NET)
NET.stop()