blob: 62afda8b347a6a2755a51ea8071b310f8d24a8b5 [file] [log] [blame]
ShreyaPandita9306c772012-09-28 12:21:40 -04001
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
9import logging
10
11import unittest
12import random
Rich Laneb90a1c42012-10-05 09:16:05 -070013import time
ShreyaPandita9306c772012-09-28 12:21:40 -040014
Rich Lane477f4812012-10-04 22:49:00 -070015from oftest import config
ShreyaPandita9306c772012-09-28 12:21:40 -040016import oftest.controller as controller
17import oftest.cstruct as ofp
18import oftest.message as message
19import oftest.dataplane as dataplane
20import oftest.action as action
21import oftest.parse as parse
Rich Laneb90a1c42012-10-05 09:16:05 -070022import oftest.base_tests as base_tests
ShreyaPandita9306c772012-09-28 12:21:40 -040023
Rich Laneda3b5ad2012-10-03 09:05:32 -070024from oftest.testutils import *
ShreyaPandita9306c772012-09-28 12:21:40 -040025from time import sleep
26from FuncUtils import *
27
Rich Laneb90a1c42012-10-05 09:16:05 -070028class NoAction(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -040029
30 """NoActionDrop : no action added to flow , drops the packet."""
31
32 def runTest(self):
33
Rich Lane9a003812012-10-04 17:17:59 -070034 logging.info("Running No_Action test")
ShreyaPandita9306c772012-09-28 12:21:40 -040035
Rich Lane477f4812012-10-04 22:49:00 -070036 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -040037 of_ports.sort()
38 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
39
40 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -070041 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -040042 self.assertEqual(rv, 0, "Failed to delete all flows")
43
Rich Lane9a003812012-10-04 17:17:59 -070044 logging.info("Install a flow without action")
45 logging.info("Send packets matching that flow")
46 logging.info("Expecting switch to drop all packets")
ShreyaPandita9306c772012-09-28 12:21:40 -040047
48 # Insert a flow wildcard all without any action
49 pkt = simple_tcp_packet()
50 match = parse.packet_to_flow_match(pkt)
51 self.assertTrue(match is not None, "Could not generate flow match from pkt")
52 match.wildcards=ofp.OFPFW_ALL
53 match.in_port = of_ports[0]
54
55 msg = message.flow_mod()
56 msg.out_port = ofp.OFPP_NONE
57 msg.command = ofp.OFPFC_ADD
58 msg.buffer_id = 0xffffffff
59 msg.match = match
Rich Lane5c3151c2013-01-03 17:15:41 -080060 self.controller.message_send(msg)
ShreyaPanditab46f8522012-09-28 15:12:15 -040061 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
62
ShreyaPandita9306c772012-09-28 12:21:40 -040063 #Sending N packets matching the flow inserted
64 for pkt_cnt in range(5):
65 self.dataplane.send(of_ports[0],str(pkt))
66
67 #Verify packets not recieved on any of the dataplane ports
ShreyaPandita7b9ec982012-09-28 14:43:08 -040068 (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1,exp_pkt=pkt)
69 self.assertTrue(rcv_pkt is None,
ShreyaPanditad4a42c62012-09-28 15:35:27 -040070 "Packet received on port " + str(rcv_port))
ShreyaPandita9306c772012-09-28 12:21:40 -040071
72 #Verify packets not sent on control plane either
73 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=1)
74 self.assertTrue(response is None,
75 'Packets not received on control plane')
76
77
Rich Laneb90a1c42012-10-05 09:16:05 -070078class Announcement(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -040079
80 """Announcement : Get all supported actions by the switch.
81 Send OFPT_FEATURES_REQUEST to get features supported by sw."""
82
83 def runTest(self):
84
Rich Lane9a003812012-10-04 17:17:59 -070085 logging.info("Running Announcement test")
ShreyaPandita9306c772012-09-28 12:21:40 -040086
Rich Lane9a003812012-10-04 17:17:59 -070087 logging.info("Sending Features_Request")
88 logging.info("Expecting Features Reply with supported actions")
ShreyaPandita9306c772012-09-28 12:21:40 -040089
90 # Sending Features_Request
91 request = message.features_request()
92 (reply, pkt) = self.controller.transact(request)
93 self.assertTrue(reply is not None, "Failed to get any reply")
94 self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
95
96 supported_actions =[]
97 if(reply.actions &1<<ofp.OFPAT_OUTPUT):
98 supported_actions.append('OFPAT_OUTPUT')
99 if(reply.actions &1<<ofp.OFPAT_SET_VLAN_VID):
100 supported_actions.append('OFPAT_SET_VLAN_VID')
101 if(reply.actions &1<<ofp.OFPAT_SET_VLAN_PCP):
102 supported_actions.append('OFPAT_SET_VLAN_PCP')
103 if(reply.actions &1<<ofp.OFPAT_STRIP_VLAN):
104 supported_actions.append('OFPAT_STRIP_VLAN')
105 if(reply.actions &1<<ofp.OFPAT_SET_DL_SRC):
106 supported_actions.append('OFPAT_SET_DL_SRC')
107 if(reply.actions &1<<ofp.OFPAT_SET_DL_DST):
108 supported_actions.append('OFPAT_SET_NW_SRC')
109 if(reply.actions &1<<ofp.OFPAT_SET_NW_DST):
110 supported_actions.append('OFPAT_SET_NW_DST')
111 if(reply.actions &1<<ofp.OFPAT_SET_NW_TOS):
112 supported_actions.append('OFPAT_SET_NW_TOS')
113 if(reply.actions &1<<ofp.OFPAT_SET_TP_SRC):
114 supported_actions.append('OFPAT_SET_TP_SRC')
115 if(reply.actions &1<<ofp.OFPAT_SET_TP_DST):
116 supported_actions.append('OFPAT_SET_TP_DST')
117 if(reply.actions &1<<ofp.OFPAT_VENDOR):
118 supported_actions.append('OFPAT_VENDOR')
119 if(reply.actions &1<<ofp.OFPAT_ENQUEUE):
120 supported_actions.append('OFPAT_ENQUEUE')
121
Rich Lane9a003812012-10-04 17:17:59 -0700122 logging.info(supported_actions)
ShreyaPandita9306c772012-09-28 12:21:40 -0400123
124
Rich Laneb90a1c42012-10-05 09:16:05 -0700125class ForwardAll(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400126
127 """ForwardAll : Packet is sent to all dataplane ports
128 except ingress port when output action.port = OFPP_ALL"""
129
130 def runTest(self):
131
Rich Lane9a003812012-10-04 17:17:59 -0700132 logging.info("Running Forward_All test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400133
Rich Lane477f4812012-10-04 22:49:00 -0700134 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400135 of_ports.sort()
136 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
137
138 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700139 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400140 self.assertEqual(rv, 0, "Failed to delete all flows")
141
Rich Lane9a003812012-10-04 17:17:59 -0700142 logging.info("Insert a flow with output action port OFPP_ALL")
143 logging.info("Send packet matching the flow")
144 logging.info("Expecting packet on all dataplane ports except ingress_port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400145
146 #Create a packet
147 pkt = simple_tcp_packet()
148 match = parse.packet_to_flow_match(pkt)
149 act = action.action_output()
150
151 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700152 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400153 self.assertEqual(rv, 0, "Failed to delete all flows")
154 ingress_port=of_ports[0]
155 match.in_port = ingress_port
156
157 #Create a flow mod with action.port = OFPP_ALL
158 request = message.flow_mod()
159 request.match = match
160 request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
161 act.port = ofp.OFPP_ALL
162 request.actions.add(act)
163
Rich Lane9a003812012-10-04 17:17:59 -0700164 logging.info("Inserting flow")
Rich Lane5c3151c2013-01-03 17:15:41 -0800165 self.controller.message_send(request)
ShreyaPandita9306c772012-09-28 12:21:40 -0400166 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
167
168 #Send Packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700169 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400170 self.dataplane.send(ingress_port, str(pkt))
171
172 #Verifying packets recieved on expected dataplane ports
173 yes_ports = set(of_ports).difference([ingress_port])
174 receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
Rich Lane2014f9b2012-10-05 15:29:40 -0700175 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400176
177
Rich Laneb90a1c42012-10-05 09:16:05 -0700178class ForwardController(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400179
180 """ForwardController : Packet is sent to controller
181 output.port = OFPP_CONTROLLER"""
182
183 def runTest(self):
184
Rich Lane9a003812012-10-04 17:17:59 -0700185 logging.info("Running Forward_Controller test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400186
Rich Lane477f4812012-10-04 22:49:00 -0700187 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400188 of_ports.sort()
189 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
190
191 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700192 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400193 self.assertEqual(rv, 0, "Failed to delete all flows")
194
Rich Lane9a003812012-10-04 17:17:59 -0700195 logging.info("Insert a flow with output action port OFPP_CONTROLLER")
196 logging.info("Send packet matching the flow")
197 logging.info("Expecting packet on the control plane")
ShreyaPandita9306c772012-09-28 12:21:40 -0400198
199 #Create packet
200 pkt = simple_tcp_packet()
201 match = parse.packet_to_flow_match(pkt)
202 act = action.action_output()
203
204 for ingress_port in of_ports:
205 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700206 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400207 self.assertEqual(rv, 0, "Failed to delete all flows")
208
209 match.in_port = ingress_port
210
211 #Create a flow mod message
212 request = message.flow_mod()
213 request.match = match
214 act.port = ofp.OFPP_CONTROLLER
215 request.actions.add(act)
216
Rich Lane9a003812012-10-04 17:17:59 -0700217 logging.info("Inserting flow")
Rich Lane5c3151c2013-01-03 17:15:41 -0800218 self.controller.message_send(request)
ShreyaPandita9306c772012-09-28 12:21:40 -0400219 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
220
221 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700222 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400223 self.dataplane.send(ingress_port, str(pkt))
224
225 #Verifying packet recieved on the control plane port
226 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=10)
227 self.assertTrue(response is not None,
228 'Packet in message not received by controller')
229
230
231
Rich Laneb90a1c42012-10-05 09:16:05 -0700232class ForwardLocal(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400233
234 """ForwardLocal : Packet is sent to OFPP_LOCAL port .
235 TBD : To verify packet recieved in the local networking stack of switch"""
236
237 def runTest(self):
238
Rich Lane9a003812012-10-04 17:17:59 -0700239 logging.info("Running Forward_Local test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400240
Rich Lane477f4812012-10-04 22:49:00 -0700241 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400242 of_ports.sort()
243 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
244
245 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700246 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400247 self.assertEqual(rv, 0, "Failed to delete all flows")
248
Rich Lane9a003812012-10-04 17:17:59 -0700249 logging.info("Insert a flow with output action port OFPP_LOCAL")
250 logging.info("Send packet matching the flow")
251 logging.info("Expecting packet in the local networking stack of switch")
ShreyaPandita9306c772012-09-28 12:21:40 -0400252
253 #Clear switch state
254 pkt = simple_tcp_packet()
255 match = parse.packet_to_flow_match(pkt)
256 act = action.action_output()
257
258 for ingress_port in of_ports:
259 #Delete the flows
Rich Lane9a003812012-10-04 17:17:59 -0700260 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400261 self.assertEqual(rv, 0, "Failed to delete all flows")
262
263 match.in_port = ingress_port
264 #Create flow mod message
265 request = message.flow_mod()
266 request.match = match
267 act.port = ofp.OFPP_LOCAL
268 request.actions.add(act)
269
Rich Lane9a003812012-10-04 17:17:59 -0700270 logging.info("Inserting flow")
Rich Lane5c3151c2013-01-03 17:15:41 -0800271 self.controller.message_send(request)
ShreyaPandita9306c772012-09-28 12:21:40 -0400272 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
273
274 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700275 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400276 self.dataplane.send(ingress_port, str(pkt))
277
278 #TBD: Verification of packets being recieved.
279
280
Rich Laneb90a1c42012-10-05 09:16:05 -0700281class ForwardFlood(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400282
283 """Forward:Flood : Packet is sent to all dataplane ports
284 except ingress port when output action.port = OFPP_FLOOD
285 TBD : Verification---Incase of STP being implemented, flood the packet along the minimum spanning tree,
286 not including the incoming interface. """
287
288 def runTest(self):
289
Rich Lane9a003812012-10-04 17:17:59 -0700290 logging.info("Running Forward_Flood test")
Rich Lane477f4812012-10-04 22:49:00 -0700291 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400292 of_ports.sort()
293 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
294
295 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700296 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400297 self.assertEqual(rv, 0, "Failed to delete all flows")
298
Rich Lane9a003812012-10-04 17:17:59 -0700299 logging.info("Insert a flow with output action port OFPP_FORWARD")
300 logging.info("Send packet matching the flow")
301 logging.info("Expecting packet on all the ports except the input port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400302
303 #Create a packet
304 pkt = simple_tcp_packet()
305 match = parse.packet_to_flow_match(pkt)
306 act = action.action_output()
307
308 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700309 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400310 self.assertEqual(rv, 0, "Failed to delete all flows")
311 ingress_port=of_ports[0]
312 match.in_port = ingress_port
313
314 #Create a flow mod with action.port = OFPP_ALL
315 request = message.flow_mod()
316 request.match = match
317 request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
318 act.port = ofp.OFPP_FLOOD
319 request.actions.add(act)
320
Rich Lane9a003812012-10-04 17:17:59 -0700321 logging.info("Inserting flow")
Rich Lane5c3151c2013-01-03 17:15:41 -0800322 self.controller.message_send(request)
ShreyaPandita9306c772012-09-28 12:21:40 -0400323 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
324
325 #Send Packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700326 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400327 self.dataplane.send(ingress_port, str(pkt))
328
329 #Verifying packets recieved on expected dataplane ports
330 yes_ports = set(of_ports).difference([ingress_port])
331 receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
Rich Lane2014f9b2012-10-05 15:29:40 -0700332 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400333
Rich Laneb90a1c42012-10-05 09:16:05 -0700334class ForwardInport(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400335
336 """ ForwardInPort : Packet sent to virtual port IN_PORT
337 If the output.port = OFPP.INPORT then the packet is sent to the input port itself"""
338
339 def runTest(self):
340
Rich Lane9a003812012-10-04 17:17:59 -0700341 logging.info("Running Forward_Inport test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400342
Rich Lane477f4812012-10-04 22:49:00 -0700343 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400344 of_ports.sort()
345 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
346
347 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700348 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400349 self.assertEqual(rv, 0, "Failed to delete all flows")
350
Rich Lane9a003812012-10-04 17:17:59 -0700351 logging.info("Insert a flow with output action port OFPP_INPORT")
352 logging.info("Send packet matching the flow")
353 logging.info("Expecting packet on the input port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400354
355 #Create a packet
356 pkt = simple_tcp_packet()
357 match = parse.packet_to_flow_match(pkt)
358 act = action.action_output()
359
360 #Delete the flows
Rich Lane9a003812012-10-04 17:17:59 -0700361 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400362 self.assertEqual(rv, 0, "Failed to delete all flows")
363 ingress_port=of_ports[0]
364 match.in_port = ingress_port
365
366 # Create a flow mod message
367 request = message.flow_mod()
368 request.match = match
369 act.port = ofp.OFPP_IN_PORT
370
371 request.actions.add(act)
Rich Lane9a003812012-10-04 17:17:59 -0700372 logging.info("Inserting flow")
Rich Lane5c3151c2013-01-03 17:15:41 -0800373 self.controller.message_send(request)
ShreyaPandita9306c772012-09-28 12:21:40 -0400374 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
375
376 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700377 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400378 self.dataplane.send(ingress_port, str(pkt))
379 yes_ports = [ingress_port]
380
381 #Verfying packet recieved on expected dataplane ports
382 receive_pkt_check(self.dataplane, pkt, yes_ports,set(of_ports).difference([ingress_port]),
Rich Lane2014f9b2012-10-05 15:29:40 -0700383 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400384
Rich Laneb90a1c42012-10-05 09:16:05 -0700385class ForwardTable(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400386
387 """ForwardTable : Perform actions in flow table. Only for packet-out messages.
388 If the output action.port in the packetout message = OFP.TABLE , then
389 the packet implements the action specified in the matching flow of the FLOW-TABLE"""
390
391 def runTest(self):
392
Rich Lane9a003812012-10-04 17:17:59 -0700393 logging.info("Running Forward_Table test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400394
Rich Lane477f4812012-10-04 22:49:00 -0700395 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400396 of_ports.sort()
397 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
398
399 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700400 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400401 self.assertEqual(rv, 0, "Failed to delete all flows")
402
Rich Lane9a003812012-10-04 17:17:59 -0700403 logging.info("Insert a flow F with output action port set to some egress_port")
404 logging.info("Send packet out message (matching flow F) with action.port = OFP.TABLE")
405 logging.info("Expecting packet on the egress_port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400406
407 #Insert a all wildcarded flow
ShreyaPandita8dab4662012-11-02 13:40:14 -0400408 (pkt,match) = wildcard_all(self,of_ports)
ShreyaPandita9306c772012-09-28 12:21:40 -0400409
410 #Create a packet out message
411 pkt_out =message.packet_out();
412 pkt_out.data = str(pkt)
413 pkt_out.in_port = of_ports[0]
414 act = action.action_output()
415 act.port = ofp.OFPP_TABLE
416 pkt_out.actions.add(act)
Rich Lane5c3151c2013-01-03 17:15:41 -0800417 self.controller.message_send(pkt_out)
ShreyaPandita9306c772012-09-28 12:21:40 -0400418
419 #Verifying packet out message recieved on the expected dataplane port.
420 (of_port, pkt, pkt_time) = self.dataplane.poll(port_number=of_ports[1],
421 exp_pkt=pkt,timeout=3)
422 self.assertTrue(pkt is not None, 'Packet not received')
423
424
Rich Laneb90a1c42012-10-05 09:16:05 -0700425class AddVlanTag(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400426
427 """AddVlanTag : Adds VLAN Tag to untagged packet."""
428
429 def runTest(self):
430
Rich Lane9a003812012-10-04 17:17:59 -0700431 logging.info("Running Add_vlan_tag test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400432
Rich Lane477f4812012-10-04 22:49:00 -0700433 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400434 of_ports.sort()
435 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
436
437 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700438 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400439 self.assertEqual(rv, 0, "Failed to delete all flows")
440
Rich Lane9a003812012-10-04 17:17:59 -0700441 logging.info("Verify if switch supports the action -- set vlan id, if not skip the test")
442 logging.info("Insert a flow with set vid action")
443 logging.info("Send packet matching the flow , verify recieved packet has vid set")
ShreyaPandita9306c772012-09-28 12:21:40 -0400444
445 #Verify set_vlan_id is a supported action
446 sup_acts = sw_supported_actions(self)
447 if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
448 skip_message_emit(self, "Add VLAN tag test skipped")
449 return
450
451 #Create packet to be sent and an expected packet with vid set
452 new_vid = 2
453 len_wo_vid = 100
454 len_w_vid = 104
455 pkt = simple_tcp_packet(pktlen=len_wo_vid)
456 exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
457 dl_vlan=new_vid,dl_vlan_pcp=0)
458 vid_act = action.action_set_vlan_vid()
459 vid_act.vlan_vid = new_vid
460
461 #Insert flow with action -- set vid , Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700462 flow_match_test(self, config["port_map"], pkt=pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400463 exp_pkt=exp_pkt, action_list=[vid_act])
464
Rich Laneb90a1c42012-10-05 09:16:05 -0700465class ModifyVlanTag(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400466
467 """ModifyVlanTag : Modifies VLAN Tag to tagged packet."""
468
469 def runTest(self):
470
Rich Lane9a003812012-10-04 17:17:59 -0700471 logging.info("Running Modify_Vlan_Tag test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400472
Rich Lane477f4812012-10-04 22:49:00 -0700473 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400474 of_ports.sort()
475 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
476
477 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700478 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400479 self.assertEqual(rv, 0, "Failed to delete all flows")
480
Rich Lane9a003812012-10-04 17:17:59 -0700481 logging.info("Verify if switch supports the action -- modify vlan id, if not skip the test")
482 logging.info("Insert a flow with action --set vid ")
483 logging.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten")
ShreyaPandita9306c772012-09-28 12:21:40 -0400484
485 #Verify set_vlan_id is a supported action
486 sup_acts = sw_supported_actions(self)
487 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
488 skip_message_emit(self, "Modify VLAN tag test skipped")
489 return
490
491 #Create a tagged packet with old_vid to be sent, and expected packet with new_vid
492 old_vid = 2
493 new_vid = 3
494 pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
495 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=new_vid)
496 vid_act = action.action_set_vlan_vid()
497 vid_act.vlan_vid = new_vid
498
499 #Insert flow with action -- set vid , Send packet matching the flow.Verify recieved packet is expected packet.
Rich Lane477f4812012-10-04 22:49:00 -0700500 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400501 action_list=[vid_act])
502
Rich Laneb90a1c42012-10-05 09:16:05 -0700503class VlanPrio1(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400504
505 """AddVlanPrioUntaggedPkt : Add VLAN priority to untagged packet."""
506
507 def runTest(self):
508
Rich Lane9a003812012-10-04 17:17:59 -0700509 logging.info("Running vlan_Prio_1 test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400510
Rich Lane477f4812012-10-04 22:49:00 -0700511 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400512 of_ports.sort()
513 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
514
515 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700516 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400517 self.assertEqual(rv, 0, "Failed to delete all flows")
518
Rich Lane9a003812012-10-04 17:17:59 -0700519 logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
520 logging.info("Insert a flow with action -- set vlan priority ")
521 logging.info("Send untagged packet matching the flow , verify recieved packet has specified VLAN priority and has vid set tO 0 ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400522
523 #Verify set_vlan_priority is a supported action
524 sup_acts = sw_supported_actions(self)
525 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
526 skip_message_emit(self, "Set VLAN priority test skipped")
527 return
528
529 #Create a untagged packet to be sent and an expected packet with vid = 0 , vlan_priority set.
530 vlan_id = 0
Rich Lane123928c2012-10-04 21:28:53 -0700531 vlan_pcp = 1
532 pkt = simple_tcp_packet(pktlen=60)
533 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vlan_id,dl_vlan_pcp=vlan_pcp, pktlen=64)
534 act = action.action_set_vlan_pcp()
535 act.vlan_pcp = vlan_pcp
ShreyaPandita9306c772012-09-28 12:21:40 -0400536
537 #Insert flow with action -- set vLAN priority, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700538 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400539 action_list=[act])
540
541
Rich Laneb90a1c42012-10-05 09:16:05 -0700542class VlanPrio2(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400543
544 """ModifyVlanPrio : Modify VLAN priority to tagged packet."""
545
546 def runTest(self):
547
Rich Lane9a003812012-10-04 17:17:59 -0700548 logging.info("Running Vlan_Prio_2 test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400549
Rich Lane477f4812012-10-04 22:49:00 -0700550 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400551 of_ports.sort()
552 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
553
554 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700555 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400556 self.assertEqual(rv, 0, "Failed to delete all flows")
557
Rich Lane9a003812012-10-04 17:17:59 -0700558 logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
559 logging.info("Insert a flow with action -- set vlan priority ")
560 logging.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten")
ShreyaPandita9306c772012-09-28 12:21:40 -0400561
562 #Verify set_vlan_priority is a supported action
563 sup_acts = sw_supported_actions(self,"true")
564 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
565 skip_message_emit(self, "modify_vlan_prio test skipped")
566 return
567
568 #Create a tagged packet , and an expected packet with vlan_priority set to specified value
569 vid = 123
570 old_vlan_pcp = 2
571 new_vlan_pcp = 3
572 pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=old_vlan_pcp)
573 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=new_vlan_pcp)
574 vid_act = action.action_set_vlan_pcp()
575 vid_act.vlan_pcp = new_vlan_pcp
576
577 #Insert flow with action -- set vLAN priority, Send tagged packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700578 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400579 action_list=[vid_act])
580
581
Rich Laneb90a1c42012-10-05 09:16:05 -0700582class ModifyL2Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400583
584 """ModifyL2Src :Modify the source MAC address"""
585
586 def runTest(self):
587
Rich Lane9a003812012-10-04 17:17:59 -0700588 logging.info("Running Modify_L2_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400589
Rich Lane477f4812012-10-04 22:49:00 -0700590 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400591 of_ports.sort()
592 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
593
594 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700595 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400596 self.assertEqual(rv, 0, "Failed to delete all flows")
597
Rich Lane9a003812012-10-04 17:17:59 -0700598 logging.info("Verify if switch supports the action -- modify_l2_src, if not skip the test")
599 logging.info("Insert a flow with action -- set etherent src address")
600 logging.info("Send packet matching the flow, verify recieved packet src address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400601
602 #Verify set_dl_src is a supported action
603 sup_acts = sw_supported_actions(self,use_cache="true")
604 if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
605 skip_message_emit(self, "modify_l2_src test skipped")
606 return
607
608 #Create packet to be sent and expected packet with dl_src set to specified value
609 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
610 check_test_params=True)
611
612 #Insert flow with action -- set src address, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700613 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400614 action_list=acts, max_test=2)
615
616
Rich Laneb90a1c42012-10-05 09:16:05 -0700617class ModifyL2Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400618
619 """ModifyL2SDSt :Modify the dest MAC address"""
620
621 def runTest(self):
622
Rich Lane9a003812012-10-04 17:17:59 -0700623 logging.info("Running Modify_L2_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400624
Rich Lane477f4812012-10-04 22:49:00 -0700625 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400626 of_ports.sort()
627 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
628
629 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700630 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400631 self.assertEqual(rv, 0, "Failed to delete all flows")
632
Rich Lane9a003812012-10-04 17:17:59 -0700633 logging.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test")
634 logging.info("Insert a flow with action -- set etherent dst address ")
635 logging.info("Send packet matching the flow, verify recieved packet dst address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400636
637 #Verify set_dl_dst is a supported action
638 sup_acts = sw_supported_actions(self)
639 if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
640 skip_message_emit(self, "modify_l2_dst test skipped")
641 return
642
643 #Create packet to be sent and expected packet with dl_src set to specified value
644 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
645 check_test_params=True)
646
647 #Insert flow with action -- set dst address, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700648 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400649 action_list=acts, max_test=2)
650
Rich Laneb90a1c42012-10-05 09:16:05 -0700651class ModifyL3Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400652
653 """ModifyL3Src : Modify the source IP address of an IP packet """
654
655 def runTest(self):
656
Rich Lane9a003812012-10-04 17:17:59 -0700657 logging.info("Running Modify_L3_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400658
Rich Lane477f4812012-10-04 22:49:00 -0700659 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400660 of_ports.sort()
661 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
662
663 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700664 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400665 self.assertEqual(rv, 0, "Failed to delete all flows")
666
Rich Lane9a003812012-10-04 17:17:59 -0700667 logging.info("Verify if switch supports the action -- modify_l3_src, if not skip the test")
668 logging.info("Insert a flow with action -- set network src address ")
669 logging.info("Send packet matching the flow, verify recieved packet network src address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400670
671 #Verify set_nw_src is a supported action
672 sup_acts = sw_supported_actions(self)
673 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC):
674 skip_message_emit(self, "modify_l3_src test")
675 return
676
677 #Create packet to be sent and expected packet with nw_src set to specified value
678 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'],
679 check_test_params=True)
680
681 #Insert flow with action -- set nw src address, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700682 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400683 action_list=acts, max_test=2)
684
Rich Laneb90a1c42012-10-05 09:16:05 -0700685class ModifyL3Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400686
687 """ModifyL3Dst :Modify the dest IP address of an IP packet"""
688
689 def runTest(self):
690
Rich Lane9a003812012-10-04 17:17:59 -0700691 logging.info("Running Modify_L3_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400692
Rich Lane477f4812012-10-04 22:49:00 -0700693 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400694 of_ports.sort()
695 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
696
697 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700698 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400699 self.assertEqual(rv, 0, "Failed to delete all flows")
700
Rich Lane9a003812012-10-04 17:17:59 -0700701 logging.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test")
702 logging.info("Insert a flow with action -- set network dst address ")
703 logging.info("Send packet matching the flow, verify recieved packet network dst address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400704
705 #Verify set_nw_dst is a supported action
706 sup_acts = sw_supported_actions(self,use_cache="true")
707 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST):
708 skip_message_emit(self, "modify_l3_dst test skipped")
709 return
710
711 #Create packet to be sent and expected packet with nw_dst set to specified value
712 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'],
713 check_test_params=True)
714
715 #Insert flow with action -- set nw dst address, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700716 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400717 action_list=acts, max_test=2)
718
719
Rich Laneb90a1c42012-10-05 09:16:05 -0700720class ModifyL4Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400721
722 """ModifyL4Src : Modify the source TCP port of a TCP packet"""
723
724 def runTest(self):
725
Rich Lane9a003812012-10-04 17:17:59 -0700726 logging.info("Running Modify_L4_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400727
Rich Lane477f4812012-10-04 22:49:00 -0700728 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400729 of_ports.sort()
730 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
731
732 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700733 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400734 self.assertEqual(rv, 0, "Failed to delete all flows")
735
Rich Lane9a003812012-10-04 17:17:59 -0700736 logging.info("Verify if switch supports the action -- modify_l4_src, if not skip the test")
737 logging.info("Insert a flow with action -- set src tcp port")
738 logging.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400739
740 #Verify set_tp_src is a supported action
741 sup_acts = sw_supported_actions(self,use_cache="true")
742 if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC):
743 skip_message_emit(self, "modify_l4_src test skipped")
744 return
745
746 #Create packet to be sent and expected packet with tcp_src set to specified value
747 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_sport'],
748 check_test_params=True)
749
750 #Insert flow with action -- set tcp src port, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700751 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400752 action_list=acts, max_test=2)
753
Rich Laneb90a1c42012-10-05 09:16:05 -0700754class ModifyL4Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400755
756 """ ModifyL4Dst: Modify the dest TCP port of a TCP packet """
757
758 def runTest(self):
759
Rich Lane9a003812012-10-04 17:17:59 -0700760 logging.info("Running Modify_L4_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400761
Rich Lane477f4812012-10-04 22:49:00 -0700762 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400763 of_ports.sort()
764 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
765
766 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700767 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400768 self.assertEqual(rv, 0, "Failed to delete all flows")
769
Rich Lane9a003812012-10-04 17:17:59 -0700770 logging.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test")
771 logging.info("Insert a flow with action -- set dst tcp port")
772 logging.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400773
774 #Verify set_tp_dst is a supported action
775 sup_acts = sw_supported_actions(self,use_cache="true")
776 if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST):
777 skip_message_emit(self, "ModifyL4Dst test")
778 return
779
780 #Create packet to be sent and expected packet with tcp_dst set to specified value
781 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_dport'],
782 check_test_params=True)
783
784 #Insert flow with action -- set tcp dst port, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700785 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400786 action_list=acts, max_test=2)
787
Rich Laneb90a1c42012-10-05 09:16:05 -0700788class ModifyTos(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400789
790 """ModifyTOS :Modify the IP type of service of an IP packet"""
791
792 def runTest(self):
793
Rich Lane9a003812012-10-04 17:17:59 -0700794 logging.info("Running Modify_Tos test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400795
Rich Lane477f4812012-10-04 22:49:00 -0700796 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400797 of_ports.sort()
798 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
799
800 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700801 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400802 self.assertEqual(rv, 0, "Failed to delete all flows")
803
Rich Lane9a003812012-10-04 17:17:59 -0700804 logging.info("Verify if switch supports the action -- modify_tos, if not skip the test")
805 logging.info("Insert a flow with action -- set type of service ")
806 logging.info("Send packet matching the flow, verify recieved packet has TOS rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400807
808 #Verify set_tos is a supported action
809 sup_acts = sw_supported_actions(self,use_cache="true")
810 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
811 skip_message_emit(self, "ModifyTOS test")
812 return
813
814 #Create packet to be sent and expected packet with TOS set to specified value
815 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_tos'],
816 check_test_params=True)
817
818 #Insert flow with action -- set TOS, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700819 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400820 action_list=acts, max_test=2, egr_count=-1)