예제 #1
0
    time.sleep(rundelay)

    flow_entry = FlowEntry()
    flow_entry.set_flow_name(flow_name="demo17.py")
    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_hard_timeout(0)
    flow_entry.set_flow_idle_timeout(0)
    flow_entry.set_flow_priority(flow_priority=1015)

    # --- 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
    #                   IPv6 Source Address
    #                   IPv6 Destination Address
    #                   IP protocol number (UDP)
    #                   IP DSCP
    #                   UDP Source Port
    #                   UDP Destination Port
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ip_proto(ip_proto)
예제 #2
0
    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()
예제 #3
0
    flow_entry.add_match(match)

    flowEntries.append(flow_entry)

    # Sample flow entry
    flow_entry = FlowEntry()
    flow_entry.set_flow_cookie(7001)
    flow_entry.set_flow_table_id(flow_table_id)
    flow_entry.set_flow_id(flow_id)
    flow_id += 1
    flow_entry.set_flow_idle_timeout(2400)
    flow_entry.set_flow_hard_timeout(2400)
    flow_entry.set_flow_priority(2000)

    instruction = Instruction(instruction_order=0)
    action = OutputAction(order=0, port="CONTROLLER", max_len=60)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    match = Match()
    match.set_eth_type(ETH_TYPE_IPv4)
    match.set_ipv4_src("1.2.3.4/32")
    match.set_ipv4_dst("192.168.1.11/32")
    flow_entry.add_match(match)

    flowEntries.append(flow_entry)

    # Sample flow entry
    flow_entry = FlowEntry()
    flow_entry.set_flow_cookie(800)
    flow_entry.set_flow_table_id(flow_table_id)
예제 #4
0
파일: demo7.py 프로젝트: jebpublic/pydevodl
        (hex(eth_type), eth_src, eth_dst, ipv4_src, ipv4_dst, input_port))
    print("        Action: Output (CONTROLLER)")

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 15
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1005)

    # --- Instruction: 'Apply-actions'
    #     Action:      'Output' to CONTROLLER
    instruction = Instruction(instruction_order=0)
    action = OutputAction(order=0, port="CONTROLLER", max_len=60)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    #--- Match Fields: Ethernet Type
    #                  Ethernet Source Address
    #                  Ethernet Destination Address
    #                  IPv4 Source Address
    #                  IPv4 Destination Address
    #                  Input Port
    match = Match()
    match.set_eth_type(eth_type)
    match.set_eth_src(eth_src)
    match.set_eth_dst(eth_dst)
    match.set_ipv4_src(ipv4_src)
    match.set_ipv4_dst(ipv4_dst)
예제 #5
0
    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 19
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_hard_timeout(0)
    flow_entry.set_flow_idle_timeout(0)
    flow_entry.set_flow_priority(1010)

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

    # --- Match Fields: Ethernet Type
    #                   Ethernet Source Address
    #                   Ethernet Destination Address
    #                   ARP Operation
    #                   ARP Source IPv4 Address
    #                   ARP Target IPv4 Address
    #                   ARP Source Hardware Address
    #                   ARP Target Hardware Address
    match = Match()
    match.set_eth_type(eth_type)
    match.set_eth_src(eth_src)
    match.set_eth_dst(eth_dst)
예제 #6
0
        (group_type.strip('group-').upper(), group_id, group_name))
    print("        Buckets    :")
    print("                     [0] actions: Output (%s)") % out_port1
    print("                     [1] actions: Output (%s)") % out_port2
    print("                     [2] actions: Output (%s)") % out_port3
    time.sleep(rundelay)

    # Allocate a placeholder for the group entry
    group_entry = GroupEntry(group_id, group_type)
    group_entry.set_group_name(group_name)

    # Fill in group entry with action buckets
    # ---------
    bucket_id = 0
    bucket1 = GroupBucket(bucket_id)
    action = OutputAction(order=0, port=out_port1)
    bucket1.add_action(action)
    group_entry.add_bucket(bucket1)

    # ---------
    bucket_id += 1
    bucket2 = GroupBucket(bucket_id)
    action = OutputAction(order=0, port=out_port2)
    bucket2.add_action(action)
    group_entry.add_bucket(bucket2)

    # ---------
    bucket_id += 1
    bucket3 = GroupBucket(bucket_id)
    action = OutputAction(order=0, port=out_port3)
    bucket3.add_action(action)
예제 #7
0
    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 20
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_hard_timeout(0)
    flow_entry.set_flow_idle_timeout(0)
    flow_entry.set_flow_priority(1011)

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

    # --- Match Fields: Ethernet Type
    #                   Ethernet Source Address
    #                   Ethernet Destination Address
    #                   VLAN ID
    #                   VLAN PCP
    match = Match()
    match.set_eth_type(eth_type)
    match.set_eth_src(eth_src)
    match.set_eth_dst(eth_dst)
    match.set_vlan_id(vlan_id)
    match.set_vlan_pcp(vlan_pcp)
    flow_entry.add_match(match)
예제 #8
0
    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 17
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_hard_timeout(0)
    flow_entry.set_flow_idle_timeout(0)
    flow_entry.set_flow_priority(flow_priority=1008)

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

    # --- Match Fields: Ethernet Type
    #                   Ethernet Source Address
    #                   Ethernet Destination Address
    #                   IPv4 Source Address
    #                   IPv4 Destination Address
    #                   IP Protocol Number
    #                   IP DSCP
    #                   IP ECN
    #                   UDP Source Port Number
    #                   UDP Destination Port Number
    #                   Input Port
    match = Match()
예제 #9
0
 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")
예제 #10
0
파일: demo35.py 프로젝트: Elbrys/pydevodl
    time.sleep(rundelay)

    # Allocate a placeholder for the group entry
    group_entry = GroupEntry(group_id, group_type)
    group_entry.set_group_name(group_name)

    # Fill actions bucket with the set of actions
    bucket_id = 0
    bucket = GroupBucket(bucket_id)

    action_order = 0
    action1 = PopVlanHeaderAction(action_order)
    bucket.add_action(action1)

    action_order += 1
    action2 = OutputAction(action_order)
    action2.set_outport(out_port)
    bucket.add_action(action2)

    # Add actions bucket to the group entry
    group_entry.add_bucket(bucket)

    # Request Controller to create the group
    print "\n".strip()
    print ("<<< Group to create:")
    print group_entry.get_payload()
    time.sleep(rundelay)
    result = ofswitch.add_modify_group(group_entry)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("<<< Group successfully added")
예제 #11
0
 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)
 
 action_order += 1
 action = OutputAction(action_order, provider_port)
 instruction.add_apply_action(action)
 
 flow_entry1.add_instruction(instruction)
 
 match = Match()
 
 match.set_eth_type(arp_eth_type)
 match.set_vlan_id(customer_vlan_id)
 match.set_in_port(in_port = customer_port)
 
 flow_entry1.add_match(match)
 
 print ("\n")
 print ("<<< Flow to send:")
 print flow_entry1.get_payload()