def get_max_throughput(net, output_dir): reset() cprint("Finding max throughput...", 'red') seconds = args.time server, client = net.hosts[0], net.hosts[1] server.popen("%s -s -p %s" % (CUSTOM_IPERF_PATH, 5001), shell=True) proc = client.popen("%s -c %s -p %s -t %d -yc -i 10 > %s/max_throughput.txt" % (CUSTOM_IPERF_PATH, server.IP(), 5001, seconds, output_dir), shell=True) progress(args.time + 1) proc.communicate() os.system('killall -9 ' + CUSTOM_IPERF_PATH)
def get_max_throughput(net, output_dir): reset() cprint("Finding max throughput...", 'red') seconds = args.time server, client = net.hosts[0], net.hosts[1] server.popen("%s -s -p %s" % (CUSTOM_IPERF_PATH, 5001), shell=True) proc = client.popen( "%s -c %s -p %s -t %d -yc -i 10 > %s/max_throughput.txt" % (CUSTOM_IPERF_PATH, server.IP(), 5001, seconds, output_dir), shell=True) progress(args.time + 1) proc.communicate() os.system('killall -9 ' + CUSTOM_IPERF_PATH)
def main(): top_dir = os.path.join(args.dir, args.topo, args.workload) if not os.path.exists(top_dir): os.makedirs(top_dir) start = time() topo, pox_c = get_topology(top_dir) link = custom(TCLink, bw=args.bw, max_queue_size=args.q) #, delay=args.delay) net = Mininet(controller=RemoteController, topo=topo, host=Host, link=link, switch=OVSKernelSwitch) net.start() workload = get_workload(net) #net.pingAll() sleep(3) #CLI(net) get_max_throughput(net, top_dir) for nflows in range(1, 9): cwd = os.path.join(top_dir, "flows%d" % nflows) if not os.path.exists(cwd): os.makedirs(cwd) enable_mptcp(nflows) cprint( "Starting experiment for workload %s with %i subflows" % (args.workload, nflows), "green") workload.run(cwd, args.qmon) # Shut down iperf processes os.system('killall -9 ' + CUSTOM_IPERF_PATH) net.stop() # kill pox controller pox_c.kill() pox_c.wait() Popen("killall -9 top bwm-ng tcpdump cat mnexec", shell=True).wait() end = time() reset() cprint("Experiment took %.3f seconds" % (end - start), "yellow")
def main(): top_dir = os.path.join(args.dir, args.topo, args.workload) if not os.path.exists(top_dir): os.makedirs(top_dir) start = time() topo, pox_c = get_topology(top_dir) link = custom(TCLink, bw=args.bw, max_queue_size=args.q) #, delay=args.delay) net = Mininet(controller=RemoteController, topo=topo, host=Host, link=link, switch=OVSKernelSwitch) net.start() workload = get_workload(net) #net.pingAll() sleep(3) #CLI(net) get_max_throughput(net, top_dir) for nflows in range(1, 9): cwd = os.path.join(top_dir, "flows%d" % nflows) if not os.path.exists(cwd): os.makedirs(cwd) enable_mptcp(nflows) cprint("Starting experiment for workload %s with %i subflows" % ( args.workload, nflows), "green") workload.run(cwd, args.qmon) # Shut down iperf processes os.system('killall -9 ' + CUSTOM_IPERF_PATH) net.stop() # kill pox controller pox_c.kill() pox_c.wait() Popen("killall -9 top bwm-ng tcpdump cat mnexec", shell=True).wait() end = time() reset() cprint("Experiment took %.3f seconds" % (end - start), "yellow")
(args.workload, nflows), "green") workload.run(cwd, args.qmon) # Shut down iperf processes os.system('killall -9 ' + CUSTOM_IPERF_PATH) net.stop() # kill pox controller pox_c.kill() pox_c.wait() Popen("killall -9 top bwm-ng tcpdump cat mnexec", shell=True).wait() end = time() reset() cprint("Experiment took %.3f seconds" % (end - start), "yellow") if __name__ == '__main__': try: main() except: print "-" * 80 print "Caught exception. Cleaning up..." print "-" * 80 import traceback reset() traceback.print_exc() os.system("killall -9 top bwm-ng tcpdump cat mnexec iperf; mn -c")
def main(args): topo = TwoHostNInterfaceTopo(n=args.n) link = custom(TCLink, bw=args.bw) net = Mininet(topo=topo, switch=Switch, link=link) set_enabled(args.mptcp) set_ndiffports(args.ndiffports) net.start() h1 = net.getNodeByName('h1') h2 = net.getNodeByName('h2') for j in range(args.n): h1.cmdPrint('ifconfig h1-eth%i 10.0.%i.1 netmask 255.255.255.0' % (j, j)) h2.cmdPrint('ifconfig h2-eth%i 10.0.%i.2 netmask 255.255.255.0' % (j, j)) if args.mptcp: dev = 'h1-eth%i' % (j) h1.cmdPrint('ip rule add from 10.0.%i.1 table %i' % (j, j+1)) h1.cmdPrint('ip route add 10.0.%i.0/24 dev %s scope link table %i' \ % (j, dev, j+1)) h1.cmdPrint('ip route add default via 10.0.%i.1 dev %s table %s'\ % (j, dev, j+1)) if args.debug: outfiles = {h: '/tmp/%s.out' % h.name for h in net.hosts} errfiles = {h: '/tmp/%s.out' % h.name for h in net.hosts} [ h.cmd('echo >',outfiles[h]) for h in net.hosts ] [ h.cmd('echo >',errfiles[h]) for h in net.hosts ] if args.debug: h2.sendCmd('python receiver.py --id %d --nr %d --ns %d --ds %s --debug' %(0, 1, 1, args.ds), '>', outfiles[h2], '2>', errfiles[h2]) else: h2.sendCmd('python receiver.py --id %d --nr %d --ns %d --ds %s' %(0, 1, 1, args.ds)) ips = [ h2.IP() ] time.sleep(1) if args.debug: h1.sendCmd('python sender.py --id %d --ns %d --ips %s --ds %s --debug'\ % (0, 1, ips, args.ds), '>', outfiles[h1], '2>', errfiles[h1]) else: h1.sendCmd('python sender.py --id %d --cs %d --ns %d --ips %s --ds %s'\ % (0, 500, 1, ips, args.ds)) tts = {} ttr = {} p = Popen(['./timer.py']) tts[h1] = h1.waitOutput() ttr[h2] = h2.waitOutput() p.kill() print tts.values() print ttr.values() write_results(tts, ttr, args) net.stop() reset()
args.r = int(args.r) return args def write_results(tts, ttr, args): if not os.path.exists('../results/sw%s' % (args.n)): os.makedirs('../results/sw%s' % (args.n)) if args.mptcp: f = open('../results/sw%s/bw%s_nf%s_mptcp.csv' % (args.n,args.bw,args.ndiffports), 'a') else: f = open('../results/sw%s/bw%s_nf%s.csv' % (args.n,args.bw,args.ndiffports), 'a') f.write('%s,%s\n' % (','.join(map(lambda x: x.strip('\n'), tts.values())), ','.join(map(lambda x: x.strip('\n'), ttr.values())))) f.close() if __name__ == '__main__': try: # lg.setLogLevel('info') args = parse_args() main(args) except: import traceback traceback.print_exc(file=sys.stdout) reset() os.system("mn -c; killall controller")
def main(): args = parse_args() # pox_c = Popen("exec ~/pox/pox.py --no-cli riplpox.riplpox --topo=dht --routing=hashed --mode=reactive 1> /tmp/pox.out 2> /tmp/pox.out", shell=True) pox_c = Popen("exec ~/pox/pox.py --no-cli riplpox.riplpox --topo=ft,%s --routing=hashed --mode=reactive 1> /tmp/pox.out 2> /tmp/pox.out" % args.k, shell=True) time.sleep(1) # wait for controller to start topo = FatTreeTopo(k=args.k) # topo = DualHomedTopo(k=args.k) link = custom(TCLink, bw=args.bw, max_queue_size=100) print 'Starting mininet...' net = Mininet(controller=RemoteController, topo=topo, link=link, switch=OVSKernelSwitch, host=Host) net.start() enable_mptcp(args.nflows) time.sleep(3) mappings = create_mappings(args, net) sndrs = mappings['s'] rcvrs = mappings['r'] # print 's:', sndrs # print 'r:', rcvrs if args.debug: outfiles = {h: '/tmp/%s.out' % h.name for h in sndrs + rcvrs} errfiles = {h: '/tmp/%s.out' % h.name for h in sndrs + rcvrs} [ h.cmd('echo >',outfiles[h]) for h in sndrs + rcvrs ] [ h.cmd('echo >',errfiles[h]) for h in sndrs + rcvrs ] for r in rcvrs: if args.debug: r.sendCmd('python receiver.py --id %s --nr %d --ns %d --ds %s --debug' % (r.name, args.nr, args.ns, args.ds), '1>', outfiles[r], '2>', errfiles[r]) else: r.sendCmd('python receiver.py --id %s --nr %i --ns %i --ds %s' % (r.name, args.nr, args.ns, args.ds)) time.sleep(1) # let servers start up ips = map(lambda x: x.IP(), rcvrs) for s,i in zip(sndrs,range(len(sndrs))): if args.debug: s.sendCmd('python sender.py --id %s --cs %d --ips %s --ds %s --debug' % (i, args.cs, ips, args.ds), '1>', outfiles[s], '2>', errfiles[s]) else: s.sendCmd('python sender.py --id %s --cs %d --ips %s --ds %s' % (i, args.cs, ips, args.ds)) tts = {} ttr = {} p = subprocess.Popen(['./timer.py']) for s in sndrs: tts[s] = s.waitOutput() for r in rcvrs: ttr[r] = r.waitOutput() p.kill() print tts.values() print ttr.values() net.stop() # kill pox controller pox_c.kill() pox_c.wait() #net.stop() reset() write_results(tts, ttr, args)