Exemplo n.º 1
0
    def __init__(self, enable_all=True):
        "Create custom topo."

        # Add default members to class.
        super(MyTopo, self).__init__()

        # Set Node IDs for hosts and switches
        leftHost = 1
        leftSwitch = 2
        rightSwitch = 3
        rightHost = 4

        # Add nodes
        self.add_node(leftSwitch, Node(is_switch=True))
        self.add_node(rightSwitch, Node(is_switch=True))
        self.add_node(leftHost, Node(is_switch=False))
        self.add_node(rightHost, Node(is_switch=False))

        # Add edges
        self.add_edge(leftHost, leftSwitch)
        self.add_edge(leftSwitch, rightSwitch)
        self.add_edge(rightSwitch, rightHost)

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 2
0
    def buildDCells(self, prefix, l):

        "If level is 0, return create the DCell0"
        if l == 0:
            " Create the DCell0 switch"
            "TODO modularize node creation"
            print prefix
            print " Dcell0 in progress"
            nodes[prefix] = self.getUID(prefix) + 10000
            self.add_node(nodes[prefix], Node(is_switch=True))
            " Create the DCell nodes"
            for i in xrange(0, N):
                newprefix = prefix.__add__((i, ))
                " Converting a host into a host+switch combo to mock routing in hosts in DCell topology "
                nodes[newprefix] = self.getUID(newprefix) + 20000
                self.add_node(nodes[newprefix], Node(is_switch=True))
                self.add_edge(nodes[prefix], nodes[newprefix])
                hosts[newprefix] = self.getUID(newprefix)
                self.add_node(hosts[newprefix], Node(is_switch=False))
                self.add_edge(nodes[newprefix], hosts[newprefix])
                print newprefix
                print " Server in progress"
            return

        "If level not zero, create Gl number of DCell(l-1)s"
        for i in xrange(0, self.getG(l)):
            self.buildDCells(pref.__add__((i, )), l - 1)

        "Connect node[i,j-1] to [j,i]"
        for i in xrange(0, self.getT(l - 1)):
            for j in xrange(i + 1, self.getG(l)):
                self.add_edge(nodes[pref.__add__((i, )).__add__((j - 1, ))],
                              nodes[pref.__add__((j, )).__add__((i, ))])
Exemplo n.º 3
0
    def __init__(self,
                 enable_all=True,
                 testbw=100,
                 lanbw=10,
                 reduce=0,
                 cpu=None):
        "Create custom topo."

        # Add default members to class.
        super(EmulabTopo, self).__init__()

        # hosts
        hosts = ['node-' + c for c in 'ABCDEFGHIJ']
        for host in hosts:
            self.add_node(host, Node(is_switch=False, cpu=cpu))

        # switches
        testsw, lansw = 'testsw', 'lansw'
        self.add_node(testsw, Node(is_switch=True))
        self.add_node(lansw, Node(is_switch=True))

        # Add edges
        for host in hosts:
            self.add_edge(host, lansw, Edge(bw=lanbw))
        bw1 = testbw - reduce if reduce > 0 else testbw
        self.add_edge(hosts[0], testsw, Edge(bw=bw1))
        self.add_edge(hosts[1], testsw, Edge(bw=testbw))
        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 4
