Example #1
0
    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)

    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) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
        print("!!!Demo terminated, reason: %s" % status.brief().lower())
Example #2
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()    
 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)
 match.set_ip_proto(ip_proto)
 match.set_ip_dscp(ip_dscp)
 match.set_ip_ecn(ip_ecn)    
 match.set_udp_src_port(udp_src_port)
 match.set_udp_dst_port(udp_dst_port)
 match.set_in_port(in_port = input_port)    
 flow_entry.add_match(match)
 
 
 print ("\n")
Example #3
0
    # 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
    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)
Example #4
0
    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)
    result = ofswitch.add_modify_flow(flow_entry1)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("<<< Flow successfully added to the Controller")
Example #5
0
    #                  '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)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   Input Port
    #                   IPv4 Destination Address
    match = Match()
    match.set_eth_type(eth_type)
    match.set_in_port(in_port)
    match.set_ipv4_dst(ipv4_dst)
    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")
Example #6
0
    # --- 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)
    #                   IP DSCP
    #                   TCP Source Port
    #                   TCP Destination Port
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ip_proto(ip_proto)
    match.set_ip_dscp(ip_dscp)
    match.set_tcp_src_port(tcp_src_port)
    match.set_tcp_dst_port(tcp_dst_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)
Example #7
0
 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_eth_src(eth_src)
 match.set_eth_dst(eth_dst)
 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()
 if(status.eq(STATUS.OK) == True):
     print ("<<< Flow successfully added to the Controller")
Example #8
0
 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()
 time.sleep(rundelay)
 result = ofswitch.add_modify_flow(flow_entry1)
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("<<< Flow successfully added to the Controller")
Example #9
0
    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)
    match.set_ip_dscp(ip_dscp)
    match.set_ip_ecn(ip_ecn)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ip_proto(ip_proto)
    match.set_icmpv6_type(icmpv6_type)
    match.set_icmpv6_code(icmpv6_code)
    match.set_metadata(metadata)
    flow_entry.add_match(match)

    print("\n")
    print("<<< Flow to send:")
    print flow_entry.get_payload()
Example #10
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
    #                   IPv6 Extension Header
    #                   IP protocol number (TCP)
    #                   TCP Source Port
    #                   TCP Destination Port
    #                   Metadata
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ip_dscp(ip_dscp)
    match.set_ip_ecn(ip_ecn)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ipv6_exh_hdr(ipv6_exthdr)
    match.set_ip_proto(ip_proto)
    match.set_tcp_src_port(tcp_src_port)
    match.set_tcp_dst_port(tcp_dst_port)
    match.set_metadata(metadata)
    flow_entry.add_match(match)

    print("\n")
    print("<<< Flow to send:")
Example #11
0
    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()
    if (status.eq(STATUS.OK) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
Example #12
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
    #                   IPv6 Extension Header
    #                   IP protocol number (TCP)
    #                   TCP Source Port
    #                   TCP Destination Port
    #                   Metadata
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ip_dscp(ip_dscp)
    match.set_ip_ecn(ip_ecn)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ipv6_exh_hdr(ipv6_exthdr)
    match.set_ip_proto(ip_proto)
    match.set_tcp_src_port(tcp_src_port)
    match.set_tcp_dst_port(tcp_dst_port)
    match.set_metadata(metadata)
    flow_entry.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
Example #13
0
 # 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
 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)
Example #14
0
 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()
 if(status.eq(STATUS.OK) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
Example #15
0
 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)
 result = ofswitch.add_modify_flow(flow_entry1)
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("<<< Flow successfully added to the Controller")
Example #16
0
    # --- 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
    #                   IP DSCP
    #                   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)
    match.set_ip_proto(ip_proto)
    match.set_ip_dscp(ip_dscp)
    match.set_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)
Example #17
0
 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)
 
 
 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) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
     print ("\n")
Example #18
0
 
 # --- 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)
 match.set_ip_dscp(ip_dscp)
 match.set_udp_src_port(udp_src_port)
 match.set_udp_dst_port(udp_dst_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)
Example #19
0
 # --- 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
 #                   IP DSCP
 #                   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)
 match.set_ip_proto(ip_proto)
 match.set_ip_dscp(ip_dscp)
 match.set_in_port(input_port)
 flow_entry.add_match(match)
 
 
 print ("\n")
 print ("<<< Flow to send:")
 print flow_entry.get_payload()
 time.sleep(rundelay)
