-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter_topo.py
45 lines (35 loc) · 1.19 KB
/
router_topo.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
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
class RouterTopo(Topo):
def build(self):
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
r1 = self.addHost('r1')
self.addLink(h1, r1)
self.addLink(h2, r1)
self.addLink(h3, r1)
if __name__ == '__main__':
topo = RouterTopo()
net = Mininet(topo = topo, controller = None)
h1, h2, h3, r1 = net.get('h1', 'h2', 'h3', 'r1')
h1.cmd('ifconfig h1-eth0 10.0.1.11/24')
h2.cmd('ifconfig h2-eth0 10.0.2.22/24')
h3.cmd('ifconfig h3-eth0 10.0.3.33/24')
h1.cmd('route add default gw 10.0.1.1')
h2.cmd('route add default gw 10.0.2.1')
h3.cmd('route add default gw 10.0.3.1')
for h in (h1, h2, h3):
h.cmd('./scripts/disable_offloading.sh')
h.cmd('./scripts/disable_ipv6.sh')
r1.cmd('ifconfig r1-eth0 10.0.1.1/24')
r1.cmd('ifconfig r1-eth1 10.0.2.1/24')
r1.cmd('ifconfig r1-eth2 10.0.3.1/24')
r1.cmd('./scripts/disable_arp.sh')
r1.cmd('./scripts/disable_icmp.sh')
r1.cmd('./scripts/disable_ip_forward.sh')
net.start()
CLI(net)
net.stop()