0
    def __init__(self, enable_all = True):
        " Create a campus topology."
        super( CampusTopo, self).__init__()

        # Add switches and hosts.
        switches = [1, 2, 3]
        trustedUsers = [101, 102]
        secureServers = [201]
        untrustedUsers = [301, 302, 303]

        for switch in switches:
            self.add_node( switch, Node( is_switch=True ) )
        for host in trustedUsers + secureServers + untrustedUsers:
            self.add_node( host, Node (is_switch=False ) )

        # Add edges.
        self.add_edge( switches[0], switches[1] )
        self.add_edge( switches[0], switches[2] )
        self.add_edge( switches[1], switches[2] )
        for host in trustedUsers:
            self.add_edge( host, switches[0] )
        for host in secureServers:
            self.add_edge( host, switches[1] )
        for host in untrustedUsers:
            self.add_edge( host, switches[2] )

        # Consider all switches and hosts 'on'.
        self.enable_all()
    def __init__(self, N):

        # Add default members to class.
        super(TestTopo, self).__init__()

        # Create switch and host nodes
        hosts = (1, N + 3)
        print "hosts: " + ` hosts `
        switches = range(2, N + 2)
        print "switches: " + ` switches `
        for h in hosts:
            self.add_node(h, Node(is_switch=False))
        for s in switches:
            self.add_node(s, Node(is_switch=True))

        # Wire up switches
        for s in switches[:-1]:
            self.add_edge(s, s + 1)

        # Wire up hosts
        self.add_edge(hosts[0], switches[0])
        self.add_edge(hosts[1], switches[N - 1])

        # Additional switch for loop topology
        self.add_node(N + 4, Node(is_switch=True))
        self.add_edge(N + 4, 2)
        self.add_edge(N + 4, N + 1)

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 6
0
    def __init__(self, e=1, d=4, c=1, b=2, a=2):

        super(HierarchicalTreeTopo, self).__init__()
        self.log = log

        # define node ranges
        self.core = range(1, c + 1)  # c core switches
        self.aggregation = range(c + 1, b + c + 1)  # b aggregation switches
        self.access = range(b + c + 1, a + b + c + 1)  # a access switches
        self.clients = range(a + b + c + 1, (d + 1) * a + b + c +
                             1)  # d*a clients, d per access switch
        self.servers = range((d + 1) * a + b + c + 1, (d + 1) * a + b +
                             (1 + e) * c + 1)  # c*e servers, e per core switch

        log_str = ''.join([
            'Starting HierarchicalTreeTopo with ',
            '%d servers, %d core, %d aggregate, %d access switches, ' %
            (len(self.servers), c, b, a),
            'and %d clients\n' % len(self.clients)
        ])
        if self.log: sys.stderr.write(log_str)

        # add switches
        for cc in self.core:
            self.add_node(cc, Node())
        for bb in self.aggregation:
            self.add_node(bb, Node())
        for aa in self.access:
            self.add_node(aa, Node())

        # add hosts
        for s in self.servers:
            sNode = Node(is_switch=False)
            self.add_node(s, sNode)
        for cl in self.clients:
            self.add_node(cl, Node(is_switch=False))

        # add links
        # server <-> core
        for s in self.servers:
            self.add_edge(s, self.core[(s - self.servers[0]) / e], Edge())

        # core <-> aggregation
        for cc in self.core:
            for bb in self.aggregation:
                self.add_edge(cc, bb, Edge())
        # aggregation <-> access
        for bb in self.aggregation:
            for aa in self.access:
                self.add_edge(bb, aa, Edge())
        # access <-> clients
        for aa in range(len(self.access)):
            sw = self.access[0] + aa
            # Add client to each port on switch
            for dd in range(d):
                cc = self.clients[0] + d * aa + dd
                self.add_edge(sw, cc, Edge())

        self.enable_all()
Exemplo n.º 7
0
    def __init__(self, enable_all=True):
        super(Square, self).__init__()

        # Set Node IDs for Switches
        leftSwitch = 1
        bottomLeftSwitch = 2
        rightSwitch = 3
        bottomRightSwitch = 4

        # Set Node IDs for hosts
        leftTopHost = 5
        rightTopHost = 6
        bottomLeftHost = 7
        bottomRightHost = 8

        switch = Node(is_switch=True)
        host = Node(is_switch=False)

        # Add Nodes
        self.add_node(leftSwitch, switch)
        self.add_node(rightSwitch, switch)
        self.add_node(bottomLeftSwitch, switch)
        self.add_node(bottomRightSwitch, switch)

        self.add_node(leftTopHost, host)
        self.add_node(rightTopHost, host)
        self.add_node(bottomLeftHost, host)
        self.add_node(bottomRightHost, host)

        # Add edges
        self.add_edge(leftTopHost, leftSwitch)
        self.add_edge(rightSwitch, rightTopHost)
        self.add_edge(bottomLeftHost, bottomLeftSwitch)
        self.add_edge(bottomRightSwitch, bottomRightHost)

        self.add_edge(leftSwitch, rightSwitch)
        self.add_edge(bottomLeftSwitch, bottomRightSwitch)
        self.add_edge(rightSwitch, bottomRightSwitch)
        self.add_edge(leftSwitch, bottomLeftSwitch)

        switches = [
            leftSwitch, rightSwitch, bottomLeftSwitch, bottomRightSwitch
        ]

        # Add inter-switch link ports
        self.port(leftSwitch, rightSwitch)
        self.port(leftSwitch, bottomLeftSwitch)
        self.port(rightSwitch, leftSwitch)
        self.port(rightSwitch, bottomRightSwitch)
        self.port(bottomLeftSwitch, leftSwitch)
        self.port(bottomLeftSwitch, bottomRightSwitch)
        self.port(bottomRightSwitch, rightSwitch)
        self.port(bottomRightSwitch, bottomLeftSwitch)

        self.enable_all()
