Exemplo n.º 1
0
    def test_irregular_graph(self):
        """Tests graphs that are not necessarily regular - some number of sources
        and destinations have no edges."""

        generator = graph_util()
        num_experiments = 100
        n_nodes = 256  # network with 8 racks of 32 nodes each
        n_racks = n_nodes / structures.MAX_NODES_PER_RACK

        for i in range(num_experiments):
            # generate admitted traffic
            g_p = generator.generate_random_regular_bipartite(n_nodes, 1)

            # choose a number of edges to remove
            num_edges_to_remove = random.randint(1, 256)
            # remove edges
            for j in range(num_edges_to_remove):
                while (True):
                    # choose an edge index at random
                    index = random.randint(0, n_nodes - 1)
                    edge = g_p.edges(index)
                    if edge != []:
                        edge_tuple = edge[0]
                        g_p.remove_edge(edge_tuple[0], edge_tuple[1])
                        break

            admitted = structures.create_admitted_traffic()
            admitted_copy = structures.create_admitted_traffic()
            for edge in g_p.edges_iter():
                structures.insert_admitted_edge(admitted, edge[0],
                                                edge[1] - n_nodes)
                structures.insert_admitted_edge(admitted_copy, edge[0],
                                                edge[1] - n_nodes)

            # select paths
            pathselection.select_paths(admitted, n_racks)

            # check that path assignments are valid
            self.assertTrue(pathselection.paths_are_valid(admitted, n_racks))

            # check that src addrs and lower bits of destination addrs are unchanged
            for e in range(admitted.size):
                edge = structures.get_admitted_edge(admitted, e)
                edge_copy = structures.get_admitted_edge(admitted_copy, e)
                self.assertEqual(edge.src, edge_copy.src)
                self.assertEqual(edge.dst & pathselection.PATH_MASK,
                                 edge_copy.dst & pathselection.PATH_MASK)

            # clean up
            structures.destroy_admitted_traffic(admitted)

        pass
Exemplo n.º 2
0
    def test_irregular_graph(self):
        """Tests graphs that are not necessarily regular - some number of sources
        and destinations have no edges."""

        generator = graph_util()
        num_experiments = 100
        n_nodes = 256 # network with 8 racks of 32 nodes each
        n_racks = n_nodes / structures.MAX_NODES_PER_RACK

        for i in range(num_experiments):
            # generate admitted traffic
            g_p = generator.generate_random_regular_bipartite(n_nodes, 1)

            # choose a number of edges to remove
            num_edges_to_remove = random.randint(1, 256)
            # remove edges
            for j in range(num_edges_to_remove):
                while (True):
                    # choose an edge index at random
                    index = random.randint(0, n_nodes - 1)
                    edge = g_p.edges(index)
                    if edge != []:
                        edge_tuple = edge[0]
                        g_p.remove_edge(edge_tuple[0], edge_tuple[1])
                        break

            admitted = structures.create_admitted_traffic()
            admitted_copy = structures.create_admitted_traffic()
            for edge in g_p.edges_iter():
                structures.insert_admitted_edge(admitted, edge[0], edge[1] - n_nodes)
                structures.insert_admitted_edge(admitted_copy, edge[0], edge[1] - n_nodes)

            # select paths
            pathselection.select_paths(admitted, n_racks)

            # check that path assignments are valid
            self.assertTrue(pathselection.paths_are_valid(admitted, n_racks))

            # check that src addrs and lower bits of destination addrs are unchanged
            for e in range(admitted.size):
                edge = structures.get_admitted_edge(admitted, e)
                edge_copy = structures.get_admitted_edge(admitted_copy, e)
                self.assertEqual(edge.src, edge_copy.src)
                self.assertEqual(edge.dst & pathselection.PATH_MASK,
                                 edge_copy.dst & pathselection.PATH_MASK)

            # clean up
            structures.destroy_admitted_traffic(admitted)

        pass
Exemplo n.º 3
0
    def __init__(self, n, duration):
        # generate a series of requests, each specified by a tuple per timeslot
        # (src, dst, # packets)
        # each src requests a fixed number of packets to a destination chosen
        # uniformly at random with intervals between send times specified by
        # an exponential distribution
        self.n = n
        self.duration = duration
        self.requests = []
        for t in range(self.duration):
          self.requests.append([]) # an empty list of requests per timeslot

        # note: over long time scales, we should just barely be able to admit
        # all traffic
        mean = 20
        fraction = 0.95
        packets_requested = int(mean * fraction)
        for src in range(n):
            t = self.gen_exponential_variate(mean)
            cumulative_demand = 0
            while (t < self.duration):
                cumulative_demand += packets_requested
                dst = random.randint(0, n-2)
                if (dst >= src):
                    dst += 1  # don't send to self
                self.requests[int(t)].append((src, dst, cumulative_demand))
                t = t + self.gen_exponential_variate(mean)

        # initialize structures
        self.queue_0 = structures.create_backlog_queue()
        self.queue_1 = structures.create_backlog_queue()
        self.new_requests = structures.create_backlog_queue()
        self.admitted = structures.create_admitted_traffic()
        self.status = structures.create_admissible_status(False, 0)
