Beispiel #1
0
    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
Beispiel #2
0
        "                UDP Destination Port (%s)" %
        (hex(eth_type), ipv6_src, ipv6_dst, ip_dscp, udp_src_port,
         udp_dst_port))
    print("        Action: Output (to %s)" % output_port)

    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
Beispiel #3
0
           "                IP DSCP (%s)\n"
           "                Input Port (%s)" %
           (hex(eth_type), eth_src,
            eth_dst, ipv4_src, ipv4_dst,
            ip_proto, ip_dscp,
            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=1006)
    flow_entry.set_flow_cookie(cookie=100)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)

    # --- 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
Beispiel #4
0
            arp_src_hw_addr,
            arp_tgt_hw_addr,
        )
    )
    print ("        Action: Output (CONTROLLER)")

    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
Beispiel #5
0
 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)
Beispiel #6
0
            match_ipv4_dst))
    print ("        Action: 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)
Beispiel #7
0
    print "\n"
    print("<<< Set OpenFlow flow on the Controller")
    print(
        "        Match:  Ethernet Type (%s)\n"
        "                IPv4 Source Address (%s)" % (hex(eth_type), ipv4_src))
    print("        Action: Drop")

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 12
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1000)

    # --- Instruction: 'Apply-actions'
    #     Action:      'Drop'
    instruction = Instruction(instruction_order=0)
    action = DropAction(order=0)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   IPv4 Source Address
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv4_src(ipv4_src)
    flow_entry.add_match(match)
Beispiel #8
0
            eth_dst, ipv4_src, ipv4_dst,
            ip_proto, ip_dscp, ip_ecn,
            icmpv4_type, icmpv4_code,
            input_port))
    print ("        Action: Output (NORMAL)")

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 18
    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(1009)

    # --- 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
Beispiel #9
0
          (ctrlIpAddr, nodeName))

    flow_table_id = 0
    flow_id_base = 12
    flow_id = flow_id_base
    flowEntries = []

    # Sample flow entry
    flow_entry = FlowEntry()
    flow_entry.set_flow_cookie(6001)
    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(12000)
    flow_entry.set_flow_hard_timeout(12000)
    flow_entry.set_flow_priority(1000)

    instruction = Instruction(instruction_order=0)
    action = DropAction(order=0)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    match = Match()
    match.set_eth_type(ETH_TYPE_ARP)
    match.set_eth_src("00:11:22:33:44:55")
    match.set_eth_dst("aa:bb:cc:dd:ee:ff")
    flow_entry.add_match(match)

    flowEntries.append(flow_entry)

    # Sample flow entry
Beispiel #10
0
    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)
    action = SetFieldAction(order=1)
    action.set_mpls_label(mpls_label)
    instruction.add_apply_action(action)
    action = OutputAction(order=2, port=output_port)
Beispiel #11
0
        "                ARP Source Hardware Address (%s)\n"
        "                ARP Target Hardware Address (%s)" %
        (hex(eth_type), eth_src, eth_dst, arp_opcode, arp_src_ipv4_addr,
         arp_tgt_ipv4_addr, arp_src_hw_addr, arp_tgt_hw_addr))
    print("        Action: Output (CONTROLLER)")

    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
Beispiel #12
0
 print ("        Action: 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)
Beispiel #13
0
                                                           icmpv4_type, icmpv4_code,
                                                           input_port))
 print ("        Action: Output (NORMAL)")
 
 
 time.sleep(rundelay)
 
 
 flow_entry = FlowEntry()
 table_id = 0
 flow_entry.set_flow_table_id(table_id)
 flow_id = 18
 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(1009)
 
 # --- 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
Beispiel #14
0
 
 
 flow_table_id = 0
 flow_id_base = 12
 flow_id = flow_id_base
 flowEntries = []
 
 # Sample flow entry
 flow_entry = FlowEntry()
 flow_entry.set_flow_cookie(6001)
 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(12000)
 flow_entry.set_flow_hard_timeout(12000)
 flow_entry.set_flow_priority(1000)
 
 instruction = Instruction(instruction_order = 0)
 action = DropAction(order = 0)
 instruction.add_apply_action(action)
 flow_entry.add_instruction(instruction)
 
 match = Match()
 match.set_eth_type(ETH_TYPE_ARP)
 match.set_eth_src("00:11:22:33:44:55")
 match.set_eth_dst("aa:bb:cc:dd:ee:ff")
 flow_entry.add_match(match)
 
 flowEntries.append(flow_entry)
 
 # Sample flow entry