-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopology.py
40 lines (30 loc) · 897 Bytes
/
topology.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
from mininet.topo import Topo
# Simple topology: 2 hosts, 1 switch
# h1 <-> s1 <-> h2
class SimpleTopo(Topo):
def __init__(self):
Topo.__init__(self)
leftHost = self.addHost('h1')
rightHost = self.addHost('h2')
switch = self.addSwitch('s1')
self.addLink(leftHost, switch)
self.addLink(switch, rightHost)
# More complex topology: 6 hosts, 1 switch
# h1 h4
# \ /
# h2 - s1 - h5
# / \
# h3 h6
class DDoSTopo(Topo):
def __init__(self):
Topo.__init__(self)
ddos_hosts = [self.addHost(f'h{i}') for i in range(1, 6)]
target_host = self.addHost('h6')
switch = self.addSwitch('s1')
for host in ddos_hosts:
self.addLink(host, switch)
self.addLink(target_host, switch)
topos = {
'simple': (lambda: SimpleTopo()),
'ddos': (lambda: DDoSTopo())
}