Beispiel #1
0
           "                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
    #                   IP Protocol Number
Beispiel #2
0
        "        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
Beispiel #3
0
            hex(match_ip_eth_type),
            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)
Beispiel #4
0
                                                         % 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)
Beispiel #5
0
        "                Output (Physical Port number %s)" % (pop_ether_type, output_port))
 
 
 time.sleep(rundelay)
 
 
 flow_entry = FlowEntry()
 table_id = 0
 flow_id = 30
 flow_entry.set_flow_table_id(table_id)
 flow_entry.set_flow_id(flow_id)
 flow_entry.set_flow_name(flow_name = "Strip 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 = 1023)
 flow_entry.set_flow_cookie(cookie = 889)
 flow_entry.set_flow_cookie_mask(cookie_mask = 255)
 
 # --- Instruction: 'Apply-actions'
 #     Actions:     'Pop MPLS Header'
 #                  'Output'
 instruction = Instruction(instruction_order = 0)
 action = PopMplsHeaderAction(order = 0)
 action.set_eth_type(pop_ether_type)
 instruction.add_apply_action(action)
 action = OutputAction(order = 1, port = output_port)
 instruction.add_apply_action(action)
 flow_entry.add_instruction(instruction)
 
 # --- Match Fields: Ethernet Type
 #                   Input Port
Beispiel #6
0
    rundelay = 5

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

    print("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
          (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")
Beispiel #7
0
           "                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)
    instruction.add_apply_action(action)
Beispiel #8
0
           "                TCP Source Port (%s)\n"
           "                TCP Destination Port (%s)" %
           (hex(eth_type), ipv6_src, ipv6_dst, ipv6_flabel,
            ip_dscp, tcp_src_port, tcp_dst_port))
    print ("        Action: Output (to %s)" % (output_port))

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    flow_entry.set_flow_name(flow_name="demo19.py")
    table_id = 0
    flow_id = 25
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1018)
    flow_entry.set_flow_cookie(cookie=23)
    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
    #                   IPv6 Source Address
    #                   IPv6 Destination Address
    #                   IPv6 Flow Label
    #                   IP protocol number (TCP)
Beispiel #9
0
                                                           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
 #                   IP Protocol Number
Beispiel #10
0
           "                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
Beispiel #11
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)
Beispiel #12
0
        "        Action: Pop MPLS (Ethernet Type %s)\n"
        "                Output (Physical Port number %s)" %
        (pop_ether_type, output_port))

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    table_id = 0
    flow_id = 30
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_name(flow_name="Strip 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=1023)
    flow_entry.set_flow_cookie(cookie=889)
    flow_entry.set_flow_cookie_mask(cookie_mask=255)

    # --- Instruction: 'Apply-actions'
    #     Actions:     'Pop MPLS Header'
    #                  'Output'
    instruction = Instruction(instruction_order=0)
    action = PopMplsHeaderAction(order=0)
    action.set_eth_type(pop_ether_type)
    instruction.add_apply_action(action)
    action = OutputAction(order=1, port=output_port)
    instruction.add_apply_action(action)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   Input Port
Beispiel #13
0
        "                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
Beispiel #14
0
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (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")
Beispiel #15
0
        "                TCP Source Port (%s)\n"
        "                TCP Destination Port (%s)" %
        (hex(eth_type), ipv6_src, ipv6_dst, ipv6_flabel, ip_dscp, tcp_src_port,
         tcp_dst_port))
    print("        Action: Output (to %s)" % output_port)

    time.sleep(rundelay)

    flow_entry = FlowEntry()
    flow_entry.set_flow_name(flow_name="demo19.py")
    table_id = 0
    flow_id = 25
    flow_entry.set_flow_table_id(table_id)
    flow_entry.set_flow_id(flow_id)
    flow_entry.set_flow_priority(flow_priority=1018)
    flow_entry.set_flow_cookie(cookie=23)
    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
    #                   IPv6 Source Address
    #                   IPv6 Destination Address
    #                   IPv6 Flow Label
    #                   IP protocol number (TCP)