示例#1
0
    object_L.append(host_2)

    #create routers and routing tables for connected clients (subnets)
    encap_tbl_D = {
        'H1': (100, 1, 0, 10)
    }  # table used to encapsulate network packets into MPLS frames
    frwd_tbl_D = {
        (0, 100): (1, 101),
        (1, 201): (0, 202)
    }  # table used to forward MPLS frames
    decap_tbl_D = {
        201: 0
    }  # table used to decapsulate network packets from MPLS frames
    router_a = Router(name='RA',
                      intf_capacity_L=[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)

    encap_tbl_D = {'H2': (200, 1, 0, 10)}
    frwd_tbl_D = {(1, 200): (0, 201), (0, 101): (1, 102)}
    decap_tbl_D = {101: 1}
    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)
    object_L.append(router_b)
            "interface": 0,
            "outLabel": "H1"
        },
        "H2": {
            "dest": "H2",
            "outLabel": "3",
            "interface": 1
        }
    }  # table used to forward MPLS frames
    decap_tbl_D = {
        "RA": {"H1"},
        "RB": {"H2"}
    }  # table used to decapsulate network packets from MPLS frames
    router_a = Router(name='RA',
                      intf_capacity_L=[("H1", 500), ("RB", 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 = {
        "H1": {
            "interface": 0,
            "dest": "H1",
            "outLabel": "2"
        },
        "3": {
            "dest": "H2",
            "outLabel": "H2",
            "interface": 1