blob: 590a91c6d4065993cdc0b8538b80c59073042dd9 [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
60 rv = self.controller.message_send(msg)
61 self.assertTrue(rv != -1, "Error installing flow mod")
ShreyaPanditab46f8522012-09-28 15:12:15 -040062 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
63
ShreyaPandita9306c772012-09-28 12:21:40 -040064 #Sending N packets matching the flow inserted
65 for pkt_cnt in range(5):
66 self.dataplane.send(of_ports[0],str(pkt))
67
68 #Verify packets not recieved on any of the dataplane ports
ShreyaPandita7b9ec982012-09-28 14:43:08 -040069 (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1,exp_pkt=pkt)
70 self.assertTrue(rcv_pkt is None,
ShreyaPanditad4a42c62012-09-28 15:35:27 -040071 "Packet received on port " + str(rcv_port))
ShreyaPandita9306c772012-09-28 12:21:40 -040072
73 #Verify packets not sent on control plane either
74 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=1)
75 self.assertTrue(response is None,
76 'Packets not received on control plane')
77
78
Rich Laneb90a1c42012-10-05 09:16:05 -070079class Announcement(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -040080
81 """Announcement : Get all supported actions by the switch.
82 Send OFPT_FEATURES_REQUEST to get features supported by sw."""
83
84 def runTest(self):
85
Rich Lane9a003812012-10-04 17:17:59 -070086 logging.info("Running Announcement test")
ShreyaPandita9306c772012-09-28 12:21:40 -040087
Rich Lane9a003812012-10-04 17:17:59 -070088 logging.info("Sending Features_Request")
89 logging.info("Expecting Features Reply with supported actions")
ShreyaPandita9306c772012-09-28 12:21:40 -040090
91 # Sending Features_Request
92 request = message.features_request()
93 (reply, pkt) = self.controller.transact(request)
94 self.assertTrue(reply is not None, "Failed to get any reply")
95 self.assertEqual(reply.header.type, ofp.OFPT_FEATURES_REPLY,'Response is not Features_reply')
96
97 supported_actions =[]
98 if(reply.actions &1<<ofp.OFPAT_OUTPUT):
99 supported_actions.append('OFPAT_OUTPUT')
100 if(reply.actions &1<<ofp.OFPAT_SET_VLAN_VID):
101 supported_actions.append('OFPAT_SET_VLAN_VID')
102 if(reply.actions &1<<ofp.OFPAT_SET_VLAN_PCP):
103 supported_actions.append('OFPAT_SET_VLAN_PCP')
104 if(reply.actions &1<<ofp.OFPAT_STRIP_VLAN):
105 supported_actions.append('OFPAT_STRIP_VLAN')
106 if(reply.actions &1<<ofp.OFPAT_SET_DL_SRC):
107 supported_actions.append('OFPAT_SET_DL_SRC')
108 if(reply.actions &1<<ofp.OFPAT_SET_DL_DST):
109 supported_actions.append('OFPAT_SET_NW_SRC')
110 if(reply.actions &1<<ofp.OFPAT_SET_NW_DST):
111 supported_actions.append('OFPAT_SET_NW_DST')
112 if(reply.actions &1<<ofp.OFPAT_SET_NW_TOS):
113 supported_actions.append('OFPAT_SET_NW_TOS')
114 if(reply.actions &1<<ofp.OFPAT_SET_TP_SRC):
115 supported_actions.append('OFPAT_SET_TP_SRC')
116 if(reply.actions &1<<ofp.OFPAT_SET_TP_DST):
117 supported_actions.append('OFPAT_SET_TP_DST')
118 if(reply.actions &1<<ofp.OFPAT_VENDOR):
119 supported_actions.append('OFPAT_VENDOR')
120 if(reply.actions &1<<ofp.OFPAT_ENQUEUE):
121 supported_actions.append('OFPAT_ENQUEUE')
122
Rich Lane9a003812012-10-04 17:17:59 -0700123 logging.info(supported_actions)
ShreyaPandita9306c772012-09-28 12:21:40 -0400124
125
Rich Laneb90a1c42012-10-05 09:16:05 -0700126class ForwardAll(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400127
128 """ForwardAll : Packet is sent to all dataplane ports
129 except ingress port when output action.port = OFPP_ALL"""
130
131 def runTest(self):
132
Rich Lane9a003812012-10-04 17:17:59 -0700133 logging.info("Running Forward_All test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400134
Rich Lane477f4812012-10-04 22:49:00 -0700135 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400136 of_ports.sort()
137 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
138
139 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700140 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400141 self.assertEqual(rv, 0, "Failed to delete all flows")
142
Rich Lane9a003812012-10-04 17:17:59 -0700143 logging.info("Insert a flow with output action port OFPP_ALL")
144 logging.info("Send packet matching the flow")
145 logging.info("Expecting packet on all dataplane ports except ingress_port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400146
147 #Create a packet
148 pkt = simple_tcp_packet()
149 match = parse.packet_to_flow_match(pkt)
150 act = action.action_output()
151
152 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700153 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400154 self.assertEqual(rv, 0, "Failed to delete all flows")
155 ingress_port=of_ports[0]
156 match.in_port = ingress_port
157
158 #Create a flow mod with action.port = OFPP_ALL
159 request = message.flow_mod()
160 request.match = match
161 request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
162 act.port = ofp.OFPP_ALL
163 request.actions.add(act)
164
Rich Lane9a003812012-10-04 17:17:59 -0700165 logging.info("Inserting flow")
ShreyaPandita9306c772012-09-28 12:21:40 -0400166 rv = self.controller.message_send(request)
167 self.assertTrue(rv != -1, "Error installing flow mod")
168 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
169
170 #Send Packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700171 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400172 self.dataplane.send(ingress_port, str(pkt))
173
174 #Verifying packets recieved on expected dataplane ports
175 yes_ports = set(of_ports).difference([ingress_port])
176 receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
Rich Lane2014f9b2012-10-05 15:29:40 -0700177 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400178
179
Rich Laneb90a1c42012-10-05 09:16:05 -0700180class ForwardController(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400181
182 """ForwardController : Packet is sent to controller
183 output.port = OFPP_CONTROLLER"""
184
185 def runTest(self):
186
Rich Lane9a003812012-10-04 17:17:59 -0700187 logging.info("Running Forward_Controller test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400188
Rich Lane477f4812012-10-04 22:49:00 -0700189 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400190 of_ports.sort()
191 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
192
193 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700194 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400195 self.assertEqual(rv, 0, "Failed to delete all flows")
196
Rich Lane9a003812012-10-04 17:17:59 -0700197 logging.info("Insert a flow with output action port OFPP_CONTROLLER")
198 logging.info("Send packet matching the flow")
199 logging.info("Expecting packet on the control plane")
ShreyaPandita9306c772012-09-28 12:21:40 -0400200
201 #Create packet
202 pkt = simple_tcp_packet()
203 match = parse.packet_to_flow_match(pkt)
204 act = action.action_output()
205
206 for ingress_port in of_ports:
207 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700208 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400209 self.assertEqual(rv, 0, "Failed to delete all flows")
210
211 match.in_port = ingress_port
212
213 #Create a flow mod message
214 request = message.flow_mod()
215 request.match = match
216 act.port = ofp.OFPP_CONTROLLER
217 request.actions.add(act)
218
Rich Lane9a003812012-10-04 17:17:59 -0700219 logging.info("Inserting flow")
ShreyaPandita9306c772012-09-28 12:21:40 -0400220 rv = self.controller.message_send(request)
221 self.assertTrue(rv != -1, "Error installing flow mod")
222 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
223
224 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700225 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400226 self.dataplane.send(ingress_port, str(pkt))
227
228 #Verifying packet recieved on the control plane port
229 (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, timeout=10)
230 self.assertTrue(response is not None,
231 'Packet in message not received by controller')
232
233
234
Rich Laneb90a1c42012-10-05 09:16:05 -0700235class ForwardLocal(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400236
237 """ForwardLocal : Packet is sent to OFPP_LOCAL port .
238 TBD : To verify packet recieved in the local networking stack of switch"""
239
240 def runTest(self):
241
Rich Lane9a003812012-10-04 17:17:59 -0700242 logging.info("Running Forward_Local test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400243
Rich Lane477f4812012-10-04 22:49:00 -0700244 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400245 of_ports.sort()
246 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
247
248 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700249 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400250 self.assertEqual(rv, 0, "Failed to delete all flows")
251
Rich Lane9a003812012-10-04 17:17:59 -0700252 logging.info("Insert a flow with output action port OFPP_LOCAL")
253 logging.info("Send packet matching the flow")
254 logging.info("Expecting packet in the local networking stack of switch")
ShreyaPandita9306c772012-09-28 12:21:40 -0400255
256 #Clear switch state
257 pkt = simple_tcp_packet()
258 match = parse.packet_to_flow_match(pkt)
259 act = action.action_output()
260
261 for ingress_port in of_ports:
262 #Delete the flows
Rich Lane9a003812012-10-04 17:17:59 -0700263 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400264 self.assertEqual(rv, 0, "Failed to delete all flows")
265
266 match.in_port = ingress_port
267 #Create flow mod message
268 request = message.flow_mod()
269 request.match = match
270 act.port = ofp.OFPP_LOCAL
271 request.actions.add(act)
272
Rich Lane9a003812012-10-04 17:17:59 -0700273 logging.info("Inserting flow")
ShreyaPandita9306c772012-09-28 12:21:40 -0400274 rv = self.controller.message_send(request)
275 self.assertTrue(rv != -1, "Error installing flow mod")
276 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
277
278 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700279 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400280 self.dataplane.send(ingress_port, str(pkt))
281
282 #TBD: Verification of packets being recieved.
283
284
Rich Laneb90a1c42012-10-05 09:16:05 -0700285class ForwardFlood(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400286
287 """Forward:Flood : Packet is sent to all dataplane ports
288 except ingress port when output action.port = OFPP_FLOOD
289 TBD : Verification---Incase of STP being implemented, flood the packet along the minimum spanning tree,
290 not including the incoming interface. """
291
292 def runTest(self):
293
Rich Lane9a003812012-10-04 17:17:59 -0700294 logging.info("Running Forward_Flood test")
Rich Lane477f4812012-10-04 22:49:00 -0700295 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400296 of_ports.sort()
297 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
298
299 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700300 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400301 self.assertEqual(rv, 0, "Failed to delete all flows")
302
Rich Lane9a003812012-10-04 17:17:59 -0700303 logging.info("Insert a flow with output action port OFPP_FORWARD")
304 logging.info("Send packet matching the flow")
305 logging.info("Expecting packet on all the ports except the input port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400306
307 #Create a packet
308 pkt = simple_tcp_packet()
309 match = parse.packet_to_flow_match(pkt)
310 act = action.action_output()
311
312 #Delete all flows
Rich Lane9a003812012-10-04 17:17:59 -0700313 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400314 self.assertEqual(rv, 0, "Failed to delete all flows")
315 ingress_port=of_ports[0]
316 match.in_port = ingress_port
317
318 #Create a flow mod with action.port = OFPP_ALL
319 request = message.flow_mod()
320 request.match = match
321 request.match.wildcards = ofp.OFPFW_ALL&~ofp.OFPFW_IN_PORT
322 act.port = ofp.OFPP_FLOOD
323 request.actions.add(act)
324
Rich Lane9a003812012-10-04 17:17:59 -0700325 logging.info("Inserting flow")
ShreyaPandita9306c772012-09-28 12:21:40 -0400326 rv = self.controller.message_send(request)
327 self.assertTrue(rv != -1, "Error installing flow mod")
328 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
329
330 #Send Packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700331 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400332 self.dataplane.send(ingress_port, str(pkt))
333
334 #Verifying packets recieved on expected dataplane ports
335 yes_ports = set(of_ports).difference([ingress_port])
336 receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
Rich Lane2014f9b2012-10-05 15:29:40 -0700337 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400338
Rich Laneb90a1c42012-10-05 09:16:05 -0700339class ForwardInport(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400340
341 """ ForwardInPort : Packet sent to virtual port IN_PORT
342 If the output.port = OFPP.INPORT then the packet is sent to the input port itself"""
343
344 def runTest(self):
345
Rich Lane9a003812012-10-04 17:17:59 -0700346 logging.info("Running Forward_Inport test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400347
Rich Lane477f4812012-10-04 22:49:00 -0700348 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400349 of_ports.sort()
350 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
351
352 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700353 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400354 self.assertEqual(rv, 0, "Failed to delete all flows")
355
Rich Lane9a003812012-10-04 17:17:59 -0700356 logging.info("Insert a flow with output action port OFPP_INPORT")
357 logging.info("Send packet matching the flow")
358 logging.info("Expecting packet on the input port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400359
360 #Create a packet
361 pkt = simple_tcp_packet()
362 match = parse.packet_to_flow_match(pkt)
363 act = action.action_output()
364
365 #Delete the flows
Rich Lane9a003812012-10-04 17:17:59 -0700366 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400367 self.assertEqual(rv, 0, "Failed to delete all flows")
368 ingress_port=of_ports[0]
369 match.in_port = ingress_port
370
371 # Create a flow mod message
372 request = message.flow_mod()
373 request.match = match
374 act.port = ofp.OFPP_IN_PORT
375
376 request.actions.add(act)
Rich Lane9a003812012-10-04 17:17:59 -0700377 logging.info("Inserting flow")
ShreyaPandita9306c772012-09-28 12:21:40 -0400378 rv = self.controller.message_send(request)
379 self.assertTrue(rv != -1, "Error installing flow mod")
380 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
381
382 #Send packet matching the flow
Rich Lane9a003812012-10-04 17:17:59 -0700383 logging.info("Sending packet to dp port " + str(ingress_port))
ShreyaPandita9306c772012-09-28 12:21:40 -0400384 self.dataplane.send(ingress_port, str(pkt))
385 yes_ports = [ingress_port]
386
387 #Verfying packet recieved on expected dataplane ports
388 receive_pkt_check(self.dataplane, pkt, yes_ports,set(of_ports).difference([ingress_port]),
Rich Lane2014f9b2012-10-05 15:29:40 -0700389 self)
ShreyaPandita9306c772012-09-28 12:21:40 -0400390
Rich Laneb90a1c42012-10-05 09:16:05 -0700391class ForwardTable(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400392
393 """ForwardTable : Perform actions in flow table. Only for packet-out messages.
394 If the output action.port in the packetout message = OFP.TABLE , then
395 the packet implements the action specified in the matching flow of the FLOW-TABLE"""
396
397 def runTest(self):
398
Rich Lane9a003812012-10-04 17:17:59 -0700399 logging.info("Running Forward_Table test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400400
Rich Lane477f4812012-10-04 22:49:00 -0700401 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400402 of_ports.sort()
403 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
404
405 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700406 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400407 self.assertEqual(rv, 0, "Failed to delete all flows")
408
Rich Lane9a003812012-10-04 17:17:59 -0700409 logging.info("Insert a flow F with output action port set to some egress_port")
410 logging.info("Send packet out message (matching flow F) with action.port = OFP.TABLE")
411 logging.info("Expecting packet on the egress_port")
ShreyaPandita9306c772012-09-28 12:21:40 -0400412
413 #Insert a all wildcarded flow
414 (pkt,match) = Wildcard_All(self,of_ports)
415
416 #Create a packet out message
417 pkt_out =message.packet_out();
418 pkt_out.data = str(pkt)
419 pkt_out.in_port = of_ports[0]
420 act = action.action_output()
421 act.port = ofp.OFPP_TABLE
422 pkt_out.actions.add(act)
423 rv = self.controller.message_send(pkt_out)
424 self.assertTrue(rv == 0, "Error sending out message")
425
426 #Verifying packet out message recieved on the expected dataplane port.
427 (of_port, pkt, pkt_time) = self.dataplane.poll(port_number=of_ports[1],
428 exp_pkt=pkt,timeout=3)
429 self.assertTrue(pkt is not None, 'Packet not received')
430
431
Rich Laneb90a1c42012-10-05 09:16:05 -0700432class AddVlanTag(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400433
434 """AddVlanTag : Adds VLAN Tag to untagged packet."""
435
436 def runTest(self):
437
Rich Lane9a003812012-10-04 17:17:59 -0700438 logging.info("Running Add_vlan_tag test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400439
Rich Lane477f4812012-10-04 22:49:00 -0700440 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400441 of_ports.sort()
442 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
443
444 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700445 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400446 self.assertEqual(rv, 0, "Failed to delete all flows")
447
Rich Lane9a003812012-10-04 17:17:59 -0700448 logging.info("Verify if switch supports the action -- set vlan id, if not skip the test")
449 logging.info("Insert a flow with set vid action")
450 logging.info("Send packet matching the flow , verify recieved packet has vid set")
ShreyaPandita9306c772012-09-28 12:21:40 -0400451
452 #Verify set_vlan_id is a supported action
453 sup_acts = sw_supported_actions(self)
454 if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
455 skip_message_emit(self, "Add VLAN tag test skipped")
456 return
457
458 #Create packet to be sent and an expected packet with vid set
459 new_vid = 2
460 len_wo_vid = 100
461 len_w_vid = 104
462 pkt = simple_tcp_packet(pktlen=len_wo_vid)
463 exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
464 dl_vlan=new_vid,dl_vlan_pcp=0)
465 vid_act = action.action_set_vlan_vid()
466 vid_act.vlan_vid = new_vid
467
468 #Insert flow with action -- set vid , Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700469 flow_match_test(self, config["port_map"], pkt=pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400470 exp_pkt=exp_pkt, action_list=[vid_act])
471
Rich Laneb90a1c42012-10-05 09:16:05 -0700472class ModifyVlanTag(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400473
474 """ModifyVlanTag : Modifies VLAN Tag to tagged packet."""
475
476 def runTest(self):
477
Rich Lane9a003812012-10-04 17:17:59 -0700478 logging.info("Running Modify_Vlan_Tag test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400479
Rich Lane477f4812012-10-04 22:49:00 -0700480 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400481 of_ports.sort()
482 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
483
484 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700485 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400486 self.assertEqual(rv, 0, "Failed to delete all flows")
487
Rich Lane9a003812012-10-04 17:17:59 -0700488 logging.info("Verify if switch supports the action -- modify vlan id, if not skip the test")
489 logging.info("Insert a flow with action --set vid ")
490 logging.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten")
ShreyaPandita9306c772012-09-28 12:21:40 -0400491
492 #Verify set_vlan_id is a supported action
493 sup_acts = sw_supported_actions(self)
494 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
495 skip_message_emit(self, "Modify VLAN tag test skipped")
496 return
497
498 #Create a tagged packet with old_vid to be sent, and expected packet with new_vid
499 old_vid = 2
500 new_vid = 3
501 pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
502 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=new_vid)
503 vid_act = action.action_set_vlan_vid()
504 vid_act.vlan_vid = new_vid
505
506 #Insert flow with action -- set vid , Send packet matching the flow.Verify recieved packet is expected packet.
Rich Lane477f4812012-10-04 22:49:00 -0700507 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400508 action_list=[vid_act])
509
Rich Laneb90a1c42012-10-05 09:16:05 -0700510class VlanPrio1(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400511
512 """AddVlanPrioUntaggedPkt : Add VLAN priority to untagged packet."""
513
514 def runTest(self):
515
Rich Lane9a003812012-10-04 17:17:59 -0700516 logging.info("Running vlan_Prio_1 test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400517
Rich Lane477f4812012-10-04 22:49:00 -0700518 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400519 of_ports.sort()
520 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
521
522 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700523 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400524 self.assertEqual(rv, 0, "Failed to delete all flows")
525
Rich Lane9a003812012-10-04 17:17:59 -0700526 logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
527 logging.info("Insert a flow with action -- set vlan priority ")
528 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 -0400529
530 #Verify set_vlan_priority is a supported action
531 sup_acts = sw_supported_actions(self)
532 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
533 skip_message_emit(self, "Set VLAN priority test skipped")
534 return
535
536 #Create a untagged packet to be sent and an expected packet with vid = 0 , vlan_priority set.
537 vlan_id = 0
Rich Lane123928c2012-10-04 21:28:53 -0700538 vlan_pcp = 1
539 pkt = simple_tcp_packet(pktlen=60)
540 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vlan_id,dl_vlan_pcp=vlan_pcp, pktlen=64)
541 act = action.action_set_vlan_pcp()
542 act.vlan_pcp = vlan_pcp
ShreyaPandita9306c772012-09-28 12:21:40 -0400543
544 #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 -0700545 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400546 action_list=[act])
547
548
Rich Laneb90a1c42012-10-05 09:16:05 -0700549class VlanPrio2(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400550
551 """ModifyVlanPrio : Modify VLAN priority to tagged packet."""
552
553 def runTest(self):
554
Rich Lane9a003812012-10-04 17:17:59 -0700555 logging.info("Running Vlan_Prio_2 test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400556
Rich Lane477f4812012-10-04 22:49:00 -0700557 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400558 of_ports.sort()
559 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
560
561 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700562 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400563 self.assertEqual(rv, 0, "Failed to delete all flows")
564
Rich Lane9a003812012-10-04 17:17:59 -0700565 logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
566 logging.info("Insert a flow with action -- set vlan priority ")
567 logging.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten")
ShreyaPandita9306c772012-09-28 12:21:40 -0400568
569 #Verify set_vlan_priority is a supported action
570 sup_acts = sw_supported_actions(self,"true")
571 if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
572 skip_message_emit(self, "modify_vlan_prio test skipped")
573 return
574
575 #Create a tagged packet , and an expected packet with vlan_priority set to specified value
576 vid = 123
577 old_vlan_pcp = 2
578 new_vlan_pcp = 3
579 pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=old_vlan_pcp)
580 exp_pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=vid, dl_vlan_pcp=new_vlan_pcp)
581 vid_act = action.action_set_vlan_pcp()
582 vid_act.vlan_pcp = new_vlan_pcp
583
584 #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 -0700585 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400586 action_list=[vid_act])
587
588
Rich Laneb90a1c42012-10-05 09:16:05 -0700589class ModifyL2Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400590
591 """ModifyL2Src :Modify the source MAC address"""
592
593 def runTest(self):
594
Rich Lane9a003812012-10-04 17:17:59 -0700595 logging.info("Running Modify_L2_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400596
Rich Lane477f4812012-10-04 22:49:00 -0700597 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400598 of_ports.sort()
599 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
600
601 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700602 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400603 self.assertEqual(rv, 0, "Failed to delete all flows")
604
Rich Lane9a003812012-10-04 17:17:59 -0700605 logging.info("Verify if switch supports the action -- modify_l2_src, if not skip the test")
606 logging.info("Insert a flow with action -- set etherent src address")
607 logging.info("Send packet matching the flow, verify recieved packet src address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400608
609 #Verify set_dl_src is a supported action
610 sup_acts = sw_supported_actions(self,use_cache="true")
611 if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
612 skip_message_emit(self, "modify_l2_src test skipped")
613 return
614
615 #Create packet to be sent and expected packet with dl_src set to specified value
616 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
617 check_test_params=True)
618
619 #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 -0700620 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400621 action_list=acts, max_test=2)
622
623
Rich Laneb90a1c42012-10-05 09:16:05 -0700624class ModifyL2Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400625
626 """ModifyL2SDSt :Modify the dest MAC address"""
627
628 def runTest(self):
629
Rich Lane9a003812012-10-04 17:17:59 -0700630 logging.info("Running Modify_L2_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400631
Rich Lane477f4812012-10-04 22:49:00 -0700632 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400633 of_ports.sort()
634 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
635
636 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700637 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400638 self.assertEqual(rv, 0, "Failed to delete all flows")
639
Rich Lane9a003812012-10-04 17:17:59 -0700640 logging.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test")
641 logging.info("Insert a flow with action -- set etherent dst address ")
642 logging.info("Send packet matching the flow, verify recieved packet dst address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400643
644 #Verify set_dl_dst is a supported action
645 sup_acts = sw_supported_actions(self)
646 if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
647 skip_message_emit(self, "modify_l2_dst test skipped")
648 return
649
650 #Create packet to be sent and expected packet with dl_src set to specified value
651 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
652 check_test_params=True)
653
654 #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 -0700655 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400656 action_list=acts, max_test=2)
657
Rich Laneb90a1c42012-10-05 09:16:05 -0700658class ModifyL3Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400659
660 """ModifyL3Src : Modify the source IP address of an IP packet """
661
662 def runTest(self):
663
Rich Lane9a003812012-10-04 17:17:59 -0700664 logging.info("Running Modify_L3_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400665
Rich Lane477f4812012-10-04 22:49:00 -0700666 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400667 of_ports.sort()
668 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
669
670 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700671 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400672 self.assertEqual(rv, 0, "Failed to delete all flows")
673
Rich Lane9a003812012-10-04 17:17:59 -0700674 logging.info("Verify if switch supports the action -- modify_l3_src, if not skip the test")
675 logging.info("Insert a flow with action -- set network src address ")
676 logging.info("Send packet matching the flow, verify recieved packet network src address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400677
678 #Verify set_nw_src is a supported action
679 sup_acts = sw_supported_actions(self)
680 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC):
681 skip_message_emit(self, "modify_l3_src test")
682 return
683
684 #Create packet to be sent and expected packet with nw_src set to specified value
685 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'],
686 check_test_params=True)
687
688 #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 -0700689 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400690 action_list=acts, max_test=2)
691
Rich Laneb90a1c42012-10-05 09:16:05 -0700692class ModifyL3Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400693
694 """ModifyL3Dst :Modify the dest IP address of an IP packet"""
695
696 def runTest(self):
697
Rich Lane9a003812012-10-04 17:17:59 -0700698 logging.info("Running Modify_L3_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400699
Rich Lane477f4812012-10-04 22:49:00 -0700700 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400701 of_ports.sort()
702 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
703
704 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700705 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400706 self.assertEqual(rv, 0, "Failed to delete all flows")
707
Rich Lane9a003812012-10-04 17:17:59 -0700708 logging.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test")
709 logging.info("Insert a flow with action -- set network dst address ")
710 logging.info("Send packet matching the flow, verify recieved packet network dst address rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400711
712 #Verify set_nw_dst is a supported action
713 sup_acts = sw_supported_actions(self,use_cache="true")
714 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST):
715 skip_message_emit(self, "modify_l3_dst test skipped")
716 return
717
718 #Create packet to be sent and expected packet with nw_dst set to specified value
719 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'],
720 check_test_params=True)
721
722 #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 -0700723 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400724 action_list=acts, max_test=2)
725
726
Rich Laneb90a1c42012-10-05 09:16:05 -0700727class ModifyL4Src(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400728
729 """ModifyL4Src : Modify the source TCP port of a TCP packet"""
730
731 def runTest(self):
732
Rich Lane9a003812012-10-04 17:17:59 -0700733 logging.info("Running Modify_L4_Src test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400734
Rich Lane477f4812012-10-04 22:49:00 -0700735 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400736 of_ports.sort()
737 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
738
739 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700740 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400741 self.assertEqual(rv, 0, "Failed to delete all flows")
742
Rich Lane9a003812012-10-04 17:17:59 -0700743 logging.info("Verify if switch supports the action -- modify_l4_src, if not skip the test")
744 logging.info("Insert a flow with action -- set src tcp port")
745 logging.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400746
747 #Verify set_tp_src is a supported action
748 sup_acts = sw_supported_actions(self,use_cache="true")
749 if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC):
750 skip_message_emit(self, "modify_l4_src test skipped")
751 return
752
753 #Create packet to be sent and expected packet with tcp_src set to specified value
754 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_sport'],
755 check_test_params=True)
756
757 #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 -0700758 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400759 action_list=acts, max_test=2)
760
Rich Laneb90a1c42012-10-05 09:16:05 -0700761class ModifyL4Dst(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400762
763 """ ModifyL4Dst: Modify the dest TCP port of a TCP packet """
764
765 def runTest(self):
766
Rich Lane9a003812012-10-04 17:17:59 -0700767 logging.info("Running Modify_L4_Dst test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400768
Rich Lane477f4812012-10-04 22:49:00 -0700769 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400770 of_ports.sort()
771 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
772
773 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700774 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400775 self.assertEqual(rv, 0, "Failed to delete all flows")
776
Rich Lane9a003812012-10-04 17:17:59 -0700777 logging.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test")
778 logging.info("Insert a flow with action -- set dst tcp port")
779 logging.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400780
781 #Verify set_tp_dst is a supported action
782 sup_acts = sw_supported_actions(self,use_cache="true")
783 if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST):
784 skip_message_emit(self, "ModifyL4Dst test")
785 return
786
787 #Create packet to be sent and expected packet with tcp_dst set to specified value
788 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_dport'],
789 check_test_params=True)
790
791 #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 -0700792 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400793 action_list=acts, max_test=2)
794
Rich Laneb90a1c42012-10-05 09:16:05 -0700795class ModifyTos(base_tests.SimpleDataPlane):
ShreyaPandita9306c772012-09-28 12:21:40 -0400796
797 """ModifyTOS :Modify the IP type of service of an IP packet"""
798
799 def runTest(self):
800
Rich Lane9a003812012-10-04 17:17:59 -0700801 logging.info("Running Modify_Tos test")
ShreyaPandita9306c772012-09-28 12:21:40 -0400802
Rich Lane477f4812012-10-04 22:49:00 -0700803 of_ports = config["port_map"].keys()
ShreyaPandita9306c772012-09-28 12:21:40 -0400804 of_ports.sort()
805 self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
806
807 #Clear switch state
Rich Lane9a003812012-10-04 17:17:59 -0700808 rv = delete_all_flows(self.controller)
ShreyaPandita9306c772012-09-28 12:21:40 -0400809 self.assertEqual(rv, 0, "Failed to delete all flows")
810
Rich Lane9a003812012-10-04 17:17:59 -0700811 logging.info("Verify if switch supports the action -- modify_tos, if not skip the test")
812 logging.info("Insert a flow with action -- set type of service ")
813 logging.info("Send packet matching the flow, verify recieved packet has TOS rewritten ")
ShreyaPandita9306c772012-09-28 12:21:40 -0400814
815 #Verify set_tos is a supported action
816 sup_acts = sw_supported_actions(self,use_cache="true")
817 if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
818 skip_message_emit(self, "ModifyTOS test")
819 return
820
821 #Create packet to be sent and expected packet with TOS set to specified value
822 (pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_tos'],
823 check_test_params=True)
824
825 #Insert flow with action -- set TOS, Send packet matching the flow, Verify recieved packet is expected packet
Rich Lane477f4812012-10-04 22:49:00 -0700826 flow_match_test(self, config["port_map"], pkt=pkt, exp_pkt=exp_pkt,
ShreyaPandita9306c772012-09-28 12:21:40 -0400827 action_list=acts, max_test=2, egr_count=-1)