Example #20
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
    #                   ICMPv4 Type
    #                   ICMPv4 Code
    #                   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)
    match.set_ip_proto(ip_proto)
    match.set_ip_dscp(ip_dscp)
    match.set_ip_ecn(ip_ecn)
    match.set_icmpv4_type(icmpv4_type)
    match.set_icmpv4_code(icmpv4_code)
    match.set_in_port(input_port)
    flow_entry.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
Example #21
0
 flow_entry.set_flow_table_id(table_id)
 flow_id = 14
 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
 #                   Ethernet Source Address
 #                   Ethernet Destination Address  
 match = Match()
 match.set_eth_type(eth_type)
 match.set_eth_src(eth_src)
 match.set_eth_dst(eth_dst)
 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) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
Example #22
0
 
 # --- 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
 #                   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) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
Example #23
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)

    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) == True):
        print("<<< Flow successfully added to the Controller")
Example #24
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)
 
 
 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) == True):
Example #25
0
 table_id = 0
 flow_entry.set_flow_table_id(table_id)
 flow_id = 11
 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 Destination Address
 match = Match()
 match.set_eth_type(eth_type)
 match.set_ipv4_dst(ipv4_dst)
 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) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
Example #26
0
    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)
    match.set_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()
    if (status.eq(STATUS.OK) == True):
Example #27
0
    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)
    match.set_ip_dscp(ip_dscp)
    match.set_ip_ecn(ip_ecn)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ip_proto(ip_proto)
    match.set_icmpv6_type(icmpv6_type)
    match.set_icmpv6_code(icmpv6_code)
    match.set_metadata(metadata)
    flow_entry.add_match(match)

    print ("\n")
    print ("<<< Flow to send:")
    print flow_entry.get_payload()
Example #28
0
    # --- 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)
    match.set_arp_opcode(arp_opcode)
    match.set_arp_src_transport_address(arp_src_ipv4_addr)
    match.set_arp_tgt_transport_address(arp_tgt_ipv4_addr)
    match.set_arp_src_hw_address(arp_src_hw_addr)
    match.set_arp_tgt_hw_address(arp_tgt_hw_addr)
    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)
Example #29
0
    table_id = 0
    flow_entry.set_flow_table_id(table_id)
    flow_id = 11
    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 Destination Address
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv4_dst(ipv4_dst)
    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) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
        print("!!!Demo terminated, reason: %s" % status.brief().lower())
Example #30
0
 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)
 flow_entry.add_instruction(instruction)
 
 # --- Match Fields: Ethernet Type
 #                   IPv6 Source Address
 #                   IPv6 Destination Address
 match = Match()
 match.set_eth_type(eth_type)
 match.set_ipv6_src(ipv6_src)
 match.set_ipv6_dst(ipv6_dst)
 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) == True):
     print ("<<< Flow successfully added to the Controller")
 else:
Example #31
0
    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)
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   IPv6 Source Address
    #                   IPv6 Destination Address
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    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) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
Example #32
0
    # --- 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)
    match.set_ip_dscp(ip_dscp)
    match.set_udp_src_port(udp_src_port)
    match.set_udp_dst_port(udp_dst_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()
Example #33
0
    # --- 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)
    match.set_arp_opcode(arp_opcode)
    match.set_arp_src_transport_address(arp_src_ipv4_addr)
    match.set_arp_tgt_transport_address(arp_tgt_ipv4_addr)
    match.set_arp_src_hw_address(arp_src_hw_addr)
    match.set_arp_tgt_hw_address(arp_tgt_hw_addr)
    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)
Example #34
0
    # --- 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) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
Example #35
0
    # --- 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)
    #                   IP DSCP
    #                   TCP Source Port
    #                   TCP Destination Port
    match = Match()
    match.set_eth_type(eth_type)
    match.set_ipv6_src(ipv6_src)
    match.set_ipv6_dst(ipv6_dst)
    match.set_ipv6_flabel(ipv6_flabel)
    match.set_ip_proto(ip_proto)
    match.set_ip_dscp(ip_dscp)
    match.set_tcp_src_port(tcp_src_port)
    match.set_tcp_dst_port(tcp_dst_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)