blob: 118e464b90aa9bc4d360d06424ae9df1a35a1151 [file] [log] [blame]
Adminc0ed1192015-10-10 14:18:26 -07001#!/usr/bin/python
2
Zsolt Harasztife525502016-03-02 05:18:52 +00003import sys
4
Adminc0ed1192015-10-10 14:18:26 -07005from mininet.topo import Topo
Zsolt Harasztife525502016-03-02 05:18:52 +00006from mininet.node import RemoteController, UserSwitch
Adminc0ed1192015-10-10 14:18:26 -07007from mininet.net import Mininet
8from mininet.util import irange
9from mininet.cli import CLI
10from mininet.log import setLogLevel
11
Zsolt Harasztife525502016-03-02 05:18:52 +000012from optparse import OptionParser
13
14
Adminc0ed1192015-10-10 14:18:26 -070015class OltTopo( Topo ):
16 "Single switch with OLT port 129 and configurable number of ONU ports"
17
18 def build( self, k=1, **_opts ):
19 "k: number of onu"
20 self.k = k
21 switch = self.addSwitch( 's1' )
22 for h in irange( 1, k ):
23 host = self.addHost( 'h%s' % h, inNamespace=False )
24 self.addLink( host, switch )
25
26 olt_port = self.addHost( 'h129', inNamespace=False )
27 self.addLink( olt_port, switch, port2=129 )
28
29if __name__ == '__main__':
Adminc0ed1192015-10-10 14:18:26 -070030
Zsolt Harasztife525502016-03-02 05:18:52 +000031 parser = OptionParser()
32 parser.add_option("-u", "--user-switch", dest="user_switch", action="store_true",
33 default=False, help="use given user mode switch (CPqD) or mininet")
34 (options, args) = parser.parse_args()
35
36 kargs = {}
37
38 if options.user_switch:
39 kargs['switch'] = UserSwitch
40
41 setLogLevel('debug')
42
43 topo = OltTopo()
44 topo.build(k=2)
45
46 net = Mininet( topo=topo, controller=RemoteController, **kargs )
Adminc0ed1192015-10-10 14:18:26 -070047
48 net.start()
49
50 CLI( net )
51
52 net.stop()