blob: b491ccad313a107383659b2add781f30654810da [file] [log] [blame]
Praseed Balakrishnand94df302014-11-12 17:20:16 -08001#!/usr/bin/env python
2
3''' file: custom/optical.py '''
4
5from mininet.topo import Topo
6from mininet.net import Mininet
7from mininet.cli import CLI
8from mininet.log import setLogLevel, info
9from mininet.link import Intf, Link
10from mininet.node import RemoteController
11
12class NullIntf( Intf ):
13 "A dummy interface with a blank name that doesn't do any configuration"
14 def __init__( self, name, **params ):
15 self.name = ''
16
17class NullLink( Link ):
18 "A dummy link that doesn't touch either interface"
Praseed Balakrishnanc0029652014-11-14 13:38:49 -080019 def makeIntfPair( cls, intf1, intf2, *args, **kwargs ):
Praseed Balakrishnand94df302014-11-12 17:20:16 -080020 pass
21 def delete( self ):
22 pass
23
24class OpticalTopo(Topo):
25 def addIntf( self, switch, intfName ):
26 "Add intf intfName to switch"
27 self.addLink( switch, switch, cls=NullLink,
28 intfName1=intfName, cls2=NullIntf )
29 def __init__(self):
30
31 # Initialize topology
32 Topo.__init__(self)
33
34 # Add hosts and switches
35 h1 = self.addHost('h1')
36 h2 = self.addHost('h2')
37 h3 = self.addHost('h3')
38 h4 = self.addHost('h4')
39 h5 = self.addHost('h5')
40 h6 = self.addHost('h6')
41
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080042 s1 = self.addSwitch('s1', dpid="0000ffffffff0001")
43 s2 = self.addSwitch('s2', dpid="0000ffffffff0002")
44 s3 = self.addSwitch('s3', dpid="0000ffffffff0003")
45 s4 = self.addSwitch('s4', dpid="0000ffffffff0004")
46 s5 = self.addSwitch('s5', dpid="0000ffffffff0005")
47 s6 = self.addSwitch('s6', dpid="0000ffffffff0006")
Praseed Balakrishnand94df302014-11-12 17:20:16 -080048
49
50 # Add links from hosts to OVS
51 self.addLink(s1, h1)
52 self.addLink(s2, h2)
53 self.addLink(s3, h3)
54 self.addLink(s4, h4)
55 self.addLink(s5, h5)
56 self.addLink(s6, h6)
57
Praseed Balakrishnand94df302014-11-12 17:20:16 -080058 # add links from ovs to linc-oe
59 # sorry about the syntax :(
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080060 self.addIntf(s1,'tap29')
61 self.addIntf(s2,'tap30')
62 self.addIntf(s3,'tap31')
63 self.addIntf(s4,'tap32')
64 self.addIntf(s5,'tap33')
65 self.addIntf(s6,'tap34')
Praseed Balakrishnand94df302014-11-12 17:20:16 -080066
weibit94f6c342014-11-17 15:27:18 -080067 self.addIntf(s1,'tap35')
68 self.addIntf(s2,'tap36')
69 self.addIntf(s3,'tap37')
70 self.addIntf(s4,'tap38')
71 self.addIntf(s5,'tap39')
72 self.addIntf(s6,'tap40')
73
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080074 # if you use, sudo mn --custom custom/optical.py, then register the topo:
Praseed Balakrishnand94df302014-11-12 17:20:16 -080075topos = {'optical': ( lambda: OpticalTopo() )}
76
Praseed Balakrishnand94df302014-11-12 17:20:16 -080077
78def run():
weibit94f6c342014-11-17 15:27:18 -080079 c = RemoteController('c','192.168.56.101',6633)
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080080 net = Mininet( topo=OpticalTopo(),controller=None,autoSetMacs=True)
Praseed Balakrishnand94df302014-11-12 17:20:16 -080081 net.addController(c)
82 net.start()
83
Praseed Balakrishnand94df302014-11-12 17:20:16 -080084 #installStaticFlows( net )
85 CLI( net )
86 net.stop()
87
88# if the script is run directly (sudo custom/optical.py):
89if __name__ == '__main__':
90 setLogLevel('info')
91 run()