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