def testNodeID(self): '''Verify NodeID conversion in both directions.''' pairs = {(0, 0, 1): 0x000001, (0, 1, 1): 0x000101, (1, 0, 1): 0x010001} for a, b in pairs.iteritems(): (x, y, z) = a self.assertEqual(FatTreeTopo.FatTreeNodeID(x, y, z).dpid, b) self.assertEqual(str(FatTreeTopo.FatTreeNodeID(dpid = b)), str(a))
def testDownNodesAndEdges(self): '''Verify number of down edges at each layer.''' ft = FatTreeTopo(4) # map FatTreeNodeID inputs to down node/edge totals pairs = {(0, 0, 1): 2, (0, 2, 1): 2, (4, 1, 1): 4} for a, b in pairs.iteritems(): (x, y, z) = a host = FatTreeTopo.FatTreeNodeID(x, y, z).name_str() self.assertEqual(len(ft.down_nodes(host)), b) self.assertEqual(len(ft.down_edges(host)), b)
def main(): "Create and run experiment" start = time() if 'seed' in vars(args): random.seed(args.seed) k = args.k host = custom(CPULimitedHost, cpu=4.0/(k**3)) link = custom(TCLink, bw=args.bw, delay='0ms') if args.control: topo = NonblockingFatTreeTopo(k=k) net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True) else: topo = FatTreeTopo(k=k) net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True, controller=RemoteController) net.start() flowsToCreate = [] for fcount in range(args.fph): if args.traffic.startswith('stride'): stride_amt = int(args.traffic.split(',')[1]) matrix = compute_stride(k, stride_amt) elif args.traffic.startswith('stag'): edge_prob, pod_prob = map(float, args.traffic.split(',')[1:]) matrix = compute_stagger_prob(k, edge_prob, pod_prob) elif args.traffic.startswith('random'): matrix = compute_random(k) elif args.traffic.startswith('randbij'): matrix = compute_randbij(k) else: raise Exception('Unrecognized traffic type') print "Running with matrix", matrix addMatrixToFlow(flowsToCreate, matrix) if args.controller: controller = Popen(args.controller, shell=True, preexec_fn=os.setsid) # NOTE: special signal for random number of flows if args.fph >= 6: random.shuffle(flowsToCreate) flowsToCreate = flowsToCreate[0:len(flowsToCreate)/2] start = time() run_expt(net, k, flowsToCreate) end = time() if args.controller: os.killpg(controller.pid, signal.SIGKILL) net.stop()
def genTopo(self): for i in range(self.num): # if self.type == 'threetier' or self.type == 'all': # t = ThreeTierTopo(int(round(self.nSw/12))) # for link in t.links(): # t.setlinkInfo(link[0], link[1], {"bw":self.bw, "delay":"1"}) # self.topos['threetier'].append(t) if self.type == 'clos' or self.type == 'all': t = ClosTopo(int(round(self.nSw / 8))) for link in t.links(): t.setlinkInfo(link[0], link[1], { "bw": self.bw, "delay": "1" }) self.topos['clos'].append(t) k = int(round((0.8 * self.nSw)**0.5)) if self.type == 'fattree' or self.type == 'all': t = FatTreeTopo(k) for link in t.links(): t.setlinkInfo(link[0], link[1], { "bw": self.bw, "delay": "1" }) self.topos['fattree'].append(t) self.nHost = int(len(t.switches()) / 1.2) # self.k = len(t.links())/len(t.switches())+1 # self.bw = 10 # if self.type == 'binarytree' or self.type == 'all': # self.topos.append(binaryTree(self.nHost, self.bw, 0.1)) if self.type == 'jellyfish' or self.type == 'all': self.topos['jellyfish'].append( JellyFish(self.nHost, self.nSw, int(0.2 * self.nSw), self.bw * 2, lat=0.1)) # JellyFish(nHost, nSw, k, bw, lat=0.1) # if self.type == 'treenet' or self.type == 'all': # t = TreeTopo(3, 2) # for link in t.links(): # t.setlinkInfo(link[0], link[1], {"bw":self.bw, "delay":"1"}) # self.topos.append(t) if self.type == 'rocketfuel' or self.type == 'all': rfFile = '../rocketfuel/sigcomm02/' + self.selectRF(self.nSw) self.topos['rocketfuel'].append(RocketFuel(rfFile))
def testValidateTopos(self): '''Verify number of hosts, switches, and nodes at each layer.''' sizes = range(4, 6, 2) for k in sizes: ft = FatTreeTopo(k) hosts = (k ** 3) / 4 self.assertEqual(len(ft.hosts()), hosts) switches = 5 * (k ** 2) / 4 self.assertEqual(len(ft.switches()), switches) nodes = hosts + switches self.assertEqual(len(ft.nodes()), nodes) self.assertEqual(len(ft.layer_nodes(0)), (k ** 2) / 4) self.assertEqual(len(ft.layer_nodes(1)), (k ** 2) / 2) self.assertEqual(len(ft.layer_nodes(2)), (k ** 2) / 2) self.assertEqual(len(ft.layer_nodes(3)), (k ** 3) / 4) self.assertEqual(len(ft.links()), 3 * hosts)
def testPorts(self): '''Verify port numbering between selected nodes.''' ft = FatTreeTopo(4) tuples = [((0, 0, 2), (0, 0, 1), 0, 2), ((0, 0, 1), (0, 2, 1), 1, 2), ((0, 0, 1), (0, 3, 1), 3, 2), ((0, 2, 1), (4, 1, 1), 1, 1), ((0, 2, 1), (4, 1, 2), 3, 1), ((3, 3, 1), (4, 2, 1), 1, 4) ] for tuple_ in tuples: src, dst, srcp_exp, dstp_exp = tuple_ x, y, z = src x2, y2, z2 = dst src_dpid = FatTreeTopo.FatTreeNodeID(x, y, z).name_str() dst_dpid = FatTreeTopo.FatTreeNodeID(x2, y2, z2).name_str() (srcp, dstp) = ft.port(src_dpid, dst_dpid) self.assertEqual(srcp, srcp_exp) self.assertEqual(dstp, dstp_exp) # flip order and ensure same result (dstp, srcp) = ft.port(dst_dpid, src_dpid) self.assertEqual(srcp, srcp_exp) self.assertEqual(dstp, dstp_exp)
def FatTreeNet(k=4, speed=1.0, **kwargs): topo = FatTreeTopo(k, speed) net = Mininet(topo, **kwargs) return net
def main(): k = int(args.n) topo = FatTreeTopo(k=k) host = custom(CPULimitedHost, cpu=.5) # 15% of system bandwidth link = custom(TCLink, bw=args.bw, delay='.05ms', max_queue_size=200) net = Mininet(topo=topo, host=host, link=link, controller=RemoteController, autoSetMacs=True) net.start() print "*** Dumping network connections:" dumpNetConnections(net) raw_args = shlex.split( "/home/ubuntu/pox/pox.py riplpox.riplpox --topo=ft,%s --routing=%s" % (k, args.routing)) proc = Popen(raw_args) print "********************************************************" print "*******************STARTED RIPLPOX**********************" #This sleep 10 is to give the riplpox controller time to start up before you start sending. Seems to work well. sleep(10) # # Actual Experiment # seconds = args.time # Start the bandwidth and cwnd monitors in the background monitor = Process(target=monitor_devs_ng, args=('%s/bwm.txt' % args.dir, 1.0)) monitor.start() start_tcpprobe() # Get receiver and clients recvr = net.getNodeByName('0_0_2') sender1 = net.getNodeByName('0_0_3') # Start the receiver port = 5001 recvr.cmd('iperf -Z reno -s -p', port, '> %s/iperf_server.txt' % args.dir, '&') waitListening(sender1, recvr, port) # TODO: start the sender iperf processes and wait for the flows to finish # Hint: Use getNodeByName() to get a handle on each sender. # Hint: Use sendCmd() and waitOutput() to start iperf and wait for them to finish # iperf command to start flow: 'iperf -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt' % (recvr.IP(), 5001, seconds, args.dir, node_name) # Hint (not important): You may use progress(t) to track your experiment progress for p in range(k): # Pod Range for e in range(2): # Edge range for h in range(2, (k / 2) + 2): # Host Range if p == 0 and e == 0: continue node_name = '_'.join(str(x) for x in [p, e, h]) sender = net.getNodeByName(node_name) sender.sendCmd( 'iperf -Z reno -c %s -p %s -t %d -i 1 -yc > %s/iperf_%s.txt' % (recvr.IP(), 5001, seconds, args.dir, node_name)) for p in range(k): # Pod Range for e in range(2): # Edge range for h in range(2, (k / 2) + 2): # Host Range if p == 0 and e == 0: continue node_name = '_'.join(str(x) for x in [p, e, h]) sender = net.getNodeByName(node_name) sender.waitOutput() recvr.cmd('kill %iperf') # Shut down monitors monitor.terminate() stop_tcpprobe() #Here just use p.terminate() to stop the process when you are done net.stop() proc.terminate()
def testCreateTopos(): '''Create multiple topos.''' sizes = range(4, 10, 2) for k in sizes: FatTreeTopo(k)