andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 1 | #TopoPerfNext |
| 2 | # |
| 3 | #Topology Performance test for ONOS-next |
| 4 | # |
| 5 | #andrew@onlab.us |
| 6 | |
| 7 | import time |
| 8 | import sys |
| 9 | import os |
| 10 | import re |
| 11 | |
| 12 | class TopoPerfNext: |
| 13 | def __init__(self): |
| 14 | self.default = '' |
| 15 | |
| 16 | def CASE1(self, main): |
| 17 | ''' |
| 18 | ONOS startup sequence |
| 19 | ''' |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 20 | import time |
| 21 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 22 | cell_name = main.params['ENV']['cellName'] |
| 23 | |
| 24 | git_pull = main.params['GIT']['autoPull'] |
| 25 | checkout_branch = main.params['GIT']['checkout'] |
| 26 | |
| 27 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 28 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 29 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 30 | MN1_ip = main.params['MN']['ip1'] |
| 31 | BENCH_ip = main.params['BENCH']['ip'] |
| 32 | |
| 33 | main.case("Setting up test environment") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 34 | main.log.report("Setting up test environment") |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 35 | |
| 36 | main.step("Creating cell file") |
| 37 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 38 | BENCH_ip, cell_name, MN1_ip, "onos-core", |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 39 | ONOS1_ip, ONOS2_ip, ONOS3_ip) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 40 | |
| 41 | main.step("Applying cell file to environment") |
| 42 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 43 | verify_cell_result = main.ONOSbench.verify_cell() |
| 44 | |
| 45 | main.step("Git checkout and pull "+checkout_branch) |
| 46 | if git_pull == 'on': |
| 47 | checkout_result = \ |
| 48 | main.ONOSbench.git_checkout(checkout_branch) |
| 49 | pull_result = main.ONOSbench.git_pull() |
| 50 | else: |
| 51 | checkout_result = main.TRUE |
| 52 | pull_result = main.TRUE |
| 53 | main.log.info("Skipped git checkout and pull") |
| 54 | |
| 55 | main.step("Using mvn clean & install") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 56 | #mvn_result = main.ONOSbench.clean_install() |
| 57 | mvn_result = main.TRUE |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 58 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 59 | main.step("Set cell for ONOS cli env") |
| 60 | main.ONOS1cli.set_cell(cell_name) |
| 61 | main.ONOS2cli.set_cell(cell_name) |
| 62 | main.ONOS3cli.set_cell(cell_name) |
| 63 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 64 | main.step("Creating ONOS package") |
| 65 | package_result = main.ONOSbench.onos_package() |
| 66 | |
| 67 | main.step("Installing ONOS package") |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 68 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 69 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 70 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 71 | |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 72 | time.sleep(10) |
| 73 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 74 | main.step("Start onos cli") |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 75 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 76 | cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 77 | cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 78 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 79 | main.step("Enable metrics feature") |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 80 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 81 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 82 | main.ONOS3cli.feature_install("onos-app-metrics") |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 83 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 84 | utilities.assert_equals(expect=main.TRUE, |
| 85 | actual= cell_file_result and cell_apply_result and\ |
| 86 | verify_cell_result and checkout_result and\ |
| 87 | pull_result and mvn_result and\ |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 88 | install1_result and install2_result and\ |
| 89 | install3_result, |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 90 | onpass="Test Environment setup successful", |
| 91 | onfail="Failed to setup test environment") |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 92 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 93 | def CASE2(self, main): |
| 94 | ''' |
| 95 | Assign s1 to ONOS1 and measure latency |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 96 | |
| 97 | There are 4 levels of latency measurements to this test: |
| 98 | 1) End-to-end measurement: Complete end-to-end measurement |
| 99 | from TCP (SYN/ACK) handshake to Graph change |
| 100 | 2) OFP-to-graph measurement: 'ONOS processing' snippet of |
| 101 | measurement from OFP Vendor message to Graph change |
| 102 | 3) OFP-to-device measurement: 'ONOS processing without |
| 103 | graph change' snippet of measurement from OFP vendor |
| 104 | message to Device change timestamp |
| 105 | 4) T0-to-device measurement: Measurement that includes |
| 106 | the switch handshake to devices timestamp without |
| 107 | the graph view change. (TCP handshake -> Device |
| 108 | change) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 109 | ''' |
| 110 | import time |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 111 | import subprocess |
| 112 | import json |
| 113 | import requests |
| 114 | import os |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 115 | |
| 116 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 117 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 118 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 119 | ONOS_user = main.params['CTRL']['user'] |
| 120 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 121 | default_sw_port = main.params['CTRL']['port1'] |
| 122 | |
| 123 | #Number of iterations of case |
| 124 | num_iter = main.params['TEST']['numIter'] |
| 125 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 126 | #Timestamp 'keys' for json metrics output. |
| 127 | #These are subject to change, hence moved into params |
| 128 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 129 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 130 | |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 131 | debug_mode = main.params['TEST']['debugMode'] |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 132 | onos_log = main.params['TEST']['onosLogFile'] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 133 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 134 | #Threshold for the test |
| 135 | threshold_str = main.params['TEST']['singleSwThreshold'] |
| 136 | threshold_obj = threshold_str.split(",") |
| 137 | threshold_min = int(threshold_obj[0]) |
| 138 | threshold_max = int(threshold_obj[1]) |
| 139 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 140 | #List of switch add latency collected from |
| 141 | #all iterations |
| 142 | latency_end_to_end_list = [] |
| 143 | latency_ofp_to_graph_list = [] |
| 144 | latency_ofp_to_device_list = [] |
| 145 | latency_t0_to_device_list = [] |
| 146 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 147 | #Directory/file to store tshark results |
| 148 | tshark_of_output = "/tmp/tshark_of_topo.txt" |
| 149 | tshark_tcp_output = "/tmp/tshark_tcp_topo.txt" |
| 150 | |
| 151 | #String to grep in tshark output |
| 152 | tshark_tcp_string = "TCP 74 "+default_sw_port |
| 153 | tshark_of_string = "OFP 86 Vendor" |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 154 | |
| 155 | #Initialize assertion to TRUE |
| 156 | assertion = main.TRUE |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 157 | |
| 158 | local_time = time.strftime('%x %X') |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 159 | local_time = local_time.replace("/","") |
| 160 | local_time = local_time.replace(" ","_") |
| 161 | local_time = local_time.replace(":","") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 162 | if debug_mode == 'on': |
| 163 | main.ONOS1.tshark_pcap("eth0", |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 164 | "/tmp/single_sw_lat_pcap_"+local_time) |
| 165 | |
| 166 | main.log.info("TEST") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 167 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 168 | main.log.report("Latency of adding one switch") |
| 169 | |
| 170 | for i in range(0, int(num_iter)): |
| 171 | main.log.info("Starting tshark capture") |
| 172 | |
| 173 | #* TCP [ACK, SYN] is used as t0_a, the |
| 174 | # very first "exchange" between ONOS and |
| 175 | # the switch for end-to-end measurement |
| 176 | #* OFP [Stats Reply] is used for t0_b |
| 177 | # the very last OFP message between ONOS |
| 178 | # and the switch for ONOS measurement |
| 179 | main.ONOS1.tshark_grep(tshark_tcp_string, |
| 180 | tshark_tcp_output) |
| 181 | main.ONOS1.tshark_grep(tshark_of_string, |
| 182 | tshark_of_output) |
| 183 | |
| 184 | #Wait and ensure tshark is started and |
| 185 | #capturing |
| 186 | time.sleep(10) |
| 187 | |
| 188 | main.log.info("Assigning s1 to controller") |
| 189 | |
| 190 | main.Mininet1.assign_sw_controller(sw="1", |
| 191 | ip1=ONOS1_ip, port1=default_sw_port) |
| 192 | |
| 193 | #Wait and ensure switch is assigned |
| 194 | #before stopping tshark |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 195 | time.sleep(30) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 196 | |
| 197 | main.log.info("Stopping all Tshark processes") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 198 | main.ONOS1.stop_tshark() |
| 199 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 200 | #tshark output is saved in ONOS. Use subprocess |
| 201 | #to copy over files to TestON for parsing |
| 202 | main.log.info("Copying over tshark files") |
| 203 | |
| 204 | #TCP CAPTURE **** |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 205 | #Copy the tshark output from ONOS machine to |
| 206 | #TestON machine in tshark_tcp_output directory>file |
| 207 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 208 | tshark_tcp_output+" /tmp/") |
| 209 | tcp_file = open(tshark_tcp_output, 'r') |
| 210 | temp_text = tcp_file.readline() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 211 | temp_text = temp_text.split(" ") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 212 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 213 | main.log.info("Object read in from TCP capture: "+ |
| 214 | str(temp_text)) |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 215 | if len(temp_text) > 1: |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 216 | t0_tcp = float(temp_text[1])*1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 217 | else: |
| 218 | main.log.error("Tshark output file for TCP"+ |
| 219 | " returned unexpected results") |
| 220 | t0_tcp = 0 |
| 221 | assertion = main.FALSE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 222 | |
| 223 | tcp_file.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 224 | #**************** |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 225 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 226 | #OF CAPTURE **** |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 227 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 228 | tshark_of_output+" /tmp/") |
| 229 | of_file = open(tshark_of_output, 'r') |
| 230 | |
| 231 | line_ofp = "" |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 232 | #Read until last line of file |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 233 | while True: |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 234 | temp_text = of_file.readline() |
| 235 | if temp_text !='': |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 236 | line_ofp = temp_text |
| 237 | else: |
| 238 | break |
| 239 | obj = line_ofp.split(" ") |
| 240 | |
| 241 | main.log.info("Object read in from OFP capture: "+ |
| 242 | str(line_ofp)) |
| 243 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 244 | if len(line_ofp) > 1: |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 245 | t0_ofp = float(obj[1])*1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 246 | else: |
| 247 | main.log.error("Tshark output file for OFP"+ |
| 248 | " returned unexpected results") |
| 249 | t0_ofp = 0 |
| 250 | assertion = main.FALSE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 251 | |
| 252 | of_file.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 253 | #**************** |
| 254 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 255 | json_str_1 = main.ONOS1cli.topology_events_metrics() |
| 256 | json_str_2 = main.ONOS2cli.topology_events_metrics() |
| 257 | json_str_3 = main.ONOS3cli.topology_events_metrics() |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 258 | |
| 259 | json_obj_1 = json.loads(json_str_1) |
| 260 | json_obj_2 = json.loads(json_str_2) |
| 261 | json_obj_3 = json.loads(json_str_3) |
| 262 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 263 | #Obtain graph timestamp. This timestsamp captures |
| 264 | #the epoch time at which the topology graph was updated. |
| 265 | graph_timestamp_1 = \ |
| 266 | json_obj_1[graphTimestamp]['value'] |
| 267 | graph_timestamp_2 = \ |
| 268 | json_obj_2[graphTimestamp]['value'] |
| 269 | graph_timestamp_3 = \ |
| 270 | json_obj_3[graphTimestamp]['value'] |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 271 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 272 | #Obtain device timestamp. This timestamp captures |
| 273 | #the epoch time at which the device event happened |
| 274 | device_timestamp_1 = \ |
| 275 | json_obj_1[deviceTimestamp]['value'] |
| 276 | device_timestamp_2 = \ |
| 277 | json_obj_2[deviceTimestamp]['value'] |
| 278 | device_timestamp_3 = \ |
| 279 | json_obj_3[deviceTimestamp]['value'] |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 280 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 281 | #t0 to device processing latency |
| 282 | delta_device_1 = int(device_timestamp_1) - int(t0_tcp) |
| 283 | delta_device_2 = int(device_timestamp_2) - int(t0_tcp) |
| 284 | delta_device_3 = int(device_timestamp_3) - int(t0_tcp) |
| 285 | |
| 286 | #Get average of delta from all instances |
| 287 | avg_delta_device = \ |
| 288 | (int(delta_device_1)+\ |
| 289 | int(delta_device_2)+\ |
| 290 | int(delta_device_3)) / 3 |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 291 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 292 | #Ensure avg delta meets the threshold before appending |
| 293 | if avg_delta_device > 0.0 and avg_delta_device < 10000: |
| 294 | latency_t0_to_device_list.append(avg_delta_device) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 295 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 296 | main.log.info("Results for t0-to-device ignored"+\ |
| 297 | "due to excess in threshold") |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 298 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 299 | #t0 to graph processing latency (end-to-end) |
| 300 | delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp) |
| 301 | delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp) |
| 302 | delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp) |
| 303 | |
| 304 | #Get average of delta from all instances |
| 305 | avg_delta_graph = \ |
| 306 | (int(delta_graph_1)+\ |
| 307 | int(delta_graph_2)+\ |
| 308 | int(delta_graph_3)) / 3 |
| 309 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 310 | #Ensure avg delta meets the threshold before appending |
| 311 | if avg_delta_graph > 0.0 and avg_delta_graph < 10000: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 312 | latency_end_to_end_list.append(avg_delta_graph) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 313 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 314 | main.log.info("Results for end-to-end ignored"+\ |
| 315 | "due to excess in threshold") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 316 | |
| 317 | #ofp to graph processing latency (ONOS processing) |
| 318 | delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp) |
| 319 | delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp) |
| 320 | delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp) |
| 321 | |
| 322 | avg_delta_ofp_graph = \ |
| 323 | (int(delta_ofp_graph_1)+\ |
| 324 | int(delta_ofp_graph_2)+\ |
| 325 | int(delta_ofp_graph_3)) / 3 |
| 326 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 327 | if avg_delta_ofp_graph > threshold_min \ |
| 328 | and avg_delta_ofp_graph < threshold_max: |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 329 | latency_ofp_to_graph_list.append(avg_delta_ofp_graph) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 330 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 331 | main.log.info("Results for ofp-to-graph "+\ |
| 332 | "ignored due to excess in threshold") |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 333 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 334 | #ofp to device processing latency (ONOS processing) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 335 | delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp) |
| 336 | delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp) |
| 337 | delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 338 | |
| 339 | avg_delta_ofp_device = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 340 | (float(delta_ofp_device_1)+\ |
| 341 | float(delta_ofp_device_2)+\ |
| 342 | float(delta_ofp_device_3)) / 3.0 |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 343 | |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 344 | #NOTE: ofp - delta measurements are occasionally negative |
| 345 | # due to system time misalignment. |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 346 | latency_ofp_to_device_list.append(avg_delta_ofp_device) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 347 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 348 | #TODO: |
| 349 | #Fetch logs upon threshold excess |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 350 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 351 | main.log.info("ONOS1 delta end-to-end: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 352 | str(delta_graph_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 353 | main.log.info("ONOS2 delta end-to-end: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 354 | str(delta_graph_2) + " ms") |
| 355 | main.log.info("ONOS3 delta end-to-end: "+ |
| 356 | str(delta_graph_3) + " ms") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 357 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 358 | main.log.info("ONOS1 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 359 | str(delta_ofp_graph_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 360 | main.log.info("ONOS2 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 361 | str(delta_ofp_graph_2) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 362 | main.log.info("ONOS3 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 363 | str(delta_ofp_graph_3) + " ms") |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 364 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 365 | main.log.info("ONOS1 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 366 | str(delta_device_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 367 | main.log.info("ONOS2 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 368 | str(delta_device_2) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 369 | main.log.info("ONOS3 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 370 | str(delta_device_3) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 371 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 372 | #main.log.info("ONOS1 delta OFP - device: "+ |
| 373 | # str(delta_ofp_device_1) + " ms") |
| 374 | #main.log.info("ONOS2 delta OFP - device: "+ |
| 375 | # str(delta_ofp_device_2) + " ms") |
| 376 | #main.log.info("ONOS3 delta OFP - device: "+ |
| 377 | # str(delta_ofp_device_3) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 378 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 379 | main.step("Remove switch from controller") |
| 380 | main.Mininet1.delete_sw_controller("s1") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 381 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 382 | time.sleep(5) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 383 | |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 384 | #END of for loop iteration |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 385 | |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 386 | #If there is at least 1 element in each list, |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 387 | #pass the test case |
| 388 | if len(latency_end_to_end_list) > 0 and\ |
| 389 | len(latency_ofp_to_graph_list) > 0 and\ |
| 390 | len(latency_ofp_to_device_list) > 0 and\ |
| 391 | len(latency_t0_to_device_list) > 0: |
| 392 | assertion = main.TRUE |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 393 | elif len(latency_end_to_end_list) == 0: |
| 394 | #The appending of 0 here is to prevent |
| 395 | #the min,max,sum functions from failing |
| 396 | #below |
| 397 | latency_end_to_end_list.append(0) |
| 398 | assertion = main.FALSE |
| 399 | elif len(latency_ofp_to_graph_list) == 0: |
| 400 | latency_ofp_to_graph_list.append(0) |
| 401 | assertion = main.FALSE |
| 402 | elif len(latency_ofp_to_device_list) == 0: |
| 403 | latency_ofp_to_device_list.append(0) |
| 404 | assertion = main.FALSE |
| 405 | elif len(latency_t0_to_device_list) == 0: |
| 406 | latency_t0_to_device_list.append(0) |
| 407 | assertion = main.FALSE |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 408 | |
| 409 | #Calculate min, max, avg of latency lists |
| 410 | latency_end_to_end_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 411 | int(max(latency_end_to_end_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 412 | latency_end_to_end_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 413 | int(min(latency_end_to_end_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 414 | latency_end_to_end_avg = \ |
andrewonlab | c90667c | 2014-10-24 16:48:28 -0400 | [diff] [blame] | 415 | (int(sum(latency_end_to_end_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 416 | len(latency_end_to_end_list)) |
| 417 | |
| 418 | latency_ofp_to_graph_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 419 | int(max(latency_ofp_to_graph_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 420 | latency_ofp_to_graph_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 421 | int(min(latency_ofp_to_graph_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 422 | latency_ofp_to_graph_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 423 | (int(sum(latency_ofp_to_graph_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 424 | len(latency_ofp_to_graph_list)) |
| 425 | |
| 426 | latency_ofp_to_device_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 427 | int(max(latency_ofp_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 428 | latency_ofp_to_device_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 429 | int(min(latency_ofp_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 430 | latency_ofp_to_device_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 431 | (int(sum(latency_ofp_to_device_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 432 | len(latency_ofp_to_device_list)) |
| 433 | |
| 434 | latency_t0_to_device_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 435 | float(max(latency_t0_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 436 | latency_t0_to_device_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 437 | float(min(latency_t0_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 438 | latency_t0_to_device_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 439 | (float(sum(latency_t0_to_device_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 440 | len(latency_ofp_to_device_list)) |
| 441 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 442 | main.log.report("Switch add - End-to-end latency: "+\ |
| 443 | "Min: "+str(latency_end_to_end_min)+" mx "+\ |
| 444 | "Max: "+str(latency_end_to_end_max)+" ms "+\ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 445 | "Avg: "+str(latency_end_to_end_avg)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 446 | main.log.report("Switch add - OFP-to-Graph latency: "+\ |
| 447 | "Min: "+str(latency_ofp_to_graph_min)+" ms "+\ |
| 448 | "Max: "+str(latency_ofp_to_graph_max)+" ms "+\ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 449 | "Avg: "+str(latency_ofp_to_graph_avg)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 450 | main.log.report("Switch add - t0-to-Device latency: "+\ |
| 451 | "Min: "+str(latency_t0_to_device_min)+" ms"+\ |
| 452 | "Max: "+str(latency_t0_to_device_max)+" ms"+\ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 453 | "Avg: "+str(latency_t0_to_device_avg)+" ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 454 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 455 | if debug_mode == 'on': |
| 456 | main.ONOS1.cp_logs_to_dir("/opt/onos/log/karaf.log", |
| 457 | "/tmp/", copy_file_name="sw_lat_karaf") |
| 458 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 459 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 460 | onpass="Switch latency test successful", |
| 461 | onfail="Switch latency test failed") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 462 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 463 | def CASE3(self, main): |
| 464 | ''' |
| 465 | Bring port up / down and measure latency. |
| 466 | Port enable / disable is simulated by ifconfig up / down |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 467 | |
| 468 | In ONOS-next, we must ensure that the port we are |
| 469 | manipulating is connected to another switch with a valid |
| 470 | connection. Otherwise, graph view will not be updated. |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 471 | ''' |
| 472 | import time |
| 473 | import subprocess |
| 474 | import os |
| 475 | import requests |
| 476 | import json |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 477 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 478 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 479 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 480 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 481 | ONOS_user = main.params['CTRL']['user'] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 482 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 483 | default_sw_port = main.params['CTRL']['port1'] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 484 | |
| 485 | assertion = main.TRUE |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 486 | #Number of iterations of case |
| 487 | num_iter = main.params['TEST']['numIter'] |
| 488 | |
| 489 | #Timestamp 'keys' for json metrics output. |
| 490 | #These are subject to change, hence moved into params |
| 491 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 492 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 493 | |
| 494 | debug_mode = main.params['TEST']['debugMode'] |
| 495 | |
| 496 | local_time = time.strftime('%x %X') |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 497 | local_time = local_time.replace("/","") |
| 498 | local_time = local_time.replace(" ","_") |
| 499 | local_time = local_time.replace(":","") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 500 | if debug_mode == 'on': |
| 501 | main.ONOS1.tshark_pcap("eth0", |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 502 | "/tmp/port_lat_pcap_"+local_time) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 503 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 504 | #Threshold for this test case |
| 505 | up_threshold_str = main.params['TEST']['portUpThreshold'] |
| 506 | down_threshold_str = main.params['TEST']['portDownThreshold'] |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 507 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 508 | up_threshold_obj = up_threshold_str.split(",") |
| 509 | down_threshold_obj = down_threshold_str.split(",") |
| 510 | |
| 511 | up_threshold_min = int(up_threshold_obj[0]) |
| 512 | up_threshold_max = int(up_threshold_obj[1]) |
| 513 | |
| 514 | down_threshold_min = int(down_threshold_obj[0]) |
| 515 | down_threshold_max = int(down_threshold_obj[1]) |
| 516 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 517 | #NOTE: Some hardcoded variables you may need to configure |
| 518 | # besides the params |
| 519 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 520 | tshark_port_status = "OFP 130 Port Status" |
| 521 | |
| 522 | tshark_port_up = "/tmp/tshark_port_up.txt" |
| 523 | tshark_port_down = "/tmp/tshark_port_down.txt" |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 524 | interface_config = "s1-eth1" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 525 | |
| 526 | main.log.report("Port enable / disable latency") |
| 527 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 528 | main.step("Assign switches s1 and s2 to controller 1") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 529 | main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip, |
| 530 | port1=default_sw_port) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 531 | main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip, |
| 532 | port1=default_sw_port) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 533 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 534 | #Give enough time for metrics to propagate the |
| 535 | #assign controller event. Otherwise, these events may |
| 536 | #carry over to our measurements |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 537 | time.sleep(15) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 538 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 539 | port_up_device_to_ofp_list = [] |
| 540 | port_up_graph_to_ofp_list = [] |
| 541 | port_down_device_to_ofp_list = [] |
| 542 | port_down_graph_to_ofp_list = [] |
| 543 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 544 | for i in range(0, int(num_iter)): |
| 545 | main.step("Starting wireshark capture for port status down") |
| 546 | main.ONOS1.tshark_grep(tshark_port_status, |
| 547 | tshark_port_down) |
| 548 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 549 | time.sleep(5) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 550 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 551 | #Disable interface that is connected to switch 2 |
| 552 | main.step("Disable port: "+interface_config) |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 553 | main.Mininet1.handle.sendline("sh ifconfig "+ |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 554 | interface_config+" down") |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 555 | main.Mininet1.handle.expect("mininet>") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 556 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 557 | time.sleep(3) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 558 | main.ONOS1.tshark_stop() |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 559 | |
| 560 | main.step("Obtain t1 by metrics call") |
| 561 | json_str_up_1 = main.ONOS1cli.topology_events_metrics() |
| 562 | json_str_up_2 = main.ONOS2cli.topology_events_metrics() |
| 563 | json_str_up_3 = main.ONOS3cli.topology_events_metrics() |
| 564 | |
| 565 | json_obj_1 = json.loads(json_str_up_1) |
| 566 | json_obj_2 = json.loads(json_str_up_2) |
| 567 | json_obj_3 = json.loads(json_str_up_3) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 568 | |
| 569 | #Copy tshark output file from ONOS to TestON instance |
| 570 | #/tmp directory |
| 571 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 572 | tshark_port_down+" /tmp/") |
| 573 | |
| 574 | f_port_down = open(tshark_port_down, 'r') |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 575 | #Get first line of port down event from tshark |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 576 | f_line = f_port_down.readline() |
| 577 | obj_down = f_line.split(" ") |
| 578 | if len(f_line) > 0: |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 579 | timestamp_begin_pt_down = int(float(obj_down[1])*1000) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 580 | main.log.info("Port down begin timestamp: "+ |
| 581 | str(timestamp_begin_pt_down)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 582 | else: |
| 583 | main.log.info("Tshark output file returned unexpected"+ |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 584 | " results: "+str(obj_down)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 585 | timestamp_begin_pt_down = 0 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 586 | |
| 587 | f_port_down.close() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 588 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 589 | main.log.info("TEST tshark obj: "+str(obj_down)) |
| 590 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 591 | time.sleep(3) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 592 | |
| 593 | #Obtain graph timestamp. This timestsamp captures |
| 594 | #the epoch time at which the topology graph was updated. |
| 595 | graph_timestamp_1 = \ |
| 596 | json_obj_1[graphTimestamp]['value'] |
| 597 | graph_timestamp_2 = \ |
| 598 | json_obj_2[graphTimestamp]['value'] |
| 599 | graph_timestamp_3 = \ |
| 600 | json_obj_3[graphTimestamp]['value'] |
| 601 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 602 | main.log.info("TEST graph timestamp ONOS1: "+ |
| 603 | str(graph_timestamp_1)) |
| 604 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 605 | #Obtain device timestamp. This timestamp captures |
| 606 | #the epoch time at which the device event happened |
| 607 | device_timestamp_1 = \ |
| 608 | json_obj_1[deviceTimestamp]['value'] |
| 609 | device_timestamp_2 = \ |
| 610 | json_obj_2[deviceTimestamp]['value'] |
| 611 | device_timestamp_3 = \ |
| 612 | json_obj_3[deviceTimestamp]['value'] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 613 | |
| 614 | #Get delta between graph event and OFP |
| 615 | pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\ |
| 616 | int(timestamp_begin_pt_down) |
| 617 | pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\ |
| 618 | int(timestamp_begin_pt_down) |
| 619 | pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\ |
| 620 | int(timestamp_begin_pt_down) |
| 621 | |
| 622 | #Get delta between device event and OFP |
| 623 | pt_down_device_to_ofp_1 = int(device_timestamp_1) -\ |
| 624 | int(timestamp_begin_pt_down) |
| 625 | pt_down_device_to_ofp_2 = int(device_timestamp_2) -\ |
| 626 | int(timestamp_begin_pt_down) |
| 627 | pt_down_device_to_ofp_3 = int(device_timestamp_3) -\ |
| 628 | int(timestamp_begin_pt_down) |
| 629 | |
| 630 | #Caluclate average across clusters |
| 631 | pt_down_graph_to_ofp_avg =\ |
| 632 | (int(pt_down_graph_to_ofp_1) + |
| 633 | int(pt_down_graph_to_ofp_2) + |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 634 | int(pt_down_graph_to_ofp_3)) / 3 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 635 | pt_down_device_to_ofp_avg = \ |
| 636 | (int(pt_down_device_to_ofp_1) + |
| 637 | int(pt_down_device_to_ofp_2) + |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 638 | int(pt_down_device_to_ofp_3)) / 3 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 639 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 640 | if pt_down_graph_to_ofp_avg > down_threshold_min and \ |
| 641 | pt_down_graph_to_ofp_avg < down_threshold_max: |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 642 | port_down_graph_to_ofp_list.append( |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 643 | pt_down_graph_to_ofp_avg) |
| 644 | main.log.info("Port down: graph to ofp avg: "+ |
| 645 | str(pt_down_graph_to_ofp_avg) + " ms") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 646 | else: |
| 647 | main.log.info("Average port down graph-to-ofp result" + |
| 648 | " exceeded the threshold: "+ |
| 649 | str(pt_down_graph_to_ofp_avg)) |
| 650 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 651 | if pt_down_device_to_ofp_avg > 0 and \ |
| 652 | pt_down_device_to_ofp_avg < 1000: |
| 653 | port_down_device_to_ofp_list.append( |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 654 | pt_down_device_to_ofp_avg) |
| 655 | main.log.info("Port down: device to ofp avg: "+ |
| 656 | str(pt_down_device_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 657 | else: |
| 658 | main.log.info("Average port down device-to-ofp result" + |
| 659 | " exceeded the threshold: "+ |
| 660 | str(pt_down_device_to_ofp_avg)) |
| 661 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 662 | #Port up events |
| 663 | main.step("Enable port and obtain timestamp") |
| 664 | main.step("Starting wireshark capture for port status up") |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 665 | main.ONOS1.tshark_grep(tshark_port_status, tshark_port_up) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 666 | time.sleep(5) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 667 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 668 | main.Mininet1.handle.sendline("sh ifconfig "+ |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 669 | interface_config+" up") |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 670 | main.Mininet1.handle.expect("mininet>") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 671 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 672 | #Allow time for tshark to capture event |
| 673 | time.sleep(3) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 674 | main.ONOS1.tshark_stop() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 675 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 676 | #Obtain metrics shortly afterwards |
| 677 | #This timestsamp captures |
| 678 | #the epoch time at which the topology graph was updated. |
| 679 | main.step("Obtain t1 by REST call") |
| 680 | json_str_up_1 = main.ONOS1cli.topology_events_metrics() |
| 681 | json_str_up_2 = main.ONOS2cli.topology_events_metrics() |
| 682 | json_str_up_3 = main.ONOS3cli.topology_events_metrics() |
| 683 | |
| 684 | json_obj_1 = json.loads(json_str_up_1) |
| 685 | json_obj_2 = json.loads(json_str_up_2) |
| 686 | json_obj_3 = json.loads(json_str_up_3) |
| 687 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 688 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 689 | tshark_port_up+" /tmp/") |
| 690 | |
| 691 | f_port_up = open(tshark_port_up, 'r') |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 692 | f_line = f_port_up.readline() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 693 | obj_up = f_line.split(" ") |
| 694 | if len(f_line) > 0: |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 695 | timestamp_begin_pt_up = int(float(obj_up[1])*1000) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 696 | main.log.info("Port up begin timestamp: "+ |
| 697 | str(timestamp_begin_pt_up)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 698 | else: |
| 699 | main.log.info("Tshark output file returned unexpected"+ |
| 700 | " results.") |
| 701 | timestamp_begin_pt_up = 0 |
| 702 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 703 | f_port_up.close() |
| 704 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 705 | graph_timestamp_1 = \ |
| 706 | json_obj_1[graphTimestamp]['value'] |
| 707 | graph_timestamp_2 = \ |
| 708 | json_obj_2[graphTimestamp]['value'] |
| 709 | graph_timestamp_3 = \ |
| 710 | json_obj_3[graphTimestamp]['value'] |
| 711 | |
| 712 | #Obtain device timestamp. This timestamp captures |
| 713 | #the epoch time at which the device event happened |
| 714 | device_timestamp_1 = \ |
| 715 | json_obj_1[deviceTimestamp]['value'] |
| 716 | device_timestamp_2 = \ |
| 717 | json_obj_2[deviceTimestamp]['value'] |
| 718 | device_timestamp_3 = \ |
| 719 | json_obj_3[deviceTimestamp]['value'] |
| 720 | |
| 721 | #Get delta between graph event and OFP |
| 722 | pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 723 | int(timestamp_begin_pt_up) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 724 | pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 725 | int(timestamp_begin_pt_up) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 726 | pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\ |
| 727 | int(timestamp_begin_pt_up) |
| 728 | |
| 729 | #Get delta between device event and OFP |
| 730 | pt_up_device_to_ofp_1 = int(device_timestamp_1) -\ |
| 731 | int(timestamp_begin_pt_up) |
| 732 | pt_up_device_to_ofp_2 = int(device_timestamp_2) -\ |
| 733 | int(timestamp_begin_pt_up) |
| 734 | pt_up_device_to_ofp_3 = int(device_timestamp_3) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 735 | int(timestamp_begin_pt_up) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 736 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 737 | main.log.info("ONOS1 delta G2O: "+str(pt_up_graph_to_ofp_1)) |
| 738 | main.log.info("ONOS2 delta G2O: "+str(pt_up_graph_to_ofp_2)) |
| 739 | main.log.info("ONOS3 delta G2O: "+str(pt_up_graph_to_ofp_3)) |
| 740 | |
| 741 | main.log.info("ONOS1 delta D2O: "+str(pt_up_device_to_ofp_1)) |
| 742 | main.log.info("ONOS2 delta D2O: "+str(pt_up_device_to_ofp_2)) |
| 743 | main.log.info("ONOS3 delta D2O: "+str(pt_up_device_to_ofp_3)) |
| 744 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 745 | pt_up_graph_to_ofp_avg = \ |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 746 | (int(pt_up_graph_to_ofp_1) + |
| 747 | int(pt_up_graph_to_ofp_2) + |
| 748 | int(pt_up_graph_to_ofp_3)) / 3 |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 749 | |
| 750 | pt_up_device_to_ofp_avg = \ |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 751 | (int(pt_up_device_to_ofp_1) + |
| 752 | int(pt_up_device_to_ofp_2) + |
| 753 | int(pt_up_device_to_ofp_3)) / 3 |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 754 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 755 | if pt_up_graph_to_ofp_avg > up_threshold_min and \ |
| 756 | pt_up_graph_to_ofp_avg < up_threshold_max: |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 757 | port_up_graph_to_ofp_list.append( |
| 758 | pt_up_graph_to_ofp_avg) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 759 | main.log.info("Port down: graph to ofp avg: "+ |
| 760 | str(pt_up_graph_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 761 | else: |
| 762 | main.log.info("Average port up graph-to-ofp result"+ |
| 763 | " exceeded the threshold: "+ |
| 764 | str(pt_up_graph_to_ofp_avg)) |
| 765 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 766 | if pt_up_device_to_ofp_avg > up_threshold_min and \ |
| 767 | pt_up_device_to_ofp_avg < up_threshold_max: |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 768 | port_up_device_to_ofp_list.append( |
| 769 | pt_up_device_to_ofp_avg) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 770 | main.log.info("Port up: device to ofp avg: "+ |
| 771 | str(pt_up_device_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 772 | else: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 773 | main.log.info("Average port up device-to-ofp result"+ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 774 | " exceeded the threshold: "+ |
| 775 | str(pt_up_device_to_ofp_avg)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 776 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 777 | #END ITERATION FOR LOOP |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 778 | |
| 779 | #Check all list for latency existence and set assertion |
| 780 | if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\ |
| 781 | and port_up_graph_to_ofp_list and port_up_device_to_ofp_list): |
| 782 | assertion = main.TRUE |
| 783 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 784 | #Calculate and report latency measurements |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 785 | port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list) |
| 786 | port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list) |
| 787 | port_down_graph_to_ofp_avg = \ |
| 788 | (sum(port_down_graph_to_ofp_list) / |
| 789 | len(port_down_graph_to_ofp_list)) |
| 790 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 791 | main.log.report("Port down graph-to-ofp Min: "+ |
| 792 | str(port_down_graph_to_ofp_min)+" ms Max: "+ |
| 793 | str(port_down_graph_to_ofp_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 794 | str(port_down_graph_to_ofp_avg)+" ms") |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 795 | |
| 796 | port_down_device_to_ofp_min = min(port_down_device_to_ofp_list) |
| 797 | port_down_device_to_ofp_max = max(port_down_device_to_ofp_list) |
| 798 | port_down_device_to_ofp_avg = \ |
| 799 | (sum(port_down_device_to_ofp_list) /\ |
| 800 | len(port_down_device_to_ofp_list)) |
| 801 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 802 | main.log.report("Port down device-to-ofp Min: "+ |
| 803 | str(port_down_device_to_ofp_min)+" ms Max: "+ |
| 804 | str(port_down_device_to_ofp_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 805 | str(port_down_device_to_ofp_avg)+" ms") |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 806 | |
| 807 | port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list) |
| 808 | port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list) |
| 809 | port_up_graph_to_ofp_avg = \ |
| 810 | (sum(port_up_graph_to_ofp_list) /\ |
| 811 | len(port_up_graph_to_ofp_list)) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 812 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 813 | main.log.report("Port up graph-to-ofp Min: "+ |
| 814 | str(port_up_graph_to_ofp_min)+" ms Max: "+ |
| 815 | str(port_up_graph_to_ofp_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 816 | str(port_up_graph_to_ofp_avg)+" ms") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 817 | |
| 818 | port_up_device_to_ofp_min = min(port_up_device_to_ofp_list) |
| 819 | port_up_device_to_ofp_max = max(port_up_device_to_ofp_list) |
| 820 | port_up_device_to_ofp_avg = \ |
| 821 | (sum(port_up_device_to_ofp_list) /\ |
| 822 | len(port_up_device_to_ofp_list)) |
| 823 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 824 | main.log.report("Port up device-to-ofp Min: "+ |
| 825 | str(port_up_device_to_ofp_min)+" ms Max: "+ |
| 826 | str(port_up_device_to_ofp_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 827 | str(port_up_device_to_ofp_avg)+" ms") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 828 | |
| 829 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 830 | onpass="Port discovery latency calculation successful", |
| 831 | onfail="Port discovery test failed") |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 832 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 833 | def CASE4(self, main): |
| 834 | ''' |
| 835 | Link down event using loss rate 100% |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 836 | |
| 837 | Important: |
| 838 | Use a simple 2 switch topology with 1 link between |
| 839 | the two switches. Ensure that mac addresses of the |
| 840 | switches are 1 / 2 respectively |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 841 | ''' |
| 842 | import time |
| 843 | import subprocess |
| 844 | import os |
| 845 | import requests |
| 846 | import json |
| 847 | |
| 848 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 849 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 850 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 851 | ONOS_user = main.params['CTRL']['user'] |
| 852 | |
| 853 | default_sw_port = main.params['CTRL']['port1'] |
| 854 | |
| 855 | #Number of iterations of case |
| 856 | num_iter = main.params['TEST']['numIter'] |
| 857 | |
| 858 | #Timestamp 'keys' for json metrics output. |
| 859 | #These are subject to change, hence moved into params |
| 860 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 861 | linkTimestamp = main.params['JSON']['linkTimestamp'] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 862 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 863 | |
| 864 | debug_mode = main.params['TEST']['debugMode'] |
| 865 | |
| 866 | local_time = time.strftime('%x %X') |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 867 | local_time = local_time.replace("/","") |
| 868 | local_time = local_time.replace(" ","_") |
| 869 | local_time = local_time.replace(":","") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 870 | if debug_mode == 'on': |
| 871 | main.ONOS1.tshark_pcap("eth0", |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 872 | "/tmp/link_lat_pcap_"+local_time) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 873 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 874 | #Threshold for this test case |
| 875 | up_threshold_str = main.params['TEST']['linkUpThreshold'] |
| 876 | down_threshold_str = main.params['TEST']['linkDownThreshold'] |
| 877 | |
| 878 | up_threshold_obj = up_threshold_str.split(",") |
| 879 | down_threshold_obj = down_threshold_str.split(",") |
| 880 | |
| 881 | up_threshold_min = int(up_threshold_obj[0]) |
| 882 | up_threshold_max = int(up_threshold_obj[1]) |
| 883 | |
| 884 | down_threshold_min = int(down_threshold_obj[0]) |
| 885 | down_threshold_max = int(down_threshold_obj[1]) |
| 886 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 887 | assertion = main.TRUE |
| 888 | #Link event timestamp to system time list |
| 889 | link_down_link_to_system_list = [] |
| 890 | link_up_link_to_system_list = [] |
| 891 | #Graph event timestamp to system time list |
| 892 | link_down_graph_to_system_list = [] |
| 893 | link_up_graph_to_system_list = [] |
| 894 | |
| 895 | main.log.report("Add / remove link latency between "+ |
| 896 | "two switches") |
| 897 | |
| 898 | main.step("Assign all switches") |
| 899 | main.Mininet1.assign_sw_controller(sw="1", |
| 900 | ip1=ONOS1_ip, port1=default_sw_port) |
| 901 | main.Mininet1.assign_sw_controller(sw="2", |
| 902 | ip1=ONOS1_ip, port1=default_sw_port) |
| 903 | |
| 904 | main.step("Verifying switch assignment") |
| 905 | result_s1 = main.Mininet1.get_sw_controller(sw="s1") |
| 906 | result_s2 = main.Mininet1.get_sw_controller(sw="s2") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 907 | |
| 908 | #Allow time for events to finish before taking measurements |
| 909 | time.sleep(10) |
| 910 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 911 | link_down1 = False |
| 912 | link_down2 = False |
| 913 | link_down3 = False |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 914 | #Start iteration of link event test |
| 915 | for i in range(0, int(num_iter)): |
| 916 | main.step("Getting initial system time as t0") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 917 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 918 | timestamp_link_down_t0 = time.time() * 1000 |
| 919 | #Link down is simulated by 100% loss rate using traffic |
| 920 | #control command |
| 921 | main.Mininet1.handle.sendline( |
| 922 | "sh tc qdisc add dev s1-eth1 root netem loss 100%") |
| 923 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 924 | #TODO: Iterate through 'links' command to verify that |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 925 | # link s1 -> s2 went down (loop timeout 30 seconds) |
| 926 | # on all 3 ONOS instances |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 927 | main.log.info("Checking ONOS for link update") |
| 928 | loop_count = 0 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 929 | while( not (link_down1 and link_down2 and link_down3)\ |
| 930 | and loop_count < 30 ): |
| 931 | json_str1 = main.ONOS1cli.links() |
| 932 | json_str2 = main.ONOS2cli.links() |
| 933 | json_str3 = main.ONOS3cli.links() |
| 934 | |
| 935 | if not (json_str1 and json_str2 and json_str3): |
| 936 | main.log.error("CLI command returned error ") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 937 | break |
| 938 | else: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 939 | json_obj1 = json.loads(json_str1) |
| 940 | json_obj2 = json.loads(json_str2) |
| 941 | json_obj3 = json.loads(json_str3) |
| 942 | for obj1 in json_obj1: |
| 943 | if '01' not in obj1['src']['device']: |
| 944 | link_down1 = True |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 945 | main.log.info("Link down from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 946 | "s1 -> s2 on ONOS1 detected") |
| 947 | for obj2 in json_obj2: |
| 948 | if '01' not in obj2['src']['device']: |
| 949 | link_down2 = True |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 950 | main.log.info("Link down from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 951 | "s1 -> s2 on ONOS2 detected") |
| 952 | for obj3 in json_obj3: |
| 953 | if '01' not in obj3['src']['device']: |
| 954 | link_down3 = True |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 955 | main.log.info("Link down from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 956 | "s1 -> s2 on ONOS3 detected") |
| 957 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 958 | loop_count += 1 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 959 | #If CLI doesn't like the continuous requests |
| 960 | #and exits in this loop, increase the sleep here. |
| 961 | #Consequently, while loop timeout will increase |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 962 | time.sleep(1) |
| 963 | |
| 964 | #Give time for metrics measurement to catch up |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 965 | #NOTE: May need to be configured more accurately |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 966 | time.sleep(10) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 967 | #If we exited the while loop and link down 1,2,3 are still |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 968 | #false, then ONOS has failed to discover link down event |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 969 | if not (link_down1 and link_down2 and link_down3): |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 970 | main.log.info("Link down discovery failed") |
| 971 | |
| 972 | link_down_lat_graph1 = 0 |
| 973 | link_down_lat_graph2 = 0 |
| 974 | link_down_lat_graph3 = 0 |
| 975 | link_down_lat_device1 = 0 |
| 976 | link_down_lat_device2 = 0 |
| 977 | link_down_lat_device3 = 0 |
| 978 | |
| 979 | assertion = main.FALSE |
| 980 | else: |
| 981 | json_topo_metrics_1 =\ |
| 982 | main.ONOS1cli.topology_events_metrics() |
| 983 | json_topo_metrics_2 =\ |
| 984 | main.ONOS2cli.topology_events_metrics() |
| 985 | json_topo_metrics_3 =\ |
| 986 | main.ONOS3cli.topology_events_metrics() |
| 987 | json_topo_metrics_1 = json.loads(json_topo_metrics_1) |
| 988 | json_topo_metrics_2 = json.loads(json_topo_metrics_2) |
| 989 | json_topo_metrics_3 = json.loads(json_topo_metrics_3) |
| 990 | |
| 991 | main.log.info("Obtaining graph and device timestamp") |
| 992 | graph_timestamp_1 = \ |
| 993 | json_topo_metrics_1[graphTimestamp]['value'] |
| 994 | graph_timestamp_2 = \ |
| 995 | json_topo_metrics_2[graphTimestamp]['value'] |
| 996 | graph_timestamp_3 = \ |
| 997 | json_topo_metrics_3[graphTimestamp]['value'] |
| 998 | |
| 999 | link_timestamp_1 = \ |
| 1000 | json_topo_metrics_1[linkTimestamp]['value'] |
| 1001 | link_timestamp_2 = \ |
| 1002 | json_topo_metrics_2[linkTimestamp]['value'] |
| 1003 | link_timestamp_3 = \ |
| 1004 | json_topo_metrics_3[linkTimestamp]['value'] |
| 1005 | |
| 1006 | if graph_timestamp_1 and graph_timestamp_2 and\ |
| 1007 | graph_timestamp_3 and link_timestamp_1 and\ |
| 1008 | link_timestamp_2 and link_timestamp_3: |
| 1009 | link_down_lat_graph1 = int(graph_timestamp_1) -\ |
| 1010 | timestamp_link_down_t0 |
| 1011 | link_down_lat_graph2 = int(graph_timestamp_2) -\ |
| 1012 | timestamp_link_down_t0 |
| 1013 | link_down_lat_graph3 = int(graph_timestamp_3) -\ |
| 1014 | timestamp_link_down_t0 |
| 1015 | |
| 1016 | link_down_lat_link1 = int(link_timestamp_1) -\ |
| 1017 | timestamp_link_down_t0 |
| 1018 | link_down_lat_link2 = int(link_timestamp_2) -\ |
| 1019 | timestamp_link_down_t0 |
| 1020 | link_down_lat_link3 = int(link_timestamp_3) -\ |
| 1021 | timestamp_link_down_t0 |
| 1022 | else: |
| 1023 | main.log.error("There was an error calculating"+ |
| 1024 | " the delta for link down event") |
| 1025 | link_down_lat_graph1 = 0 |
| 1026 | link_down_lat_graph2 = 0 |
| 1027 | link_down_lat_graph3 = 0 |
| 1028 | |
| 1029 | link_down_lat_device1 = 0 |
| 1030 | link_down_lat_device2 = 0 |
| 1031 | link_down_lat_device3 = 0 |
| 1032 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1033 | main.log.info("Link down latency ONOS1 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1034 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1035 | str(link_down_lat_graph1)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1036 | main.log.info("Link down latency ONOS2 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1037 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1038 | str(link_down_lat_graph2)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1039 | main.log.info("Link down latency ONOS3 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1040 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1041 | str(link_down_lat_graph3)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1042 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1043 | main.log.info("Link down latency ONOS1 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1044 | str(i)+" (link-event-to-system-timestamp): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1045 | str(link_down_lat_link1)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1046 | main.log.info("Link down latency ONOS2 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1047 | str(i)+" (link-event-to-system-timestamp): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1048 | str(link_down_lat_link2)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1049 | main.log.info("Link down latency ONOS3 iteration "+ |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1050 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1051 | str(link_down_lat_link3)) |
| 1052 | |
| 1053 | #Calculate avg of node calculations |
| 1054 | link_down_lat_graph_avg =\ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1055 | (link_down_lat_graph1 + |
| 1056 | link_down_lat_graph2 + |
| 1057 | link_down_lat_graph3) / 3.0 |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1058 | link_down_lat_link_avg =\ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1059 | (link_down_lat_link1 + |
| 1060 | link_down_lat_link2 + |
| 1061 | link_down_lat_link3) / 3.0 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1062 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1063 | #Set threshold and append latency to list |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1064 | if link_down_lat_graph_avg > down_threshold_min and\ |
| 1065 | link_down_lat_graph_avg < down_threshold_max: |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1066 | link_down_graph_to_system_list.append( |
| 1067 | link_down_lat_graph_avg) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1068 | else: |
| 1069 | main.log.info("Link down latency exceeded threshold") |
| 1070 | main.log.info("Results for iteration "+str(i)+ |
| 1071 | "have been omitted") |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1072 | if link_down_lat_link_avg > down_threshold_min and\ |
| 1073 | link_down_lat_link_avg < down_threshold_max: |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1074 | link_down_link_to_system_list.append( |
| 1075 | link_down_lat_link_avg) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1076 | else: |
| 1077 | main.log.info("Link down latency exceeded threshold") |
| 1078 | main.log.info("Results for iteration "+str(i)+ |
| 1079 | "have been omitted") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1080 | |
| 1081 | #NOTE: To remove loss rate and measure latency: |
| 1082 | # 'sh tc qdisc del dev s1-eth1 root' |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1083 | timestamp_link_up_t0 = time.time() * 1000 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1084 | main.Mininet1.handle.sendline("sh tc qdisc del dev "+ |
| 1085 | "s1-eth1 root") |
| 1086 | main.Mininet1.handle.expect("mininet>") |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1087 | |
| 1088 | main.log.info("Checking ONOS for link update") |
| 1089 | |
| 1090 | link_down1 = True |
| 1091 | link_down2 = True |
| 1092 | link_down3 = True |
| 1093 | loop_count = 0 |
| 1094 | while( (link_down1 and link_down2 and link_down3)\ |
| 1095 | and loop_count < 30 ): |
| 1096 | json_str1 = main.ONOS1cli.links() |
| 1097 | json_str2 = main.ONOS2cli.links() |
| 1098 | json_str3 = main.ONOS3cli.links() |
| 1099 | if not (json_str1 and json_str2 and json_str3): |
| 1100 | main.log.error("CLI command returned error ") |
| 1101 | break |
| 1102 | else: |
| 1103 | json_obj1 = json.loads(json_str1) |
| 1104 | json_obj2 = json.loads(json_str2) |
| 1105 | json_obj3 = json.loads(json_str3) |
| 1106 | |
| 1107 | for obj1 in json_obj1: |
| 1108 | if '01' in obj1['src']['device']: |
| 1109 | link_down1 = False |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1110 | main.log.info("Link up from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1111 | "s1 -> s2 on ONOS1 detected") |
| 1112 | for obj2 in json_obj2: |
| 1113 | if '01' in obj2['src']['device']: |
| 1114 | link_down2 = False |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1115 | main.log.info("Link up from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1116 | "s1 -> s2 on ONOS2 detected") |
| 1117 | for obj3 in json_obj3: |
| 1118 | if '01' in obj3['src']['device']: |
| 1119 | link_down3 = False |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1120 | main.log.info("Link up from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1121 | "s1 -> s2 on ONOS3 detected") |
| 1122 | |
| 1123 | loop_count += 1 |
| 1124 | time.sleep(1) |
| 1125 | |
| 1126 | if (link_down1 and link_down2 and link_down3): |
| 1127 | main.log.info("Link up discovery failed") |
| 1128 | |
| 1129 | link_up_lat_graph1 = 0 |
| 1130 | link_up_lat_graph2 = 0 |
| 1131 | link_up_lat_graph3 = 0 |
| 1132 | link_up_lat_device1 = 0 |
| 1133 | link_up_lat_device2 = 0 |
| 1134 | link_up_lat_device3 = 0 |
| 1135 | |
| 1136 | assertion = main.FALSE |
| 1137 | else: |
| 1138 | json_topo_metrics_1 =\ |
| 1139 | main.ONOS1cli.topology_events_metrics() |
| 1140 | json_topo_metrics_2 =\ |
| 1141 | main.ONOS2cli.topology_events_metrics() |
| 1142 | json_topo_metrics_3 =\ |
| 1143 | main.ONOS3cli.topology_events_metrics() |
| 1144 | json_topo_metrics_1 = json.loads(json_topo_metrics_1) |
| 1145 | json_topo_metrics_2 = json.loads(json_topo_metrics_2) |
| 1146 | json_topo_metrics_3 = json.loads(json_topo_metrics_3) |
| 1147 | |
| 1148 | main.log.info("Obtaining graph and device timestamp") |
| 1149 | graph_timestamp_1 = \ |
| 1150 | json_topo_metrics_1[graphTimestamp]['value'] |
| 1151 | graph_timestamp_2 = \ |
| 1152 | json_topo_metrics_2[graphTimestamp]['value'] |
| 1153 | graph_timestamp_3 = \ |
| 1154 | json_topo_metrics_3[graphTimestamp]['value'] |
| 1155 | |
| 1156 | link_timestamp_1 = \ |
| 1157 | json_topo_metrics_1[linkTimestamp]['value'] |
| 1158 | link_timestamp_2 = \ |
| 1159 | json_topo_metrics_2[linkTimestamp]['value'] |
| 1160 | link_timestamp_3 = \ |
| 1161 | json_topo_metrics_3[linkTimestamp]['value'] |
| 1162 | |
| 1163 | if graph_timestamp_1 and graph_timestamp_2 and\ |
| 1164 | graph_timestamp_3 and link_timestamp_1 and\ |
| 1165 | link_timestamp_2 and link_timestamp_3: |
| 1166 | link_up_lat_graph1 = int(graph_timestamp_1) -\ |
| 1167 | timestamp_link_up_t0 |
| 1168 | link_up_lat_graph2 = int(graph_timestamp_2) -\ |
| 1169 | timestamp_link_up_t0 |
| 1170 | link_up_lat_graph3 = int(graph_timestamp_3) -\ |
| 1171 | timestamp_link_up_t0 |
| 1172 | |
| 1173 | link_up_lat_link1 = int(link_timestamp_1) -\ |
| 1174 | timestamp_link_up_t0 |
| 1175 | link_up_lat_link2 = int(link_timestamp_2) -\ |
| 1176 | timestamp_link_up_t0 |
| 1177 | link_up_lat_link3 = int(link_timestamp_3) -\ |
| 1178 | timestamp_link_up_t0 |
| 1179 | else: |
| 1180 | main.log.error("There was an error calculating"+ |
| 1181 | " the delta for link down event") |
| 1182 | link_up_lat_graph1 = 0 |
| 1183 | link_up_lat_graph2 = 0 |
| 1184 | link_up_lat_graph3 = 0 |
| 1185 | |
| 1186 | link_up_lat_device1 = 0 |
| 1187 | link_up_lat_device2 = 0 |
| 1188 | link_up_lat_device3 = 0 |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1189 | |
| 1190 | if debug_mode == 'on': |
| 1191 | main.log.info("Link up latency ONOS1 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1192 | str(i)+" (end-to-end): "+ |
| 1193 | str(link_up_lat_graph1)+" ms") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1194 | main.log.info("Link up latency ONOS2 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1195 | str(i)+" (end-to-end): "+ |
| 1196 | str(link_up_lat_graph2)+" ms") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1197 | main.log.info("Link up latency ONOS3 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1198 | str(i)+" (end-to-end): "+ |
| 1199 | str(link_up_lat_graph3)+" ms") |
| 1200 | |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1201 | main.log.info("Link up latency ONOS1 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1202 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1203 | str(link_up_lat_link1)+" ms") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1204 | main.log.info("Link up latency ONOS2 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1205 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1206 | str(link_up_lat_link2)+" ms") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1207 | main.log.info("Link up latency ONOS3 iteration "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1208 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1209 | str(link_up_lat_link3)) |
| 1210 | |
| 1211 | #Calculate avg of node calculations |
| 1212 | link_up_lat_graph_avg =\ |
| 1213 | (link_up_lat_graph1 + |
| 1214 | link_up_lat_graph2 + |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1215 | link_up_lat_graph3) / 3 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1216 | link_up_lat_link_avg =\ |
| 1217 | (link_up_lat_link1 + |
| 1218 | link_up_lat_link2 + |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1219 | link_up_lat_link3) / 3 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1220 | |
| 1221 | #Set threshold and append latency to list |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1222 | if link_up_lat_graph_avg > up_threshold_min and\ |
| 1223 | link_up_lat_graph_avg < up_threshold_max: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1224 | link_up_graph_to_system_list.append( |
| 1225 | link_up_lat_graph_avg) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1226 | else: |
| 1227 | main.log.info("Link up latency exceeded threshold") |
| 1228 | main.log.info("Results for iteration "+str(i)+ |
| 1229 | "have been omitted") |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1230 | if link_up_lat_link_avg > up_threshold_min and\ |
| 1231 | link_up_lat_link_avg < up_threshold_max: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1232 | link_up_link_to_system_list.append( |
| 1233 | link_up_lat_link_avg) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1234 | else: |
| 1235 | main.log.info("Link up latency exceeded threshold") |
| 1236 | main.log.info("Results for iteration "+str(i)+ |
| 1237 | "have been omitted") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1238 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1239 | #Calculate min, max, avg of list and report |
| 1240 | link_down_min = min(link_down_graph_to_system_list) |
| 1241 | link_down_max = max(link_down_graph_to_system_list) |
| 1242 | link_down_avg = sum(link_down_graph_to_system_list) / \ |
| 1243 | len(link_down_graph_to_system_list) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1244 | link_up_min = min(link_up_graph_to_system_list) |
| 1245 | link_up_max = max(link_up_graph_to_system_list) |
| 1246 | link_up_avg = sum(link_up_graph_to_system_list) / \ |
| 1247 | len(link_up_graph_to_system_list) |
| 1248 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1249 | main.log.report("Link down latency - Min: "+ |
| 1250 | str(link_down_min)+" ms Max: "+ |
| 1251 | str(link_down_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1252 | str(link_down_avg)+" ms") |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1253 | main.log.report("Link up latency - Min: "+ |
| 1254 | str(link_up_min)+" ms Max: "+ |
| 1255 | str(link_up_max)+" ms Avg: "+ |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1256 | str(link_up_avg)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1257 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1258 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 1259 | onpass="Link discovery latency calculation successful", |
| 1260 | onfail="Link discovery latency case failed") |
| 1261 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1262 | def CASE5(self, main): |
| 1263 | ''' |
| 1264 | 100 Switch discovery latency |
| 1265 | |
| 1266 | Important: |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1267 | This test case can be potentially dangerous if |
| 1268 | your machine has previously set iptables rules. |
| 1269 | One of the steps of the test case will flush |
| 1270 | all existing iptables rules. |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1271 | Note: |
| 1272 | You can specify the number of switches in the |
| 1273 | params file to adjust the switch discovery size |
| 1274 | (and specify the corresponding topology in Mininet1 |
| 1275 | .topo file) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1276 | ''' |
| 1277 | import time |
| 1278 | import subprocess |
| 1279 | import os |
| 1280 | import requests |
| 1281 | import json |
| 1282 | |
| 1283 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 1284 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 1285 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 1286 | MN1_ip = main.params['MN']['ip1'] |
| 1287 | ONOS_user = main.params['CTRL']['user'] |
| 1288 | |
| 1289 | default_sw_port = main.params['CTRL']['port1'] |
| 1290 | |
| 1291 | #Number of iterations of case |
| 1292 | num_iter = main.params['TEST']['numIter'] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1293 | num_sw = main.params['TEST']['numSwitch'] |
| 1294 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1295 | #Timestamp 'keys' for json metrics output. |
| 1296 | #These are subject to change, hence moved into params |
| 1297 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1298 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1299 | |
| 1300 | debug_mode = main.params['TEST']['debugMode'] |
| 1301 | |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 1302 | local_time = time.strftime('%X') |
| 1303 | local_time = local_time.replace("/","") |
| 1304 | local_time = local_time.replace(" ","_") |
| 1305 | local_time = local_time.replace(":","") |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1306 | if debug_mode == 'on': |
| 1307 | main.ONOS1.tshark_pcap("eth0", |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 1308 | "/tmp/100_sw_lat_pcap_"+local_time) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1309 | |
| 1310 | #Threshold for this test case |
| 1311 | sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold'] |
| 1312 | sw_disc_threshold_obj = sw_disc_threshold_str.split(",") |
| 1313 | sw_disc_threshold_min = int(sw_disc_threshold_obj[0]) |
| 1314 | sw_disc_threshold_max = int(sw_disc_threshold_obj[1]) |
| 1315 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1316 | tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt" |
| 1317 | tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt" |
| 1318 | |
| 1319 | tshark_ofp_result_list = [] |
| 1320 | tshark_tcp_result_list = [] |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1321 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1322 | sw_discovery_lat_list = [] |
| 1323 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1324 | main.case(num_sw+" Switch discovery latency") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1325 | main.step("Assigning all switches to ONOS1") |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1326 | for i in range(1, int(num_sw)+1): |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1327 | main.Mininet1.assign_sw_controller( |
| 1328 | sw=str(i), |
| 1329 | ip1=ONOS1_ip, |
| 1330 | port1=default_sw_port) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1331 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1332 | #Ensure that nodes are configured with ptpd |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1333 | #Just a warning message |
| 1334 | main.log.info("Please check ptpd configuration to ensure"+\ |
| 1335 | " All nodes' system times are in sync") |
| 1336 | time.sleep(5) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1337 | |
| 1338 | for i in range(0, int(num_iter)): |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 1339 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1340 | main.step("Set iptables rule to block incoming sw connections") |
| 1341 | #Set iptables rule to block incoming switch connections |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1342 | #The rule description is as follows: |
| 1343 | # Append to INPUT rule, |
| 1344 | # behavior DROP that matches following: |
| 1345 | # * packet type: tcp |
| 1346 | # * source IP: MN1_ip |
| 1347 | # * destination PORT: 6633 |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1348 | main.ONOS1.handle.sendline( |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1349 | "sudo iptables -A INPUT -p tcp -s "+MN1_ip+ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1350 | " --dport "+default_sw_port+" -j DROP") |
| 1351 | main.ONOS1.handle.expect("\$") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1352 | # Append to OUTPUT rule, |
| 1353 | # behavior DROP that matches following: |
| 1354 | # * packet type: tcp |
| 1355 | # * source IP: MN1_ip |
| 1356 | # * destination PORT: 6633 |
| 1357 | main.ONOS1.handle.sendline( |
| 1358 | "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+ |
| 1359 | " --dport "+default_sw_port+" -j DROP") |
| 1360 | main.ONOS1.handle.expect("\$") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1361 | #Give time to allow rule to take effect |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1362 | #NOTE: Sleep period may need to be configured |
| 1363 | # based on the number of switches in the topology |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1364 | main.log.info("Please wait for switch connection to "+ |
| 1365 | "time out") |
| 1366 | time.sleep(60) |
| 1367 | |
| 1368 | #Gather vendor OFP with tshark |
| 1369 | main.ONOS1.tshark_grep("OFP 86 Vendor", |
| 1370 | tshark_ofp_output) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1371 | main.ONOS1.tshark_grep("TCP 74 ", |
| 1372 | tshark_tcp_output) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1373 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1374 | #NOTE: Remove all iptables rule quickly (flush) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1375 | # Before removal, obtain TestON timestamp at which |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1376 | # removal took place |
| 1377 | # (ensuring nodes are configured via ptp) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1378 | # sudo iptables -F |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1379 | |
| 1380 | t0_system = time.time() * 1000 |
| 1381 | main.ONOS1.handle.sendline( |
| 1382 | "sudo iptables -F") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1383 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1384 | #Counter to track loop count |
| 1385 | counter_loop = 0 |
| 1386 | counter_avail1 = 0 |
| 1387 | counter_avail2 = 0 |
| 1388 | counter_avail3 = 0 |
| 1389 | onos1_dev = False |
| 1390 | onos2_dev = False |
| 1391 | onos3_dev = False |
| 1392 | while counter_loop < 60: |
| 1393 | #Continue to check devices for all device |
| 1394 | #availability. When all devices in all 3 |
| 1395 | #ONOS instances indicate that devices are available |
| 1396 | #obtain graph event timestamp for t1. |
| 1397 | device_str_obj1 = main.ONOS1cli.devices() |
| 1398 | device_str_obj2 = main.ONOS2cli.devices() |
| 1399 | device_str_obj3 = main.ONOS3cli.devices() |
| 1400 | |
| 1401 | device_json1 = json.loads(device_str_obj1) |
| 1402 | device_json2 = json.loads(device_str_obj2) |
| 1403 | device_json3 = json.loads(device_str_obj3) |
| 1404 | |
| 1405 | for device1 in device_json1: |
| 1406 | if device1['available'] == True: |
| 1407 | counter_avail1 += 1 |
| 1408 | if counter_avail1 == int(num_sw): |
| 1409 | onos1_dev = True |
| 1410 | main.log.info("All devices have been "+ |
| 1411 | "discovered on ONOS1") |
| 1412 | else: |
| 1413 | counter_avail1 = 0 |
| 1414 | for device2 in device_json2: |
| 1415 | if device2['available'] == True: |
| 1416 | counter_avail2 += 1 |
| 1417 | if counter_avail2 == int(num_sw): |
| 1418 | onos2_dev = True |
| 1419 | main.log.info("All devices have been "+ |
| 1420 | "discovered on ONOS2") |
| 1421 | else: |
| 1422 | counter_avail2 = 0 |
| 1423 | for device3 in device_json3: |
| 1424 | if device3['available'] == True: |
| 1425 | counter_avail3 += 1 |
| 1426 | if counter_avail3 == int(num_sw): |
| 1427 | onos3_dev = True |
| 1428 | main.log.info("All devices have been "+ |
| 1429 | "discovered on ONOS3") |
| 1430 | else: |
| 1431 | counter_avail3 = 0 |
| 1432 | |
| 1433 | if onos1_dev and onos2_dev and onos3_dev: |
| 1434 | main.log.info("All devices have been discovered "+ |
| 1435 | "on all ONOS instances") |
| 1436 | json_str_topology_metrics_1 =\ |
| 1437 | main.ONOS1cli.topology_events_metrics() |
| 1438 | json_str_topology_metrics_2 =\ |
| 1439 | main.ONOS2cli.topology_events_metrics() |
| 1440 | json_str_topology_metrics_3 =\ |
| 1441 | main.ONOS3cli.topology_events_metrics() |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1442 | |
| 1443 | #Exit while loop if all devices discovered |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1444 | break |
| 1445 | |
| 1446 | counter_loop += 1 |
| 1447 | #Give some time in between CLI calls |
| 1448 | #(will not affect measurement) |
| 1449 | time.sleep(3) |
| 1450 | |
| 1451 | main.ONOS1.tshark_stop() |
| 1452 | |
| 1453 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 1454 | tshark_ofp_output+" /tmp/") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1455 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 1456 | tshark_tcp_output+" /tmp/") |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1457 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1458 | #TODO: Automate OFP output analysis |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1459 | #Debug mode - print out packets captured at runtime |
| 1460 | if debug_mode == 'on': |
| 1461 | ofp_file = open(tshark_ofp_output, 'r') |
| 1462 | main.log.info("Tshark OFP Vendor output: ") |
| 1463 | for line in ofp_file: |
| 1464 | tshark_ofp_result_list.append(line) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1465 | main.log.info(line) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1466 | ofp_file.close() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1467 | |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1468 | tcp_file = open(tshark_tcp_output, 'r') |
| 1469 | main.log.info("Tshark TCP 74 output: ") |
| 1470 | for line in tcp_file: |
| 1471 | tshark_tcp_result_list.append(line) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1472 | main.log.info(line) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1473 | tcp_file.close() |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1474 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1475 | json_obj_1 = json.loads(json_str_topology_metrics_1) |
| 1476 | json_obj_2 = json.loads(json_str_topology_metrics_2) |
| 1477 | json_obj_3 = json.loads(json_str_topology_metrics_3) |
| 1478 | |
| 1479 | graph_timestamp_1 = \ |
| 1480 | json_obj_1[graphTimestamp]['value'] |
| 1481 | graph_timestamp_2 = \ |
| 1482 | json_obj_2[graphTimestamp]['value'] |
| 1483 | graph_timestamp_3 = \ |
| 1484 | json_obj_3[graphTimestamp]['value'] |
| 1485 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1486 | graph_lat_1 = int(graph_timestamp_1) - int(t0_system) |
| 1487 | graph_lat_2 = int(graph_timestamp_2) - int(t0_system) |
| 1488 | graph_lat_3 = int(graph_timestamp_3) - int(t0_system) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1489 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1490 | avg_graph_lat = \ |
| 1491 | (int(graph_lat_1) +\ |
| 1492 | int(graph_lat_2) +\ |
| 1493 | int(graph_lat_3)) / 3 |
| 1494 | |
| 1495 | if avg_graph_lat > sw_disc_threshold_min \ |
| 1496 | and avg_graph_lat < sw_disc_threshold_max: |
| 1497 | sw_discovery_lat_list.append( |
| 1498 | avg_graph_lat) |
| 1499 | else: |
| 1500 | main.log.info("100 Switch discovery latency "+ |
| 1501 | "exceeded the threshold.") |
| 1502 | |
| 1503 | #END ITERATION FOR LOOP |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1504 | |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1505 | sw_lat_min = min(sw_discovery_lat_list) |
| 1506 | sw_lat_max = max(sw_discovery_lat_list) |
| 1507 | sw_lat_avg = sum(sw_discovery_lat_list) /\ |
| 1508 | len(sw_discovery_lat_list) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1509 | |
andrewonlab | f9828f0 | 2014-11-10 14:50:27 -0500 | [diff] [blame^] | 1510 | main.log.report("100 Switch discovery lat "+\ |
| 1511 | "Min: "+str(sw_lat_min)+" ms"+\ |
| 1512 | "Max: "+str(sw_lat_max)+" ms"+\ |
| 1513 | "Avg: "+str(sw_lat_avg)+" ms") |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1514 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1515 | |