ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 1 | """These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases). |
| 2 | Refer Documentation -- Detailed testing methodology |
| 3 | <Some of test-cases are directly taken from oftest> """ |
| 4 | |
| 5 | "Test Suite 6 --> Flow Matches" |
| 6 | |
| 7 | |
| 8 | import logging |
| 9 | |
| 10 | import unittest |
| 11 | import random |
| 12 | |
Rich Lane | cd97d3d | 2013-01-07 18:50:06 -0800 | [diff] [blame] | 13 | from oftest import config |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 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 oftest.base_tests as base_tests |
| 21 | import time |
| 22 | |
| 23 | from oftest.testutils import * |
| 24 | from time import sleep |
| 25 | from FuncUtils import * |
| 26 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 27 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 28 | |
| 29 | class AllWildcardMatch(base_tests.SimpleDataPlane): |
| 30 | |
| 31 | """Verify for an all wildcarded flow all the injected packets would match that flow""" |
| 32 | |
| 33 | def runTest(self): |
| 34 | |
| 35 | logging.info("Running All Wildcard Match test") |
| 36 | |
| 37 | of_ports = config["port_map"].keys() |
| 38 | of_ports.sort() |
| 39 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 40 | |
| 41 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 42 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 43 | |
| 44 | logging.info("Inserting an all wildcarded flow and sending packets with various match fields") |
| 45 | logging.info("Expecting all sent packets to match") |
| 46 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 47 | egress_port=of_ports[1] |
| 48 | no_ports=set(of_ports).difference([egress_port]) |
| 49 | yes_ports = of_ports[1] |
| 50 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 51 | #Insert an All Wildcarded flow. |
| 52 | wildcard_all(self,of_ports) |
| 53 | |
| 54 | #check for different match fields and verify packet implements the action specified in the flow |
| 55 | pkt1 = simple_tcp_packet(dl_src="00:01:01:01:01:01"); |
| 56 | self.dataplane.send(of_ports[0], str(pkt1)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 57 | receive_pkt_check(self.dataplane,pkt1,[yes_ports],no_ports,self) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 58 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 59 | pkt2 = simple_tcp_packet(dl_dst="00:01:01:01:01:01"); |
| 60 | self.dataplane.send(of_ports[0], str(pkt2)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 61 | receive_pkt_check(self.dataplane,pkt2,[yes_ports],no_ports,self) |
| 62 | |
| 63 | pkt3 = simple_tcp_packet(ip_src="192.168.2.1"); |
| 64 | self.dataplane.send(of_ports[0], str(pkt3)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 65 | receive_pkt_check(self.dataplane,pkt3,[yes_ports],no_ports,self) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 66 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 67 | pkt4 = simple_tcp_packet(ip_dst="192.168.2.2"); |
| 68 | self.dataplane.send(of_ports[0], str(pkt4)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 69 | receive_pkt_check(self.dataplane,pkt4,[yes_ports],no_ports,self) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 70 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 71 | pkt5 = simple_tcp_packet(ip_tos=2); |
| 72 | self.dataplane.send(of_ports[0], str(pkt5)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 73 | receive_pkt_check(self.dataplane,pkt5,[yes_ports],no_ports,self) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 74 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 75 | pkt6 = simple_tcp_packet(tcp_sport=8080); |
| 76 | self.dataplane.send(of_ports[0], str(pkt6)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 77 | receive_pkt_check(self.dataplane,pkt6,[yes_ports],no_ports,self) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 78 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 79 | pkt7 = simple_tcp_packet(tcp_dport=8081); |
| 80 | self.dataplane.send(of_ports[0], str(pkt7)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 81 | receive_pkt_check(self.dataplane,pkt7,[yes_ports],no_ports,self) |
| 82 | |
| 83 | |
| 84 | |
| 85 | class EthernetSrcAddress(base_tests.SimpleDataPlane): |
| 86 | |
| 87 | """Verify match on single header field -- Ethernet Src Address """ |
| 88 | |
| 89 | def runTest(self): |
| 90 | |
| 91 | logging.info("Running Ethernet Src Address test") |
| 92 | |
| 93 | of_ports = config["port_map"].keys() |
| 94 | of_ports.sort() |
| 95 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 96 | |
| 97 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 98 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 99 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 100 | egress_port=of_ports[1] |
| 101 | no_ports=set(of_ports).difference([egress_port]) |
| 102 | yes_ports = of_ports[1] |
| 103 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 104 | logging.info("Inserting a flow with match on Ethernet Source Address ") |
| 105 | logging.info("Sending matching and non-matching ethernet packets") |
| 106 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 107 | |
| 108 | #Insert a Match On Ethernet Src Address flow |
| 109 | (pkt,match) = match_ethernet_src_address(self,of_ports) |
| 110 | |
| 111 | #Sending packet matching the flow, verify it implements the action |
| 112 | self.dataplane.send(of_ports[0], str(pkt)) |
| 113 | |
| 114 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 115 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 116 | |
| 117 | #Sending non matching packet , verify Packetin event gets triggered. |
| 118 | pkt2 = simple_eth_packet(dl_src='00:01:01:01:01:02'); |
| 119 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 120 | |
| 121 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 122 | self.assertTrue(response is not None, "PacketIn not received for non matching packets") |
| 123 | |
| 124 | class EthernetDstAddress(base_tests.SimpleDataPlane): |
| 125 | |
| 126 | """Verify match on single Header Field Field -- Ethernet Dst Address """ |
| 127 | |
| 128 | def runTest(self): |
| 129 | |
| 130 | logging.info("Running Ethernet Dst Address test") |
| 131 | |
| 132 | of_ports = config["port_map"].keys() |
| 133 | of_ports.sort() |
| 134 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 135 | |
| 136 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 137 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 138 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 139 | egress_port=of_ports[1] |
| 140 | no_ports=set(of_ports).difference([egress_port]) |
| 141 | yes_ports = of_ports[1] |
| 142 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 143 | logging.info("Inserting a flow with match on Ethernet Destination Address ") |
| 144 | logging.info("Sending matching and non-matching ethernet packets") |
| 145 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 146 | |
| 147 | #Insert a Match on Destination Address flow |
| 148 | (pkt,match) = match_ethernet_dst_address(self,of_ports) |
| 149 | |
| 150 | #Send Packet matching the flow |
| 151 | self.dataplane.send(of_ports[0], str(pkt)) |
| 152 | |
| 153 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 154 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 155 | |
| 156 | #Send Non-matching packet |
| 157 | pkt2 = simple_eth_packet(dl_dst='00:01:01:01:01:02'); |
| 158 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 159 | |
| 160 | #Verify PacketIn event gets triggered |
| 161 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 162 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 163 | |
| 164 | |
| 165 | class EthernetType(base_tests.SimpleDataPlane): |
| 166 | |
| 167 | """Verify match on single header field -- Ethernet Type """ |
| 168 | |
| 169 | def runTest(self): |
| 170 | |
| 171 | logging.info("Running Ethernet Type test") |
| 172 | |
| 173 | of_ports = config["port_map"].keys() |
| 174 | of_ports.sort() |
| 175 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 176 | |
| 177 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 178 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 179 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 180 | egress_port=of_ports[1] |
| 181 | no_ports=set(of_ports).difference([egress_port]) |
| 182 | yes_ports = of_ports[1] |
| 183 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 184 | logging.info("Inserting a flow with match on Ethernet Type ") |
| 185 | logging.info("Sending matching and non-matching ethernet packets") |
| 186 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 187 | |
| 188 | #Insert a Match on Ethernet-Type flow |
| 189 | (pkt,match) = match_ethernet_type(self,of_ports) |
| 190 | |
| 191 | #Sending packet matching the flow |
| 192 | self.dataplane.send(of_ports[0], str(pkt)) |
| 193 | |
| 194 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 195 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 196 | |
| 197 | #Sending non matching packet , |
| 198 | pkt2 = simple_eth_packet(dl_type=0x0806); |
| 199 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 200 | |
| 201 | #verify Packetin event gets triggered. |
| 202 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 203 | self.assertTrue(response is not None, "PacketIn not received for non-matching packet") |
| 204 | |
| 205 | |
| 206 | class IngressPort(base_tests.SimpleDataPlane): |
| 207 | |
| 208 | """Verify match on single Header Field Field -- In_port """ |
| 209 | |
| 210 | def runTest(self): |
| 211 | |
| 212 | logging.info("Running Ingress Port test") |
| 213 | |
| 214 | of_ports = config["port_map"].keys() |
| 215 | of_ports.sort() |
| 216 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 217 | |
| 218 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 219 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 220 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 221 | egress_port=of_ports[1] |
| 222 | no_ports=set(of_ports).difference([egress_port]) |
| 223 | yes_ports = of_ports[1] |
| 224 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 225 | logging.info("Inserting a flow with match on Ingress Port ") |
| 226 | logging.info("Sending matching and non-matching packets") |
| 227 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 228 | |
| 229 | #Insert a Match on Ingress Port FLow |
| 230 | (pkt,match) = wildcard_all_except_ingress(self,of_ports,priority=0) |
| 231 | |
| 232 | #Send Packet matching the flow i.e on in_port specified in the flow |
| 233 | self.dataplane.send(of_ports[0], str(pkt)) |
| 234 | |
| 235 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 236 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 237 | |
| 238 | #Send Non-Matching Packet |
| 239 | self.dataplane.send(of_ports[1],str(pkt)) |
| 240 | |
| 241 | #Verify PacketIn event gets triggered |
| 242 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 243 | self.assertTrue(response is not None, "PacketIn not received for non-matching packet") |
| 244 | |
| 245 | class VlanId(base_tests.SimpleDataPlane): |
| 246 | |
| 247 | """Verify match on single Header Field Field -- Vlan Id """ |
| 248 | |
| 249 | def runTest(self): |
| 250 | |
| 251 | of_ports = config["port_map"].keys() |
| 252 | of_ports.sort() |
| 253 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 254 | |
| 255 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 256 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 257 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 258 | egress_port=of_ports[1] |
| 259 | no_ports=set(of_ports).difference([egress_port]) |
| 260 | yes_ports = of_ports[1] |
| 261 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 262 | logging.info("Inserting a flow with match on VLAN ID ") |
| 263 | logging.info("Sending matching and non-matching tagged packets") |
| 264 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 265 | |
| 266 | #Create a flow with match on Vlan Id |
| 267 | (pkt,match) = match_vlan_id(self,of_ports) |
| 268 | |
| 269 | #Send tagged packet matching the flow i.e packet with same vlan id as in flow |
| 270 | self.dataplane.send(of_ports[0], str(pkt)) |
| 271 | |
| 272 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 273 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 274 | |
| 275 | #Send Non-matching packet, i.e packet with different Vlan Id |
| 276 | pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=4); |
| 277 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 278 | |
| 279 | #Verify PacketIn event gets triggered |
| 280 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 281 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 282 | |
| 283 | class VlanPCP(base_tests.SimpleDataPlane): |
| 284 | |
| 285 | """"Verify match on single Header Field Field -- Vlan Priority""" |
| 286 | |
| 287 | def runTest(self): |
| 288 | |
| 289 | logging.info("Running VlanPCP1 test") |
| 290 | |
| 291 | of_ports = config["port_map"].keys() |
| 292 | of_ports.sort() |
| 293 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 294 | |
| 295 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 296 | delete_all_flows(self.controller) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 297 | |
| 298 | egress_port=of_ports[1] |
| 299 | no_ports=set(of_ports).difference([egress_port]) |
| 300 | yes_ports = of_ports[1] |
| 301 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 302 | logging.info("Inserting a flow with match on VLAN Priority ") |
| 303 | logging.info("Sending matching and non-matching tagged packets") |
| 304 | logging.info("Verifying matching packet implements the action specified in the flow") |
| 305 | |
| 306 | #Create a flow matching on VLAN Priority |
| 307 | (pkt,match) = match_vlan_pcp(self,of_ports) |
| 308 | |
| 309 | #Send tagged Packet matching the flow |
| 310 | self.dataplane.send(of_ports[0], str(pkt)) |
| 311 | |
| 312 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 313 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 314 | |
| 315 | #Send tagged packet with same vlan_id but different vlan priority |
| 316 | pkt2 = simple_tcp_packet(dl_vlan_enable=True,dl_vlan=1,dl_vlan_pcp=20); |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 317 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 318 | |
| 319 | #Verify Packet_In event gets triggered |
| 320 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 321 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 322 | |
| 323 | class MultipleHeaderFieldL2(base_tests.SimpleDataPlane): |
| 324 | |
| 325 | """Verify match on multiple header field -- Ethernet Type, Ethernet Source Address, Ethernet Destination Address """ |
| 326 | |
| 327 | def runTest(self): |
| 328 | |
| 329 | logging.info("Running Multiple Header Field L2 test") |
| 330 | |
| 331 | of_ports = config["port_map"].keys() |
| 332 | of_ports.sort() |
| 333 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 334 | |
| 335 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 336 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 337 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 338 | egress_port=of_ports[1] |
| 339 | no_ports=set(of_ports).difference([egress_port]) |
| 340 | yes_ports = of_ports[1] |
| 341 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 342 | logging.info("Inserting a flow with match on Multiple Header Fields in L2 ") |
| 343 | logging.info("Sending matching and non-matching packets") |
| 344 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 345 | |
| 346 | (pkt,match) = match_mul_l2(self,of_ports) |
| 347 | |
| 348 | #Send eth packet matching the dl_type field, verify it implements the action |
| 349 | self.dataplane.send(of_ports[0], str(pkt)) |
| 350 | |
| 351 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 352 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 353 | |
| 354 | #Sending non matching packet (only dl_dst is different) , verify Packetin event gets triggered. |
| 355 | pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:02:01:01'); |
| 356 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 357 | |
| 358 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 359 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 360 | |
| 361 | #Sending non matching packet (only dl_src is different) , verify Packetin event gets triggered. |
| 362 | pkt2 = simple_eth_packet(dl_type=0x88cc,dl_src='00:01:01:01:01:02',dl_dst='00:01:01:01:01:02'); |
| 363 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 364 | |
| 365 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 366 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 367 | |
| 368 | #Sending non matching packet (only ether_type is different) , verify Packetin event gets triggered. |
| 369 | pkt2 = simple_eth_packet(dl_type=0x0806,dl_src='00:01:01:01:01:01',dl_dst='00:01:01:01:01:02'); |
| 370 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 371 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 372 | #Verify packet_in event gets triggered |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 373 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 374 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 375 | |
| 376 | class IpTos(base_tests.SimpleDataPlane): |
| 377 | |
| 378 | """"Verify match on single Header Field Field -- Type of service""" |
| 379 | |
| 380 | def runTest(self): |
| 381 | |
| 382 | logging.info("Running Ip_Tos test") |
| 383 | |
| 384 | of_ports = config["port_map"].keys() |
| 385 | of_ports.sort() |
| 386 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 387 | |
| 388 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 389 | delete_all_flows(self.controller) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 390 | |
| 391 | egress_port=of_ports[1] |
| 392 | no_ports=set(of_ports).difference([egress_port]) |
| 393 | yes_ports = of_ports[1] |
| 394 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 395 | logging.info("Inserting a flow with match on Ip_Tos ") |
| 396 | logging.info("Sending matching and non-matching tcp/ip packets") |
| 397 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 398 | |
| 399 | #Create a flow matching on VLAN Priority |
| 400 | (pkt,match) = match_ip_tos(self,of_ports) |
| 401 | |
| 402 | #Send Packet matching the flow |
| 403 | self.dataplane.send(of_ports[0], str(pkt)) |
| 404 | |
| 405 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 406 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 407 | |
| 408 | #Create a non-matching packet , verify packet_in get generated |
Rich Lane | b5c7379 | 2012-12-03 17:12:32 -0800 | [diff] [blame] | 409 | pkt2 = simple_tcp_packet(ip_tos=4); |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 410 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 411 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 412 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 413 | |
| 414 | class IpProtocol(base_tests.SimpleDataPlane): |
| 415 | |
| 416 | """"Verify match on single Header Field Field -- Ip Protocol""" |
| 417 | |
| 418 | def runTest(self): |
| 419 | |
| 420 | logging.info("Running Ip Protocol test") |
| 421 | |
| 422 | of_ports = config["port_map"].keys() |
| 423 | of_ports.sort() |
| 424 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 425 | |
| 426 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 427 | delete_all_flows(self.controller) |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 428 | |
| 429 | egress_port=of_ports[1] |
| 430 | no_ports=set(of_ports).difference([egress_port]) |
| 431 | yes_ports = of_ports[1] |
| 432 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 433 | logging.info("Inserting a flow with match on Ip Protocol ") |
| 434 | logging.info("Sending matching and non-matching tcp/ip packets") |
| 435 | logging.info("Verifying only matching packets implements the action specified in the flow") |
| 436 | |
| 437 | #Create a flow matching on VLAN Priority |
| 438 | (pkt,match) = match_ip_protocol(self,of_ports) |
| 439 | |
| 440 | #Send Packet matching the flow |
| 441 | self.dataplane.send(of_ports[0], str(pkt)) |
| 442 | |
| 443 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 444 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 445 | |
| 446 | #Create a non-matching packet , verify packet_in get generated |
| 447 | pkt2 = simple_icmp_packet(); |
| 448 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 449 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 450 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 451 | |
| 452 | |
| 453 | class TcpSrcPort(base_tests.SimpleDataPlane): |
| 454 | |
| 455 | """Verify match on Single header field -- Tcp Source Port, """ |
| 456 | |
| 457 | def runTest(self): |
| 458 | |
| 459 | logging.info("Running Tcp Src Port test") |
| 460 | |
| 461 | of_ports = config["port_map"].keys() |
| 462 | of_ports.sort() |
| 463 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 464 | |
| 465 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 466 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 467 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 468 | egress_port=of_ports[1] |
| 469 | no_ports=set(of_ports).difference([egress_port]) |
| 470 | yes_ports = of_ports[1] |
| 471 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 472 | logging.info("Inserting a flow with match on Tcp Tcp Source Port ") |
| 473 | logging.info("Sending matching and non-matching tcp packets") |
| 474 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 475 | |
| 476 | (pkt,match) = match_tcp_src(self,of_ports) |
| 477 | |
| 478 | #Sending packet matching the tcp_sport, verify it implements the action |
| 479 | self.dataplane.send(of_ports[0], str(pkt)) |
| 480 | |
| 481 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 482 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 483 | |
| 484 | #Sending non matching packet , verify Packetin event gets triggered. |
| 485 | pkt2 = simple_tcp_packet(tcp_sport=540); |
| 486 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 487 | |
| 488 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 489 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 490 | |
| 491 | class TcpDstPort(base_tests.SimpleDataPlane): |
| 492 | |
| 493 | """Verify match on Single header field -- Tcp Destination Port """ |
| 494 | |
| 495 | def runTest(self): |
| 496 | |
| 497 | logging.info("Running Tcp Destination Port test") |
| 498 | |
| 499 | of_ports = config["port_map"].keys() |
| 500 | of_ports.sort() |
| 501 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 502 | |
| 503 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 504 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 505 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 506 | egress_port=of_ports[1] |
| 507 | no_ports=set(of_ports).difference([egress_port]) |
| 508 | yes_ports = of_ports[1] |
| 509 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 510 | logging.info("Inserting a flow with match on Tcp Destination Port ") |
| 511 | logging.info("Sending matching and non-matching packets") |
| 512 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 513 | |
| 514 | (pkt,match) = match_tcp_dst(self,of_ports) |
| 515 | |
| 516 | #Sending packet matching the tcp_dport, verify it implements the action |
| 517 | self.dataplane.send(of_ports[0], str(pkt)) |
| 518 | |
| 519 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 520 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 521 | |
| 522 | #Sending non matching packet , verify Packetin event gets triggered. |
| 523 | pkt2 = simple_tcp_packet(tcp_dport=541); |
| 524 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 525 | |
| 526 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10) |
| 527 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 528 | |
Shudong Zhou | c2f1876 | 2013-01-11 00:12:44 -0800 | [diff] [blame] | 529 | class UdpSrcPort(base_tests.SimpleDataPlane): |
| 530 | |
| 531 | """Verify match on Single header field -- Udp Source Port, """ |
| 532 | |
| 533 | def runTest(self): |
| 534 | |
| 535 | logging.info("Running Udp Src Port test") |
| 536 | |
| 537 | of_ports = config["port_map"].keys() |
| 538 | of_ports.sort() |
| 539 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 540 | |
| 541 | #Clear Switch State |
| 542 | delete_all_flows(self.controller) |
| 543 | |
| 544 | egress_port=of_ports[1] |
| 545 | no_ports=set(of_ports).difference([egress_port]) |
| 546 | yes_ports = of_ports[1] |
| 547 | |
| 548 | logging.info("Inserting a flow with match on Udp Udp Source Port ") |
| 549 | logging.info("Sending matching and non-matching tcp packets") |
| 550 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 551 | |
| 552 | (pkt,match) = match_udp_src(self,of_ports) |
| 553 | |
| 554 | #Sending packet matching the tcp_sport, verify it implements the action |
| 555 | self.dataplane.send(of_ports[0], str(pkt)) |
| 556 | |
| 557 | #Verify packet implements the action specified in the flow |
| 558 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 559 | |
| 560 | #Sending non matching packet , verify Packetin event gets triggered. |
| 561 | pkt2 = simple_udp_packet(udp_sport=540); |
| 562 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 563 | |
| 564 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 565 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 566 | |
| 567 | class UdpDstPort(base_tests.SimpleDataPlane): |
| 568 | |
| 569 | """Verify match on Single header field -- Udp Destination Port """ |
| 570 | |
| 571 | def runTest(self): |
| 572 | |
| 573 | logging.info("Running Udp Destination Port test") |
| 574 | |
| 575 | of_ports = config["port_map"].keys() |
| 576 | of_ports.sort() |
| 577 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 578 | |
| 579 | #Clear Switch State |
| 580 | delete_all_flows(self.controller) |
| 581 | |
| 582 | egress_port=of_ports[1] |
| 583 | no_ports=set(of_ports).difference([egress_port]) |
| 584 | yes_ports = of_ports[1] |
| 585 | |
| 586 | logging.info("Inserting a flow with match on Udp Destination Port ") |
| 587 | logging.info("Sending matching and non-matching packets") |
| 588 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 589 | |
| 590 | (pkt,match) = match_udp_dst(self,of_ports) |
| 591 | |
| 592 | #Sending packet matching the tcp_dport, verify it implements the action |
| 593 | self.dataplane.send(of_ports[0], str(pkt)) |
| 594 | |
| 595 | #Verify packet implements the action specified in the flow |
| 596 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 597 | |
| 598 | #Sending non matching packet , verify Packetin event gets triggered. |
| 599 | pkt2 = simple_udp_packet(udp_dport=541); |
| 600 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 601 | |
| 602 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10) |
| 603 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 604 | |
| 605 | class ICMPType(base_tests.SimpleDataPlane): |
| 606 | |
| 607 | """Verify match on Single header field -- ICMP type, """ |
| 608 | |
| 609 | def runTest(self): |
| 610 | |
| 611 | logging.info("Running ICMP type test") |
| 612 | |
| 613 | of_ports = config["port_map"].keys() |
| 614 | of_ports.sort() |
| 615 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 616 | |
| 617 | #Clear Switch State |
| 618 | delete_all_flows(self.controller) |
| 619 | |
| 620 | egress_port=of_ports[1] |
| 621 | no_ports=set(of_ports).difference([egress_port]) |
| 622 | yes_ports = of_ports[1] |
| 623 | |
| 624 | logging.info("Inserting a flow with match on ICMP type") |
| 625 | logging.info("Sending matching and non-matching ICMP packets") |
| 626 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 627 | |
| 628 | (pkt,match) = match_icmp_type(self,of_ports) |
| 629 | |
| 630 | #Sending packet matching the tcp_sport, verify it implements the action |
| 631 | self.dataplane.send(of_ports[0], str(pkt)) |
| 632 | |
| 633 | #Verify packet implements the action specified in the flow |
| 634 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 635 | |
| 636 | #Sending non matching packet , verify Packetin event gets triggered. |
| 637 | pkt2 = simple_icmp_packet(icmp_type=10); |
| 638 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 639 | |
| 640 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 641 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 642 | |
| 643 | class ICMPCode(base_tests.SimpleDataPlane): |
| 644 | |
| 645 | """Verify match on Single header field -- ICMP code, """ |
| 646 | |
| 647 | def runTest(self): |
| 648 | |
| 649 | logging.info("Running ICMP code test") |
| 650 | |
| 651 | of_ports = config["port_map"].keys() |
| 652 | of_ports.sort() |
| 653 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 654 | |
| 655 | #Clear Switch State |
| 656 | delete_all_flows(self.controller) |
| 657 | |
| 658 | egress_port=of_ports[1] |
| 659 | no_ports=set(of_ports).difference([egress_port]) |
| 660 | yes_ports = of_ports[1] |
| 661 | |
| 662 | logging.info("Inserting a flow with match on ICMP type") |
| 663 | logging.info("Sending matching and non-matching ICMP packets") |
| 664 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 665 | |
| 666 | (pkt,match) = match_icmp_code(self,of_ports) |
| 667 | |
| 668 | #Sending packet matching the tcp_dport, verify it implements the action |
| 669 | self.dataplane.send(of_ports[0], str(pkt)) |
| 670 | |
| 671 | #Verify packet implements the action specified in the flow |
| 672 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 673 | |
| 674 | #Sending non matching packet , verify Packetin event gets triggered. |
| 675 | pkt2 = simple_icmp_packet(icmp_code=10); |
| 676 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 677 | |
| 678 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 679 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 680 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 681 | |
| 682 | class ExactMatch(base_tests.SimpleDataPlane): |
| 683 | |
| 684 | """Verify match on Single header field -- Exact Match """ |
| 685 | |
| 686 | def runTest(self): |
| 687 | |
| 688 | logging.info("Running Tcp Exact Match test") |
| 689 | |
| 690 | of_ports = config["port_map"].keys() |
| 691 | of_ports.sort() |
| 692 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 693 | |
| 694 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 695 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 696 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 697 | egress_port=of_ports[1] |
| 698 | no_ports=set(of_ports).difference([egress_port]) |
| 699 | yes_ports = of_ports[1] |
| 700 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 701 | logging.info("Inserting a flow with match for Exact Match ") |
| 702 | logging.info("Sending matching and non-matching packets") |
| 703 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 704 | |
| 705 | (pkt,match) = exact_match(self,of_ports) |
| 706 | |
| 707 | #Sending packet matching all the fields of a tcp_packet, verify it implements the action |
| 708 | self.dataplane.send(of_ports[0], str(pkt)) |
| 709 | |
| 710 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 711 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 712 | |
| 713 | #Sending non matching packet , verify Packetin event gets triggered. |
| 714 | pkt2 = simple_tcp_packet(tcp_sport=540); |
| 715 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 716 | |
| 717 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 718 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 719 | |
| 720 | |
| 721 | class MultipleHeaderFieldL4(base_tests.SimpleDataPlane): |
| 722 | |
| 723 | """Verify match on multiple header field -- Tcp Source Port, Tcp Destination Port """ |
| 724 | |
| 725 | def runTest(self): |
| 726 | |
| 727 | logging.info("Running Multiple Header Field L4 test") |
| 728 | |
| 729 | of_ports = config["port_map"].keys() |
| 730 | of_ports.sort() |
| 731 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 732 | |
| 733 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 734 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 735 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 736 | egress_port=of_ports[1] |
| 737 | no_ports=set(of_ports).difference([egress_port]) |
| 738 | yes_ports = of_ports[1] |
| 739 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 740 | logging.info("Inserting a flow with match on Multiple Header Field L4 ") |
| 741 | logging.info("Sending matching and non-matching packets") |
| 742 | logging.info("Verifying matching packets implements the action specified in the flow") |
| 743 | |
| 744 | (pkt,match) = match_mul_l4(self,of_ports) |
| 745 | |
| 746 | #Sending packet matching the tcp_sport and tcp_dport field, verify it implements the action |
| 747 | self.dataplane.send(of_ports[0], str(pkt)) |
| 748 | |
| 749 | #Verify packet implements the action specified in the flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 750 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 751 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 752 | #Sending non matching packet (tcp_dport different), verify Packetin event gets triggered. |
| 753 | pkt2 = simple_tcp_packet(tcp_sport=111,tcp_dport=541); |
| 754 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 755 | |
| 756 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 757 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 758 | |
| 759 | #Sending non matching packet (tcp_sport different), verify Packetin event gets triggered. |
| 760 | pkt2 = simple_tcp_packet(tcp_sport=100,tcp_dport=112); |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 761 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 762 | |
| 763 | (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4) |
| 764 | self.assertTrue(response is not None, "PacketIn not received for non matching packet") |
| 765 | |
| 766 | |
| 767 | class ExactMatchPrio(base_tests.SimpleDataPlane): |
| 768 | |
| 769 | """Verify that Exact Match has highest priority """ |
| 770 | |
| 771 | def runTest(self): |
| 772 | |
| 773 | logging.info("Running Exact Match High Priority test") |
| 774 | |
| 775 | of_ports = config["port_map"].keys() |
| 776 | of_ports.sort() |
| 777 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 778 | |
| 779 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 780 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 781 | |
Rich Lane | ed13065 | 2012-12-31 17:35:33 -0800 | [diff] [blame] | 782 | egress_port=of_ports[2] |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 783 | no_ports=set(of_ports).difference([egress_port]) |
Rich Lane | ed13065 | 2012-12-31 17:35:33 -0800 | [diff] [blame] | 784 | yes_ports = egress_port |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 785 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 786 | logging.info("Inserting a flow with Exact Match (low priority)") |
| 787 | logging.info("Inserting an overlapping wildcarded flow (higher priority)") |
| 788 | logging.info("Sending packets matching both the flows ") |
| 789 | logging.info("Verifying matching packets implements the action specified in the exact match flow") |
| 790 | |
| 791 | #Insert two Overlapping Flows : Exact Match and Wildcard All. |
| 792 | (pkt,match) = exact_match_with_prio(self,of_ports,priority=10) |
| 793 | (pkt2,match2) = wildcard_all(self,of_ports,priority=20); |
| 794 | |
| 795 | #Sending packet matching both the flows , |
| 796 | self.dataplane.send(of_ports[0], str(pkt2)) |
| 797 | |
| 798 | #verify it implements the action specified in Exact Match Flow |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 799 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 800 | |
| 801 | |
| 802 | class WildcardMatchPrio(base_tests.SimpleDataPlane): |
| 803 | |
| 804 | """Verify that Wildcard Match with highest priority overrides the low priority WildcardMatch """ |
| 805 | |
| 806 | def runTest(self): |
| 807 | |
| 808 | logging.info("Running Wildcard Match High Priority test") |
| 809 | |
| 810 | of_ports = config["port_map"].keys() |
| 811 | of_ports.sort() |
| 812 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 813 | |
| 814 | #Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 815 | delete_all_flows(self.controller) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 816 | |
ShreyaPandita | efdff31 | 2012-11-21 13:35:34 -0500 | [diff] [blame] | 817 | egress_port=of_ports[1] |
| 818 | no_ports=set(of_ports).difference([egress_port]) |
| 819 | yes_ports = of_ports[1] |
| 820 | |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 821 | logging.info("Inserting two wildcarded flows with priorities ") |
| 822 | logging.info("Sending packets matching the flows") |
| 823 | logging.info("Verifying matching packets implements the action specified in the flow with higher priority") |
| 824 | |
| 825 | (pkt,match) = wildcard_all(self,of_ports,priority=20) |
| 826 | (pkt1,match1) = wildcard_all_except_ingress1(self,of_ports,priority=10) |
| 827 | |
| 828 | #Sending packet matching both the flows , verify it implements the action specified by Higher Priority flow |
| 829 | self.dataplane.send(of_ports[0], str(pkt1)) |
ShreyaPandita | 6fbff25 | 2012-11-13 16:56:48 -0500 | [diff] [blame] | 830 | receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self) |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |