def run_adaptive_redundancy(host_num, coder_log_conf): """Run network application for multi-hop topology :param host_num (int): Number of hosts :param profile (int): To be tested profile :param coder_log_conf (dict): Configs for logs of coders """ net = Containernet(controller=RemoteController, link=TCLink, autoStaticArp=True) mgr = VNFManager(net) hosts = create_topology(net, host_num) try: info("*** Starting network\n") net.start() # MARK: Use static ARP to avoid ping losses # info("*** Ping all to update ARP tables of each host\n") # net.pingAll() info("*** Adding OpenFlow rules\n") add_ovs_flows(net, host_num) info("*** Disable Checksum offloading\n") disable_cksum_offload(host_num) info("*** Deploy coders\n") coders = deploy_coders(mgr, hosts) # Wait for coders to be ready info("*** Starting Ryu controller\n") c0 = net.get("c0") makeTerm(c0, cmd="ryu-manager adaptive_rlnc_sdn_controller.py ; read") # s2 = net.get('s2') # makeTerm(s2, cmd="watch -n 1 ovs-ofctl dump-flows s2") # s4 = net.get('s4') # makeTerm(s4, cmd="watch -n 1 ovs-ofctl dump-flows s4") time.sleep(3) info("*** Run Iperf\n") run_iperf_test(hosts[0], hosts[-1], "udp", 30) print_coders_log(coders, coder_log_conf) remove_coders(mgr, coders) info("*** Emulation stops...") except Exception as e: error("*** Emulation has errors:") error(e) finally: info("*** Stopping network\n") net.stop() mgr.stop()
def run_topo(): net = Containernet( controller=Controller, link=TCLink, switch=OVSBridge, topo=TestTopo(2) ) info("*** Adding controller\n") net.addController("c0") info("*** Starting network\n") net.start() net.pingAll() h1 = net.get("h1") h2 = net.get("h2") net.iperf((h1, h2), l4Type="UDP", udpBw="10M") info("*** Stopping network") net.stop()
def run_net(): # To be tested parameters at runtime loss_rates = [30] net = Containernet(controller=Controller, link=TCLink) info("*** Adding controller\n") net.addController("c0") info("*** Adding hosts\n") h1 = net.addHost( "h1", cls=DockerHost, dimage="dev_test", ip="10.0.0.1/24", docker_args={"cpuset_cpus": "0", "nano_cpus": int(1e8)}, ) h2 = net.addHost( "h2", cls=DockerHost, dimage="dev_test", ip="10.0.0.2/24", docker_args={"cpuset_cpus": "0", "nano_cpus": int(1e8)}, ) info("*** Adding switch\n") s1 = net.addSwitch("s1") info("*** Creating links\n") net.addLink(h1, s1, bw=10, delay="100ms", intfName1="h1-s1", intfName2="s1-h1") net.addLink(h2, s1, bw=10, delay="100ms", intfName1="h2-s1", intfName2="s1-h2") info("*** Starting network\n") net.start() info("**** Testing bandwidth between h1 and h2\n") net.iperf((h1, h2), l4Type="UDP", udpBw="10M") info("*** Configure the link loss rate of h1 at runtime\n") for loss in loss_rates: print("* The loss rate of h1 is {:.2f}%, unidirectional".format(loss)) print("* Ping test count: %d" % PING_COUNT) host = net.get("h1") # INFO: The parent number is defined in mininet/link.py ret = host.cmd( "tc qdisc change dev {} {} handle 10: netem loss {}%".format( "h1-s1", " parent 5:1", loss ) ) if ret != "": print("Failed to change loss. Error:%s\n", ret) ret = h1.cmd("ping -c %d 10.0.0.2" % PING_COUNT) sent, received = tool.parsePing(ret) measured = ((sent - received) / float(sent)) * 100.0 print( "Expected loss rate: {:.2f}%, measured loss rate: {:.2f}%".format( loss, measured ) ) info("*** Stopping network") net.stop()