当前位置: 首页>>代码示例>>Python>>正文


Python FlowEntry.set_flow_name方法代码示例

本文整理汇总了Python中pybvc.openflowdev.ofswitch.FlowEntry.set_flow_name方法的典型用法代码示例。如果您正苦于以下问题:Python FlowEntry.set_flow_name方法的具体用法?Python FlowEntry.set_flow_name怎么用?Python FlowEntry.set_flow_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybvc.openflowdev.ofswitch.FlowEntry的用法示例。


在下文中一共展示了FlowEntry.set_flow_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: of_demo_15

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_15():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 15 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    # --- Flow Match: Ethernet Type
    #                 VLAN ID
    #                 Input Port
    eth_type = ETH_TYPE_IPv4
    vlan_id = 100
    input_port = 3

    # --- Flow Actions: Push VLAN: Ethernet Type
    #                   Set Field: VLAN ID
    #                   Output:    Port Number
    push_eth_type = ETH_TYPE_DOT1AD  # 802.1ad VLAN tagged frame
    push_vlan_id = 200
    output_port = 5

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Ethernet Type (%s)\n"
           "                VLAN ID (%s)\n"
           "                Input Port (%s)" %
           (hex(eth_type), vlan_id, input_port))
    print ("        Action: Push VLAN (Ethernet Type=%s)" %
           (hex(push_eth_type)))
    print ("                Set Field (VLAN ID=%s)" %
           (push_vlan_id))
    print ("                Output (to Physical Port Number %s)" %
           (output_port))

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    flow_entry.set_flow_name(flow_name="Push VLAN")
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 22
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1013)
    flow_entry.set_flow_cookie(cookie=407)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)
    flow_entry.set_flow_hard_timeout(hard_timeout=3400)
    flow_entry.set_flow_idle_timeout(idle_timeout=3400)

    # --- Instruction: 'Apply-actions'
    #     Actions:     'PushVlan'
    #                  'SetField'
    #                  'Output'
    instruction = Instruction(instruction_order=0)
    action = PushVlanHeaderAction(order=0)
    action.set_eth_type(eth_type=push_eth_type)
    instruction.add_apply_action(action)
    action = SetFieldAction(order=1)
    action.set_vlan_id(vid=push_vlan_id)
    instruction.add_apply_action(action)
    action = OutputAction(order=2, port=output_port)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   Ethernet Source Address
    #                   Ethernet Destination Address
    #                   Input Port
    match = Match()
    match.set_eth_type(eth_type)
    match.set_vlan_id(vlan_id)
    match.set_in_port(in_port=input_port)
    flow_entry.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry.get_payload()
    time.sleep(rundelay)
    result = ofswitch.add_modify_flow(flow_entry)
    status = result.get_status()
#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:103,代码来源:demo15.py

示例2: of_demo_40

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_40():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit(0)

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 40 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Modify IP packet example1"
    priority = 900
    cookie = 1300

    match_in_port = 10
    match_eth_type = ETH_TYPE_IPv4
    match_ip_proto = IP_PROTO_TCP
    match_ipv4_src_addr = "192.1.2.0/24"
    match_ipv4_dst_addr = "173.194.123.40/32"
    match_tcp_dst_port = 8080

    act_mod_ipv4_src_addr = "212.16.1.8/32"
    act_mod_ipv4_dst_addr = "52.87.12.11/32"
    act_mod_tcp_src_port = 8888
    act_mod_tcp_dst_port = 9999
    act_out_port = 119

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Input Port (%s)\n"
           "                Ethernet Type (%s)\n"
           "                IP Protocol (%s)\n"
           "                IPv4 Source Address (%s)\n"
           "                IPv4 Destination Address (%s)\n"
           "                TCP Destination Port (%s)" %
           (match_in_port,
            hex(match_eth_type),
            match_ip_proto,
            match_ipv4_src_addr,
            match_ipv4_dst_addr,
            match_tcp_dst_port))
    print ("        Actions: Modify IPv4 Source Address (%s)\n"
           "                 Modify IPv4 Destination Address (%s)\n"
           "                 Modify TCP Source Port (%s)\n"
           "                 Modify TCP Destination Port (%s)\n"
           "                 Output (%s)" %
           (act_mod_ipv4_src_addr,
            act_mod_ipv4_dst_addr,
            act_mod_tcp_src_port,
            act_mod_tcp_dst_port,
            act_out_port))

    time.sleep(rundelay)

    # Allocate a placeholder for the Flow Entry
    flow_entry1 = FlowEntry()

    # Generic attributes of the Flow Entry
    flow_entry1.set_flow_table_id(table_id)
    flow_entry1.set_flow_name(flow_name)
    flow_entry1.set_flow_id(flow_id)
    flow_entry1.set_flow_cookie(cookie)
    flow_entry1.set_flow_priority(priority)
    flow_entry1.set_flow_hard_timeout(0)
    flow_entry1.set_flow_idle_timeout(0)

    # Instructions/Actions for the Flow Entry
    instruction = Instruction(instruction_order=0)

    action_order = 0
    action = SetNwSrcAction(action_order)
    action.set_nw_src(act_mod_ipv4_src_addr)
    instruction.add_apply_action(action)

    action_order += 1
    action = SetNwDstAction(action_order)