Exemplo n.º 8
0
    def __init__(self, c=1, b=2, a=2):

        super(HierarchicalTopo, self).__init__()
        self.log = log

        # define node ranges
        self.core = range(1, c + 1)  # c core switches
        self.aggregation = range(c + 1, b + c + 1)  # b aggregation switches
        self.access = range(b + c + 1, a + b + c + 1)  # a access switches
        self.servers = range(a + b + c + 1, 3 * a + b + c +
                             1)  # 2*a servers, 2 per access switch
        self.client = 3 * a + b + c + 1  # 1 client

        log_str = ''.join([
            'Starting HierarchicalTopo with ',
            '%d core, %d aggregate, %d access switches, ' % (c, b, a),
            'and %d servers\n' % len(self.servers)
        ])
        if self.log: sys.stderr.write(log_str)

        # add switches
        for cc in self.core:
            self.add_node(cc, Node())
        for bb in self.aggregation:
            self.add_node(bb, Node())
        for aa in self.access:
            self.add_node(aa, Node())

        # add hosts
        self.add_node(self.client, Node(is_switch=False))
        for s in self.servers:
            self.add_node(s, Node(is_switch=False))

        # add links
        # client <-> core
        self.add_edge(self.client, self.core[0], Edge())
        # core <-> aggregation
        for cc in self.core:
            for bb in self.aggregation:
                self.add_edge(cc, bb, Edge())
        # aggregation <-> access
        for bb in self.aggregation:
            for aa in self.access:
                self.add_edge(bb, aa, Edge())
        # access <-> servers
        for aa in range(len(self.access)):
            sw = self.access[0] + aa
            s1 = self.servers[0] + 2 * aa
            s2 = self.servers[0] + 2 * aa + 1
            self.add_edge(sw, s1, Edge())
            self.add_edge(sw, s2, Edge())

        self.enable_all()
    def __init__(self, numEdgeSwitches=4):

        super(FattreeTopology, self).__init__()

        # add switches
        numHosts = 4 * numEdgeSwitches
        numCoreSwitches = 2
        hosts = range(1, numHosts + 1)
        firstSwitch = max(101, numHosts + 1)
        edgeSwitches = range(firstSwitch, numEdgeSwitches + firstSwitch)
        self.edgeSwitches = edgeSwitches
        coreSwitches = range(numEdgeSwitches + firstSwitch,
                             numEdgeSwitches + firstSwitch + numCoreSwitches)
        self.coreSwitches = coreSwitches

        # Add switches
        for s in edgeSwitches:
            self.add_node(s, Node(is_switch=True))

        for s in coreSwitches:
            self.add_node(s, Node(is_switch=True))

        # Add hosts
        for h in hosts:
            self.add_node(h, Node(is_switch=False))

        # Add links
        for h in hosts:
            if h <= 4:
                self.add_edge(h, firstSwitch)
            elif h <= 8:
                self.add_edge(h, firstSwitch + 1)
            elif h <= 12:
                self.add_edge(h, firstSwitch + 2)
            else:
                self.add_edge(h, firstSwitch + 3)

        # Add monitoring host
        # self.add_node(99, Node(is_switch=False))

        for s1 in edgeSwitches:
            if (s1 - firstSwitch) < numEdgeSwitches / 2:
                self.add_edge(s1, coreSwitches[0])
            else:
                self.add_edge(s1, coreSwitches[1])
            # connect monitor to every edge switch
            # self.add_edge(99, s1)

        self.add_edge(coreSwitches[0], coreSwitches[1])

        self.enable_all()
Exemplo n.º 10
0
    def buildBCube(self, prefix, level):
        if level == 0:
            switchPrefix = (level, )
            switchPrefix = switchPrefix.__add__(prefix)
            switchPrefix = switchPrefix.__add__((0, ))
            switches[switchPrefix] = self.getUID(switchPrefix) + 10000
            self.add_node(switches[switchPrefix], Node(is_switch=True))
            print switchPrefix
            print " Level 0 switch created"

            " Hosts creation "
            for i in xrange(0, N):
                hostPrefix = (
                    192,
                    subBCubeCount,
                    subBCubeCountDict[subBCubeCount],
                )
                subBCubeCountDict[
                    subBCubeCount] = subBCubeCountDict[subBCubeCount] + 1
                hosts[hostPrefix] = self.getUID(hostPrefix)
                self.add_node(hosts[hostPrefix], Node(is_switch=False))
                self.add_edge(switches[switchPrefix], hosts[hostPrefix])

            return

        "Create N^level switches"
        for i in xrange(0, pow(N, level)):
            switchPrefix = (level, )
            switchPrefix = switchPrefix.__add__(prefix)
            switchPrefix = switchPrefix.__add__((i, ))
            # print "Creating level " + str(level) + "switch "
            # print switchPrefix
            switches[switchPrefix] = self.getUID(switchPrefix) + 10000
            self.add_node(switches[switchPrefix], Node(is_switch=True))

        " Recursively create lower level BCubes "
        for i in xrange(0, N):
            if level == L:
                global subBCubeCount
                subBCubeCount = subBCubeCount + 1
                subBCubeCountDict[subBCubeCount] = 0
            self.buildBCube(prefix.__add__((i, )), level - 1)

        " Network connections "
        for i in xrange(0, N):
            for j in xrange(0, subBCubeCount):
                for k in xrange(0, pow(N, L), pow(N, level)):
                    lookupPrefix = (level, )
                    lookupPrefix = lookupPrefix.__add__(prefix)
                    lookupPrefix = lookupPrefix.__add__((i, ))
                    self.add_edge(switches[lookupPrefix], hosts[(192, j, k)])
