Ejemplo n.º 1
0
    def build(self, topo):
        routingTable = {}

        # assign core-edge downward
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    # send to core
                    core = self.assignments[h.name]
                    outport = topo.ports[edge.name][core]

                routingTable[edge.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 2
0
    def build(self, topo):
        routingTable = {}

        # use only one core switch
        core = topo.coreSwitches.keys()[0]
        coreDpid = topo.coreSwitches[core].dpid

        routingTable[coreDpid] = []

        # create rules for packets from core -> edge (downward)
        for h in topo.hosts.values():
            outport = topo.ports[core][h.switch]
            routingTable[coreDpid].append({"eth_dst": h.eth, "output": [outport], "priority": 2, "type": "dst"})

        # DEFAULT
        # create rules for packets from edge -> core (upward)
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    outport = topo.ports[edge.name][core]

                routingTable[edge.dpid].append({"eth_dst": h.eth, "output": [outport], "priority": 2, "type": "dst"})

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 3
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 4
0
    def build(self, topo):
        routingTable = {}

        # assign core-edge downward
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    # send to core
                    core = self.assignments[h.name]
                    outport = topo.ports[edge.name][core]

                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 5
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({"eth_dst": h.eth, "output": [outport], "priority": 2, "type": "dst"})

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                # print "OutportNeigh Set to: ", outport, "for edge", edge, "host", h.name
                # print "OUTPORT: ", outport
                else:
                    outport = topo.ports[edge.name][topo.getVlanCore(h.vlans[0])]
                    # if h.name in topo.vlans[0]:
                    # outport = topo.ports[edge.name][topo.getVlanCore(h.vlans[0])]
                    # outport = topo.ports[edge.name][topo.getVlanCore(0)]
                    # print "Outport0 Set to: ", outport, "for edge:", edge, "host:", h.name
                    # print "VLANS0: ", topo.vlans[0]
                # print "VLANS0: ", topo.getVlanCore(0)
                # print "EDGE Name", edge.name, h.name
                # print "HOST Name", h.name, h.vlans[0]
                # print "CORE0", core
                # print "PORTS0", topo.ports[edge.name][topo.getVlanCore(0)]
                # elif h.name in topo.vlans[1]:
                # print "VLANS1: ", topo.vlans[1]
                # print "VLANS1: ", topo.getVlanCore(1)
                # print "EDGE.NEIGHBORS", edge.name, h.name, core
                # print "HOST Name", h.name, h.vlans
                # print "PORTS1", topo.ports.keys()
                # print "CORE1", core
                # print "PORTS1", topo.ports[edge.name][topo.getVlanCore(1)]
                # outport = topo.ports[edge.name][topo.getVlanCore(1)]
                # print "Outport1 Set to: ", outport, "for edge:", edge, "host", h.name
                # print "OUTPORT: ", outport

                routingTable[edge.dpid].append({"eth_dst": h.eth, "output": [outport], "priority": 2, "type": "dst"})

                # print "Routing Table: ", routingTable

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 6
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    #pPfx = "BBI:StaticPolicy:build:"
                    #print pPfx + "host h: " + h.name
                    #pprint(h)
                    thsVlanId = h.vlans[0]
                    #print pPfx + "host h.vlans[0]: %d" % (thsVlanId)
                    thsVlanCore = topo.getVlanCore(thsVlanId)
                    #print pPfx + "thsVlanId: VLANCore:" + thsVlanCore

                    #core = topo.coreSwitches.keys()[0]
                    #print pPfx + "core: "
                    #pprint(core)
                    outport = topo.ports[edge.name][thsVlanCore]

                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        # [END MY CODE]

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 7
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    #pPfx = "BBI:StaticPolicy:build:" 
                    #print pPfx + "host h: " + h.name
                    #pprint(h)
                    thsVlanId = h.vlans[0]
                    #print pPfx + "host h.vlans[0]: %d" % (thsVlanId)
                    thsVlanCore = topo.getVlanCore(thsVlanId)
                    #print pPfx + "thsVlanId: VLANCore:" + thsVlanCore

                    #core = topo.coreSwitches.keys()[0]
                    #print pPfx + "core: "
                    #pprint(core)
                    outport = topo.ports[edge.name][thsVlanCore]

                routingTable[edge.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        # [END MY CODE]

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 8
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]

# create rules for packets from edge -> core (upward)
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    # find the core that host vlan belongs to,
                    # if more than one vlan the host has, use the first item in the list
                    core = topo.getVlanCore(h.vlans[0])
                    outport = topo.ports[edge.name][core]

                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 9
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                #print "OutportNeigh Set to: ", outport, "for edge", edge, "host", h.name
                #print "OUTPORT: ", outport
                else:
                    outport = topo.ports[edge.name][topo.getVlanCore(
                        h.vlans[0])]
                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        #print "Routing Table: ", routingTable

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 10
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        # 
	
	for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
		# don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
		    vlanID = h.vlans
		    vlanCore = topo.getVlanCore(vlanID[0])
                    outport = topo.ports[edge.name][vlanCore]
		    

                routingTable[edge.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 11
0
    def build(self, topo):
        routingTable = {}

        # use only one core switch
        core = topo.coreSwitches.keys()[0]
        coreDpid = topo.coreSwitches[core].dpid

        routingTable[coreDpid] = []

        # create rules for packets from core -> edge (downward)
        for h in topo.hosts.values():
            outport = topo.ports[core][h.switch]
            routingTable[coreDpid].append({
                'eth_dst': h.eth,
                'output': [outport],
                'priority': 2,
                'type': 'dst'
            })

# DEFAULT
# create rules for packets from edge -> core (upward)
        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    outport = topo.ports[edge.name][core]

                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 12
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })

        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
                # don't send edge switch's neighbors up to core
                if h.name in edge.neighbors:
                    outport = topo.ports[edge.name][h.name]
                else:
                    outport = topo.ports[edge.name][topo.getVlanCore(
                        h.vlans[0])]
                    print(edge.name, h.name, topo.getVlanCore(h.vlans[0]),
                          outport)

                routingTable[edge.dpid].append({
                    'eth_dst': h.eth,
                    'output': [outport],
                    'priority': 2,
                    'type': 'dst'
                })
        print routingTable
        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 13