#.........这里部分代码省略.........
开发者ID:s-garbuzov,项目名称:pybvc,代码行数:103,代码来源:demo40.py

示例3: print

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
 print ("<<< Set OpenFlow flow on the Controller")
 print ("        Match:  Ethernet Type (%s)\n"
        "                VLAN ID (%s)\n"
        "                Input Port (%s)"              % (hex(eth_type), vlan_id,
                                                          input_port))
 print ("        Action: Push VLAN (Ethernet Type=%s)"
                                                         % hex(push_eth_type))
 print ("                Set Field (VLAN ID=%s)" % push_vlan_id)
 
 print ("                Output (to Physical Port Number %s)" % output_port)
 
 
 time.sleep(rundelay)
 
 flow_entry = FlowEntry()
 flow_entry.set_flow_name(flow_name = "Push VLAN")
 table_id = 0
 flow_entry.set_flow_table_id(table_id)
 flow_id = 22
 flow_entry.set_flow_id(flow_id)
 flow_entry.set_flow_priority(flow_priority = 1013)
 flow_entry.set_flow_cookie(cookie = 407)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 flow_entry.set_flow_hard_timeout(hard_timeout = 3400)
 flow_entry.set_flow_idle_timeout(idle_timeout = 3400)
 
 # --- Instruction: 'Apply-actions'
 #     Actions:     'PushVlan'
 #                  'SetField'
 #                  'Output'
 instruction = Instruction(instruction_order = 0)
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo15.py

示例4: of_demo_31

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_31():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit(0)

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 31 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Set IPv4 ToS action"
    priority = 600
    cookie = 1000

    match_in_port = 109
    match_ip_eth_type = ETH_TYPE_IPv4
    match_ipv4_dst = "10.1.2.3/32"

    mod_nw_tos = 8

    act_out_port = 112

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Input Port (%s)\n"
           "                Ethernet Type (%s)\n"
           "                IPv4 Destination Address (%s)" %
           (match_in_port,
            hex(match_ip_eth_type),
            match_ipv4_dst))
    print ("        Actions: Set IPv4 ToS (tos %s)\n"
           "                 Output (Port number %s)" %
           (mod_nw_tos, act_out_port))

    time.sleep(rundelay)

    # Allocate a placeholder for the Flow Entry
    flow_entry1 = FlowEntry()

    # Generic attributes of the Flow Entry
    flow_entry1.set_flow_table_id(table_id)
    flow_entry1.set_flow_name(flow_name)
    flow_entry1.set_flow_id(flow_id)
    flow_entry1.set_flow_cookie(cookie)
    flow_entry1.set_flow_priority(priority)
    flow_entry1.set_flow_hard_timeout(0)
    flow_entry1.set_flow_idle_timeout(0)

    # Instructions/Actions for the Flow Entry
    instruction = Instruction(instruction_order=0)

    action_order = 0
    action = SetNwTosAction(action_order)
    action.set_tos(mod_nw_tos)
    instruction.add_apply_action(action)

    action_order += 1
    action = OutputAction(action_order)
    action.set_outport(act_out_port)
    instruction.add_apply_action(action)

    flow_entry1.add_instruction(instruction)

    # Match Fields for the Flow Entry
    match = Match()

    match.set_in_port(match_in_port)
    match.set_eth_type(match_ip_eth_type)
    match.set_ipv4_dst(match_ipv4_dst)

    flow_entry1.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry1.get_payload()
    time.sleep(rundelay)
