-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_topology_c_5.py
84 lines (75 loc) · 2.82 KB
/
test_topology_c_5.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
79
80
81
82
83
84
#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSKernelSwitch, UserSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.link import Link, TCLink
def topology():
natIP = '10.0.0.20'
private_dirs = [("/etc/ssl/private/", "/home/ubuntu")]
net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch)
c0 = net.addController('c0', controller=RemoteController, ip='127.0.0.1', port=6633)
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
# s3 = net.addSwitch('s3')
# s4 = net.addSwitch('s4')
# s5 = net.addSwitch('s5')
s6 = net.addSwitch('s6')
s7 = net.addSwitch('s7')
# s8 = net.addSwitch('s8')
# s9 = net.addSwitch('s9')
s10 = net.addSwitch('s10')
h1 = net.addHost('h1', mac='f6:c0:28:8f:a5:9a', defaultRoute='via ' + natIP)
net.addLink(s6, h1, bw=100)
# h2 = net.addHost('h2', mac='d2:77:87:57:5d:69', defaultRoute='via ' + natIP)
# net.addLink(s9, h2, bw=100)
# h3 = net.addHost('h3', mac='8a:ae:bc:42:55:d8', defaultRoute='via ' + natIP)
# net.addLink(s3, h3, bw=100)
# h4 = net.addHost('h4', mac='f6:c3:e5:59:2a:6d', defaultRoute='via ' + natIP)
# net.addLink(s4, h4, bw=100)
h5 = net.addHost('h5', mac='5a:0d:09:aa:cd:f8', defaultRoute='via ' + natIP)
net.addLink(s1, h5, bw=100)
h6 = net.addHost('h6', mac='96:f3:f8:b7:84:ab', defaultRoute='via ' + natIP)
net.addLink(s2, h6, bw=100)
h7 = net.addHost('h7', mac='72:9e:d8:59:8b:d0', defaultRoute='via ' + natIP)
net.addLink(s2, h7, bw=100)
# h8 = net.addHost('h8', mac='1e:75:d8:41:51:f9', defaultRoute='via ' + natIP)
# net.addLink(s5, h8, bw=100)
h9 = net.addHost('h9', mac='4a:e2:74:fa:3e:c7', defaultRoute='via ' + natIP)
net.addLink(s2, h9, bw=100)
h10 = net.addHost('h10', mac='ba:a7:e7:40:7e:95', defaultRoute='via ' + natIP)
net.addLink(s7, h10, bw=100)
net.addLink(s1, s2, bw=57)
net.addLink(s1, s6, bw=9)
# net.addLink(s1, s6, bw=93)
net.addLink(s2, s10, bw=9)
# net.addLink(s2, s10, bw=93)
net.addLink(s7, s10, bw=100)
net.addLink(s6, s7, bw=100)
# Add NAT connectivity
nat0 = net.addNAT('nat0', ip=natIP, mac='42:ef:43:7c:76:0d', localIntf='eth0', connect=None, inNamespace=False)
net.addLink(nat0, s1)
net.start()
set_arp_hosts(net)
net.staticArp()
c0.start()
s1.start([c0])
s2.start([c0])
# s3.start([c0])
# s4.start([c0])
# s5.start([c0])
s6.start([c0])
s7.start([c0])
# s8.start([c0])
# s9.start([c0])
s10.start([c0])
CLI(net)
net.stop()
def set_arp_hosts(net):
for src in net.hosts:
for dst in net.hosts:
if src != dst:
src.setARP(dst.IP(), dst.MAC())
if __name__ == '__main__':
setLogLevel('info')
topology()