Exemplo n.º 11
0
    def __init__(self, N):

        # Add default members to class.
        super(TestTopo, self).__init__()

        # Create switch and host nodes
        self.add_node(1, Node(is_switch=1))

        for num in range(2, N + 1):
            self.add_node(num, Node(is_switch=1))
            self.add_edge(1, num)
            self.add_node(N + 1 + num, Node(is_switch=0))
            self.add_edge(num, N + 1 + num)

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 12
0
    def finalize(self):
        # make mininet topo
        topo = Topo()
        
        # add nodes
        for x,d in self.nodes(data=True):
            topo.add_node(x,Node(is_switch=d['isSwitch']))
                
        # add links
        for src,dst in self.edges():
            topo.add_edge(src,dst)
            
        # backpatch ports into original graph
        for x in self.nodes():
            self.node[x]['ports'] = {}
            self.node[x]['port'] = {}            
            for y in self.neighbors(x):
                x_port, y_port = topo.port(x,y)
                self.node[x]['ports'][y] = x_port
                # Support indexing in by port to get neighbor switch/port                
                self.node[x]['port'][x_port] = (y, y_port)

        
        topo.enable_all()
        self.topo = topo        
        self.finalized = True
Exemplo n.º 13
0
    def __init__(self, enable_all=True):
        "Create custom topo."

        # Add default members to class.
        super(RFTopo, self).__init__()

        # Set Node IDs for hosts and switches
        h1 = 1
        h2 = 2
        h3 = 3
        h4 = 4
        sA = 5
        sB = 6
        sC = 7
        sD = 8
        sE = 9
        sF = 10

        # Add nodes
        self.add_node(h1, Node(is_switch=False))
        self.add_node(h2, Node(is_switch=False))
        self.add_node(h3, Node(is_switch=False))
        self.add_node(h4, Node(is_switch=False))
        self.add_node(sA, Node(is_switch=True))
        self.add_node(sB, Node(is_switch=True))
        self.add_node(sC, Node(is_switch=True))
        self.add_node(sD, Node(is_switch=True))
        self.add_node(sE, Node(is_switch=True))
        self.add_node(sF, Node(is_switch=True))

        # Add edges
        self.add_edge(h1, sA)
        self.add_edge(h2, sB)
        self.add_edge(h3, sC)
        self.add_edge(h4, sD)
        self.add_edge(sE, sF)
        self.add_edge(sB, sD)
        self.add_edge(sD, sF)
        self.add_edge(sC, sA)
        self.add_edge(sA, sE)
        self.add_edge(sC, sD)
        #	self.add_edge( sE, sD )
        #	self.add_edge( sA, sB )

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 14
0
    def __init__(self, enable_all=True):
        # add default members to class
        super(MyTopo, self).__init__()

        # set host and switch IDs
        h1 = 1
        s2 = 2
        s3 = 3
        s4 = 4
        h5 = 5
        h6 = 6
        h7 = 7

        # add nodes
        self.add_node(h1, Node(is_switch=False))
        self.add_node(s2, Node(is_switch=True))
        self.add_node(s3, Node(is_switch=True))
        self.add_node(s4, Node(is_switch=True))
        self.add_node(h5, Node(is_switch=False))
        self.add_node(h6, Node(is_switch=False))
        self.add_node(h7, Node(is_switch=False))

        # add edges
        self.add_edge(h1, s2)
        self.add_edge(s2, h6)
        self.add_edge(s2, s3, delay=50)
        self.add_edge(s3, s4, delay=100)
        self.add_edge(s4, h7)
        self.add_edge(s4, h5)

        # turn all switches and hosts 'on'
        self.enable_all()
    def __init__(self, numSwitches=6):

        super(WattsStrogatzTopology, self).__init__()

        # add switches
        numHosts = numSwitches
        hosts = range(1, numHosts + 1)
        firstSwitch = max(101, numHosts + 1)
        switches = range(firstSwitch, numSwitches + firstSwitch)

        # Add switches
        for s in switches:
            self.add_node(s, Node(is_switch=True))

        # Add hosts
        for h in hosts:
            self.add_node(h, Node(is_switch=False))

        # Add links
        for h in hosts:
            self.add_edge(h, switches[h - 1])

        rev_switches = list(switches)
        rev_switches.reverse()
        [last] = rev_switches[-1:]
        for s in rev_switches:
            self.add_edge(s, last)
            last = s

        # Add "magic" links

        self.add_edge(101, 103)
        self.add_edge(102, 105)

        # Add monitoring host
        # self.add_node(99, Node(is_switch=False))

        # for s in switches:
        #     self.add_edge(s, 99)

        self.enable_all()