#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:103,代码来源:demo31.py

示例5: of_demo_23

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_23():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 23 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    # --- Flow Match: Ethernet Type
    #                 Input Port
    #                 IPv4 Destination Address
    eth_type = ETH_TYPE_MPLS_UCAST
    in_port = 13
    mpls_label = 27

    # --- Flow Actions: Set Field
    #                   Output
    new_mpls_label = 44
    output_port = 14

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Ethernet Type (%s)\n"
           "                Input Port (%s)\n"
           "                MPLS Label (%s)" %
           (hex(eth_type), in_port, mpls_label))
    print ("        Action: Set Field (MPLS Label %s)\n"
           "                Output (Physical Port number %s)" %
           (new_mpls_label, output_port))

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_id = 29
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_name(flow_name="Change MPLS Label")
    flow_entry.set_flow_hard_timeout(hard_timeout=0)
    flow_entry.set_flow_idle_timeout(idle_timeout=0)
    flow_entry.set_flow_priority(flow_priority=1022)
    flow_entry.set_flow_cookie(cookie=401)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)

    # --- Instruction: 'Apply-actions'
    #     Actions:     'Set Field'
    #                  'Output'
    instruction = Instruction(instruction_order=0)
    action = SetFieldAction(order=0)
    action.set_mpls_label(new_mpls_label)
    instruction.add_apply_action(action)
    action = OutputAction(order=1, port=2)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   Input Port
    #                   MPLS Label
    match = Match()
    match.set_eth_type(eth_type)
    match.set_in_port(in_port)
    match.set_mpls_label(mpls_label)
    flow_entry.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry.get_payload()
    time.sleep(rundelay)
    result = ofswitch.add_modify_flow(flow_entry)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("<<< Flow successfully added to the Controller")
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    print ("\n")
    print ("<<< Get configured flow from the Controller")
    time.sleep(rundelay)
#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:103,代码来源:demo23.py

示例6: print

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
 print ("        Match:  Ethernet Type (%s)\n"
        "                Ethernet Source Address (%s)\n"
        "                Ethernet Destination Address (%s)\n"
        "                Input Port (%s)\n"              % (hex(eth_type), eth_src, 
                                                            eth_dst, input_port))
 print ("        Actions: 'Push VLAN' (Ethernet Type=%s)"
                                                         % hex(push_eth_type))
 print ("                 'Set Field' (VLAN ID=%s)" % push_vlan_id)
 
 print ("                 'Output' (to Physical Port Number %s)" % output_port)
 
 
 time.sleep(rundelay)
 
 flow_entry = FlowEntry()
 flow_entry.set_flow_name(flow_name = "push_vlan_flow")
 table_id = 0
 flow_entry.set_flow_table_id(table_id)
 flow_id = 21
 flow_entry.set_flow_id(flow_id)
 flow_entry.set_flow_priority(flow_priority = 1012)
 flow_entry.set_flow_cookie(cookie = 401)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 flow_entry.set_flow_hard_timeout(hard_timeout = 1200)
 flow_entry.set_flow_idle_timeout(idle_timeout = 3400)
 
 # --- Instruction: 'Apply-action'
 #     Actions:     'PushVlan'
 #                  'SetField'
 #                  'Output'
 instruction = Instruction(instruction_order = 0)
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:of_flowMatchPhysPort-EthSrcDest_ActVlanPushSetPhysPort.py