0
    def build(self, topo):
        routingTable = {}

        # core switches: for a given host destination, send packet
        # to the host's edge switch ("downward")
        for core in topo.coreSwitches.values():
            routingTable[core.dpid] = []
            for h in topo.hosts.values():
                outport = topo.ports[core.name][h.switch]
                routingTable[core.dpid].append({
                    'eth_dst' : h.eth,
                    'output' : [outport],
                    'priority' : 2,
                    'type' : 'dst'
                })

        # ASSIGNMENT 3:
        # Rules to Install:
        #   On the Edge Switches: output the appropriate port if the destination
        #   is a neighboring host (that is, don't send it up to a core switch).
        #   Otherwise, send to the core switch for that destination's vlan
        #   ("upward").  If a host has multiple VLANs, you can use the first
        #   in the list of VLANs.
        #   (Hint: you can look up the port of a neighboring host using
        #           topo.ports[edge switch name][host name]
        #   (Hint: to find a the VLAN, use topo.getVlanCore(vlanId))

        # [ADD YOUR CODE HERE]

	import pprint
	#pprint.pprint(topo.vlans)

        #vlans = [topo.coreSwitches[core].vlans[0] for core in topo.coreSwitches.keys()]
	#for vlan in vlans:
	#  print "*** vlan %d ***"%vlan
	#  pprint.pprint(topo.getVlanCore(vlan))

        #for core in topo.coreSwitches.values():
        #  for h in topo.hosts.values():
        #    print "%s %s %s"%(core.name, h.switch, topo.ports[core.name][h.switch])

	edgeSwitches = topo.edgeSwitches.values()
        pprint.pprint(edgeSwitches)

        for edge in topo.edgeSwitches.values():
            routingTable[edge.dpid] = []
            for h in topo.hosts.values():
              # don't send neighbors up to core
              if h.name in edge.neighbors:
		#print "*** edge.name %s edge.dpid %d vlan %s edge_port %d ***"%(edge.name, edge.dpid, 'none', topo.ports[edge.name][h.name])
          	outport = topo.ports[edge.name][h.name]
	      else:
		#if h.name in topo.vlans[h.vlans[0]]:
		  #print "*** h.name %s h.eth %s vlan %d edge_port %d ***"%(h.name, h.eth, h.vlans[0], topo.ports[edge.name][topo.getVlanCore(h.vlans[0])])
		outport = topo.ports[edge.name][topo.getVlanCore(h.vlans[0])]
		
              routingTable[edge.dpid].append({
          	'eth_dst' : h.eth,
          	'output' : [outport],
         	'priority' : 2,
          	'type' : 'dst'
              })
	

	#pprint.pprint(routingTable)

        return flood.add_arpflood(routingTable, topo)
Ejemplo n.º 14
0
	for edge in topo.edgeSwitches.values():
	    routingTable[edge.dpid] = []
	    for h in topo.hosts.values():
		if h.name in edge.neightbors:
		    outport = topo.ports[edge.name][h.name]
		else:
		    outport = topo.ports[edge.name][topo.getVlanCore(h.vlans[0])]
		
		routingTable[edge.dpid].append({
		    'eth_dst' : h.eth,
		    'output' :[outport],	
		    'priority':2,
	 	    'type':'dst'
		})
'''
        return flood.add_arpflood(routingTable, topo)

class DefaultPolicy(object):
    def __init__(self, topo):
        self.routingTable = self.build(topo)

    def build(self, topo):
        routingTable = {}

        # use only one core switch
        core = topo.coreSwitches.keys()[0]
        coreDpid = topo.coreSwitches[core].dpid

        routingTable[coreDpid] = []

        # create rules for packets from core -> edge (downward)