def __init__(self, *args, **kwargs):
        super(L2Forwarding, self).__init__(*args, **kwargs)

        # Load the topology
        topo_file = 'topology.txt'
        self.G = load_topology(topo_file)

        # For each node in the graph, add an attribute mac-to-port
        # for n in self.G.nodes():
        #     self.G.add_node(n, mactoport={})

        self.mac_to_port = {}

        self.counter = 0

        # Compute a Spanning Tree for the graph G
        self.ST = compute_spanning_tree(self.G)

        print "Regular..."
        print self.get_str_topo(self.G)
        print "NX Lib Spanning..."
        print self.get_str_topo(self.ST)
        # my_compute_spanning_tree(self.G)
        min_spanning_tree = get_my_spanning_tree(self.G)
        print "My Spanning!"
        print self.get_str_topo(min_spanning_tree)
        self.MY_ST = min_spanning_tree
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        super(L2Forwarding, self).__init__(*args, **kwargs)

        # Load the topology
        topo_file = 'topology.txt'
        self.G = load_topology(topo_file)

        # For each node in the graph, add an attribute mac-to-port
        for n in self.G.nodes():
            self.G.add_node(n, mactoport={})
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        super(L2Forwarding, self).__init__(*args, **kwargs)

        # Load the topology
        topo_file = 'topology.txt'
        self.G = load_topology(topo_file)

        # For each node in the graph, add an attribute mac-to-port
        for n in self.G.nodes():
            self.G.add_node(n, mactoport={})

        # Compute a Spanning Tree for the graph G
        self.ST = compute_spanning_tree(self.G)

        print self.get_str_topo(self.G)
        print self.get_str_topo(self.ST)
Esempio n. 4
0
    def __init__(self):
        Topo.__init__(self)

        self.read_config('config/config')
        self.topology_graph = load_topology(Topology.FILENAME + '.graphml')

        self.link_table = {}
        self.switch_table = Set()

        self.mylinks = []
        self.myswitches = {}

        for v in self.topology_graph.vertices():
            #node_name = self.topology_graph.vertex_properties['name'][v]
            print 'switch id:', v, ' dpid: ', self.dpid(v)
            current_sw_name = self.switch_name(v)

            if v not in self.switch_table:
                self.myswitches[int(v)] = self.addSwitch(
                    current_sw_name, dpid=self.dpid(v), protocols='OpenFlow13')
                self.switch_table.add(v)
            self.add_neighbor_switch(v)
            self.add_neighbor_link(v)
Esempio n. 5
0
    # Creating links between switches and hosts_tab
    for switch_id in G:
        port_from = G.node[switch_id]['ports']['host']

        print 'Add Link s' + str(switch_id) + '(' + str(
            port_from) + ')->(?)' + 'h' + str(switch_id)
        net.addLink(node1='s' + str(switch_id),
                    node2='h' + str(switch_id),
                    port1=port_from)

    print "*** Creating remote controller"
    c1 = net.addController('c1', controller=RemoteController, port=6633)

    print "*** Starting network"
    net.build()
    c1.start()
    for s in switches_tab:
        s.start([c1])

    return net


if __name__ == '__main__':

    G = load_topology('topology.txt')

    net = createMininetNetwork(G)

    print "*** Running CLI"
    CLI(net)
Esempio n. 6
0
def lab0_topology():
    G = load_topology('topology.txt')
    net = createMininetNetwork(G)
    return net