-
Notifications
You must be signed in to change notification settings - Fork 4
/
SimpleOptTopo.py
67 lines (53 loc) · 2.41 KB
/
SimpleOptTopo.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
#!/usr/bin/python
from opticalUtils import MininetOE, OpticalSwitch, OpticalLink
from mininet.topo import Topo
from mininet.log import setLogLevel
from mininet.node import RemoteController
from mininet.cli import CLI
"""
Note that this file uses some of the libraries provided by ONOS. The library takes care of seting up the LINC (optical switches).
"""
class SmallOptTopo(Topo):
def build(self):
o1ann = {"latitude": 37.6, "longitude": -122.3, "optical.regens": 0}
o1 = self.addSwitch('OPT-001', dpid='0000ffffffffff01', annotations=o1ann, cls=OpticalSwitch)
o2ann = {"latitude": 37.6, "longitude": -122.3, "optical.regens": 0}
o2 = self.addSwitch('OPT-002', dpid='0000ffffffffff02', annotations=o2ann, cls=OpticalSwitch)
pkt1 = self.addSwitch('PK1-R10', dpid='0000000000000001', annotations={"latitude": 37.6, "longitude": -122.3})
pkt2 = self.addSwitch('PK2-R10', dpid='0000000000000002', annotations={"latitude": 33.9, "longitude": -118.4})
# Connecting two optical switches
self.addLink(o1, o2, port1=10, port2=20,
annotations={"optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true"},
cls=OpticalLink)
# Connecting pkt2 to O2
self.addLink(pkt2, o2, port1=22, port2=21,
annotations={"bandwidth": 100000,
"optical.type": "cross-connect",
"durable": "true"},
cls=OpticalLink)
# Connecting pkt1 to O1
self.addLink(pkt1, o1, port1=12, port2=11,
annotations={"bandwidth": 100000,
"optical.type": "cross-connect",
"durable": "true"},
cls=OpticalLink)
# Adding hosts
h1 = self.addHost('h1')
h2 = self.addHost('h2')
self.addLink(pkt1, h1, port1=1)
self.addLink(pkt2, h2, port1=1)
if __name__ == '__main__':
import sys
if len(sys.argv) >= 2:
controllers = sys.argv[1:]
else:
print 'Usage: ./opticalUtils.py (<Controller IP>)+'
print 'Using localhost...\n'
controllers = ['127.0.1.1']
setLogLevel('info')
net = MininetOE(topo=SmallOptTopo(), controller=None,
autoSetMacs=True)
net.addControllers(controllers)
net.start()
CLI(net)
net.stop()