示例#1
0
def _make_graph_preferred():
    # Test AS3 routes correctly to AS3; multiple routes of different preferences.
    # 2----3-\
    # |    | |
    # \ 1--5 |
    #  -4  | |
    #   6--/-/
    graph = ASGraph()
    graph.add_peering(1, 4, Relationship.P2C)
    graph.add_peering(1, 5, Relationship.P2P)
    graph.add_peering(2, 3, Relationship.P2P)
    graph.add_peering(2, 4, Relationship.P2C)
    graph.add_peering(3, 6, Relationship.P2C)
    graph.add_peering(4, 6, Relationship.P2C)
    graph.add_peering(5, 6, Relationship.P2C)
    return graph
示例#2
0
 def make_three_way_diamond(relationship_combination):
     graph = ASGraph()
     graph.add_peering(1, 2, relationship_combination[0])
     graph.add_peering(1, 3, relationship_combination[1])
     graph.add_peering(1, 4, relationship_combination[2])
     graph.add_peering(2, 5, relationship_combination[3])
     graph.add_peering(3, 5, relationship_combination[4])
     graph.add_peering(4, 5, relationship_combination[5])
     return graph
示例#3
0
def _make_graph_implicit_withdrawal_multihop():
    # Test implicit withdrawal and distant propagation.
    # AS11 will route towards AS10 through AS2 and discard route through AS1.
    # 1---11
    # |   | \
    # |   2  3
    # | / |   \
    # 10  12   4
    graph = ASGraph()
    graph.add_peering(1, 11, Relationship.P2P)
    graph.add_peering(10, 1, Relationship.C2P)
    graph.add_peering(10, 2, Relationship.C2P)
    graph.add_peering(2, 11, Relationship.C2P)
    graph.add_peering(4, 3, Relationship.C2P)
    graph.add_peering(3, 11, Relationship.C2P)
    graph.add_peering(12, 2, Relationship.C2P)
    return graph
示例#4
0
def _make_graph_multiple_choices():
    # Test ASes learn and correctly propagate multiple routes:
    # 1---\---\
    # |   |   |
    # 2   3   4===6   # 2, 3, 4 peer with 6
    # |   |   |   |
    # 5---/---/   7
    # |
    # |---\---\
    # 8   9   10===12   # 8, 9, 10 peer with 12
    # |   |   |    |
    # 11--/---/    13
    graph = ASGraph()
    graph.add_peering(1, 2, Relationship.P2C)
    graph.add_peering(1, 3, Relationship.P2C)
    graph.add_peering(1, 4, Relationship.P2C)
    graph.add_peering(2, 5, Relationship.P2C)
    graph.add_peering(3, 5, Relationship.P2C)
    graph.add_peering(4, 5, Relationship.P2C)
    graph.add_peering(2, 6, Relationship.P2P)
    graph.add_peering(3, 6, Relationship.P2P)
    graph.add_peering(4, 6, Relationship.P2P)
    graph.add_peering(6, 7, Relationship.P2C)
    graph.add_peering(5, 8, Relationship.P2C)
    graph.add_peering(5, 9, Relationship.P2C)
    graph.add_peering(5, 10, Relationship.P2C)
    graph.add_peering(8, 11, Relationship.P2C)
    graph.add_peering(9, 11, Relationship.P2C)
    graph.add_peering(10, 11, Relationship.P2C)
    graph.add_peering(8, 12, Relationship.P2P)
    graph.add_peering(9, 12, Relationship.P2P)
    graph.add_peering(10, 12, Relationship.P2P)
    graph.add_peering(12, 13, Relationship.P2C)
    return graph
