示例#1
0
    
    #create network hosts
    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)
    
    # tables for router a 
    encap_tbl_D = {0: ('11', 3), 1: ('12', 2)}    # table used to encapsulate network packets into MPLS frames {(in interface: (out label, out interface)}
    frwd_tbl_D = {}     # table used to forward MPLS frames {(in label, in interface): (out label, out interface)}
    decap_tbl_D = {('21', 3): 1}    # table used to decapsulate network packets from MPLS frames {(in label, in interface): out interface}
    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)

    # tables for router b
    encap_tbl_D = {}    # table used to encapsulate network packets into MPLS frames {in interface: (out label, out interface)}
    frwd_tbl_D = {('12', 0): ('15', 1)}     # table used to forward MPLS frames {(in label, in interface): (out label, out interface)}
    decap_tbl_D = {}    # table used to decapsulate network packets from MPLS frames {(in label, in interface): out interface}
    
    router_b = Router(name='RB', 
                              intf_capacity_L=[500,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)
示例#2
0
            "outLabel": "1"
        },
        "H2": {
            "dest": "H3",
            "outLabel": "2",
            "interface": 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", 500),
                                       ("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": {"interface": 1, "dest": "H3", "outLabel": "1"}}
    decap_tbl_D = {"RA": {"H1", "H2"}, "RD": {"H3"}}
    router_b = Router(name='RB',
                      intf_capacity_L=[("RA", 500), ("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)