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