Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 1 | """ |
| 2 | Flow stats test case. |
| 3 | Similar to Flow stats test case in the perl test harness. |
| 4 | |
| 5 | """ |
| 6 | |
| 7 | import logging |
| 8 | |
| 9 | import unittest |
| 10 | import random |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 11 | import copy |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 12 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 13 | from oftest import config |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 14 | import oftest.controller as controller |
Rich Lane | d7b0ffa | 2013-03-08 15:53:42 -0800 | [diff] [blame] | 15 | import ofp |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 16 | import oftest.dataplane as dataplane |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 17 | import oftest.parse as parse |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 18 | import oftest.base_tests as base_tests |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 19 | |
Rich Lane | da3b5ad | 2012-10-03 09:05:32 -0700 | [diff] [blame] | 20 | from oftest.testutils import * |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 21 | from time import sleep |
| 22 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 23 | # TODO: ovs has problems with VLAN id? |
| 24 | WILDCARD_VALUES = [ofp.OFPFW_IN_PORT, |
Dan Talayco | 488fbc5 | 2012-04-09 16:30:41 -0700 | [diff] [blame] | 25 | # (ofp.OFPFW_DL_VLAN | ofp.OFPFW_DL_VLAN_PCP), |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 26 | ofp.OFPFW_DL_SRC, |
| 27 | ofp.OFPFW_DL_DST, |
Dan Talayco | 488fbc5 | 2012-04-09 16:30:41 -0700 | [diff] [blame] | 28 | (ofp.OFPFW_DL_TYPE | ofp.OFPFW_NW_SRC_ALL | |
| 29 | ofp.OFPFW_NW_DST_ALL | ofp.OFPFW_NW_TOS | ofp.OFPFW_NW_PROTO | |
| 30 | ofp.OFPFW_TP_SRC | ofp.OFPFW_TP_DST), |
| 31 | (ofp.OFPFW_NW_PROTO | ofp.OFPFW_TP_SRC | ofp.OFPFW_TP_DST), |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 32 | ofp.OFPFW_TP_SRC, |
| 33 | ofp.OFPFW_TP_DST, |
Dan Talayco | 488fbc5 | 2012-04-09 16:30:41 -0700 | [diff] [blame] | 34 | ofp.OFPFW_NW_SRC_MASK, |
| 35 | ofp.OFPFW_NW_DST_MASK, |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 36 | ofp.OFPFW_DL_VLAN_PCP, |
| 37 | ofp.OFPFW_NW_TOS] |
| 38 | |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 39 | def sendPacket(obj, pkt, ingress_port, egress_port, test_timeout): |
| 40 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 41 | logging.info("Sending packet to dp port " + str(ingress_port) + |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 42 | ", expecting output on " + str(egress_port)) |
| 43 | obj.dataplane.send(ingress_port, str(pkt)) |
| 44 | |
| 45 | exp_pkt_arg = None |
| 46 | exp_port = None |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 47 | if config["relax"]: |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 48 | exp_pkt_arg = pkt |
| 49 | exp_port = egress_port |
| 50 | |
Rich Lane | c8aaa3e | 2012-07-26 19:28:02 -0700 | [diff] [blame] | 51 | (rcv_port, rcv_pkt, pkt_time) = obj.dataplane.poll(port_number=exp_port, |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 52 | exp_pkt=exp_pkt_arg) |
| 53 | obj.assertTrue(rcv_pkt is not None, |
| 54 | "Packet not received on port " + str(egress_port)) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 55 | logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " + |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 56 | str(rcv_port)) |
| 57 | obj.assertEqual(rcv_port, egress_port, |
| 58 | "Packet received on port " + str(rcv_port) + |
| 59 | ", expected port " + str(egress_port)) |
| 60 | obj.assertEqual(str(pkt), str(rcv_pkt), |
| 61 | 'Response packet does not match send packet') |
| 62 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 63 | class SingleFlowStats(base_tests.SimpleDataPlane): |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 64 | """ |
| 65 | Verify flow stats are properly retrieved. |
| 66 | |
| 67 | Generate a packet |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 68 | Generate and install a matching flow |
| 69 | Send the packet |
| 70 | Send a flow stats request to match the flow and retrieve stats |
| 71 | Verify that the packet counter has incremented |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 72 | """ |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 73 | |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 74 | def verifyStats(self, flow_mod_msg, match, out_port, test_timeout, packet_count): |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 75 | stat_req = ofp.message.flow_stats_request() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 76 | stat_req.match = match |
| 77 | stat_req.table_id = 0xff |
| 78 | stat_req.out_port = out_port |
| 79 | |
| 80 | all_packets_received = 0 |
| 81 | for i in range(0,test_timeout): |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 82 | logging.info("Sending stats request") |
Ken Chiang | fb593e7 | 2012-03-28 17:19:13 -0700 | [diff] [blame] | 83 | response, pkt = self.controller.transact(stat_req, |
| 84 | timeout=test_timeout) |
| 85 | self.assertTrue(response is not None, |
| 86 | "No response to stats request") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 87 | self.assertTrue(len(response.entries) == 1, |
Ken Chiang | fb593e7 | 2012-03-28 17:19:13 -0700 | [diff] [blame] | 88 | "Did not receive flow stats reply") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 89 | for obj in response.entries: |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 90 | # TODO: pad1 and pad2 fields may be nonzero, is this a bug? |
| 91 | # for now, just clear them so the assert is simpler |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 92 | obj.match.pad1 = 0 |
| 93 | obj.match.pad2 = [0, 0] |
| 94 | self.assertEqual(flow_mod_msg.match, obj.match, |
| 95 | "Matches do not match") |
| 96 | self.assertEqual(obj.cookie, flow_mod_msg.cookie) |
| 97 | self.assertEqual(obj.priority, flow_mod_msg.priority) |
| 98 | self.assertEqual(obj.idle_timeout, flow_mod_msg.idle_timeout) |
| 99 | self.assertEqual(obj.hard_timeout, flow_mod_msg.hard_timeout) |
| 100 | self.assertEqual(obj.actions, flow_mod_msg.actions) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 101 | logging.info("Received " + str(obj.packet_count) + " packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 102 | if obj.packet_count == packet_count: |
| 103 | all_packets_received = 1 |
| 104 | |
| 105 | if all_packets_received: |
| 106 | break |
| 107 | sleep(1) |
| 108 | |
| 109 | self.assertTrue(all_packets_received, |
| 110 | "Packet count does not match number sent") |
| 111 | |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 112 | def runTest(self): |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 113 | # TODO: set from command-line parameter |
| 114 | test_timeout = 60 |
| 115 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 116 | of_ports = config["port_map"].keys() |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 117 | of_ports.sort() |
| 118 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 119 | |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 120 | delete_all_flows(self.controller) |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 121 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 122 | # build packet |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 123 | pkt = simple_tcp_packet() |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 124 | match = packet_to_flow_match(self, pkt) |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 125 | match.wildcards &= ~ofp.OFPFW_IN_PORT |
| 126 | self.assertTrue(match is not None, |
| 127 | "Could not generate flow match from pkt") |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 128 | act = ofp.action.output() |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 129 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 130 | # build flow |
Dan Talayco | 39bf691 | 2010-07-08 14:17:52 -0700 | [diff] [blame] | 131 | ingress_port = of_ports[0]; |
| 132 | egress_port = of_ports[1]; |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 133 | logging.info("Ingress " + str(ingress_port) + |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 134 | " to egress " + str(egress_port)) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 135 | match.in_port = ingress_port |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 136 | flow_mod_msg = ofp.message.flow_mod() |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 137 | flow_mod_msg.match = copy.deepcopy(match) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 138 | flow_mod_msg.cookie = random.randint(0,9007199254740992) |
| 139 | flow_mod_msg.buffer_id = 0xffffffff |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 140 | flow_mod_msg.idle_timeout = 60000 |
| 141 | flow_mod_msg.hard_timeout = 65000 |
| 142 | flow_mod_msg.priority = 100 |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 143 | act.port = egress_port |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 144 | flow_mod_msg.actions.append(act) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 145 | |
| 146 | # send flow |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 147 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 148 | self.controller.message_send(flow_mod_msg) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 149 | do_barrier(self.controller) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 150 | |
| 151 | # no packets sent, so zero packet count |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 152 | self.verifyStats(flow_mod_msg, match, ofp.OFPP_NONE, test_timeout, 0) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 153 | |
| 154 | # send packet N times |
| 155 | num_sends = random.randint(10,20) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 156 | logging.info("Sending " + str(num_sends) + " test packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 157 | for i in range(0,num_sends): |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 158 | sendPacket(self, pkt, ingress_port, egress_port, |
| 159 | test_timeout) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 160 | |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 161 | self.verifyStats(flow_mod_msg, match, ofp.OFPP_NONE, test_timeout, num_sends) |
| 162 | self.verifyStats(flow_mod_msg, match, egress_port, test_timeout, num_sends) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 163 | for wc in WILDCARD_VALUES: |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 164 | match.wildcards = required_wildcards(self) | wc |
Rich Lane | c42dbad | 2012-10-11 10:57:44 -0700 | [diff] [blame] | 165 | self.verifyStats(flow_mod_msg, match, egress_port, test_timeout, num_sends) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 166 | |
| 167 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 168 | class TwoFlowStats(base_tests.SimpleDataPlane): |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 169 | """ |
| 170 | Verify flow stats are properly retrieved. |
| 171 | |
| 172 | Generate two packets and install two matching flows |
| 173 | Send some number of packets |
| 174 | Send a flow stats request to match the flows and retrieve stats |
| 175 | Verify that the packet counter has incremented |
| 176 | |
| 177 | TODO: add a third flow, and then configure the match to exclude |
| 178 | that flow? |
| 179 | """ |
| 180 | |
| 181 | def buildFlowModMsg(self, pkt, ingress_port, egress_port): |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 182 | match = packet_to_flow_match(self, pkt) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 183 | match.wildcards &= ~ofp.OFPFW_IN_PORT |
| 184 | self.assertTrue(match is not None, |
| 185 | "Could not generate flow match from pkt") |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 186 | match.in_port = ingress_port |
| 187 | |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 188 | flow_mod_msg = ofp.message.flow_mod() |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 189 | flow_mod_msg.match = match |
| 190 | flow_mod_msg.cookie = random.randint(0,9007199254740992) |
| 191 | flow_mod_msg.buffer_id = 0xffffffff |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 192 | flow_mod_msg.idle_timeout = 0 |
| 193 | flow_mod_msg.hard_timeout = 0 |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 194 | act = ofp.action.output() |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 195 | act.port = egress_port |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 196 | flow_mod_msg.actions.append(act) |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 197 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 198 | logging.info("Ingress " + str(ingress_port) + |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 199 | " to egress " + str(egress_port)) |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 200 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 201 | return flow_mod_msg |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 202 | |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 203 | def sumStatsReplyCounts(self, response): |
| 204 | total_packets = 0 |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 205 | for obj in response.entries: |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 206 | # TODO: pad1 and pad2 fields may be nonzero, is this a bug? |
| 207 | # for now, just clear them so the assert is simpler |
| 208 | #obj.match.pad1 = 0 |
| 209 | #obj.match.pad2 = [0, 0] |
| 210 | #self.assertEqual(match, obj.match, |
| 211 | # "Matches do not match") |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 212 | logging.info("Received " + str(obj.packet_count) |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 213 | + " packets") |
| 214 | total_packets += obj.packet_count |
| 215 | return total_packets |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 216 | |
| 217 | def verifyStats(self, match, out_port, test_timeout, packet_count): |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 218 | stat_req = ofp.message.flow_stats_request() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 219 | stat_req.match = match |
| 220 | stat_req.table_id = 0xff |
| 221 | stat_req.out_port = out_port |
| 222 | |
| 223 | all_packets_received = 0 |
| 224 | for i in range(0,test_timeout): |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 225 | logging.info("Sending stats request") |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 226 | # TODO: move REPLY_MORE handling to controller.transact? |
Ken Chiang | fb593e7 | 2012-03-28 17:19:13 -0700 | [diff] [blame] | 227 | response, pkt = self.controller.transact(stat_req, |
| 228 | timeout=test_timeout) |
| 229 | self.assertTrue(response is not None, |
| 230 | "No response to stats request") |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 231 | total_packets = self.sumStatsReplyCounts(response) |
| 232 | |
| 233 | while response.flags == ofp.OFPSF_REPLY_MORE: |
| 234 | response, pkt = self.controller.poll(exp_msg= |
| 235 | ofp.OFPT_STATS_REPLY, |
| 236 | timeout=test_timeout) |
| 237 | total_packets += self.sumStatsReplyCounts(response) |
| 238 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 239 | if total_packets == packet_count: |
| 240 | all_packets_received = 1 |
| 241 | break |
| 242 | sleep(1) |
| 243 | |
| 244 | self.assertTrue(all_packets_received, |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 245 | "Total stats packet count " + str(total_packets) + |
| 246 | " does not match number sent " + str(packet_count)) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 247 | |
| 248 | def runTest(self): |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 249 | # TODO: set from command-line parameter |
| 250 | test_timeout = 60 |
| 251 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 252 | of_ports = config["port_map"].keys() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 253 | of_ports.sort() |
| 254 | self.assertTrue(len(of_ports) >= 3, "Not enough ports for test") |
| 255 | ingress_port = of_ports[0]; |
| 256 | egress_port1 = of_ports[1]; |
| 257 | egress_port2 = of_ports[2]; |
| 258 | |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 259 | delete_all_flows(self.controller) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 260 | |
| 261 | pkt1 = simple_tcp_packet() |
| 262 | flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1) |
| 263 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 264 | pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7') |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 265 | flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2) |
| 266 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 267 | logging.info("Inserting flow1") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 268 | self.controller.message_send(flow_mod_msg1) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 269 | logging.info("Inserting flow2") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 270 | self.controller.message_send(flow_mod_msg2) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 271 | do_barrier(self.controller) |
Dan Talayco | 89d5734 | 2010-06-07 16:24:59 -0700 | [diff] [blame] | 272 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 273 | num_pkt1s = random.randint(10,30) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 274 | logging.info("Sending " + str(num_pkt1s) + " pkt1s") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 275 | num_pkt2s = random.randint(10,30) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 276 | logging.info("Sending " + str(num_pkt2s) + " pkt2s") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 277 | for i in range(0,num_pkt1s): |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 278 | sendPacket(self, pkt1, ingress_port, egress_port1, test_timeout) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 279 | for i in range(0,num_pkt2s): |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 280 | sendPacket(self, pkt2, ingress_port, egress_port2, test_timeout) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 281 | |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 282 | match1 = packet_to_flow_match(self, pkt1) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 283 | logging.info("Verifying flow1's " + str(num_pkt1s) + " packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 284 | self.verifyStats(match1, ofp.OFPP_NONE, test_timeout, num_pkt1s) |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 285 | match2 = packet_to_flow_match(self, pkt2) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 286 | logging.info("Verifying flow2's " + str(num_pkt2s) + " packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 287 | self.verifyStats(match2, ofp.OFPP_NONE, test_timeout, num_pkt2s) |
| 288 | match1.wildcards |= ofp.OFPFW_DL_SRC |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 289 | logging.info("Verifying combined " + str(num_pkt1s+num_pkt2s) + " packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 290 | self.verifyStats(match1, ofp.OFPP_NONE, test_timeout, |
| 291 | num_pkt1s+num_pkt2s) |
| 292 | # TODO: sweep through the wildcards to verify matching? |
| 293 | |
| 294 | |
Rich Lane | b90a1c4 | 2012-10-05 09:16:05 -0700 | [diff] [blame] | 295 | class AggregateStats(base_tests.SimpleDataPlane): |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 296 | """ |
| 297 | Verify aggregate flow stats are properly retrieved. |
| 298 | |
| 299 | Generate two packets |
| 300 | Generate and install two matching flows |
| 301 | Send an aggregate stats request |
| 302 | Verify that aggregate stats are correct |
| 303 | Also verify out_port filtering |
| 304 | """ |
| 305 | |
| 306 | def buildFlowModMsg(self, pkt, ingress_port, egress_port): |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 307 | match = packet_to_flow_match(self, pkt) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 308 | match.wildcards &= ~ofp.OFPFW_IN_PORT |
| 309 | self.assertTrue(match is not None, |
| 310 | "Could not generate flow match from pkt") |
| 311 | match.in_port = ingress_port |
| 312 | |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 313 | flow_mod_msg = ofp.message.flow_mod() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 314 | flow_mod_msg.match = match |
| 315 | flow_mod_msg.cookie = random.randint(0,9007199254740992) |
| 316 | flow_mod_msg.buffer_id = 0xffffffff |
| 317 | flow_mod_msg.idle_timeout = 0 |
| 318 | flow_mod_msg.hard_timeout = 0 |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 319 | act = ofp.action.output() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 320 | act.port = egress_port |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 321 | flow_mod_msg.actions.append(act) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 322 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 323 | logging.info("Ingress " + str(ingress_port) + |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 324 | " to egress " + str(egress_port)) |
| 325 | |
| 326 | return flow_mod_msg |
| 327 | |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 328 | def verifyAggFlowStats(self, match, out_port, test_timeout, |
| 329 | flow_count, packet_count): |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 330 | stat_req = ofp.message.aggregate_stats_request() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 331 | stat_req.match = match |
| 332 | stat_req.table_id = 0xff |
| 333 | stat_req.out_port = out_port |
| 334 | |
| 335 | all_packets_received = 0 |
| 336 | for i in range(0,test_timeout): |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 337 | logging.info("Sending stats request") |
Ken Chiang | fb593e7 | 2012-03-28 17:19:13 -0700 | [diff] [blame] | 338 | response, pkt = self.controller.transact(stat_req, |
| 339 | timeout=test_timeout) |
| 340 | self.assertTrue(response is not None, |
| 341 | "No response to stats request") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 342 | self.assertTrue(len(response.entries) == 1, |
Dan Talayco | aff26c8 | 2012-03-25 15:06:26 -0700 | [diff] [blame] | 343 | "Did not receive flow stats reply") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 344 | for obj in response.entries: |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 345 | self.assertTrue(obj.flow_count == flow_count, |
| 346 | "Flow count " + str(obj.flow_count) + |
| 347 | " does not match expected " + str(flow_count)) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 348 | logging.info("Received " + str(obj.packet_count) + " packets") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 349 | if obj.packet_count == packet_count: |
| 350 | all_packets_received = 1 |
| 351 | |
| 352 | if all_packets_received: |
| 353 | break |
| 354 | sleep(1) |
| 355 | |
| 356 | self.assertTrue(all_packets_received, |
| 357 | "Packet count does not match number sent") |
| 358 | |
| 359 | def runTest(self): |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 360 | # TODO: set from command-line parameter |
| 361 | test_timeout = 60 |
| 362 | |
Rich Lane | 477f481 | 2012-10-04 22:49:00 -0700 | [diff] [blame] | 363 | of_ports = config["port_map"].keys() |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 364 | of_ports.sort() |
| 365 | self.assertTrue(len(of_ports) >= 3, "Not enough ports for test") |
| 366 | ingress_port = of_ports[0]; |
| 367 | egress_port1 = of_ports[1]; |
| 368 | egress_port2 = of_ports[2]; |
| 369 | |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 370 | delete_all_flows(self.controller) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 371 | |
| 372 | pkt1 = simple_tcp_packet() |
| 373 | flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1) |
| 374 | |
Rich Lane | d0478ff | 2013-03-11 12:46:58 -0700 | [diff] [blame] | 375 | pkt2 = simple_tcp_packet(eth_src='0:7:7:7:7:7') |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 376 | flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2) |
| 377 | |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 378 | logging.info("Inserting flow1") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 379 | self.controller.message_send(flow_mod_msg1) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 380 | logging.info("Inserting flow2") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 381 | self.controller.message_send(flow_mod_msg2) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 382 | do_barrier(self.controller) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 383 | |
| 384 | num_pkt1s = random.randint(10,30) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 385 | logging.info("Sending " + str(num_pkt1s) + " pkt1s") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 386 | num_pkt2s = random.randint(10,30) |
Rich Lane | 9a00381 | 2012-10-04 17:17:59 -0700 | [diff] [blame] | 387 | logging.info("Sending " + str(num_pkt2s) + " pkt2s") |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 388 | for i in range(0,num_pkt1s): |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 389 | sendPacket(self, pkt1, ingress_port, egress_port1, test_timeout) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 390 | for i in range(0,num_pkt2s): |
Ken Chiang | aa5bc06 | 2012-03-31 14:03:28 -0700 | [diff] [blame] | 391 | sendPacket(self, pkt2, ingress_port, egress_port2, test_timeout) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 392 | |
| 393 | # loop on flow stats request until timeout |
Ed Swierk | 99a74de | 2012-08-22 06:40:54 -0700 | [diff] [blame] | 394 | match = packet_to_flow_match(self, pkt1) |
Ken Chiang | 620bdcc | 2012-03-23 12:52:07 -0700 | [diff] [blame] | 395 | match.wildcards |= ofp.OFPFW_DL_SRC |
| 396 | self.verifyAggFlowStats(match, ofp.OFPP_NONE, test_timeout, |
| 397 | 2, num_pkt1s+num_pkt2s) |
| 398 | |
| 399 | # out_port filter for egress_port1 |
| 400 | self.verifyAggFlowStats(match, egress_port1, test_timeout, |
| 401 | 1, num_pkt1s) |
| 402 | |
| 403 | # out_port filter for egress_port1 |
| 404 | self.verifyAggFlowStats(match, egress_port2, test_timeout, |
| 405 | 1, num_pkt2s) |
Rich Lane | 97a5f50 | 2012-10-11 09:28:11 -0700 | [diff] [blame] | 406 | |
Rich Lane | f062b3d | 2012-10-11 09:53:19 -0700 | [diff] [blame] | 407 | class EmptyFlowStats(base_tests.SimpleDataPlane): |
| 408 | """ |
| 409 | Verify the switch replies to a flow stats request when |
| 410 | the query doesn't match any flows. |
| 411 | """ |
| 412 | def runTest(self): |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 413 | delete_all_flows(self.controller) |
Rich Lane | f062b3d | 2012-10-11 09:53:19 -0700 | [diff] [blame] | 414 | match = ofp.ofp_match() |
| 415 | match.wildcards = 0 |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 416 | stat_req = ofp.message.flow_stats_request() |
Rich Lane | f062b3d | 2012-10-11 09:53:19 -0700 | [diff] [blame] | 417 | stat_req.match = match |
| 418 | stat_req.table_id = 0xff |
| 419 | stat_req.out_port = ofp.OFPP_NONE |
| 420 | |
| 421 | response, pkt = self.controller.transact(stat_req) |
| 422 | self.assertTrue(response is not None, |
| 423 | "No response to stats request") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 424 | self.assertEquals(len(response.entries), 0) |
Rich Lane | f062b3d | 2012-10-11 09:53:19 -0700 | [diff] [blame] | 425 | self.assertEquals(response.flags, 0) |
| 426 | |
Rich Lane | 97a5f50 | 2012-10-11 09:28:11 -0700 | [diff] [blame] | 427 | class EmptyAggregateStats(base_tests.SimpleDataPlane): |
| 428 | """ |
| 429 | Verify aggregate flow stats are properly retrieved when |
| 430 | the query doesn't match any flows. |
| 431 | """ |
| 432 | def runTest(self): |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 433 | delete_all_flows(self.controller) |
Rich Lane | 97a5f50 | 2012-10-11 09:28:11 -0700 | [diff] [blame] | 434 | match = ofp.ofp_match() |
| 435 | match.wildcards = 0 |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 436 | stat_req = ofp.message.aggregate_stats_request() |
Rich Lane | 97a5f50 | 2012-10-11 09:28:11 -0700 | [diff] [blame] | 437 | stat_req.match = match |
| 438 | stat_req.table_id = 0xff |
| 439 | stat_req.out_port = ofp.OFPP_NONE |
| 440 | |
| 441 | response, pkt = self.controller.transact(stat_req) |
| 442 | self.assertTrue(response is not None, |
| 443 | "No response to stats request") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 444 | self.assertTrue(len(response.entries) == 1, |
Rich Lane | 97a5f50 | 2012-10-11 09:28:11 -0700 | [diff] [blame] | 445 | "Did not receive flow stats reply") |
Rich Lane | 5fd6faf | 2013-03-11 13:30:20 -0700 | [diff] [blame] | 446 | self.assertEquals(response.entries[0].flow_count, 0) |
| 447 | self.assertEquals(response.entries[0].packet_count, 0) |
| 448 | self.assertEquals(response.entries[0].byte_count, 0) |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 449 | |
| 450 | class DeletedFlowStats(base_tests.SimpleDataPlane): |
| 451 | """ |
| 452 | Verify flow stats are properly returned when a flow is deleted. |
| 453 | |
| 454 | Generate a packet |
| 455 | Generate and install a matching flow |
| 456 | Send the packet |
| 457 | Delete the flow |
| 458 | Verify that the flow_removed message has the correct stats |
| 459 | """ |
| 460 | |
| 461 | def runTest(self): |
| 462 | # TODO: set from command-line parameter |
| 463 | test_timeout = 60 |
| 464 | |
| 465 | of_ports = config["port_map"].keys() |
| 466 | of_ports.sort() |
| 467 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 468 | |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 469 | delete_all_flows(self.controller) |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 470 | |
| 471 | # build packet |
| 472 | pkt = simple_tcp_packet() |
| 473 | match = packet_to_flow_match(self, pkt) |
| 474 | match.wildcards &= ~ofp.OFPFW_IN_PORT |
| 475 | self.assertTrue(match is not None, |
| 476 | "Could not generate flow match from pkt") |
Rich Lane | 9d3cc6b | 2013-03-08 16:33:08 -0800 | [diff] [blame] | 477 | act = ofp.action.output() |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 478 | |
| 479 | # build flow |
| 480 | ingress_port = of_ports[0]; |
| 481 | egress_port = of_ports[1]; |
| 482 | logging.info("Ingress " + str(ingress_port) + |
| 483 | " to egress " + str(egress_port)) |
| 484 | match.in_port = ingress_port |
Rich Lane | 28fa927 | 2013-03-08 16:00:25 -0800 | [diff] [blame] | 485 | flow_mod_msg = ofp.message.flow_mod() |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 486 | flow_mod_msg.match = copy.deepcopy(match) |
| 487 | flow_mod_msg.cookie = random.randint(0,9007199254740992) |
| 488 | flow_mod_msg.buffer_id = 0xffffffff |
| 489 | flow_mod_msg.idle_timeout = 0 |
| 490 | flow_mod_msg.hard_timeout = 0 |
| 491 | flow_mod_msg.priority = 100 |
| 492 | flow_mod_msg.flags = ofp.OFPFF_SEND_FLOW_REM |
| 493 | act.port = egress_port |
Rich Lane | c495d9e | 2013-03-08 17:43:36 -0800 | [diff] [blame] | 494 | flow_mod_msg.actions.append(act) |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 495 | |
| 496 | # send flow |
| 497 | logging.info("Inserting flow") |
Rich Lane | 5c3151c | 2013-01-03 17:15:41 -0800 | [diff] [blame] | 498 | self.controller.message_send(flow_mod_msg) |
Rich Lane | 3a261d5 | 2013-01-03 17:45:08 -0800 | [diff] [blame] | 499 | do_barrier(self.controller) |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 500 | |
| 501 | # send packet N times |
| 502 | num_sends = random.randint(10,20) |
| 503 | logging.info("Sending " + str(num_sends) + " test packets") |
| 504 | for i in range(0,num_sends): |
| 505 | sendPacket(self, pkt, ingress_port, egress_port, |
| 506 | test_timeout) |
| 507 | |
Ken Chiang | 626ce1d | 2013-01-09 11:58:50 -0800 | [diff] [blame] | 508 | # wait some time for flow stats to be propagated |
| 509 | # FIXME timeout handling should be unified |
| 510 | sleep(test_param_get('default_timeout', default=2)) |
| 511 | |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 512 | # delete flow |
| 513 | logging.info("Deleting flow") |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 514 | delete_all_flows(self.controller) |
Rich Lane | d10e8e0 | 2012-11-21 15:48:36 -0800 | [diff] [blame] | 515 | |
| 516 | # wait for flow_removed message |
| 517 | flow_removed, _ = self.controller.poll( |
| 518 | exp_msg=ofp.OFPT_FLOW_REMOVED, timeout=test_timeout) |
| 519 | |
| 520 | self.assertTrue(flow_removed != None, "Did not receive flow_removed message") |
Ken Chiang | 626ce1d | 2013-01-09 11:58:50 -0800 | [diff] [blame] | 521 | self.assertEqual(flow_removed.cookie, flow_mod_msg.cookie, |
| 522 | "Received cookie " + str(flow_removed.cookie) + |
| 523 | " does not match expected " + str(flow_mod_msg.cookie)) |
| 524 | self.assertEqual(flow_removed.reason, ofp.OFPRR_DELETE, |
| 525 | "Received reason " + str(flow_removed.reason) + |
| 526 | " does not match expected " + str(ofp.OFPRR_DELETE)) |
| 527 | self.assertEqual(flow_removed.packet_count, num_sends, |
| 528 | "Received packet count " + str(flow_removed.packet_count) + |
| 529 | " does not match expected " + str(num_sends)) |
| 530 | tolerance = 5 # percent |
| 531 | self.assertTrue(flow_removed.byte_count >= |
| 532 | (1-tolerance/100.0) * num_sends * len(str(pkt)) and |
| 533 | flow_removed.byte_count <= |
| 534 | (1+tolerance/100.0) * num_sends * len(str(pkt)), |
| 535 | "Received byte count " + str(flow_removed.byte_count) + |
| 536 | " is not within " + str(tolerance) + "% of expected " + |
| 537 | str(num_sends*len(str(pkt)))) |