ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 1 | |
Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
| 17 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 18 | """These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases). |
| 19 | Refer Documentation -- Detailed testing methodology |
| 20 | <Some of test-cases are directly taken from oftest> """ |
| 21 | |
| 22 | "Test Suite 6 ---> Actions " |
| 23 | |
| 24 | |
| 25 | import logging |
| 26 | |
| 27 | import unittest |
| 28 | import random |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 29 | import time |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 30 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 31 | from oftest import config |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 32 | import oftest.controller as controller |
Rich Lane | d7b0ffa | 2013-03-08 15:53:42 -0800 | [diff] [blame] | 33 | import ofp |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 34 | import oftest.dataplane as dataplane |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 35 | import oftest.parse as parse |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 36 | import oftest.base_tests as base_tests |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 37 | |
Rich Lane | da3b5ad | 2012-10-03 09:05:32 -0700 | [diff] [blame] | 38 | from oftest.testutils import * |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 39 | from time import sleep |
| 40 | from FuncUtils import * |
| 41 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 42 | class NoAction(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 43 | |
| 44 | """NoActionDrop : no action added to flow , drops the packet.""" |
| 45 | |
| 46 | def runTest(self): |
| 47 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 48 | logging.info("Running No_Action test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 49 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 50 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 51 | of_ports.sort() |
| 52 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 53 | |
| 54 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 55 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 56 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 57 | logging.info("Install a flow without action") |
| 58 | logging.info("Send packets matching that flow") |
| 59 | logging.info("Expecting switch to drop all packets") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 60 | |
| 61 | # Insert a flow wildcard all without any action |
| 62 | pkt = simple_tcp_packet() |
| 63 | match = parse.packet_to_flow_match(pkt) |
| 64 | self.assertTrue(match is not None, "Could not generate flow match from pkt") |
| 65 | match.wildcards=ofp.OFPFW_ALL |
| 66 | match.in_port = of_ports[0] |
| 67 | |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 68 | msg = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 69 | msg.out_port = ofp.OFPP_NONE |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 70 | msg.buffer_id = 0xffffffff |
| 71 | msg.match = match |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 72 | self.controller.message_send(msg) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 73 | do_barrier(self.controller) |
ShreyaPandita | b46f852 | 2012-09-28 15:12:15 -0400 | [diff] [blame] | 74 | |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 75 | #Sending N packets matching the flow inserted |
| 76 | for pkt_cnt in range(5): |
| 77 | self.dataplane.send(of_ports[0],str(pkt)) |
| 78 | |
| 79 | #Verify packets not recieved on any of the dataplane ports |
ShreyaPandita | 7b9ec98 | 2012-09-28 14:43:08 -0400 | [diff] [blame] | 80 | (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1,exp_pkt=pkt) |
| 81 | self.assertTrue(rcv_pkt is None, |
ShreyaPandita | d4a42c6 | 2012-09-28 15:35:27 -0400 | [diff] [blame] | 82 | "Packet received on port " + str(rcv_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 83 | |
| 84 | #Verify packets not sent on control plane either |
Rich Lane | 4c504f3 | 2013-06-07 17:24:14 -0700 | [diff] [blame] | 85 | verify_no_packet_in(self, str(pkt), of_ports[0]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 86 | |
| 87 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 88 | class Announcement(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 89 | |
| 90 | """Announcement : Get all supported actions by the switch. |
| 91 | Send OFPT_FEATURES_REQUEST to get features supported by sw.""" |
| 92 | |
| 93 | def runTest(self): |
| 94 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 95 | logging.info("Running Announcement test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 96 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 97 | logging.info("Sending Features_Request") |
| 98 | logging.info("Expecting Features Reply with supported actions") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 99 | |
| 100 | # Sending Features_Request |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 101 | request = ofp.message.features_request() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 102 | (reply, pkt) = self.controller.transact(request) |
| 103 | self.assertTrue(reply is not None, "Failed to get any reply") |
Rich Lane | b73808c | 2013-03-11 15:22:23 -0700 | [diff] [blame] | 104 | self.assertEqual(reply.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply') |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 105 | |
| 106 | supported_actions =[] |
| 107 | if(reply.actions &1<<ofp.OFPAT_OUTPUT): |
| 108 | supported_actions.append('OFPAT_OUTPUT') |
| 109 | if(reply.actions &1<<ofp.OFPAT_SET_VLAN_VID): |
| 110 | supported_actions.append('OFPAT_SET_VLAN_VID') |
| 111 | if(reply.actions &1<<ofp.OFPAT_SET_VLAN_PCP): |
| 112 | supported_actions.append('OFPAT_SET_VLAN_PCP') |
| 113 | if(reply.actions &1<<ofp.OFPAT_STRIP_VLAN): |
| 114 | supported_actions.append('OFPAT_STRIP_VLAN') |
| 115 | if(reply.actions &1<<ofp.OFPAT_SET_DL_SRC): |
| 116 | supported_actions.append('OFPAT_SET_DL_SRC') |
| 117 | if(reply.actions &1<<ofp.OFPAT_SET_DL_DST): |
| 118 | supported_actions.append('OFPAT_SET_NW_SRC') |
| 119 | if(reply.actions &1<<ofp.OFPAT_SET_NW_DST): |
| 120 | supported_actions.append('OFPAT_SET_NW_DST') |
| 121 | if(reply.actions &1<<ofp.OFPAT_SET_NW_TOS): |
| 122 | supported_actions.append('OFPAT_SET_NW_TOS') |
| 123 | if(reply.actions &1<<ofp.OFPAT_SET_TP_SRC): |
| 124 | supported_actions.append('OFPAT_SET_TP_SRC') |
| 125 | if(reply.actions &1<<ofp.OFPAT_SET_TP_DST): |
| 126 | supported_actions.append('OFPAT_SET_TP_DST') |
Rich Lane | 609194f | 2013-10-21 06:17:37 -0700 | [diff] [blame] | 127 | if(reply.actions &1<<ofp.OFPAT_EXPERIMENTER): |
| 128 | supported_actions.append('OFPAT_EXPERIMENTER') |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 129 | if(reply.actions &1<<ofp.OFPAT_ENQUEUE): |
| 130 | supported_actions.append('OFPAT_ENQUEUE') |
| 131 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 132 | logging.info(supported_actions) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 133 | |
| 134 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 135 | class ForwardAll(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 136 | |
| 137 | """ForwardAll : Packet is sent to all dataplane ports |
| 138 | except ingress port when output action.port = OFPP_ALL""" |
| 139 | |
| 140 | def runTest(self): |
| 141 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 142 | logging.info("Running Forward_All test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 143 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 144 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 145 | of_ports.sort() |
| 146 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 147 | |
| 148 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 149 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 150 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 151 | logging.info("Insert a flow with output action port OFPP_ALL") |
| 152 | logging.info("Send packet matching the flow") |
| 153 | logging.info("Expecting packet on all dataplane ports except ingress_port") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 154 | |
| 155 | #Create a packet |
| 156 | pkt = simple_tcp_packet() |
| 157 | match = parse.packet_to_flow_match(pkt) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 158 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 159 | |
| 160 | #Delete all flows |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 161 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 162 | ingress_port=of_ports[0] |
| 163 | match.in_port = ingress_port |
| 164 | |
| 165 | #Create a flow mod with action.port = OFPP_ALL |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 166 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 167 | request.match = match |
| 168 | request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT |
| 169 | act.port = ofp.OFPP_ALL |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 170 | request.actions.append(act) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 171 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 172 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 173 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 174 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 175 | |
| 176 | #Send Packet matching the flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 177 | logging.info("Sending packet to dp port " + str(ingress_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 178 | self.dataplane.send(ingress_port, str(pkt)) |
| 179 | |
| 180 | #Verifying packets recieved on expected dataplane ports |
| 181 | yes_ports = set(of_ports).difference([ingress_port]) |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 182 | verify_packets(self, pkt, yes_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 183 | |
| 184 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 185 | class ForwardController(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 186 | |
| 187 | """ForwardController : Packet is sent to controller |
| 188 | output.port = OFPP_CONTROLLER""" |
| 189 | |
| 190 | def runTest(self): |
| 191 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 192 | logging.info("Running Forward_Controller test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 193 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 194 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 195 | of_ports.sort() |
| 196 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 197 | |
| 198 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 199 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 200 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 201 | logging.info("Insert a flow with output action port OFPP_CONTROLLER") |
| 202 | logging.info("Send packet matching the flow") |
| 203 | logging.info("Expecting packet on the control plane") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 204 | |
| 205 | #Create packet |
| 206 | pkt = simple_tcp_packet() |
| 207 | match = parse.packet_to_flow_match(pkt) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 208 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 209 | |
| 210 | for ingress_port in of_ports: |
| 211 | #Delete all flows |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 212 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 213 | |
| 214 | match.in_port = ingress_port |
| 215 | |
| 216 | #Create a flow mod message |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 217 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 218 | request.match = match |
| 219 | act.port = ofp.OFPP_CONTROLLER |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 220 | request.actions.append(act) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 221 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 222 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 223 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 224 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 225 | |
| 226 | #Send packet matching the flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 227 | logging.info("Sending packet to dp port " + str(ingress_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 228 | self.dataplane.send(ingress_port, str(pkt)) |
| 229 | |
| 230 | #Verifying packet recieved on the control plane port |
Rich Lane | 4c504f3 | 2013-06-07 17:24:14 -0700 | [diff] [blame] | 231 | verify_packet_in(self, str(pkt), ingress_port, ofp.OFPR_ACTION) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 232 | |
| 233 | |
| 234 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 235 | class ForwardLocal(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 236 | |
| 237 | """ForwardLocal : Packet is sent to OFPP_LOCAL port . |
| 238 | TBD : To verify packet recieved in the local networking stack of switch""" |
| 239 | |
| 240 | def runTest(self): |
| 241 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 242 | logging.info("Running Forward_Local test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 243 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 244 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 245 | of_ports.sort() |
| 246 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 247 | |
| 248 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 249 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 250 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 251 | logging.info("Insert a flow with output action port OFPP_LOCAL") |
| 252 | logging.info("Send packet matching the flow") |
| 253 | logging.info("Expecting packet in the local networking stack of switch") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 254 | |
| 255 | #Clear switch state |
| 256 | pkt = simple_tcp_packet() |
| 257 | match = parse.packet_to_flow_match(pkt) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 258 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 259 | |
| 260 | for ingress_port in of_ports: |
| 261 | #Delete the flows |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 262 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 263 | |
| 264 | match.in_port = ingress_port |
| 265 | #Create flow mod message |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 266 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 267 | request.match = match |
| 268 | act.port = ofp.OFPP_LOCAL |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 269 | request.actions.append(act) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 270 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 271 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 272 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 273 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 274 | |
| 275 | #Send packet matching the flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 276 | logging.info("Sending packet to dp port " + str(ingress_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 277 | self.dataplane.send(ingress_port, str(pkt)) |
| 278 | |
| 279 | #TBD: Verification of packets being recieved. |
| 280 | |
| 281 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 282 | class ForwardFlood(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 283 | |
| 284 | """Forward:Flood : Packet is sent to all dataplane ports |
| 285 | except ingress port when output action.port = OFPP_FLOOD |
| 286 | TBD : Verification---Incase of STP being implemented, flood the packet along the minimum spanning tree, |
| 287 | not including the incoming interface. """ |
| 288 | |
| 289 | def runTest(self): |
| 290 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 291 | logging.info("Running Forward_Flood test") |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 292 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 293 | of_ports.sort() |
| 294 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 295 | |
| 296 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 297 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 298 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 299 | logging.info("Insert a flow with output action port OFPP_FORWARD") |
| 300 | logging.info("Send packet matching the flow") |
| 301 | logging.info("Expecting packet on all the ports except the input port") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 302 | |
| 303 | #Create a packet |
| 304 | pkt = simple_tcp_packet() |
| 305 | match = parse.packet_to_flow_match(pkt) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 306 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 307 | |
| 308 | #Delete all flows |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 309 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 310 | ingress_port=of_ports[0] |
| 311 | match.in_port = ingress_port |
| 312 | |
| 313 | #Create a flow mod with action.port = OFPP_ALL |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 314 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 315 | request.match = match |
| 316 | request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT |
| 317 | act.port = ofp.OFPP_FLOOD |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 318 | request.actions.append(act) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 319 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 320 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 321 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 322 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 323 | |
| 324 | #Send Packet matching the flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 325 | logging.info("Sending packet to dp port " + str(ingress_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 326 | self.dataplane.send(ingress_port, str(pkt)) |
| 327 | |
| 328 | #Verifying packets recieved on expected dataplane ports |
| 329 | yes_ports = set(of_ports).difference([ingress_port]) |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 330 | verify_packets(self, pkt, yes_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 331 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 332 | class ForwardInport(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 333 | |
| 334 | """ ForwardInPort : Packet sent to virtual port IN_PORT |
| 335 | If the output.port = OFPP.INPORT then the packet is sent to the input port itself""" |
| 336 | |
| 337 | def runTest(self): |
| 338 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 339 | logging.info("Running Forward_Inport test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 340 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 341 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 342 | of_ports.sort() |
| 343 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 344 | |
| 345 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 346 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 347 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 348 | logging.info("Insert a flow with output action port OFPP_INPORT") |
| 349 | logging.info("Send packet matching the flow") |
| 350 | logging.info("Expecting packet on the input port") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 351 | |
| 352 | #Create a packet |
| 353 | pkt = simple_tcp_packet() |
| 354 | match = parse.packet_to_flow_match(pkt) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 355 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 356 | |
| 357 | #Delete the flows |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 358 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 359 | ingress_port=of_ports[0] |
| 360 | match.in_port = ingress_port |
| 361 | |
| 362 | # Create a flow mod message |
Rich Lane | ba3f0e2 | 2013-03-11 16:43:57 -0700 | [diff] [blame] | 363 | request = ofp.message.flow_add() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 364 | request.match = match |
| 365 | act.port = ofp.OFPP_IN_PORT |
| 366 | |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 367 | request.actions.append(act) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 368 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 369 | self.controller.message_send(request) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 370 | do_barrier(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 371 | |
| 372 | #Send packet matching the flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 373 | logging.info("Sending packet to dp port " + str(ingress_port)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 374 | self.dataplane.send(ingress_port, str(pkt)) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 375 | |
| 376 | #Verfying packet recieved on expected dataplane ports |
Rich Lane | e4b384d | 2013-09-13 14:33:40 -0700 | [diff] [blame] | 377 | verify_packets(self, pkt, [ingress_port]) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 378 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 379 | class ForwardTable(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 380 | |
| 381 | """ForwardTable : Perform actions in flow table. Only for packet-out messages. |
| 382 | If the output action.port in the packetout message = OFP.TABLE , then |
| 383 | the packet implements the action specified in the matching flow of the FLOW-TABLE""" |
| 384 | |
| 385 | def runTest(self): |
| 386 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 387 | logging.info("Running Forward_Table test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 388 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 389 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 390 | of_ports.sort() |
| 391 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 392 | |
| 393 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 394 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 395 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 396 | logging.info("Insert a flow F with output action port set to some egress_port") |
| 397 | logging.info("Send packet out message (matching flow F) with action.port = OFP.TABLE") |
| 398 | logging.info("Expecting packet on the egress_port") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 399 | |
| 400 | #Insert a all wildcarded flow |
ShreyaPandita | 8dab466 | 2012-11-02 13:40:14 -0400 | [diff] [blame] | 401 | (pkt,match) = wildcard_all(self,of_ports) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 402 | |
| 403 | #Create a packet out message |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 404 | pkt_out =ofp.message.packet_out(); |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 405 | pkt_out.data = str(pkt) |
| 406 | pkt_out.in_port = of_ports[0] |
Rich Lane | ea8c472 | 2013-04-04 15:30:20 -0700 | [diff] [blame] | 407 | pkt_out.buffer_id = 0xffffffff |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 408 | act = ofp.action.output() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 409 | act.port = ofp.OFPP_TABLE |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 410 | pkt_out.actions.append(act) |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 411 | self.controller.message_send(pkt_out) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 412 | |
| 413 | #Verifying packet out message recieved on the expected dataplane port. |
| 414 | (of_port, pkt, pkt_time) = self.dataplane.poll(port_number=of_ports[1], |
| 415 | exp_pkt=pkt,timeout=3) |
| 416 | self.assertTrue(pkt is not None, 'Packet not received') |
| 417 | |
| 418 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 419 | class AddVlanTag(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 420 | |
| 421 | """AddVlanTag : Adds VLAN Tag to untagged packet.""" |
| 422 | |
| 423 | def runTest(self): |
| 424 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 425 | logging.info("Running Add_vlan_tag test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 426 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 427 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 428 | of_ports.sort() |
| 429 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 430 | |
| 431 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 432 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 433 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 434 | logging.info("Verify if switch supports the action -- set vlan id, if not skip the test") |
| 435 | logging.info("Insert a flow with set vid action") |
| 436 | logging.info("Send packet matching the flow , verify recieved packet has vid set") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 437 | |
| 438 | #Verify set_vlan_id is a supported action |
| 439 | sup_acts = sw_supported_actions(self) |
| 440 | if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID): |
| 441 | skip_message_emit(self, "Add VLAN tag test skipped") |
| 442 | return |
| 443 | |
| 444 | #Create packet to be sent and an expected packet with vid set |
| 445 | new_vid = 2 |
| 446 | len_wo_vid = 100 |
| 447 | len_w_vid = 104 |
| 448 | pkt = simple_tcp_packet(pktlen=len_wo_vid) |
| 449 | exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True, |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 450 | vlan_vid=new_vid,vlan_pcp=0) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 451 | vid_act = ofp.action.set_vlan_vid() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 452 | vid_act.vlan_vid = new_vid |
| 453 | |
| 454 | #Insert flow with action -- set vid , Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 455 | flow_match_test(self, config["port_map"], pkt=pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 456 | exp_pkt=exp_pkt, action_list=[vid_act]) |
| 457 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 458 | class ModifyVlanTag(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 459 | |
| 460 | """ModifyVlanTag : Modifies VLAN Tag to tagged packet.""" |
| 461 | |
| 462 | def runTest(self): |
| 463 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 464 | logging.info("Running Modify_Vlan_Tag test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 465 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 466 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 467 | of_ports.sort() |
| 468 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 469 | |
| 470 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 471 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 472 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 473 | logging.info("Verify if switch supports the action -- modify vlan id, if not skip the test") |
| 474 | logging.info("Insert a flow with action --set vid ") |
| 475 | logging.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 476 | |
| 477 | #Verify set_vlan_id is a supported action |
| 478 | sup_acts = sw_supported_actions(self) |
| 479 | if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID): |
| 480 | skip_message_emit(self, "Modify VLAN tag test skipped") |
| 481 | return |
| 482 | |
| 483 | #Create a tagged packet with old_vid to be sent, and expected packet with new_vid |
| 484 | old_vid = 2 |
| 485 | new_vid = 3 |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 486 | pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=old_vid) |
| 487 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=new_vid) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 488 | vid_act = ofp.action.set_vlan_vid() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 489 | vid_act.vlan_vid = new_vid |
| 490 | |
| 491 | #Insert flow with action -- set vid , Send packet matching the flow.Verify recieved packet is expected packet. |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 492 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 493 | action_list=[vid_act]) |
| 494 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 495 | class VlanPrio1(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 496 | |
| 497 | """AddVlanPrioUntaggedPkt : Add VLAN priority to untagged packet.""" |
| 498 | |
| 499 | def runTest(self): |
| 500 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 501 | logging.info("Running vlan_Prio_1 test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 502 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 503 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 504 | of_ports.sort() |
| 505 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 506 | |
| 507 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 508 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 509 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 510 | logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test") |
| 511 | logging.info("Insert a flow with action -- set vlan priority ") |
| 512 | logging.info("Send untagged packet matching the flow , verify recieved packet has specified VLAN priority and has vid set tO 0 ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 513 | |
| 514 | #Verify set_vlan_priority is a supported action |
| 515 | sup_acts = sw_supported_actions(self) |
| 516 | if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP): |
| 517 | skip_message_emit(self, "Set VLAN priority test skipped") |
| 518 | return |
| 519 | |
| 520 | #Create a untagged packet to be sent and an expected packet with vid = 0 , vlan_priority set. |
| 521 | vlan_id = 0 |
Rich Lane | 123928c | 2012-10-04 21:28:53 -0700 | [diff] [blame] | 522 | vlan_pcp = 1 |
Dan Talayco | 3bfc822 | 2013-02-13 18:18:57 -0800 | [diff] [blame] | 523 | pktlen = 64 if config["minsize"] < 64 else config["minsize"] |
| 524 | pkt = simple_tcp_packet(pktlen=pktlen) |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 525 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,vlan_pcp=vlan_pcp, pktlen=pktlen + 4) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 526 | act = ofp.action.set_vlan_pcp() |
Rich Lane | 123928c | 2012-10-04 21:28:53 -0700 | [diff] [blame] | 527 | act.vlan_pcp = vlan_pcp |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 528 | |
| 529 | #Insert flow with action -- set vLAN priority, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 530 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 531 | action_list=[act]) |
| 532 | |
| 533 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 534 | class VlanPrio2(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 535 | |
| 536 | """ModifyVlanPrio : Modify VLAN priority to tagged packet.""" |
| 537 | |
| 538 | def runTest(self): |
| 539 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 540 | logging.info("Running Vlan_Prio_2 test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 541 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 542 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 543 | of_ports.sort() |
| 544 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 545 | |
| 546 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 547 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 548 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 549 | logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test") |
| 550 | logging.info("Insert a flow with action -- set vlan priority ") |
| 551 | logging.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 552 | |
| 553 | #Verify set_vlan_priority is a supported action |
| 554 | sup_acts = sw_supported_actions(self,"true") |
| 555 | if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP): |
| 556 | skip_message_emit(self, "modify_vlan_prio test skipped") |
| 557 | return |
| 558 | |
| 559 | #Create a tagged packet , and an expected packet with vlan_priority set to specified value |
| 560 | vid = 123 |
| 561 | old_vlan_pcp = 2 |
| 562 | new_vlan_pcp = 3 |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 563 | pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=old_vlan_pcp) |
| 564 | exp_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vid, vlan_pcp=new_vlan_pcp) |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 565 | vid_act = ofp.action.set_vlan_pcp() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 566 | vid_act.vlan_pcp = new_vlan_pcp |
| 567 | |
| 568 | #Insert flow with action -- set vLAN priority, Send tagged packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 569 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 570 | action_list=[vid_act]) |
| 571 | |
| 572 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 573 | class ModifyL2Src(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 574 | |
| 575 | """ModifyL2Src :Modify the source MAC address""" |
| 576 | |
| 577 | def runTest(self): |
| 578 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 579 | logging.info("Running Modify_L2_Src test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 580 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 581 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 582 | of_ports.sort() |
| 583 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 584 | |
| 585 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 586 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 587 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 588 | logging.info("Verify if switch supports the action -- modify_l2_src, if not skip the test") |
| 589 | logging.info("Insert a flow with action -- set etherent src address") |
| 590 | logging.info("Send packet matching the flow, verify recieved packet src address rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 591 | |
| 592 | #Verify set_dl_src is a supported action |
| 593 | sup_acts = sw_supported_actions(self,use_cache="true") |
| 594 | if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC): |
| 595 | skip_message_emit(self, "modify_l2_src test skipped") |
| 596 | return |
| 597 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 598 | #Create packet to be sent and expected packet with eth_src set to specified value |
| 599 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_src'], |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 600 | check_test_params=True) |
| 601 | |
| 602 | #Insert flow with action -- set src address, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 603 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 604 | action_list=acts, max_test=2) |
| 605 | |
| 606 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 607 | class ModifyL2Dst(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 608 | |
| 609 | """ModifyL2SDSt :Modify the dest MAC address""" |
| 610 | |
| 611 | def runTest(self): |
| 612 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 613 | logging.info("Running Modify_L2_Dst test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 614 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 615 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 616 | of_ports.sort() |
| 617 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 618 | |
| 619 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 620 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 621 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 622 | logging.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test") |
| 623 | logging.info("Insert a flow with action -- set etherent dst address ") |
| 624 | logging.info("Send packet matching the flow, verify recieved packet dst address rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 625 | |
| 626 | #Verify set_dl_dst is a supported action |
| 627 | sup_acts = sw_supported_actions(self) |
| 628 | if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST): |
| 629 | skip_message_emit(self, "modify_l2_dst test skipped") |
| 630 | return |
| 631 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 632 | #Create packet to be sent and expected packet with eth_src set to specified value |
| 633 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['eth_dst'], |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 634 | check_test_params=True) |
| 635 | |
| 636 | #Insert flow with action -- set dst address, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 637 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 638 | action_list=acts, max_test=2) |
| 639 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 640 | class ModifyL3Src(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 641 | |
| 642 | """ModifyL3Src : Modify the source IP address of an IP packet """ |
| 643 | |
| 644 | def runTest(self): |
| 645 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 646 | logging.info("Running Modify_L3_Src test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 647 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 648 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 649 | of_ports.sort() |
| 650 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 651 | |
| 652 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 653 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 654 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 655 | logging.info("Verify if switch supports the action -- modify_l3_src, if not skip the test") |
| 656 | logging.info("Insert a flow with action -- set network src address ") |
| 657 | logging.info("Send packet matching the flow, verify recieved packet network src address rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 658 | |
| 659 | #Verify set_nw_src is a supported action |
| 660 | sup_acts = sw_supported_actions(self) |
| 661 | if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC): |
| 662 | skip_message_emit(self, "modify_l3_src test") |
| 663 | return |
| 664 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 665 | #Create packet to be sent and expected packet with ipv4_src set to specified value |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 666 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'], |
| 667 | check_test_params=True) |
| 668 | |
| 669 | #Insert flow with action -- set nw src address, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 670 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 671 | action_list=acts, max_test=2) |
| 672 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 673 | class ModifyL3Dst(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 674 | |
| 675 | """ModifyL3Dst :Modify the dest IP address of an IP packet""" |
| 676 | |
| 677 | def runTest(self): |
| 678 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 679 | logging.info("Running Modify_L3_Dst test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 680 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 681 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 682 | of_ports.sort() |
| 683 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 684 | |
| 685 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 686 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 687 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 688 | logging.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test") |
| 689 | logging.info("Insert a flow with action -- set network dst address ") |
| 690 | logging.info("Send packet matching the flow, verify recieved packet network dst address rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 691 | |
| 692 | #Verify set_nw_dst is a supported action |
| 693 | sup_acts = sw_supported_actions(self,use_cache="true") |
| 694 | if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST): |
| 695 | skip_message_emit(self, "modify_l3_dst test skipped") |
| 696 | return |
| 697 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 698 | #Create packet to be sent and expected packet with ipv4_dst set to specified value |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 699 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'], |
| 700 | check_test_params=True) |
| 701 | |
| 702 | #Insert flow with action -- set nw dst address, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 703 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 704 | action_list=acts, max_test=2) |
| 705 | |
| 706 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 707 | class ModifyL4Src(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 708 | |
| 709 | """ModifyL4Src : Modify the source TCP port of a TCP packet""" |
| 710 | |
| 711 | def runTest(self): |
| 712 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 713 | logging.info("Running Modify_L4_Src test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 714 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 715 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 716 | of_ports.sort() |
| 717 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 718 | |
| 719 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 720 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 721 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 722 | logging.info("Verify if switch supports the action -- modify_l4_src, if not skip the test") |
| 723 | logging.info("Insert a flow with action -- set src tcp port") |
| 724 | logging.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 725 | |
| 726 | #Verify set_tp_src is a supported action |
| 727 | sup_acts = sw_supported_actions(self,use_cache="true") |
| 728 | if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC): |
| 729 | skip_message_emit(self, "modify_l4_src test skipped") |
| 730 | return |
| 731 | |
| 732 | #Create packet to be sent and expected packet with tcp_src set to specified value |
| 733 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_sport'], |
| 734 | check_test_params=True) |
| 735 | |
| 736 | #Insert flow with action -- set tcp src port, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 737 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 738 | action_list=acts, max_test=2) |
| 739 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 740 | class ModifyL4Dst(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 741 | |
| 742 | """ ModifyL4Dst: Modify the dest TCP port of a TCP packet """ |
| 743 | |
| 744 | def runTest(self): |
| 745 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 746 | logging.info("Running Modify_L4_Dst test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 747 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 748 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 749 | of_ports.sort() |
| 750 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 751 | |
| 752 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 753 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 754 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 755 | logging.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test") |
| 756 | logging.info("Insert a flow with action -- set dst tcp port") |
| 757 | logging.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 758 | |
| 759 | #Verify set_tp_dst is a supported action |
| 760 | sup_acts = sw_supported_actions(self,use_cache="true") |
| 761 | if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST): |
| 762 | skip_message_emit(self, "ModifyL4Dst test") |
| 763 | return |
| 764 | |
| 765 | #Create packet to be sent and expected packet with tcp_dst set to specified value |
| 766 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_dport'], |
| 767 | check_test_params=True) |
| 768 | |
| 769 | #Insert flow with action -- set tcp dst port, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 770 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 771 | action_list=acts, max_test=2) |
| 772 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 773 | class ModifyTos(base_tests.SimpleDataPlane): |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 774 | |
| 775 | """ModifyTOS :Modify the IP type of service of an IP packet""" |
| 776 | |
| 777 | def runTest(self): |
| 778 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 779 | logging.info("Running Modify_Tos test") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 780 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 781 | of_ports = config["port_map"].keys() |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 782 | of_ports.sort() |
| 783 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 784 | |
| 785 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 786 | delete_all_flows(self.controller) |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 787 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 788 | logging.info("Verify if switch supports the action -- modify_tos, if not skip the test") |
| 789 | logging.info("Insert a flow with action -- set type of service ") |
| 790 | logging.info("Send packet matching the flow, verify recieved packet has TOS rewritten ") |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 791 | |
| 792 | #Verify set_tos is a supported action |
| 793 | sup_acts = sw_supported_actions(self,use_cache="true") |
| 794 | if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS): |
| 795 | skip_message_emit(self, "ModifyTOS test") |
| 796 | return |
| 797 | |
| 798 | #Create packet to be sent and expected packet with TOS set to specified value |
| 799 | (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_tos'], |
| 800 | check_test_params=True) |
| 801 | |
| 802 | #Insert flow with action -- set TOS, Send packet matching the flow, Verify recieved packet is expected packet |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 803 | flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt, |
ShreyaPandita | 9306c77 | 2012-09-28 12:21:40 -0400 | [diff] [blame] | 804 | action_list=acts, max_test=2, egr_count=-1) |