Ejemplo n.º 1
0
        "                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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    print("<<< Set OpenFlow flow on the Controller")
    print(
        "        Match:  Ethernet Type (%s)\n"
        "                IPv6 Source Address (%s)\n"
        "                IPv6 Destination Address (%s)\n"
        "                IP DSCP (%s)\n"
        "                UDP Source Port (%s)\n"
        "                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)
Ejemplo n.º 4
0
           "                IPv4 Destination Address (%s)" %
           (match_in_port,
            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
Ejemplo n.º 5
0
 
 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)
Ejemplo n.º 6
0
    print ("<<< Set OpenFlow flow on the Controller")
    print ("        Match:  Ethernet Type (%s)\n"
           "                IPv6 Source Address (%s)\n"
           "                IPv6 Destination Address (%s)\n"
           "                IPv6 Flow Label (%s)\n"
           "                IP DSCP (%s)\n"
           "                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)
Ejemplo n.º 7
0
 print ("        Match:  Ethernet Type (%s)\n"
        "                Input Port (%s)\n"
        "                MPLS Label (%s)"%     (hex(eth_type), in_port, mpls_label))
 print ("        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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    print ("        Match:  Ethernet Type (%s)\n"
           "                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)
Ejemplo n.º 10
0
    print("<<< Set OpenFlow flow on the Controller")
    print(
        "        Match:  Ethernet Type (%s)\n"
        "                Ethernet Source Address (%s)\n"
        "                Ethernet Destination Address (%s)\n"
        "                Input Port (%s)" %
        (hex(eth_type), eth_src, eth_dst, 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 100")
    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-actions'
    #     Actions:     'PushVlan'
    #                  'SetField'
    #                  'Output'
    instruction = Instruction(instruction_order=0)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
        % (match_in_port,
           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
Ejemplo n.º 13
0
           (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()
    fname = "match=ipv6_src,ipv6_dst;actions=output:Controller"
    flow_entry.set_flow_name(flow_name=fname)
    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)
Ejemplo n.º 14
0
        "                Input Port (%s)\n"
        "                MPLS Label (%s)" %
        (hex(eth_type), in_port, mpls_label))
    print(
        "        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)
Ejemplo n.º 15
0
        "                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
Ejemplo n.º 16
0
           "                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