def CreatTopo(self,Da,Di,**params): Topo.__init__(self,**params) inters = [self.addSwitch('inter%x' % k,dpid='%x' %(k+10)) for k in range(1,Da/2+1) ] aggs = [self.addSwitch('agg%x' % k,dpid='%x' %(k+20)) for k in range(1,Di+1) ] tors = [self.addSwitch('tor%x' % k,dpid='%x' %(k+30)) for k in range(1,Da*Di/4+1) ] hosts = [ self.addHost( 'vm%d' % i,ip='10.0.0.%d' %i ) for i in range(1,(Da*Di/4)*3+1) ] # creat links between instances for a in aggs: for i in inters: self.addLink(a,i) for i in range(0,Di/2): for j in range(0,Da*Di/8): self.addLink(aggs[i],tors[j]) for i in range(Di/2,Di): for j in range(Da*Di/8,Da*Di/4): self.addLink(aggs[i],tors[j]) for i in range(0,Da*Di/4): self.addLink(hosts[i*3],tors[i]) self.addLink(hosts[i*3+1],tors[i]) self.addLink(hosts[i*3+2],tors[i]) print self.ports
def __init__(self, **opts): Topo.__init__(self, **opts) h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') h5 = self.addHost('h5') h6 = self.addHost('h6') h7 = self.addHost('h7') h8 = self.addHost('h8') h9 = self.addHost('h9') h10 = self.addHost('h10') s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') self.addLink(h1, s1) self.addLink(h7, s1) self.addLink(h8, s1) self.addLink(h2, s2) self.addLink(h3, s3) self.addLink(h4, s4) self.addLink(h9, s4) self.addLink(h10, s4) self.addLink(h5, s5) self.addLink(h6, s6) self.addLink(s1, s2, bw=20, delay='40ms') self.addLink(s2, s3, bw=40, delay='10ms') self.addLink(s3, s4, bw=30, delay='30ms') self.addLink(s2, s5, bw=25, delay='5ms') self.addLink(s3, s6, bw=25, delay='5ms')
def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts): # Initialize topology and default options Topo.__init__(self, **opts) # Add your logic here ... core_sw = [] agg_sw = [] edge_sw = [] hosts = [] # creating core switch (root of the tree) core_sw.append(self.addSwitch("c1")) # creating aggregation switches for x in range(1, len(core_sw) * fanout + 1): print x agg_sw.append(self.addSwitch("a%s" % x)) self.addLink(agg_sw[x - 1], core_sw[x // fanout - 1], **linkopts1) # creating edge switches for x in range(1, len(agg_sw) * fanout + 1): edge_sw.append(self.addSwitch("e%s" % x)) self.addLink(edge_sw[x - 1], agg_sw[x // fanout - 1], **linkopts2) for x in range(1, len(edge_sw) * fanout + 1): hosts.append(self.addHost("h%s" % x)) self.addLink(hosts[x - 1], edge_sw[x // fanout - 1], **linkopts3)
def __init__(self, n=2, **opts): Topo.__init__(self, **opts) # Add hosts and switches h1 = self.addHost('h1') h2 = self.addHost('h2') I1 = self.addSwitch('I1', dpid=toID('00:00:00:00:00:01')) s2 = self.addSwitch('s2', dpid=toID('00:00:00:00:00:02')) s3 = self.addSwitch('s3', dpid=toID('00:00:00:00:00:03')) s4 = self.addSwitch('s4', dpid=toID('00:00:00:00:00:04')) s5 = self.addSwitch('s5', dpid=toID('00:00:00:00:00:05')) s6 = self.addSwitch('s6', dpid=toID('00:00:00:00:00:06')) s7 = self.addSwitch('s7', dpid=toID('00:00:00:00:00:07')) s8 = self.addSwitch('s8', dpid=toID('00:00:00:00:00:09')) s9 = self.addSwitch('s9', dpid=toID('00:00:00:00:00:09')) E2 = self.addSwitch('E2', dpid=toID('00:00:00:00:00:10')) # links Add self.addLink(I1, h1)#, 2, 1, intfName1 = 'eth0-h1') self.addLink(E2, h2)#, 2, 1, intfName1 = 'eth0-h2') self.addLink(I1, s2) self.addLink(s2, s3) self.addLink(s3, s4) self.addLink(s4, s5) self.addLink(s5, s6) self.addLink(s6, s7) self.addLink(s7, s8) self.addLink(s8, s9) self.addLink(s9, E2)
def __init__( self, **opts ): "Create a topology." # Initialize Topology Topo.__init__( self, **opts ) # add nodes, switches first... NewYork = self.addSwitch( 's0' ) Chicago = self.addSwitch( 's1' ) WashingtonDC = self.addSwitch( 's2' ) Seattle = self.addSwitch( 's3' ) Sunnyvale = self.addSwitch( 's4' ) LosAngeles = self.addSwitch( 's5' ) Denver = self.addSwitch( 's6' ) KansasCity = self.addSwitch( 's7' ) Houston = self.addSwitch( 's8' ) Atlanta = self.addSwitch( 's9' ) Indianapolis = self.addSwitch( 's10' ) # ... and now hosts NewYork_host = self.addHost( 'h0' ) Chicago_host = self.addHost( 'h1' ) WashingtonDC_host = self.addHost( 'h2' ) Seattle_host = self.addHost( 'h3' ) Sunnyvale_host = self.addHost( 'h4' ) LosAngeles_host = self.addHost( 'h5' ) Denver_host = self.addHost( 'h6' ) KansasCity_host = self.addHost( 'h7' ) Houston_host = self.addHost( 'h8' ) Atlanta_host = self.addHost( 'h9' ) Indianapolis_host = self.addHost( 'h10' ) # add edges between switch and corresponding host self.addLink( NewYork , NewYork_host ) self.addLink( Chicago , Chicago_host ) self.addLink( WashingtonDC , WashingtonDC_host ) self.addLink( Seattle , Seattle_host ) self.addLink( Sunnyvale , Sunnyvale_host ) self.addLink( LosAngeles , LosAngeles_host ) self.addLink( Denver , Denver_host ) self.addLink( KansasCity , KansasCity_host ) self.addLink( Houston , Houston_host ) self.addLink( Atlanta , Atlanta_host ) self.addLink( Indianapolis , Indianapolis_host ) # add edges between switches self.addLink( NewYork , Chicago, bw=10, delay='5.82294818601ms') self.addLink( NewYork , WashingtonDC, bw=10, delay='1.66933354639ms') self.addLink( Chicago , Indianapolis, bw=10, delay='1.33817152535ms') self.addLink( WashingtonDC , Atlanta, bw=10, delay='4.43098085052ms') self.addLink( Seattle , Sunnyvale, bw=10, delay='5.78617273178ms') self.addLink( Seattle , Denver, bw=10, delay='8.33987030826ms') self.addLink( Sunnyvale , LosAngeles, bw=10, delay='2.55695492867ms') self.addLink( Sunnyvale , Denver, bw=10, delay='7.64100479966ms') self.addLink( LosAngeles , Houston, bw=10, delay='11.2143737889ms') self.addLink( Denver , KansasCity, bw=10, delay='4.53199947571ms') self.addLink( KansasCity , Houston, bw=10, delay='5.29499644815ms') self.addLink( KansasCity , Indianapolis, bw=10, delay='3.7130222434ms') self.addLink( Houston , Atlanta, bw=10, delay='5.73005892826ms') self.addLink( Atlanta , Indianapolis, bw=10, delay='3.49428237002ms')
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches host1 = self.addHost( 'h1' ) host2 = self.addHost( 'h2' ) host3 = self.addHost( 'h3' ) host4 = self.addHost( 'h4' ) host5 = self.addHost( 'h5' ) switch1 = self.addSwitch( 's12' ) switch2 = self.addSwitch( 's11' ) switch3 = self.addSwitch( 's22' ) switch4 = self.addSwitch( 's34' ) switch5 = self.addSwitch( 's33' ) switch6 = self.addSwitch( 's44' ) switch7 = self.addSwitch( 's55' ) # Add links self.addLink( host1, switch1 ) self.addLink( host2, switch1 ) self.addLink( host3, switch4 ) self.addLink( host4, switch4 ) self.addLink( host5, switch7 ) self.addLink( switch1, switch2 ) self.addLink( switch1, switch3 ) self.addLink( switch4, switch2 ) self.addLink( switch4, switch3 ) self.addLink( switch5, switch2 ) self.addLink( switch5, switch3 ) self.addLink( switch5, switch6 ) self.addLink( switch6, switch7 )
def __init__( self, snum, hnum ): Topo.__init__( self ) swi = {} hos = {} # print "reached 1" snum = int(snum) hnum = int(hnum) for x in xrange(snum): s = self.addSwitch("s" +str(x+1)) swi[x+1]= s # print "reached 2 " for x in xrange(hnum): h = self.addHost("h" +str(x+1)) hos[x+1]= h # print "reached 3" for x in xrange(snum): for y in xrange(x): self.addLink(swi[x+1],swi[y+1]) # print "reached 4" sph = hnum/snum sin = swi.keys() skey = sin*int(hnum/snum) # print skey tmp = sin[:(hnum%snum)] # print tmp skey = skey + tmp skey.sort() # print skey i = 1 for x in skey: self.addLink(swi[x], hos[i]) i = i+1
def __init__(self, hosts=2, bwlimit=10, lat=0.1, workers=2, bottleneck = 1000, **params): print " * __init__ Dumbbell topo" assert workers==2, "!Assertion Error: Dumbbell may formed of two workers! Asked:"+str(workers) Topo.__init__(self, **params) tor = [] bw = bwlimit s = 1 #bw = 10a #Note: if we send 10, partition is 5/5, if we send 11, partition is 5/6 or 5/11 host = 1 assert hosts%workers==0, "!Assertion Error: MaxiNet Tools-Dumbbell, host partition unequal" #hostsperworker = hosts/worker print " * Adding hosts and switches to dumbbell topology. Link BW =",bwlimit for i in xrange(workers): #1 switch per worker print ' s'+str(s), sw = self.addSwitch('s' + str(s), dpid=self.makeDPID(s), **dict(listenPort=(13000 + s - 1))) s = s + 1 tor.append(sw) #equal percentage host for j in xrange(hosts/workers): print " h"+str(host), h = self.addHost('h' + str(host), mac=self.makeMAC(host-1), ip="10.0.0." + str(host)) host = host+1 self.addLink(h, sw, bw=bw, delay=str(lat) + "ms") print "\n" #toDo = tor # nodes that have to be integrated into the tree print " * Adding dumbbell bottleneck link. BW =",bottleneck assert len(tor)==2, "Dumbbell link requested with more than two links" self.addLink(tor[0], tor[1], bw=bottleneck, delay=str(lat) + "ms")
def __init__(self, hosts=2, bwlimit=10, lat=0.1, **opts): Topo.__init__(self, **opts) tor = [] numLeafes = hosts bw = bwlimit s = 1 #bw = 10 for i in range(numLeafes): h = self.addHost('h' + str(i + 1), mac=self.makeMAC(i), ip="10.0.0." + str(i + 1)) sw = self.addSwitch('s' + str(s), dpid=self.makeDPID(s), **dict(listenPort=(13000 + s - 1))) s = s + 1 self.addLink(h, sw, bw=bw, delay=str(lat) + "ms") tor.append(sw) toDo = tor # nodes that have to be integrated into the tree while len(toDo) > 1: newToDo = [] for i in range(0, len(toDo), 2): sw = self.addSwitch('s' + str(s), dpid=self.makeDPID(s), **dict(listenPort=(13000 + s - 1))) s = s + 1 newToDo.append(sw) self.addLink(toDo[i], sw, bw=bw, delay=str(lat) + "ms") if len(toDo) > (i + 1): self.addLink(toDo[i + 1], sw, bw=bw, delay=str(lat) + "ms") toDo = newToDo bw = 1.0 * bw
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches host1 = self.addHost( 'h1' ) host2 = self.addHost( 'h2' ) host3 = self.addHost( 'h3' ) host4 = self.addHost( 'h4' ) host5 = self.addHost( 'h5' ) edge_switch1 = self.addSwitch( 'es1' ) edge_switch2 = self.addSwitch( 'es2' ) core_switch1 = self.addSwitch('cs1') core_switch2 = self.addSwitch('cs2') core_switch3 = self.addSwitch('cs3') # Add links self.addLink( host1, edge_switch1 ) self.addLink( host2, edge_switch1 ) self.addLink( edge_switch1, core_switch1 ) self.addLink( core_switch1, core_switch2 ) self.addLink( core_switch2, edge_switch2 ) self.addLink( host3, edge_switch2 ) self.addLink( core_switch3, core_switch2 ) self.addLink( host4, core_switch3) self.addLink( host5, core_switch3)
def __init__(self, **opts): # Initialize topology and default options Topo.__init__(self, **opts) # Add switch s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s31 = self.addSwitch('s31') s32 = self.addSwitch('s32') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') s7 = self.addSwitch('s7') # Add hosts h1 = self.addHost('h1', mac='00:00:00:00:01:01', ip='10.0.1.1') h5 = self.addHost('h5', mac='00:00:00:00:05:01', ip='10.0.5.1') # Add link self.addLink(s1, h1) self.addLink(s5, h5) self.addLink(s1, s2) self.addLink(s2, s31) self.addLink(s2, s32) self.addLink(s31, s4) self.addLink(s32, s4) self.addLink(s4,s5) self.addLink(s5,s6) self.addLink(s4,s6) self.addLink(s5,s7) self.addLink(s7,s1)
def __init__( self ): # Initialize topology Topo.__init__( self ) # Add hosts and switches Host1 = self.addHost( 'h1' ) Host2 = self.addHost( 'h2' ) Host3 = self.addHost( 'h3' ) Host4 = self.addHost( 'h4' ) Host5 = self.addHost( 'h5' ) Switch1 = self.addSwitch( 's1' ) Switch2 = self.addSwitch( 's2' ) Switch3 = self.addSwitch( 's3' ) # Add links self.addLink( Host1, Switch1 ) self.addLink( Host2, Switch1 ) self.addLink( Switch1, Switch2 ) self.addLink( Switch2, Switch3 ) self.addLink( Host3, Switch3 ) self.addLink( Host4, Switch3 ) self.addLink( Host5, Switch3 )
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches emissor1 = self.addHost( 'h1' ) exibidor1000 = self.addHost( 'h2' ) servidor = self.addHost( 'h3' ) emissor2 = self.addHost( 'h4' ) exibidor1001 = self.addHost( 'h5' ) switch1 = self.addSwitch( 's1' ) switch2 = self.addSwitch( 's2' ) switch3 = self.addSwitch( 's3' ) switch4 = self.addSwitch( 's4' ) # Add links self.addLink(emissor1, switch1) self.addLink(exibidor1000, switch1) self.addLink(switch1, switch4) self.addLink(switch4, switch2) self.addLink(switch2, servidor) self.addLink(switch4, switch3) self.addLink(switch3, emissor2) self.addLink(exibidor1001, switch3)
def __init__( self ): # Initialize topology Topo.__init__( self ) #add switches s1 = self.addSwitch('s1', dpid="1") s2 = self.addSwitch('s2', dpid="2") #add hosts vm1 = self.addHost('vm1', ip="10.0.0.1", mac="00:00:00:00:00:01") vm2 = self.addHost('vm2', ip="10.0.0.2", mac="00:00:00:00:00:02") vm3 = self.addHost('vm3', ip="10.0.0.3", mac="00:00:00:00:00:03") vm4 = self.addHost('vm4', ip="10.0.0.4", mac="00:00:00:00:00:04") vm5 = self.addHost('vm5', ip="10.0.0.11", mac="00:00:00:00:01:01") vm6 = self.addHost('vm6', ip="10.0.0.12", mac="00:00:00:00:01:02") vm7 = self.addHost('vm7', ip="10.0.0.13", mac="00:00:00:00:01:03") vm8 = self.addHost('vm8', ip="10.0.0.14", mac="00:00:00:00:01:04") vmx = self.addHost('vmx', ip="10.0.0.128", mac="00:00:00:00:02:01") # Add links self.addLink(s1, s2, port1 = 5, port2 = 5) self.addLink(vm1, s1, port2 = 1) self.addLink(vm2, s1, port2 = 2) self.addLink(vm3, s1, port2 = 3) self.addLink(vm4, s1, port2 = 4) self.addLink(vm5, s2, port2 = 1) self.addLink(vm6, s2, port2 = 2) self.addLink(vm7, s2, port2 = 3) self.addLink(vm8, s2, port2 = 4) self.addLink(vmx, s1, port2 = 6)
def __init__(self): """Create custom topo.""" # Initialize topology Topo.__init__(self) # Add hosts and switches host1 = self.addHost('h1', cls=VLANHost, vlan=200) host2 = self.addHost('h2', cls=VLANHost, vlan=300) host3 = self.addHost('h3', cls=VLANHost, vlan=200) host4 = self.addHost('h4', cls=VLANHost, vlan=300) host5 = self.addHost('h5', cls=VLANHost, vlan=200) host6 = self.addHost('h6', cls=VLANHost, vlan=300) s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') self.addLink(s1, s2) self.addLink(s2, host1) self.addLink(s2, host2) self.addLink(s2, host3) self.addLink(s1, s3) self.addLink(s3, host4) self.addLink(s3, host5) self.addLink(s3, host6)
def __init__(self, conf_arq, workDir, **opts): Topo.__init__(self, **opts) global hosts_conf global links_conf hosts_conf = parse_hosts(conf_arq) switches_conf = parse_switches(conf_arq) links_conf = parse_links(conf_arq) self.isTCLink = False self.isLimited = False for host in hosts_conf: if host.cpu != None and self.isLimited != True: self.isLimited = True self.addHost(host.name, app=host.app, params=host.uri_tuples, cpu=host.cpu,cores=host.cores,cache=host.cache, workdir=workDir) for switch in switches_conf: self.addSwitch(switch.name) for link in links_conf: if len(link.linkDict) == 0: self.addLink(link.h1, link.h2) else: self.addLink(link.h1, link.h2, **link.linkDict) self.isTCLink = True info('Parse of ' + conf_arq + ' done.\n')
def __init__( self, enable_all = True ): "Create custom topo." Topo.__init__( self ) # h1 = self.addHost("h1") # h2 = self.addHost("h2") # h3 = self.addHost("h3", # ip="172.31.3.100/24", # defaultRoute="gw 172.31.3.1") # h4 = self.addHost("h4", # ip="172.31.4.100/24", # defaultRoute="gw 172.31.4.1") sA = self.addSwitch("s21") sB = self.addSwitch("s22") sC = self.addSwitch("s23") sD = self.addSwitch("s24") sE = self.addSwitch("s25") sF = self.addSwitch("s26") # self.addLink(h1, sA) # self.addLink(h2, sB) # self.addLink(h3, sC) # self.addLink(h4, sD) self.addLink(sA, sB) self.addLink(sA, sC) self.addLink(sB, sD) self.addLink(sC, sE) self.addLink(sD, sF) self.addLink(sE, sF)
def __init__( self ): """Create custom topo.""" Topo.__init__( self ) # Set Node IDs for hosts and switches # Add Nodes switches = [ self.addSwitch('s1'), self.addSwitch('s2') ] hosts = [ self.addHost('h3'), self.addHost('h4'), self.addHost('h5'), self.addHost('h6') ] # Add Edges edges = [ Edge(hosts[0], switches[0]), Edge(hosts[1], switches[0]), Edge(switches[0], switches[1]), Edge(hosts[2], switches[1]), Edge(hosts[3], switches[1]) ] for edge in edges: self.addLink( edge.left, edge.right )
def __init__( self ): "Creating topology." Topo.__init__( self ) h1 = self.addHost( 'h1' ) h2 = self.addHost( 'h2' ) h3 = self.addHost( 'h3' ) h4 = self.addHost( 'h4' ) h5 = self.addHost( 'h5' ) h6 = self.addHost( 'h6' ) s1 = self.addSwitch( 's1' ) s2 = self.addSwitch( 's2' ) s3 = self.addSwitch( 's3' ) s4 = self.addSwitch( 's4' ) s5 = self.addSwitch( 's5' ) s6 = self.addSwitch( 's6' ) s7 = self.addSwitch( 's7') self.addLink(s1,h1,port1=1) self.addLink(s2,h2,port1=1) self.addLink(s3,h3,port1=1) self.addLink(s4,h4,port1=1) self.addLink(s5,h5,port1=1) self.addLink(s6,h6,port1=1) self.addLink(h1,s7,port1=1) self.addLink(s1,s2) self.addLink(s2,s3) self.addLink(s3,s4) self.addLink(s4,s5) self.addLink(s5,s6) self.addLink(s6,s7)
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches leftHost_1 = self.addHost( 'h1' ) midHost_1 = self.addHost( 'h2' ) midHost_2 = self.addHost( 'h3' ) rightHost_1 = self.addHost( 'h4' ) rightHost_2 = self.addHost( 'h5' ) rightHost_3 = self.addHost( 'h6' ) leftSwitch = self.addSwitch( 's1' ) midSwitch = self.addSwitch( 's2' ) rightSwitch = self.addSwitch( 's3' ) # Add links self.addLink( leftHost_1, leftSwitch ) self.addLink( midHost_1, midSwitch ) self.addLink( midHost_2, midSwitch ) self.addLink( rightHost_1, rightSwitch ) self.addLink( rightHost_2, rightSwitch ) self.addLink( rightHost_3, rightSwitch ) self.addLink( leftSwitch, midSwitch ) self.addLink( midSwitch, rightSwitch )
def __init__(self, n=2, **opts): # Initialize topology and default options Topo.__init__(self, **opts) switch = self.addSwitch('s1') for h in range(n): host = self.addHost('h%s' % (h + 1)) self.addLink(host, switch)
def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts): # Initialize topology and default options Topo.__init__(self, **opts) aggregation = [] edge = [] host = [] self.linkopts = [ linkopts1, linkopts2, linkopts3 ] # Create core switch core = self.addSwitch('c1') # Aggregation switches for i in irange(1, fanout): aggregation.append(self.addSwitch('a%s' % (len(aggregation) + 1))) self.addLink(core, aggregation[-1], **linkopts1) # Edge switches for j in irange(1, fanout): edge.append(self.addSwitch('e%s' % (len(edge) + 1))) self.addLink(aggregation[-1], edge[-1], **linkopts2) # Hosts for k in irange(1, fanout): host.append(self.addHost('h%s' % (len(host) + 1))) self.addLink(host[-1], edge[-1], **linkopts3)
def __init__(self, **opts): Topo.__init__(self, **opts) #make switchs self.Iot_1 = self.addSwitch('Iot1') self.Iot_2 = self.addSwitch('IoT2') self.Iot_3 = self.addSwitch('IoT3') self.Iot_left = self.addSwitch('Iot4') self.Iot_right = self.addSwitch('Iot5') #make host self.H_1 = self.addHost('H1') self.H_2 = self.addHost('H2') #make link #self.addLink(self.Iot_1,self.H_1,0,0) #self.addLink(self.Iot_1,self.Iot_2,1,0) #self.addLink(self.Iot_2,self.H_2,1,0) #self.addLink(self.Iot_3,self.H_2,1,1) #self.addLink(self.Iot_3,self.H_1,0,1) self.addLink(self.Iot_left,self.H_1) self.addLink(self.Iot_1,self.Iot_left) self.addLink(self.Iot_1,self.Iot_2) self.addLink(self.Iot_2,self.Iot_right) self.addLink(self.Iot_3,self.Iot_right) self.addLink(self.Iot_3,self.Iot_left) self.addLink(self.Iot_right,self.H_2)
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches Switch1 = self.addSwitch( 's1' ) Switch2 = self.addSwitch( 's2' ) Switch3 = self.addSwitch( 's3' ) Switch4 = self.addSwitch( 's4' ) Host11 = self.addHost( 'h1' ) Host12 = self.addHost( 'h2' ) Host21 = self.addHost( 'h3' ) Host22 = self.addHost( 'h4' ) Host23 = self.addHost( 'h5' ) Service1 = self.addHost( 'srvc1' ) # Add links self.addLink( Host11, Switch1 ) self.addLink( Host12, Switch1 ) self.addLink( Host21, Switch2 ) self.addLink( Host22, Switch2 ) self.addLink( Host23, Switch2 ) self.addLink( Switch1, Switch2 ) self.addLink( Switch2, Switch4 ) self.addLink( Switch4, Switch3 ) self.addLink( Switch3, Switch1 ) self.addLink( Switch3, Service1 ) self.addLink( Switch4, Service1 )
def __init__( self, *args, **kwargs ): Topo.__init__( self, *args, **kwargs ) # Describe Code # Set up data plane switch - this is the emulated router dataplane # Note: The controller needs to be configured with the specific driver that # will be attached to this switch. # IXP fabric main_switch = self.addSwitch( 's1' ) # Add node for central Route Server" route_server = self.addHost('x1', ip = '172.0.255.254/16', mac='08:00:27:89:3b:ff', inNamespace = False) self.addLink(main_switch, route_server, 1) # Add node for ARP Proxy" arp_proxy = self.addHost('x2', ip = '172.0.255.253/16', mac='08:00:27:89:33:ff', inNamespace = False) self.addLink(main_switch, arp_proxy, 2) # Add Participants to the IXP # Each participant consists of 1 quagga router PLUS # 1 host per network advertised behind quagga self.addParticipant(fabric=main_switch, name = 'a1', port = 3, mac = '08:00:27:89:3b:9f', ip = '172.0.0.01/16', networks = ['100.0.0.0/24', '110.0.0.0/24'], AS = 100) self.addParticipant(fabric=main_switch, name = 'b1', port = 4, mac = '08:00:27:92:18:1f', ip = '172.0.0.11/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 200) self.addParticipant(fabric=main_switch, name = 'c1', port = 5, mac='08:00:27:54:56:ea', ip = '172.0.0.21/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 300) self.addParticipant(fabric=main_switch, name = 'c2', port = 6, mac = '08:00:27:bd:f8:b2', ip = '172.0.0.22/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 300)
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches host1 = self.addHost( 'h1' ) host2 = self.addHost( 'h2' ) host3 = self.addHost( 'h3' ) host4 = self.addHost( 'h4' ) host5 = self.addHost( 'h5' ) host6 = self.addHost( 'h6' ) switch1 = self.addSwitch( 's1' ) switch2 = self.addSwitch( 's2' ) switch3 = self.addSwitch( 's3' ) # Add links self.addLink( host1, switch1, bw=100, delay='5ms' ) self.addLink( host2, switch1, bw=100, delay='5ms' ) self.addLink( host3, switch1, bw=100, delay='5ms' ) self.addLink( host4, switch1, bw=5, delay='10ms' ) self.addLink( host5, switch1, bw=5, delay='10ms' ) self.addLink( host6, switch1, bw=5, delay='10ms' ) self.addLink( switch1, switch2, delay='40ms' ) self.addLink( switch2, switch3, delay='40ms' )
def __init__( self): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches host1 = self.addHost( 'h1', ip="10.0.1.2", defaultRoute = "via 10.0.1.1/24" ) host2 = self.addHost( 'h2', ip="10.0.1.3", defaultRoute = "via 10.0.1.1/24" ) host3 = self.addHost( 'h3', ip="10.0.2.2", defaultRoute = "via 10.0.2.1/24" ) host4 = self.addHost( 'h4', ip="10.0.2.3", defaultRoute = "via 10.0.2.1/24" ) host5 = self.addHost( 'h5', ip="10.0.2.4", defaultRoute = "via 10.0.2.1/24" ) switch1 = self.addSwitch( 's1') switch2 = self.addSwitch( 's2') # Add links self.addLink( host1, switch1 ) self.addLink( host2, switch1 ) self.addLink( host3, switch2 ) self.addLink( host4, switch2 ) self.addLink( host5, switch2 ) self.addLink( switch1, switch2 )
def __init__(self): # Initialize topology Topo.__init__(self) # Create template host, switch, and link hconfig = {'inNamespace': True} link_config = {'bw': 100} host_link_config = {} # Create switch nodes self.addSwitch('s1') self.addSwitch('s2') # Create host nodes self.addHost('h1', **hconfig) self.addHost('h2', **hconfig) self.addHost('h3', **hconfig) # Add switch links self.addLink('s1', 's2', **link_config) # Add host links self.addLink('h1', 's1', **link_config) self.addLink('h2', 's1', **link_config) self.addLink('h3', 's2', **link_config)
def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches leftHost = self.addHost( 'h1' ) leftHost1 = self.addHost( 'h2' ) centerHost = self.addHost( 'h3' ) centerHost1 = self.addHost( 'h4' ) rightHost = self.addHost( 'h5' ) rightHost1 = self.addHost( 'h6' ) leftSwitch = self.addSwitch( 's1' ) centerSwitch = self.addSwitch( 's2' ) rightSwitch = self.addSwitch( 's3' ) # Add links self.addLink( leftHost, leftSwitch ) self.addLink( leftHost1, leftSwitch ) self.addLink( centerHost, centerSwitch) self.addLink( centerHost1, centerSwitch) self.addLink( rightHost, rightSwitch) self.addLink( rightHost1, rightSwitch) self.addLink( leftSwitch, centerSwitch ) self.addLink( rightSwitch, centerSwitch )
def __init__(self,**opts): Topo.__init__(self, **opts) host1 = self.addHost('h1') host2 = self.addHost('h2') host3 = self.addHost('h3') host4 = self.addHost('h4') host5 = self.addHost('h5') host6 = self.addHost('h6') host7 = self.addHost('h7') host8 = self.addHost('h8') host9 = self.addHost('h9') host10 = self.addHost('h10') self.switch = {} for s in range(1,6): self.switch[s-1] = self.addSwitch('s%s' %(s)) self.addLink(self.switch[0], self.switch[1]) self.addLink(self.switch[0], self.switch[2]) self.addLink(self.switch[0], self.switch[3]) self.addLink(self.switch[4], self.switch[1]) self.addLink(self.switch[4], self.switch[2]) self.addLink(self.switch[4], self.switch[3]) #Adding host self.addLink(self.switch[0], host1) self.addLink(self.switch[4], host2) self.addLink(self.switch[4], host3) self.addLink(self.switch[4], host4) self.addLink(self.switch[4], host5) self.addLink(self.switch[4], host6) self.addLink(self.switch[4], host7) self.addLink(self.switch[4], host8) self.addLink(self.switch[4], host9) self.addLink(self.switch[4], host10)
def __init__(self): Topo.__init__(self) self.net=None
def __init__(self, low=16, high=17, k=3, p=0.3, r=8, sigma=0.25, t=1024, threshold=128, alpha_values=np.arange(0.1, 1.1, 0.1)): "Create random topology." # Initialize topology Topo.__init__(self) self.low = low self.high = high self.k = k # Not used for now self.p = p self.r = r # Not used for now self.sigma = sigma # Not used for now self.T = t # Not used for now self.threshold = threshold # Not used for now self.alpha_values = alpha_values # Not used for now # Generate a random network self.num_switches = np.random.randint(self.low, self.high) self.num_hosts = np.random.poisson(self.num_switches) self.num_nodes = self.num_switches + self.num_hosts self.G = nx.connected_watts_strogatz_graph(self.num_switches, self.k, self.p) # Append hosts host_switches = np.random.choice(self.num_switches, self.num_hosts) for i in range(self.num_hosts): host = self.num_switches + i self.G.add_node(host) self.G.add_edge(host_switches[i], host) #nx.draw(self.G) #plt.show() # Add switches self.switch_list = [] for i in range(1, self.num_switches + 1): self.switch_list.append(self.addSwitch('s' + str(i))) # Add hosts self.host_list = [] for i in range(self.num_switches + 1, self.num_nodes + 1): self.host_list.append(self.addHost('h' + str(i))) for edge in self.G.edges(): if edge[0] < self.num_switches and edge[1] < self.num_switches: self.addLink(self.switch_list[edge[0]], self.switch_list[edge[1]]) elif edge[0] >= self.num_switches and edge[1] < self.num_switches: self.addLink(self.host_list[edge[0] - self.num_switches], self.switch_list[edge[1]]) elif edge[0] < self.num_switches and edge[1] >= self.num_switches: self.addLink(self.switch_list[edge[0]], self.host_list[edge[1] - self.num_switches])
def __init__(self): Topo.__init__(self) switch = self.addSwitch('s1') for h in range(3): host = self.addHost('h%s' % (h + 1)) self.addLink(host, switch)
def __init__(self, dhcp=False, routers=False, ipv4=False, ipv6=False, **opts): Topo.__init__(self, **opts) linkopts = dict( bw=10 ) spine = 4 leaf = 6 # Create spine switches for s in range(spine): self.spines[s] = self.addSwitch('spine10%s' % (s + 1), dpid = "00000000010%s" % (s + 1) ) # Create leaf switches for ls in range(leaf): self.leafs[ls] = self.addSwitch('leaf%s' % (ls + 1), dpid = "00000000000%s" % ( ls + 1) ) # connecting leaf and spines, leafs 1-5 have double links for s in range(2): spine_switch = self.spines[s] for ls in range(1, 5): leaf_switch = self.leafs[ls] self.addLink( spine_switch, leaf_switch, **linkopts ) self.addLink( spine_switch, leaf_switch, **linkopts ) # connect paired leafs self.addLink(self.leafs[1], self.leafs[2], **linkopts) self.addLink(self.leafs[3], self.leafs[4], **linkopts) # build second fabric with single links for s in range(2, 4): spine_switch = self.spines[s] for ls in [0, 5]: leaf_switch = self.leafs[ls] self.addLink( spine_switch, leaf_switch, **linkopts ) # connect spines together self.addLink(self.spines[2], self.spines[0], **linkopts) self.addLink(self.spines[3], self.spines[1], **linkopts) # create hosts if ipv6: self.createIpv6Hosts(dhcp) if ipv4: self.createIpv4Hosts(dhcp) if not ipv4 and not ipv6: print("No hosts were created!") # create quagga routers # Note: Change "fpm connection ip" to $OC1 in zebradbgp1.conf and zebradbgp2.conf to make quagga work correctly if routers: last_ls = self.leafs[4] last_paired_ls = self.leafs[3] # Control plane switch (for quagga fpm) cs0 = self.addSwitch('cs0', cls=OVSBridge) # Control plane NAT (for quagga fpm) nat = self.addHost('nat', cls=NAT, ip='172.16.0.1/12', subnet=str(ip_network(u'172.16.0.0/12')), inNamespace=False) self.addLink(cs0, nat) # Internal Quagga bgp1 intfs = {'bgp1-eth0': [{'ipAddrs': ['10.0.1.2/24', '2000::102/120'], 'mac': '00:88:00:00:00:03', 'vlan': '110'}, {'ipAddrs': ['10.0.7.2/24', '2000::702/120'], 'mac': '00:88:00:00:00:03', 'vlan': '170'}], 'bgp1-eth1': {'ipAddrs': ['172.16.0.3/12']}} bgp1 = self.addHost('bgp1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdbgp1.conf', zebraConfFile='./zebradbgp1.conf') self.addLink(bgp1, last_paired_ls) self.addLink(bgp1, cs0) # Internal Quagga bgp2 intfs = {'bgp2-eth0': [{'ipAddrs': ['10.0.5.2/24', '2000::502/120'], 'mac': '00:88:00:00:00:04', 'vlan': '150'}, {'ipAddrs': ['10.0.6.2/24', '2000::602/120'], 'mac': '00:88:00:00:00:04', 'vlan': '160'}], 'bgp2-eth1': {'ipAddrs': ['172.16.0.4/12']}} bgp2 = self.addHost('bgp2', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdbgp2.conf', zebraConfFile='./zebradbgp2.conf') self.addLink(bgp2, last_ls) self.addLink(bgp2, cs0) # External Quagga r1 intfs = {'r1-eth0': {'ipAddrs': ['10.0.1.1/24', '2000::101/120'], 'mac': '00:88:00:00:00:01'}, 'r1-eth1': {'ipAddrs': ['10.0.5.1/24', '2000::501/120'], 'mac': '00:88:00:00:00:11'}, 'r1-eth2': {'ipAddrs': ['10.0.99.1/16']}, 'r1-eth3': {'ipAddrs': ['2000::9901/120']}, 'r1-eth4': {'ipAddrs': ['2000::7701/120']}, 'r1-eth5': {'ipAddrs': ['10.0.88.1/24']}, 'r1-eth6': {'ipAddrs': ['2000::8701/120']}} r1 = self.addHost('r1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdr1.conf') self.addLink(r1, last_paired_ls) self.addLink(r1, last_ls) # External IPv4 Host behind r1 rh1v4 = self.addHost('rh1v4', cls=RoutedHost, ips=['10.0.99.2/24'], gateway='10.0.99.1') self.addLink(r1, rh1v4) # External IPv6 Host behind r1 rh1v6 = self.addHost('rh1v6', cls=RoutedHost, ips=['2000::9902/120'], gateway='2000::9901') self.addLink(r1, rh1v6) # Another external IPv6 Host behind r1 rh11v6 = self.addHost('rh11v6', cls=RoutedHost, ips=['2000::7702/120'], gateway='2000::7701') self.addLink(r1, rh11v6) # Add an external ipv4 hosts that is not configured in the bgp conf # files rh5v4 = self.addHost('rh5v4', cls=RoutedHost, ips=['10.0.88.2/24'], gateway='10.0.88.1') self.addLink(r1, rh5v4) # Add an external ipv6 hosts that is not configured in the bgp conf # files rh5v6 = self.addHost('rh5v6', cls=RoutedHost, ips=['2000::8702/120'], gateway='2000::8701') self.addLink(r1, rh5v6) # External Quagga r2 intfs = {'r2-eth0': {'ipAddrs': ['10.0.6.1/24', '2000::601/120'], 'mac': '00:88:00:00:00:02'}, 'r2-eth1': {'ipAddrs': ['10.0.7.1/24', '2000::701/120'], 'mac': '00:88:00:00:00:22'}, 'r2-eth2': {'ipAddrs': ['10.0.99.1/16']}, 'r2-eth3': {'ipAddrs': ['2000::9901/120']}, 'r2-eth4': {'ipAddrs': ['2000::8801/120']}} r2 = self.addHost('r2', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdr2.conf') self.addLink(r2, last_ls) self.addLink(r2, last_paired_ls) # External IPv4 Host behind r2 rh2v4 = self.addHost('rh2v4', cls=RoutedHost, ips=['10.0.99.2/24'], gateway='10.0.99.1') self.addLink(r2, rh2v4) # External IPv6 Host behind r2 rh2v6 = self.addHost('rh2v6', cls=RoutedHost, ips=['2000::9902/120'], gateway='2000::9901') self.addLink(r2, rh2v6) # Another external IPv6 Host behind r1 rh22v6 = self.addHost('rh22v6', cls=RoutedHost, ips=['2000::8802/120'], gateway='2000::8801') self.addLink(r2, rh22v6) # create dhcp servers if dhcp: cs1 = self.addSwitch('cs1', cls=OVSBridge) self.addLink(cs1, self.leafs[4]) if ipv4: dhcp4 = self.addHost( 'dhcp', cls=TrellisHost, mac="00:cc:00:00:00:01", ips=["10.0.3.253/24"], gateway="10.0.3.254", dhcpServer=True) self.addLink(dhcp4, cs1, **linkopts) if ipv6: dhcp6 = self.addHost( 'dhcp6', cls=TrellisHost, mac="00:dd:00:00:00:01", ips=["2000::3fd/120"], gateway="2000::3ff", dhcpServer=True, ipv6=True) self.addLink(dhcp6, cs1, **linkopts)
def __init__(self): Topo.__init__(self) #deklaracja 4 hostów host1 = self.addHost('h1') #source of traffic 1 host2 = self.addHost('h2') #source of traffic 2 host3 = self.addHost('h3') #DHCP Server host3 = self.addHost('h3', ip='10.0.0.50', inNamespace=False) #DHCP Server host4 = self.addHost('h4') #DHCP Client host5 = self.addHost('h5') #attacker host5 = self.addHost('h5', ip='10.0.0.51', inNamespace=False) #attacker #pierwszy switch switch1 = self.addSwitch('s1') self.addLink(host1, switch1) self.addLink(host2, switch1) #ostatni switch switch4 = self.addSwitch('s4') self.addLink(host3, switch4) self.addLink(host4, switch4) self.addLink(host5, switch4) #pierwsza warstwa switchy switch11 = self.addSwitch('s11') switch12 = self.addSwitch('s12') switch13 = self.addSwitch('s13') switch14 = self.addSwitch('s14') #polaczenie pierwszej warstwy ze switchem1 self.addLink(switch1, switch11) self.addLink(switch1, switch12) self.addLink(switch1, switch13) self.addLink(switch1, switch14) #druga warstwa switch switch22 = self.addSwitch('s22') switch23 = self.addSwitch('s23') switch24 = self.addSwitch('s24') #trzecia warstwa switchy switch33 = self.addSwitch('s33') switch34 = self.addSwitch('s34') #czwarta warstwa switchy switch44 = self.addSwitch('s44') #laczenie warst self.addLink(switch12, switch22) self.addLink(switch13, switch23) self.addLink(switch14, switch24) self.addLink(switch23, switch33) self.addLink(switch24, switch34) self.addLink(switch34, switch44) #podlaczenie switcha4 ze switchami self.addLink(switch4, switch11) self.addLink(switch4, switch22) self.addLink(switch4, switch33) self.addLink(switch4, switch44)
def __init__(self, **opts): # Initialize topology and default options Topo.__init__(self, **opts) s10 = self.addSwitch('s10', dpid=formula.s10_id, protocols='OpenFlow13') s11 = self.addSwitch('s11', dpid=formula.s11_id, protocols='OpenFlow13') s12 = self.addSwitch('s12', dpid=formula.s12_id, protocols='OpenFlow13') s13 = self.addSwitch('s13', dpid=formula.s13_id, protocols='OpenFlow13') s14 = self.addSwitch('s14', dpid=formula.s14_id, protocols='OpenFlow13') s15 = self.addSwitch('s15', dpid=formula.s15_id, protocols='OpenFlow13') s16 = self.addSwitch('s16', dpid=formula.s16_id, protocols='OpenFlow13') h1 = self.addHost('h1', ip='10.0.0.1', mac='000000000001') h2 = self.addHost('h2', ip='10.0.0.2', mac='000000000002') h3 = self.addHost('h3', ip='10.0.0.3', mac='000000000003') h4 = self.addHost('h4', ip='10.0.0.4', mac='000000000004') self.addLink(s10, h1) self.addLink(s12, h2) self.addLink(s11, h3) self.addLink(s16, h4) self.addLink(s10, s13, bw=formula.band_sa_sd, delay=str(formula.lat_sa_sd) + "ms") # sa/2-sd/1 self.addLink(s10, s13, loss=formula.p_loss(formula.d4), bw=formula.band_sa_sd2, delay=str(formula.lat_sa_sd2) + "ms") # sa/3-sd/2 self.addLink(s11, s14, bw=formula.band_sb_se, delay=str(formula.lat_sb_se) + "ms") # sb/2-se/1 self.addLink(s11, s14, bw=formula.band_sb_se2, delay=str(formula.lat_sb_se2) + "ms") # sb/3-se/2 self.addLink(s11, s14, loss=formula.p_loss(formula.d1), bw=formula.band_sb_se3, delay=str(formula.lat_sb_se3) + "ms") # sb/4-se/3 self.addLink(s12, s15, bw=formula.band_sc_sf, delay=str(formula.lat_sc_sf) + "ms") # sc/2-sf/1 self.addLink(s12, s15, bw=formula.band_sc_sf2, delay=str(formula.lat_sc_sf2) + "ms") # sc/3-sf/3 self.addLink(s13, s14, loss=formula.p_loss(formula.d3), bw=formula.band_sd_se, delay=str(formula.lat_sd_se) + "ms") # sd/3-se/4 self.addLink(s14, s15, bw=formula.band_se_sf, delay=str(formula.lat_se_sf) + "ms") # se/5-sf/3 self.addLink(s13, s15, loss=formula.p_loss(formula.d2), bw=formula.band_sd_sf, delay=str(formula.lat_sd_sf) + "ms") # sd/4-sf/4 self.addLink(s10, s16, loss=formula.p_loss(formula.d5), bw=formula.band_sa_sg, delay=str(formula.lat_sa_sg) + "ms") # sa/4-sg/2 self.addLink(s12, s16, bw=formula.band_sc_sg, delay=str(formula.lat_sc_sg) + "ms") # sc/4-sg/3 self.addLink(s13, s16, bw=formula.band_sd_sg, delay=str(formula.lat_sd_sg) + "ms") # sd/5-sg/4
def __init__( self, **opts ): "Create a topology." # Initialize Topology Topo.__init__( self, **opts ) # add nodes # switches first NewYork = self.addSwitch( 's1' , cls=OVSKernelSwitch, dpid='0000000000000001') Chicago = self.addSwitch( 's2' , cls=OVSKernelSwitch, dpid='0000000000000002') WashingtonDC = self.addSwitch( 's3' , cls=OVSKernelSwitch, dpid='0000000000000003') Seattle = self.addSwitch( 's4' , cls=OVSKernelSwitch, dpid='0000000000000004') Sunnyvale = self.addSwitch( 's5' , cls=OVSKernelSwitch, dpid='0000000000000005') LosAngeles = self.addSwitch( 's6' , cls=OVSKernelSwitch, dpid='0000000000000006') Denver = self.addSwitch( 's7' , cls=OVSKernelSwitch, dpid='0000000000000007') KansasCity = self.addSwitch( 's8' , cls=OVSKernelSwitch, dpid='0000000000000008') Houston = self.addSwitch( 's9' , cls=OVSKernelSwitch, dpid='0000000000000009') Atlanta = self.addSwitch( 's10' , cls=OVSKernelSwitch, dpid='0000000000000010') Indianapolis = self.addSwitch( 's11' , cls=OVSKernelSwitch, dpid='0000000000000011') # and now hosts NewYork_host = self.addHost( 'h0' ) Chicago_host = self.addHost( 'h1' ) WashingtonDC_host = self.addHost( 'h2' ) Seattle_host = self.addHost( 'h3' ) Sunnyvale_host = self.addHost( 'h4' ) LosAngeles_host = self.addHost( 'h5' ) Denver_host = self.addHost( 'h6' ) KansasCity_host = self.addHost( 'h7' ) Houston_host = self.addHost( 'h8' ) Atlanta_host = self.addHost( 'h9' ) Indianapolis_host = self.addHost( 'h10' ) # hosts (put here if needed) # dont forget to add edges afterwards! #FIXME host and links section needs adjusting to your topology needs!!! # this are just exemplarical entries, # fitting my topology and needs. # I left this here as an sample entry. #FIXME this was needed before a host per switch was generated and linked #node1 = self.addHost( 'h1' ) #node2 = self.addHost( 'h2' ) # next tree lines never put to use so far #node3 = self.addHost( 'rcv1' ) #node4 = self.addHost( 'rcv2' ) #node5 = self.addHost( 'logserv' ) #self.addLink( HAM , node1 ) #self.addLink( GAR , node2 ) # add edges between switch and corresponding host self.addLink( NewYork , NewYork_host ) self.addLink( Chicago , Chicago_host ) self.addLink( WashingtonDC , WashingtonDC_host ) self.addLink( Seattle , Seattle_host ) self.addLink( Sunnyvale , Sunnyvale_host ) self.addLink( LosAngeles , LosAngeles_host ) self.addLink( Denver , Denver_host ) self.addLink( KansasCity , KansasCity_host ) self.addLink( Houston , Houston_host ) self.addLink( Atlanta , Atlanta_host ) self.addLink( Indianapolis , Indianapolis_host ) # add edges between switches self.addLink( NewYork , Chicago, bw=10, delay='0.690677696537ms') self.addLink( NewYork , WashingtonDC, bw=10, delay='0.518903303662ms') self.addLink( Chicago , Indianapolis, bw=10, delay='1.15170240387ms') self.addLink( WashingtonDC , Atlanta, bw=10, delay='0.477628158502ms') self.addLink( Seattle , Sunnyvale, bw=10, delay='1.10351797289ms') self.addLink( Seattle , Denver, bw=10, delay='0.952189623151ms') self.addLink( Sunnyvale , LosAngeles, bw=10, delay='0.506044716762ms') self.addLink( Sunnyvale , Denver, bw=10, delay='0.85423284091ms') self.addLink( LosAngeles , Houston, bw=10, delay='1.02920365882ms') self.addLink( Denver , KansasCity, bw=10, delay='0.191285963954ms') self.addLink( KansasCity , Houston, bw=10, delay='1.46743666378ms') self.addLink( KansasCity , Indianapolis, bw=10, delay='0.206336052247ms') self.addLink( Houston , Atlanta, bw=10, delay='1.15068985002ms') self.addLink( Atlanta , Indianapolis, bw=10, delay='0.466772343871ms')
def __init__(self): "Create custom topo." # Initialize topology Topo.__init__(self) # Add hosts and switches host1 = self.addHost('h1') host2 = self.addHost('h2') host3 = self.addHost('h3') host4 = self.addHost('h4') host5 = self.addHost('h5') host6 = self.addHost('h6') host7 = self.addHost('h7') host8 = self.addHost('h8') host9 = self.addHost('h9') host10 = self.addHost('h10') host11 = self.addHost('h11') host12 = self.addHost('h12') host13 = self.addHost('h13') host14 = self.addHost('h14') host15 = self.addHost('h15') host16 = self.addHost('h16') switch1 = self.addSwitch('s1') switch2 = self.addSwitch('s2') switch3 = self.addSwitch('s3') switch4 = self.addSwitch('s4') switch5 = self.addSwitch('s5') switch6 = self.addSwitch('s6') switch7 = self.addSwitch('s7') switch8 = self.addSwitch('s8') switch9 = self.addSwitch('s9') switch10 = self.addSwitch('s10') switch11 = self.addSwitch('s11') switch12 = self.addSwitch('s12') switch13 = self.addSwitch('s13') switch14 = self.addSwitch('s14') switch15 = self.addSwitch('s15') switch16 = self.addSwitch('s16') switch17 = self.addSwitch('s17') switch18 = self.addSwitch('s18') switch19 = self.addSwitch('s19') switch20 = self.addSwitch('s20') # Add links # Links for Core switch self.addLink(switch1, switch5) self.addLink(switch1, switch7) self.addLink(switch1, switch9) self.addLink(switch1, switch11) self.addLink(switch2, switch5) self.addLink(switch2, switch7) self.addLink(switch2, switch9) self.addLink(switch2, switch11) self.addLink(switch3, switch6) self.addLink(switch3, switch8) self.addLink(switch3, switch10) self.addLink(switch3, switch12) self.addLink(switch4, switch6) self.addLink(switch4, switch8) self.addLink(switch4, switch10) self.addLink(switch4, switch12) #Links for pods #1 self.addLink(switch5, switch13) self.addLink(switch5, switch14) self.addLink(switch6, switch13) self.addLink(switch6, switch14) #2 self.addLink(switch7, switch15) self.addLink(switch7, switch16) self.addLink(switch8, switch15) self.addLink(switch8, switch16) #3 self.addLink(switch9, switch17) self.addLink(switch9, switch18) self.addLink(switch10, switch17) self.addLink(switch10, switch18) #4 self.addLink(switch11, switch19) self.addLink(switch11, switch20) self.addLink(switch12, switch19) self.addLink(switch12, switch20) #Hosts #pair1 self.addLink(switch13, host1) self.addLink(switch13, host2) self.addLink(switch14, host3) self.addLink(switch14, host4) #pair2 self.addLink(switch15, host5) self.addLink(switch15, host6) self.addLink(switch16, host7) self.addLink(switch16, host8) #pair 3 self.addLink(switch17, host9) self.addLink(switch17, host10) self.addLink(switch18, host11) self.addLink(switch18, host12) #pair 4 self.addLink(switch19, host13) self.addLink(switch19, host14) self.addLink(switch20, host15) self.addLink(switch20, host16)
def __init__(self): Topo.__init__(self) #log.write('Start to add host:\n\n') #add hosts h1 = self.addHost('h1', ip='100.0.0.10/24', mac='00:00:00:00:00:01', defaultRoute='via 100.0.0.1') h2 = self.addHost('h2', ip='100.0.0.11/24', mac='00:00:00:00:00:02', defaultRoute='via 100.0.0.1') h3 = self.addHost('h3', ip='10.0.0.50/24', mac='00:00:00:00:00:03', defaultRoute='via 10.0.0.1') h4 = self.addHost('h4', ip='10.0.0.51/24', mac='00:00:00:00:00:04', defaultRoute='via 10.0.0.1') #add switch sw1 = self.addSwitch('s1') sw2 = self.addSwitch('s2') sw3 = self.addSwitch('s3') sw4 = self.addSwitch('s4') sw5 = self.addSwitch('s5') #add firewalls fw1 = self.addSwitch('s6') fw2 = self.addSwitch('s7') lb1 = self.addSwitch('s8') lb2 = self.addSwitch('s9') ids = self.addSwitch('s10') napt = self.addSwitch('s11') #add dns server ds1 = self.addHost('ds1', ip='100.0.0.20/24', defaultRoute='via 100.0.0.1') ds2 = self.addHost('ds2', ip='100.0.0.21/24', defaultRoute='via 100.0.0.1') ds3 = self.addHost('ds3', ip='100.0.0.22/24', defaultRoute='via 100.0.0.1') #add web servers ws1 = self.addHost('ws1', ip='100.0.0.40/24', mac='00:00:00:00:00:40', defaultRoute='via 100.0.0.1') ws2 = self.addHost('ws2', ip='100.0.0.41/24', mac='00:00:00:00:00:41', defaultRoute='via 100.0.0.1') ws3 = self.addHost('ws3', ip='100.0.0.42/24', mac='00:00:00:00:00:42', defaultRoute='via 100.0.0.1') #add insp insp = self.addHost('insp', mac='00:00:00:00:00:88') #add links for h in h1, h2, fw1: self.addLink(h, sw1) for h in ds1, ds2, ds3, lb1: self.addLink(h, sw3) for h in fw1, lb1, ids, fw2: self.addLink(h, sw2) for h in napt, h3, h4: self.addLink(h, sw5) self.addLink(fw2, napt) for h in ws1, ws2, ws3, lb2: self.addLink(h, sw4) for h in lb2, insp: self.addLink(h, ids)
def __init__(self, _pubNum=None, _subNum=None): "Create custom topo." # Initialize topology Topo.__init__(self) self.pubNum = _pubNum self.subNum = _subNum hostList = list() localSwitchList = list() busSwitchList = list() # track the name of host and switch. hostNum = _pubNum + _subNum # a broker at the center # Add publishers index = 1 for num in range(0, _pubNum): pubName = "pub" + str(index) hostList.append(self.addHost(pubName)) index += 1 # Add subscribers index = 1 for num in range(0, _subNum): subName = "sub" + str(index) hostList.append(self.addHost(subName)) index += 1 # Add local switches for publishers index = 1 for num in range(0, _pubNum): sName = "ps" + str(index) localSwitchList.append(self.addSwitch(sName)) index += 1 # Add local switches for subscribers index = 1 for num in range(0, _subNum): sName = "ss" + str(index) localSwitchList.append(self.addSwitch(sName)) index += 1 # Add bus switches index = 1 numBusSwitch = (hostNum - 1) // 2 + 1 for num in range(numBusSwitch): sName = "bus" + str(index) busSwitchList.append(self.addSwitch(sName)) index += 1 # Build Local Links for num in range(hostNum): self.addLink(hostList[num], localSwitchList[num]) # Link the bus switches together for num in range(0, numBusSwitch - 1): self.addLink(busSwitchList[num], busSwitchList[num + 1]) # Build Links between local switches and bus switches for num in range(hostNum): self.addLink(localSwitchList[num], busSwitchList[num // 2])
def __init__(self): "Create custom topo." # Initialize topology Topo.__init__(self) # Add hosts and switches p = self.addHost('p') c = self.addHost('c') t11 = self.addHost('t11') t12 = self.addHost('t12') t13 = self.addHost('t13') t21 = self.addHost('t21') t22 = self.addHost('t22') t23 = self.addHost('t23') t31 = self.addHost('t31') t32 = self.addHost('t32') t33 = self.addHost('t33') s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s11 = self.addSwitch('s11') s12 = self.addSwitch('s12') #link opts #10 Mbps local_linkopts = dict(bw=10, delay='5ms', loss=0, max_queue_size=1000, use_htb=True) wide_linkopts = dict(bw=10, delay='50ms', loss=0, max_queue_size=1000, use_htb=True) dsa_linkopts = dict(bw=1000, delay='1ms', loss=0, max_queue_size=10000, use_htb=True) # Add links self.addLink(p, s11, **wide_linkopts) self.addLink(s11, s1, **local_linkopts) self.addLink(s1, s2, **local_linkopts) self.addLink(s1, s3, **local_linkopts) self.addLink(s3, s2, **local_linkopts) self.addLink(s2, s12, **local_linkopts) self.addLink(s12, c, **wide_linkopts) #for DSA 1 self.addLink(s1, t11, **dsa_linkopts) self.addLink(s1, t12, **dsa_linkopts) self.addLink(s1, t13, **dsa_linkopts) #for DSA 2 self.addLink(s2, t21, **dsa_linkopts) self.addLink(s2, t22, **dsa_linkopts) self.addLink(s2, t23, **dsa_linkopts) #for DSA 2 self.addLink(s3, t31, **dsa_linkopts) self.addLink(s3, t32, **dsa_linkopts) self.addLink(s3, t33, **dsa_linkopts)
def __init__(self): Topo.__init__(self) #define the switches s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') s7 = self.addSwitch('s7') s8 = self.addSwitch('s8') s9 = self.addSwitch('s9') s10 = self.addSwitch('s10') bbra = self.addSwitch('s11') bbrb = self.addSwitch('s12') oz1a = self.addSwitch('s13') oz1b = self.addSwitch('s14') oz2a = self.addSwitch('s15') oz2b = self.addSwitch('s16') oz3a = self.addSwitch('s17') oz3b = self.addSwitch('s18') oz4a = self.addSwitch('s19') oz4b = self.addSwitch('s20') oz5a = self.addSwitch('s21') oz5b = self.addSwitch('s22') oz6a = self.addSwitch('s23') oz6b = self.addSwitch('s24') oz7a = self.addSwitch('s25') oz7b = self.addSwitch('s26') #add link #bbra self.addLink(bbra, s1, bw=10) self.addLink(bbra, s2, bw=10) self.addLink(bbra, s3, bw=10) self.addLink(bbra, s4, bw=10) self.addLink(bbra, s5, bw=10) self.addLink(bbra, bbrb, bw=10) self.addLink(bbra, oz4a, bw=10) #bbrb self.addLink(bbrb, s6, bw=10) self.addLink(bbrb, s7, bw=10) self.addLink(bbrb, s8, bw=10) self.addLink(bbrb, s9, bw=10) self.addLink(bbrb, s10, bw=10) self.addLink(bbrb, oz4a, bw=10) #s1 self.addLink(s1, oz1b, bw=10) self.addLink(s1, oz5b, bw=10) #s2 self.addLink(s2, oz3a, bw=10) self.addLink(s2, oz4b, bw=10) self.addLink(s2, oz6a, bw=10) #s3 self.addLink(s3, oz3b, bw=10) self.addLink(s3, oz6b, bw=10) #s4 self.addLink(s4, oz1a, bw=10) self.addLink(s4, oz2a, bw=10) self.addLink(s4, oz5a, bw=10) self.addLink(s4, oz7a, bw=10) #s5 self.addLink(s5, oz2b, bw=10) self.addLink(s5, oz7b, bw=10) #s6 self.addLink(s6, oz1b, bw=10) self.addLink(s6, oz5b, bw=10) #s7 self.addLink(s7, oz3a, bw=10) self.addLink(s7, oz6a, bw=10) #s8 self.addLink(s8, oz3b, bw=10) self.addLink(s8, oz6b, bw=10) #s9 self.addLink(s9, oz1a, bw=10) self.addLink(s9, oz2a, bw=10) self.addLink(s9, oz7a, bw=10) #s10 self.addLink(s10, oz2b, bw=10) self.addLink(s10, oz7b, bw=10) #bottom self.addLink(oz1a, oz1b, bw=10) self.addLink(oz2a, oz2b, bw=10) self.addLink(oz3a, oz3b, bw=10) self.addLink(oz4a, oz4b, bw=10) self.addLink(oz5a, oz5b, bw=10) self.addLink(oz6a, oz6b, bw=10) self.addLink(oz7a, oz7b, bw=10) #host h1 = self.addHost('h1', ip='100.0.0.1/24') h2 = self.addHost('h2', ip='100.0.0.2/24') h3 = self.addHost('h3', ip='100.0.0.3/24') h4 = self.addHost('h4', ip='100.0.0.4/24') self.addLink(h1, oz2a, bw=10) self.addLink(h2, oz3a, bw=10) self.addLink(h3, oz6a, bw=10) self.addLink(h4, oz7a, bw=10)
def __init__(self, spine=2, leaf=2, fanout=2, vlan_id=[], ipv6=False, dhcp_client=False, dhcp_relay=False, multiple_server=False, remote_server=False, **opts): Topo.__init__(self, **opts) spines = dict() leafs = dict() # TODO: support IPv6 hosts linkopts = dict(bw=100) # Create spine switches for s in range(spine): spines[s] = self.addSwitch('spine10%s' % (s + 1), dpid="00000000010%s" % (s + 1), **SWITCH_PARAMS) # Create leaf switches for ls in range(leaf): leafs[ls] = self.addSwitch('leaf%s' % (ls + 1), dpid="00000000000%s" % (ls + 1), **SWITCH_PARAMS) # Connect leaf to all spines for s in range(spine): switch = spines[s] self.addLink(leafs[ls], switch, **linkopts) # If dual-homed ToR, add hosts only when adding second switch at each edge-pair # When the number of leaf switches is odd, leave the last switch as a single ToR # Add hosts for f in range(fanout): name = 'h%s%s' % (ls * fanout + f + 1, "v6" if ipv6 else "") if ipv6: ips = [ '2000::%d0%d/%d' % (ls + 2, f + 1, IP6_SUBNET_CLASS) ] gateway = '2000::%dff' % (ls + 2) mac = '00:bb:00:00:00:%02x' % (ls * fanout + f + 1) else: ips = ['10.0.%d.%d/%d' % (ls + 2, f + 1, IP4_SUBNET_CLASS)] gateway = '10.0.%d.254' % (ls + 2) mac = '00:aa:00:00:00:%02x' % (ls * fanout + f + 1) host = self.addHost( name=name, cls=TrellisHost, ips=ips, gateway=gateway, mac=mac, vlan=vlan_id[ls * fanout + f] if vlan_id[ls * fanout + f] != 0 else None, dhcpClient=dhcp_client, ipv6=ipv6) if dhcp_relay and f % 2: relayIndex = ls * fanout + f + 1 if ipv6: intfs = { 'relay%s-eth0' % relayIndex: { 'ipAddrs': [ '2000::%dff/%d' % (leaf + ls + 2, IP6_SUBNET_CLASS) ] }, 'relay%s-eth1' % relayIndex: { 'ipAddrs': [ '2000::%d5%d/%d' % (ls + 2, f, IP6_SUBNET_CLASS) ] } } if remote_server: serverIp = '2000::99fd' elif multiple_server: serverIp = '2000::3fc' else: serverIp = '2000::3fd' dhcpRelay = self.addHost(name='relay%s' % relayIndex, cls=DhcpRelay, serverIp=serverIp, gateway='2000::%dff' % (ls + 2), interfaces=intfs) else: intfs = { 'relay%s-eth0' % relayIndex: { 'ipAddrs': [ '10.0.%d.254/%d' % (leaf + ls + 2, IP4_SUBNET_CLASS) ] }, 'relay%s-eth1' % relayIndex: { 'ipAddrs': [ '10.0.%d.%d/%d' % (ls + 2, f + 99, IP4_SUBNET_CLASS) ] } } if remote_server: serverIp = '10.0.99.3' elif multiple_server: serverIp = '10.0.3.252' else: serverIp = '10.0.3.253' dhcpRelay = self.addHost(name='relay%s' % relayIndex, cls=DhcpRelay, serverIp=serverIp, gateway='10.0.%d.254' % (ls + 2), interfaces=intfs) self.addLink(host, dhcpRelay, **linkopts) self.addLink(dhcpRelay, leafs[ls], **linkopts) else: self.addLink(host, leafs[ls], **linkopts) last_ls = leafs[leaf - 1] # Create common components # Control plane switch (for DHCP servers) cs1 = self.addSwitch('cs1', cls=OVSBridge) self.addLink(cs1, last_ls) # Control plane switch (for quagga fpm) cs0 = self.addSwitch('cs0', cls=OVSBridge) # Control plane NAT (for quagga fpm) nat = self.addHost('nat', cls=NAT, ip='172.16.0.1/12', subnet=str(ip_network(u'172.16.0.0/12')), inNamespace=False) self.addLink(cs0, nat) # Internal Quagga bgp1 intfs = { 'bgp1-eth0': { 'ipAddrs': ['10.0.1.2/24', '2000::102/120'], 'mac': '00:88:00:00:00:02' }, 'bgp1-eth1': { 'ipAddrs': ['172.16.0.2/12'] } } bgp1 = self.addHost('bgp1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdbgp1.conf', zebraConfFile='./zebradbgp1.conf') self.addLink(bgp1, last_ls) self.addLink(bgp1, cs0) # External Quagga r1 intfs = { 'r1-eth0': { 'ipAddrs': ['10.0.1.1/24', '2000::101/120'], 'mac': '00:88:00:00:00:01' }, 'r1-eth1': { 'ipAddrs': ['10.0.99.1/16'] }, 'r1-eth2': { 'ipAddrs': ['2000::9901/120'] } } r1 = self.addHost('r1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdr1.conf') self.addLink(r1, last_ls) # External switch behind r1 rs0 = self.addSwitch('rs0', cls=OVSBridge) self.addLink(r1, rs0) # External IPv4 Host behind r1 rh1 = self.addHost('rh1', cls=TrellisHost, ips=['10.0.99.2/24'], gateway='10.0.99.1') self.addLink(r1, rh1) # External IPv6 Host behind r1 rh1v6 = self.addHost('rh1v6', cls=TrellisHost, ips=['2000::9902/120'], gateway='2000::9901', ipv6=True) self.addLink(r1, rh1v6) # DHCP server if ipv6: if remote_server: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['2000::99fd/120'], gateway='2000::9901', dhcpServer=True, ipv6=True) self.addLink(rs0, dhcp) else: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['2000::3fd/120'], gateway='2000::3ff', dhcpServer=True, ipv6=True) self.addLink(dhcp, cs1) if multiple_server: dhcp2 = self.addHost('dhcp2', cls=TrellisHost, mac='00:99:00:00:00:02', ips=['2000::3fc/120'], gateway='2000::3ff', dhcpServer=True, ipv6=True) self.addLink(dhcp2, cs1) else: if remote_server: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['10.0.99.3/24'], gateway='10.0.99.1', dhcpServer=True) self.addLink(rs0, dhcp) else: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['10.0.3.253/24'], gateway='10.0.3.254', dhcpServer=True) self.addLink(dhcp, cs1) if multiple_server: dhcp2 = self.addHost('dhcp2', cls=TrellisHost, mac='00:99:00:00:00:02', ips=['10.0.3.252/24'], gateway='10.0.3.254', dhcpServer=True) self.addLink(dhcp2, cs1)
def __init__( self ): "Create a topology." # Initialize Topology Topo.__init__( self ) # add nodes, switches first... NY54 = self.addSwitch( 's25' ) # 40.728270, -73.994483 CMBR = self.addSwitch( 's1' ) # 42.373730, -71.109734 CHCG = self.addSwitch( 's2' ) # 41.877461, -87.642892 CLEV = self.addSwitch( 's3' ) # 41.498928, -81.695217 RLGH = self.addSwitch( 's4' ) # 35.780150, -78.644026 ATLN = self.addSwitch( 's5' ) # 33.749017, -84.394168 PHLA = self.addSwitch( 's6' ) # 39.952906, -75.172278 WASH = self.addSwitch( 's7' ) # 38.906696, -77.035509 NSVL = self.addSwitch( 's8' ) # 36.166410, -86.787305 STLS = self.addSwitch( 's9' ) # 38.626418, -90.198143 NWOR = self.addSwitch( 's10' ) # 29.951475, -90.078434 HSTN = self.addSwitch( 's11' ) # 29.763249, -95.368332 SNAN = self.addSwitch( 's12' ) # 29.424331, -98.491745 DLLS = self.addSwitch( 's13' ) # 32.777665, -96.802064 ORLD = self.addSwitch( 's14' ) # 28.538641, -81.381110 DNVR = self.addSwitch( 's15' ) # 39.736623, -104.984887 KSCY = self.addSwitch( 's16' ) # 39.100725, -94.581228 SNFN = self.addSwitch( 's17' ) # 37.779751, -122.409791 SCRM = self.addSwitch( 's18' ) # 38.581001, -121.497844 PTLD = self.addSwitch( 's19' ) # 45.523317, -122.677768 STTL = self.addSwitch( 's20' ) # 47.607326, -122.331786 SLKC = self.addSwitch( 's21' ) # 40.759577, -111.895079 LA03 = self.addSwitch( 's22' ) # 34.056346, -118.235951 SNDG = self.addSwitch( 's23' ) # 32.714564, -117.153528 PHNX = self.addSwitch( 's24' ) # 33.448289, -112.076299 # ... and now hosts NY54_host = self.addHost( 'h25' ) CMBR_host = self.addHost( 'h1' ) CHCG_host = self.addHost( 'h2' ) CLEV_host = self.addHost( 'h3' ) RLGH_host = self.addHost( 'h4' ) ATLN_host = self.addHost( 'h5' ) PHLA_host = self.addHost( 'h6' ) WASH_host = self.addHost( 'h7' ) NSVL_host = self.addHost( 'h8' ) STLS_host = self.addHost( 'h9' ) NWOR_host = self.addHost( 'h10' ) HSTN_host = self.addHost( 'h11' ) SNAN_host = self.addHost( 'h12' ) DLLS_host = self.addHost( 'h13' ) ORLD_host = self.addHost( 'h14' ) DNVR_host = self.addHost( 'h15' ) KSCY_host = self.addHost( 'h16' ) SNFN_host = self.addHost( 'h17' ) SCRM_host = self.addHost( 'h18' ) PTLD_host = self.addHost( 'h19' ) STTL_host = self.addHost( 'h20' ) SLKC_host = self.addHost( 'h21' ) LA03_host = self.addHost( 'h22' ) SNDG_host = self.addHost( 'h23' ) PHNX_host = self.addHost( 'h24' ) # add edges between switch and corresponding host self.addLink( NY54 , NY54_host ) self.addLink( CMBR , CMBR_host ) self.addLink( CHCG , CHCG_host ) self.addLink( CLEV , CLEV_host ) self.addLink( RLGH , RLGH_host ) self.addLink( ATLN , ATLN_host ) self.addLink( PHLA , PHLA_host ) self.addLink( WASH , WASH_host ) self.addLink( NSVL , NSVL_host ) self.addLink( STLS , STLS_host ) self.addLink( NWOR , NWOR_host ) self.addLink( HSTN , HSTN_host ) self.addLink( SNAN , SNAN_host ) self.addLink( DLLS , DLLS_host ) self.addLink( ORLD , ORLD_host ) self.addLink( DNVR , DNVR_host ) self.addLink( KSCY , KSCY_host ) self.addLink( SNFN , SNFN_host ) self.addLink( SCRM , SCRM_host ) self.addLink( PTLD , PTLD_host ) self.addLink( STTL , STTL_host ) self.addLink( SLKC , SLKC_host ) self.addLink( LA03 , LA03_host ) self.addLink( SNDG , SNDG_host ) self.addLink( PHNX , PHNX_host ) # add edges between switches self.addLink( NY54 , CMBR) self.addLink( NY54 , CMBR) self.addLink( NY54 , CMBR) self.addLink( NY54 , CHCG) self.addLink( NY54 , PHLA) self.addLink( NY54 , PHLA) self.addLink( NY54 , WASH) self.addLink( CMBR , PHLA) self.addLink( CHCG , CLEV) self.addLink( CHCG , PHLA) self.addLink( CHCG , STLS) self.addLink( CHCG , DNVR) self.addLink( CHCG , KSCY) self.addLink( CHCG , KSCY) self.addLink( CHCG , SNFN) self.addLink( CHCG , STTL) self.addLink( CHCG , SLKC) self.addLink( CLEV , NSVL) self.addLink( CLEV , STLS) self.addLink( CLEV , PHLA) self.addLink( RLGH , ATLN) self.addLink( RLGH , WASH) self.addLink( ATLN , WASH) self.addLink( ATLN , NSVL) self.addLink( ATLN , STLS) self.addLink( ATLN , DLLS) self.addLink( ATLN , DLLS) self.addLink( ATLN , DLLS) self.addLink( ATLN , ORLD) self.addLink( PHLA , WASH) self.addLink( NSVL , STLS) self.addLink( NSVL , DLLS) self.addLink( STLS , DLLS) self.addLink( STLS , KSCY) self.addLink( STLS , LA03) self.addLink( NWOR , HSTN) self.addLink( NWOR , DLLS) self.addLink( NWOR , ORLD) self.addLink( HSTN , SNAN) self.addLink( HSTN , DLLS) self.addLink( HSTN , ORLD) self.addLink( SNAN , PHNX) self.addLink( SNAN , DLLS) self.addLink( DLLS , DNVR) self.addLink( DLLS , DNVR) self.addLink( DLLS , KSCY) self.addLink( DLLS , KSCY) self.addLink( DLLS , SNFN) self.addLink( DLLS , LA03) self.addLink( DLLS , LA03) self.addLink( DNVR , KSCY) self.addLink( DNVR , SNFN) self.addLink( DNVR , SNFN) self.addLink( DNVR , SLKC) self.addLink( KSCY , SNFN) self.addLink( SNFN , SCRM) self.addLink( SNFN , PTLD) self.addLink( SNFN , STTL) self.addLink( SNFN , SLKC) self.addLink( SNFN , LA03) self.addLink( SNFN , LA03) self.addLink( SNFN , LA03) self.addLink( SCRM , SLKC) self.addLink( PTLD , STTL) self.addLink( SLKC , LA03) self.addLink( LA03 , SNDG) self.addLink( LA03 , SNDG) self.addLink( LA03 , PHNX) self.addLink( LA03 , PHNX) self.addLink( SNDG , PHNX)
def __init__(self): #Init Topo Topo.__init__(self) # self.host = [] # self.switch = [] # self.createhost() # self.createswitch() # self.createlink() """ host1 = self.addHost("h1") host2 = self.addHost("h2") host3 = self.addHost("h3") host4 = self.addHost("h4") host5 = self.addHost("h5") host6 = self.addHost("h6") host7 = self.addHost("h7") host8 = self.addHost("h8") host9 = self.addHost("h9") switch1 = self.addSwitch("s1") switch2 = self.addSwitch("s2") switch3 = self.addSwitch("s3") switch4 = self.addSwitch("s4") switch5 = self.addSwitch("s5") self.addLink(host1,switch2) self.addLink(host2,switch2) self.addLink(host3,switch2) self.addLink(host4,switch3) self.addLink(host5,switch3) self.addLink(host6,switch3) self.addLink(host7,switch4) self.addLink(host8,switch4) self.addLink(host9,switch4) self.addLink(switch1,switch5) self.addLink(switch4,switch5) self.addLink(switch3,switch1) self.addLink(switch2,switch1) """ host1 = self.addHost("h1") host2 = self.addHost("h2") host3 = self.addHost("h3") host4 = self.addHost("h4") host5 = self.addHost("h5") host6 = self.addHost("h6") host7 = self.addHost("h7") host8 = self.addHost("h8") host9 = self.addHost("h9") host10 = self.addHost("h10") host11 = self.addHost("h11") host12 = self.addHost("h12") host13 = self.addHost("h13") host14 = self.addHost("h14") host15 = self.addHost("h15") host16 = self.addHost("h16") host17 = self.addHost("h17") # host3 = self.addHost("h3") switch1 = self.addSwitch("s1") switch2 = self.addSwitch("s2") switch3 = self.addSwitch("s3") # switch4 = self.addSwitch("s4") # switch5 = self.addSwitch("s5") self.addLink(host1,switch2) self.addLink(host2,switch3) self.addLink(host3,switch3) self.addLink(host4,switch3) self.addLink(host5,switch3) self.addLink(host6,switch3) self.addLink(host7,switch3) self.addLink(host8,switch3) self.addLink(host9,switch3) self.addLink(host10,switch3) self.addLink(host11,switch3) self.addLink(host12,switch3) self.addLink(host13,switch3) self.addLink(host14,switch3) self.addLink(host15,switch3) self.addLink(host16,switch3) self.addLink(host17,switch3) # self.addLink(switch1,switch5) # self.addLink(switch4,switch5) self.addLink(switch3,switch1) self.addLink(switch2,switch1)
def __init__(self, **opts): "Create a topology." # Initialize Topology self.switchList = {} self.hostList = {} Topo.__init__(self, **opts) # add nodes, switches first... id_gen_0 = ZooNodeID edge_id = id_gen_0(0, 0, 1).name_str() edge_opts = def_nopts(id_gen_0, 0, edge_id) Zurich = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_1 = ZooNodeID edge_id = id_gen_1(0, 1, 1).name_str() edge_opts = def_nopts(id_gen_1, 0, edge_id) Geneva = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_2 = ZooNodeID edge_id = id_gen_2(0, 2, 1).name_str() edge_opts = def_nopts(id_gen_2, 0, edge_id) Budapest = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_3 = ZooNodeID edge_id = id_gen_3(0, 3, 1).name_str() edge_opts = def_nopts(id_gen_3, 0, edge_id) Stuttgart = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_4 = ZooNodeID edge_id = id_gen_4(0, 4, 1).name_str() edge_opts = def_nopts(id_gen_4, 0, edge_id) Madrid = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_5 = ZooNodeID edge_id = id_gen_5(0, 5, 1).name_str() edge_opts = def_nopts(id_gen_5, 0, edge_id) Lisbon = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_6 = ZooNodeID edge_id = id_gen_6(0, 6, 1).name_str() edge_opts = def_nopts(id_gen_6, 0, edge_id) Milan = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_7 = ZooNodeID edge_id = id_gen_7(0, 7, 1).name_str() edge_opts = def_nopts(id_gen_7, 0, edge_id) Barcelona = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_8 = ZooNodeID edge_id = id_gen_8(0, 8, 1).name_str() edge_opts = def_nopts(id_gen_8, 0, edge_id) Paris = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_9 = ZooNodeID edge_id = id_gen_9(0, 9, 1).name_str() edge_opts = def_nopts(id_gen_9, 0, edge_id) London = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_10 = ZooNodeID edge_id = id_gen_10(0, 10, 1).name_str() edge_opts = def_nopts(id_gen_10, 0, edge_id) Tokyo = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_11 = ZooNodeID edge_id = id_gen_11(0, 11, 1).name_str() edge_opts = def_nopts(id_gen_11, 0, edge_id) Chicago = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_12 = ZooNodeID edge_id = id_gen_12(0, 12, 1).name_str() edge_opts = def_nopts(id_gen_12, 0, edge_id) Washington = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_13 = ZooNodeID edge_id = id_gen_13(0, 13, 1).name_str() edge_opts = def_nopts(id_gen_13, 0, edge_id) Miami = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_14 = ZooNodeID edge_id = id_gen_14(0, 14, 1).name_str() edge_opts = def_nopts(id_gen_14, 0, edge_id) LosAngeles = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_15 = ZooNodeID edge_id = id_gen_15(0, 15, 1).name_str() edge_opts = def_nopts(id_gen_15, 0, edge_id) PaloAlto = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_16 = ZooNodeID edge_id = id_gen_16(0, 16, 1).name_str() edge_opts = def_nopts(id_gen_16, 0, edge_id) SanJose = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_17 = ZooNodeID edge_id = id_gen_17(0, 17, 1).name_str() edge_opts = def_nopts(id_gen_17, 0, edge_id) HongKong = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_18 = ZooNodeID edge_id = id_gen_18(0, 18, 1).name_str() edge_opts = def_nopts(id_gen_18, 0, edge_id) Singapore = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_19 = ZooNodeID edge_id = id_gen_19(0, 19, 1).name_str() edge_opts = def_nopts(id_gen_19, 0, edge_id) Toronto = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_20 = ZooNodeID edge_id = id_gen_20(0, 20, 1).name_str() edge_opts = def_nopts(id_gen_20, 0, edge_id) NewYork = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_21 = ZooNodeID edge_id = id_gen_21(0, 21, 1).name_str() edge_opts = def_nopts(id_gen_21, 0, edge_id) Frankfurt = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_22 = ZooNodeID edge_id = id_gen_22(0, 22, 1).name_str() edge_opts = def_nopts(id_gen_22, 0, edge_id) Cologne = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_23 = ZooNodeID edge_id = id_gen_23(0, 23, 1).name_str() edge_opts = def_nopts(id_gen_23, 0, edge_id) Hanover = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_24 = ZooNodeID edge_id = id_gen_24(0, 24, 1).name_str() edge_opts = def_nopts(id_gen_24, 0, edge_id) Amsterdam = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_25 = ZooNodeID edge_id = id_gen_25(0, 25, 1).name_str() edge_opts = def_nopts(id_gen_25, 0, edge_id) Ashburn = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_26 = ZooNodeID edge_id = id_gen_26(0, 26, 1).name_str() edge_opts = def_nopts(id_gen_26, 0, edge_id) Hamburg = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_27 = ZooNodeID edge_id = id_gen_27(0, 27, 1).name_str() edge_opts = def_nopts(id_gen_27, 0, edge_id) Dortmund = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_28 = ZooNodeID edge_id = id_gen_28(0, 28, 1).name_str() edge_opts = def_nopts(id_gen_28, 0, edge_id) Dusseldorf = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_29 = ZooNodeID edge_id = id_gen_29(0, 29, 1).name_str() edge_opts = def_nopts(id_gen_29, 0, edge_id) Vienna = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_30 = ZooNodeID edge_id = id_gen_30(0, 30, 1).name_str() edge_opts = def_nopts(id_gen_30, 0, edge_id) Munich = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_31 = ZooNodeID edge_id = id_gen_31(0, 31, 1).name_str() edge_opts = def_nopts(id_gen_31, 0, edge_id) Copenhagen = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_32 = ZooNodeID edge_id = id_gen_32(0, 32, 1).name_str() edge_opts = def_nopts(id_gen_32, 0, edge_id) Stockholm = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_33 = ZooNodeID edge_id = id_gen_33(0, 33, 1).name_str() edge_opts = def_nopts(id_gen_33, 0, edge_id) Warsaw = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_34 = ZooNodeID edge_id = id_gen_34(0, 34, 1).name_str() edge_opts = def_nopts(id_gen_34, 0, edge_id) Moscow = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_35 = ZooNodeID edge_id = id_gen_35(0, 35, 1).name_str() edge_opts = def_nopts(id_gen_35, 0, edge_id) Berlin = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_36 = ZooNodeID edge_id = id_gen_36(0, 36, 1).name_str() edge_opts = def_nopts(id_gen_36, 0, edge_id) Leipzig = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_37 = ZooNodeID edge_id = id_gen_37(0, 37, 1).name_str() edge_opts = def_nopts(id_gen_37, 0, edge_id) Prague = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts id_gen_38 = ZooNodeID edge_id = id_gen_38(0, 38, 1).name_str() edge_opts = def_nopts(id_gen_38, 0, edge_id) Nuremberg = self.addSwitch(edge_id, **edge_opts) self.switchList[edge_id] = edge_opts # ... and now hosts host_id = id_gen_0(3, 0, 1).name_str() host_opts = def_nopts(id_gen_0, 3, host_id) Zurich_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_1(3, 1, 2).name_str() host_opts = def_nopts(id_gen_1, 3, host_id) Geneva_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_2(3, 2, 3).name_str() host_opts = def_nopts(id_gen_2, 3, host_id) Budapest_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_3(3, 3, 4).name_str() host_opts = def_nopts(id_gen_3, 3, host_id) Stuttgart_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_4(3, 4, 5).name_str() host_opts = def_nopts(id_gen_4, 3, host_id) Madrid_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_5(3, 5, 6).name_str() host_opts = def_nopts(id_gen_5, 3, host_id) Lisbon_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_6(3, 6, 7).name_str() host_opts = def_nopts(id_gen_6, 3, host_id) Milan_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_7(3, 7, 8).name_str() host_opts = def_nopts(id_gen_7, 3, host_id) Barcelona_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_8(3, 8, 9).name_str() host_opts = def_nopts(id_gen_8, 3, host_id) Paris_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_9(3, 9, 10).name_str() host_opts = def_nopts(id_gen_9, 3, host_id) London_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_10(3, 10, 11).name_str() host_opts = def_nopts(id_gen_10, 3, host_id) Tokyo_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_11(3, 11, 12).name_str() host_opts = def_nopts(id_gen_11, 3, host_id) Chicago_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_12(3, 12, 13).name_str() host_opts = def_nopts(id_gen_12, 3, host_id) Washington_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_13(3, 13, 14).name_str() host_opts = def_nopts(id_gen_13, 3, host_id) Miami_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_14(3, 14, 15).name_str() host_opts = def_nopts(id_gen_14, 3, host_id) LosAngeles_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_15(3, 15, 16).name_str() host_opts = def_nopts(id_gen_15, 3, host_id) PaloAlto_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_16(3, 16, 17).name_str() host_opts = def_nopts(id_gen_16, 3, host_id) SanJose_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_17(3, 17, 18).name_str() host_opts = def_nopts(id_gen_17, 3, host_id) HongKong_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_18(3, 18, 19).name_str() host_opts = def_nopts(id_gen_18, 3, host_id) Singapore_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_19(3, 19, 20).name_str() host_opts = def_nopts(id_gen_19, 3, host_id) Toronto_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_20(3, 20, 21).name_str() host_opts = def_nopts(id_gen_20, 3, host_id) NewYork_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_21(3, 21, 22).name_str() host_opts = def_nopts(id_gen_21, 3, host_id) Frankfurt_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_22(3, 22, 23).name_str() host_opts = def_nopts(id_gen_22, 3, host_id) Cologne_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_23(3, 23, 24).name_str() host_opts = def_nopts(id_gen_23, 3, host_id) Hanover_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_24(3, 24, 25).name_str() host_opts = def_nopts(id_gen_24, 3, host_id) Amsterdam_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_25(3, 25, 26).name_str() host_opts = def_nopts(id_gen_25, 3, host_id) Ashburn_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_26(3, 26, 27).name_str() host_opts = def_nopts(id_gen_26, 3, host_id) Hamburg_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_27(3, 27, 28).name_str() host_opts = def_nopts(id_gen_27, 3, host_id) Dortmund_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_28(3, 28, 29).name_str() host_opts = def_nopts(id_gen_28, 3, host_id) Dusseldorf_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_29(3, 29, 30).name_str() host_opts = def_nopts(id_gen_29, 3, host_id) Vienna_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_30(3, 30, 31).name_str() host_opts = def_nopts(id_gen_30, 3, host_id) Munich_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_31(3, 31, 32).name_str() host_opts = def_nopts(id_gen_31, 3, host_id) Copenhagen_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_32(3, 32, 33).name_str() host_opts = def_nopts(id_gen_32, 3, host_id) Stockholm_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_33(3, 33, 34).name_str() host_opts = def_nopts(id_gen_33, 3, host_id) Warsaw_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_34(3, 34, 35).name_str() host_opts = def_nopts(id_gen_34, 3, host_id) Moscow_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_35(3, 35, 36).name_str() host_opts = def_nopts(id_gen_35, 3, host_id) Berlin_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_36(3, 36, 37).name_str() host_opts = def_nopts(id_gen_36, 3, host_id) Leipzig_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_37(3, 37, 38).name_str() host_opts = def_nopts(id_gen_37, 3, host_id) Prague_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts host_id = id_gen_38(3, 38, 39).name_str() host_opts = def_nopts(id_gen_38, 3, host_id) Nuremberg_host = self.addHost(host_id, **host_opts) self.hostList[host_id] = host_opts # add edges between switch and corresponding host self.addLink(Zurich, Zurich_host) self.addLink(Geneva, Geneva_host) self.addLink(Budapest, Budapest_host) self.addLink(Stuttgart, Stuttgart_host) self.addLink(Madrid, Madrid_host) self.addLink(Lisbon, Lisbon_host) self.addLink(Milan, Milan_host) self.addLink(Barcelona, Barcelona_host) self.addLink(Paris, Paris_host) self.addLink(London, London_host) self.addLink(Tokyo, Tokyo_host) self.addLink(Chicago, Chicago_host) self.addLink(Washington, Washington_host) self.addLink(Miami, Miami_host) self.addLink(LosAngeles, LosAngeles_host) self.addLink(PaloAlto, PaloAlto_host) self.addLink(SanJose, SanJose_host) self.addLink(HongKong, HongKong_host) self.addLink(Singapore, Singapore_host) self.addLink(Toronto, Toronto_host) self.addLink(NewYork, NewYork_host) self.addLink(Frankfurt, Frankfurt_host) self.addLink(Cologne, Cologne_host) self.addLink(Hanover, Hanover_host) self.addLink(Amsterdam, Amsterdam_host) self.addLink(Ashburn, Ashburn_host) self.addLink(Hamburg, Hamburg_host) self.addLink(Dortmund, Dortmund_host) self.addLink(Dusseldorf, Dusseldorf_host) self.addLink(Vienna, Vienna_host) self.addLink(Munich, Munich_host) self.addLink(Copenhagen, Copenhagen_host) self.addLink(Stockholm, Stockholm_host) self.addLink(Warsaw, Warsaw_host) self.addLink(Moscow, Moscow_host) self.addLink(Berlin, Berlin_host) self.addLink(Leipzig, Leipzig_host) self.addLink(Prague, Prague_host) self.addLink(Nuremberg, Nuremberg_host) # add edges between switches self.addLink(Zurich, Paris) self.addLink(Zurich, Geneva) self.addLink(Zurich, Stuttgart) self.addLink(Zurich, Milan) self.addLink(Zurich, Barcelona) self.addLink(Geneva, Paris) self.addLink(Geneva, Milan) self.addLink(Budapest, Vienna) self.addLink(Budapest, Munich) self.addLink(Madrid, Paris) self.addLink(Madrid, Lisbon) self.addLink(Madrid, Barcelona) self.addLink(Milan, Paris) self.addLink(Paris, London) self.addLink(Paris, Frankfurt) self.addLink(Paris, Amsterdam) self.addLink(Paris, Ashburn) self.addLink(London, NewYork) self.addLink(London, Frankfurt) self.addLink(London, Amsterdam) self.addLink(London, Ashburn) self.addLink(London, Dusseldorf) self.addLink(Tokyo, SanJose) self.addLink(Tokyo, HongKong) self.addLink(Chicago, Toronto) self.addLink(Chicago, NewYork) self.addLink(Chicago, PaloAlto) self.addLink(Washington, Ashburn) self.addLink(Washington, NewYork) self.addLink(Washington, Miami) self.addLink(Washington, LosAngeles) self.addLink(LosAngeles, SanJose) self.addLink(LosAngeles, HongKong) self.addLink(LosAngeles, Singapore) self.addLink(LosAngeles, PaloAlto) self.addLink(PaloAlto, SanJose) self.addLink(PaloAlto, Ashburn) self.addLink(PaloAlto, NewYork) self.addLink(SanJose, NewYork) self.addLink(HongKong, Singapore) self.addLink(Singapore, Frankfurt) self.addLink(Toronto, NewYork) self.addLink(NewYork, Leipzig) self.addLink(NewYork, Frankfurt) self.addLink(NewYork, Hanover) self.addLink(NewYork, Dusseldorf) self.addLink(Frankfurt, Moscow) self.addLink(Frankfurt, Amsterdam) self.addLink(Frankfurt, Ashburn) self.addLink(Hanover, Ashburn) self.addLink(Amsterdam, Hamburg) self.addLink(Amsterdam, Dusseldorf) self.addLink(Ashburn, Leipzig) self.addLink(Ashburn, Dusseldorf) self.addLink(Hamburg, Stockholm) self.addLink(Hamburg, Copenhagen) self.addLink(Vienna, Prague) self.addLink(Vienna, Munich) self.addLink(Copenhagen, Stockholm) self.addLink(Warsaw, Berlin) self.addLink(Warsaw, Nuremberg) self.addLink(Prague, Nuremberg)
def __init__(self): # Initialize topology Topo.__init__(self) # You can write other functions as you need. numHost = 0 numSwitch = 0 numLink = 0 mapNodes = {} MEGA_BITS = 1000000 QUEUE_DEFAULT_BW_RATIO = 0.5 QUEUE_PREMIUM_BW_RATIO = 0.8 ''' Between switches, link bandwidth is 100Mbps. Configure under qosSwitchConfig Between host and switch, link bandwidth is 10Mbps. Configure under qosHostConfig QOS: 1. Host 1, 2, 5 at least 8Mbps 2. Other host max 5Mbps ''' # qosHostConfig = ' qos=@newqos \ # -- --id=@newqos create QoS type=linux-htb other-config:max-rate=%s queues=0=@q0,1=@q1 \ # -- --id=@q0 create queue other-config:max-rate=5000000 \ # -- --id=@q1 create queue other-config:min-rate=8000000 other-config:max-rate=%s' qosHostConfig = ' qos=@newqos \ -- --id=@newqos create QoS type=linux-htb other-config:max-rate=%s queues=0=@q0,1=@q1 \ -- --id=@q0 create queue other-config:max-rate=%s \ -- --id=@q1 create queue other-config:min-rate=%s other-config:max-rate=%s' qosSwitchConfig = ' qos=@newqos -- --id=@newqos create QoS type=linux-htb other-config:max-rate=%s' with open(topoInputFile, 'r') as f: index = 1 for line in f: line = line.strip("\n ' '") if index == 1: # i.e. 7 4 11 # 7 hosts # 4 switches # 11 links firstLineItems = line.split(' ') numHost = int(firstLineItems[0]) numSwitch = int(firstLineItems[1]) numLink = int(firstLineItems[2]) # numHost, numSwitch, numLink = [int(num) for num in line.split(' ')] for hIndex in range(1, numHost + 1): hostId = 'h%d' % hIndex hostObj = self.addHost(hostId) mapNodes[hostId] = hostObj cmd = 'h{0}.setIP("10.0.0.{0}/24")'.format(hIndex) os.system(cmd) for sIndex in range(1, numSwitch + 1): switchId = 's%d' % sIndex sconfig = {'dpid': "%016x" % sIndex} switchObj = self.addSwitch(switchId, **sconfig) mapNodes[switchId] = switchObj # elif (numRowFirewall >= index): # items = line.split(',') # # (srcIp, destIp, port) = True # self.firewallTable[(items[0], items[1], items[2])] = True # else: # link rows items = line.split(',') nodeStr1 = items[0] nodeStr2 = items[1] bandwidth = int(items[2]) print "Read %s <---> %s on %s" % (nodeStr1, nodeStr2, bandwidth) link = self.addLink(mapNodes[nodeStr1], mapNodes[nodeStr2]) print "Link...interface = %s" % (self.linkInfo(nodeStr1, nodeStr2)) # Create QoS for each link # If both nodes are switches, info = self.linkInfo(nodeStr1, nodeStr2) maxBandwidth = str(bandwidth * MEGA_BITS) defaultMaxBandwidth = str(bandwidth * MEGA_BITS * QUEUE_DEFAULT_BW_RATIO) preimumMinBandwidth = str(bandwidth * MEGA_BITS * QUEUE_PREMIUM_BW_RATIO) # print "MAX BW = %s" % (maxBandwidth) firstPort = str('%s-eth%s' % (nodeStr1, str(info["port1"]))) secondPort = str('%s-eth%s' % (nodeStr2, str(info["port2"]))) if (is_switch(nodeStr1) and is_switch(nodeStr2)): cmd = 'sudo ovs-vsctl -- set Port %s ' + qosSwitchConfig qosCommands.append(cmd % (firstPort, maxBandwidth)) qosCommands.append(cmd % (secondPort, maxBandwidth)) # os.system(cmd % (firstPort, maxBandwidth)) # os.system(cmd % (secondPort, maxBandwidth)) else: cmd = 'sudo ovs-vsctl -- set Port %s ' + qosHostConfig if (is_switch(nodeStr1)): cmd = cmd % (firstPort, maxBandwidth, defaultMaxBandwidth, preimumMinBandwidth, maxBandwidth) else: cmd = cmd % (secondPort, maxBandwidth, defaultMaxBandwidth, preimumMinBandwidth, maxBandwidth) # os.system('sudo ovs-vsctl -- set Port %s ' + qosHostConfig % (secondPort, maxBandwidth, maxBandwidth)) # print cmd qosCommands.append(cmd) # os.system(cmd) index +=1
def __init__(self, spine=2, leaf=2, fanout=2, vlan_id=[], ipv6=False, dhcp_client=False, dhcp_relay=False, multiple_server=False, remote_server=False, **opts): # TODO: add support to dhcp_relay, multiple_server and remote_server Topo.__init__(self, **opts) spines = dict() leafs = dict() # leaf should be 2 or 4 # calculate the subnets to use and set options linkopts = dict(bw=100) # Create spine switches for s in range(spine): spines[s] = self.addSwitch('spine10%s' % (s + 1), dpid="00000000010%s" % (s + 1), **SWITCH_PARAMS) # Create leaf switches for ls in range(leaf): leafs[ls] = self.addSwitch('leaf%s' % (ls + 1), dpid="00000000000%s" % (ls + 1), **SWITCH_PARAMS) # Connect leaf to all spines with dual link for s in range(spine): switch = spines[s] self.addLink(leafs[ls], switch, **linkopts) self.addLink(leafs[ls], switch, **linkopts) # Add hosts after paired ToR switches are added. if ls % 2 == 0: continue # Add leaf-leaf link self.addLink(leafs[ls], leafs[ls - 1]) dual_ls = ls / 2 # Add hosts for f in range(fanout): name = 'h%s%s' % (dual_ls * fanout + f + 1, "v6" if ipv6 else "") if ipv6: ips = [ '2000::%d0%d/%d' % (dual_ls + 2, f + 1, IP6_SUBNET_CLASS) ] gateway = '2000::%dff' % (dual_ls + 2) mac = '00:bb:00:00:00:%02x' % (dual_ls * fanout + f + 1) else: ips = [ '10.0.%d.%d/%d' % (dual_ls + 2, f + 1, IP4_SUBNET_CLASS) ] gateway = '10.0.%d.254' % (dual_ls + 2) mac = '00:aa:00:00:00:%02x' % (dual_ls * fanout + f + 1) host = self.addHost( name=name, cls=TrellisHost, ips=ips, gateway=gateway, mac=mac, vlan=vlan_id[dual_ls * fanout + f] if vlan_id[dual_ls * fanout + f] != 0 else None, dhcpClient=dhcp_client, ipv6=ipv6, dualHomed=True) self.addLink(host, leafs[ls], **linkopts) self.addLink(host, leafs[ls - 1], **linkopts) last_ls = leafs[leaf - 2] last_paired_ls = leafs[leaf - 1] # Create common components # Control plane switch (for DHCP servers) cs1 = self.addSwitch('cs1', cls=OVSBridge) self.addLink(cs1, last_ls) # Control plane switch (for quagga fpm) cs0 = self.addSwitch('cs0', cls=OVSBridge) # Control plane NAT (for quagga fpm) nat = self.addHost('nat', cls=NAT, ip='172.16.0.1/12', subnet=str(ip_network(u'172.16.0.0/12')), inNamespace=False) self.addLink(cs0, nat) # Internal Quagga bgp1 intfs = { 'bgp1-eth0': { 'ipAddrs': ['10.0.1.2/24', '2000::102/120'], 'mac': '00:88:00:00:00:03' }, 'bgp1-eth1': { 'ipAddrs': ['172.16.0.2/12'] } } bgp1 = self.addHost('bgp1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdbgp1.conf', zebraConfFile='./zebradbgp1.conf') self.addLink(bgp1, last_ls) self.addLink(bgp1, cs0) # Internal Quagga bgp2 intfs = { 'bgp2-eth0': [{ 'ipAddrs': ['10.0.5.2/24', '2000::502/120'], 'mac': '00:88:00:00:00:04', 'vlan': '150' }, { 'ipAddrs': ['10.0.6.2/24', '2000::602/120'], 'mac': '00:88:00:00:00:04', 'vlan': '160' }], 'bgp2-eth1': { 'ipAddrs': ['172.16.0.4/12'] } } bgp2 = self.addHost('bgp2', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdbgp2.conf', zebraConfFile='./zebradbgp2.conf') self.addLink(bgp2, last_paired_ls) self.addLink(bgp2, cs0) # External Quagga r1 intfs = { 'r1-eth0': { 'ipAddrs': ['10.0.1.1/24', '2000::101/120'], 'mac': '00:88:00:00:00:01' }, 'r1-eth1': { 'ipAddrs': ['10.0.5.1/24', '2000::501/120'], 'mac': '00:88:00:00:00:11' }, 'r1-eth2': { 'ipAddrs': ['10.0.99.1/16'] } } r1 = self.addHost('r1', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdr1.conf') self.addLink(r1, last_ls) self.addLink(r1, last_paired_ls) # External IPv4 Host behind r1 rh1 = self.addHost('rh1', cls=TrellisHost, ips=['10.0.99.2/24'], gateway='10.0.99.1') self.addLink(r1, rh1) # External Quagga r2 intfs = { 'r2-eth0': { 'ipAddrs': ['10.0.6.1/24', '2000::601/120'], 'mac': '00:88:00:00:00:02' }, 'r2-eth1': { 'ipAddrs': ['10.0.7.1/24', '2000::701/120'], 'mac': '00:88:00:00:00:22' }, 'r2-eth2': { 'ipAddrs': ['10.0.99.1/16'] } } r2 = self.addHost('r2', cls=BgpRouter, interfaces=intfs, quaggaConfFile='./bgpdr2.conf') self.addLink(r2, last_ls) self.addLink(r2, last_paired_ls) # External IPv4 Host behind r2 rh2 = self.addHost('rh2', cls=TrellisHost, ips=['10.0.99.2/24'], gateway='10.0.99.1') self.addLink(r2, rh2) # DHCP server if ipv6: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['2000::3fd/120'], gateway='2000::3ff', dhcpServer=True, ipv6=True) self.addLink(dhcp, cs1) else: dhcp = self.addHost('dhcp', cls=TrellisHost, mac='00:99:00:00:00:01', ips=['10.0.3.253/24'], gateway='10.0.3.254', dhcpServer=True) self.addLink(dhcp, cs1)
def __init__(self, params): Topo.__init__(self) self.params = params if params["num_switches"] < 2: print "Need to have at least three switches for a ring." raise if params["per_switch_links"] < 2 and params[ "per_switch_links"] > params["num_switches"] - 1: print "Cannot have less than 2 and more than " + str( params["num_switches"] - 1) + " links." self.num_switches = params["num_switches"] self.total_switches = params["num_switches"] self.num_hosts_per_switch = params["num_hosts_per_switch"] self.per_switch_links = params["per_switch_links"] if "switch_switch_link_latency_range" in params: switch_switch_link_opts = \ dict(delay=str(int(random.uniform(*params["switch_switch_link_latency_range"]))) + "ms") else: switch_switch_link_opts = dict() if "host_switch_link_latency_range" in params: host_switch_link_opts = \ dict(delay=str(int(random.uniform(*params["host_switch_link_latency_range"]))) + "ms") else: host_switch_link_opts = dict() self.switch_names = [] self.host_names = [] self.host_cntr = 1 # Add switches and hosts under them for i in xrange(self.num_switches): curr_switch = self.addSwitch("s" + str(i + 1), protocols="OpenFlow14") self.switch_names.append(curr_switch) for j in xrange(self.num_hosts_per_switch): curr_host = self.addHost("h" + str(self.host_cntr)) self.host_names.append(curr_host) self.host_cntr += 1 self.addLink(curr_switch, curr_host, **host_switch_link_opts) # Add links between switches for i in xrange(self.num_switches - 1): dst_switch_offsets = xrange(1, self.per_switch_links) for j in dst_switch_offsets: try: l = self.g[self.switch_names[i]][self.switch_names[ (i + j) % self.num_switches]] print l except KeyError: self.addLink( self.switch_names[i], self.switch_names[(i + j) % self.num_switches], **switch_switch_link_opts) # Form a ring only when there are more than two switches self.addLink(self.switch_names[0], self.switch_names[-1], **switch_switch_link_opts) self.add_enterprise_net_with_attk_node(host_switch_link_opts, switch_switch_link_opts)
def __init__(self, **opts): "Create a topology." # Initialize Topology Topo.__init__(self, **opts) # add nodes, Leaf switches s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') s7 = self.addSwitch('s7') s8 = self.addSwitch('s8') s9 = self.addSwitch('s9') s10 = self.addSwitch('s10') s11 = self.addSwitch('s11') s12 = self.addSwitch('s12') s13 = self.addSwitch('s13') s14 = self.addSwitch('s14') # add nodes, Spine switches first... s15 = self.addSwitch('s15') s16 = self.addSwitch('s16') s17 = self.addSwitch('s17') s18 = self.addSwitch('s18') s19 = self.addSwitch('s19') s20 = self.addSwitch('s20') s21 = self.addSwitch('s21') s22 = self.addSwitch('s22') s23 = self.addSwitch('s23') s24 = self.addSwitch('s24') s25 = self.addSwitch('s25') s26 = self.addSwitch('s26') s27 = self.addSwitch('s27') s28 = self.addSwitch('s28') s29 = self.addSwitch('s29') s30 = self.addSwitch('s30') s31 = self.addSwitch('s31') s32 = self.addSwitch('s32') s33 = self.addSwitch('s33') s34 = self.addSwitch('s34') s35 = self.addSwitch('s35') s36 = self.addSwitch('s36') s37 = self.addSwitch('s37') s38 = self.addSwitch('s38') s39 = self.addSwitch('s39') s40 = self.addSwitch('s40') s41 = self.addSwitch('s41') s42 = self.addSwitch('s42') s43 = self.addSwitch('s43') s44 = self.addSwitch('s44') s45 = self.addSwitch('s45') s46 = self.addSwitch('s46') s47 = self.addSwitch('s47') s48 = self.addSwitch('s48') s49 = self.addSwitch('s49') s50 = self.addSwitch('s50') s51 = self.addSwitch('s51') s52 = self.addSwitch('s52') s53 = self.addSwitch('s53') s54 = self.addSwitch('s54') s55 = self.addSwitch('s55') s56 = self.addSwitch('s56') s57 = self.addSwitch('s57') s58 = self.addSwitch('s58') s59 = self.addSwitch('s59') s60 = self.addSwitch('s60') s61 = self.addSwitch('s61') s62 = self.addSwitch('s62') s63 = self.addSwitch('s63') s64 = self.addSwitch('s64') s65 = self.addSwitch('s65') s66 = self.addSwitch('s66') s67 = self.addSwitch('s67') s68 = self.addSwitch('s68') s69 = self.addSwitch('s69') s70 = self.addSwitch('s70') s71 = self.addSwitch('s71') s72 = self.addSwitch('s72') s73 = self.addSwitch('s73') s74 = self.addSwitch('s74') s75 = self.addSwitch('s75') s76 = self.addSwitch('s76') s77 = self.addSwitch('s77') s78 = self.addSwitch('s78') # ... and now hosts #s1_host = self.addHost( 'h1' ) #s2_host = self.addHost( 'h2' ) #s3_host = self.addHost( 'h3' ) #s4_host = self.addHost( 'h4' ) #s5_host = self.addHost( 'h5' ) #s6_host = self.addHost( 'h6' ) #s7_host = self.addHost( 'h7' ) #s8_host = self.addHost( 'h8' ) #s9_host = self.addHost( 'h9' ) #s10_host = self.addHost( 'h10' ) s11_host = self.addHost('h11') s12_host = self.addHost('h12') s13_host = self.addHost('h13') s14_host = self.addHost('h14') s15_host = self.addHost('h15') s16_host = self.addHost('h16') s17_host = self.addHost('h17') s18_host = self.addHost('h18') s19_host = self.addHost('h19') s20_host = self.addHost('h20') s21_host = self.addHost('h21') s22_host = self.addHost('h22') s23_host = self.addHost('h23') s24_host = self.addHost('h24') s25_host = self.addHost('h25') s26_host = self.addHost('h26') s27_host = self.addHost('h27') s28_host = self.addHost('h28') s29_host = self.addHost('h29') s30_host = self.addHost('h30') s31_host = self.addHost('h31') s32_host = self.addHost('h32') s33_host = self.addHost('h33') s34_host = self.addHost('h34') s35_host = self.addHost('h35') s36_host = self.addHost('h36') s37_host = self.addHost('h37') s38_host = self.addHost('h38') s39_host = self.addHost('h39') s40_host = self.addHost('h40') s41_host = self.addHost('h41') s42_host = self.addHost('h42') s43_host = self.addHost('h43') s44_host = self.addHost('h44') s45_host = self.addHost('h45') s46_host = self.addHost('h46') s47_host = self.addHost('h47') s48_host = self.addHost('h48') s49_host = self.addHost('h49') s50_host = self.addHost('h50') s51_host = self.addHost('h51') s52_host = self.addHost('h52') s53_host = self.addHost('h53') s54_host = self.addHost('h54') s55_host = self.addHost('h55') s56_host = self.addHost('h56') s57_host = self.addHost('h57') s58_host = self.addHost('h58') s59_host = self.addHost('h59') s60_host = self.addHost('h60') s61_host = self.addHost('h61') s62_host = self.addHost('h62') s63_host = self.addHost('h63') s64_host = self.addHost('h64') s65_host = self.addHost('h65') s66_host = self.addHost('h66') s67_host = self.addHost('h67') s68_host = self.addHost('h68') s69_host = self.addHost('h69') s70_host = self.addHost('h70') s71_host = self.addHost('h71') s72_host = self.addHost('h72') s73_host = self.addHost('h73') s74_host = self.addHost('h74') s75_host = self.addHost('h75') s76_host = self.addHost('h76') s77_host = self.addHost('h77') s78_host = self.addHost('h78') # add edges between switch and corresponding host #self.addLink( s1 , s1_host ) #self.addLink( s2 , s2_host ) #self.addLink( s3 , s3_host ) #self.addLink( s4 , s4_host ) #self.addLink( s5 , s5_host ) #self.addLink( s6 , s6_host ) #self.addLink( s7 , s7_host ) #self.addLink( s8 , s8_host ) #self.addLink( s9 , s9_host ) #self.addLink( s10 , s10_host ) self.addLink(s11, s11_host) self.addLink(s12, s12_host) self.addLink(s13, s13_host) self.addLink(s14, s14_host) self.addLink(s15, s15_host) self.addLink(s16, s16_host) self.addLink(s17, s17_host) self.addLink(s18, s18_host) self.addLink(s19, s19_host) self.addLink(s20, s20_host) self.addLink(s21, s21_host) self.addLink(s22, s22_host) self.addLink(s23, s23_host) self.addLink(s24, s24_host) self.addLink(s25, s25_host) self.addLink(s26, s26_host) self.addLink(s27, s27_host) self.addLink(s28, s28_host) self.addLink(s29, s29_host) self.addLink(s30, s30_host) self.addLink(s31, s31_host) self.addLink(s32, s32_host) self.addLink(s33, s33_host) self.addLink(s34, s34_host) self.addLink(s35, s35_host) self.addLink(s36, s36_host) self.addLink(s37, s37_host) self.addLink(s38, s38_host) self.addLink(s39, s39_host) self.addLink(s40, s40_host) self.addLink(s41, s41_host) self.addLink(s42, s42_host) self.addLink(s43, s43_host) self.addLink(s44, s44_host) self.addLink(s45, s45_host) self.addLink(s46, s46_host) self.addLink(s47, s47_host) self.addLink(s48, s48_host) self.addLink(s49, s49_host) self.addLink(s50, s50_host) self.addLink(s51, s51_host) self.addLink(s52, s52_host) self.addLink(s53, s53_host) self.addLink(s54, s54_host) self.addLink(s55, s55_host) self.addLink(s56, s56_host) self.addLink(s57, s57_host) self.addLink(s58, s58_host) self.addLink(s59, s59_host) self.addLink(s60, s60_host) self.addLink(s61, s61_host) self.addLink(s62, s62_host) self.addLink(s63, s63_host) self.addLink(s64, s64_host) self.addLink(s65, s65_host) self.addLink(s66, s66_host) self.addLink(s67, s67_host) self.addLink(s68, s68_host) self.addLink(s69, s69_host) self.addLink(s70, s70_host) self.addLink(s71, s71_host) self.addLink(s72, s72_host) self.addLink(s73, s73_host) self.addLink(s74, s74_host) self.addLink(s75, s75_host) self.addLink(s76, s76_host) self.addLink(s77, s77_host) self.addLink(s78, s78_host) #info( '*** Add Leaf links\n') self.addLink(s1, s9) self.addLink(s2, s10) self.addLink(s3, s9) self.addLink(s4, s10) self.addLink(s5, s9) self.addLink(s6, s10) self.addLink(s7, s9) self.addLink(s8, s10) self.addLink(s9, s11) self.addLink(s9, s12) self.addLink(s10, s13) self.addLink(s10, s14) self.addLink(s11, s12) self.addLink(s13, s14) #info( '*** Add Spine-1 links\n') self.addLink(s15, s1) self.addLink(s15, s2) self.addLink(s16, s1) self.addLink(s16, s2) self.addLink(s17, s1) self.addLink(s17, s2) self.addLink(s18, s1) self.addLink(s18, s2) self.addLink(s19, s1) self.addLink(s19, s2) self.addLink(s20, s1) self.addLink(s20, s2) self.addLink(s21, s1) self.addLink(s21, s2) self.addLink(s22, s1) self.addLink(s22, s2) self.addLink(s23, s1) self.addLink(s23, s2) self.addLink(s24, s1) self.addLink(s24, s2) self.addLink(s25, s1) self.addLink(s25, s2) self.addLink(s26, s1) self.addLink(s26, s2) self.addLink(s27, s1) self.addLink(s27, s2) self.addLink(s28, s1) self.addLink(s28, s2) self.addLink(s29, s1) self.addLink(s29, s2) self.addLink(s30, s1) self.addLink(s30, s2) #info( '*** Add Spine-2 links\n') self.addLink(s31, s3) self.addLink(s31, s4) self.addLink(s32, s3) self.addLink(s32, s4) self.addLink(s33, s3) self.addLink(s33, s4) self.addLink(s34, s3) self.addLink(s34, s4) self.addLink(s35, s3) self.addLink(s35, s4) self.addLink(s36, s3) self.addLink(s36, s4) self.addLink(s37, s3) self.addLink(s37, s4) self.addLink(s38, s3) self.addLink(s38, s4) self.addLink(s39, s3) self.addLink(s39, s4) self.addLink(s40, s3) self.addLink(s40, s4) self.addLink(s41, s3) self.addLink(s41, s4) self.addLink(s42, s3) self.addLink(s42, s4) self.addLink(s43, s3) self.addLink(s43, s4) self.addLink(s44, s3) self.addLink(s44, s4) self.addLink(s45, s3) self.addLink(s45, s4) self.addLink(s46, s3) self.addLink(s46, s4) #info( '*** Add Spine-3 links\n') self.addLink(s47, s5) self.addLink(s47, s6) self.addLink(s48, s5) self.addLink(s48, s6) self.addLink(s49, s5) self.addLink(s49, s6) self.addLink(s50, s5) self.addLink(s50, s6) self.addLink(s51, s5) self.addLink(s51, s6) self.addLink(s52, s5) self.addLink(s52, s6) self.addLink(s53, s5) self.addLink(s53, s6) self.addLink(s54, s5) self.addLink(s54, s6) self.addLink(s55, s5) self.addLink(s55, s6) self.addLink(s56, s5) self.addLink(s56, s6) self.addLink(s57, s5) self.addLink(s57, s6) self.addLink(s58, s5) self.addLink(s58, s6) self.addLink(s59, s5) self.addLink(s59, s6) self.addLink(s60, s5) self.addLink(s60, s6) self.addLink(s61, s5) self.addLink(s61, s6) self.addLink(s62, s5) self.addLink(s62, s6) #info( '*** Add Spine-4 links\n') self.addLink(s63, s7) self.addLink(s63, s8) self.addLink(s64, s7) self.addLink(s64, s8) self.addLink(s65, s7) self.addLink(s65, s8) self.addLink(s66, s7) self.addLink(s66, s8) self.addLink(s67, s7) self.addLink(s67, s8) self.addLink(s68, s7) self.addLink(s68, s8) self.addLink(s69, s7) self.addLink(s69, s8) self.addLink(s70, s7) self.addLink(s70, s8) self.addLink(s71, s7) self.addLink(s71, s8) self.addLink(s72, s7) self.addLink(s72, s8) self.addLink(s73, s7) self.addLink(s73, s8) self.addLink(s74, s7) self.addLink(s74, s8) self.addLink(s75, s7) self.addLink(s75, s8) self.addLink(s76, s7) self.addLink(s76, s8) self.addLink(s77, s7) self.addLink(s77, s8) self.addLink(s78, s7) self.addLink(s78, s8)
def __init__(self): Topo.__init__(self) _init(self)
def __init__(self, **opts): Topo.__init__(self, **opts)
def __init__( self, **opts ): "Create a topology." # Initialize Topology Topo.__init__( self, **opts ) # add nodes, switches first... s1 = self.addSwitch( 's1' ) s2 = self.addSwitch( 's2' ) s3 = self.addSwitch( 's3' ) s4 = self.addSwitch( 's4' ) s5 = self.addSwitch( 's5' ) s6 = self.addSwitch( 's6' ) s7 = self.addSwitch( 's7' ) s8 = self.addSwitch( 's8' ) s9 = self.addSwitch( 's9' ) s10 = self.addSwitch( 's10' ) s11 = self.addSwitch( 's11' ) s12 = self.addSwitch( 's12' ) s13 = self.addSwitch( 's13' ) s14 = self.addSwitch( 's14' ) s15 = self.addSwitch( 's15' ) s16 = self.addSwitch( 's16' ) s17 = self.addSwitch( 's17' ) s18 = self.addSwitch( 's18' ) s19 = self.addSwitch( 's19' ) s20 = self.addSwitch( 's20' ) s21 = self.addSwitch( 's21' ) s22 = self.addSwitch( 's22' ) s23 = self.addSwitch( 's23' ) s24 = self.addSwitch( 's24' ) s25 = self.addSwitch( 's25' ) # ... and now hosts s1_host = self.addHost( 'h1' ) s2_host = self.addHost( 'h2' ) s3_host = self.addHost( 'h3' ) s4_host = self.addHost( 'h4' ) s5_host = self.addHost( 'h5' ) s6_host = self.addHost( 'h6' ) s7_host = self.addHost( 'h7' ) s8_host = self.addHost( 'h8' ) s9_host = self.addHost( 'h9' ) s10_host = self.addHost( 'h10' ) s11_host = self.addHost( 'h11' ) s12_host = self.addHost( 'h12' ) s13_host = self.addHost( 'h13' ) s14_host = self.addHost( 'h14' ) s15_host = self.addHost( 'h15' ) s16_host = self.addHost( 'h16' ) s17_host = self.addHost( 'h17' ) s18_host = self.addHost( 'h18' ) s19_host = self.addHost( 'h19' ) s20_host = self.addHost( 'h20' ) s21_host = self.addHost( 'h21' ) s22_host = self.addHost( 'h22' ) s23_host = self.addHost( 'h23' ) s24_host = self.addHost( 'h24' ) s25_host = self.addHost( 'h25' ) # add edges between switch and corresponding host self.addLink( s1 , s1_host ) self.addLink( s2 , s2_host ) self.addLink( s3 , s3_host ) self.addLink( s4 , s4_host ) self.addLink( s5 , s5_host ) self.addLink( s6 , s6_host ) self.addLink( s7 , s7_host ) self.addLink( s8 , s8_host ) self.addLink( s9 , s9_host ) self.addLink( s10 , s10_host ) self.addLink( s11 , s11_host ) self.addLink( s12 , s12_host ) self.addLink( s13 , s13_host ) self.addLink( s14 , s14_host ) self.addLink( s15 , s15_host ) self.addLink( s16 , s16_host ) self.addLink( s17 , s17_host ) self.addLink( s18 , s18_host ) self.addLink( s19 , s19_host ) self.addLink( s20 , s20_host ) self.addLink( s21 , s21_host ) self.addLink( s22 , s22_host ) self.addLink( s23 , s23_host ) self.addLink( s24 , s24_host ) self.addLink( s25 , s25_host ) self.addLink(s1, s2) self.addLink(s1, s3) self.addLink(s1, s4) self.addLink(s1, s5) self.addLink(s1, s6) self.addLink(s1, s7) self.addLink(s1, s8) self.addLink(s1, s9) self.addLink(s1, s10) self.addLink(s1, s11) self.addLink(s1, s12) self.addLink(s1, s13) self.addLink(s1, s14) self.addLink(s1, s15) self.addLink(s1, s16) self.addLink(s1, s17) self.addLink(s1, s18) self.addLink(s1, s19) self.addLink(s1, s20) self.addLink(s1, s21) self.addLink(s1, s22) self.addLink(s1, s23) self.addLink(s1, s24) self.addLink(s1, s25) self.addLink(s2, s3) self.addLink(s2, s4) self.addLink(s2, s5) self.addLink(s2, s6) self.addLink(s2, s7) self.addLink(s2, s8) self.addLink(s2, s9) self.addLink(s2, s10) self.addLink(s2, s11) self.addLink(s2, s12) self.addLink(s2, s13) self.addLink(s2, s14) self.addLink(s2, s15) self.addLink(s2, s16) self.addLink(s2, s17) self.addLink(s2, s18) self.addLink(s2, s19) self.addLink(s2, s20) self.addLink(s2, s21) self.addLink(s2, s22) self.addLink(s2, s23) self.addLink(s2, s24) self.addLink(s2, s25) self.addLink(s3, s4) self.addLink(s3, s5) self.addLink(s3, s6) self.addLink(s3, s7) self.addLink(s3, s8) self.addLink(s3, s9) self.addLink(s3, s10) self.addLink(s3, s11) self.addLink(s3, s12) self.addLink(s3, s13) self.addLink(s3, s14) self.addLink(s3, s15) self.addLink(s3, s16) self.addLink(s3, s17) self.addLink(s3, s18) self.addLink(s3, s19) self.addLink(s3, s20) self.addLink(s3, s21) self.addLink(s3, s22) self.addLink(s3, s23) self.addLink(s3, s24) self.addLink(s3, s25) self.addLink(s4, s5) self.addLink(s4, s6) self.addLink(s4, s7) self.addLink(s4, s8) self.addLink(s4, s9) self.addLink(s4, s10) self.addLink(s4, s11) self.addLink(s4, s12) self.addLink(s4, s13) self.addLink(s4, s14) self.addLink(s4, s15) self.addLink(s4, s16) self.addLink(s4, s17) self.addLink(s4, s18) self.addLink(s4, s19) self.addLink(s4, s20) self.addLink(s4, s21) self.addLink(s4, s22) self.addLink(s4, s23) self.addLink(s4, s24) self.addLink(s4, s25) self.addLink(s5, s6) self.addLink(s5, s7) self.addLink(s5, s8) self.addLink(s5, s9) self.addLink(s5, s10) self.addLink(s5, s11) self.addLink(s5, s12) self.addLink(s5, s13) self.addLink(s5, s14) self.addLink(s5, s15) self.addLink(s5, s16) self.addLink(s5, s17) self.addLink(s5, s18) self.addLink(s5, s19) self.addLink(s5, s20) self.addLink(s5, s21) self.addLink(s5, s22) self.addLink(s5, s23) self.addLink(s5, s24) self.addLink(s5, s25) self.addLink(s6, s7) self.addLink(s6, s8) self.addLink(s6, s9) self.addLink(s6, s10) self.addLink(s6, s11) self.addLink(s6, s12) self.addLink(s6, s13) self.addLink(s6, s14) self.addLink(s6, s15) self.addLink(s6, s16) self.addLink(s6, s17) self.addLink(s6, s18) self.addLink(s6, s19) self.addLink(s6, s20) self.addLink(s6, s21) self.addLink(s6, s22) self.addLink(s6, s23) self.addLink(s6, s24) self.addLink(s6, s25) self.addLink(s7, s8) self.addLink(s7, s9) self.addLink(s7, s10) self.addLink(s7, s11) self.addLink(s7, s12) self.addLink(s7, s13) self.addLink(s7, s14) self.addLink(s7, s15) self.addLink(s7, s16) self.addLink(s7, s17) self.addLink(s7, s18) self.addLink(s7, s19) self.addLink(s7, s20) self.addLink(s7, s21) self.addLink(s7, s22) self.addLink(s7, s23) self.addLink(s7, s24) self.addLink(s7, s25) self.addLink(s8, s9) self.addLink(s8, s10) self.addLink(s8, s11) self.addLink(s8, s12) self.addLink(s8, s13) self.addLink(s8, s14) self.addLink(s8, s15) self.addLink(s8, s16) self.addLink(s8, s17) self.addLink(s8, s18) self.addLink(s8, s19) self.addLink(s8, s20) self.addLink(s8, s21) self.addLink(s8, s22) self.addLink(s8, s23) self.addLink(s8, s24) self.addLink(s8, s25) self.addLink(s9, s10) self.addLink(s9, s11) self.addLink(s9, s12) self.addLink(s9, s13) self.addLink(s9, s14) self.addLink(s9, s15) self.addLink(s9, s16) self.addLink(s9, s17) self.addLink(s9, s18) self.addLink(s9, s19) self.addLink(s9, s20) self.addLink(s9, s21) self.addLink(s9, s22) self.addLink(s9, s23) self.addLink(s9, s24) self.addLink(s9, s25) self.addLink(s10, s11) self.addLink(s10, s12) self.addLink(s10, s13) self.addLink(s10, s14) self.addLink(s10, s15) self.addLink(s10, s16) self.addLink(s10, s17) self.addLink(s10, s18) self.addLink(s10, s19) self.addLink(s10, s20) self.addLink(s10, s21) self.addLink(s10, s22) self.addLink(s10, s23) self.addLink(s10, s24) self.addLink(s10, s25) self.addLink(s11, s12) self.addLink(s11, s13) self.addLink(s11, s14) self.addLink(s11, s15) self.addLink(s11, s16) self.addLink(s11, s17) self.addLink(s11, s18) self.addLink(s11, s19) self.addLink(s11, s20) self.addLink(s11, s21) self.addLink(s11, s22) self.addLink(s11, s23) self.addLink(s11, s24) self.addLink(s11, s25) self.addLink(s12, s13) self.addLink(s12, s14) self.addLink(s12, s15) self.addLink(s12, s16) self.addLink(s12, s17) self.addLink(s12, s18) self.addLink(s12, s19) self.addLink(s12, s20) self.addLink(s12, s21) self.addLink(s12, s22) self.addLink(s12, s23) self.addLink(s12, s24) self.addLink(s12, s25) self.addLink(s13, s14) self.addLink(s13, s15) self.addLink(s13, s16) self.addLink(s13, s17) self.addLink(s13, s18) self.addLink(s13, s19) self.addLink(s13, s20) self.addLink(s13, s21) self.addLink(s13, s22) self.addLink(s13, s23) self.addLink(s13, s24) self.addLink(s13, s25) self.addLink(s14, s15) self.addLink(s14, s16) self.addLink(s14, s17) self.addLink(s14, s18) self.addLink(s14, s19) self.addLink(s14, s20) self.addLink(s14, s21) self.addLink(s14, s22) self.addLink(s14, s23) self.addLink(s14, s24) self.addLink(s14, s25) self.addLink(s15, s16) self.addLink(s15, s17) self.addLink(s15, s18) self.addLink(s15, s19) self.addLink(s15, s20) self.addLink(s15, s21) self.addLink(s15, s22) self.addLink(s15, s23) self.addLink(s15, s24) self.addLink(s15, s25) self.addLink(s16, s17) self.addLink(s16, s18) self.addLink(s16, s19) self.addLink(s16, s20) self.addLink(s16, s21) self.addLink(s16, s22) self.addLink(s16, s23) self.addLink(s16, s24) self.addLink(s16, s25) self.addLink(s17, s18) self.addLink(s17, s19) self.addLink(s17, s20) self.addLink(s17, s21) self.addLink(s17, s22) self.addLink(s17, s23) self.addLink(s17, s24) self.addLink(s17, s25) self.addLink(s18, s19) self.addLink(s18, s20) self.addLink(s18, s21) self.addLink(s18, s22) self.addLink(s18, s23) self.addLink(s18, s24) self.addLink(s18, s25) self.addLink(s19, s20) self.addLink(s19, s21) self.addLink(s19, s22) self.addLink(s19, s23) self.addLink(s19, s24) self.addLink(s19, s25) self.addLink(s20, s21) self.addLink(s20, s22) self.addLink(s20, s23) self.addLink(s20, s24) self.addLink(s20, s25) self.addLink(s21, s22) self.addLink(s21, s23) self.addLink(s21, s24) self.addLink(s21, s25) self.addLink(s22, s23) self.addLink(s22, s24) self.addLink(s22, s25) self.addLink(s23, s24) self.addLink(s23, s25) self.addLink(s24, s25)
def __init__(self, sw_path, json_path, thrift_port, pcap_dump, **opts): # initialize topology and default options Topo.__init__(self, **opts) # implement several switches s1 = self.addSwitch('s1', sw_path=sw_path, json_path=json_path, thrift_port=thrift_port, pcap_dump=pcap_dump, enable_debugger=True) s2 = self.addSwitch('s2', sw_path=sw_path, json_path=json_path, thrift_port=thrift_port + 1, pcap_dump=pcap_dump, enable_debugger=True) s3 = self.addSwitch('s3', sw_path=sw_path, json_path=json_path, thrift_port=thrift_port + 2, pcap_dump=pcap_dump, enable_debugger=True) # Create hosts h1 = self.addHost('h1', ip="10.0.1.10/24", mac='00:04:00:00:00:01') h2 = self.addHost('h2', ip="10.0.2.10/24", mac='00:04:00:00:00:02') h3 = self.addHost('h3', ip="10.0.3.10/24", mac='00:04:00:00:00:03') # Create links self.addLink(h1, s1, addr1='00:04:00:00:00:01', addr2='00:aa:bb:00:01:01', intfName1="eth0", intfName2="s1-eth1") self.addLink(h2, s2, addr1='00:04:00:00:00:02', addr2='00:aa:bb:00:02:02', intfName1="eth0", intfName2="s2-eth1") self.addLink(h3, s3, addr1='00:04:00:00:00:03', addr2='00:aa:bb:00:03:03', intfName1="eth0", intfName2="s3-eth1") self.addLink(s1, s2, addr1='00:aa:bb:00:01:02', addr2='00:aa:bb:00:02:01', intfName1="s1-eth2", intfName2="s2-eth2") self.addLink(s2, s3, addr1='00:aa:bb:00:02:03', addr2='00:aa:bb:00:03:02', intfName1="s2-eth3", intfName2="s3-eth2") self.addLink(s3, s1, addr1='00:aa:bb:00:03:01', addr2='00:aa:bb:00:01:03', intfName1="s3-eth3", intfName2="s1-eth3")
def __init__(self): Topo.__init__(self) h1 = self.addHost('h1') h2 = self.addHost('h2') h3 = self.addHost('h3') h4 = self.addHost('h4') h5 = self.addHost('h5') h6 = self.addHost('h6') h7 = self.addHost('h7') h8 = self.addHost('h8') h9 = self.addHost('h9') h10 = self.addHost('h10') h11 = self.addHost('h11') h12 = self.addHost('h12') h13 = self.addHost('h13') h14 = self.addHost('h14') h15 = self.addHost('h15') h16 = self.addHost('h16') s1 = self.addSwitch('s1') s2 = self.addSwitch('s2') s3 = self.addSwitch('s3') s4 = self.addSwitch('s4') s5 = self.addSwitch('s5') s6 = self.addSwitch('s6') s7 = self.addSwitch('s7') s8 = self.addSwitch('s8') s9 = self.addSwitch('s9') s10 = self.addSwitch('s10') s11 = self.addSwitch('s11') s12 = self.addSwitch('s12') s13 = self.addSwitch('s13') s14 = self.addSwitch('s14') s15 = self.addSwitch('s15') s16 = self.addSwitch('s16') self.addLink(s1, s2) self.addLink(s2, s3) self.addLink(s3, s4) self.addLink(s4, s5) self.addLink(s5, s6) self.addLink(s6, s7) self.addLink(s7, s8) self.addLink(s8, s9) self.addLink(s9, s10) self.addLink(s10, s11) self.addLink(s11, s12) self.addLink(s12, s13) self.addLink(s13, s14) self.addLink(s14, s15) self.addLink(s15, s16) self.addLink(s1, h1) self.addLink(s2, h2) self.addLink(s3, h3) self.addLink(s4, h4) self.addLink(s5, h5) self.addLink(s6, h6) self.addLink(s7, h7) self.addLink(s8, h8) self.addLink(s9, h9) self.addLink(s10, h10) self.addLink(s11, h11) self.addLink(s12, h12) self.addLink(s13, h13) self.addLink(s14, h14) self.addLink(s15, h15) self.addLink(s16, h16)
def __init__(self): "Create custom topo." # Initialize topology Topo.__init__(self) # Add hosts and switches leftTopHost = self.addHost('hl1') leftMidHost = self.addHost('hl2') leftBotHost = self.addHost('hl3') rightTopHost = self.addHost('hr1') rightMidHost = self.addHost('hr2') rightBotHost = self.addHost('hr3') leftTopSwitch = self.addSwitch('s11') leftMidSwitch = self.addSwitch('s12') leftBotSwitch = self.addSwitch('s13') midTopSwitch = self.addSwitch('s21') midMidSwitch = self.addSwitch('s22') midBotSwitch = self.addSwitch('s23') rightTopSwitch = self.addSwitch('s31') rightMidSwitch = self.addSwitch('s32') rightBotSwitch = self.addSwitch('s33') # Add links self.addLink(leftTopHost, leftTopSwitch) self.addLink(leftMidHost, leftMidSwitch) self.addLink(leftBotHost, leftBotSwitch) self.addLink(rightTopHost, rightTopSwitch) self.addLink(rightMidHost, rightMidSwitch) self.addLink(rightBotHost, rightBotSwitch) self.addLink(leftTopSwitch, midTopSwitch) self.addLink(leftMidSwitch, midTopSwitch) self.addLink(leftBotSwitch, midTopSwitch) self.addLink(leftTopSwitch, midMidSwitch) self.addLink(leftMidSwitch, midMidSwitch) self.addLink(leftBotSwitch, midMidSwitch) self.addLink(leftTopSwitch, midBotSwitch) self.addLink(leftMidSwitch, midBotSwitch) self.addLink(leftBotSwitch, midBotSwitch) self.addLink(leftTopSwitch, leftMidSwitch) self.addLink(leftMidSwitch, leftBotSwitch) self.addLink(leftTopSwitch, leftBotSwitch) self.addLink(rightTopSwitch, rightMidSwitch) self.addLink(rightMidSwitch, rightBotSwitch) self.addLink(rightTopSwitch, rightBotSwitch) self.addLink(rightTopSwitch, midTopSwitch) self.addLink(rightMidSwitch, midTopSwitch) self.addLink(rightBotSwitch, midTopSwitch) self.addLink(rightTopSwitch, midMidSwitch) self.addLink(rightMidSwitch, midMidSwitch) self.addLink(rightBotSwitch, midMidSwitch) self.addLink(rightTopSwitch, midBotSwitch) self.addLink(rightMidSwitch, midBotSwitch) self.addLink(rightBotSwitch, midBotSwitch)
def __init__(self, bw=1, conf={}, **opts): # Init steps Topo.__init__(self, **opts) # Get VNFs mapping vnfs = conf['vnfs'] # We are going to use bw constrained links linkopts = dict( bw=bw ) # Create subnetting objects for assigning data plane addresses dataPlaneSpace = unicode('2001::0/%d' % DP_SPACE) dataPlaneNets = list(IPv6Network(dataPlaneSpace).subnets(new_prefix=DP_MASK)) # Create subnetting objects for assigning mgmt plane addresses mgmtPlaneSpace = unicode('2000::0/%d' % MGMT_MASK) mgmtPlaneNet = list(IPv6Network(mgmtPlaneSpace).subnets(new_prefix=MGMT_MASK))[0] mgmtPlaneHosts = mgmtPlaneNet.hosts() # Define the switches representing the cities routers = ['nyc', 'chi', 'wdc', 'sea', 'sun', 'lan', 'den', 'kan', 'hou', 'atl', 'ind'] # Define the host/servers representing the cities hosts = ['hnyc', 'hchi', 'hwdc', 'hsea', 'hsun', 'hlan', 'hden', 'hkan', 'hhou', 'hatl', 'hind'] # Define the edge links connecting hosts and switches edge_links = [('nyc', 'hnyc'), ('chi', 'hchi'), ('wdc', 'hwdc'), ('sea', 'hsea'), ('sun', 'hsun'), ('lan', 'hlan'), ('den', 'hden'), ('kan', 'hkan'), ('hou', 'hhou'), ('atl', 'hatl'), ('ind', 'hind')] # Define the core links connecting switches core_links = [('nyc', 'chi'), ('nyc', 'wdc'), ('chi', 'ind'), ('wdc', 'atl'), ('sea', 'sun'), ('sea', 'den'), ('sun', 'lan'), ('sun', 'den'), ('lan', 'hou'), ('den', 'kan'), ('kan', 'hou'), ('kan', 'ind'), ('hou', 'atl'), ('atl', 'ind')] # Iterate on the switches and generate them for router in routers: # Assign mgmt plane IP mgmtIP = mgmtPlaneHosts.next() # Add the router to the topology self.addHost( name=router, cls=IPHost, sshd=True, mgmtip="%s/%s" %(mgmtIP, MGMT_MASK), vnfips=[] ) # Save mapping node to mgmt node_to_mgmt[router] = str(mgmtIP) # Add node to the topology graph topology.add_node(router, mgmtip="%s/%s" %(mgmtIP, MGMT_MASK), type="router", group=200) # Create the mgmt switch br_mgmt = self.addSwitch('br-mgmt1', cls=OVSBridge) # Iterate on the switches and generate them for host in hosts: # Define host group group = 100 # Get the assinged vnfs host_vnfs = vnfs[host] # Create an empty list vnfips = [] # If the host has assigned vnfs if host_vnfs > 0: # Update group group = host_vnfs # Assign a data-plane net to the host net = dataPlaneNets.pop(0) # Get hosts iterator host_ips = net.hosts() # Iterate over the number of vnfs for index in range(host_vnfs): # Add the ip to the set vnfips.append("%s/%d" %(host_ips.next().exploded, VNF_MASK)) # Save the destination subnets_to_via[str(net.exploded)].append(host) # Save the mapping nodes to vnfs nodes_to_vnfs[host] = vnfips # Assign mgmt plane IP mgmtIP = mgmtPlaneHosts.next() # Add the router to the topology self.addHost( name=host, cls=IPHost, sshd=True, mgmtip="%s/%s" %(mgmtIP, MGMT_MASK), vnfips=vnfips ) # Save mapping node to mgmt node_to_mgmt[host] = str(mgmtIP) # Add node to the topology graph topology.add_node(host, mgmtip="%s/%s" %(mgmtIP, MGMT_MASK), type="server", group=group) # Assign the mgmt ip to the mgmt station mgmtIP = mgmtPlaneHosts.next() # Mgmt name mgmt ='mgt' # Create the mgmt node in the root namespace self.addHost( name=mgmt, cls=IPHost, sshd=False, mgmtip="%s/%s" %(mgmtIP, MGMT_MASK), inNamespace=False ) # Save mapping node to mgmt node_to_mgmt[mgmt] = str(mgmtIP) # Store mgmt in hosts hosts.append(mgmt) # Connect all the routers to the management network for router in routers: # Create a link between mgmt switch and the router self.addLink(router, br_mgmt, **linkopts ) portNumber = self.port(router, br_mgmt) # Connect all the hosts/servers to the management network for host in hosts: # Create a link between mgmt switch and the host self.addLink(host, br_mgmt, **linkopts ) portNumber = self.port(host, br_mgmt) # Iterate over the edge links and generate them for edge_link in edge_links: # The router is the left hand side of the pair router = edge_link[0] # The host is the right hand side of the pair host = edge_link[1] # Create the edge link self.addLink(router, host, **linkopts) # Get Port number portNumber = self.port(router, host) # Create lhs_intf lhs_intf = "%s-eth%d" %(router, portNumber[0]) # Create rhs_intf rhs_intf = "%s-eth%d" %(host, portNumber[1]) # Assign a data-plane net to this link net = dataPlaneNets.pop(0) # Get hosts on this subnet host_ips = net.hosts() # Get the default via default_via = "%s/%d" %(host_ips.next().exploded, DP_MASK) # Get the host ip host_ip = "%s/%d" %(host_ips.next().exploded, DP_MASK) # Map lhs_intf to ip interfaces_to_ip[lhs_intf] = default_via # Map rhs_intf to ip interfaces_to_ip[rhs_intf] = host_ip # Map host to default via host_to_default_via[host] = default_via # Add edge to the topology topology.add_edge(router, host, lhs_intf=lhs_intf, rhs_intf=rhs_intf, lhs_ip=default_via, rhs_ip=host_ip) # Add reverse edge to the topology topology.add_edge(host, router, lhs_intf=rhs_intf, rhs_intf=lhs_intf, lhs_ip=host_ip, rhs_ip=default_via) # Map subnets to router subnets_to_via[str(net.exploded)].append(router) # Map subnets to router subnets_to_via[str(net.exploded)].append(host) # Iterate over the core links and generate them for core_link in core_links: # Get the left hand side of the pair lhs = core_link[0] # Get the right hand side of the pair rhs = core_link[1] # Create the core link self.addLink(lhs, rhs, **linkopts ) # Get Port number portNumber = self.port(lhs, rhs) # Create lhs_intf lhs_intf = "%s-eth%d" %(lhs, portNumber[0]) # Create rhs_intf rhs_intf = "%s-eth%d" %(rhs, portNumber[1]) # Assign a data-plane net to this link net = dataPlaneNets.pop(0) # Get hosts on this subnet host_ips = net.hosts() # Get lhs_ip lhs_ip = "%s/%d" %(host_ips.next().exploded, DP_MASK) # Get rhs_ip rhs_ip = "%s/%d" %(host_ips.next().exploded, DP_MASK) # Map lhs_intf to ip interfaces_to_ip[lhs_intf] = lhs_ip # Map rhs_intf to ip interfaces_to_ip[rhs_intf] = rhs_ip # Add edge to the topology topology.add_edge(lhs, rhs, lhs_intf=lhs_intf, rhs_intf=rhs_intf, lhs_ip=lhs_ip, rhs_ip=rhs_ip) # Add the reverse edge to the topology topology.add_edge(rhs, lhs, lhs_intf=rhs_intf, rhs_intf=lhs_intf, lhs_ip=rhs_ip, rhs_ip=lhs_ip) # Map subnet to lhs subnets_to_via[str(net.exploded)].append(lhs) # Map subnet to rhs subnets_to_via[str(net.exploded)].append(rhs)
def __init__(self, links, latencies={}, manifest=None, target=None, **opts): Topo.__init__(self, **opts) nodes = sum(map(list, zip(*links)), []) host_names = sorted(list(set(filter(lambda n: n[0] == 'h', nodes)))) sw_names = sorted(list(set(filter(lambda n: n[0] == 's', nodes)))) sw_ports = dict([(sw, []) for sw in sw_names]) self._host_links = {} self._sw_links = dict([(sw, {}) for sw in sw_names]) for sw_name in sw_names: self.addSwitch(sw_name) for host_name in host_names: host_num = int(host_name[1:]) host_ip = "10.0.%d.10" % host_num host_mac = '00:04:00:00:00:%02x' % host_num self.addHost(host_name) self._host_links[host_name] = {} host_links = filter( lambda l: l[0] == host_name or l[1] == host_name, links) sw_idx = 0 for link in host_links: sw = link[0] if link[0] != host_name else link[1] sw_num = int(sw[1:]) assert sw[ 0] == 's', "Hosts should be connected to switches, not " + str( sw) delay_key = ''.join([host_name, sw]) delay = latencies[ delay_key] if delay_key in latencies else '0ms' sw_ports[sw].append(host_name) self._host_links[host_name][sw] = dict( idx=sw_idx, host_mac=host_mac, host_ip=host_ip, sw=sw, sw_mac="00:aa:00:%02x:00:%02x" % (sw_num, host_num), sw_ip="10.0.%d.%d" % (host_num, sw_idx + 1), sw_port=sw_ports[sw].index(host_name) + 1) self.addLink(host_name, sw, delay=delay, addr1=host_mac, addr2=self._host_links[host_name][sw]['sw_mac']) sw_idx += 1 for link in links: # only check switch-switch links sw1, sw2 = link if sw1[0] != 's' or sw2[0] != 's': continue delay_key = ''.join(sorted([host_name, sw])) delay = latencies[delay_key] if delay_key in latencies else '0ms' self.addLink(sw1, sw2, delay=delay) sw_ports[sw1].append(sw2) sw_ports[sw2].append(sw1) sw1_num, sw2_num = int(sw1[1:]), int(sw2[1:]) sw1_port = dict(mac="00:aa:00:%02x:%02x:00" % (sw1_num, sw2_num), port=sw_ports[sw1].index(sw2) + 1) sw2_port = dict(mac="00:aa:00:%02x:%02x:00" % (sw2_num, sw1_num), port=sw_ports[sw2].index(sw1) + 1) self._sw_links[sw1][sw2] = [sw1_port, sw2_port] self._sw_links[sw2][sw1] = [sw2_port, sw1_port]
def __init__( self, onoses, **kwargs ): Topo.__init__( self, **kwargs ) coreMesh = [] # Create first 4 switches for i in range( 1, 5 ): coreMesh.append( self.addSwitch( 's%s' %i ) ) # create full mesh between middle 4 switches remaining = list( coreMesh ) while True: first = remaining[ 0 ] for switch in tuple( remaining ): if switch is not first: self.addLink( switch, first ) remaining.remove( first ) if not remaining: break # Add more switches s5 = self.addSwitch( 's5', dpid='00:00:00:00:00:00:00:05' ) s6 = self.addSwitch( 's6', dpid='00:00:00:00:00:00:00:06' ) s7 = self.addSwitch( 's7', dpid='00:00:00:00:00:00:00:07' ) s8 = self.addSwitch( 's8', dpid='00:00:00:00:00:00:00:08' ) s9 = self.addSwitch( 's9', dpid='00:00:00:00:00:00:00:09' ) s10 = self.addSwitch( 's10', dpid='00:00:00:00:00:00:00:0A' ) # Add more links self.addLink( s5, s6 ) self.addLink( s5, s8 ) self.addLink( s6, s7 ) self.addLink( s8, s9 ) self.addLink( s9, s10 ) self.addLink( coreMesh[ 0 ], s5 ) self.addLink( coreMesh[ 0 ], s6 ) self.addLink( coreMesh[ 0 ], s7 ) self.addLink( coreMesh[ 1 ], s8 ) self.addLink( coreMesh[ 1 ], s9 ) self.addLink( coreMesh[ 1 ], s10 ) self.addLink( coreMesh[ 2 ], s7 ) self.addLink( coreMesh[ 3 ], s10 ) # SDN AS sdnAs = SdnAutonomousSystem(onoses, numBgpSpeakers=3, asNum=65000, externalOnos=True) cs0 = self.addSwitch('cs0', cls=OVSBridge) numRoutesPerAs = 32 # Add external ASes as1 = BasicAutonomousSystem(1, generateRoutes(u'192.168.1.0/24', numRoutesPerAs)) AutonomousSystem.addPeering(as1, sdnAs) AutonomousSystem.addPeering(as1, sdnAs, router2=3, intf1=2) as1.addLink(s5) as1.addLink(s6) as1.build(self) as2 = BasicAutonomousSystem(2, generateRoutes(u'192.168.2.0/24', numRoutesPerAs)) AutonomousSystem.addPeering(as2, sdnAs) AutonomousSystem.addPeering(as2, sdnAs, router2=2) as2.addLink(s7) as2.build(self) as3 = BasicAutonomousSystem(3, generateRoutes(u'192.168.3.0/24', numRoutesPerAs)) AutonomousSystem.addPeering(as3, sdnAs, router2=2) AutonomousSystem.addPeering(as3, sdnAs, router2=3) as3.addLink(s8) as3.build(self) as4 = BasicAutonomousSystem(4, generateRoutes(u'192.168.4.0/24', numRoutesPerAs), numRouters=2) AutonomousSystem.addPeering(as4, sdnAs) AutonomousSystem.addPeering(as4, sdnAs, router1=2, router2=3) as4.addLink(s9) as4.addLink(s10, router=2) as4.build(self) # add links between nets #self.addLink( BGP1, coreMesh[ 0 ], port2=10 ) #self.addLink( BGP2, coreMesh[ 1 ], port2=10 ) #self.addLink( BGP3, coreMesh[ 2 ], port2=10 ) sdnAs.build(self, coreMesh[ 0 ], cs0)
def __init__(self, links, latencies, log_dir="/tmp", bws=None, **opts): Topo.__init__(self, **opts) nodes = sum(map(list, zip(*links)), []) host_names = sorted(list(set(filter(lambda n: n[0] == 'h', nodes)))) sw_names = sorted(list(set(filter(lambda n: n[0] == 's', nodes)))) sw_ports = dict([(sw, []) for sw in sw_names]) self.host_links = dict() self.sw_links = dict([(sw, {}) for sw in sw_names]) for sw_name in sw_names: self.addSwitch(sw_name, log_file="%s/%s.log" % (log_dir, sw_name)) for host_name in host_names: host_num = int(host_name[1:]) self.addHost(host_name) self.host_links[host_name] = {} host_links = filter( lambda l: l[0] == host_name or l[1] == host_name, links) sw_idx = 0 for link in host_links: sw = link[0] if link[0] != host_name else link[1] sw_num = int(sw[1:]) assert sw[0] ==\ 's', "Hosts should be connected to switches, not {}".format(str(sw)) host_ip = "10.0.%d.%d" % (sw_num, host_num) host_mac = '00:00:00:00:%02x:%02x' % (sw_num, host_num) delay_key = ''.join([host_name, sw]) delay = latencies[ delay_key] if delay_key in latencies else '0ms' bw = bws[delay_key] if delay_key in bws else None sw_ports[sw].append(host_name) self.host_links[host_name][sw] = dict( idx=sw_idx, host_mac=host_mac, host_ip=host_ip, sw=sw, sw_mac="00:00:00:00:%02x:%02x" % (sw_num, host_num), sw_ip="10.0.%d.%d" % (sw_num, 254), sw_port=sw_ports[sw].index(host_name) + 1) self.addLink(host_name, sw, delay=delay, bw=bw, addr1=host_mac, addr2=self.host_links[host_name][sw]['sw_mac']) sw_idx += 1 for link in links: # only check switch-switch links sw1, sw2 = link if sw1[0] != 's' or sw2[0] != 's': continue delay_key = ''.join(sorted([sw1, sw2])) delay = latencies[delay_key] if delay_key in latencies else '0ms' bw = bws[delay_key] if delay_key in bws else None self.addLink(sw1, sw2, delay=delay, bw=bw) # , max_queue_size=10) sw_ports[sw1].append(sw2) sw_ports[sw2].append(sw1) sw1_num, sw2_num = int(sw1[1:]), int(sw2[1:]) sw1_port = dict(mac="00:00:00:%02x:%02x:00" % (sw1_num, sw2_num), port=sw_ports[sw1].index(sw2) + 1) sw2_port = dict(mac="00:00:00:%02x:%02x:00" % (sw2_num, sw1_num), port=sw_ports[sw2].index(sw1) + 1) self.sw_links[sw1][sw2] = [sw1_port, sw2_port] self.sw_links[sw2][sw1] = [sw2_port, sw1_port]