示例7: Type

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
        "                ICMPv6 Type (%s)\n"
        "                ICMPv6 Code (%s)\n" 
        "                Metadata (%s)"             % (hex(eth_type), ip_dscp, ip_ecn,
                                                       ipv6_src, ipv6_dst, ipv6_flabel,
                                                       icmpv6_type, icmpv6_code, metadata))
 print ("        Action: Output (to %s)" % output_port)
 
 
 time.sleep(rundelay)
 
 
 flow_entry = FlowEntry()
 table_id = 0
 flow_id = 26
 flow_entry.set_flow_table_id(table_id)
 flow_entry.set_flow_name(flow_name = "demo20.py")
 flow_entry.set_flow_id(flow_id)
 flow_entry.set_flow_priority(flow_priority = 1019)
 flow_entry.set_flow_cookie(cookie = 250)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 flow_entry.set_flow_hard_timeout(hard_timeout = 1200)
 flow_entry.set_flow_idle_timeout(idle_timeout = 3400)
 
 # --- Instruction: 'Apply-actions'
 #     Actions:     'Output'
 instruction = Instruction(instruction_order = 0)
 action = OutputAction(order = 0, port = output_port)
 instruction.add_apply_action(action)
 flow_entry.add_instruction(instruction)
 
 # --- Match Fields: Ethernet Type
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo20.py

示例8: print

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
 print ("        Match:  Ethernet Type (%s)\n"
        "                Input Port (%s)\n"
        "                MPLS Label (%s)"%     (hex(eth_type), in_port, mpls_label))
 print ("        Action: Set Field (MPLS Label %s)\n"
        "                Output (Physical Port number %s)" % (new_mpls_label, output_port))
 
 
 time.sleep(rundelay)
 
 
 flow_entry = FlowEntry()
 table_id = 0
 flow_id = 29
 flow_entry.set_flow_table_id(table_id)
 flow_entry.set_flow_id(flow_id)
 flow_entry.set_flow_name(flow_name = "Change MPLS Label")
 flow_entry.set_flow_hard_timeout(hard_timeout = 0)
 flow_entry.set_flow_idle_timeout(idle_timeout = 0)
 flow_entry.set_flow_priority(flow_priority = 1022)
 flow_entry.set_flow_cookie(cookie = 401)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 
 # --- Instruction: 'Apply-actions'
 #     Actions:     'Set Field'
 #                  'Output'
 instruction = Instruction(instruction_order = 0)
 action = SetFieldAction(order = 0)
 action.set_mpls_label(new_mpls_label)
 instruction.add_apply_action(action)
 action = OutputAction(order = 1, port = 2)
 instruction.add_apply_action(action)
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo23.py

示例9: of_demo_20

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_20():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 20 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    # --- Flow Match: Ethernet Type
    #                 IP DSCP
    #                 IP ECN
    #                 IPv6 Source Address
    #                 IPv6 Destination Address
    #                 IPv6 Flow Label
    #                 ICMPv6 type
    #                 ICMPv6 Code
    #                 Metadata
    eth_type = ETH_TYPE_IPv6
    ip_dscp = IP_DSCP_CS7  # 'Class Selector' = 'Network'
    ip_ecn = IP_ECN_CE     # 'Congestion Encountered'
    ipv6_src = "1234:5678:9ABC:DEF0:FDCD:A987:6543:210F/76"
    ipv6_dst = "2000:2abc:edff:fe00::3456/94"
    ipv6_flabel = 15
    ip_proto = IP_PROTO_ICMPv6
    icmpv6_type = 1        # 'Destination Unreachable'
    icmpv6_code = 3        # 'Address Unreachable'
    metadata = "0x0123456789ABCDEF"

    # --- Flow Actions: Output (CONTROLLER)
    output_port = "CONTROLLER"

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Ethernet Type (%s)\n"
           "                IP DSCP (%s)\n"
           "                IP ECN (%s)\n"
           "                IPv6 Source Address (%s)\n"
           "                IPv6 Destination Address (%s)\n"
           "                IPv6 Flow Label (%s)\n"
           "                ICMPv6 Type (%s)\n"
           "                ICMPv6 Code (%s)\n"
           "                Metadata (%s)" %
           (hex(eth_type), ip_dscp, ip_ecn,
            ipv6_src, ipv6_dst, ipv6_flabel,
            icmpv6_type, icmpv6_code, metadata))
    print ("        Action: Output (to %s)" % (output_port))

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_id = 26
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_name(flow_name="demo20.py")
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1019)
    flow_entry.set_flow_cookie(cookie=250)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)
    flow_entry.set_flow_hard_timeout(hard_timeout=1200)
    flow_entry.set_flow_idle_timeout(idle_timeout=3400)

    # --- Instruction: 'Apply-actions'
    #     Actions:     'Output'
    instruction = Instruction(instruction_order=0)
    action = OutputAction(order=0, port=output_port)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   IP DSCP
    #                   IP ECN
    #                   IPv6 Source Address
    #                   IPv6 Destination Address
    #                   IPv6 Flow Label
    #                   IP protocol number (ICMPv6)
    #                   ICMPv6 Type
    #                   ICMPv6 Code
    #                   Metadata
    match = Match()
    match.set_eth_type(eth_type)
