-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopo.py
62 lines (48 loc) · 1.18 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from mininet.node import CPULimitedHost, RemoteController, OVSSwitch
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.log import setLogLevel, info
from mininet.cli import CLI
class CustomTopo( Topo ):
# Crea topologia personalizada
def __init__(self, **opts):
# Inicializa la topologia
super(CustomTopo, self).__init__(**opts)
# Agrega los hosts
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
# Agrega los switches
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
# Agrega los enlaces
self.addLink(s1, s2)
# s1
self.addLink(h1, s1)
self.addLink(h2, s1)
self.addLink(h3, s1)
# s2
self.addLink(h4, s2)
def run():
# Crea el controlador
c = RemoteController('c', '127.0.0.1', 6633)
# Crea la red
net = Mininet(
topo=CustomTopo(),
controller=None,
host=CPULimitedHost,
switch=OVSSwitch,
)
# Agrega el controlador
net.addController(c)
# Inicia la red
net.start()
# Ejecuta la aplicacion
CLI(net)
# Detiene la red
net.stop()
# sudo custom/nombre.py:
if __name__ == '__main__':
setLogLevel('info')
run()