Merge pull request #25 from InCNTRE/master
Counters.py & detailed testing methodology
diff --git a/Detailed_Testing_Methodology.txt b/Detailed_Testing_Methodology.txt
index a2c94e2..34922cc 100644
--- a/Detailed_Testing_Methodology.txt
+++ b/Detailed_Testing_Methodology.txt
@@ -979,3 +979,844 @@
24. Sequential execution -- TBD
+
+
+
+
+**** Counters ****
+
+
+
+1. Received Packets per Flow
+
+
+Test Description: Verify that packet_count in the Flow_Stats reply increments in accordance with the packets in flow
+
+Test mode: Automated
+Test Tile: PktPerFlow
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow , match = ingress_port
+b) Send N packet matching the flow i.e packets should be sent on ingress_port
+c) Send flow_stats_request for the flow
+d) Verify packet_count = N in the flow_stats_reply
+
+
+
+2. Received Bytes per Flow
+
+
+Test Description: Verify that byte_count in the Flow_Stats reply increments in accordance with the bytes in flow
+
+Test mode: Automated
+Test Tile: BytPerFlow
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow , match = ingress_port
+b) Send N packet matching the flow i.e packets should be sent on ingress_port
+c) Send flow_stats_request for the flow
+d) Verify byte_count = N*(no. of bytes in one packet) in the flow_stats_reply
+
+
+
+3. Duration in sec per Flow
+
+
+Test Description: Verify that duration_sec in the Flow_Stats reply increments in accordance with the time that flow was alive in sec
+
+Test mode: Automated
+Test Tile: DurationPerFlow
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a any flow
+b) Send flow_stats_request for that flow periodically after n sec intervals upto timeout of y
+c) Verify each flow_stats_reply has duration_sec field incrementing as n , 2n , 3n .. y
+
+
+
+4. Duration in nsec per flow
+
+
+Test Description: Verify that duration_nsec in the flow_stats repl increments in accordance with the time flow has been alive in nanoseconds
+beyond duration_sec.
+
+Test mode: Automated
+Test Tile: DurationPerFlow
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert any flow
+b) Send flow_stats_request periodically after n sec intervals upto timeout of y
+c) Verify each flow_stats_reply has duration_sec field incrementing as n , 2n , 3n .. y and read out duration_nsec field ( Verification of nsec field
+is out of scope)
+
+
+
+5. Received packets per port
+
+
+Test Description: Verify that rx_packets in the Port_Stats reply increments in accordance with the packets recieved on that port
+
+Test mode: Automated
+Test Tile: RxPktPerPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port
+b) Send N packets on the ingress_port
+c) Send port_stats request for port=ingress_port
+d) Verify port_stats_reply has rx_packet=N
+
+
+
+
+6. Transmitted packets per port
+
+
+Test Description: Verify that tx_packets in the Port_Stats reply increments in accordance with the packets transmitted from a port
+
+Test mode: Automated
+Test Tile: TxPktPerPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port, action output = egress_port
+b) Send N packets on the ingress_port
+c) Send port_stats request for port=ingress_port
+d) Verify port_stats_reply had tx_packets=N
+
+
+
+7. Received Bytes per port
+
+
+Test Description: Verify that rx_bytes in the Port_Stats reply increments in accordance with the bytes recieved on a port
+
+Test mode: Automated
+Test Tile: RxBytPerPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port, action output = egress_port
+b) Send N packet matching the flow
+c) Send port_stats request for port=ingress_port
+d) Verify port_stats_reply had rx_bytes=N*(no. of bytes in a packet)
+
+
+
+8. Transmitted Bytes per port
+
+
+Test Description: Verify that tx_bytes in the Port_Stats reply increments in accordance with the bytes transmitted from a port
+
+Test mode: Automated
+Test Tile: TxBytPerPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port, action output = egress_port
+b) Send N packet matching the flow
+c) Send port_stats request for port=ingress_port
+d) Verify port_stats_reply had tx_bytes=N*(no. of bytes in a packet)
+
+
+
+9. Recieve Drops per port (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX
+
+Test mode: Automated
+Test Tile: RxDrops
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+Test Notes :
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has rx_dropped count
+
+
+
+
+
+10. Transmit Drops per port (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX
+
+Test mode: Automated
+Test Tile: TxDrops
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Manadatory
+
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has tx_dropped count
+
+
+
+
+11. Recieve Errors (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error
+ This is a super-set of more specific receive errors and should be greater than or equal to the sum of all
+ rx_*_err values.
+
+Test mode: Automated
+Test Tile: RxErrors
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has rx_errors count
+
+
+
+12. Transmit Errors (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit errors
+
+Test mode: Automated
+Test Tile: TxErrors
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has tx_errors count
+
+
+
+13. Recieve Frame Errors (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors
+Test mode: Automated
+Test Tile: RxFrameErr
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has rx_frame_err count
+
+
+
+14. Recieve Overrun Errors (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun
+
+Test mode: Automated
+Test Tile: RxOErr
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has rx_over_err count
+
+
+15. CRC Errors (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors
+
+Test mode: Automated
+Test Tile: RxCrcErr
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Manadatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has rx_crc_err count
+
+
+
+16. Collisions (TBD ---> Verification of counter incrementing correctly)
+
+
+Test Description: Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch
+
+Test mode: Automated
+Test Tile: Collisions
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Send port_stats request for port=ingress_port
+b) Verify port_stats reply has collisions count
+
+
+
+17. Active Entries per Table
+
+
+Test Description: Verify that active_count in the table increments in accordance with the flows inserted in the table
+
+Test mode: Automated
+Test Tile: ActiveCount
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow
+b) Send table_stats_request
+c) Verify active_count=1
+
+
+
+18. Packet Lookup per Table
+
+
+Test Description: Verify that lookup_count in the Table_Stats reply increments in accordance with the number of packets looked up in table
+
+Test mode: Automated
+Test Tile: LookupMatchedCount
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port
+b) Send N packets on ingress_port (matching the flow)
+c) Send N' packets on x port (Not matching the flow)
+d) Send table_stats_request
+e) Verify lookup_count = N+N'
+
+
+
+19. Packets matched per Table
+
+Test Description: Verify that matched_count in the Table_Stats reply increments in accordance with the number of packets matched with the table
+
+Test mode: Automated
+Test Tile: LookupMatchedCount
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match on ingress_port
+b) Send N packets on ingress_port (matching the flow)
+c) Send N' packets on x port (Not matching the flow)
+d) Send table_stats_request
+e) Verify matched_count = N
+
+
+
+
+20. Transmit Packets per Queue
+
+Test Description: Verify that tx_packets in the queue_stats reply increments in accordance with the number of transmitted packets
+
+Test mode: Automated
+Test Tile: TxPktPerQueue
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Optional
+
+
+Test Notes:
+
+a) Send queue_stats request for ports=ofp.OFPP_ALL and queue_ids=ofp.OFPQ_ALL (i.e all ports and all queues)
+b) Send queue_stats request for egress_port[0] and queue_id[0] and note the tx_packets count in the reply
+c) Insert a flow entry with enqueue action , port = egress_port[0] queue_id= queue_id[0]
+d) Send packet matching the flow
+e) Send queue_stats request again, verify tx_packet count incremented
+f) Repeat b , c , d , e for all the queue_ids configured for egress_port[0]
+h) Repeat b , c , d , e , f for all the egress_ports available
+
+
+
+
+21. Transmit Bytes per Queue
+
+Test Description: Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes
+
+Test mode: Automated
+Test Tile: TxBytPerQueue
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Optional
+
+
+Test Notes:
+
+a) Send queue_stats request for ports=ofp.OFPP_ALL and queue_ids=ofp.OFPQ_ALL (i.e all ports and all queues)
+b) Send queue_stats request for egress_port[0] and queue_id[0] and note the tx_bytes count in the reply
+c) Insert a flow entry with enqueue action , port = egress_port[0] queue_id= queue_id[0]
+d) Send packet matching the flow
+e) Send queue_stats request again, verify tx_byte count incremented
+f) Repeat b , c , d , e for all the queue_ids configured for egress_port[0]
+h) Repeat b , c , d , e , f for all the egress_ports available
+
+
+
+22. Transmit Overrun Errors per queue (TBD ----> Verification of tx_error count being incremented correctly)
+
+Test Description: Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun.
+Test mode: Automated
+Test Tile: TxErrorPerQueue
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Optional
+
+Test Notes:
+
+
+a) Send queue_stats request for port=egress_port and queue_ids=ofp.OFPQ_ALL
+B) send queue_stats request for egress_port and queue_id[0] (i.e first queue configured for egress_port)
+c) Verify reply has tx_errors count .
+d) Repear b , c for the all queue_ids of egress_port
+
+
+
+
+
+**** Flow matches ****
+
+
+
+1. All Wildcard Match
+
+Test Description: Adding a Flow that matches all the possible fields
+
+Test mode: Automated
+Test Tile: AllWildcardMatch
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with wildcard = OFPFW_ALL (wildcard all fields), action output to egress_port
+b) Send packets with different header fields
+c) Verify all packets match the flow and implement the action specified.
+
+
+2. Single Header Field: Ingress Port
+
+Test Description: Match on Ingress Port and Wildcard rest
+
+Test mode: Automated
+Test Tile: IngressPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = in_port (say port x), action output to egress_port
+b) Send packet on port x
+c) Verify packet was recieved on egress_port
+d) Send packet on port y
+e) Verify PacketIn event was triggered on control plane
+
+
+
+3. Single Header Field: Ethernet Src Address
+
+Test Description: Match on Ethernet Source Address and Wildcard rest
+
+Test mode: Automated
+Test Tile: EthernetSrcAddress
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_src (say x) , action output to egress_port
+b) Send packet wth dl_src = x
+c) Verify packet was recieved on egress_port
+d) Send packet with dl_src = y
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+4. Single Header Field: Ethernet Dst Address
+
+Test Description: Match on Ethernet Destination Address and Wildcard rest
+
+Test mode: Automated
+Test Tile: EthernetDstAddress
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_dst (say x) , action output to egress_port
+b) Send packet wth dl_dst = x
+c) Verify packet was recieved on egress_port
+d) Send packet with dl_dst = y
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+5. Single Header Field: Ethernet Type
+
+Test Description: Match on Ehternet Type and Wildcard rest
+
+Test mode: Automated
+Test Tile: EthernetType
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_type (say x) , action output to egress_port
+b) Send packet wth dl_type = x
+c) Verify packet was recieved on egress_port
+d) Send packet with dl_type = y
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+
+6. Single Header Field: Vlan Id
+
+Test Description: Match on Ingress Port and Wildcard rest
+
+Test mode: Automated
+Test Tile: VlanId
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_vlan (say x) , action output to egress_port
+b) Send a tagged packet with (dl_vlan_enable=True,dl_vlan = x)
+c) Verify packet was recieved on egress_port
+d) Send another tagged packet with (dl_vlan_enable=True,dl_vlan = y )
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+
+7. Single Header Field: Vlan PCP
+
+Test Description: Match on Vlan ID Priority
+
+Test mode: Automated
+Test Tile: VlanPcp
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_vlan_pcp (say x) , action output to egress_port
+b) Send a tagged packet with (dl_vlan_enable=True, dl_vlan = * , dl_vlan_pcp = x)
+c) Verify packet was recieved on egress_port
+b) Send a tagged packet with (dl_vlan_enable=True, dl_vlan = * , dl_vlan_pcp = y)
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+
+
+8. Single Header Field: IP Src Address -------- > (TBD)
+
+Test Description: Match on IP Src Address and Wildcard rest
+
+Test mode: Automated
+Test Tile: IPSrcAddress
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+
+
+9. Single Header Field: IP Dst Address -----------> (TBD)
+
+Test Description: Match on IP Dst Address and Wildcard rest
+
+Test mode: Automated
+Test Tile: IPDstAddress
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+
+
+
+10. Single Header Field: IP protocol---------------> (TBD)
+
+Test Description: Match on IP Protocol and Wildcard rest
+
+Test mode: Automated
+Test Tile: IPprotocol
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+
+
+
+
+11. Single Header Field: IP Tos bits
+
+Test Description: Match on IP Tos bits and Wildcard rest
+
+Test mode: Automated
+Test Tile: IpTos
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = nw_tos (say x) , action output to egress_port
+b) Send a tcp packet with (nw_tos=x)
+c) Verify packet was recieved on egress_port
+b) Send a tcp packet with (nw_tos = y)
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+12. Single Header Field: Transport Source Port
+
+Test Description: Match on Transport Src Port and Wildcard rest
+
+Test mode: Automated
+Test Tile: TcpSrcPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = tp_src (say x) , action output to egress_port
+b) Send a tcp packet with (tp_src=x)
+c) Verify packet was recieved on egress_port
+b) Send a tcp packet with tp_src= y)
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+13. Single Header Field: Transport Destination Port
+
+Test Description: Match on Transport Dst Port and Wildcard rest
+
+Test mode: Automated
+Test Tile: TcpDstPort
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = tp_dst (say x) , action output to egress_port
+b) Send a tcp packet with (tp_dst=x)
+c) Verify packet was recieved on egress_port
+b) Send a tcp packet with tp_dst = y)
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+
+14. Multiple Header Fields: L2
+
+
+Test Description: Match on Ethernet Type, Ethernet Source Address, Ethernet Destination Address and Wildcard rest
+
+Test mode: Automated
+Test Tile: MultipleHeaderFieldL2
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = dl_type (say x), dl_src (say y ), dl_dst (say z), action output to egress_port
+b) Send a eth packet with dl_type (say x), dl_src (say y ), dl_dst (say z)
+c) Verify packet was recieved on egress_port
+b) Send a eth packet with dl_type (say w), dl_src (say v ), dl_dst (say f)
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+15. Multiple Header Fields: L3 ------> TBD
+
+
+
+
+16. Multiple Header Fields: L4
+
+Test Description: Match on Tcp Source Port, Tcp Destination Port
+
+Test mode: Automated
+Test Tile: MultipleHeaderFieldL4
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with match = tp_src (say x), tp_dst (say y )
+b) Send a tcp packet with tp_src (say x), tp_dst (say y )
+c) Verify packet was recieved on egress_port
+b) Send a eth packet with tcp_src (say w), tcp_dst (say v )
+e) Verify PacketIn event was triggered on the control plane
+
+
+
+17. All Header Fields: Exact Match flows
+
+Test Description: Verify exact flow matches are possible
+
+Test mode: Automated
+Test Tile: ExactMatch
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert a flow with exact match, action output to egress_port
+b) Send packet matching the flow
+c) Verify packet received on egress_port
+d) Send a non-matching packet
+e) Verify PacketIn event gets triggered
+
+
+
+18. Exact Match Highest Priority
+
+Test Description: An exact match flow entry has a highest priority compared to other flow entries
+
+Test mode: Automated
+Test Tile: ExactMatchHigh
+POrts: 4 (1 Control Plane 3 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert two overlapping flows:
+ Exact Match (prio = p ) action egress_port
+ Wildacrd All (prio = p+ ) action egress_port2
+b) Send packet matching the flows
+c) Verify packet received on egress_port
+
+
+
+
+19. Wildcard Match Highest Priority
+
+Test Description: If Wildcard flow entries have priority associated with them.
+ Higher priority Wildcard flow overrides the lower priroty Wildcard flow
+
+Test mode: Automated
+Test Tile: WildcardMatchHigh
+POrts: 4 (1 Control Plane 3 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
+
+
+Test Notes:
+
+a) Insert two wildcarded flows :
+ Wildcard All Except ingress (prio = p ) , action = egress_port
+ Wildcard All (prio = p+ ) ,action = egress_port2
+b) Send packet matching the flows
+c) Verify packet is recieved on egress_port2
+
+
+
+20. Fragment TCP Segments ------> TBD
+
+Test Description: Create flow matching on tcp port number. Verify that fragmented packets always match that flow rule.
+
+Test mode: Automated
+Test Tile: FragTcpSeg
+POrts: 3 (1 Control Plane 2 Data Plane)
+Initial State: Default (Clear switch state), Connection setup
+Test-Field: Mandatory
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 5cfcb6a..ad00246 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -12,272 +12,843 @@
import oftest.parse as parse
import logging
import types
+
import oftest.base_tests as base_tests
from oftest.testutils import *
from time import sleep
#################### Functions for various types of flow_mod ##########################################################################################
-def Exact_Match(self,of_ports,priority=0):
+def exact_match(self,of_ports,priority=None):
# Generate ExactMatch flow .
- #Create a simple tcp packet and generate exact flow match from it.
- Pkt_ExactFlow = simple_tcp_packet()
- match = parse.packet_to_flow_match(Pkt_ExactFlow)
- self.assertTrue(match is not None, "Could not generate flow match from pkt")
- match.in_port = of_ports[0]
- #match.nw_src = 1
- match.wildcards=0
- msg = message.flow_mod()
- msg.out_port = ofp.OFPP_NONE
- msg.command = ofp.OFPFC_ADD
- msg.buffer_id = 0xffffffff
- msg.match = match
- if priority != 0 :
- msg.priority = priority
+ #Create a simple tcp packet and generate exact flow match from it.
+ pkt_exactflow = simple_tcp_packet()
+ match = parse.packet_to_flow_match(pkt_exactflow)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+ match.in_port = of_ports[0]
+ #match.nw_src = 1
+ match.wildcards=0
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
- act = action.action_output()
- act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- return (Pkt_ExactFlow,match)
-
+ return (pkt_exactflow,match)
-def Match_All_Except_Source_Address(self,of_ports,priority=0):
+def exact_match_with_prio(self,of_ports,priority=None):
+ # Generate ExactMatch with action output to port 2
+
+ #Create a simple tcp packet and generate exact flow match from it.
+ pkt_exactflow = simple_tcp_packet()
+ match = parse.packet_to_flow_match(pkt_exactflow)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+ match.in_port = of_ports[0]
+ #match.nw_src = 1
+ match.wildcards=0
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[2]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_exactflow,match)
+
+
+def match_all_except_source_address(self,of_ports,priority=None):
# Generate Match_All_Except_Source_Address flow
- #Create a simple tcp packet and generate match all except src address flow.
- Pkt_WildcardSrc= simple_tcp_packet()
- match1 = parse.packet_to_flow_match(Pkt_WildcardSrc)
- self.assertTrue(match1 is not None, "Could not generate flow match from pkt")
- match1.in_port = of_ports[0]
- #match1.nw_src = 1
- match1.wildcards = ofp.OFPFW_DL_SRC
- msg1 = message.flow_mod()
- msg1.out_port = ofp.OFPP_NONE
- msg1.command = ofp.OFPFC_ADD
- msg1.buffer_id = 0xffffffff
- msg1.match = match1
- if priority != 0 :
- msg1.priority = priority
+ #Create a simple tcp packet and generate match all except src address flow.
+ pkt_wildcardsrc= simple_tcp_packet()
+ match1 = parse.packet_to_flow_match(pkt_wildcardsrc)
+ self.assertTrue(match1 is not None, "Could not generate flow match from pkt")
+ match1.in_port = of_ports[0]
+ #match1.nw_src = 1
+ match1.wildcards = ofp.OFPFW_DL_SRC
+ msg1 = message.flow_mod()
+ msg1.out_port = ofp.OFPP_NONE
+ msg1.command = ofp.OFPFC_ADD
+ msg1.buffer_id = 0xffffffff
+ msg1.match = match1
+ if priority != None :
+ msg1.priority = priority
- act1 = action.action_output()
- act1.port = of_ports[1]
- self.assertTrue(msg1.actions.add(act1), "could not add action")
+ act1 = action.action_output()
+ act1.port = of_ports[1]
+ self.assertTrue(msg1.actions.add(act1), "could not add action")
- rv = self.controller.message_send(msg1)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ rv = self.controller.message_send(msg1)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- return (Pkt_WildcardSrc,match1)
+ return (pkt_wildcardsrc,match1)
+
+def match_wthernet_src_address(self,of_ports,priority=None):
+ #Generate Match_Ethernet_SrC_Address flow
+
+ #Create a simple tcp packet and generate match on ethernet src address flow
+ pkt_MatchSrc = simple_tcp_packet(dl_src='00:01:01:01:01:01')
+ match = parse.packet_to_flow_match(pkt_MatchSrc)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_SRC
-def Wildcard_All(self,of_ports,priority=0):
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_MatchSrc,match)
+
+def match_ethernet_dst_address(self,of_ports,priority=None):
+ #Generate Match_Ethernet_Dst_Address flow
+
+ #Create a simple tcp packet and generate match on ethernet dst address flow
+ pkt_matchdst = simple_tcp_packet(dl_dst='00:01:01:01:01:01')
+ match = parse.packet_to_flow_match(pkt_matchdst)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_DST
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchdst,match)
+
+def wildcard_all(self,of_ports,priority=None):
# Generate a Wildcard_All Flow
- #Create a simple tcp packet and generate wildcard all flow match from it.
- Pkt_Wildcard = simple_tcp_packet()
- match2 = parse.packet_to_flow_match(Pkt_Wildcard)
- self.assertTrue(match2 is not None, "Could not generate flow match from pkt")
- match2.wildcards=ofp.OFPFW_ALL
- match2.in_port = of_ports[0]
+ #Create a simple tcp packet and generate wildcard all flow match from it.
+ pkt_wildcard = simple_tcp_packet()
+ match2 = parse.packet_to_flow_match(pkt_wildcard)
+ self.assertTrue(match2 is not None, "Could not generate flow match from pkt")
+ match2.wildcards=ofp.OFPFW_ALL
+ match2.in_port = of_ports[0]
- msg2 = message.flow_mod()
- msg2.out_port = ofp.OFPP_NONE
- msg2.command = ofp.OFPFC_ADD
- msg2.buffer_id = 0xffffffff
- msg2.match = match2
- act2 = action.action_output()
- act2.port = of_ports[1]
- self.assertTrue(msg2.actions.add(act2), "could not add action")
- if priority != 0 :
- msg2.priority = priority
+ msg2 = message.flow_mod()
+ msg2.out_port = ofp.OFPP_NONE
+ msg2.command = ofp.OFPFC_ADD
+ msg2.buffer_id = 0xffffffff
+ msg2.match = match2
+ act2 = action.action_output()
+ act2.port = of_ports[1]
+ self.assertTrue(msg2.actions.add(act2), "could not add action")
+ if priority != None :
+ msg2.priority = priority
- rv = self.controller.message_send(msg2)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ rv = self.controller.message_send(msg2)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- return (Pkt_Wildcard,match2)
+ return (pkt_wildcard,match2)
-def Wildcard_All_Except_Ingress(self,of_ports,priority=0):
+def wildcard_all_except_ingress(self,of_ports,priority=None):
# Generate Wildcard_All_Except_Ingress_port flow
- #Create a simple tcp packet and generate wildcard all except ingress_port flow.
- Pkt_MatchIngress = simple_tcp_packet()
- match3 = parse.packet_to_flow_match(Pkt_MatchIngress)
- self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
- match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
- match3.in_port = of_ports[0]
+ #Create a simple tcp packet and generate wildcard all except ingress_port flow.
+ pkt_matchingress = simple_tcp_packet()
+ match3 = parse.packet_to_flow_match(pkt_matchingress)
+ self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
+ match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
+ match3.in_port = of_ports[0]
- msg3 = message.flow_mod()
- msg3.command = ofp.OFPFC_ADD
- msg3.match = match3
- msg3.out_port = of_ports[2] # ignored by flow add,flow modify
- msg3.cookie = random.randint(0,9007199254740992)
- msg3.buffer_id = 0xffffffff
- msg3.idle_timeout = 0
- msg3.hard_timeout = 0
- msg3.buffer_id = 0xffffffff
+ msg3 = message.flow_mod()
+ msg3.command = ofp.OFPFC_ADD
+ msg3.match = match3
+ msg3.out_port = of_ports[2] # ignored by flow add,flow modify
+ msg3.cookie = random.randint(0,9007199254740992)
+ msg3.buffer_id = 0xffffffff
+ msg3.idle_timeout = 0
+ msg3.hard_timeout = 0
+ msg3.buffer_id = 0xffffffff
- act3 = action.action_output()
- act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ act3 = action.action_output()
+ act3.port = of_ports[1]
+ self.assertTrue(msg3.actions.add(act3), "could not add action")
- if priority != 0 :
- msg3.priority = priority
+ if priority != None :
+ msg3.priority = priority
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ rv = self.controller.message_send(msg3)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- return (Pkt_MatchIngress,match3)
-
+ return (pkt_matchingress,match3)
+
+def wildcard_all_except_ingress1(self,of_ports,priority=None):
+# Generate Wildcard_All_Except_Ingress_port flow with action output to port egress_port 2
+
+
+ #Create a simple tcp packet and generate wildcard all except ingress_port flow.
+ pkt_matchingress = simple_tcp_packet()
+ match3 = parse.packet_to_flow_match(pkt_matchingress)
+ self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
+ match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
+ match3.in_port = of_ports[0]
+
+ msg3 = message.flow_mod()
+ msg3.command = ofp.OFPFC_ADD
+ msg3.match = match3
+ msg3.out_port = of_ports[2] # ignored by flow add,flow modify
+ msg3.cookie = random.randint(0,9007199254740992)
+ msg3.buffer_id = 0xffffffff
+ msg3.idle_timeout = 0
+ msg3.hard_timeout = 0
+ msg3.buffer_id = 0xffffffff
+
+ act3 = action.action_output()
+ act3.port = of_ports[2]
+ self.assertTrue(msg3.actions.add(act3), "could not add action")
+ if priority != None :
+ msg3.priority = priority
+
+ rv = self.controller.message_send(msg3)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchingress,match3)
+
+
+
+
+def match_vlan_id(self,of_ports,priority=None):
+ #Generate Match_Vlan_Id
+
+ #Create a simple tcp packet and generate match on ethernet dst address flow
+ pkt_matchvlanid = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1)
+ match = parse.packet_to_flow_match(pkt_matchvlanid)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchvlanid,match)
+
+def match_vlan_pcp(self,of_ports,priority=None):
+ #Generate Match_Vlan_Id
+
+ #Create a simple tcp packet and generate match on ethernet dst address flow
+ pkt_matchvlanpcp = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=10)
+ match = parse.packet_to_flow_match(pkt_matchvlanpcp)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_VLAN_PCP
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchvlanpcp,match)
+
+
+def match_mul_l2(self,of_ports,priority=None):
+ #Generate Match_Mul_L2 flow
+
+ #Create a simple eth packet and generate match on ethernet protocol flow
+ pkt_mulL2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02')
+ match = parse.packet_to_flow_match(pkt_mulL2)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_DL_DST ^ofp.OFPFW_DL_SRC
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_mulL2,match)
+
+
+def match_mul_L4(self,of_ports,priority=None):
+ #Generate Match_Mul_L4 flow
+
+ #Create a simple tcp packet and generate match on tcp protocol flow
+ pkt_mulL4 = simple_tcp_packet(tcp_sport=111,tcp_dport=112)
+ match = parse.packet_to_flow_match(pkt_mulL4)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC ^ofp.OFPFW_TP_DST
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_mulL4,match)
+
+def match_ip_tos(self,of_ports,priority=None):
+ #Generate a Match on IP Type of service flow
+
+ #Create a simple tcp packet and generate match on Type of service
+ pkt_iptos = simple_tcp_packet(ip_tos=3)
+ match = parse.packet_to_flow_match(pkt_iptos)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_NW_TOS
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_iptos,match)
+
+def match_tcp_src(self,of_ports,priority=None):
+ #Generate Match_Tcp_Src
+
+ #Create a simple tcp packet and generate match on tcp source port flow
+ pkt_matchtSrc = simple_tcp_packet(tcp_sport=111)
+ match = parse.packet_to_flow_match(pkt_matchtSrc)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_SRC
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchtSrc,match)
+
+def match_tcp_dst(self,of_ports,priority=None):
+ #Generate Match_Tcp_Dst
+
+ #Create a simple tcp packet and generate match on tcp destination port flow
+ pkt_Matchtdst = simple_tcp_packet(tcp_dport=112)
+ match = parse.packet_to_flow_match(pkt_matchtdst)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_TP_DST
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchtdst,match)
+
+
+
+
+
+def match_ethernet_type(self,of_ports,priority=None):
+ #Generate a Match_Ethernet_Type flow
+
+ #Create a simple tcp packet and generate match on ethernet type flow
+ pkt_matchtype = simple_eth_packet(dl_type=0x88cc)
+ match = parse.packet_to_flow_match(pkt_matchtype)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL ^ofp.OFPFW_DL_TYPE
+ msg = message.flow_mod()
+ msg.out_port = ofp.OFPP_NONE
+ msg.command = ofp.OFPFC_ADD
+ msg.buffer_id = 0xffffffff
+ msg.match = match
+ if priority != None :
+ msg.priority = priority
+
+ act = action.action_output()
+ act.port = of_ports[1]
+ self.assertTrue(msg.actions.add(act), "could not add action")
+
+ rv = self.controller.message_send(msg)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ return (pkt_matchtype,match)
+
-def Strict_Modify_Flow_Action(self,egress_port,match,priority=0):
+
+def strict_modify_flow_action(self,egress_port,match,priority=None):
# Strict Modify the flow Action
- #Create a flow_mod message , command MODIFY_STRICT
- msg5 = message.flow_mod()
- msg5.match = match
- msg5.cookie = random.randint(0,9007199254740992)
- msg5.command = ofp.OFPFC_MODIFY_STRICT
- msg5.buffer_id = 0xffffffff
- act5 = action.action_output()
- act5.port = egress_port
- self.assertTrue(msg5.actions.add(act5), "could not add action")
+ #Create a flow_mod message , command MODIFY_STRICT
+ msg5 = message.flow_mod()
+ msg5.match = match
+ msg5.cookie = random.randint(0,9007199254740992)
+ msg5.command = ofp.OFPFC_MODIFY_STRICT
+ msg5.buffer_id = 0xffffffff
+ act5 = action.action_output()
+ act5.port = egress_port
+ self.assertTrue(msg5.actions.add(act5), "could not add action")
- if priority != 0 :
- msg5.priority = priority
+ if priority != None :
+ msg5.priority = priority
- # Send the flow with action A'
- rv = self.controller.message_send (msg5)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ # Send the flow with action A'
+ rv = self.controller.message_send (msg5)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-def Modify_Flow_Action(self,of_ports,match,priority=0):
+def modify_flow_action(self,of_ports,match,priority=None):
# Modify the flow action
- #Create a flow_mod message , command MODIFY
- msg8 = message.flow_mod()
- msg8.match = match
- msg8.cookie = random.randint(0,9007199254740992)
- msg8.command = ofp.OFPFC_MODIFY
- #Will be ignored for flow adds and flow modify (here for test-case Add_Modify_With_Outport)
- msg8.out_port = of_ports[3]
- msg8.buffer_id = 0xffffffff
- act8 = action.action_output()
- act8.port = of_ports[2]
- self.assertTrue(msg8.actions.add(act8), "could not add action")
+ #Create a flow_mod message , command MODIFY
+ msg8 = message.flow_mod()
+ msg8.match = match
+ msg8.cookie = random.randint(0,9007199254740992)
+ msg8.command = ofp.OFPFC_MODIFY
+ #out_port will be ignored for flow adds and flow modify (here for test-case Add_Modify_With_Outport)
+ msg8.out_port = of_ports[3]
+ msg8.buffer_id = 0xffffffff
+ act8 = action.action_output()
+ act8.port = of_ports[2]
+ self.assertTrue(msg8.actions.add(act8), "could not add action")
- if priority != 0 :
- msg8.priority = priority
+ if priority != None :
+ msg8.priority = priority
- # Send the flow with action A'
- rv = self.controller.message_send (msg8)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ # Send the flow with action A'
+ rv = self.controller.message_send (msg8)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+def enqueue(self,ingress_port,egress_port,egress_queue_id):
+#Generate a flow with enqueue action i.e output to a queue configured on a egress_port
+
+ pkt = simple_tcp_packet()
+ match = packet_to_flow_match(self, pkt)
+ match.wildcards &= ~ofp.OFPFW_IN_PORT
+ self.assertTrue(match is not None,
+ "Could not generate flow match from pkt")
+
+ match.in_port = ingress_port
+ request = message.flow_mod()
+ request.match = match
+ request.buffer_id = 0xffffffff
+ act = action.action_enqueue()
+ act.port = egress_port
+ act.queue_id = egress_queue_id
+ self.assertTrue(request.actions.add(act), "Could not add action")
+
+ logging.info("Inserting flow")
+ rv = self.controller.message_send(request)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ return (pkt,match)
+
+
########################### Verify Stats Functions ###########################################################################################
+def get_flowstats(self,match):
+ # Generate flow_stats request
+
+ stat_req = message.flow_stats_request()
+ stat_req.match = match
+ stat_req.table_id = 0xff
+ stat_req.out_port = ofp.OFPP_NONE
-def Verify_TableStats(self,active_entries=0,):
-#Verify Table_Stats
-
- #Send Table_Stats_Request
- request = message.table_stats_request()
- response, pkt = self.controller.transact(request, timeout=1)
- self.assertTrue(response is not None, "Did not get response")
- active_count=0
-
- #Verify active_count in the reply
- for stat in response.stats:
- active_count += stat.active_count
- self.assertTrue(active_entries == active_count,"Incorrect no. of flows in Table")
+ logging.info("Sending stats request")
+ response, pkt = self.controller.transact(stat_req,
+ timeout=5)
+ self.assertTrue(response is not None,"No response to stats request")
-def Verify_FlowStats(self,match,byte_count=0,packet_count=0):
-# Verify flow counters : byte_count and packet_count
+def get_portstats(self,port_num):
- stat_req = message.flow_stats_request()
- stat_req.match = match
- stat_req.table_id = 0xff
- stat_req.out_port = ofp.OFPP_NONE
- test_timeout = 10
- all_packets_received = 0
- for i in range(0,test_timeout):
-
- response, pkt = self.controller.transact(stat_req,
- timeout=test_timeout)
- self.assertTrue(response is not None,
+# Return all the port counters in the form a tuple
+ port_stats_req = message.port_stats_request()
+ port_stats_req.port_no = port_num
+ response,pkt = self.controller.transact(port_stats_req)
+ self.assertTrue(response is not None,"No response received for port stats request")
+ rx_pkts=0
+ tx_pkts=0
+ rx_byts=0
+ tx_byts=0
+ rx_drp =0
+ tx_drp = 0
+ rx_err=0
+ tx_err =0
+ rx_fr_err=0
+ rx_ovr_err=0
+ rx_crc_err=0
+ collisions = 0
+ tx_err=0
+
+
+ for obj in response.stats:
+ rx_pkts += obj.rx_packets
+ tx_pkts += obj.tx_packets
+ rx_byts += obj.rx_bytes
+ tx_byts += obj.tx_bytes
+ rx_drp += obj.rx_dropped
+ tx_drp += obj.tx_dropped
+ rx_err += obj.rx_errors
+ rx_fr_err += obj.rx_frame_err
+ rx_ovr_err += obj.rx_over_err
+ rx_crc_err += obj.rx_crc_err
+ collisions+= obj.collisions
+ tx_err += obj.tx_errors
+
+ return (rx_pkts,tx_pkts,rx_byts,tx_byts,rx_drp,tx_drp,rx_err,tx_err,rx_fr_err,rx_ovr_err,rx_crc_err,collisions,tx_err)
+
+def get_queuestats(self,port_num,queue_id):
+#Generate Queue Stats request
+
+ request = message.queue_stats_request()
+ request.port_no = port_num
+ request.queue_id = queue_id
+ (queue_stats, p) = self.controller.transact(request)
+ self.assertNotEqual(queue_stats, None, "Queue stats request failed")
+
+ return (queue_stats,p)
+
+def get_tablestats(self):
+# Send Table_Stats request (retrieve current table counters )
+
+ stat_req = message.table_stats_request()
+ response, pkt = self.controller.transact(stat_req,
+ timeout=5)
+ self.assertTrue(response is not None,
"No response to stats request")
- for obj in response.stats:
- if ( obj.packet_count == packet_count and obj.byte_count == byte_count ) :
- all_packets_received = 1
+ current_lookedup = 0
+ current_matched = 0
+ current_active = 0
- if all_packets_received:
- break
- sleep(1)
+ for obj in response.stats:
+ current_lookedup += obj.lookup_count
+ current_matched += obj.matched_count
+ current_active += obj.active_count
- self.assertTrue(all_packets_received,
- "Flow counters are incorrect")
+ return (current_lookedup,current_matched,current_active)
-def Verify_PortStats(self,in_port,rx_dropped):
-#Verify Port counters like rx_dropped
- port_stats_req = message.port_stats_request()
- port_stats_req.port_no = in_port
- resp,pkt = self.controller.transact(port_stats_req)
- self.assertTrue(resp is not None,"No response received for port stats request")
- self.assertTrue(resp.rx_dropped == rx_dropped, "Packets not dropped")
+def verify_tablestats(self,expect_lookup=None,expect_match=None,expect_active=None):
+
+ stat_req = message.table_stats_request()
+
+ for i in range(0,60):
+
+ logging.info("Sending stats request")
+ # TODO: move REPLY_MORE handling to controller.transact?
+ response, pkt = self.controller.transact(stat_req,
+ timeout=5)
+ self.assertTrue(response is not None,"No response to stats request")
+
+ lookedup = 0
+ matched = 0
+ active = 0
+
+ sleep(1)
+
+ for item in response.stats:
+
+ lookedup += item.lookup_count
+ matched += item.matched_count
+ active += item.active_count
+
+ logging.info("Packets Looked up " + str(lookedup) + " packets")
+ logging.info("Packets matched " + str(matched) + "packets")
+ logging.info("Active flow entries" + str(active) + "flows")
+
+ if expect_lookup != None and expect_lookup != lookedup:continue
+ if expect_match != None and expect_match != matched:continue
+ if expect_active != None and expect_active != active:continue
+ break
+
+
+
+ if expect_lookup != None :
+ self.assertEqual(expect_lookup,item.lookup_count,"lookup counter is not incremented properly")
+ if expect_match != None :
+ self.assertEqual(expect_match,item.matched_count, "matched counter is not incremented properly")
+ if expect_active != None :
+ self.assertEqual(expect_active,item.active_count,"active counter is not incremented properly")
+
+
+def verify_flowstats(self,match,byte_count=None,packet_count=None):
+ # Verify flow counters : byte_count and packet_count
+
+ stat_req = message.flow_stats_request()
+ stat_req.match = match
+ stat_req.table_id = 0xff
+ stat_req.out_port = ofp.OFPP_NONE
+
+ for i in range(0,60):
+ logging.info("Sending stats request")
+ # TODO: move REPLY_MORE handling to controller.transact?
+ response, pkt = self.controller.transact(stat_req,
+ timeout=5)
+ self.assertTrue(response is not None,"No response to stats request")
+
+ packet_counter = 0
+ byte_counter = 0
+
+ sleep(1)
+
+ for item in response.stats:
+ packet_counter += item.packet_count
+ byte_counter += item.byte_count
+
+ logging.info("Recieved" + str(item.packet_count) + " packets")
+
+ logging.info("Received " + str(item.byte_count) + "bytes")
+
+ if packet_count != None and packet_count != packet_counter: continue
+ if byte_count != None and byte_count != byte_counter: continue
+ break
+
+
+
+ if packet_count != None :
+ self.assertEqual(packet_count,item.packet_count,"packet_count counter is not incremented correctly")
+
+ if byte_count != None :
+ self.assertEqual(byte_count,item.byte_count,"byte_count counter is not incremented correctly")
+
+
+def verify_portstats(self, port,tx_packets=None,rx_packets=None,rx_byte=None,tx_byte=None):
+
+
+ stat_req = message.port_stats_request()
+ stat_req.port_no = port
+
+ for i in range(0,60):
+ logging.info("Sending stats request")
+ response, pkt = self.controller.transact(stat_req,
+ timeout=5)
+ self.assertTrue(response is not None,
+ "No response to stats request")
+ self.assertTrue(len(response.stats) == 1,
+ "Did not receive port stats reply")
+
+ sentp = recvp = 0
+ sentb = recvb = 0
+
+ sleep(1)
+
+ for item in response.stats:
+ sentp += item.tx_packets
+ recvp += item.rx_packets
+ recvb += item.rx_bytes
+ sentb += item.tx_bytes
+
+
+ logging.info("Sent " + str(sentp) + " packets")
+ logging.info("Received " + str(recvp) + " packets")
+ logging.info("Received " + str(recvb) + "bytes")
+ logging.info("Sent" + str(sentb) + "bytes")
+
+ if tx_packets != None and tx_packets != sentp: continue
+ if rx_packets != None and rx_packets != recvp: continue
+ if rx_byte != None and rx_byte != recvb: continue
+ if tx_byte != None and tx_byte != sentb: continue
+
+ break
+
+
+
+ if (tx_packets != None):
+ self.assertEqual(tx_packets,item.tx_packets,"rx_packets counter is not incremented correctly")
+ if (rx_packets != None):
+ self.assertEqual(rx_packets,item.rx_packets,"tx_packets counter is not incremented correctly")
+ if (rx_byte != None):
+ self.assertEqual(rx_byte,item.rx_bytes,"rx_bytes counter is not incremented correctly")
+ if (tx_byte != None):
+ self.assertEqual(tx_byte,item.tx_bytes,"tx_bytes counter is not incremented correctly")
+
+
+
+def verify_queuestats(self,port_num,queue_id,expect_packet=None,expect_byte=None):
+
+ # Verify queue counters : tx_packets and tx_bytes
+
+ request = message.queue_stats_request()
+ request.port_no = port_num
+ request.queue_id = queue_id
+
+ for i in range(0,60):
+
+ logging.info("Sending stats request")
+
+ (queue_stats, p) = self.controller.transact(request)
+ self.assertNotEqual(queue_stats, None, "Queue stats request failed")
+ packet_counter = 0
+ byte_counter = 0
+
+ sleep(1)
+
+ for item in queue_stats.stats:
+ packet_counter += item.tx_packets
+ byte_counter += item.tx_bytes
+
+ logging.info("Transmitted" + str(packet_counter) + " packets")
+ logging.info("Transmitted" + str(byte_counter) + "bytes")
+
+ if expect_packet != None and packet_counter != expect_packet: continue
+ if expect_byte != None and byte_counter != expect_byte: continue
+ break
+
+
+
+ if expect_packet != None :
+ self.assertEqual(packet_counter,expect_packet,"tx_packets counter is not incremented correctly")
+
+ if expect_byte != None :
+ self.assertEqual(byte_counter,expect_byte,"tx_bytes counter is not incremented correctly")
############################## Various delete commands #############################################################################################
-def Strict_Delete(self,match,priority=0):
+def strict_delete(self,match,priority=None):
# Issue Strict Delete
- #Create flow_mod message, command DELETE_STRICT
- msg4 = message.flow_mod()
- msg4.out_port = ofp.OFPP_NONE
- msg4.command = ofp.OFPFC_DELETE_STRICT
- msg4.buffer_id = 0xffffffff
- msg4.match = match
+ #Create flow_mod message, command DELETE_STRICT
+ msg4 = message.flow_mod()
+ msg4.out_port = ofp.OFPP_NONE
+ msg4.command = ofp.OFPFC_DELETE_STRICT
+ msg4.buffer_id = 0xffffffff
+ msg4.match = match
- if priority != 0 :
- msg4.priority = priority
-
- rv = self.controller.message_send(msg4)
- self.assertTrue(rv!= -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ if priority != None :
+ msg4.priority = priority
+ rv = self.controller.message_send(msg4)
+ self.assertTrue(rv!= -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
-def NonStrict_Delete(self,match,priority=0):
+def nonstrict_delete(self,match,priority=None):
# Issue Non_Strict Delete
- #Create flow_mod message, command DELETE
- msg6 = message.flow_mod()
- msg6.out_port = ofp.OFPP_NONE
- msg6.command = ofp.OFPFC_DELETE
- msg6.buffer_id = 0xffffffff
- msg6.match = match
+ #Create flow_mod message, command DELETE
+ msg6 = message.flow_mod()
+ msg6.out_port = ofp.OFPP_NONE
+ msg6.command = ofp.OFPFC_DELETE
+ msg6.buffer_id = 0xffffffff
+ msg6.match = match
- if priority != 0 :
- msg6.priority = priority
+ if priority != None :
+ msg6.priority = priority
- rv = self.controller.message_send(msg6)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
+ rv = self.controller.message_send(msg6)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
###########################################################################################################################################################
-def SendPacket(obj, pkt, ingress_port, egress_port):
+def send_packet(obj, pkt, ingress_port, egress_port):
#Send Packets on a specified ingress_port and verify if its recieved on correct egress_port.
obj.dataplane.send(ingress_port, str(pkt))
@@ -307,3 +878,5 @@
cache_supported_actions = reply.actions
return cache_supported_actions
+##############################################################################################################################################################
+
diff --git a/tests/actions.py b/tests/actions.py
index 590a91c..330068c 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -411,7 +411,7 @@
logging.info("Expecting packet on the egress_port")
#Insert a all wildcarded flow
- (pkt,match) = Wildcard_All(self,of_ports)
+ (pkt,match) = wildcard_all(self,of_ports)
#Create a packet out message
pkt_out =message.packet_out();
diff --git a/tests/counters.py b/tests/counters.py
new file mode 100644
index 0000000..daa3cb2
--- /dev/null
+++ b/tests/counters.py
@@ -0,0 +1,692 @@
+"""These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases).
+ Refer Documentation -- Detailed testing methodology
+ <Some of test-cases are directly taken from oftest> """
+
+"Test Suite 5 --> Counters"
+
+import logging
+
+import unittest
+import random
+
+from oftest import config
+import oftest.controller as controller
+import oftest.cstruct as ofp
+import oftest.message as message
+import oftest.dataplane as dataplane
+import oftest.action as action
+import oftest.parse as parse
+import oftest.base_tests as base_tests
+import time
+
+from oftest.testutils import *
+from time import sleep
+from FuncUtils import*
+
+
+def port_queues_get(self, queue_stats, port_num):
+ result = []
+ for qs in queue_stats.stats:
+ if qs.port_no != port_num:
+ continue
+ result.append(qs.queue_id)
+ return result
+
+
+class PktPerFlow(base_tests.SimpleDataPlane):
+
+ """Verify Packet counters per flow are
+ incremented by no. of packets received for that flow"""
+
+ def runTest(self):
+
+ logging.info("Running PktPerFlow test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow")
+ logging.info("Sending N Packets matching the flow")
+ logging.info("Verify packet counters increment in accordance")
+
+ #Create a Match on Ingress flow
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
+
+ #Send Packets matching the flow
+ num_pkts = 5
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ #Verify Recieved Packets/Bytes Per Flow
+ verify_flowstats(self,match,packet_count=num_pkts)
+
+
+class BytPerFlow(base_tests.SimpleDataPlane):
+
+ """Verify Byte counters per flow are
+ incremented by no. of bytes received for that flow"""
+
+ def runTest(self):
+
+ logging.info("Running BytPerFlow test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow")
+ logging.info("Sending N Packets matching the flow")
+ logging.info("Verify byte counters increment in accordance")
+
+ #Create a Match on Ingress flow
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
+
+ #Send Packets matching the flow
+ num_pkts = 5
+ byte_count = num_pkts*len(str(pkt))
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ #Verify Recieved Packets/Bytes Per Flow
+ verify_flowstats(self,match,byte_count=byte_count)
+
+
+class DurationPerFlow(base_tests.SimpleDataPlane):
+
+ """Verify Duration_sec and Duration_nsec counters per flow varies in accordance with the amount of
+ time the flow was alive"""
+
+ def runTest(self):
+
+ logging.info("Running DurationPerFlow test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch state
+ rc = delete_all_flows(self.controller)
+ self.assertEqual(rc, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow")
+ logging.info("Send Flow_stats request after n sec intervals")
+ logging.info("Verify duration_sec and nsec counters are incrementing in accordance with the life of flow")
+
+ #Create a flow with match on ingress_port
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
+
+ #Create flow_stats request
+ test_timeout = 30
+ stat_req = message.flow_stats_request()
+ stat_req.match= match
+ stat_req.table_id = 0xff
+ stat_req.out_port = ofp.OFPP_NONE
+
+ flow_stats_gen_ts = range (10,test_timeout,10)
+
+ for ts in range(0,test_timeout):
+ if ts in flow_stats_gen_ts:
+ response, pkt = self.controller.transact(stat_req)
+
+ self.assertTrue(response is not None,"No response to stats request")
+ self.assertTrue(len(response.stats) == 1,"Did not receive flow stats reply")
+
+ stat = response.stats[0]
+ self.assertTrue(stat.duration_sec == ts,"Flow stats reply incorrect")
+ logging.info("Duration of flow is " + str(stat.duration_sec) + str(stat.duration_nsec))
+
+ sleep(1)
+
+
+class RxPktPerPort(base_tests.SimpleDataPlane):
+
+ """Verify that rx_packets counter in the Port_Stats reply
+ increments when packets are received on a port"""
+
+ def runTest(self):
+
+ logging.info("Running RxPktPerPort test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ # Clear Switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert a flow with match on ingress_port")
+ logging.info("Send N Packets on an ingress_port P ")
+ logging.info("Send Port_Stats Request for Port P , verify recieved packets counters are incrementing in accordance")
+
+ #Insert a flow with match on all ingress port
+ (pkt, match ) = wildcard_all_except_ingress(self,of_ports)
+
+ # Send Port_Stats request for the ingress port (retrieve old counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ # Send packets matching the flow
+ num_pkts = 5
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ pkts = num_pkts+counter[0]
+
+ #Verify recieved packet counters
+ verify_portstats(self,of_ports[0],rx_packets=pkts)
+
+class TxPktPerPort(base_tests.SimpleDataPlane):
+
+ """Verify that tx_packets counter in the Port_Stats reply , increments when packets are transmitted by a port"""
+
+ def runTest(self):
+
+ logging.info("Running TxPktPerPort test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow matching on in_port=ingress_port, action output to egress_port T ")
+ logging.info("Send N Packets matching the flow on ingress_port P ")
+ logging.info("Send Port_Stats Request for Port T , verify transmitted packets counters are incrementing in accordance")
+
+ #Insert a flow with match on all ingress port
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
+
+ # Send Port_Stats request for the ingress port (retrieve old counter state)
+ (counter) = get_portstats(self,of_ports[1])
+
+ #Send packets matching the flow
+ num_pkts = 5
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ pkts = num_pkts+counter[1]
+
+ #Verify transmitted_packet counters
+ verify_portstats(self,of_ports[1],tx_packets=pkts)
+
+
+
+class RxBytPerPort(base_tests.SimpleDataPlane):
+
+ """Verify that recieved bytes counter in the Port_Stats reply , increments in accordance with the bytes recieved on a port"""
+
+ def runTest(self):
+
+ logging.info("Running RxBytPerPort test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow matching on in_port=ingress_port")
+ logging.info("Send N Packets matching the flow on ingress_port P ")
+ logging.info("Send Port_Stats Request for Port P , verify recieved bytes counters are incrementing in accordance")
+
+ #Insert a flow with match on all ingress port
+ (pkt, match ) = wildcard_all_except_ingress(self,of_ports)
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ #Send packets matching the flow.
+ num_pkts = 5
+ byte_count = num_pkts*len(str(pkt))
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ byt_count = byte_count+counter[2]
+
+ #Verify recieved_bytes counters
+ verify_portstats(self,of_ports[0],rx_byte=byt_count)
+
+
+class TxBytPerPort(base_tests.SimpleDataPlane):
+
+ """Verify that trasnsmitted bytes counter in the Port_Stats reply , increments in accordance with the bytes trasmitted by a port"""
+
+ def runTest(self):
+
+ logging.info("Running TxBytPerPort test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T")
+ logging.info("Send N Packets matching the flow on ingress_port P ")
+ logging.info("Send Port_Stats Request for Port T , verify trasmitted bytes counters are incrementing in accordance")
+
+ #Insert a flow with match on all ingress port
+ (pkt, match ) = wildcard_all_except_ingress(self,of_ports)
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[1])
+
+ #Send packets matching the flow.
+ num_pkts = 5
+ byte_count = num_pkts*len(str(pkt))
+ for pkt_cnt in range(num_pkts):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ byt_count = byte_count+counter[3]
+
+ #Verify trasmitted_bytes counters
+ verify_portstats(self,of_ports[1],tx_byte=byt_count)
+
+class ActiveCount(base_tests.SimpleDataPlane):
+
+ """Verify that active_count counter in the Table_Stats reply , increments in accordance with the flows inserted in a table"""
+
+ def runTest(self):
+
+ logging.info("Running Table_Counter_1 test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear Switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T ")
+ logging.info("Send Table_Stats, verify active_count counter is incremented in accordance")
+
+ #Insert a flow with match on all ingress port
+ (pkt, match ) = wildcard_all_except_ingress(self,of_ports)
+
+ #Generate Table_Stats
+ verify_tablestats(self,expect_active=1)
+
+
+class LookupMatchedCount(base_tests.SimpleDataPlane):
+
+ """Verify that lookup_count and matched_count counter in the Table_Stats reply
+ increments in accordance with the packets looked up and matched with the flows in the table"""
+
+ def runTest(self):
+
+ logging.info("Running LookupMatchedCount test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear Switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port")
+ logging.info("Send N packets matching the flow, N' packets not matching the flow")
+ logging.info("Send Table_Stats, verify lookup_count = N+N' & matched_count=N ")
+
+ #Get Current Table Stats
+ (current_lookedup,current_matched,current_active) = get_tablestats(self)
+
+ #Insert a flow with match on all ingress port
+ (pkt, match ) = wildcard_all_except_ingress(self,of_ports)
+
+ #send packet pkt N times (pkt matches the flow)
+ num_sends = 5
+ for pkt_cnt in range(num_sends):
+ self.dataplane.send(of_ports[0],str(pkt))
+
+ #send packet pkt N' (pkt does not match the flow)
+ num_sends2 = 5
+ for pkt_cnt in range(num_sends):
+ self.dataplane.send(of_ports[1],str(pkt))
+
+ new_lookup = num_sends+num_sends2+current_lookedup
+ new_matched = num_sends+current_matched
+
+ #Verify lookup_count and matched_count counters.
+ verify_tablestats(self,expect_lookup=new_lookup,expect_match=new_matched)
+
+class TxPktPerQueue(base_tests.SimpleDataPlane):
+
+ """Verify that tx_packets in the queue_stats reply increments in accordance with the number of transmitted packets"""
+
+ def runTest(self):
+ logging.info("Running TxPktPerQueue test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ # Get queue stats from switch (retrieve current state)
+ (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL)
+
+ for idx in range(len(of_ports)):
+ ingress_port = of_ports[idx]
+ egress_port = of_ports[(idx + 1) % len(of_ports)]
+
+ queue_id = port_queues_get(self,queue_stats,egress_port)
+
+ for egress_queue_id in queue_id:
+
+ #Clear switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ # Get Queue stats for selected egress queue only
+ (qs_before,p) = get_queuestats(self,egress_port,egress_queue_id)
+
+ #Insert a flow with enqueue action to queues configured on egress_port
+ (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id)
+
+ #Send packet on the ingress_port and verify its received on egress_port
+ send_packet(self,pkt,ingress_port,egress_port)
+
+ expected_packets = qs_before.stats[0].tx_packets+1
+
+ verify_queuestats(self,egress_port,egress_queue_id,expect_packet=expected_packets)
+
+
+class TxBytPerQueue(base_tests.SimpleDataPlane):
+
+ """Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes"""
+
+ def runTest(self):
+ logging.info("Running TxBytPerQueue test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ # Get queue stats from switch (retrieve current state)
+ (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL)
+
+ for idx in range(len(of_ports)):
+ ingress_port = of_ports[idx]
+ egress_port = of_ports[(idx + 1) % len(of_ports)]
+
+ queue_id = port_queues_get(self,queue_stats,egress_port)
+
+ for egress_queue_id in queue_id:
+
+ #Clear switch state
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ # Get Queue stats for selected egress queue only
+ (qs_before,p) = get_queuestats(self,egress_port,egress_queue_id)
+
+ #Insert a flow with enqueue action to queues configured on egress_port
+ (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id)
+
+ #Send packet on the ingress_port and verify its received on egress_port
+ send_packet(self,pkt,ingress_port,egress_port)
+
+ expected_bytes = qs_before.stats[0].tx_bytes+len(str(pkt))
+
+ verify_queuestats(self,egress_port,egress_queue_id,expect_byte=expected_bytes)
+
+
+class RxDrops(base_tests.SimpleDataPlane):
+
+ """Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX"""
+
+ def runTest(self):
+
+ logging.info("Running Rx_Drops test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has rx_dropped count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ rx_drp = counter[4]
+ logging.info("recieved dropped count is :" + str(rx_drp))
+
+
+
+class TxDrops(base_tests.SimpleDataPlane):
+
+ """Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX"""
+
+ def runTest(self):
+
+ logging.info("Running Tx_Drops test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has tx_dropped count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[1])
+
+ tx_drp = counter[5]
+ logging.info("Transmitted dropped count is :" + str(tx_drp))
+
+
+class RxErrors(base_tests.SimpleDataPlane):
+
+ """Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error
+ This is a super-set of more specific receive errors and should be greater than or equal to the sum of all
+ rx_*_err values"""
+
+ def runTest(self):
+
+ logging.info("Running Rx_Errors test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has rx_errors count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ rx_err = counter[6]
+ logging.info("Recieve Errors count is :" + str(rx_err))
+
+
+class TxErrors(base_tests.SimpleDataPlane):
+
+ """Verify that Tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit error"""
+
+ def runTest(self):
+
+ logging.info("Running Tx_Errors test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has Tx_errors count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ tx_err = counter[7]
+ logging.info("Trasmit Error count is :" + str(tx_err))
+
+
+class RxFrameErr(base_tests.SimpleDataPlane):
+
+ """Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors"""
+
+ def runTest(self):
+
+ logging.info("Running Rx_Frame_Err test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has rx_frame_err count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ rx_fr_err = counter[8]
+ logging.info("Recieve Frame Errors count is :" + str(rx_fr_err))
+
+
+
+class RxOErr(base_tests.SimpleDataPlane):
+
+ """Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun"""
+
+ def runTest(self):
+
+ logging.info("Running Rx_O_Err test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has rx_over_err count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ rx_over_err = counter[9]
+ logging.info("Recieve Overrun Errors count is :" + str(rx_over_err))
+
+
+
+
+class RxCrcErr(base_tests.SimpleDataPlane):
+
+ """Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors"""
+
+ def runTest(self):
+
+ logging.info("Running Port_Counter_9 test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has rx_crc_err count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ rx_crc_err = counter[10]
+ logging.info("Recieve CRC Errors count is :" + str(rx_crc_err))
+
+
+
+class Collisions(base_tests.SimpleDataPlane):
+
+ """Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch """
+
+ def runTest(self):
+
+ logging.info("Running Collisions test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Port_Stats Request")
+ logging.info("Verify reply has Collisions count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ collisions = counter[11]
+ logging.info("collisions count is :" + str(collisions))
+
+
+
+
+class TxErrorPerQueue(base_tests.SimpleDataPlane):
+
+ """Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun """
+
+ def runTest(self):
+
+ logging.info("Running TxErrorPerQueue test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear switch State
+ rv = delete_all_flows(self.controller)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ logging.info("Send Queue_Stats Request")
+ logging.info("Verify reply has Tramitted Overrun errors count ")
+
+ # Send Port_Stats request for the ingress port (retrieve current counter state)
+ (counter) = get_portstats(self,of_ports[0])
+
+ tx_err = counter[12]
+ logging.info("Transmit Overrun Error count is :" + str(tx_err))
+
+
+
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index c969030..da1b046 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -43,14 +43,14 @@
logging.info("Expecting switch to return an error")
#Insert a flow F with wildcarded all fields
- (pkt,match) = Wildcard_All(self,of_ports)
+ (pkt,match) = wildcard_all(self,of_ports)
#Verify flow is active
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Build a overlapping flow F'-- Wildcard All except ingress with check overlap bit set
- Pkt_MatchIngress = simple_tcp_packet()
- match3 = parse.packet_to_flow_match(Pkt_MatchIngress)
+ pkt_matchingress = simple_tcp_packet()
+ match3 = parse.packet_to_flow_match(pkt_matchingress)
self.assertTrue(match3 is not None, "Could not generate flow match from pkt")
match3.wildcards = ofp.OFPFW_ALL-ofp.OFPFW_IN_PORT
match3.in_port = of_ports[0]
@@ -70,7 +70,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Verify Flow does not get inserted
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
#Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,
@@ -103,16 +103,16 @@
logging.info("Expecting switch to insert the flows without generating errors")
#Build a flow F with wildcarded all fields.
- (pkt,match) = Wildcard_All(self,of_ports)
+ (pkt,match) = wildcard_all(self,of_ports)
#Verify flow is active
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Build a overlapping flow F' without check overlap bit set.
- Wildcard_All_Except_Ingress(self,of_ports)
+ wildcard_all_except_ingress(self,of_ports)
# Verify Flow gets inserted
- Verify_TableStats(self,active_entries=2)
+ verify_tablestats(self,expect_active=2)
class IdenticalFlows(base_tests.SimpleDataPlane):
@@ -135,25 +135,25 @@
logging.info("Expecting switch to overwrite the first flow and clear the counters associated with it ")
# Create and add flow-1, check on dataplane it is active.
- (pkt,match) = Wildcard_All(self,of_ports)
+ (pkt,match) = wildcard_all(self,of_ports)
# Verify active_entries in table_stats_request =1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Send Packet (to increment counters like byte_count and packet_count)
- SendPacket(self,pkt,of_ports[0],of_ports[1])
+ send_packet(self,pkt,of_ports[0],of_ports[1])
# Verify Flow counters have incremented
- Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+ verify_flowstats(self,match,byte_count=len(str(pkt)),packet_count=1)
#Send Identical flow
- (pkt1,match1) = Wildcard_All(self,of_ports)
+ (pkt1,match1) = wildcard_all(self,of_ports)
# Verify active_entries in table_stats_request =1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Verify Flow counters reset
- Verify_FlowStats(self,match,byte_count=0,packet_count=0)
+ verify_flowstats(self,match,byte_count=0,packet_count=0)
class EmerFlowTimeout(base_tests.SimpleProtocol):
@@ -245,7 +245,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify the flow gets added i.e. active_count= 1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
class ModifyAction(base_tests.SimpleDataPlane):
@@ -268,22 +268,22 @@
logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
#Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A , output to of_port[1]
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
+ (pkt,match) = match_all_except_source_address(self,of_ports)
#Send Packet matching the flow thus incrementing counters like packet_count,byte_count
- SendPacket(self,pkt,of_ports[0],of_ports[1])
+ send_packet(self,pkt,of_ports[0],of_ports[1])
#Verify flow counters
- Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+ verify_flowstats(self,match,byte_count=len(str(pkt)),packet_count=1)
#Modify flow- 1
- Modify_Flow_Action(self,of_ports,match)
+ modify_flow_action(self,of_ports,match)
# Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2]
- SendPacket(self,pkt,of_ports[0],of_ports[2])
+ send_packet(self,pkt,of_ports[0],of_ports[2])
#Verify flow counters are preserved
- Verify_FlowStats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
+ verify_flowstats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
class StrictModifyAction(base_tests.SimpleDataPlane):
@@ -306,28 +306,28 @@
logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
#Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
+ (pkt,match) = match_all_except_source_address(self,of_ports,priority=100)
#Create and add flow-2 , Match on ingress_port only, Action A
- (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=10)
+ (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=10)
# Verify both the flows are active
- Verify_TableStats(self,active_entries=2)
+ verify_tablestats(self,expect_active=2)
#Send a packet matching the flows, thus incrementing flow-counters (packet matches the flow F-1 with higher priority)
- SendPacket(self,pkt,of_ports[0],of_ports[1])
+ send_packet(self,pkt,of_ports[0],of_ports[1])
# Verify flow counters of the flow-1
- Verify_FlowStats(self,match,byte_count=len(str(pkt)),packet_count=1)
+ verify_flowstats(self,match,byte_count=len(str(pkt)),packet_count=1)
# Strict-Modify flow- 1
- Strict_Modify_Flow_Action(self,of_ports[2],match,priority=100)
+ strict_modify_flow_action(self,of_ports[2],match,priority=100)
# Send Packet matching the flow-1 i.e ingress_port=port[0] and verify it is recieved on corret dataplane port i.e port[2]
- SendPacket(self,pkt,of_ports[0],of_ports[2])
+ send_packet(self,pkt,of_ports[0],of_ports[2])
# Verify flow counters are preserved
- Verify_FlowStats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
+ verify_flowstats(self,match,byte_count=(2*len(str(pkt))),packet_count=2)
class DeleteNonexistingFlow(base_tests.SimpleDataPlane):
@@ -387,13 +387,13 @@
logging.info("Expecting flow removed message only for F2")
# Insert flow-1 with F without OFPFF_SEND_FLOW_REM flag set.
- (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
# Verify flow is inserted
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
#Delete the flow-1
- NonStrict_Delete(self,match,priority=0)
+ nonstrict_delete(self,match,priority=0)
# Verify no flow removed message is generated for the FLOW-1
@@ -461,7 +461,7 @@
# Delete the emergency flow
- NonStrict_Delete(self,match)
+ nonstrict_delete(self,match)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPFF_SEND_FLOW_REM ,
timeout=2)
self.assertTrue(response is None,
@@ -489,69 +489,69 @@
logging.info("Issue Strict Delete command , verify it gets deleted")
#Insert F with an exact Match
- (pkt,match) = Exact_Match(self,of_ports)
- Verify_TableStats(self,active_entries=1)
+ (pkt,match) = exact_match(self,of_ports)
+ verify_tablestats(self,expect_active=1)
#Issue Strict Delete Command , verify F gets deleted.
- Strict_Delete(self,match)
- Verify_TableStats(self,active_entries=0)
+ strict_delete(self,match)
+ verify_tablestats(self,expect_active=0)
logging.info("Inserting two overlapping flows")
logging.info("Issue Strict Delete command ")
logging.info("Expecting only one flow gets deleted , because Strict Delete matches on wildcards as well")
#Insert Flow T with match on all , except one wildcarded ( say src adddress ).
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
+ (pkt,match) = match_all_except_source_address(self,of_ports)
#Insert another flow T' with match on ingress_port , wildcarded rest.
- (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports)
- Verify_TableStats(self,active_entries=2)
+ (pkt1,match1) = wildcard_all_except_ingress(self,of_ports)
+ verify_tablestats(self,expect_active=2)
#Issue Strict Delete matching on ingress_port. Verify only T' gets deleted
- Strict_Delete(self,match1)
- Verify_TableStats(self,active_entries=1)
+ strict_delete(self,match1)
+ verify_tablestats(self,expect_active=1)
logging.info("Inserting two overlapping flows")
logging.info("Issue Non-Strict Delete command ")
logging.info("Expecting both the flow gets deleted , because wildcards are active")
#Insert T and T' again .
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports)
- (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports)
- Verify_TableStats(self,active_entries=2)
+ (pkt,match) = match_all_except_source_address(self,of_ports)
+ (pkt1,match1) = wildcard_all_except_ingress(self,of_ports)
+ verify_tablestats(self,expect_active=2)
#Issue Non-strict Delete with match on ingress_port.Verify T+T' gets deleted .
- NonStrict_Delete(self,match1)
- Verify_TableStats(self,active_entries=0)
+ nonstrict_delete(self,match1)
+ verify_tablestats(self,expect_active=0)
logging.info("Inserting three overlapping flows with different priorities")
logging.info("Issue Non-Strict Delete command ")
logging.info("Expecting all the flows to get deleted")
#Insert T , add Priority P (say 100 )
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
+ (pkt,match) = match_all_except_source_address(self,of_ports,priority=100)
#Insert T' add priority (200).
- (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=200)
+ (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=200)
#Insert T' again add priority 300 --> T" .
- (pkt2,match2) = Wildcard_All_Except_Ingress(self,of_ports,priority=300)
- Verify_TableStats(self,active_entries=3)
+ (pkt2,match2) = wildcard_all_except_ingress(self,of_ports,priority=300)
+ verify_tablestats(self,expect_active=3)
#Issue Non-Strict Delete and verify all getting deleted
- NonStrict_Delete(self,match1,priority=200)
- Verify_TableStats(self,active_entries=0)
+ nonstrict_delete(self,match1,priority=200)
+ verify_tablestats(self,expect_active=0)
logging.info("Inserting three overlapping flows with different priorities")
logging.info("Issue Strict Delete command ")
logging.info("Expecting only one to get deleted because here priorities & wildcards are being matched")
#Issue Strict-Delete and verify only T'' gets deleted.
- (pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
- (pkt1,match1) = Wildcard_All_Except_Ingress(self,of_ports,priority=200)
- (pkt2,match2) = Wildcard_All_Except_Ingress(self,of_ports,priority=300)
- Strict_Delete(self,match1,priority=200)
- Verify_TableStats(self,active_entries=2)
+ (pkt,match) = match_all_except_source_address(self,of_ports,priority=100)
+ (pkt1,match1) = wildcard_all_except_ingress(self,of_ports,priority=200)
+ (pkt2,match2) = wildcard_all_except_ingress(self,of_ports,priority=300)
+ strict_delete(self,match1,priority=200)
+ verify_tablestats(self,expect_active=2)
@@ -577,10 +577,10 @@
logging.info("Expecting switch to filter the delete command")
#Build and send Flow-1 with action output to of_port[1]
- (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
# Verify active_entries in table_stats_request = 1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
#Send delete command matching the flow-1 but with contraint out_port = of_port[2]
msg7 = message.flow_mod()
@@ -594,7 +594,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Verify flow will not get deleted, active_entries in table_stats_request = 1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
logging.info("Deleting the flow with out_port set to of_port[1]")
logging.info("Expecting switch to delete the flow")
@@ -611,7 +611,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify flow gets deleted.
- Verify_TableStats(self,active_entries=0)
+ verify_tablestats(self,expect_active=0)
class IdleTimeout(base_tests.SimpleDataPlane):
@@ -645,7 +645,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify flow gets inserted
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Verify flow removed message is recieved.
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
@@ -678,22 +678,22 @@
logging.info("Expecting switch to ignore out_port")
# Create and add flow-1,Action A ,output to port of_port[1], out_port set to of_ports[2]
- (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
# Verify flow is active
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Send Packet matching the flow
- SendPacket(self,pkt,of_ports[0],of_ports[1])
+ send_packet(self,pkt,of_ports[0],of_ports[1])
# Insert Flow-Modify matching flow F-1 ,action A', output to port[2], out_port set to port[3]
- Modify_Flow_Action(self,of_ports,match)
+ modify_flow_action(self,of_ports,match)
# Again verify active_entries in table_stats_request =1
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
#Verify action is modified
- SendPacket(self,pkt,of_ports[0],of_ports[2])
+ send_packet(self,pkt,of_ports[0],of_ports[2])
@@ -729,7 +729,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify flow gets inserted
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
# Verify flow removed message is recieved.
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
@@ -793,7 +793,7 @@
'Recieved flow removed message ')
# Verify no entries in the table
- Verify_TableStats(self,active_entries=0)
+ verify_tablestats(self,expect_active=0)
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index 43ce062..80828c1 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -102,10 +102,10 @@
logging.info("Expecting active_count=1 in table_stats_reply")
#Insert a flow entry matching on ingress_port
- (Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
# Send Table_Stats_Request and verify flow gets inserted.
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
class ModifyStateDelete(base_tests.SimpleProtocol):
@@ -131,16 +131,16 @@
logging.info("Expecting the active_count=0 in table_stats_reply")
#Insert a flow matching on ingress_port
- (Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
#Verify Flow inserted.
- Verify_TableStats(self,active_entries=1)
+ verify_tablestats(self,expect_active=1)
#Delete the flow
- NonStrict_Delete(self,match)
+ nonstrict_delete(self,match)
# Send Table_Stats_Request and verify flow deleted.
- Verify_TableStats(self,active_entries=0)
+ verify_tablestats(self,expect_active=0)
@@ -166,13 +166,13 @@
logging.info("Expecting the Test Packet to implement the modified action")
# Insert a flow matching on ingress_port with action A (output to of_port[1])
- (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match) = wildcard_all_except_ingress(self,of_ports)
# Modify the flow action (output to of_port[2])
- Modify_Flow_Action(self,of_ports,match)
+ modify_flow_action(self,of_ports,match)
# Send the Test Packet and verify action implemented is A' (output to of_port[2])
- SendPacket(self,pkt,of_ports[0],of_ports[2])
+ send_packet(self,pkt,of_ports[0],of_ports[2])
class ReadState(base_tests.SimpleProtocol):
@@ -197,10 +197,10 @@
logging.info("Expecting the a flow_stats_reply without errors")
# Insert a flow with match on ingress_port
- (pkt,match ) = Wildcard_All_Except_Ingress(self,of_ports)
+ (pkt,match ) = wildcard_all_except_ingress(self,of_ports)
#Verify Flow_Stats request does not generate errors
- Verify_FlowStats(self,match)
+ get_flowstats(self,match)
class PacketOut(base_tests.SimpleDataPlane):
@@ -355,7 +355,7 @@
#Send Barrier Request
request = message.barrier_request()
- (response, pkt) = self.controller.transact(request)
+ (response,pkt) = self.controller.transact(request)
self.assertEqual(response.header.type, ofp.OFPT_BARRIER_REPLY,'response is not barrier_reply')
self.assertEqual(request.header.xid, response.header.xid,
'response xid != request xid')