#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:103,代码来源:demo20.py

示例10: ID

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
        "                VLAN ID (%s)\n"
        "                Input Port (%s)" % (hex(arp_eth_type), customer_vlan_id, customer_port))
 print ("        Action: Push VLAN (Ethernet Type %s)\n"
        "                Set Field (VLAN ID %s)\n"
        "                Push VLAN (Ethernet Type %s)\n"
        "                Set Field (VLAN ID %s)\n"
        "                Output (Physical Port number %s)" % (hex(qinq_eth_type), provider_vlan_id,
                                                              hex(dot1q_eth_type), customer_vlan_id,
                                                              provider_port))
 
 time.sleep(rundelay)
 
 flow_id = first_flow_id
 flow_entry1 = FlowEntry()
 flow_entry1.set_flow_table_id(table_id)
 flow_entry1.set_flow_name(flow_name = "[MLX1-A] Test flow (match:inport=110,arp;actions:push-QINQ-tag,mod_vlan=100,push-DOT1Q-tag,mod_vlan=998,output:111)")
 flow_entry1.set_flow_id(flow_id)
 flow_entry1.set_flow_hard_timeout(hard_timeout = 600)
 flow_entry1.set_flow_idle_timeout(idle_timeout = 300)
 flow_entry1.set_flow_priority(priority)
 flow_entry1.set_flow_cookie(cookie)
 flow_entry1.set_flow_cookie_mask(cookie_mask)
 
 instruction = Instruction(instruction_order = 0)
 
 action_order = 0
 action = PushVlanHeaderAction(action_order)
 action.set_eth_type(qinq_eth_type)
 instruction.add_apply_action(action)
 
 action_order += 1
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo25.py

示例11: of_demo_43

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_43():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit(0)

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 43 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Set Queue example"
    priority = 1000
    cookie = 1400

    match_in_port = 109
    match_eth_type = ETH_TYPE_IPv4
    match_ipv4_dst_addr = "10.0.0.0/8"

    act_queue_id = 7
    act_out_port = 112

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Input Port (%s)\n"
           "                Ethernet Type (%s)\n"
           "                IPv4 Destination Address (%s)" %
           (match_in_port,
            hex(match_eth_type),
            match_ipv4_dst_addr))
    print ("        Actions: Set Queue (%s)\n"
           "                 Output (%s)" %
           (act_queue_id, act_out_port))

    time.sleep(rundelay)

    # Allocate a placeholder for the Flow Entry
    flow_entry1 = FlowEntry()

    # Generic attributes of the Flow Entry
    flow_entry1.set_flow_table_id(table_id)
    flow_entry1.set_flow_name(flow_name)
    flow_entry1.set_flow_id(flow_id)
    flow_entry1.set_flow_cookie(cookie)
    flow_entry1.set_flow_priority(priority)
    flow_entry1.set_flow_hard_timeout(0)
    flow_entry1.set_flow_idle_timeout(0)

    # Instructions/Actions for the Flow Entry
    instruction = Instruction(instruction_order=0)

    action_order = 0
    action = SetQueueAction(action_order)
    action.set_gueue_id(act_queue_id)
    instruction.add_apply_action(action)

    action_order += 1
    action = OutputAction(action_order)
    action.set_outport(act_out_port)
    instruction.add_apply_action(action)

    flow_entry1.add_instruction(instruction)

    # Match Fields for the Flow Entry
    match = Match()

    match.set_in_port(match_in_port)
    match.set_eth_type(match_eth_type)
    match.set_ipv4_dst(match_ipv4_dst_addr)

    flow_entry1.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry1.get_payload()
    time.sleep(rundelay)
    result = ofswitch.add_modify_flow(flow_entry1)
#.........这里部分代码省略.........
开发者ID:s-garbuzov,项目名称:pybvc,代码行数:103,代码来源:demo43.py