Exemplo n.º 4
0
    def __init__(self, n, duration):
        # generate a series of requests, each specified by a tuple per timeslot
        # (src, dst, # packets)
        # each src requests a fixed number of packets to a destination chosen
        # uniformly at random with intervals between send times specified by
        # an exponential distribution
        self.n = n
        self.duration = duration
        self.requests = []
        for t in range(self.duration):
            self.requests.append([])  # an empty list of requests per timeslot

        # note: over long time scales, we should just barely be able to admit
        # all traffic
        mean = 20
        fraction = 0.95
        packets_requested = int(mean * fraction)
        for src in range(n):
            t = self.gen_exponential_variate(mean)
            cumulative_demand = 0
            while (t < self.duration):
                cumulative_demand += packets_requested
                dst = random.randint(0, n - 2)
                if (dst >= src):
                    dst += 1  # don't send to self
                self.requests[int(t)].append((src, dst, cumulative_demand))
                t = t + self.gen_exponential_variate(mean)

        # initialize structures
        self.queue_0 = structures.create_backlog_queue()
        self.queue_1 = structures.create_backlog_queue()
        self.new_requests = structures.create_backlog_queue()
        self.admitted = structures.create_admitted_traffic()
        self.status = structures.create_admissible_status(False, 0)
Exemplo n.º 5
0
    def test_regular_graph(self):
        """Basic test involving graphs that are already regular."""

        generator = graph_util()
        num_experiments = 10
        n_nodes = 256  # network with 8 racks of 32 nodes each
        n_racks = n_nodes / structures.MAX_NODES_PER_RACK

        for i in range(num_experiments):
            # generate admitted traffic
            g_p = generator.generate_random_regular_bipartite(n_nodes, 1)

            admitted = structures.create_admitted_traffic()
            admitted_copy = structures.create_admitted_traffic()
            for edge in g_p.edges_iter():
                structures.insert_admitted_edge(admitted, edge[0],
                                                edge[1] - n_nodes)
                structures.insert_admitted_edge(admitted_copy, edge[0],
                                                edge[1] - n_nodes)

            # select paths
            pathselection.select_paths(admitted, n_racks)

            # check that path assignments are valid
            self.assertTrue(pathselection.paths_are_valid(admitted, n_racks))

            # check that src addrs and lower bits of destination addrs are unchanged
            for e in range(admitted.size):
                edge = structures.get_admitted_edge(admitted, e)
                edge_copy = structures.get_admitted_edge(admitted_copy, e)
                self.assertEqual(edge.src, edge_copy.src)
                self.assertEqual(edge.dst & pathselection.PATH_MASK,
                                 edge_copy.dst & pathselection.PATH_MASK)

            # clean up
            structures.destroy_admitted_traffic(admitted)

        pass
Exemplo n.º 6
0
    def test_regular_graph(self):
        """Basic test involving graphs that are already regular."""

        generator = graph_util()
        num_experiments = 10
        n_nodes = 256 # network with 8 racks of 32 nodes each
        n_racks = n_nodes / structures.MAX_NODES_PER_RACK

        for i in range(num_experiments):
            # generate admitted traffic
            g_p = generator.generate_random_regular_bipartite(n_nodes, 1)

            admitted = structures.create_admitted_traffic()
            admitted_copy = structures.create_admitted_traffic()
            for edge in g_p.edges_iter():
                structures.insert_admitted_edge(admitted, edge[0], edge[1] - n_nodes)
                structures.insert_admitted_edge(admitted_copy, edge[0], edge[1] - n_nodes)

            # select paths
            pathselection.select_paths(admitted, n_racks)

            # check that path assignments are valid
            self.assertTrue(pathselection.paths_are_valid(admitted, n_racks))

            # check that src addrs and lower bits of destination addrs are unchanged
            for e in range(admitted.size):
                edge = structures.get_admitted_edge(admitted, e)
                edge_copy = structures.get_admitted_edge(admitted_copy, e)
                self.assertEqual(edge.src, edge_copy.src)
                self.assertEqual(edge.dst & pathselection.PATH_MASK,
                                 edge_copy.dst & pathselection.PATH_MASK)

            # clean up
            structures.destroy_admitted_traffic(admitted)

        pass