blob: b778592c391fe4826084554375c611e425f42ab0 [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
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080067 # if you use, sudo mn --custom custom/optical.py, then register the topo:
Praseed Balakrishnand94df302014-11-12 17:20:16 -080068topos = {'optical': ( lambda: OpticalTopo() )}
69
Praseed Balakrishnand94df302014-11-12 17:20:16 -080070
71def run():
Charles Chan45624b82015-08-24 00:29:20 +080072 c = RemoteController('c','127.0.0.1',6653)
Praseed Balakrishnan56051d02014-11-14 09:56:04 -080073 net = Mininet( topo=OpticalTopo(),controller=None,autoSetMacs=True)
Praseed Balakrishnand94df302014-11-12 17:20:16 -080074 net.addController(c)
75 net.start()
76
Praseed Balakrishnand94df302014-11-12 17:20:16 -080077 #installStaticFlows( net )
78 CLI( net )
79 net.stop()
80
81# if the script is run directly (sudo custom/optical.py):
82if __name__ == '__main__':
83 setLogLevel('info')
84 run()