| #!/usr/bin/python |
| |
| from mininet.topo import Topo |
| from mininet.node import RemoteController |
| from mininet.net import Mininet |
| from mininet.util import irange |
| from mininet.cli import CLI |
| from mininet.log import setLogLevel |
| |
| class OltTopo( Topo ): |
| "Single switch with OLT port 129 and configurable number of ONU ports" |
| |
| def build( self, k=1, **_opts ): |
| "k: number of onu" |
| self.k = k |
| switch = self.addSwitch( 's1' ) |
| for h in irange( 1, k ): |
| host = self.addHost( 'h%s' % h, inNamespace=False ) |
| self.addLink( host, switch ) |
| |
| olt_port = self.addHost( 'h129', inNamespace=False ) |
| self.addLink( olt_port, switch, port2=129 ) |
| |
| if __name__ == '__main__': |
| setLogLevel('debug') |
| topo = OltTopo() |
| |
| net = Mininet( topo=topo, controller=RemoteController ) |
| |
| net.start() |
| |
| CLI( net ) |
| |
| net.stop() |