Exemplo n.º 16
0
    def __init__(self, enable_all=True):
        "Create custom topo."
        super(MyTopo, self).__init__()

        #set Node IDs for hosts and switchs
        leftHost1 = 1
        leftHost2 = 2
        leftSwitch = 3
        rightSwitch = 4
        rightHost1 = 5
        rightHost2 = 6

        #Add nodes
        self.add_node(leftSwitch, Node(is_switch=True))
        self.add_node(rightSwitch, Node(is_switch=True))
        self.add_node(leftHost1, Node(is_switch=False))
        self.add_node(rightHost1, Node(is_switch=False))
        self.add_node(leftHost2, Node(is_switch=False))
        self.add_node(rightHost2, Node(is_switch=False))

        #Add edges
        self.add_edge(leftHost1, leftSwitch)
        self.add_edge(leftHost2, leftSwitch)
        self.add_edge(leftSwitch, rightSwitch)
        self.add_edge(rightSwitch, rightHost1)
        self.add_edge(rightSwitch, rightHost2)

        #Consider all switches and host 'on'
        self.enable_all()
    def __init__(self, num_switches=5, seed=100):

        super(WaxmanTopology, self).__init__()

        num_hosts_per_switch = 2
        # Needed so that subsequent calls will generate the same graph
        random.seed(seed)
        num_hosts = num_switches * num_hosts_per_switch
        # build waxman graph
        wax = nx.waxman_graph(num_switches, .9, .9)

        # Add switches
        for s in wax.nodes():
            self.add_node(s + 1, Node(is_switch=True))

        # Add edges
        for s1, s2 in wax.edges():
            print "new edge"
            self.add_edge(s1 + 1, s2 + 1)

        # Add hosts
        hostoffset = num_switches + 2
        for s in wax:
            # Add host
            host_base = num_hosts_per_switch * s + hostoffset
            for host in range(0, num_hosts_per_switch):
                self.add_node(host_base + host, Node(is_switch=False))
                self.add_edge(host_base + host, s + 1)

        # # Globally connected host
        # self.add_host(9999)
        # for switch in wax:
        #     self.add_link(9999, switch)

        # f = open('/home/openflow/workspace/foo.log', 'w')
        # f.write('hosts: %d\n' % len(self.hosts()))
        # f.close()
        # assert(False)
        self.enable_all()
Exemplo n.º 18
0
 def __init__(self,
              islands=2,
              switches_per_island=2,
              hosts_per_sw=1,
              enable_all=True):
     super(Islands, self).__init__()
     nextid = 1
     for i in range(islands):
         thissw = None
         prevsw = None
         for i in range(switches_per_island):
             thissw = nextid
             nextid += 1
             self.add_node(thissw, Node(is_switch=True))
             if prevsw:
                 self.add_edge(prevsw, thissw)
             for i in range(hosts_per_sw):
                 hostid = nextid
                 nextid += 1
                 self.add_node(hostid, Node(is_switch=False))
                 self.add_edge(hostid, thissw)
             prevsw = thissw
     if enable_all:
         self.enable_all()
Exemplo n.º 19
0
    def __init__(self, N):

        # Add default members to class.
        super(LinearTestTopo, self).__init__()

        # Create switch and host nodes
        hosts = range(1, N + 1)
        switches = range(N + 1, N + N)
        for h in hosts:
            self.add_node(h, Node(is_switch=False))
        for s in switches:
            self.add_node(s, Node(is_switch=True))

        # Wire up switches
        for s in switches[:-1]:
            self.add_edge(s, s + 1)

        # Wire up hosts
        self.add_edge(hosts[0], switches[0])
        for h in hosts[1:]:
            self.add_edge(h, h + N - 1)

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 20
0
 def addTree(self, depth, fanout):
     """Add a subtree starting with node n.
        returns: last node added"""
     isSwitch = depth > 0
     if isSwitch:
         num = self.switchNum
         self.switchNum += 1
     else:
         num = self.hostNum
         self.hostNum += 1
     self.add_node(num, Node(is_switch=isSwitch))
     if isSwitch:
         for i in range(0, fanout):
             child = self.addTree(depth - 1, fanout)
             self.add_edge(num, child)
     return num