示例12: of_demo_42

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_42():
    f = "cfg.yml"
    d = {}
    if load_dict_from_file(f, d) is False:
        print ("Config file '%s' read error: " % f)
        exit(0)

    try:
        ctrlIpAddr = d["ctrlIpAddr"]
        ctrlPortNum = d["ctrlPortNum"]
        ctrlUname = d["ctrlUname"]
        ctrlPswd = d["ctrlPswd"]
        nodeName = d["nodeName"]
        rundelay = d["rundelay"]
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 42 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Modify MPLS TTL example1"
    priority = 900
    cookie = 1300

    match_in_port = 3
    match_eth_type = ETH_TYPE_MPLS_UCAST
    match_mpls_label = 567

    act_mod_mpls_ttl = 2
    act_out_port = 112

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print (
        "        Match:  Input Port (%s)\n"
        "                Ethernet Type (%s)\n"
        "                MPLS Label (%s)" % (match_in_port, hex(match_eth_type), match_mpls_label)
    )
    print ("        Actions: Set MPLS TTL (%s)\n" "                 Output (%s)" % (act_mod_mpls_ttl, act_out_port))

    time.sleep(rundelay)

    # Allocate a placeholder for the Flow Entry
    flow_entry1 = FlowEntry()

    # Generic attributes of the Flow Entry
    flow_entry1.set_flow_table_id(table_id)
    flow_entry1.set_flow_name(flow_name)
    flow_entry1.set_flow_id(flow_id)
    flow_entry1.set_flow_cookie(cookie)
    flow_entry1.set_flow_priority(priority)
    flow_entry1.set_flow_hard_timeout(0)
    flow_entry1.set_flow_idle_timeout(0)

    # Instructions/Actions for the Flow Entry
    instruction = Instruction(instruction_order=0)

    action_order = 0
    action = SetMplsTTLAction(action_order)
    action.set_ttl(act_mod_mpls_ttl)
    instruction.add_apply_action(action)

    action_order += 1
    action = OutputAction(action_order)
    action.set_outport(act_out_port)
    instruction.add_apply_action(action)

    flow_entry1.add_instruction(instruction)

    # Match Fields for the Flow Entry
    match = Match()

    match.set_in_port(match_in_port)
    match.set_eth_type(match_eth_type)
    match.set_mpls_label(match_mpls_label)

    flow_entry1.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry1.get_payload()
    time.sleep(rundelay)
    result = ofswitch.add_modify_flow(flow_entry1)
    status = result.get_status()
    if status.eq(STATUS.OK):
        print ("<<< Flow successfully added to the Controller")
    else:
#.........这里部分代码省略.........
开发者ID:jebpublic,项目名称:pybvc,代码行数:103,代码来源:demo42.py

示例13: Port

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
        "                Input Port (%s)\n"
        "                IPv4 Destination Address (%s)"% (hex(eth_type), in_port, ipv4_dst))
 print ("        Action: Push MPLS Header (Ethernet Type %s)\n"
        "                Set Field (MPLS label %s)\n"
        "                Output (Physical Port number %s)" % (hex(push_ether_type), 
                                                                 mpls_label, output_port))
 
 
 time.sleep(rundelay)
 
 
 flow_entry = FlowEntry()
 table_id = 0
 flow_id = 28
 flow_entry.set_flow_table_id(table_id)
 flow_entry.set_flow_name(flow_name = "Push MPLS Label")
 flow_entry.set_flow_id(flow_id )
 flow_entry.set_flow_hard_timeout(hard_timeout = 0)
 flow_entry.set_flow_idle_timeout(idle_timeout = 0)
 flow_entry.set_flow_priority(flow_priority = 1021)
 flow_entry.set_flow_cookie(cookie = 654)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 
 # --- Instruction: 'Apply-actions'
 #     Actions:     'Push MPLS Header'
 #                  'Set Field'
 #                  'Output'
 instruction = Instruction(instruction_order = 0)
 action = PushMplsHeaderAction(order = 0)
 action.set_eth_type(push_ether_type)
 instruction.add_apply_action(action)
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo22.py

