def perfTest(): "Create a network and run simle performance test" linkopts1 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) linkopts2 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) linkopts3 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=2) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) #Start the network net.start() print "Dumping host dumpNodeConnections" dumpNodeConnections(net.hosts) print "Testing network connetivity" net.pingAll() print "Testing bandwidth between hosts h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) #Call ineractive CLI #mininet.cli.CLI(net) net.stop()
def run(): cleanup() c = RemoteController('c', '127.0.0.1', 6653) net = Mininet(topo=SimplePktSwitch(), host=CPULimitedHost, controller=None, link=TCLink) net.addController(c) net.start() h1, h5 = net.get('h1', 'h5') net.iperf((h1, h5)) h2 = net.get('h2') print "Testing network connectivity" net.pingAll() result = h5.cmd('ifconfig') print(result) result3 = h2.cmd('ping 10.0.0.5 -c 4') print(result3) #print "Starting xtrem here" #t1 = threading.Thread(target = h4.cmd('xterm h4')) #t2 = threading.Thread(target = h1.cmd('sudo hping3 10.0.0.4 --flood')) #t1.start() #t2.start() #t1.join() #t2.join() #print (result2) CLI(net) net.stop()
def run(): "Create and test a simple network" c = RemoteController('c', '118.138.235.213', 6633) topo = HypercubeTopo(n=3) net = Mininet(topo=topo, controller=None) net.addController(c) net.start() print "Testing network connectivity" for _ in range(2): net.pingAll() (first, last) = net.get('h1', 'h' + str(len(net.hosts))) net.iperf((first, last)) CLI(net) time.sleep(120) node1 = net.get('s1') node2 = net.get('s2') net.delLinkBetween(node1, node2) for _ in range(2): net.pingAll() (first, last) = net.get('h1', 'h' + str(len(net.hosts))) net.iperf((first, last)) CLI(net) net.stop()
def perfTest(): "Create network and run simple performance test" prm = myParam(n=200, data_size=200) print prm.n, prm.m, prm.data_size, prm.pipes topo = myTopo(prm.n, prm.m) net = Mininet(topo=topo, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections( net.hosts ) print "Dumping switch connections" dumpNodeConnections( net.switches ) #print "Testing network connectivity" #net.pingAll() print "Testing bandwidth under s1" h1, h2 = net.get('h1', 'h2') net.iperf((h1, h2)) print "Testing bandwidth across tree" h1, h2 = net.get('h1', 'h%d'%(prm.n+1)) net.iperf((h1, h2)) for p in (1, 2, 5, 10, 20): prm.pipes = p simTrans(net.hosts, prm) #CLI( net ) net.stop()
def perfTest(): "Create network and run simple performance test" prm = myParam(n=200, data_size=200) print prm.n, prm.m, prm.data_size, prm.pipes topo = myTopo(prm.n, prm.m) net = Mininet(topo=topo, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Dumping switch connections" dumpNodeConnections(net.switches) #print "Testing network connectivity" #net.pingAll() print "Testing bandwidth under s1" h1, h2 = net.get('h1', 'h2') net.iperf((h1, h2)) print "Testing bandwidth across tree" h1, h2 = net.get('h1', 'h%d' % (prm.n + 1)) net.iperf((h1, h2)) for p in (1, 2, 5, 10, 20): prm.pipes = p simTrans(net.hosts, prm) #CLI( net ) net.stop()
def redistTest(): "Create network and run simple performance test" topo = SimpleTopo() net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=RemoteController, autoSetMacs=True) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) h1, h2, h3 = net.get('h1', 'h2', 'h3') # ping all to make sure all flows get installed print "Testing network connectivity" net.pingAll() print dump_flows("s1") net.iperf((h1,h3), l4Type='TCP', udpBw=100, seconds=5) net.iperf((h2,h3), l4Type='TCP', udpBw=100, seconds=10) sleep(15) print dump_flows("s1") # net.iperf((h1,h3), l4Type='TCP', udpBw=100, seconds=5) # net.iperf((h2,h3), l4Type='TCP', udpBw=100, seconds=10) net.pingAll() CLI(net)
def test_topology(topo: Topo, net: Mininet): print("Dumping host connections") dumpNodeConnections(net.hosts) print("Waiting switch connections") net.waitConnected() print("Testing network connectivity - (i: switches are learning)") net.pingAll() print("Testing network connectivity - (ii: after learning)") net.pingAll() print("Get all hosts") print(topo.hosts(sort=True)) # print("Get all links") # for link in topo.links(sort=True, withKeys=True, withInfo=True): # pprint(link) # print() if conf['test']['iperf'] == -1: return else: hosts = [net.get(i) for i in topo.hosts(sort=True)] if conf['test']['iperf'] == 0: net.iperf((hosts[0], hosts[-1])) else: [net.iperf((i, j)) for i in hosts for j in hosts if i != j]
def perfTest(): "Create network and run simple performance test" topo = SingleSwitchTopo(c=50, s=5) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.iperf() for p in range(5): h1 = net.getNodeByName('server%s' % (p + 1)) print "running daemon on %s" % h1 h1.cmd( '/home/seth/magi/scripts/magi_daemon.py --nodeconf /tmp/server%s/server%s.conf -l DEBUG &' % (p + 1, p + 1)) time.sleep(10) for p in range(50): h1 = net.getNodeByName('client%s' % (p + 1)) print "running daemon on %s" % h1 h1.cmd( '/home/seth/magi/scripts/magi_daemon.py --nodeconf /tmp/client%s/client%s.conf -l DEBUG &' % (p + 1, p + 1)) #net.pingAll() CLI(net) #c1, s1 = net.getNodeByName('c1', 's1') #mnet.iperf((c1, s1)) net.stop()
def run_tests(delay): print("DELAY {0}".format(delay)) topo = Dumbbell_Topology(delay) net = Mininet(topo=topo, link=TCLink) net.start() print("Dumping host connections") dumpNodeConnections(net.hosts) print("Testing network connectivity") h1, h3 = net.get('h1', 'h3') h2, h4 = net.get('h2', 'h4') for i in range(1, 10): net.pingFull(hosts=(h1, h3)) for i in range(1, 10): net.pingFull(hosts=(h3, h1)) for i in range(1, 10): net.pingFull(hosts=(h2, h4)) for i in range(1, 10): net.pingFull(hosts=(h4, h2)) print("Testing bandwidth between h1 and h3..") net.iperf(hosts=(h1, h3), fmt='m', seconds=10, port=5001) print("Testing bandwidth between h2 and h4") net.iperf(hosts=(h2, h4), fmt='m', seconds=10, port=5001) print("Stopping test...") net.stop()
def simpleTest(): topo = DumbbellTopo(n=4) net = Mininet( topo=topo, host=CPULimitedHost, link=TCLink, controller=lambda name: RemoteController(name, ip='127.0.0.1')) net.start() print("Dumping host connections") dumpNodeConnections(net.hosts) print("Testing network connectivity") # os.system("./config_queue.sh") net.pingAll() h1, h2 = net.get('h1', 'h2') # pdb.set_trace() # h1.cmd('iperf -c %s -u -n 200M -i 1 -b 20M'%(h2.IP())) # h2.cmd('iperf -s -u') print("Start iperf...") h2.sendCmd("iperf -s -u") h1.cmdPrint("iperf -c %s -u -n 20 -i 1 -b 2" % (h2.IP())) net.iperf((h1, h2)) os.system("./destroy_queue.sh") net.stop() os.system("sudo ovs-vsctl -- --all destroy qos -- --all destroy queue")
def intfOptions(): "run various traffic control commands on a single interface" net = Mininet( autoStaticArp=True ) net.addController( 'c0' ) h1 = net.addHost( 'h1' ) h2 = net.addHost( 'h2' ) s1 = net.addSwitch( 's1' ) link1 = net.addLink( h1, s1, cls=TCLink ) net.addLink( h2, s1 ) net.start() # flush out latency from reactive forwarding delay net.pingAll() info( '\n*** Configuring one intf with bandwidth of 5 Mb\n' ) link1.intf1.config( bw=5 ) info( '\n*** Running iperf to test\n' ) net.iperf() info( '\n*** Configuring one intf with loss of 50%\n' ) link1.intf1.config( loss=50 ) info( '\n' ) net.iperf( ( h1, h2 ), l4Type='UDP' ) info( '\n*** Configuring one intf with delay of 15ms\n' ) link1.intf1.config( delay='15ms' ) info( '\n*** Run a ping to confirm delay\n' ) net.pingPairFull() info( '\n*** Done testing\n' ) net.stop()
def testIt(): topo = Topology(int(sys.argv[1])) net = Mininet(topo, link=TCLink) net.start() h1, h2 = net.get('h1', 'h2') net.iperf((h1,h2)) net.stop()
def dumbbell_test(): """ Create and test a dumbbell network. """ topo = DumbbellTopo(delay=21) net = Mininet(topo) net.start() print "Dumping host connections..." dumpNodeConnections(net.hosts) print "Testing network connectivity..." h1, h2 = net.get('h1', 'h2') h3, h4 = net.get('h3', 'h4') for i in xrange(1, 10): net.pingFull(hosts=(h1, h2)) for i in xrange(1, 10): net.pingFull(hosts=(h2, h1)) for i in xrange(1, 10): net.pingFull(hosts=(h4, h3)) for i in xrange(1, 10): net.pingFull(hosts=(h3, h4)) print "Testing bandwidth between h1 and h2..." net.iperf(hosts=(h1, h2), fmt='m', seconds=10, port=5001) print "Testing bandwidth between h3 and h4..." net.iperf(hosts=(h3, h4), fmt='m', seconds=10, port=5001) print "Stopping test..." net.stop()
def run_experiment(): "Create and test a simple experiment" topo = SampleTopology() privateDirs = [('/var/log', '/tmp/%(name)s/var/log'), ('/var/run', '/tmp/%(name)s/var/run'), '/var/mn'] host = partial(Host, privateDirs=privateDirs) net = Mininet(topo, host=host, link=TCLink, build=False) c1 = RemoteController('c1', ip='192.168.1.103', port=6633) net.addController(c1) net.build() net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() info("Testing bandwidth between h1 and h2\n") h1, h2 = net.getNodeByName('h1', 'h2') net.iperf((h2, h1), l4Type='UDP') p1 = h1.popen('python myServer.py -i %s &' % h1.IP()) h2.cmd('python myClient.py -i %s -m "hello world"' % h1.IP()) directories = [directory[0] if isinstance(directory, tuple) else directory for directory in privateDirs] #info('Private Directories:', directories, '\n') #CLI(net) p1.terminate() net.stop()
def perfTest(): "Create network and run perf test" linkopts1 = dict(bw=50, delay='5ms') #, loss=1, max_queue_size=1000, use_htb=True) linkopts2 = dict(bw=30, delay='10ms') #, loss=3, max_queue_size=2000, use_htb=True) linkopts3 = dict(bw=10, delay='15ms') #, loss=5, max_queue_size=3000, use_htb=True) topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3) net = Mininet(topo=topo, link=TCLink) net.start() """ print "Dump host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() """ print "Testing bandwidth between h1 and h27" h1 = net.get('h1') h27 = net.get('h27') net.iperf((h1, h27)) outputString = h1.cmd('ping', '-c6', h27.IP()) print "output: " + outputString.strip() net.stop()
def test_iperf(): topo = TopoTest() net = Mininet(topo=topo, link=TCLink) net.start() net.iperf() net.pingAll() net.stop()
def Test(): # Initialize Mininet net = Mininet(topo=CustomTree(), build=False, ipBase='10.0.0.0/8') # Add a Controller info('*** Adding controller\n') c0 = net.addController('c0', controller=None, ip='127.0.0.1', protocol='tcp', port=6633) # Start controller and switches info('*** Starting network\n') net.start() # Dump all host connections info('*** Dumping host connections\n') dumpNodeConnections(net.hosts) # Ping all hosts (UDP) info('*** Testing network connectivity\n') net.pingAll() # Use iperf to check bandwidth between two nodes (TCP) info('*** Testing bandwidth between h1 and h8\n') h1, h8 = net.get('h1', 'h8') net.iperf((h1, h8)) # Stop the network net.stop()
def test_iperf2(): topo = TopoTest() net = Mininet(topo=topo, link=TCLink) net.start() sleep(30) net.iperf() net.stop()
def required(x,y): topo = MyTopo(x, y) net = Mininet(topo,host=CPULimitedHost, link=TCLink) net.start() for i in xrange(y): for j in xrange(y): if (i+1)%2==0 and (j+1)%2==1: net.nameToNode["h"+str(i+1)].cmd("iptables -A OUTPUT -o h"+str(i+1)+"-eth0 -d 10.0.0."+ str(j+1)+" -j DROP") net.nameToNode["h"+str(j+1)].cmd("iptables -A OUTPUT -o h"+str(j+1)+"-eth0 -d 10.0.0."+ str(i+1)+" -j DROP") elif (i+1)%2==1 and (j+1)%2==0: net.nameToNode["h"+str(i+1)].cmd("iptables -A OUTPUT -o h"+str(i+1)+"-eth0 -d 10.0.0."+ str(j+1)+" -j DROP") net.nameToNode["h"+str(j+1)].cmd("iptables -A OUTPUT -o h"+str(j+1)+"-eth0 -d 10.0.0."+ str(i+1)+" -j DROP") net.pingAll() try: print "Testing bandwidth between h1 and h3" h1, h3 = net.get('h1', 'h3') net.iperf((h1, h3)) except: c=1 try: print "Testing bandwidth between h1 and h3" h4, h2 = net.get('h2', 'h4') net.iperf((h2, h4)) except: c=1 dumpNodeConnections(net.switches) CLI(net) net.stop()
def treeNet(): # Create a tree network without a local controller and constrained links net = Mininet(controller=None, link=TCLink) # Adding remote controller net.addController('c1', controller=RemoteController, ip='127.0.0.1', port=6633) # Adding hosts h1 = net.addHost('h1', ip='10.0.0.1') h2 = net.addHost('h2', ip='10.0.0.2') h3 = net.addHost('h3', ip='10.0.0.3') h4 = net.addHost('h4', ip='10.0.0.4') # Adding switches s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') s3 = net.addSwitch('s3') # Creating core links 100Mbps, 100ms delay and user links 1000Mbps and 1ms delay net.addLink(s2, s1) net.addLink(s3, s1) net.addLink(h1, s2) net.addLink(h2, s2) net.addLink(h3, s3) net.addLink(h4, s3) # Starting network net.start() # Dumping host connections dumpNodeConnections(net.hosts) # Testing network connectivity net.pingAll() # Testing bandwidth between nodes h1, h2 = net.get('h1', 'h2') net.iperf((h1, h2)) h2, h1 = net.get('h2', 'h1') net.iperf((h2, h1)) h2, h3 = net.get('h2', 'h3') net.iperf((h2, h3)) h2, h4 = net.get('h2', 'h4') net.iperf((h2, h4)) h3, h4 = net.get('h3', 'h4') net.iperf((h3, h4)) # Running CLI CLI(net) # Stopping network net.stop()
def perf(Link): net = Mininet( host=RemoteHost, link=Link ) h1 = net.addHost( 'h1') h2 = net.addHost( 'h2', server='ubuntu2' ) net.addLink( h1, h2 ) net.start() net.pingAll() net.iperf() net.stop()
def perf(Link): net = Mininet( host=RemoteHost, link=Link ) h1 = net.addHost( 'h1') h2 = net.addHost( 'h2', server='mn1.local' ) net.addLink( h1, h2 ) net.start() net.pingAll() net.iperf() net.stop()
def perfTest(): net = Mininet(topo=DirectLinkTopo(), link=TCLink) net.start() h1, h2 = net.getNodeByName("h1", "h2") net.iperf((h1, h2)) h1.cmd("xterm -hold -e ./Bandwidth -s -p 10000&") time.sleep(1) h2.cmd("xterm -hold -e ./Bandwidth -c -h 10.0.0.1 -p 10000") net.stop()
def perf(Link): "Test connectivity nand performance over Link" net = Mininet(host=RemoteHost, link=Link, waitConnected=True) h1 = net.addHost('h1') h2 = net.addHost('h2', server='ubuntu2') net.addLink(h1, h2) net.start() net.pingAll() net.iperf() net.stop()
def perf(Link): "Test connectivity nand performance over Link" net = Mininet( host=RemoteHost, link=Link ) h1 = net.addHost( 'h1') h2 = net.addHost( 'h2', server='ubuntu2' ) net.addLink( h1, h2 ) net.start() net.pingAll() net.iperf() net.stop()
def createTopo(): topo = DynamicTopo(HOST, LINK, BANDWIDTH) net = Mininet(topo=topo, switch=OVSBridge, link=TCLink) net.start() initHost(topo.hostList, net, ATTACK_OPTS.index(ATTACK)) print "Starting network: host=" + str(HOST) + " link=" + str( LINK) + " bandwidth=" + str(BANDWIDTH) + " attack=" + str(ATTACK) CLI(net) net.iperf() net.stop()
def perfTest(): "Create and test a simple network" topo = MyTopo(switch_num=SWITCH_NUM, host_num=HOST_NUM, conn_map=CONN_MAP) net = Mininet(topo) net.start() for i in range(2, 5): print(f"Testing TCP throughput between h1 and h{i}") h1, hi = net.get('h1', f'h{i}') net.iperf((h1, hi)) net.stop()
def simpleTest(): topo = SingleSwitchTopo(n = 4) net = Mininet(topo = topo, host = CPULimitedHost, link = TCLink) net.start() print 'Dumping host connections' dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "testing bandwidth between h1 and h4" h1,h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def perfTest(): topo = LinearTopo(k=4) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def simpleTest(): "Create and test a simple network" topo = LinearTopo(k=4) net = Mininet(topo) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def performaceTest(): topo = SingleTopologyPerformance(k=5) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Exibindo informacoes de conexao do host" dumpNodeConnections(net.hosts) print "Testando a conectividade de rede" net.pingAll() print "Teste de largura de banda entre h1 e h3" h1, h3 = net.get('h1','h3') net.iperf((h1, h3)) net.stop()
def perfTest( lossy=True ): "Create network and run simple performance test" topo = SingleSwitchTopo( n=4, lossy=lossy ) net = Mininet( topo=topo, host=CPULimitedHost, link=TCLink, autoStaticArp=True ) net.start() info( "Dumping host connections\n" ) dumpNodeConnections(net.hosts) info( "Testing bandwidth between h1 and h4\n" ) h1, h4 = net.getNodeByName('h1', 'h4') net.iperf( ( h1, h4 ), l4Type='TCP' ) net.stop()
def perfTest(): "Create network and run simple performance test" topo = fatTreeTopo() net = Mininet(topo) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h8" h1, h8 = net.get('h1', 'h8') net.iperf((h1, h8)) net.stop()
def perfTest(): "Create and test a simple performance test" topo = LinearTopo(k=4) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dmping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivitiy" net.pingAll() print "Testing bandwidht between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1,h4)) net.stop()
def perfTest( lossy=True ): "Create network and run simple performance test" topo = SingleSwitchTopo( n=4, lossy=lossy ) net = Mininet( topo=topo, host=CPULimitedHost, link=TCLink, autoStaticArp=True ) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing bandwidth between h1 and h4" h1, h4 = net.getNodeByName('h1', 'h4') net.iperf( ( h1, h4 ), l4Type='UDP' ) net.stop()
def Test(): "Create network and run simple performance test" topo = SingleSwitchTopo(n=4) net = Mininet(topo=topo, link=NSLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def perfTest(): """Create network and run simple performance test""" topo = SingleSwitchTopo(n=4) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print("Dumping host connections") dumpNodeConnections(net.hosts) print("Testing network connectivity") net.pingAll() print("Testing bandwidth between h1 and h4") h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
class BasicOpenflowTest(unittest.TestCase): def addHost(self, N): logging.debug("Creating host h%s and add to net.", N) name = 'h%d' % N ip = '10.0.0.%d' % N return self.net.addHost(name, ip=ip) def setUp(self): self.net = Mininet(controller=Controller, switch=Switch) logging.info("Creating controllers") self.net.addController('c1', command='ovs-testcontroller') logging.info("Creating switches") s1 = self.net.addSwitch('s1', protocols="OpenFlow10") s2 = self.net.addSwitch('s2', protocols="OpenFlow10") logging.info("Creating hosts (7 on each switch)") hosts1 = [self.addHost(n) for n in (1, 2, 3, 4, 5, 6, 7)] hosts2 = [self.addHost(n) for n in (8, 9, 10, 11, 12, 13, 14)] logging.info("Creating links") for h in hosts1: self.net.addLink(s1, h) for h in hosts2: self.net.addLink(s2, h) self.net.addLink(s1, s2) logging.info("Starting network") self.net.start() def testPingAll(self): logging.info("Testing network") packetLoss = self.net.pingAll() self.assertTrue( packetLoss == 0, "Packet loss during ping test %s" % packetLoss) def testIPerfTCP(self): logging.info("Running TCP performance test") self.net.iperf() def testIPerfUDP(self): logging.info("Running UDP performance test") self.net.iperf(l4Type='UDP') def tearDown(self): logging.info("Stopping network") self.net.stop()
def perTest(): "Specify performance parameters for the links" # Between core and aggregation switches linkopts1 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) # Between aggregation and edge switches linkopts2 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) # Between edge switches and hosts linkopts3 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) "Create and test a simple network" topo = CustomTopo(linkopts1=linkopts1, linkopts2=linkopts2, linkopts3=linkopts3, fanout=2) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 with h2, h3 and h5" h1, h2 = net.get('h1', 'h2') net.iperf( ( h1, h2 ) ) h1, h3 = net.get('h1', 'h3') net.iperf( ( h1, h3 ) ) h1, h5 = net.get('h1', 'h5') net.iperf( ( h1, h5 ) ) h1, h7 = net.get('h1', 'h7') net.iperf( ( h1, h7 ) ) net.stop()
def verySimpleLimit( bw=150 ): "Absurdly simple limiting test" intf = custom( TCIntf, bw=bw ) net = Mininet( intf=intf ) h1, h2 = net.addHost( 'h1' ), net.addHost( 'h2' ) net.addLink( h1, h2 ) net.start() net.pingAll() net.iperf() h1.cmdPrint( 'tc -s qdisc ls dev', h1.defaultIntf() ) h2.cmdPrint( 'tc -d class show dev', h2.defaultIntf() ) h1.cmdPrint( 'tc -s qdisc ls dev', h1.defaultIntf() ) h2.cmdPrint( 'tc -d class show dev', h2.defaultIntf() ) net.stop()
def perfTest(): "Create network and run simple performance test" topo = CustomTopo(linkopts1=1, linkopts2=2, linkopts3=2, fanout=2) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h4" h1, h8 = net.get('h1', 'h8') net.iperf((h1, h8)) net.stop()
def createTopo(): "Creating network" topo = SwitchHostTopo() net = Mininet(topo=topo, controller=OVSController, link=TCLink) net.start() print "Testing network connectivity" net.pingAll() print "Testing bandwidth between odd hosts" net.iperf((net.getNodeByName(hosts_array[0]), net.getNodeByName(hosts_array[2]))) print "Testing bandwidth between even hosts" net.iperf((net.getNodeByName(hosts_array[1]), net.getNodeByName(hosts_array[3]))) net.stop()
def testIt(): bw = sys.argv[1] topo = Topology(int(bw)) net = Mininet(topo, link=TCLink) net.start() h1, h2 = net.get('h1', 'h2') h2.cmd("sar -u 1 60 > simple_no_ntop_cpu_%s &" % bw) sleep(5) net.iperf((h1, h2)) h2.cmd('killall sar') #h1.cmd("ITGDec recv_log_file") net.stop()
def perfTest(): "Create network and run simple performance test" linkopts1 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) linkopts2 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) linkopts3 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True) topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=2) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def simpleTest(): "Create and test a simple network" linkopts1 = {'bw':100, 'delay':'5ms'} linkopts2 = {'bw':50, 'delay':'10ms'} linkopts3 = {'bw':5, 'delay':'20ms'} "linkopts1 = dict(bw=10, delay='5ms', loss=1, max_queue_size=1000, use_htb=True)" topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=2) net = Mininet(topo=topo, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def customTest(): "Create and Test a Simple Network" linkopts1={'bw':10,'delay':'5ms','loss':1,'max_queue_size':1000,'use_htb':True} linkopts2={'bw':10,'delay':'5ms','loss':1,'max_queue_size':1000,'use_htb':True} linkopts3={'bw':10,'delay':'5ms','loss':1,'max_queue_size':1000,'use_htb':True} fanout=2 topo=CustomTopo(linkopts1,linkopts2,linkopts3,fanout) net=Mininet(topo,link=TCLink) net.start() print "dumping host connections" dumpNodeConnections(net.hosts) print"Testing network Connectivity" net.pingAll() print"Testing Bandwidth between h1 and h4" h1,h4=net.get('h1','h4') net.iperf((h1,h4)) net.stop()
def testing(): "Create network and run simple performance" topology = TestTopo(sw=3, hosts=4) controllerIP='127.0.0.1' controllerPort=6653 net = Mininet(topo=topology, link=TCLink, controller=lambda name: RemoteController('c0', controllerIP, controllerPort), autoSetMacs=True, cleanup=True) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) net.pingAll() print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) net.stop()
def linearBandwidthTest( lengths ): "Check bandwidth at various lengths along a switch chain." results = {} switchCount = max( lengths ) hostCount = switchCount + 1 switches = { 'reference user': UserSwitch, 'Open vSwitch kernel': OVSKernelSwitch } # UserSwitch is horribly slow with recent kernels. # We can reinstate it once its performance is fixed del switches[ 'reference user' ] topo = LinearTestTopo( hostCount ) # Select TCP Reno output = quietRun( 'sysctl -w net.ipv4.tcp_congestion_control=reno' ) assert 'reno' in output for datapath in switches.keys(): print( "*** testing", datapath, "datapath" ) Switch = switches[ datapath ] results[ datapath ] = [] link = partial( TCLink, delay='1ms' ) net = Mininet( topo=topo, switch=Switch, controller=Controller, waitConnected=True, link=link ) net.start() print( "*** testing basic connectivity" ) for n in lengths: net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] ) print( "*** testing bandwidth" ) for n in lengths: src, dst = net.hosts[ 0 ], net.hosts[ n ] # Try to prime the pump to reduce PACKET_INs during test # since the reference controller is reactive src.cmd( 'telnet', dst.IP(), '5001' ) print( "testing", src.name, "<->", dst.name ) bandwidth = net.iperf( [ src, dst ], seconds=10 ) print( bandwidth ) flush() results[ datapath ] += [ ( n, bandwidth ) ] net.stop() for datapath in switches.keys(): print() print( "*** Linear network results for", datapath, "datapath:" ) print() result = results[ datapath ] print( "SwitchCount\tiperf Results" ) for switchCount, bandwidth in result: print( switchCount, '\t\t' ) print( bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client' ) print() print()
def testDecisionTopology(): "Create network and run simple performance test" topo = SpecialTopo(100, 10) net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=RemoteController) net.start() time.sleep(10) h1, h2, h3, h4, h5, h6 = net.hosts pairs = [(h1, h2), (h2, h3), (h4, h5), (h5, h6), (h1, h4), (h2, h5), (h3, h6), (h2, h4), (h3, h5)] for a,b in pairs: net.ping([a,b]) net.iperf([a,b]) for i in xrange(4): j = requests.get("http://localhost:8080/set?f={}".format(i)).json() print j["message"] print test_pings(h1, h6, 40) print net.iperf([h1,h6], l4Type='UDP', udpBw='10M') time.sleep(20) CLI(net) net.stop()
def Test(): corelinkopts = {'bw':10, 'delay':'5ms' } aggrlinkopts = {'bw':5, 'delay':'5ms' } edgelinkopts = {'bw':1, 'delay':'5ms' } #linkopts = {} linkopts = {'bw':10, 'delay':'5ms', 'loss':1, 'max_queue_size':1000, 'use_htb':True} topo = CustomTopo(linkopts, linkopts, linkopts, fanout=2) net = Mininet(topo,link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing bandwidth between h1 and h4" h1, h4 = net.get('h1', 'h4') net.iperf((h1, h4)) h8 = net.get('h8') net.iperf((h1, h8)) net.stop()
def run(topo_conf, tunnels, old_trf, new_trf, default_route={}, ryu_controller='./cuphook.py'): setLogLevel('info') net = Mininet(autoSetMacs=True, autoStaticArp=True, controller=RemoteController) hosts, switches, output_ports = build_topo(net, topo_conf) with open('outports.txt', 'w') as f: for k in sorted(output_ports): print(k, output_ports[k], file=f) c0 = net.addController('c0') net.start() set_of_version(switches.values()) gen_default_rules(hosts, switches, output_ports, default_route) gen_tunnel_rules(hosts, switches, output_ports, old_trf, new_trf, tunnels) # start controller c0.cmdPrint('ryu-manager --verbose {0} &'.format(ryu_controller)) #time.sleep(10) net.iperf() CLI(net) net.stop()
def testIt(): bw = sys.argv[1] topo = Topology(int(bw)) net = Mininet(topo, link=TCLink) net.start() h1, h2 = net.get('h1', 'h2') h2.cmd("redis-server > /tmp/redis 2>&1 &") sleep(5) h2.cmd("ntopng > /tmp/ntop 2>&1 &") sleep(5) h2.cmd("sar -u 1 60 > iperf_ntop_cpu_%s &" % bw) sleep(5) net.iperf((h1, h2)) h2.cmd('killall ntopng') h2.cmd('killall redis-server') h2.cmd('killall sar') #h1.cmd("ITGDec recv_log_file") net.stop()
def simpleTest(): # argument to put in either remote or local controller "Create and test a simple network" #c0 = RemoteController( 'c0', ip='192.168.90.146' ) c0 = RemoteController( 'c0', ip='192.168.56.1' ) #c0 = Controller( 'c0', port=6633) # the cmap here needs to dynamically take the switch name from the switchLists[] so that it is not static #cmap = { 'a11': c0, 'a12': c0, 'a21': c0, 'a22': c0, 'a31': c0, 'a32': c0, 'a41': c0, 'a42': c0, 'c11': c0, 'c21': c0, 'c31': c0, 'c41': c0, 't11': c0, 't12': c0, 't21': c0, 't22': c0, 't31': c0, 't32': c0, 't41': c0, 't42': c0} class MultiSwitch( OVSSwitch ): "Custom Switch() subclass that connects to different controllers" def start( self, controllers ): return OVSSwitch.start( self, [ cmap[ self.name ] ] ) #section for handling the differnt argumetns.... simpleTest(arg1, arg2, ...) will take in arguments from user topo = dcFatTreeTopo(k=2) net = Mininet( topo=topo, switch=MultiSwitch, build=False, link=TCLink ) cString = "{" for i in irange(0, len(allList)-1): if i != len(allList)-1: tempCString = "'" + allList[i] + "'" + " : c0, " else: tempCString = "'" + allList[i] + "'" + " : c0 " cString += tempCString cmapString = cString + "}" #print "wowzer" + cmapString cmap = cmapString net.addController(c0) net.build() net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) stplen=len(stplist) for i in range(0,stplen): os.system(stplist[i]) print stplist[i] sleep(5) print "Testing network connectivity" #def perfTest(): # if user test argument is active then pick the correct test net.pingAll() net.pingAll() print "Testing bandwidth between h11 and h12..............." #h11, h12 = net.get('h11', 'h12') #net.iperf((h11, h12) #print "Testing bandwidth between h11 and h14..............." h11, h14 = net.get('h11', 'h14') net.iperf((h11, h14)) #print "Testing bandwidth between h11 and h16..............." h11, h22 = net.get('h11', 'h22') net.iperf((h11, h22)) #print "Testing bandwidth between h11 and h18..............." h11, h24 = net.get('h11', 'h24') net.iperf((h11, h24)) # also argument for generating traffic # arugment for stat analysis CLI( net ) net.stop()
def perfTest(n,delay,loss,c): "Create network and run simple performance test" #topo= SingleSwitchTopo() topo = SingleSwitchTopoWithLossAndDelay() topo.build(n=n,delay=delay,loss=loss) #topoLAD.build() net = Mininet(topo=topo,link=TCLink,controller=OVSController) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() print "Testing bandwidth between h1 and h2" h1, h2 ,s1 = net.get('h1', 'h2', 's1') #h1.sendCmd('sudo tcpdump -s 68 -ttt -w h1-normal.pcap -i h1-eth0 &') #h2.sendCmd('sudo tcpdump -s 68 -ttt -w h2-normal.pcap -i h2-eth0 &') #h1.sendCmd('./D-ITG-2.8.1-r1023/bin/ITGRecv -l recv_log_file &') #h2.sendCmd('./D-ITG-2.8.1-r1023/bin/ITGSend -a 10.0.0.1 -rp 9501 -C 1000 -u 500 1000 -l send_log_file &') cmd = 'sudo tcpdump -s 68 -ttt -w s1-%d-%s-%d.pcap -i s1-eth1 &'%(c,delay if delay else '0ms',loss) s1.sendCmd(cmd) net.iperf((h1, h2)) #CLI(net) net.stop()
def linearBandwidthTest( lengths ): "Check bandwidth at various lengths along a switch chain." results = {} switchCount = max( lengths ) hostCount = switchCount + 1 switches = { 'reference user': UserSwitch, 'Open vSwitch kernel': OVSKernelSwitch } # UserSwitch is horribly slow with recent kernels. # We can reinstate it once its performance is fixed del switches[ 'reference user' ] topo = LinearTestTopo( hostCount ) for datapath in switches.keys(): print "*** testing", datapath, "datapath" Switch = switches[ datapath ] results[ datapath ] = [] link = partial( TCLink, delay='1ms' ) net = Mininet( topo=topo, switch=Switch, controller=Controller, waitConnected=True, link=link ) net.start() print "*** testing basic connectivity" for n in lengths: net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] ) print "*** testing bandwidth" for n in lengths: src, dst = net.hosts[ 0 ], net.hosts[ n ] print "testing", src.name, "<->", dst.name, bandwidth = net.iperf( [ src, dst ] ) print bandwidth flush() results[ datapath ] += [ ( n, bandwidth ) ] net.stop() for datapath in switches.keys(): print print "*** Linear network results for", datapath, "datapath:" print result = results[ datapath ] print "SwitchCount\tiperf Results" for switchCount, bandwidth in result: print switchCount, '\t\t', print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client' print print
def customTest(): "Create and test a fanout network." # linkopts1 = {'bw':50, 'delay':'5ms', 'loss':0, 'max_queue_size':1000, 'use_htb':True} linkopts1 = {'bw':50, 'delay':'5ms'} linkopts2 = {'bw':30, 'delay':'10ms'} linkopts3 = {'bw':10, 'delay':'15ms'} topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3) net = Mininet(topo=topo, link=TCLink) net.start() print "Dumping switch connections" dumpNodeConnections(net.switches) print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" # net.pingAll() print "Testing bandwidth between h1 and h27" h1, h27 = net.get('h1', 'h27') net.iperf((h1, h27)) print h1.cmd('ping', '-c6', h27.IP()) net.stop()