Exemplo n.º 21
0
    def __init__(self, enable_all=True):
        "Create custom topo : TwoByTwo."

        # Add default members to class.
        super(TwoByTwo, self).__init__()

        # Set Node IDs for hosts and switches
        leftAHost = 1
        leftBHost = 2
        rightCHost = 3
        rightDHost = 4
        leftSwitch = 5
        rightSwitch = 6
        topSwitch = 7

        # Add nodes
        self.add_node(leftSwitch, Node(is_switch=True))
        self.add_node(rightSwitch, Node(is_switch=True))
        self.add_node(topSwitch, Node(is_switch=True))
        self.add_node(leftAHost, Node(is_switch=False))
        self.add_node(leftBHost, Node(is_switch=False))
        self.add_node(rightCHost, Node(is_switch=False))
        self.add_node(rightDHost, Node(is_switch=False))

        # Add edges
        self.add_edge(leftAHost, leftSwitch)
        self.add_edge(leftBHost, leftSwitch)

        self.add_edge(rightSwitch, rightCHost)
        self.add_edge(rightSwitch, rightDHost)

        self.add_edge(leftSwitch, topSwitch)
        self.add_edge(rightSwitch, topSwitch)

        # Consider all switches and hosts 'on'
        self.enable_all()

        # Print out the slice config files for VMOC

        self.generateSliceConfig('S1', None, 101, [1, 4])
        #        self.generateSliceConfig('S2', 'http://localhost:9001', 102, [2, 3])
        self.generateSliceConfig('S2', None, 102, [2, 3])
Exemplo n.º 22
0
    def __init__(self, enable_all=True):
        "Create custom topo."

        # Add default members to class.
        super(MyTopo, self).__init__()

        # Set Node IDs for hosts and switches
        src = 1
        switch0 = 2
        switch1 = 3
        switch2 = 4
        switch3 = 5
        switch4 = 6
        sink = 7

        # Add nodes
        self.add_node(src, Node(is_switch=False))
        self.add_node(switch0, Node(is_switch=True))
        self.add_node(switch1, Node(is_switch=True))
        self.add_node(switch2, Node(is_switch=True))
        self.add_node(switch3, Node(is_switch=True))
        self.add_node(switch4, Node(is_switch=True))
        self.add_node(sink, Node(is_switch=False))

        # Add edges
        self.add_edge(src, switch0)
        self.add_edge(switch0, switch1)
        self.add_edge(switch0, switch2)
        self.add_edge(switch1, switch2)
        self.add_edge(switch1, switch3)
        self.add_edge(switch2, switch4)
        self.add_edge(switch3, switch4)
        self.add_edge(switch4, sink)

        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 23
0
    def __init__( self, enable_all = True ):
        "Create custom topo."

        # Add default members to class.
        super( RFTopo, self ).__init__()

        # Set Node IDs for hosts and switches
        h1 = 1
        h2 = 2
        h3 = 3
        h4 = 4
	h5 = 5
        h6 = 6
        h7 = 7
        h8 = 8
 	h9 = 9
        h10 = 10
        h11 = 11
        h12 = 12
 	h13 = 13
        h14 = 14
        h15 = 15
        h16 = 16
        
	sA = 17
        sB = 18
        sC = 19
        sD = 20
        sE = 21
        sF = 22
        sG = 23
        sH = 24
        sI = 25
        sJ = 26
        sK = 27
        sL = 28
 	sM = 29
        sN = 30
        sO = 31

        sP = 32
        sQ = 33
        sR = 34
        sS = 35
        sT = 36


        # Add nodes
        # Add hosts
        self.add_node( h1, Node( is_switch=False ) )
        self.add_node( h2, Node( is_switch=False ) )
        self.add_node( h3, Node( is_switch=False ) )
        self.add_node( h4, Node( is_switch=False ) )
        self.add_node( h5, Node( is_switch=False ) )
        self.add_node( h6, Node( is_switch=False ) )
        self.add_node( h7, Node( is_switch=False ) )
        self.add_node( h8, Node( is_switch=False ) )
        self.add_node( h9, Node( is_switch=False ) )
        self.add_node( h10, Node( is_switch=False ) )
        self.add_node( h11, Node( is_switch=False ) )
        self.add_node( h12, Node( is_switch=False ) )
        self.add_node( h13, Node( is_switch=False ) )
        self.add_node( h14, Node( is_switch=False ) )
        self.add_node( h15, Node( is_switch=False ) )
        self.add_node( h16, Node( is_switch=False ) )

        self.add_node( sA, Node( is_switch=True ) )
        self.add_node( sB, Node( is_switch=True ) )
        self.add_node( sC, Node( is_switch=True ) )
        self.add_node( sD, Node( is_switch=True ) )
        self.add_node( sE, Node( is_switch=True ) )
        self.add_node( sF, Node( is_switch=True ) )
        self.add_node( sG, Node( is_switch=True ) )
        self.add_node( sH, Node( is_switch=True ) )
        self.add_node( sI, Node( is_switch=True ) )
        self.add_node( sJ, Node( is_switch=True ) )
        self.add_node( sK, Node( is_switch=True ) )
        self.add_node( sL, Node( is_switch=True ) )
        self.add_node( sM, Node( is_switch=True ) )
        self.add_node( sN, Node( is_switch=True ) )
        self.add_node( sO, Node( is_switch=True ) )
        self.add_node( sP, Node( is_switch=True ) )
        self.add_node( sQ, Node( is_switch=True ) )
        self.add_node( sR, Node( is_switch=True ) )
        self.add_node( sS, Node( is_switch=True ) )
        self.add_node( sT, Node( is_switch=True ) )




        # Add edges
        # LEVEL 4
        self.add_edge( h1, sI )
        self.add_edge( h2, sI )
        self.add_edge( h3, sJ )
        self.add_edge( h4, sJ )
        self.add_edge( h5, sK )
        self.add_edge( h6, sK )
        self.add_edge( h7, sL )
        self.add_edge( h8, sL )
        self.add_edge( h9, sM )
        self.add_edge( h10, sM )
        self.add_edge( h11, sN )
        self.add_edge( h12, sN )
        self.add_edge( h13, sO )
        self.add_edge( h14, sO )
        self.add_edge( h15, sP )
        self.add_edge( h16, sP )
           
        # LEVEL 2 TO 3
        self.add_edge( sA, sI )
        self.add_edge( sA, sJ )
        self.add_edge( sB, sI )
        self.add_edge( sB, sJ )
        self.add_edge( sC, sK )
        self.add_edge( sC, sL )
        self.add_edge( sD, sK )
        self.add_edge( sD, sL )
        self.add_edge( sE, sM )
        self.add_edge( sE, sN )
        self.add_edge( sF, sM )
        self.add_edge( sF, sN )
        self.add_edge( sG, sO )
        self.add_edge( sG, sP )
        self.add_edge( sH, sO )
        self.add_edge( sH, sP )
        
        #LEVEL 1 TO 2
        self.add_edge( sQ, sA )
        self.add_edge( sQ, sC )
        self.add_edge( sQ, sE )
        self.add_edge( sQ, sG )
        self.add_edge( sR, sA )
        self.add_edge( sR, sC )
        self.add_edge( sR, sE )
        self.add_edge( sR, sG )
        self.add_edge( sS, sB )
        self.add_edge( sS, sD )
        self.add_edge( sS, sF )
        self.add_edge( sS, sH )
        self.add_edge( sT, sB )
        self.add_edge( sT, sD )
        self.add_edge( sT, sF )
        self.add_edge( sT, sH )



       


        # Consider all switches and hosts 'on'
        self.enable_all()