示例#5
0
def _make_graph_implicit_withdrawal():
    # Make AS graph that requires a BGP implicit withdrawal prior to convergence.
    # AS2 is a peer of AS3, but is not a client of AS1.
    # AS8 should learn 8 3 1 10 then change to 8 6 4 1 10 when
    # AS3 finally learns the route through AS2.
    # 1--------\---\
    # |    2---3   4
    # |    5   |   6
    # |    7   8---/
    # |    9
    # 10---/
    graph = ASGraph()
    graph.add_peering(1, 3, Relationship(-1))
    graph.add_peering(1, 4, Relationship(-1))
    graph.add_peering(1, 10, Relationship(-1))
    graph.add_peering(2, 3, Relationship(0))
    graph.add_peering(2, 5, Relationship(-1))
    graph.add_peering(3, 8, Relationship(-1))
    graph.add_peering(4, 6, Relationship(-1))
    graph.add_peering(5, 7, Relationship(-1))
    graph.add_peering(6, 8, Relationship(-1))
    graph.add_peering(7, 9, Relationship(-1))
    graph.add_peering(9, 10, Relationship(-1))
    return graph
示例#6
0
def _make_graph_peer_lock():
    # Test propagation of hijacked routes through when using peer lock:
    # ASes 2 and 3 peer with AS1, ASes 4 and 5 are providers of AS1.
    # ASes 2 and 4 have peer lock configured with AS1. ASes 6 and 7 are
    # customers of ASes 2-5. AS7 will hijack the prefix. AS 8 peers with
    # ASes 2-5 and AS9 is a provider of ASes 2-5.
    #   ----9----
    #  /   / \   \
    # |   4   5   |  --\
    # |  | \ / |  |  --\
    # 2--+--1--+--3----8
    # |  |     |  |  --/
    #  \-6     7-/
    graph = ASGraph()
    graph.add_peering(1, 2, Relationship.P2P)
    graph.add_peering(1, 3, Relationship.P2P)
    graph.add_peering(1, 4, Relationship.C2P)
    graph.add_peering(1, 5, Relationship.C2P)
    graph.add_peering(6, 2, Relationship.C2P)
    graph.add_peering(6, 3, Relationship.C2P)
    graph.add_peering(6, 4, Relationship.C2P)
    graph.add_peering(6, 5, Relationship.C2P)
    graph.add_peering(7, 2, Relationship.C2P)
    graph.add_peering(7, 3, Relationship.C2P)
    graph.add_peering(7, 4, Relationship.C2P)
    graph.add_peering(7, 5, Relationship.C2P)
    graph.add_peering(8, 2, Relationship.P2P)
    graph.add_peering(8, 3, Relationship.P2P)
    graph.add_peering(8, 4, Relationship.P2P)
    graph.add_peering(8, 5, Relationship.P2P)
    graph.add_peering(9, 2, Relationship.P2C)
    graph.add_peering(9, 3, Relationship.P2C)
    graph.add_peering(9, 4, Relationship.P2C)
    graph.add_peering(9, 5, Relationship.P2C)
    graph.set_import_filter(2, _check_origin, 1)
    graph.set_import_filter(4, _check_origin, 1)
    return graph
示例#7
0
def _make_graph_peer_peer_relationships():
    # Test route propagation through sequence of P2P links:
    # AS9 is a provider of 1 and 5. AS10 is a provider of 3 and 7.
    # 9-------\   10
    # |    /--+--/|
    # 1---3---5---7
    # 2   4   6   8
    graph = ASGraph()
    graph.add_peering(1, 2, Relationship.P2C)
    graph.add_peering(3, 4, Relationship.P2C)
    graph.add_peering(5, 6, Relationship.P2C)
    graph.add_peering(7, 8, Relationship.P2C)
    graph.add_peering(9, 1, Relationship.P2C)
    graph.add_peering(9, 5, Relationship.P2C)
    graph.add_peering(10, 3, Relationship.P2C)
    graph.add_peering(10, 7, Relationship.P2C)
    graph.add_peering(1, 3, Relationship.P2P)
    graph.add_peering(3, 5, Relationship.P2P)
    graph.add_peering(5, 7, Relationship.P2P)
    return graph