示例14: print

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr, nodeName))

    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print (
        "        Match:  Ethernet Type (%s)\n"
        "                IPv6 Source Address (%s)\n"
        "                IPv6 Destination Address (%s)" % (hex(eth_type), ipv6_src, ipv6_dst)
    )
    print ("        Action: Output (to %s)" % output_port)

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    flow_entry.set_flow_name(flow_name="match=ipv6_src,ipv6_dst;actions=output:Controller")
    table_id = 0
    flow_id = 23
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1014)
    flow_entry.set_flow_cookie(cookie=408)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)
    flow_entry.set_flow_hard_timeout(hard_timeout=3400)
    flow_entry.set_flow_idle_timeout(idle_timeout=3400)

    # --- Instruction: 'Apply-actions'
    #     Actions:     'Output'
    instruction = Instruction(instruction_order=0)
    action = OutputAction(order=0, port=output_port)
    instruction.add_apply_action(action)
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:32,代码来源:demo16.py

示例15: of_demo_25

# 需要导入模块: from pybvc.openflowdev.ofswitch import FlowEntry [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.FlowEntry import set_flow_name [as 别名]
def of_demo_25():
    f = "cfg.yml"
    d = {}
    if(load_dict_from_file(f, d) is False):
        print("Config file '%s' read error: " % f)
        exit()

    try:
        ctrlIpAddr = d['ctrlIpAddr']
        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
        rundelay = d['rundelay']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 25 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")



    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    table_id = 0
    priority = 500
    cookie = 1000
    cookie_mask = 255
    customer_port = 110
    provider_port = 111
    qinq_eth_type = ETH_TYPE_STAG   # 802.1ad (QinQ) VLAN tagged frame
    dot1q_eth_type = ETH_TYPE_CTAG  # 802.1q VLAN tagged frame
    arp_eth_type = ETH_TYPE_ARP
    ip_eth_type = ETH_TYPE_IPv4
    provider_vlan_id = 100          # Provider VLAN
    customer_vlan_id = 998          # Customer VLAN
    first_flow_id = 31

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'"
           % (ctrlIpAddr, nodeName))

    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    print "\n"
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Ethernet Type (%s)\n"
           "                VLAN ID (%s)\n"
           "                Input Port (%s)"
           % (hex(arp_eth_type), customer_vlan_id, customer_port))
    print ("        Action: Push VLAN (Ethernet Type %s)\n"
           "                Set Field (VLAN ID %s)\n"
           "                Push VLAN (Ethernet Type %s)\n"
           "                Set Field (VLAN ID %s)\n"
           "                Output (Physical Port number %s)"
           % (hex(qinq_eth_type), provider_vlan_id,
              hex(dot1q_eth_type), customer_vlan_id,
              provider_port))

    time.sleep(rundelay)

    flow_id = first_flow_id
    flow_entry1 = FlowEntry()
    flow_entry1.set_flow_table_id(table_id)
    fname = "[MLX1-A] Test flow (match:inport=110,arp;" + \
            "actions:push-QINQ-tag,mod_vlan=100," + \
            "push-DOT1Q-tag,mod_vlan=998,output:111)"
    flow_entry1.set_flow_name(flow_name=fname)
    flow_entry1.set_flow_id(flow_id)
    flow_entry1.set_flow_hard_timeout(hard_timeout=600)
    flow_entry1.set_flow_idle_timeout(idle_timeout=300)
    flow_entry1.set_flow_priority(priority)
    flow_entry1.set_flow_cookie(cookie)
    flow_entry1.set_flow_cookie_mask(cookie_mask)

    instruction = Instruction(instruction_order=0)

    action_order = 0
    action = PushVlanHeaderAction(action_order)
    action.set_eth_type(qinq_eth_type)
    instruction.add_apply_action(action)

    action_order += 1
    action = SetFieldAction(action_order)
    action.set_vlan_id(provider_vlan_id)
    instruction.add_apply_action(action)

    action_order += 1
    action = PushVlanHeaderAction(action_order)
    action.set_eth_type(dot1q_eth_type)
    instruction.add_apply_action(action)

    action_order += 1
    action = SetFieldAction(action_order)
    action.set_vlan_id(customer_vlan_id)
    instruction.add_apply_action(action)

#.........这里部分代码省略.........
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:103,代码来源:demo25.py


注:本文中的pybvc.openflowdev.ofswitch.FlowEntry.set_flow_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。