コード例 #1
0
ファイル: simulation_3.py プロジェクト: Byzantium72/PA5
    host_1 = Host('H1')
    object_L.append(host_1)
    host_2 = Host('H2')
    object_L.append(host_2)
    host_3 = Host('H3')
    object_L.append(host_3)
    
    #create routers and routing tables for connected clients (subnets)
    #encap_tbl_D = {'H1': '1','H2': '2','H3': '3'}    # table used to encapsulate network packets into MPLS frames
    encap_tbl_D = {'H1': '1','H2': '2','H3': {'2': '4', '3': '3'}} 
    #Still need to be able to have source, to send to new route
    frwd_tbl_D = {'1': ['99', 'H1', 3], '2':['98','H2',2], '3':['4','RB',0], '4':['5','RC',1]}     # table used to forward MPLS frames
    decap_tbl_D = {'99':'H1','98':'H2'}    # table used to decapsulate network packets from MPLS frames
    router_a = Router(name='RA', 
                              intf_capacity_L=[500,500, 500, 500],
                              encap_tbl_D = encap_tbl_D,
                              frwd_tbl_D = frwd_tbl_D,
                              decap_tbl_D = decap_tbl_D, 
                              max_queue_size=router_queue_size)
    object_L.append(router_a)

    #H1 here is where you're sending it, and 11 is on what interface I think
    encap_tbl_D = {}
    #12 here is what it's coming in as, then 11 is what you're putting it in as next, destination, and the interface
    frwd_tbl_D = {'4': ['6', 'RB', 0], '7':['6','H1',1]}
    #If it's 11, decapsulate, and send it to H2
    decap_tbl_D = {}
    router_b = Router(name='RB', 
                              intf_capacity_L=[500,500],
                              encap_tbl_D = encap_tbl_D,
                              frwd_tbl_D = frwd_tbl_D,
                              decap_tbl_D = decap_tbl_D,
コード例 #2
0
            "outLabel": "1"
        },
        "2": {
            "dest": "H3",
            "outLabel": "2",
            "intf": 3
        }
    }  # table used to forward MPLS frames
    decap_tbl_D = {
        "RA": {"H1", "H2"},
        "RD": {"H3"}
    }  # table used to decapsulate network packets from MPLS frames
    router_a = Router(name='RA',
                      intf_capacity_L=[("H1", 500), ("H2", 500), ("RB", 100),
                                       ("RC", 500)],
                      encap_tbl_D=encap_tbl_D,
                      frwd_tbl_D=frwd_tbl_D,
                      decap_tbl_D=decap_tbl_D,
                      max_queue_size=router_queue_size)
    object_L.append(router_a)

    encap_tbl_D = {"H1": {"RA"}, "H2": {"RB"}}
    frwd_tbl_D = {"1": {"intf": 1, "dest": "H3", "outLabel": "1"}}
    decap_tbl_D = {"RA": {"H1", "H2"}, "RD": {"H3"}}
    router_b = Router(name='RB',
                      intf_capacity_L=[("RA", 100), ("RD", 100)],
                      encap_tbl_D=encap_tbl_D,
                      frwd_tbl_D=frwd_tbl_D,
                      decap_tbl_D=decap_tbl_D,
                      max_queue_size=router_queue_size)
    object_L.append(router_b)