Admin | c0ed119 | 2015-10-10 14:18:26 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from mininet.topo import Topo |
| 4 | from mininet.node import RemoteController |
| 5 | from mininet.net import Mininet |
| 6 | from mininet.util import irange |
| 7 | from mininet.cli import CLI |
| 8 | from mininet.log import setLogLevel |
| 9 | |
| 10 | class OltTopo( Topo ): |
| 11 | "Single switch with OLT port 129 and configurable number of ONU ports" |
| 12 | |
| 13 | def build( self, k=1, **_opts ): |
| 14 | "k: number of onu" |
| 15 | self.k = k |
| 16 | switch = self.addSwitch( 's1' ) |
| 17 | for h in irange( 1, k ): |
| 18 | host = self.addHost( 'h%s' % h, inNamespace=False ) |
| 19 | self.addLink( host, switch ) |
| 20 | |
| 21 | olt_port = self.addHost( 'h129', inNamespace=False ) |
| 22 | self.addLink( olt_port, switch, port2=129 ) |
| 23 | |
| 24 | if __name__ == '__main__': |
| 25 | setLogLevel('debug') |
Jonathan Hart | f65e181 | 2015-10-05 15:15:37 -0700 | [diff] [blame] | 26 | topo = OltTopo(k=2) |
Admin | c0ed119 | 2015-10-10 14:18:26 -0700 | [diff] [blame] | 27 | |
| 28 | net = Mininet( topo=topo, controller=RemoteController ) |
| 29 | |
| 30 | net.start() |
| 31 | |
| 32 | CLI( net ) |
| 33 | |
| 34 | net.stop() |