Brian O'Connor
Committed by Pavlin Radoslavov

Adding optical topo files

[Merged from onos-1.0]

Change-Id: I276454b09d32e1a7b7182271ddba8cf6add71c40
(cherry picked from commit e84ab32f)
1 +#!/usr/bin/python
2 +
3 +from opticalUtils import MininetOE, OpticalSwitch, OpticalLink
4 +from mininet.topo import Topo
5 +from mininet.log import setLogLevel
6 +from mininet.node import RemoteController
7 +from mininet.cli import CLI
8 +
9 +class SmallOpticalTopo( Topo ):
10 +
11 + def build( self ):
12 + o1ann = { "latitude": 37.6, "longitude": -122.3, "optical.regens": 0 }
13 + O1 = self.addSwitch( 'SFO-W10', dpid='0000ffffffffff01', annotations=o1ann, cls=OpticalSwitch )
14 + o2ann = { "latitude": 37.3, "longitude": -121.9, "optical.regens": 0 }
15 + O2 = self.addSwitch( 'SJC-W10', dpid='0000ffffffffff02', annotations=o2ann, cls=OpticalSwitch )
16 + o3ann = { "latitude": 33.9, "longitude": -118.4, "optical.regens": 0 }
17 + O3 = self.addSwitch( 'LAX-W10', dpid='0000ffffffffff03', annotations=o3ann, cls=OpticalSwitch )
18 + o4ann = { "latitude": 32.8, "longitude": -117.1, "optical.regens": 3 }
19 + O4 = self.addSwitch( 'SDG-W10', dpid='0000ffffffffff04', annotations=o4ann, cls=OpticalSwitch )
20 + o5ann = { "latitude": 44.8, "longitude": -93.1, "optical.regens": 3 }
21 + O5 = self.addSwitch( 'MSP-M10', dpid='0000ffffffffff05', annotations=o5ann, cls=OpticalSwitch )
22 + o6ann = { "latitude": 32.8, "longitude": -97.1, "optical.regens": 3 }
23 + O6 = self.addSwitch( 'DFW-M10', dpid='0000ffffffffff06', annotations=o6ann, cls=OpticalSwitch )
24 + o7ann = { "latitude": 41.8, "longitude": -87.6, "optical.regens": 3 }
25 + O7 = self.addSwitch( 'CHG-N10', dpid='0000ffffffffff07', annotations=o7ann, cls=OpticalSwitch )
26 + o8ann = { "latitude": 38.8, "longitude": -77.1, "optical.regens": 3 }
27 + O8 = self.addSwitch( 'IAD-M10', dpid='0000ffffffffff08', annotations=o8ann, cls=OpticalSwitch )
28 + o9ann = { "latitude": 40.8, "longitude": -73.1, "optical.regens": 0 }
29 + O9 = self.addSwitch( 'JFK-M10', dpid='0000ffffffffff09', annotations=o9ann, cls=OpticalSwitch )
30 + o10ann = { "latitude": 33.8, "longitude": -84.1, "optical.regens": 0 }
31 + O10 = self.addSwitch( 'ATL-S10', dpid='0000ffffffffff0A', annotations=o10ann, cls=OpticalSwitch )
32 +
33 +
34 + SFOR10 = self.addSwitch( 'SFO-R10', dpid='0000ffffffff0001', annotations={"latitude": 37.6, "longitude": -122.3} )
35 + LAXR10 = self.addSwitch( 'LAX-R10', dpid='0000ffffffff0002', annotations={ "latitude": 33.9, "longitude": -118.4 } )
36 + SDGR10 = self.addSwitch( 'SDG-R10', dpid='0000ffffffff0003', annotations={ "latitude": 32.8, "longitude": -117.1 } )
37 + CHGR10 = self.addSwitch( 'CHG-R10', dpid='0000ffffffff0004', annotations={ "latitude": 41.8, "longitude": -87.6 } )
38 + JFKR10 = self.addSwitch( 'JFK-R10', dpid='0000ffffffff0005', annotations={ "latitude": 40.8, "longitude": -73.1 } )
39 + ATLR10 = self.addSwitch( 'ATL-R10', dpid='0000ffffffff0006', annotations={ "latitude": 33.8, "longitude": -84.1 } )
40 +
41 + self.addLink( O1, O2, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
42 + self.addLink( O2, O3, port1=50, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
43 + self.addLink( O3, O4, port1=50, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
44 + self.addLink( O1, O5, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
45 + self.addLink( O2, O5, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
46 + self.addLink( O3, O6, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
47 + self.addLink( O4, O6, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
48 + self.addLink( O5, O6, port1=30, port2=40, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
49 + self.addLink( O5, O7, port1=40, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
50 + self.addLink( O6, O8, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
51 + self.addLink( O7, O8, port1=20, port2=30, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
52 + self.addLink( O7, O9, port1=30, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
53 + self.addLink( O8, O10, port1=20, port2=50, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
54 + self.addLink( O9, O10, port1=20, port2=20, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" }, cls=OpticalLink )
55 +
56 + self.addLink( SFOR10, O1, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
57 + self.addLink( LAXR10, O3, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
58 + # added second tap
59 + self.addLink( LAXR10, O3, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
60 + self.addLink( SDGR10, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
61 + self.addLink( CHGR10, O7, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
62 + self.addLink( JFKR10, O9, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
63 + self.addLink( ATLR10, O10, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
64 +
65 + h1 = self.addHost( 'h1' )
66 + h2 = self.addHost( 'h2' )
67 + h3 = self.addHost( 'h3' )
68 + h4 = self.addHost( 'h4' )
69 + h5 = self.addHost( 'h5' )
70 + h6 = self.addHost( 'h6' )
71 +
72 + self.addLink( SFOR10, h1, port1=1 )
73 + self.addLink( LAXR10, h2, port1=1 )
74 + self.addLink( SDGR10, h3, port1=1 )
75 + self.addLink( CHGR10, h4, port1=1 )
76 + self.addLink( JFKR10, h5, port1=1 )
77 + self.addLink( ATLR10, h6, port1=1 )
78 +
79 +if __name__ == '__main__':
80 + import sys
81 + if len( sys.argv ) >= 2:
82 + controllers = sys.argv[1:]
83 + else:
84 + print 'Usage: ./opticalUtils.py (<Controller IP>)+'
85 + print 'Using localhost...\n'
86 + controllers = [ '127.0.0.1' ]
87 +
88 + setLogLevel( 'info' )
89 + net = MininetOE( topo=SmallOpticalTopo(), controller=None, autoSetMacs=True )
90 + net.addControllers( controllers )
91 + net.start()
92 + CLI( net )
93 + net.stop()
1 +#!/usr/bin/python
2 +
3 +from opticalUtils import MininetOE, OpticalSwitch, OpticalLink
4 +from mininet.topo import Topo
5 +from mininet.log import setLogLevel
6 +from mininet.node import RemoteController
7 +from mininet.cli import CLI
8 +
9 +class BigOpticalTopo( Topo ):
10 +
11 + def build( self ):
12 + # Optical layer ROADMs
13 + o1ann = { "latitude": 32.508086, "longitude": -99.741564, "optical.regens": 0 }
14 + O1 = self.addSwitch( 'ABLNTXRO', dpid='0000ffffffffff01', annotations=o1ann, cls=OpticalSwitch )
15 + o2ann = { "latitude": 35.084446, "longitude": -106.649719, "optical.regens": 0 }
16 + O2 = self.addSwitch( 'ALBQNMMA', dpid='0000ffffffffff02', annotations=o2ann, cls=OpticalSwitch )
17 + o3ann = { "latitude": 42.652222, "longitude": -73.758333, "optical.regens": 0 }
18 + O3 = self.addSwitch( 'ALBYNYSS', dpid='0000ffffffffff03', annotations=o3ann, cls=OpticalSwitch )
19 + o4ann = { "latitude": 33.755833, "longitude": -97.743057, "optical.regens": 5 }
20 + O4 = self.addSwitch( 'ATLNGATL', dpid='0000ffffffffff04', annotations=o4ann, cls=OpticalSwitch ) # ATLNGATL Connected to packet node
21 + o5ann = { "latitude": 42.882778, "longitude": -78.877778, "optical.regens": 0 }
22 + O5 = self.addSwitch( 'BFLONYFR', dpid='0000ffffffffff05', annotations=o5ann, cls=OpticalSwitch )
23 + o6ann = { "latitude": 45.781667, "longitude": -108.509167, "optical.regens": 0 }
24 + O6 = self.addSwitch( 'BLNGMTMA', dpid='0000ffffffffff06', annotations=o6ann, cls=OpticalSwitch )
25 + o7ann = { "latitude": 39.293781, "longitude": -76.614127, "optical.regens": 0 }
26 + O7 = self.addSwitch( 'BLTMMDCH', dpid='0000ffffffffff07', annotations=o7ann, cls=OpticalSwitch )
27 + o8ann = { "latitude": 33.517223, "longitude": -86.812225, "optical.regens": 0 }
28 + O8 = self.addSwitch( 'BRHMALMT', dpid='0000ffffffffff08', annotations=o8ann, cls=OpticalSwitch )
29 + o9ann = { "latitude": 46.836379, "longitude": -100.796917, "optical.regens": 0 }
30 + O9 = self.addSwitch( 'BSMRNDJC', dpid='0000ffffffffff09', annotations=o9ann, cls=OpticalSwitch )
31 + o10ann = { "latitude": 30.449722, "longitude": -91.184167, "optical.regens": 0 }
32 + O10 = self.addSwitch( 'BTRGLAMA', dpid='0000ffffffffff0A', annotations=o10ann, cls=OpticalSwitch )
33 + o11ann = { "latitude": 41.881484, "longitude": -87.640432, "optical.regens": 4 }
34 + O11 = self.addSwitch( 'CHCGILCL', dpid='0000ffffffffff0B', annotations=o11ann, cls=OpticalSwitch )
35 + o12ann = { "latitude": 35.224924, "longitude": -80.837502, "optical.regens": 0 }
36 + O12 = self.addSwitch( 'CHRLNCCA', dpid='0000ffffffffff0C', annotations=o12ann, cls=OpticalSwitch )
37 + o13ann = { "latitude": 32.785278, "longitude": -79.938056, "optical.regens": 0 }
38 + O13 = self.addSwitch( 'CHTNSCDT', dpid='0000ffffffffff0D', annotations=o13ann, cls=OpticalSwitch )
39 + o14ann = { "latitude": 41.498333, "longitude": -81.686943, "optical.regens": 0 }
40 + O14 = self.addSwitch( 'CLEVOH02', dpid='0000ffffffffff0E', annotations=o14ann, cls=OpticalSwitch )
41 + o15ann = { "latitude": 39.965279, "longitude": -82.996666, "optical.regens": 0 }
42 + O15 = self.addSwitch( 'CLMBOH11', dpid='0000ffffffffff0F', annotations=o15ann, cls=OpticalSwitch )
43 + o16ann = { "latitude": 42.36745, "longitude": -71.084918, "optical.regens": 0 }
44 + O16 = self.addSwitch( 'CMBRMA01', dpid='0000ffffffffff10', annotations=o16ann, cls=OpticalSwitch )
45 + o17ann = { "latitude": 39.102778, "longitude": -84.516944, "optical.regens": 0 }
46 + O17 = self.addSwitch( 'CNCNOHWS', dpid='0000ffffffffff11', annotations=o17ann, cls=OpticalSwitch )
47 + o18ann = { "latitude": 32.797524, "longitude": -96.780431, "optical.regens": 0 }
48 + O18 = self.addSwitch( 'DLLSTXTL', dpid='0000ffffffffff12', annotations=o18ann, cls=OpticalSwitch ) # DLLSTXTL Connected to packet node
49 + o19ann = { "latitude": 39.744999, "longitude": -104.996391, "optical.regens": 0 }
50 + O19 = self.addSwitch( 'DNVRCOMA', dpid='0000ffffffffff13', annotations=o19ann, cls=OpticalSwitch )
51 + o20ann = { "latitude": 42.332779, "longitude": -83.054169, "optical.regens": 5 }
52 + O20 = self.addSwitch( 'DTRTMIBA', dpid='0000ffffffffff14', annotations=o20ann, cls=OpticalSwitch )
53 + o21ann = { "latitude": 31.756389, "longitude": -106.483611, "optical.regens": 0 }
54 + O21 = self.addSwitch( 'ELPSTXMA', dpid='0000ffffffffff15', annotations=o21ann, cls=OpticalSwitch )
55 + o22ann = { "latitude": 36.73923, "longitude": -119.79423, "optical.regens": 0 }
56 + O22 = self.addSwitch( 'FRSNCA01', dpid='0000ffffffffff16', annotations=o22ann, cls=OpticalSwitch )
57 + o23ann = { "latitude": 36.072222, "longitude": -79.793889, "optical.regens": 0 }
58 + O23 = self.addSwitch( 'GNBONCEU', dpid='0000ffffffffff17', annotations=o23ann, cls=OpticalSwitch )
59 + o24ann = { "latitude": 41.765833, "longitude": -72.676389, "optical.regens": 0 }
60 + O24 = self.addSwitch( 'HRFRCT03', dpid='0000ffffffffff18', annotations=o24ann, cls=OpticalSwitch )
61 + o25ann = { "latitude": 29.748333, "longitude": -95.36528, "optical.regens": 0 }
62 + O25 = self.addSwitch( 'HSTNTX01', dpid='0000ffffffffff19', annotations=o25ann, cls=OpticalSwitch )
63 + o26ann = { "latitude": 30.33071, "longitude": -81.43, "optical.regens": 0 }
64 + O26 = self.addSwitch( 'JCVLFLCL', dpid='0000ffffffffff1A', annotations=o26ann, cls=OpticalSwitch )
65 + o27ann = { "latitude": 39.096649, "longitude": -94.578716, "optical.regens": 0 }
66 + O27 = self.addSwitch( 'KSCYMO09', dpid='0000ffffffffff1B', annotations=o27ann, cls=OpticalSwitch )
67 + o28ann = { "latitude": 40.5899999,"longitude": -73.6699993, "optical.regens": 0 }
68 + O28 = self.addSwitch( 'Island', dpid='0000ffffffffff1C', annotations=o28ann, cls=OpticalSwitch )
69 + o29ann = { "latitude": 34.051227, "longitude": -118.252958, "optical.regens": 0 }
70 + O29 = self.addSwitch( 'LSANCA03', dpid='0000ffffffffff1D', annotations=o29ann, cls=OpticalSwitch ) # LSANCA03 Connected to packet node
71 + o30ann = { "latitude": 36.168056, "longitude": -115.138889, "optical.regens": 0 }
72 + O30 = self.addSwitch( 'LSVGNV02', dpid='0000ffffffffff1E', annotations=o30ann, cls=OpticalSwitch )
73 + o31ann = { "latitude":38.249167, "longitude": -85.760833, "optical.regens": 0 }
74 + O31 = self.addSwitch( 'LSVLKYCS', dpid='0000ffffffffff1F', annotations=o31ann, cls=OpticalSwitch )
75 + o32ann = { "latitude": 34.740833, "longitude": -92.271942, "optical.regens": 2 }
76 + O32 = self.addSwitch( 'LTRKARFR', dpid='0000ffffffffff20', annotations=o32ann, cls=OpticalSwitch )
77 + o33ann = { "latitude": 25.779167, "longitude": -80.195, "optical.regens": 0 }
78 + O33 = self.addSwitch( 'MIAMFLAC', dpid='0000ffffffffff21', annotations=o33ann, cls=OpticalSwitch )
79 + o34ann = { "latitude": 43.037224, "longitude": -87.922501, "optical.regens": 0 }
80 + O34 = self.addSwitch( 'MILWWIHE', dpid='0000ffffffffff22', annotations=o34ann, cls=OpticalSwitch )
81 + o35ann = { "latitude": 35.145158, "longitude": -90.048058, "optical.regens": 0 }
82 + O35 = self.addSwitch( 'MMPHTNMA', dpid='0000ffffffffff23', annotations=o35ann, cls=OpticalSwitch )
83 + o36ann = { "latitude": 44.977365, "longitude": -93.26718, "optical.regens": 0 }
84 + O36 = self.addSwitch( 'MPLSMNDT', dpid='0000ffffffffff24', annotations=o36ann, cls=OpticalSwitch ) # MPLSMNDT Connected to packet node
85 + o37ann = { "latitude": 36.853333, "longitude": -76.29, "optical.regens": 0 }
86 + O37 = self.addSwitch( 'NRFLVABS', dpid='0000ffffffffff25', annotations=o37ann, cls=OpticalSwitch )
87 + o38ann = { "latitude": 36.163955, "longitude": -86.775558, "optical.regens": 0 }
88 + O38 = self.addSwitch( 'NSVLTNMT', dpid='0000ffffffffff26', annotations=o38ann, cls=OpticalSwitch )
89 + o39ann = { "latitude": 29.949806, "longitude": -90.07222, "optical.regens": 0 }
90 + O39 = self.addSwitch( 'NWORLAMA', dpid='0000ffffffffff27', annotations=o39ann, cls=OpticalSwitch )
91 + o40ann = { "latitude": 40.734408, "longitude": -74.177978, "optical.regens": 0 }
92 + O40 = self.addSwitch( 'NWRKNJ02', dpid='0000ffffffffff28', annotations=o40ann, cls=OpticalSwitch ) # NWRKNJ02 Connected to packet node
93 + o41ann = { "latitude": 40.767497, "longitude": -73.989713, "optical.regens": 0 }
94 + O41 = self.addSwitch( 'NYCMNY54', dpid='0000ffffffffff29', annotations=o41ann, cls=OpticalSwitch )
95 + o42ann = { "latitude": 35.470833, "longitude": -97.515274, "optical.regens": 0 }
96 + O42 = self.addSwitch( 'OKCYOKCE', dpid='0000ffffffffff2A', annotations=o42ann, cls=OpticalSwitch )
97 + o43ann = { "latitude": 37.805556, "longitude": -122.268889, "optical.regens": 2 }
98 + O43 = self.addSwitch( 'OKLDCA03', dpid='0000ffffffffff2B', annotations=o43ann, cls=OpticalSwitch )
99 + o44ann = { "latitude": 41.259167, "longitude":-95.940277, "optical.regens": 0 }
100 + O44 = self.addSwitch( 'OMAHNENW', dpid='0000ffffffffff2C', annotations=o44ann, cls=OpticalSwitch )
101 + o45ann = { "latitude": 28.543279, "longitude": -81.377502, "optical.regens": 0 }
102 + O45 = self.addSwitch( 'ORLDFLMA', dpid='0000ffffffffff2D', annotations=o45ann, cls=OpticalSwitch ) # ORLDFLMA Connected to packet node
103 + o46ann = { "latitude": 39.946446, "longitude": -75.184139, "optical.regens": 0 }
104 + O46 = self.addSwitch( 'PHLAPASL', dpid='0000ffffffffff2E', annotations=o46ann, cls=OpticalSwitch )
105 + o47ann = { "latitude": 33.450361, "longitude": -112.07709, "optical.regens": 0 }
106 + O47 = self.addSwitch( 'PHNXAZMA', dpid='0000ffffffffff2F', annotations=o47ann, cls=OpticalSwitch ) # PHNXAZMA Connected to packet node
107 + o48ann = { "latitude":40.441387, "longitude": -79.995552, "optical.regens": 0 }
108 + O48 = self.addSwitch( 'PITBPADG', dpid='0000ffffffffff30', annotations=o48ann, cls=OpticalSwitch )
109 + o49ann = { "latitude":41.818889, "longitude": -71.415278, "optical.regens": 0 }
110 + O49 = self.addSwitch( 'PRVDRIGR', dpid='0000ffffffffff31', annotations=o49ann, cls=OpticalSwitch )
111 + o50ann = { "latitude": 45.522499, "longitude": -122.678055, "optical.regens": 2 }
112 + O50 = self.addSwitch( 'PTLDOR62', dpid='0000ffffffffff32', annotations=o50ann, cls=OpticalSwitch )
113 + o51ann = { "latitude": 37.540752, "longitude": -77.436096, "optical.regens": 0 }
114 + O51 = self.addSwitch( 'RCMDVAGR', dpid='0000ffffffffff33', annotations=o51ann, cls=OpticalSwitch )
115 + o52ann = { "latitude": 35.779656, "longitude": -78.640831, "optical.regens": 0 }
116 + O52 = self.addSwitch( 'RLGHNCMO', dpid='0000ffffffffff34', annotations=o52ann, cls=OpticalSwitch )
117 + o53ann = { "latitude": 43.157222, "longitude": -77.616389, "optical.regens": 0 }
118 + O53 = self.addSwitch( 'ROCHNYXA', dpid='0000ffffffffff35', annotations=o53ann, cls=OpticalSwitch ) # ROCHNYXA Connected to packet node
119 + o54ann = { "latitude": 38.578609, "longitude": -121.487221, "optical.regens": 0 }
120 + O54 = self.addSwitch( 'SCRMCA01', dpid='0000ffffffffff36', annotations=o54ann, cls=OpticalSwitch )
121 + o55ann = { "latitude": 41.415278, "longitude": -75.649167, "optical.regens": 0 }
122 + O55 = self.addSwitch( 'SCTNPA01', dpid='0000ffffffffff37', annotations=o55ann, cls=OpticalSwitch )
123 + o56ann = { "latitude": 40.767776, "longitude": -111.888336, "optical.regens": 0 }
124 + O56 = self.addSwitch( 'SLKCUTMA', dpid='0000ffffffffff38', annotations=o56ann, cls=OpticalSwitch )
125 + o57ann = { "latitude": 29.429445, "longitude": -98.488892, "optical.regens": 0 }
126 + O57 = self.addSwitch( 'SNANTXCA', dpid='0000ffffffffff39', annotations=o57ann, cls=OpticalSwitch ) # SNANTXCA Connected to packet node
127 + o58ann = { "latitude": 34.418889, "longitude": -119.7, "optical.regens": 0 }
128 + O58 = self.addSwitch( 'SNBBCA01', dpid='0000ffffffffff40', annotations=o58ann, cls=OpticalSwitch )
129 + o59ann = { "latitude":32.746944, "longitude": -117.158611, "optical.regens": 0 }
130 + O59= self.addSwitch( 'SNDGCA02', dpid='0000ffffffffff41', annotations=o59ann, cls=OpticalSwitch )
131 + o60ann = { "latitude":37.785143, "longitude": -122.397263, "optical.regens": 0 }
132 + O60 = self.addSwitch( 'SNFCCA21', dpid='0000ffffffffff42', annotations=o60ann, cls=OpticalSwitch )
133 + o61ann = { "latitude": 37.333333, "longitude": -121.892778, "optical.regens": 0 }
134 + O61 = self.addSwitch( 'SNJSCA02', dpid='0000ffffffffff43', annotations=o61ann, cls=OpticalSwitch ) # SNJSCA02 Connected to packet node
135 + o62ann = { "latitude": 39.795278, "longitude": -89.649444, "optical.regens": 0 }
136 + O62 = self.addSwitch( 'SPFDILSD', dpid='0000ffffffffff44', annotations=o62ann, cls=OpticalSwitch )
137 + o63ann = { "latitude": 47.654724, "longitude": -117.419167, "optical.regens": 0 }
138 + O63 = self.addSwitch( 'SPKNWA01', dpid='0000ffffffffff45', annotations=o63ann, cls=OpticalSwitch )
139 + o64ann = { "latitude": 38.633335, "longitude": -90.215279, "optical.regens": 0 }
140 + O64 = self.addSwitch( 'STLSMO09', dpid='0000ffffffffff46', annotations=o64ann, cls=OpticalSwitch )
141 + o65ann = { "latitude": 47.606945, "longitude": -122.333336, "optical.regens": 0 }
142 + O65 = self.addSwitch( 'STTLWA06', dpid='0000ffffffffff47', annotations=o65ann, cls=OpticalSwitch )
143 + o66ann = { "latitude": 43.049444, "longitude": -76.1475, "optical.regens": 3 }
144 + O66 = self.addSwitch( 'SYRCNYSU', dpid='0000ffffffffff48', annotations=o66ann, cls=OpticalSwitch )
145 + o67ann = { "latitude": 28.0225, "longitude": -82.522778, "optical.regens": 0 }
146 + O67 = self.addSwitch( 'TAMQFLFN', dpid='0000ffffffffff49', annotations=o67ann, cls=OpticalSwitch )
147 + o68ann = { "latitude": 32.224444, "longitude": -110.968333, "optical.regens": 0 }
148 + O68 = self.addSwitch( 'TCSNAZMA', dpid='0000ffffffffff4A', annotations=o68ann, cls=OpticalSwitch )
149 + o69ann = { "latitude": 30.456389,"longitude": -84.290833, "optical.regens": 0 }
150 + O69 = self.addSwitch( 'TLHSFLAT', dpid='0000ffffffffff4B', annotations=o69ann, cls=OpticalSwitch )
151 + o70ann = { "latitude": 41.65,"longitude": -83.538056, "optical.regens": 2 }
152 + O70 = self.addSwitch( 'TOLDOH21', dpid='0000ffffffffff4C', annotations=o70ann, cls=OpticalSwitch )
153 + o71ann = { "latitude": 36.151669,"longitude": -95.985832, "optical.regens": 0 }
154 + O71 = self.addSwitch( 'TULSOKTB', dpid='0000ffffffffff4D', annotations=o71ann, cls=OpticalSwitch )
155 + o72ann = { "latitude": 38.88306 ,"longitude": -77.01028, "optical.regens": 0 }
156 + O72 = self.addSwitch( 'WASHDCSW', dpid='0000ffffffffff4E', annotations=o72ann, cls=OpticalSwitch ) # WASHDCSW Connected to packet node
157 + o73ann = { "latitude": 39.739167,"longitude": -75.553889, "optical.regens": 0 }
158 + O73 = self.addSwitch( 'WLMGDE01', dpid='0000ffffffffff4F', annotations=o73ann, cls=OpticalSwitch )
159 + o74ann = { "latitude": 26.709391,"longitude": -80.05278, "optical.regens": 0 }
160 + O74 = self.addSwitch( 'WPBHFLAN', dpid='0000ffffffffff50', annotations=o74ann, cls=OpticalSwitch )
161 +
162 +
163 + # Packet Layer switches
164 + ''' # from opticalTest.py
165 + SFOR10 = self.addSwitch( 'SFO-R10', dpid='0000ffffffff0001', annotations={"latitude": 37.6, "longitude": -122.3} )
166 + LAXR10 = self.addSwitch( 'LAX-R10', dpid='0000ffffffff0002', annotations={ "latitude": 33.9, "longitude": -118.4 } )
167 + SDGR10 = self.addSwitch( 'SDG-R10', dpid='0000ffffffff0003', annotations={ "latitude": 32.8, "longitude": -117.1 } )
168 + CHGR10 = self.addSwitch( 'CHG-R10', dpid='0000ffffffff0004', annotations={ "latitude": 41.8, "longitude": -87.6 } )
169 + JFKR10 = self.addSwitch( 'JFK-R10', dpid='0000ffffffff0005', annotations={ "latitude": 40.8, "longitude": -73.1 } )
170 + ATLR10 = self.addSwitch( 'ATL-R10', dpid='0000ffffffff0006', annotations={ "latitude": 33.8, "longitude": -84.1 } )
171 + '''
172 + WASHDCSWR = self.addSwitch( 'WASHDCSW-R', dpid='0000ffffff000001', annotations={ "latitude": 38.8, "longitude": -77.0 } ) # this switch is O72
173 + SNJSCA02R = self.addSwitch( 'SNJSCA02-R', dpid='0000ffffff000002', annotations={ "latitude": 37.3, "longitude": -121.8 } ) # O61
174 + SNANTXCAR = self.addSwitch( 'SNANTXCA-R', dpid='0000ffffff000003', annotations={ "latitude": 29.4, "longitude": -98.4 } ) # O57
175 + ROCHNYXAR = self.addSwitch( 'ROCHNYXA-R', dpid='0000ffffff000004', annotations={ "latitude": 43.1, "longitude": -77.6 } ) # O53
176 + PHNXAZMAR = self.addSwitch( 'PHNXAZMA-R', dpid='0000ffffff000005', annotations={ "latitude": 33.4, "longitude": -112.0 } ) # O47
177 + ORLDFLMAR = self.addSwitch( 'ORLDFLMA-R', dpid='0000ffffff000006', annotations={ "latitude": 28.5, "longitude": -81.3 } ) # O45
178 + NWRKNJ02R = self.addSwitch( 'NWRKNJ02-R', dpid='0000ffffff000007', annotations={ "latitude": 40.7, "longitude": -74.1 } ) # O40
179 + MPLSMNDTR = self.addSwitch( 'MPLSMNDT-R', dpid='0000ffffff000008', annotations={ "latitude": 44.9, "longitude": -93.2 } ) # O36
180 + LSANCA03R = self.addSwitch( 'LSANCA03-R', dpid='0000ffffff000009', annotations={ "latitude": 34.1, "longitude": -118.3 } ) # O29
181 + DLLSTXTLR = self.addSwitch( 'DLLSTXTL-R', dpid='0000ffffff00000a', annotations={ "latitude": 32.7, "longitude": -96.7 } ) # O18
182 + ATLNGATLR = self.addSwitch( 'ATLNGATL-R', dpid='0000ffffff00000b', annotations={ "latitude": 33.7, "longitude": -97.7 } ) # O4
183 +
184 +
185 +
186 + # Optical Links between the ROADMs (although Distance is not used; we should keep these for future reference)
187 + self.addLink( O1, O18, port1=100, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 334, "durable": "true" }, cls=OpticalLink ) # ABLNTXRO DLLSTXTL
188 + self.addLink( O1, O21, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 768, "durable": "true" }, cls=OpticalLink ) # ABLNTXRO ELPSTXMA
189 + self.addLink( O3, O16, port1=100, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 265, "durable": "true" }, cls=OpticalLink ) # ALBYNYSS CMBRMA01
190 + self.addLink( O3, O66, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 239, "durable": "true" }, cls=OpticalLink ) # ALBYNYSS SYRCNYSU
191 + self.addLink( O2, O18, port1=100, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1134, "durable": "true" }, cls=OpticalLink ) # ALBQNMMA DLLSTXTL
192 + self.addLink( O2, O19, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 646, "durable": "true" }, cls=OpticalLink ) # ALBQNMMA DNVRCOMA
193 + self.addLink( O2, O21, port1=102, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 444, "durable": "true" }, cls=OpticalLink ) # ALBQNMMA ELPSTXMA
194 + self.addLink( O2, O30, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 931, "durable": "true" }, cls=OpticalLink ) # ALBQNMMA LSVGNV02
195 + self.addLink( O4, O8, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 271, "durable": "true" }, cls=OpticalLink ) # ATLNGATL BRHMALMT
196 + self.addLink( O4, O12, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 436, "durable": "true" }, cls=OpticalLink ) # ATLNGATL CHRLNCCA
197 + self.addLink( O4, O26, port1=103, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 566, "durable": "true" }, cls=OpticalLink ) # ATLNGATL JCVLFLCL
198 + self.addLink( O5, O25, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 283, "durable": "true" }, cls=OpticalLink ) # AUSTTXGR HSTNTX01
199 + self.addLink( O5, O57, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 141, "durable": "true" }, cls=OpticalLink ) # AUSTTXGR SNANTXCA
200 + self.addLink( O7, O46, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 170, "durable": "true" }, cls=OpticalLink ) # BLTMMDCH PHLAPASL
201 + self.addLink( O7, O48, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 378, "durable": "true" }, cls=OpticalLink ) # BLTMMDCH PITBPADG
202 + self.addLink( O7, O70, port1=103, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 68, "durable": "true" }, cls=OpticalLink ) # BLTMMDCH WASHDCSW
203 + self.addLink( O10, O25, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 491, "durable": "true" }, cls=OpticalLink ) # BTRGLAMA HSTNTX01
204 + self.addLink( O10, O39, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 144, "durable": "true" }, cls=OpticalLink ) # BTRGLAMA NWORLAMA
205 + self.addLink( O6, O9, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 724, "durable": "true" }, cls=OpticalLink ) # BLNGMTMA BSMRNDJC
206 + self.addLink( O6, O19, port1=102, port2=107, annotations={ "optical.wves": 80, "optical.type": "WDM", "optical.kms": 875, "durable": "true" }, cls=OpticalLink ) # BLNGMTMA DNVRCOMA
207 + self.addLink( O6, O63, port1=103, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 852, "durable": "true" }, cls=OpticalLink ) # BLNGMTMA SPKNWA01
208 + self.addLink( O8, O38, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 353, "durable": "true" }, cls=OpticalLink ) # BRHMALMT NSVLTNMT
209 + self.addLink( O8, O39, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 602, "durable": "true" }, cls=OpticalLink ) # BRHMALMT NWORLAMA
210 + self.addLink( O9, O36, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 741, "durable": "true" }, cls=OpticalLink ) # BSMRNDJC MPLSMNDT
211 + self.addLink( O16, O49, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 80, "durable": "true" }, cls=OpticalLink ) # CMBRMA01 PRVDRIGR
212 + self.addLink( O5, O14, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 333, "durable": "true" }, cls=OpticalLink ) # BFLONYFR CLEVOH02
213 + self.addLink( O5, O53, port1=104, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 128, "durable": "true" }, cls=OpticalLink ) # BFLONYFR ROCHNYXA
214 + self.addLink( O13, O26, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 368, "durable": "true" }, cls=OpticalLink ) # CHTNSCDT JCVLFLCL
215 + self.addLink( O13, O52, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 424, "durable": "true" }, cls=OpticalLink ) # CHTNSCDT RLGHNCMO
216 + self.addLink( O12, O23, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 160, "durable": "true" }, cls=OpticalLink ) # CHRLNCCA GNBONCEU
217 + self.addLink( O11, O20, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 458, "durable": "true" }, cls=OpticalLink ) # CHCGILCL DTRTMIBA
218 + self.addLink( O11, O34, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 156, "durable": "true" }, cls=OpticalLink ) # CHCGILCL MILWWIHE
219 + self.addLink( O11, O62, port1=103, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 344, "durable": "true" }, cls=OpticalLink ) # CHCGILCL SPFDILSD
220 + self.addLink( O17, O15, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 194, "durable": "true" }, cls=OpticalLink ) # CNCNOHWS CLMBOH11
221 + self.addLink( O17, O31, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 172, "durable": "true" }, cls=OpticalLink ) # CNCNOHWS LSVLKYCS
222 + self.addLink( O17, O72, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 779, "durable": "true" }, cls=OpticalLink ) # CNCNOHWS WASHDCSW
223 + self.addLink( O14, O15, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 243, "durable": "true" }, cls=OpticalLink ) # CLEVOH02 CLMBOH11
224 + self.addLink( O14, O70, port1=102, port2=101, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 185, "durable": "true" }, cls=OpticalLink ) # CLEVOH02 TOLDOH21
225 + self.addLink( O15, O48, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 312, "durable": "true" }, cls=OpticalLink ) # CLMBOH11 PITBPADG
226 + self.addLink( O18, O25, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 437, "durable": "true" }, cls=OpticalLink ) # DLLSTXTL HSTNTX01
227 + self.addLink( O18, O32, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 563, "durable": "true" }, cls=OpticalLink ) # DLLSTXTL LTRKARFR
228 + self.addLink( O18, O42, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 365, "durable": "true" }, cls=OpticalLink ) # DLLSTXTL OKCYOKCE
229 + self.addLink( O19, O44, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 940, "durable": "true" }, cls=OpticalLink ) # DNVRCOMA OMAHNENW
230 + self.addLink( O19, O56, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 714, "durable": "true" }, cls=OpticalLink ) # DNVRCOMA SLKCUTMA
231 + self.addLink( O20, O70, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 103, "durable": "true" }, cls=OpticalLink ) # DTRTMIBA TOLDOH21
232 + self.addLink( O21, O57, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 969, "durable": "true" }, cls=OpticalLink ) # ELPSTXMA SNANTXCA
233 + self.addLink( O21, O68, port1=102, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 511, "durable": "true" }, cls=OpticalLink ) # ELPSTXMA TCSNAZMA
234 + self.addLink( O22, O31, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 505, "durable": "true" }, cls=OpticalLink ) # FRSNCA01 LSVGNV02
235 + self.addLink( O22, O29, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 396, "durable": "true" }, cls=OpticalLink ) # FRSNCA01 LSANCA03
236 + self.addLink( O22, O42, port1=103, port2=108, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 298, "durable": "true" }, cls=OpticalLink ) # FRSNCA01 OKLDCA03
237 + self.addLink( O23, O31, port1=101, port2=108, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 697, "durable": "true" }, cls=OpticalLink ) # GNBONCEU LSVLKYCS
238 + self.addLink( O23, O52, port1=102, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 130, "durable": "true" }, cls=OpticalLink ) # GNBONCEU RLGHNCMO
239 + self.addLink( O23, O51, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 319, "durable": "true" }, cls=OpticalLink ) # GNBONCEU RCMDVAGR
240 + self.addLink( O24, O28, port1=101, port2=108, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 185, "durable": "true" }, cls=OpticalLink ) # HRFRCT03 L_Island
241 + self.addLink( O24, O49, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 125, "durable": "true" }, cls=OpticalLink ) # HRFRCT03 PRVDRIGR
242 + self.addLink( O26, O45, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 238, "durable": "true" }, cls=OpticalLink ) # JCVLFLCL ORLDFLMA
243 + self.addLink( O27, O44, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 320, "durable": "true" }, cls=OpticalLink ) # KSCYMO09 OMAHNENW
244 + self.addLink( O27, O64, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 457, "durable": "true" }, cls=OpticalLink ) # KSCYMO09 STLSMO09
245 + self.addLink( O27, O71, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 420, "durable": "true" }, cls=OpticalLink ) # KSCYMO09 TULSOKTB
246 + self.addLink( O30, O47, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 494, "durable": "true" }, cls=OpticalLink ) # LSVGNV02 PHNXAZMA
247 + self.addLink( O30, O56, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 701, "durable": "true" }, cls=OpticalLink ) # LSVGNV02 SLKCUTMA
248 + self.addLink( O32, O35, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 249, "durable": "true" }, cls=OpticalLink ) # LTRKARFR MMPHTNMA
249 + self.addLink( O28, O41, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 40, "durable": "true" }, cls=OpticalLink ) # L_Island NYCMNY54
250 + self.addLink( O29, O59, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 212, "durable": "true" }, cls=OpticalLink ) # LSANCA03 SNDGCA02
251 + self.addLink( O29, O58, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 167, "durable": "true" }, cls=OpticalLink ) # LSANCA03 SNBBCA01
252 + self.addLink( O31, O38, port1=104, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 298, "durable": "true" }, cls=OpticalLink ) # LSVLKYCS NSVLTNMT
253 + self.addLink( O31, O64, port1=102, port2=108, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 468, "durable": "true" }, cls=OpticalLink ) # LSVLKYCS STLSMO09
254 + self.addLink( O35, O38, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 380, "durable": "true" }, cls=OpticalLink ) # MMPHTNMA NSVLTNMT
255 + self.addLink( O33, O67, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 407, "durable": "true" }, cls=OpticalLink ) # MIAMFLAC TAMQFLFN
256 + self.addLink( O33, O74, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 125, "durable": "true" }, cls=OpticalLink ) # MIAMFLAC WPBHFLAN
257 + self.addLink( O34, O36, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 574, "durable": "true" }, cls=OpticalLink ) # MILWWIHE MPLSMNDT
258 + self.addLink( O36, O44, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 560, "durable": "true" }, cls=OpticalLink ) # MPLSMNDT OMAHNENW
259 + self.addLink( O39, O69, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 670, "durable": "true" }, cls=OpticalLink ) # NWORLAMA TLHSFLAT
260 + self.addLink( O41, O40, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 19, "durable": "true" }, cls=OpticalLink ) # NYCMNY54 NWRKNJ02
261 + self.addLink( O41, O55, port1=102, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 187, "durable": "true" }, cls=OpticalLink ) # NYCMNY54 SCTNPA01
262 + self.addLink( O41, O73, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 210, "durable": "true" }, cls=OpticalLink ) # NYCMNY54 WLMGDE01
263 + self.addLink( O40, O46, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 146, "durable": "true" }, cls=OpticalLink ) # NWRKNJ02 PHLAPASL
264 + self.addLink( O37, O52, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 290, "durable": "true" }, cls=OpticalLink ) # NRFLVABS RLGHNCMO
265 + self.addLink( O37, O73, port1=102, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 392, "durable": "true" }, cls=OpticalLink ) # NRFLVABS WLMGDE01
266 + self.addLink( O43, O54, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 131, "durable": "true" }, cls=OpticalLink ) # OKLDCA03 SCRMCA01
267 + self.addLink( O43, O56, port1=102, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1142, "durable": "true" }, cls=OpticalLink ) # OKLDCA03 SLKCUTMA
268 + self.addLink( O43, O60, port1=103, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 13, "durable": "true" }, cls=OpticalLink ) # OKLDCA03 SNFCCA21
269 + self.addLink( O42, O71, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 188, "durable": "true" }, cls=OpticalLink ) # OKCYOKCE TULSOKTB
270 + self.addLink( O45, O74, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 290, "durable": "true" }, cls=OpticalLink ) # ORLDFLMA WPBHFLAN
271 + self.addLink( O46, O55, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 201, "durable": "true" }, cls=OpticalLink ) # PHLAPASL SCTNPA01
272 + self.addLink( O47, O59, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 575, "durable": "true" }, cls=OpticalLink ) # PHNXAZMA SNDGCA02
273 + self.addLink( O47, O68, port1=102, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 205, "durable": "true" }, cls=OpticalLink ) # PHNXAZMA TCSNAZMA
274 + self.addLink( O48, O55, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 457, "durable": "true" }, cls=OpticalLink ) # PITBPADG SCTNPA01
275 + self.addLink( O50, O54, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 934, "durable": "true" }, cls=OpticalLink ) # PTLDOR62 SCRMCA01
276 + self.addLink( O50, O56, port1=102, port2=108, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1225, "durable": "true" }, cls=OpticalLink ) # PTLDOR62 SLKCUTMA
277 + self.addLink( O50, O65, port1=103, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 280, "durable": "true" }, cls=OpticalLink ) # PTLDOR62 STTLWA06
278 + self.addLink( O51, O72, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 184, "durable": "true" }, cls=OpticalLink ) # RCMDVAGR WASHDCSW
279 + self.addLink( O53, O66, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 143, "durable": "true" }, cls=OpticalLink ) # ROCHNYXA SYRCNYSU
280 + self.addLink( O60, O61, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 80., "durable": "true" }, cls=OpticalLink ) # SNFCCA21 SNJSCA02
281 + self.addLink( O61, O58, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 455, "durable": "true" }, cls=OpticalLink ) # SNJSCA02 SNBBCA01
282 + self.addLink( O55, O66, port1=101, port2=105, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 223, "durable": "true" }, cls=OpticalLink ) # SCTNPA01 SYRCNYSU
283 + self.addLink( O65, O63, port1=101, port2=107, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 442, "durable": "true" }, cls=OpticalLink ) # STTLWA06 SPKNWA01
284 + self.addLink( O62, O64, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 165, "durable": "true" }, cls=OpticalLink ) # SPFDILSD STLSMO09
285 + self.addLink( O69, O67, port1=101, port2=106, annotations={ "optical.waves": 80, "optical.type": "WDM", "optical.kms": 384, "durable": "true" }, cls=OpticalLink ) # TLHSFLAT TAMQFLFN
286 +
287 + # Packet/Optical cross connect links (this will be the tap interfaces)
288 + self.addLink( WASHDCSWR, O72, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
289 + #self.addLink( WASHDCSWR, O72, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
290 + #self.addLink( WASHDCSWR, O72, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
291 + #self.addLink( WASHDCSWR, O72, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
292 + #self.addLink( WASHDCSWR, O72, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
293 + self.addLink( SNJSCA02R, O61, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
294 + #self.addLink( SNJSCA02R, O61, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
295 + #self.addLink( SNJSCA02R, O61, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
296 + #self.addLink( SNJSCA02R, O61, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
297 + #self.addLink( SNJSCA02R, O61, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
298 + self.addLink( SNANTXCAR, O57, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
299 + #self.addLink( SNANTXCAR, O57, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
300 + #self.addLink( SNANTXCAR, O57, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
301 + #self.addLink( SNANTXCAR, O57, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
302 + #self.addLink( SNANTXCAR, O57, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
303 + self.addLink( ROCHNYXAR, O53, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
304 + #self.addLink( ROCHNYXAR, O53, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
305 + #self.addLink( ROCHNYXAR, O53, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
306 + #self.addLink( ROCHNYXAR, O53, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
307 + #self.addLink( ROCHNYXAR, O53, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
308 + self.addLink( PHNXAZMAR, O47, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
309 + #self.addLink( PHNXAZMAR, O47, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
310 + #self.addLink( PHNXAZMAR, O47, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
311 + #self.addLink( PHNXAZMAR, O47, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
312 + #self.addLink( PHNXAZMAR, O47, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
313 + self.addLink( ORLDFLMAR, O45, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
314 + #self.addLink( ORLDFLMAR, O45, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
315 + #self.addLink( ORLDFLMAR, O45, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
316 + #self.addLink( ORLDFLMAR, O45, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
317 + #self.addLink( ORLDFLMAR, O45, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
318 + self.addLink( NWRKNJ02R, O40, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
319 + #self.addLink( NWRKNJ02R, O40, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
320 + #self.addLink( NWRKNJ02R, O40, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
321 + #self.addLink( NWRKNJ02R, O40, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
322 + #self.addLink( NWRKNJ02R, O40, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
323 + self.addLink( MPLSMNDTR, O36, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
324 + #self.addLink( MPLSMNDTR, O36, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
325 + #self.addLink( MPLSMNDTR, O36, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
326 + #self.addLink( MPLSMNDTR, O36, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
327 + #self.addLink( MPLSMNDTR, O36, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
328 + self.addLink( LSANCA03R, O29, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
329 + #self.addLink( LSANCA03R, O29, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
330 + #self.addLink( LSANCA03R, O29, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
331 + #self.addLink( LSANCA03R, O29, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
332 + #self.addLink( LSANCA03R, O29, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
333 + self.addLink( DLLSTXTLR, O18, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
334 + #self.addLink( DLLSTXTLR, O18, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
335 + #self.addLink( DLLSTXTLR, O18, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
336 + #self.addLink( DLLSTXTLR, O18, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
337 + #self.addLink( DLLSTXTLR, O18, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
338 + self.addLink( ATLNGATLR, O4, port1=2, port2=10, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
339 + #self.addLink( ATLNGATLR, O4, port1=3, port2=11, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
340 + #self.addLink( ATLNGATLR, O4, port1=4, port2=12, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
341 + #self.addLink( ATLNGATLR, O4, port1=5, port2=13, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
342 + #self.addLink( ATLNGATLR, O4, port1=6, port2=14, speed1=10000, annotations={ "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }, cls=OpticalLink )
343 +
344 + # Create Hosts 1..11
345 + h1 = self.addHost( 'h1' )
346 + h2 = self.addHost( 'h2' )
347 + h3 = self.addHost( 'h3' )
348 + h4 = self.addHost( 'h4' )
349 + h5 = self.addHost( 'h5' )
350 + h6 = self.addHost( 'h6' )
351 + h7 = self.addHost( 'h7' )
352 + h8 = self.addHost( 'h8' )
353 + h9 = self.addHost( 'h9' )
354 + h10 = self.addHost( 'h10' )
355 + h11 = self.addHost( 'h11' )
356 +
357 + # Attach hosts to the packet layer switches
358 + self.addLink( SNJSCA02R, h1, port1=1 )
359 + self.addLink( SNANTXCAR, h2, port1=1 )
360 + self.addLink( ROCHNYXAR, h3, port1=1 )
361 + self.addLink( PHNXAZMAR, h4, port1=1 )
362 + self.addLink( ORLDFLMAR, h5, port1=1 )
363 + self.addLink( NWRKNJ02R, h6, port1=1 )
364 + self.addLink( MPLSMNDTR, h7, port1=1 )
365 + self.addLink( LSANCA03R, h8, port1=1 )
366 + self.addLink( DLLSTXTLR, h9, port1=1 )
367 + self.addLink( ATLNGATLR, h10, port1=1 )
368 + self.addLink( WASHDCSWR, h11, port1=1 )
369 +
370 +if __name__ == '__main__':
371 + import sys
372 + if len( sys.argv ) >= 2:
373 + controllers = sys.argv[1:]
374 + else:
375 + print 'Usage: ./opticalUtils.py (<Controller IP>)+'
376 + print 'Using localhost...\n'
377 + controllers = [ '127.0.0.1' ]
378 +
379 + setLogLevel( 'info' )
380 + net = MininetOE( topo=BigOpticalTopo(), controller=None, autoSetMacs=True )
381 + net.addControllers( controllers )
382 + net.start()
383 + CLI( net )
384 + net.stop()
1 +#!/usr/bin/python
2 +
3 +'''
4 +Notes:
5 +
6 +This file contains classes and methods useful for integrating LincOE with Mininet,
7 +such as startOE, stopOE, OpticalLink, and OpticalSwitch
8 +
9 +- $ONOS_ROOT ust be set
10 +- Need to run with sudo -E to preserve ONOS_ROOT env var
11 +- We assume LINC-Config-Generator is named LINC-Config-Generator
12 +- We also assume linc-oe is named linc-oe
13 +- LINC-config-generator and linc-oe must be subdirectories of the user's
14 + home directory
15 +
16 + TODO
17 + -----------
18 + - clean up files after runtime
19 + - maybe save the old files in a separate directory?
20 + - modify script to allow startOE to run before net.start()
21 + - add ONOS as a controller in script
22 +
23 + Usage:
24 + ------------
25 + - import OpticalLink and OpticalSwitch from this module
26 + - import startOE and stopOE from this module
27 + - create topology as you would a normal topology. when
28 + to an optical switch with topo.addLink, always specify cls=OpticalLink
29 + - when creating an optical switch, use cls=OpticalSwitch in topo.addSwitch
30 + - for annotations on links and switches, a dictionary must be passed in as
31 + the annotations argument
32 + - startOE must be run AFTER net.start() with net as an argument.
33 + - stopOE can be run at any time
34 +
35 +I created a separate function to start lincOE to avoid subclassing Mininet.
36 +In case anyone wants to write something that DOES subclass Mininet, I
37 +thought I would outline how:
38 +
39 +If we want an object that starts lincOE within the mininet class itself,
40 +we need to add another object to Mininet that contains all of the json object
41 +information for each switch. We would still subclass switch and link, but these
42 +classes would basically be dummy classes that store their own json information
43 +in the Mininet class object. We may also change the default switch class to add
44 +it's tap interfaces from lincOE during startup. The start() method for mininet would
45 +grab all of the information from these switches and links, write configuration files
46 +for lincOE using the json module, start lincOE, then run the start methodfor each
47 +switch. The new start() method for each switch would parse through the sys.config
48 +file that was created and find the tap interface it needs to connect to, similar
49 +to the findTap function that I currently use. After all of the controllers and
50 +switches have been started, the new Mininet start() method should also push the
51 +Topology configuration file to ONOS.
52 +
53 +'''
54 +
55 +import re
56 +import json
57 +import os
58 +from time import sleep
59 +
60 +from mininet.node import Switch, RemoteController
61 +from mininet.topo import Topo
62 +from mininet.util import quietRun
63 +from mininet.net import Mininet
64 +from mininet.log import setLogLevel, info, error, warn
65 +from mininet.link import Link, Intf
66 +from mininet.cli import CLI
67 +
68 +class OpticalSwitch( Switch ):
69 +
70 + def __init__( self, name, dpid=None, allowed=True,
71 + switchType='ROADM', annotations={}, **params ):
72 + params[ 'inNamespace' ] = False
73 + Switch.__init__( self, name, dpid=dpid, **params )
74 + self.name = name
75 + self.annotations = annotations
76 + self.allowed = allowed
77 + self.switchType = switchType
78 + self.configDict = {} # dictionary that holds all of the JSON configuration data
79 +
80 + def start( self, *opts, **params ):
81 + '''Instead of starting a virtual switch, we build the JSON
82 + dictionary for the emulated optical switch'''
83 + self.configDict[ 'uri' ] = 'of:' + self.dpid
84 + self.configDict[ 'annotations' ] = self.annotations
85 + self.configDict[ 'annotations' ].setdefault( 'name', self.name )
86 + self.configDict[ 'hw' ] = 'OE'
87 + self.configDict[ 'mfr' ] = 'Linc'
88 + self.configDict[ 'mac' ] = 'ffffffffffff' + self.dpid[-2] + self.dpid[-1]
89 + self.configDict[ 'type' ] = self.switchType
90 + self.configDict[ 'ports' ] = []
91 + for port, intf in self.intfs.items():
92 + if intf.name == 'lo':
93 + continue
94 + else:
95 + self.configDict[ 'ports' ].append( intf.json() )
96 +
97 +
98 + def json( self ):
99 + "return json configuration dictionary for switch"
100 + return self.configDict
101 +
102 + def terminate( self ):
103 + pass
104 +
105 +class OpticalLink( Link ):
106 +
107 + def __init__( self, node1, node2, port1=None, port2=None, allowed=True,
108 + intfName1=None, intfName2=None, linkType='OPTICAL',
109 + annotations={}, speed1=0, speed2=0, **params ):
110 + "Creates a dummy link without a virtual ethernet pair."
111 + self.allowed = allowed
112 + self.annotations = annotations
113 + self.linkType = linkType
114 + params1 = { 'speed': speed1 }
115 + params2 = { 'speed': speed2 }
116 +
117 + if isinstance( node1, OpticalSwitch ):
118 + cls1 = OpticalIntf
119 + else:
120 + cls1 = Intf
121 + # bad hack to stop error message from appearing when we try to set up intf in a packet switch,
122 + # and there is no interface there( because we do not run makeIntfPair ). This way, we just set lo up
123 + intfName1 = 'lo'
124 + if isinstance( node2, OpticalSwitch ):
125 + cls2 = OpticalIntf
126 + else:
127 + cls2 = Intf
128 + intfName2 = 'lo'
129 + Link.__init__( self, node1, node2, port1=port1, port2=port2,
130 + intfName1=intfName1, intfName2=intfName2, cls1=cls1,
131 + cls2=cls2, params1=params1, params2=params2 )
132 +
133 +
134 + @classmethod
135 + def makeIntfPair( _cls, intfName1, intfName2, *args, **kwargs ):
136 + pass
137 +
138 + def json( self ):
139 + "build and return the json configuration dictionary for this link"
140 + configData = {}
141 + configData[ 'src' ] = ( 'of:' + self.intf1.node.dpid +
142 + '/%s' % self.intf1.node.ports[ self.intf1 ] )
143 + configData[ 'dst' ] = ( 'of:' + self.intf2.node.dpid +
144 + '/%s' % self.intf2.node.ports[ self.intf2 ] )
145 + configData[ 'type' ] = self.linkType
146 + configData[ 'annotations' ] = self.annotations
147 + return configData
148 +
149 +class OpticalIntf( Intf ):
150 +
151 + def __init__( self, name=None, node=None, speed=0,
152 + port=None, link=None, **params ):
153 + self.node = node
154 + self.speed = speed
155 + self.port = port
156 + self.link = link
157 + self.name = name
158 + node.addIntf( self, port=port )
159 + self.params = params
160 + self.ip = None
161 +
162 + def json( self ):
163 + "build and return the JSON information for this interface( not used right now )"
164 + configDict = {}
165 + configDict[ 'port' ] = self.port
166 + configDict[ 'speed' ] = self.speed
167 + configDict[ 'type' ] = 'FIBER'
168 + return configDict
169 +
170 + def config( self, *args, **kwargs ):
171 + "dont configure a dummy interface"
172 + pass
173 +
174 +def switchJSON( switch ):
175 + "Returns the json configuration for a packet switch"
176 + configDict = {}
177 + configDict[ 'uri' ] = 'of:' + switch.dpid
178 + configDict[ 'mac' ] = quietRun( 'cat /sys/class/net/%s/address' % switch.name ).strip( '\n' ).translate( None, ':' )
179 + configDict[ 'hw' ] = 'PK' # FIXME what about OVS?
180 + configDict[ 'mfr' ] = 'Linc' # FIXME what about OVS?
181 + configDict[ 'type' ] = 'SWITCH' # FIXME what about OVS?
182 + annotations = switch.params.get( 'annotations', {} )
183 + annotations.setdefault( 'name', switch.name )
184 + configDict[ 'annotations' ] = annotations
185 + ports = []
186 + for port, intf in switch.intfs.items():
187 + if intf.name == 'lo':
188 + continue
189 + portDict = {}
190 + portDict[ 'port' ] = port
191 + portDict[ 'type' ] = 'FIBER' if isinstance( intf.link, OpticalLink ) else 'COPPER'
192 + intfList = [ intf.link.intf1, intf.link.intf2 ]
193 + intfList.remove( intf )
194 + portDict[ 'speed' ] = intfList[ 0 ].speed if isinstance( intf.link, OpticalLink ) else 0
195 + ports.append( portDict )
196 + configDict[ 'ports' ] = ports
197 + return configDict
198 +
199 +
200 +def startOE( net, controllerIP=None, controllerPort=None ):
201 + "Start the LINC optical emulator within a mininet instance"
202 + opticalJSON = {}
203 + linkConfig = []
204 + devices = []
205 +
206 + # if we are not given a controller IP or Port, we use the first found in Mininet
207 + if controllerIP is None:
208 + controllerIP = net.controllers[ 0 ].ip
209 + if controllerPort is None:
210 + controllerPort = net.controllers[ 0 ].port
211 +
212 + for switch in net.switches:
213 + if isinstance( switch, OpticalSwitch ):
214 + devices.append( switch.json() )
215 + else:
216 + devices.append( switchJSON( switch ) )
217 + opticalJSON[ 'devices' ] = devices
218 +
219 + for link in net.links:
220 + if isinstance( link, OpticalLink ) :
221 + linkConfig.append( link.json() )
222 +
223 + opticalJSON[ 'links' ] = linkConfig
224 +
225 + try:
226 + onosDir = os.environ[ 'ONOS_ROOT' ]
227 + except:
228 + onosDir = findDir( 'onos' )
229 + os.environ[ 'ONOS_ROOT' ] = onosDir
230 + if not onosDir:
231 + error( 'Please set ONOS_ROOT environment variable!\n' )
232 + return False
233 +
234 + info( '*** Writing Topology.json file\n' )
235 + with open( 'Topology.json', 'w' ) as outfile:
236 + json.dump( opticalJSON, outfile, indent=4, separators=(',', ': ') )
237 +
238 + info( '*** Converting Topology.json to linc-oe format (TopoConfig.json) file\n' )
239 + output = quietRun( '%s/tools/test/bin/onos-oecfg ./Topology.json > TopoConfig.json' % onosDir, shell=True )
240 + if output:
241 + error( '***ERROR: Error creating topology file: %s ' % output + '\n' )
242 + return False
243 +
244 + info( '*** Creating sys.config...\n' )
245 + configGen = findDir( 'LINC-config-generator' )
246 + if not configGen:
247 + error( "***ERROR: Could not find LINC-config-generator in user's home directory\n" )
248 + return False
249 + output = quietRun( '%s/config_generator TopoConfig.json %s/sys.config.template %s %s'
250 + % ( configGen, configGen, controllerIP, controllerPort ), shell=True )
251 + if output:
252 + error( '***ERROR: Error creating sys.config file: %s\n' % output )
253 + return False
254 +
255 + info( '*** Copying sys.config to linc-oe directory: ', output + '\n' )
256 + lincDir = findDir( 'linc-oe' )
257 + if not lincDir:
258 + error( "***ERROR: Could not find linc-oe in user's home directory\n" )
259 + return False
260 + output = quietRun( 'cp -v sys.config %s/rel/linc/releases/1.0/' % lincDir, shell=True ).strip( '\n' )
261 + info( output + '\n' )
262 +
263 + info( '*** Starting linc OE...\n' )
264 + output = quietRun( '%s/rel/linc/bin/linc start' % lincDir, shell=True )
265 + if output:
266 + error( '***ERROR: LINC-OE: %s' % output + '\n' )
267 + quietRun( '%s/rel/linc/bin/linc stop' % lincDir, shell=True )
268 + return False
269 +
270 + info( '*** Waiting for linc-oe to start...\n' )
271 + waitStarted( net )
272 +
273 + info( '*** Adding cross-connect (tap) interfaces to packet switches...\n' )
274 + for link in net.links:
275 + if isinstance( link, OpticalLink ):
276 + if link.annotations[ 'optical.type' ] == 'cross-connect':
277 + for intf in [ link.intf1, link.intf2 ]:
278 + if not isinstance( intf, OpticalIntf ):
279 + intfList = [ intf.link.intf1, intf.link.intf2 ]
280 + intfList.remove( intf )
281 + intf2 = intfList[ 0 ]
282 + intf.node.attach( findTap( intf2.node, intf2.node.ports[ intf2 ] ) )
283 +
284 + info( '*** Press any key to push Topology.json to onos...\n' )
285 + raw_input() # FIXME... we should eventually remove this
286 + info( '*** Pushing Topology.json to ONOS\n' )
287 + output = quietRun( '%s/tools/test/bin/onos-topo-cfg %s Topology.json' % ( onosDir, controllerIP ), shell=True )
288 + # successful output contains the two characters '{}'
289 + # if there is more output than this, there is an issue
290 + if output.strip( '{}' ):
291 + warn( '***WARNING: Could not push topology file to ONOS: %s' % output )
292 +
293 +def waitStarted( net, timeout=None ):
294 + "wait until all tap interfaces are available"
295 + tapCount = 0
296 + time = 0
297 + for link in net.links:
298 + if isinstance( link, OpticalLink ):
299 + if link.annotations[ 'optical.type' ] == 'cross-connect':
300 + tapCount += 1
301 +
302 + while True:
303 + if str( tapCount ) == quietRun( 'ip addr | grep tap | wc -l', shell=True ).strip( '\n' ):
304 + return True
305 + if timeout:
306 + if time >= timeout:
307 + error( '***ERROR: Linc OE did not start within %s seconds' % timeout )
308 + return False
309 + time += .5
310 + sleep( .5 )
311 +
312 +def stopOE():
313 + "stop the optical emulator"
314 + info( '*** Stopping linc OE...\n' )
315 + lincDir = findDir( 'linc-oe' )
316 + quietRun( '%s/rel/linc/bin/linc stop' % lincDir, shell=True )
317 +
318 +def findDir( directory ):
319 + "finds and returns the path of any directory in the user's home directory"
320 + user = findUser()
321 + homeDir = '/home/' + user
322 + Dir = quietRun( 'find %s -maxdepth 1 -name %s -type d' % ( homeDir, directory ) ).strip( '\n' )
323 + DirList = Dir.split( '\n' )
324 + if not Dir:
325 + return None
326 + elif len( DirList ) > 1 :
327 + warn( '***WARNING: Found multiple instances of %s; using %s\n'
328 + % ( directory, DirList[ 0 ] ) )
329 + return DirList[ 0 ]
330 + else:
331 + return Dir
332 +
333 +def findUser():
334 + "Try to return logged-in (usually non-root) user"
335 + try:
336 + # If we're running sudo
337 + return os.environ[ 'SUDO_USER' ]
338 + except:
339 + try:
340 + # Logged-in user (if we have a tty)
341 + return quietRun( 'who am i' ).split()[ 0 ]
342 + except:
343 + # Give up and return effective user
344 + return quietRun( 'whoami' )
345 +
346 +
347 +def findTap( node, port, path=None ):
348 + '''utility function to parse through a sys.config
349 + file to find tap interfaces for a switch'''
350 + switch=False
351 + portLine = ''
352 + intfLines = []
353 +
354 + if path is None:
355 + lincDir = findDir( 'linc-oe' )
356 + if not lincDir:
357 + error( '***ERROR: Could not find linc-oe in users home directory\n' )
358 + return None
359 + path = '%s/rel/linc/releases/1.0/sys.config' % lincDir
360 +
361 + with open( path ) as f:
362 + for line in f:
363 + if 'tap' in line:
364 + intfLines.append( line )
365 + if node.dpid in line.translate( None, ':' ):
366 + switch=True
367 + continue
368 + if switch:
369 + if 'switch' in line:
370 + switch = False
371 + if 'port_no,%s}' % port in line:
372 + portLine = line
373 + break
374 +
375 + if portLine:
376 + m = re.search( 'port,\d+', portLine )
377 + port = m.group( 0 ).split( ',' )[ 1 ]
378 + else:
379 + error( '***ERROR: Could not find any ports in sys.config\n' )
380 + return
381 +
382 + for intfLine in intfLines:
383 + if 'port,%s' % port in intfLine:
384 + return re.findall( 'tap\d+', intfLine )[ 0 ]
385 +
386 +
387 +class MininetOE( Mininet ):
388 + "Mininet with Linc-OE support (starts and stops linc-oe)"
389 +
390 + def start( self ):
391 + Mininet.start( self )
392 + startOE( self )
393 +
394 + def stop( self ):
395 + Mininet.stop( self )
396 + stopOE()
397 +
398 + def addControllers( self, controllers ):
399 + i = 0
400 + for ctrl in controllers:
401 + self.addController( RemoteController( 'c%d' % i, ip=ctrl ) )
402 +
403 +
404 +class OpticalTestTopo( Topo ):
405 +
406 + def build( self ):
407 + opticalAnn = { 'optical.waves': 80, 'optical.type': "WDM", 'durable': True }
408 + switchAnn = { 'bandwidth': 100000, 'optical.type': 'cross-connect', 'durable': True }
409 + h1 = self.addHost( 'h1' )
410 + h2 = self.addHost( 'h2' )
411 + s1 = self.addSwitch( 's1' )
412 + s2 = self.addSwitch( 's2' )
413 + O4 = self.addSwitch( 'O4', cls=OpticalSwitch )
414 + O5 = self.addSwitch( 'O5', cls=OpticalSwitch )
415 + O6 = self.addSwitch( 'O6', cls=OpticalSwitch )
416 + self.addLink( O4, O5, cls=OpticalLink, annotations=opticalAnn )
417 + self.addLink( O5, O6, cls=OpticalLink, annotations=opticalAnn )
418 + self.addLink( s1, O4, cls=OpticalLink, annotations=switchAnn )
419 + self.addLink( s2, O6, cls=OpticalLink, annotations=switchAnn )
420 + self.addLink( h1, s1 )
421 + self.addLink( h2, s2 )
422 +
423 +if __name__ == '__main__':
424 + import sys
425 + if len( sys.argv ) >= 2:
426 + controllers = sys.argv[1:]
427 + else:
428 + print 'Usage: ./opticalUtils.py (<Controller IP>)+'
429 + print 'Using localhost...\n'
430 + controllers = [ '127.0.0.1' ]
431 +
432 + setLogLevel( 'info' )
433 + net = MininetOE( topo=OpticalTestTopo(), controller=None, autoSetMacs=True )
434 + net.addControllers( controllers )
435 + net.start()
436 + CLI( net )
437 + net.stop()