Exemplo n.º 1
0
def figure2a_line_2_bgpsec_partial(
        nx_graph: nx.Graph, deployment: int,
        trials: List[Tuple[AS_ID, AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=RPKIPolicy())
    for asys in graph.identify_top_isps(deployment):
        asys.policy = BGPsecMedSecPolicy()
    return figure2a_experiment(graph, trials, n_hops=1)
Exemplo n.º 2
0
def figure2a_line_1_next_as(
        nx_graph: nx.Graph, deployment: int,
        trials: List[Tuple[AS_ID, AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=RPKIPolicy())
    for asys in graph.identify_top_isps(deployment):
        asys.policy = PathEndValidationPolicy()
    return figure2a_experiment(graph, trials, n_hops=1)
Exemplo n.º 3
0
def figure9_line_1_rpki_partial(
        nx_graph: nx.Graph, deployment: int,
        trials: List[Tuple[AS_ID, AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=DefaultPolicy())
    for asys in graph.identify_top_isps(deployment):
        asys.policy = RPKIPolicy()
    return figure2a_experiment(graph, trials, n_hops=0)
Exemplo n.º 4
0
    def test_learn_routes(self):
        graph = ASGraph(as_graph.parse_as_rel_file(AS_REL_FILEPATH))
        asys_8 = graph.get_asys(8)
        for asys in graph.asyss.values():
            graph.find_routes_to(asys_8)

        for asys in graph.asyss.values():
            assert 8 in asys.routing_table
            route = asys.routing_table[8]
            assert route.final == asys
Exemplo n.º 5
0
def figure8_line_2_bgpsec_partial(
        nx_graph: nx.Graph, deployment: int, p: float,
        trials: List[Tuple[AS_ID, AS_ID]]) -> List[Fraction]:
    results = []
    for _ in range(20):
        graph = ASGraph(nx_graph, policy=RPKIPolicy())
        for asys in graph.identify_top_isps(int(deployment / p)):
            if random.random() < p:
                asys.policy = BGPsecMedSecPolicy()
        results.extend(figure2a_experiment(graph, trials, n_hops=1))
    return results
Exemplo n.º 6
0
def check_graph(as_rel_file):
    nx_graph = as_graph.parse_as_rel_file(as_rel_file)

    if not nx.is_connected(nx_graph):
        print("Graph is not fully connected!")
    else:
        print("Graph is fully connected")

    graph = ASGraph(nx_graph)
    print("Checking for customer-provider cycles")
    if graph.any_customer_provider_cycles():
        print("Graph has a customer-provider cycle!")
    else:
        print("Graph has no cycles")
Exemplo n.º 7
0
def figure2a_line_5_bgpsec_high_full(
        nx_graph: nx.Graph, trials: List[Tuple[AS_ID,
                                               AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=BGPsecHighSecPolicy())
    for asys in graph.asyss.values():
        asys.bgp_sec_enabled = True
    return figure2a_experiment(graph, trials, n_hops=1)
Exemplo n.º 8
0
def get_path_lengths(as_rel_file, target_asn):
    nx_graph = as_graph.parse_as_rel_file(as_rel_file)

    graph = ASGraph(nx_graph, policy=routing_policy.RPKIPolicy())
    print("Loaded graph")

    origin_id = int(target_asn)
    origin = graph.get_asys(origin_id)

    print(f"Determining reachability to AS {origin_id}")
    reachable_from = graph.determine_reachability_one(origin_id)
    total_asyss = len(graph.asyss)
    print(
        f"AS {origin_id} is reachable from {reachable_from} / {total_asyss} ASs"
    )

    print(f"Finding routes to AS {origin_id}")
    graph.find_routes_to(origin)

    path_lengths = {}
    for asys in graph.asyss.values():
        route = asys.get_route(origin.as_id)
        path_len = route.length if route else -1
        if path_len not in path_lengths:
            path_lengths[path_len] = 0
        path_lengths[path_len] += 1

    # Cross-check path routing results with reachability.
    assert path_lengths.get(-1, 0) + reachable_from == total_asyss

    for path_len, count in sorted(path_lengths.items()):
        print(f"path_length: {path_len}, count: {count}")
Exemplo n.º 9
0
    def test_check_for_customer_provider_cycles(self):
        nx_graph = as_graph.parse_as_rel_file(AS_REL_FILEPATH)
        graph = ASGraph(nx_graph)
        self.assertFalse(graph.any_customer_provider_cycles())

        # Create a customer-provider cycle
        nx_graph.add_edge(1, 6, customer=1)
        graph = ASGraph(nx_graph)
        self.assertTrue(graph.any_customer_provider_cycles())
Exemplo n.º 10
0
def find_route(as_rel_file, origin_asn, final_asn):
    nx_graph = as_graph.parse_as_rel_file(as_rel_file)

    graph = ASGraph(nx_graph)
    print("Loaded graph")

    origin = graph.get_asys(origin_asn)
    final = graph.get_asys(final_asn)

    print(f"Finding routes to AS {origin_asn}")
    graph.find_routes_to(origin)

    print(final.routing_table.get(origin_asn, None))
Exemplo n.º 11
0
 def test_ASGraph_constructor(self):
     graph = ASGraph(as_graph.parse_as_rel_file(AS_REL_FILEPATH))
     for i in range(1, 14):
         assert i in graph.asyss
     assert graph.get_asys(1).get_relation(
         graph.get_asys(2)) == Relation.CUSTOMER
     assert graph.get_asys(2).get_relation(
         graph.get_asys(1)) == Relation.PROVIDER
     assert graph.get_asys(2).get_relation(
         graph.get_asys(6)) == Relation.CUSTOMER
     assert graph.get_asys(6).get_relation(
         graph.get_asys(2)) == Relation.PROVIDER
     assert graph.get_asys(2).get_relation(
         graph.get_asys(3)) == Relation.PEER
     assert graph.get_asys(3).get_relation(
         graph.get_asys(2)) == Relation.PEER
Exemplo n.º 12
0
def figure2a_line_4_rpki(nx_graph: nx.Graph,
                         trials: List[Tuple[AS_ID, AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=RPKIPolicy())
    return figure2a_experiment(graph, trials, n_hops=1)
Exemplo n.º 13
0
def figure2a_line_3_two_hop(
        nx_graph: nx.Graph, trials: List[Tuple[AS_ID,
                                               AS_ID]]) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=PathEndValidationPolicy())
    return figure2a_experiment(graph, trials, n_hops=2)
Exemplo n.º 14
0
def figure4_k_hop(nx_graph: nx.Graph, trials: List[Tuple[AS_ID, AS_ID]],
                  n_hops: int) -> List[Fraction]:
    graph = ASGraph(nx_graph, policy=DefaultPolicy())
    return figure2a_experiment(graph, trials, n_hops)