def main(): ''' args = get_args() numNodes = args.numNodes numPorts = args.numPorts numServerPorts = arsg.numServerPorts numSwitches = args.numSwitches ''' numHosts = 20 numSwitches = 20 numPorts = 5 adj_list = "graph_adjlist" setLogLevel('info') info('* Creating Network\n') topo = Jellyfish(numNodes=numHosts, numSwitches=numSwitches, numPorts=numPorts, adj_list=adj_list) network = Mininet(topo=topo) network.start() dumpNodeConnections(network.hosts) # network.pingAll() network.run(CLI, network) info('* Stopping Network\n') network.stop()
def configure(): topo = part3_topo() net = Mininet(topo=topo, controller=RemoteController) net.run() CLI(net) net.stop()
def testNet(): net = Mininet(topo = LobaTopo(), build = False, switch = UserSwitch) # Add my remote controller info('*** Adding controller\n') net.addController('c0', RemoteController, ip = '10.37.129.2', port = 8888) info('c0\n') net.run(CLI, net)
def testNet(): net = Mininet(topo=LobaTopo(), build=False, switch=UserSwitch) # Add my remote controller info('*** Adding controller\n') net.addController('c0', RemoteController, ip='10.37.129.2', port=8888) info('c0\n') net.run(CLI, net)
def runOptionsTopoTest(self, n, msg, hopts=None, lopts=None): "Generic topology-with-options test runner." mn = Mininet(topo=SingleSwitchOptionsTopo(n=n, hopts=hopts, lopts=lopts), host=CPULimitedHost, link=TCLink, switch=self.switchClass, waitConnected=True, isWiFi=True) dropped = mn.run(mn.ping) hoptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in hopts.items()) loptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in lopts.items()) msg += ('%s%% of pings were dropped during mininet.ping().\n' 'Topo = SingleAPTopo, %s stations\n' 'hopts = %s\n' 'lopts = %s\n' 'host = CPULimitedHost\n' 'link = TCLink\n' 'Switch = %s\n' % (dropped, n, hoptsStr, loptsStr, self.switchClass)) self.assertEqual(dropped, 0, msg=msg)
def testLinkBandwidth( self ): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: self.skipTest( 'UserSwitch has very poor performance -' ' skipping for now' ) BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = { 'bw': BW, 'use_htb': True } # Also verify correctness of limit limitng within a bound. mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ), link=TCLink, switch=self.switchClass, waitConnected=True ) bw_strs = mn.run( mn.iperf, fmt='m' ) loptsStr = ', '.join( '%s: %s' % ( opt, value ) for opt, value in lopts.items() ) msg = ( '\nTesting link bandwidth limited to %d Mbps per link\n' 'iperf results[ client, server ]: %s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'Link = TCLink\n' 'lopts = %s\n' 'host = default\n' 'switch = %s\n' % ( BW, bw_strs, N, loptsStr, self.switchClass ) ) # On the client side, iperf doesn't wait for ACKs - it simply # reports how long it took to fill up the TCP send buffer. # As long as the kernel doesn't wait a long time before # delivering bytes to the iperf server, its reported data rate # should be close to the actual receive rate. serverRate, _clientRate = bw_strs bw = float( serverRate.split(' ')[0] ) self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
def runOptionsTopoTest( self, n, hopts=None, lopts=None ): "Generic topology-with-options test runner." mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts, lopts=lopts ), host=CPULimitedHost, link=TCLink, switch=self.switchClass ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testLinkBandwidth(self): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: self.skipTest( 'UserSwitch has very poor performance, so skip for now') BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = {'bw': BW, 'use_htb': True} # Also verify correctness of limit limitng within a bound. mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink, switch=self.switchClass, waitConnected=True) bw_strs = mn.run(mn.iperf, format='m') loptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in lopts.items()) msg = ('\nTesting link bandwidth limited to %d Mbps per link\n' 'iperf results[ client, server ]: %s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'Link = TCLink\n' 'lopts = %s\n' 'host = default\n' 'switch = %s\n' % (BW, bw_strs, N, loptsStr, self.switchClass)) for bw_str in bw_strs: bw = float(bw_str.split(' ')[0]) self.assertWithinTolerance(bw, BW, BW_TOLERANCE, msg)
def testLinkBandwidth( self ): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: self.skipTest ( 'UserSwitch has very poor performance, so skip for now' ) BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = { 'bw': BW, 'use_htb': True } # Also verify correctness of limit limitng within a bound. mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ), link=TCLink, switch=self.switchClass, waitConnected=True ) bw_strs = mn.run( mn.iperf, format='m' ) loptsStr = ', '.join( '%s: %s' % ( opt, value ) for opt, value in lopts.items() ) msg = ( '\nTesting link bandwidth limited to %d Mbps per link\n' 'iperf results[ client, server ]: %s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'Link = TCLink\n' 'lopts = %s\n' 'host = default\n' 'switch = %s\n' % ( BW, bw_strs, N, loptsStr, self.switchClass ) ) for bw_str in bw_strs: bw = float( bw_str.split(' ')[0] ) self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
def testLinear5(self): "Ping test on a 5-switch topology" mn = Mininet(LinearTopo(k=5), self.switchClass, Host, Controller, waitConnected=True) dropped = mn.run(mn.ping) self.assertEqual(dropped, 0)
def testMinimal(self): "Ping test on minimal topology" mn = Mininet(SingleSwitchTopo(), self.switchClass, Host, Controller, waitConnected=True) dropped = mn.run(mn.ping) self.assertEqual(dropped, 0)
def testSingle5(self): "Ping test on 5-host single-switch topology" mn = Mininet(SingleSwitchTopo(k=5), self.switchClass, Host, Controller, waitConnected=True) dropped = mn.run(mn.ping) self.assertEqual(dropped, 0)
def testLinear5( self ): "Ping test with both datapaths on a 5-switch topology" init() for switch in SWITCHES.values(): controllerParams = ControllerParams( '10.0.0.0', 8 ) mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller, controllerParams ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testMinimal( self ): "Ping test with both datapaths on minimal topology" init() for switch in SWITCHES.values(): controllerParams = ControllerParams( '10.0.0.0', 8 ) mn = Mininet( SingleSwitchTopo(), switch, Host, Controller, controllerParams ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testMinimal(self): "Ping test with both datapaths on minimal topology" init() for switch in SWITCHES.values(): controllerParams = ControllerParams('10.0.0.0', 8) mn = Mininet(SingleSwitchTopo(), switch, Host, Controller, controllerParams) dropped = mn.run(mn.ping) self.assertEqual(dropped, 0)
def testLinear5(self): "Ping test with both datapaths on a 5-switch topology" init() for switch in SWITCHES.values(): controllerParams = ControllerParams('10.0.0.0', 8) mn = Mininet(LinearTopo(k=5), switch, Host, Controller, controllerParams) dropped = mn.run(mn.ping) self.assertEqual(dropped, 0)
def testLinkBandwidth(self): "Verify that link bandwidths are accurate within a bound." BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = {"bw": BW, "use_htb": True} # Also verify correctness of limit limitng within a bound. mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink) bw_strs = mn.run(mn.iperf) for bw_str in bw_strs: bw = float(bw_str.split(" ")[0]) self.assertWithinTolerance(bw, BW, BW_TOLERANCE)
def testLinkBandwidth(self): "Verify that link bandwidths are accurate within a bound." BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = {'bw': BW, 'use_htb': True} # Also verify correctness of limit limitng within a bound. mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink) bw_strs = mn.run(mn.iperf) for bw_str in bw_strs: bw = float(bw_str.split(' ')[0]) self.assertWithinTolerance(bw, BW, BW_TOLERANCE)
def main(): numNodes = 20 numPorts = 5 numServerPorts = 5 numSwitches = 20 setLogLevel('info') info('* Creating Network\n') topo = Jellyfish(numNodes=numNodes, numPorts=numPorts, numServerPorts=numServerPorts, numSwitches=numSwitches) network = Mininet(topo=topo) network.start() dumpNodeConnections(network.hosts) # network.pingAll() network.run(CLI, network) info('* Stopping Network\n') network.stop()
def testLinkBandwidth( self ): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: self.skipTest ( 'UserSwitch has very poor performance, so skip for now' ) BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = { 'bw': BW, 'use_htb': True } # Also verify correctness of limit limitng within a bound. mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ), link=TCLink, switch=self.switchClass, waitConnected=True ) bw_strs = mn.run( mn.iperf, format='m' ) for bw_str in bw_strs: bw = float( bw_str.split(' ')[0] ) self.assertWithinTolerance( bw, BW, BW_TOLERANCE )
def testLinkDelay(self): "Verify that link delays are accurate within a bound." DELAY_MS = 15 DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail lopts = {"delay": "%sms" % DELAY_MS, "use_htb": True} mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink) ping_delays = mn.run(mn.pingFull) test_outputs = ping_delays[0] # Ignore unused variables below # pylint: disable-msg=W0612 node, dest, ping_outputs = test_outputs sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs self.assertEqual(sent, received) # pylint: enable-msg=W0612 for rttval in [rttmin, rttavg, rttmax]: # Multiply delay by 4 to cover there & back on two links self.assertWithinTolerance(rttval, DELAY_MS * 4.0, DELAY_TOLERANCE)
def testLinkDelay(self): "Verify that link delays are accurate within a bound." DELAY_MS = 15 DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail lopts = {'delay': '%sms' % DELAY_MS, 'use_htb': True} mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink) ping_delays = mn.run(mn.pingFull) test_outputs = ping_delays[0] # Ignore unused variables below # pylint: disable-msg=W0612 node, dest, ping_outputs = test_outputs sent, received, rttmin, rttavg, rttmax, rttdev = ping_outputs self.assertEqual(sent, received) # pylint: enable-msg=W0612 for rttval in [rttmin, rttavg, rttmax]: # Multiply delay by 4 to cover there & back on two links self.assertWithinTolerance(rttval, DELAY_MS * 4.0, DELAY_TOLERANCE)
def runOptionsTopoTest( self, n, msg, hopts=None, lopts=None ): "Generic topology-with-options test runner." mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts, lopts=lopts ), host=CPULimitedHost, link=TCLink, switch=self.switchClass, waitConnected=True ) dropped = mn.run( mn.ping ) hoptsStr = ', '.join( '%s: %s' % ( opt, value ) for opt, value in hopts.items() ) loptsStr = ', '.join( '%s: %s' % ( opt, value ) for opt, value in lopts.items() ) msg += ( '%s%% of pings were dropped during mininet.ping().\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'hopts = %s\n' 'lopts = %s\n' 'host = CPULimitedHost\n' 'link = TCLink\n' 'Switch = %s\n' % ( dropped, n, hoptsStr, loptsStr, self.switchClass ) ) self.assertEqual( dropped, 0, msg=msg )
def testSingle5( self ): "Ping test on 5-host single-switch topology" mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testMinimal( self ): "Ping test on minimal topology" mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testSingle5( self ): "Ping test with both datapaths on 5-host single-switch topology" for switch in SWITCHES.values(): mn = Mininet( SingleSwitchTopo( k=5 ), switch, Host, Controller ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testLinear5( self ): "Ping test with both datapaths on a 5-switch topology" for switch in SWITCHES.values(): mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testLinear5( self ): "Ping test on a 5-switch topology" mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
#!/usr/bin/python from mininet.topo import Topo from mininet.net import Mininet from mininet.cli import CLI class part1_topo(Topo): def build(self): s1 = self.addSwitch('s1') h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') self.addLink(s1, h1) self.addLink(s1, h2) self.addLink(s1, h3) self.addLink(s1, h4) topos = {'part1': part1_topo} if __name__ == '__main__': t = part1_topo() net = Mininet(topo=t) net.run() CLI(net) net.stop()
for i in range(sw_head, sw_head + max_sw): Switchs.append('sw%d' %i) self.addNode('sw%d' %i) for i in range(h_head, h_head + max_h): Hosts.append('h%d' %i) self.addNode('h%d' %i) #"""偶数と奇数をここで分ける""" Hostknum = Hosts[0::2] #偶数 Hostgnum = Hosts[1::2] #奇数 for (i,j,sw) in zip(Hostknum, Hostgnum, Switchs): if i != None: self.addLink(sw,i) if j != None: self.addLink(sw,j) for i in range(0, max_sw-1): self.addLink(Switchs[i], Switchs[i+1]) self.addLink(Switchs[max_sw-1], Switchs[0]) # topos = { 'myringtopo': ( lambda: MyRingTopo() ) } if __name__ == '__main__': setLogLevel( 'info' ) topo = MyRingTopo( max_sw=22 ) network = Mininet(topo, switch=OVSSwitch ) network.run( CLI, network )