Exemplo n.º 24
0
    def __init__(self, enable_all=True):
        "Create custom topo"

        super(CustomTopo, self).__init__()

        #Switches
        torswitch1 = 1
        torswitch2 = 2
        torswitch3 = 3
        torswitch4 = 4
        torswitch5 = 5
        torswitch6 = 6
        torswitch7 = 7
        torswitch8 = 8
        torswitch9 = 9
        torswitch10 = 10

        #Nodes
        rack1node1 = 32
        rack1node2 = 33
        rack5node1 = 64
        rack7node1 = 65
        rack8node1 = 66
        rack9node1 = 128
        rack10node1 = 129

        #Add Switches
        self.add_node(torswitch1, Node(is_switch=True))
        self.add_node(torswitch2, Node(is_switch=True))
        self.add_node(torswitch3, Node(is_switch=True))
        self.add_node(torswitch4, Node(is_switch=True))
        self.add_node(torswitch5, Node(is_switch=True))
        self.add_node(torswitch6, Node(is_switch=True))
        self.add_node(torswitch7, Node(is_switch=True))
        self.add_node(torswitch8, Node(is_switch=True))
        self.add_node(torswitch9, Node(is_switch=True))
        self.add_node(torswitch10, Node(is_switch=True))

        #Add Nodes
        self.add_node(rack1node1, Node(is_switch=False))
        self.add_node(rack1node2, Node(is_switch=False))
        self.add_node(rack5node1, Node(is_switch=False))
        self.add_node(rack7node1, Node(is_switch=False))
        self.add_node(rack8node1, Node(is_switch=False))
        self.add_node(rack9node1, Node(is_switch=False))
        self.add_node(rack10node1, Node(is_switch=False))

        #Add Links
        #Rack 1
        self.add_edge(rack1node1, torswitch1)
        self.add_edge(rack1node2, torswitch1)

        #Rack 5
        self.add_edge(rack5node1, torswitch5)

        #Rack 7
        self.add_edge(rack7node1, torswitch7)

        #Rack 8
        self.add_edge(rack8node1, torswitch8)

        #Rack 9
        self.add_edge(rack9node1, torswitch9)

        #Rack 10
        self.add_edge(rack10node1, torswitch10)

        self.add_edge(torswitch1, torswitch2)
        self.add_edge(torswitch1, torswitch3)
        self.add_edge(torswitch2, torswitch4)
        self.add_edge(torswitch2, torswitch5)
        self.add_edge(torswitch3, torswitch4)
        self.add_edge(torswitch4, torswitch5)
        self.add_edge(torswitch4, torswitch6)
        self.add_edge(torswitch5, torswitch9)
        self.add_edge(torswitch6, torswitch7)
        self.add_edge(torswitch6, torswitch8)
        self.add_edge(torswitch6, torswitch10)
        self.add_edge(torswitch9, torswitch10)

        self.enable_all()
