blob: cd365b32a0e38e228f1f91af02c5c929bdd0eb50 [file] [log] [blame]
Jeremy Songster5665f1b2016-06-20 14:38:22 -07001#!/usr/bin/env python
2
3from mininet.net import Mininet
4from mininet.topo import Topo
5from mininet.node import Host, RemoteController
6from mininet.cli import CLI
7from mininet.log import setLogLevel
8
9from opticalUtils import LINCSwitch, LINCLink
10
11class OpticalTopo( Topo ):
12 """
13 A simple optical topology of three LINC nodes(OE*), two OVS switches(ps*), and two hosts:
14
15 OE3
16 /\
17 h1-ps1-OE1--OE2-ps2-h2
18
19 """
20 def build( self ):
21
22 # set up packet layer - OVS + hosts
23 s1 = self.addSwitch( 'ps1' )
24 s2 = self.addSwitch( 'ps2' )
25 h1 = self.addHost( 'h1' )
26 h2 = self.addHost( 'h2' )
27 self.addLink( s1, h1 )
28 self.addLink( s2, h2 )
29
30 # set up ROADMs, add them to oel[]
31 oel = []
32 an = { "durable": "true" }
33 for i in range (1,4):
34 oean = { "optical.regens": 0 }
35 oel.append( self.addSwitch('OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch) )
36
37 # ROADM port numbers are built as: OE1 <-> OE2 = 1200
38 # leaving port number up to 100 open for use by Och port
39 self.addLink( oel[0], oel[1], port1=1200, port2=2100, annotations=an, cls=LINCLink )
40 self.addLink( oel[1], oel[2], port1=2300, port2=3200, annotations=an, cls=LINCLink )
41 self.addLink( oel[2], oel[0], port1=3100, port2=1300, annotations=an, cls=LINCLink )
42
43 # cross-connects between OVSes and LINCs
44 self.addLink( s1, oel[0], port1=2, port2=1, annotations=an, cls=LINCLink )
45 self.addLink( s2, oel[1], port1=2, port2=1, annotations=an, cls=LINCLink )
46
47
48def setup( ctls ):
49 net = Mininet( topo=OpticalTopo(), controller=None )
50 i = 1
51 for ctl in ctls:
52 net.addController( RemoteController( 'c%d' % i, ip=ctl ) )
53 i+=1
54
55 net.start()
56 LINCSwitch.bootOE( net )
57 CLI( net )
58 net.stop()
59 LINCSwitch.shutdownOE()
60
61
62if __name__ == "__main__" :
63 import sys
64 if len( sys.argv ) >= 2 :
65 setLogLevel( 'info' )
66 ctls = sys.argv[ 1: ]
67 setup( ctls )
68 else:
69 print('./ectopo.py [IP1] [IP2]...\n')