Exemplo n.º 25
0
    def __init__( self, enable_all = True ):
        # Add default members to class.
        super( FoursTopo, self ).__init__()

        # Set Node IDs for switches
        leftSwitch = 1
        bottomLeftSwitch = 2
        rightSwitch = 3
        bottomRightSwitch = 4
        
        #Set Node IDs for hosts
        leftTopHost = 5
        rightTopHost = 6
        bottomLeftHost = 7
        bottomRightHost = 8
       	
	switch = Node( is_switch=True ) 
	host = Node( is_switch=False )

 	 # Add nodes
  	self.add_node( leftSwitch, switch )
  	self.add_node( rightSwitch, switch )
  	self.add_node( bottomLeftSwitch, switch)
  	self.add_node( bottomRightSwitch, switch)
        
   	self.add_node( leftTopHost, host )
   	self.add_node( rightTopHost, host )
   	self.add_node( bottomLeftHost, host )
   	self.add_node( bottomRightHost, host )

   	# Add edges
   	self.add_edge( leftTopHost, leftSwitch )
   	self.add_edge( rightSwitch, rightTopHost )
   	self.add_edge( bottomLeftHost, bottomLeftSwitch )
   	self.add_edge( bottomRightSwitch, bottomRightHost )
        
   	#Switch Edges to support full mesh
   	self.add_edge( leftSwitch, rightSwitch )
 	self.add_edge( bottomLeftSwitch, bottomRightSwitch )
	self.add_edge( bottomLeftSwitch, rightSwitch )
	self.add_edge( leftSwitch, bottomRightSwitch )
	self.add_edge( rightSwitch, bottomRightSwitch )
	self.add_edge( leftSwitch, bottomLeftSwitch )
	
	#verify mesh	
	switches = []
	switches.append(leftSwitch) 
	switches.append(rightSwitch)
	switches.append(bottomLeftSwitch) 
	switches.append(bottomRightSwitch)
	for switch in switches:
		for connectingSwitch in switches:
			if switch == connectingSwitch:
				print 'Destination to itself'
			else:
				ports = self.port(switch, connectingSwitch)
				print 'Source SW: %s Destination SW: %s have ports (outport, inport) %s' % (str(switch),str(connectingSwitch),ports)
	print "Edge Object {Source dpid: Dest dpid} Tuples"
	print self.ports


        # Consider all switches and hosts 'on'
        self.enable_all()
    def __init__(self, enable_all=True):
        "Call Super constructor"
        super(MyRingTopo, self).__init__()
        """
		Following is the topology (just the switches):
				
				1

			5		2

			4		3
		
		"""

        topSwitch = 1
        midRightSwitch = 2
        bottomRightSwitch = 3
        bottomLeftSwitch = 4
        midLeftSwitch = 5

        host1 = 1001
        host2 = 1002
        host3 = 1003
        host4 = 1004
        host5 = 1005
        host6 = 1006
        host7 = 1007
        host8 = 1008
        host9 = 1009
        host10 = 1010

        "Add nodes to topology"
        self.add_node(topSwitch, Node(is_switch=True))
        self.add_node(midRightSwitch, Node(is_switch=True))
        self.add_node(midLeftSwitch, Node(is_switch=True))
        self.add_node(bottomRightSwitch, Node(is_switch=True))
        self.add_node(bottomLeftSwitch, Node(is_switch=True))

        "Add hosts"
        self.add_node(host1, Node(is_switch=False))
        self.add_node(host2, Node(is_switch=False))
        self.add_node(host3, Node(is_switch=False))
        self.add_node(host4, Node(is_switch=False))
        self.add_node(host5, Node(is_switch=False))
        self.add_node(host6, Node(is_switch=False))
        self.add_node(host7, Node(is_switch=False))
        self.add_node(host8, Node(is_switch=False))
        self.add_node(host9, Node(is_switch=False))
        self.add_node(host10, Node(is_switch=False))

        "Add edges to nodes"
        self.add_edge(topSwitch, host1)
        self.add_edge(topSwitch, host2)

        self.add_edge(midRightSwitch, host3)
        self.add_edge(midRightSwitch, host4)

        self.add_edge(bottomRightSwitch, host5)
        self.add_edge(bottomRightSwitch, host6)

        self.add_edge(bottomLeftSwitch, host7)
        self.add_edge(bottomLeftSwitch, host8)

        self.add_edge(midLeftSwitch, host9)
        self.add_edge(midLeftSwitch, host10)

        "Ring connection of switches"

        self.add_edge(topSwitch, midRightSwitch)
        self.add_edge(midRightSwitch, bottomRightSwitch)
        self.add_edge(bottomRightSwitch, bottomLeftSwitch)
        self.add_edge(bottomLeftSwitch, midLeftSwitch)
        self.add_edge(midLeftSwitch, topSwitch)

        self.enable_all()