andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1 | # TopoPerfNext |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 2 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 3 | # Topology Performance test for ONOS-next |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 4 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 5 | # andrew@onlab.us |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 6 | # |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 7 | # If your machine does not come with numpy |
| 8 | # run the following command: |
| 9 | # sudo apt-get install python-numpy python-scipy |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 10 | |
| 11 | import time |
| 12 | import sys |
| 13 | import os |
| 14 | import re |
| 15 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 16 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 17 | class TopoPerfNext: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 18 | |
| 19 | def __init__( self ): |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 20 | self.default = '' |
| 21 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 22 | def CASE1( self, main ): |
| 23 | """ |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 24 | ONOS startup sequence |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 25 | """ |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 26 | import time |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 27 | |
| 28 | # Global cluster count for scale-out purposes |
| 29 | global clusterCount |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 30 | #TODO: fix run number implementation |
| 31 | global runNum |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 32 | # Set initial cluster count |
| 33 | clusterCount = 1 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 34 | ## |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 35 | |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 36 | runNum = time.strftime("%d%H%M%S") |
| 37 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 38 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 39 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 40 | gitPull = main.params[ 'GIT' ][ 'autoPull' ] |
| 41 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 42 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 43 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 44 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 45 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 46 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 47 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 48 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 49 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 50 | |
| 51 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 52 | BENCHIp = main.params[ 'BENCH' ][ 'ip' ] |
| 53 | |
| 54 | topoCfgFile = main.params[ 'TEST' ][ 'topoConfigFile' ] |
| 55 | topoCfgName = main.params[ 'TEST' ][ 'topoConfigName' ] |
| 56 | |
| 57 | mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 58 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 59 | main.case( "Setting up test environment" ) |
| 60 | main.log.info( "Copying topology event accumulator config" + |
| 61 | " to ONOS /package/etc" ) |
| 62 | main.ONOSbench.handle.sendline( "cp ~/" + |
| 63 | topoCfgFile + |
| 64 | " ~/ONOS/tools/package/etc/" + |
| 65 | topoCfgName ) |
| 66 | main.ONOSbench.handle.expect( "\$" ) |
andrewonlab | 6c8bbeb | 2014-11-14 12:43:48 -0500 | [diff] [blame] | 67 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 68 | main.log.report( "Setting up test environment" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 69 | |
andrewonlab | 5b954b0 | 2015-02-05 13:03:46 -0500 | [diff] [blame] | 70 | main.step( "Starting mininet topology " ) |
| 71 | main.Mininet1.startNet() |
| 72 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 73 | main.step( "Cleaning previously installed ONOS if any" ) |
| 74 | main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip ) |
| 75 | main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip ) |
| 76 | main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip ) |
| 77 | main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip ) |
| 78 | main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip ) |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 79 | main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip ) |
andrewonlab | 0e1825c | 2014-11-20 20:07:00 -0500 | [diff] [blame] | 80 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 81 | main.step( "Creating cell file" ) |
| 82 | cellFileResult = main.ONOSbench.createCellFile( |
| 83 | BENCHIp, cellName, MN1Ip, |
| 84 | "onos-core,onos-app-metrics,onos-app-gui", |
| 85 | ONOS1Ip ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 86 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 87 | main.step( "Applying cell file to environment" ) |
| 88 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 89 | verifyCellResult = main.ONOSbench.verifyCell() |
andrewonlab | 6c8bbeb | 2014-11-14 12:43:48 -0500 | [diff] [blame] | 90 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 91 | # NOTE: This step may be removed after proper |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 92 | # copy cat log functionality |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 93 | main.step( "Removing raft/copy-cat logs from ONOS nodes" ) |
| 94 | main.ONOSbench.onosRemoveRaftLogs() |
| 95 | time.sleep( 30 ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 96 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 97 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 98 | if gitPull == 'on': |
| 99 | # checkoutResult = \ |
| 100 | # main.ONOSbench.gitCheckout( checkoutBranch ) |
| 101 | checkoutResult = main.TRUE |
| 102 | pullResult = main.ONOSbench.gitPull() |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 103 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 104 | checkoutResult = main.TRUE |
| 105 | pullResult = main.TRUE |
| 106 | main.log.info( "Skipped git checkout and pull" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 107 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 108 | main.log.report( "Commit information - " ) |
| 109 | main.ONOSbench.getVersion( report=True ) |
andrewonlab | 9284434 | 2014-11-18 16:39:11 -0500 | [diff] [blame] | 110 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 111 | main.step( "Using mvn clean & install" ) |
| 112 | if mvnCleanInstall == 'on': |
| 113 | mvnResult = main.ONOSbench.cleanInstall() |
| 114 | elif mvnCleanInstall == 'off': |
| 115 | main.log.info("mci turned off by settings") |
| 116 | mvnResult = main.TRUE |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 117 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 118 | main.step( "Set cell for ONOS cli env" ) |
| 119 | main.ONOS1cli.setCell( cellName ) |
| 120 | # main.ONOS2cli.setCell( cellName ) |
| 121 | # main.ONOS3cli.setCell( cellName ) |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 122 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 123 | main.step( "Creating ONOS package" ) |
| 124 | packageResult = main.ONOSbench.onosPackage() |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 125 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 126 | main.step( "Installing ONOS package" ) |
| 127 | install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip ) |
| 128 | #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 129 | #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 130 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 131 | time.sleep( 10 ) |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 132 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 133 | main.step( "Start onos cli" ) |
| 134 | cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip ) |
| 135 | #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 136 | #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip ) |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 137 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 138 | utilities.assert_equals( expect=main.TRUE, |
| 139 | actual=cellFileResult and cellApplyResult and |
| 140 | verifyCellResult and checkoutResult and |
| 141 | pullResult and mvnResult and |
| 142 | install1Result, # and install2Result and |
| 143 | # install3Result, |
| 144 | onpass="Test Environment setup successful", |
| 145 | onfail="Failed to setup test environment" ) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 146 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 147 | def CASE2( self, main ): |
| 148 | """ |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 149 | Assign s1 to ONOS1 and measure latency |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 150 | |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 151 | There are 4 levels of latency measurements to this test: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 152 | 1 ) End-to-end measurement: Complete end-to-end measurement |
| 153 | from TCP ( SYN/ACK ) handshake to Graph change |
| 154 | 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 155 | measurement from OFP Vendor message to Graph change |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 156 | 3 ) OFP-to-device measurement: 'ONOS processing without |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 157 | graph change' snippet of measurement from OFP vendor |
| 158 | message to Device change timestamp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 159 | 4 ) T0-to-device measurement: Measurement that includes |
| 160 | the switch handshake to devices timestamp without |
| 161 | the graph view change. ( TCP handshake -> Device |
| 162 | change ) |
| 163 | """ |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 164 | import time |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 165 | import subprocess |
| 166 | import json |
| 167 | import requests |
| 168 | import os |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 169 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 170 | global clusterCount |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 171 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 172 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 173 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 174 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 175 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 176 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 177 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 178 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 179 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 180 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 4b5c8b9 | 2014-11-10 16:04:33 -0500 | [diff] [blame] | 181 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 182 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 183 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 184 | # Number of iterations of case |
| 185 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 186 | # Number of first 'x' iterations to ignore: |
| 187 | iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] ) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 188 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 189 | # Timestamp 'keys' for json metrics output. |
| 190 | # These are subject to change, hence moved into params |
| 191 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 192 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 193 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 194 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
| 195 | onosLog = main.params[ 'TEST' ][ 'onosLogFile' ] |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 196 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 197 | # Threshold for the test |
| 198 | thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ] |
| 199 | thresholdObj = thresholdStr.split( "," ) |
| 200 | thresholdMin = int( thresholdObj[ 0 ] ) |
| 201 | thresholdMax = int( thresholdObj[ 1 ] ) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 202 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 203 | # List of switch add latency collected from |
| 204 | # all iterations |
| 205 | latencyEndToEndList = [] |
| 206 | latencyOfpToGraphList = [] |
| 207 | latencyOfpToDeviceList = [] |
| 208 | latencyT0ToDeviceList = [] |
| 209 | latencyTcpToOfpList = [] |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 210 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 211 | # Initialize 2d array for [node][iteration] storage |
| 212 | endToEndLatNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
| 213 | ofpToGraphLatNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
| 214 | # tcp-to-ofp measurements are same throughout each iteration |
| 215 | tcpToOfpLatIter = [] |
| 216 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 217 | # Directory/file to store tshark results |
| 218 | tsharkOfOutput = "/tmp/tshark_of_topo.txt" |
| 219 | tsharkTcpOutput = "/tmp/tshark_tcp_topo.txt" |
| 220 | |
| 221 | # String to grep in tshark output |
| 222 | tsharkTcpString = "TCP 74 " + defaultSwPort |
| 223 | tsharkOfString = "OFP 86 Vendor" |
| 224 | |
| 225 | # Initialize assertion to TRUE |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 226 | assertion = main.TRUE |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 227 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 228 | localTime = time.strftime( '%x %X' ) |
| 229 | localTime = localTime.replace( "/", "" ) |
| 230 | localTime = localTime.replace( " ", "_" ) |
| 231 | localTime = localTime.replace( ":", "" ) |
| 232 | if debugMode == 'on': |
| 233 | main.ONOS1.tsharkPcap( "eth0", |
| 234 | "/tmp/single_sw_lat_pcap_" + localTime ) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 235 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 236 | main.log.info( "Debug mode is on" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 237 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 238 | main.log.report( "Latency of adding one switch to controller" ) |
| 239 | main.log.report( "First " + str( iterIgnore ) + " iterations ignored" + |
| 240 | " for jvm warmup time" ) |
| 241 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 242 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 243 | for i in range( 0, int( numIter ) ): |
| 244 | main.log.info( "Starting tshark capture" ) |
| 245 | |
| 246 | #* TCP [ ACK, SYN ] is used as t0A, the |
| 247 | # very first "exchange" between ONOS and |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 248 | # the switch for end-to-end measurement |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 249 | #* OFP [ Stats Reply ] is used for t0B |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 250 | # the very last OFP message between ONOS |
| 251 | # and the switch for ONOS measurement |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 252 | main.ONOS1.tsharkGrep( tsharkTcpString, |
| 253 | tsharkTcpOutput ) |
| 254 | main.ONOS1.tsharkGrep( tsharkOfString, |
| 255 | tsharkOfOutput ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 256 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 257 | # Wait and ensure tshark is started and |
| 258 | # capturing |
| 259 | time.sleep( 10 ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 260 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 261 | main.log.info( "Assigning s1 to controller" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 262 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 263 | main.Mininet1.assignSwController( |
| 264 | sw="1", |
| 265 | ip1=ONOS1Ip, |
| 266 | port1=defaultSwPort ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 267 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 268 | # Wait and ensure switch is assigned |
| 269 | # before stopping tshark |
| 270 | time.sleep( 30 ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 271 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 272 | main.log.info( "Stopping all Tshark processes" ) |
| 273 | main.ONOS1.stopTshark() |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 274 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 275 | # tshark output is saved in ONOS. Use subprocess |
| 276 | # to copy over files to TestON for parsing |
| 277 | main.log.info( "Copying over tshark files" ) |
| 278 | |
| 279 | # TCP CAPTURE **** |
| 280 | # Copy the tshark output from ONOS machine to |
| 281 | # TestON machine in tsharkTcpOutput directory>file |
| 282 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 283 | tsharkTcpOutput + " /tmp/" ) |
| 284 | tcpFile = open( tsharkTcpOutput, 'r' ) |
| 285 | tempText = tcpFile.readline() |
| 286 | tempText = tempText.split( " " ) |
| 287 | |
| 288 | main.log.info( "Object read in from TCP capture: " + |
| 289 | str( tempText ) ) |
| 290 | if len( tempText ) > 1: |
| 291 | t0Tcp = float( tempText[ 1 ] ) * 1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 292 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 293 | main.log.error( "Tshark output file for TCP" + |
| 294 | " returned unexpected results" ) |
| 295 | t0Tcp = 0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 296 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 297 | |
| 298 | tcpFile.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 299 | #**************** |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 300 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 301 | # OF CAPTURE **** |
| 302 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 303 | tsharkOfOutput + " /tmp/" ) |
| 304 | ofFile = open( tsharkOfOutput, 'r' ) |
| 305 | |
| 306 | lineOfp = "" |
| 307 | # Read until last line of file |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 308 | while True: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 309 | tempText = ofFile.readline() |
| 310 | if tempText != '': |
| 311 | lineOfp = tempText |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 312 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 313 | break |
| 314 | obj = lineOfp.split( " " ) |
| 315 | |
| 316 | main.log.info( "Object read in from OFP capture: " + |
| 317 | str( lineOfp ) ) |
| 318 | |
andrewonlab | 5b954b0 | 2015-02-05 13:03:46 -0500 | [diff] [blame] | 319 | if len( obj ) > 1: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 320 | t0Ofp = float( obj[ 1 ] ) * 1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 321 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 322 | main.log.error( "Tshark output file for OFP" + |
| 323 | " returned unexpected results" ) |
| 324 | t0Ofp = 0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 325 | assertion = main.FALSE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 326 | |
| 327 | ofFile.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 328 | #**************** |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 329 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 330 | jsonStr1 = main.ONOS1cli.topologyEventsMetrics() |
| 331 | # Initialize scale-out variables |
| 332 | jsonStr2 = "" |
| 333 | jsonStr3 = "" |
| 334 | jsonStr4 = "" |
| 335 | jsonStr5 = "" |
| 336 | jsonStr6 = "" |
| 337 | jsonStr7 = "" |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 338 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 339 | jsonObj1 = json.loads( jsonStr1 ) |
| 340 | # Initialize scale-out variables |
| 341 | jsonObj2 = "" |
| 342 | jsonObj3 = "" |
| 343 | jsonObj4 = "" |
| 344 | jsonObj5 = "" |
| 345 | jsonObj6 = "" |
| 346 | jsonObj7 = "" |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 347 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 348 | # Obtain graph timestamp. This timestsamp captures |
| 349 | # the epoch time at which the topology graph was updated. |
| 350 | graphTimestamp1 = \ |
| 351 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 352 | # Obtain device timestamp. This timestamp captures |
| 353 | # the epoch time at which the device event happened |
| 354 | deviceTimestamp1 = \ |
| 355 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 356 | |
| 357 | # t0 to device processing latency |
| 358 | deltaDevice1 = int( deviceTimestamp1 ) - int( t0Tcp ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 359 | # t0 to graph processing latency ( end-to-end ) |
| 360 | deltaGraph1 = int( graphTimestamp1 ) - int( t0Tcp ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 361 | # ofp to graph processing latency ( ONOS processing ) |
| 362 | deltaOfpGraph1 = int( graphTimestamp1 ) - int( t0Ofp ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 363 | # ofp to device processing latency ( ONOS processing ) |
| 364 | deltaOfpDevice1 = float( deviceTimestamp1 ) - float( t0Ofp ) |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 365 | # tcp to ofp processing latency ( switch connection ) |
| 366 | deltaTcpOfp1 = int(t0Ofp) - int(t0Tcp) |
| 367 | |
| 368 | if deltaTcpOfp1 > thresholdMin and deltaTcpOfp1 < thresholdMax\ |
| 369 | and i >= iterIgnore: |
| 370 | tcpToOfpLatIter.append(deltaTcpOfp1) |
| 371 | main.log.info("iter"+str(i)+" tcp-to-ofp: "+ |
| 372 | str(deltaTcpOfp1)+" ms") |
| 373 | else: |
| 374 | tcpToOfpLatIter.append(0) |
| 375 | main.log.info("iter"+str(i)+" tcp-to-ofp: "+ |
| 376 | str(deltaTcpOfp1)+" ms - ignored this iteration") |
| 377 | |
| 378 | # Store initial measurements in data array |
| 379 | #This measurement is for node 1 |
| 380 | |
| 381 | if deltaGraph1 > thresholdMin and deltaGraph1 < thresholdMax\ |
| 382 | and i >= iterIgnore: |
| 383 | endToEndLatNodeIter[0][i] = deltaGraph1 |
| 384 | main.log.info("ONOS1 iter"+str(i)+" end-to-end: "+ |
| 385 | str(deltaGraph1)+" ms") |
| 386 | else: |
| 387 | main.log.info("ONOS1 iter"+str(i)+" end-to-end: "+ |
| 388 | str(deltaGraph1)+" ms - ignored this iteration") |
| 389 | |
| 390 | |
| 391 | if deltaOfpGraph1 > thresholdMin and deltaOfpGraph1 < thresholdMax\ |
| 392 | and i >= iterIgnore: |
| 393 | ofpToGraphLatNodeIter[0][i] = deltaOfpGraph1 |
| 394 | |
| 395 | main.log.info("ONOS1 iter"+str(i)+" ofp-to-graph: "+ |
| 396 | str(deltaOfpGraph1)+" ms") |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 397 | |
| 398 | # TODO: Create even cluster number events |
| 399 | |
| 400 | # Include scale-out measurements when applicable |
| 401 | if clusterCount >= 3: |
| 402 | jsonStr2 = main.ONOS2cli.topologyEventsMetrics() |
| 403 | jsonStr3 = main.ONOS3cli.topologyEventsMetrics() |
| 404 | jsonObj2 = json.loads( jsonStr2 ) |
| 405 | jsonObj3 = json.loads( jsonStr3 ) |
| 406 | graphTimestamp2 = \ |
| 407 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 408 | graphTimestamp3 = \ |
| 409 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 410 | deviceTimestamp2 = \ |
| 411 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 412 | deviceTimestamp3 = \ |
| 413 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 414 | deltaDevice2 = int( deviceTimestamp2 ) - int( t0Tcp ) |
| 415 | deltaDevice3 = int( deviceTimestamp3 ) - int( t0Tcp ) |
| 416 | deltaGraph2 = int( graphTimestamp2 ) - int( t0Tcp ) |
| 417 | deltaGraph3 = int( graphTimestamp3 ) - int( t0Tcp ) |
| 418 | deltaOfpGraph2 = int( graphTimestamp2 ) - int( t0Ofp ) |
| 419 | deltaOfpGraph3 = int( graphTimestamp3 ) - int( t0Ofp ) |
| 420 | deltaOfpDevice2 = float( deviceTimestamp2 ) -\ |
| 421 | float( t0Ofp ) |
| 422 | deltaOfpDevice3 = float( deviceTimestamp3 ) -\ |
| 423 | float( t0Ofp ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 424 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 425 | if deltaGraph2 > thresholdMin and\ |
| 426 | deltaGraph2 < thresholdMax and i >= iterIgnore: |
| 427 | endToEndLatNodeIter[1][i] = deltaGraph2 |
| 428 | main.log.info("ONOS2 iter"+str(i)+" end-to-end: "+ |
| 429 | str(deltaGraph2)+" ms") |
| 430 | |
| 431 | if deltaOfpGraph2 > thresholdMin and\ |
| 432 | deltaOfpGraph2 < thresholdMax and i >= iterIgnore: |
| 433 | ofpToGraphLatNodeIter[1][i] = deltaOfpGraph2 |
| 434 | main.log.info("ONOS2 iter"+str(i)+" ofp-to-graph: "+ |
| 435 | str(deltaOfpGraph2)+" ms") |
| 436 | |
| 437 | if deltaGraph3 > thresholdMin and\ |
| 438 | deltaGraph3 < thresholdMax and i >= iterIgnore: |
| 439 | endToEndLatNodeIter[2][i] = deltaGraph3 |
| 440 | main.log.info("ONOS3 iter"+str(i)+" end-to-end: "+ |
| 441 | str(deltaGraph3)+" ms") |
| 442 | |
| 443 | if deltaOfpGraph3 > thresholdMin and\ |
| 444 | deltaOfpGraph3 < thresholdMax and i >= iterIgnore: |
| 445 | ofpToGraphLatNodeIter[2][i] = deltaOfpGraph3 |
| 446 | main.log.info("ONOS3 iter"+str(i)+" ofp-to-graph: "+ |
| 447 | str(deltaOfpGraph3)+" ms") |
| 448 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 449 | if clusterCount >= 5: |
| 450 | jsonStr4 = main.ONOS4cli.topologyEventsMetrics() |
| 451 | jsonStr5 = main.ONOS5cli.topologyEventsMetrics() |
| 452 | jsonObj4 = json.loads( jsonStr4 ) |
| 453 | jsonObj5 = json.loads( jsonStr5 ) |
| 454 | graphTimestamp4 = \ |
| 455 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 456 | graphTimestamp5 = \ |
| 457 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 458 | deviceTimestamp4 = \ |
| 459 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 460 | deviceTimestamp5 = \ |
| 461 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 462 | deltaDevice4 = int( deviceTimestamp4 ) - int( t0Tcp ) |
| 463 | deltaDevice5 = int( deviceTimestamp5 ) - int( t0Tcp ) |
| 464 | deltaGraph4 = int( graphTimestamp4 ) - int( t0Tcp ) |
| 465 | deltaGraph5 = int( graphTimestamp5 ) - int( t0Tcp ) |
| 466 | deltaOfpGraph4 = int( graphTimestamp4 ) - int( t0Ofp ) |
| 467 | deltaOfpGraph5 = int( graphTimestamp5 ) - int( t0Ofp ) |
| 468 | deltaOfpDevice4 = float( deviceTimestamp4 ) -\ |
| 469 | float( t0Ofp ) |
| 470 | deltaOfpDevice5 = float( deviceTimestamp5 ) -\ |
| 471 | float( t0Ofp ) |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 472 | |
| 473 | if deltaGraph4 > thresholdMin and\ |
| 474 | deltaGraph4 < thresholdMax and i >= iterIgnore: |
| 475 | endToEndLatNodeIter[3][i] = deltaGraph4 |
| 476 | main.log.info("ONOS4 iter"+str(i)+" end-to-end: "+ |
| 477 | str(deltaGraph4)+" ms") |
| 478 | |
| 479 | #TODO: |
| 480 | if deltaOfpGraph4 > thresholdMin and\ |
| 481 | deltaOfpGraph4 < thresholdMax and i >= iterIgnore: |
| 482 | ofpToGraphLatNodeIter[3][i] = deltaOfpGraph4 |
| 483 | main.log.info("ONOS4 iter"+str(i)+" ofp-to-graph: "+ |
| 484 | str(deltaOfpGraph4)+" ms") |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 485 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 486 | if deltaGraph5 > thresholdMin and\ |
| 487 | deltaGraph5 < thresholdMax and i >= iterIgnore: |
| 488 | endToEndLatNodeIter[4][i] = deltaGraph5 |
| 489 | main.log.info("ONOS5 iter"+str(i)+" end-to-end: "+ |
| 490 | str(deltaGraph5)+" ms") |
| 491 | |
| 492 | if deltaOfpGraph5 > thresholdMin and\ |
| 493 | deltaOfpGraph5 < thresholdMax and i >= iterIgnore: |
| 494 | ofpToGraphLatNodeIter[4][i] = deltaOfpGraph5 |
| 495 | main.log.info("ONOS5 iter"+str(i)+" ofp-to-graph: "+ |
| 496 | str(deltaOfpGraph5)+" ms") |
| 497 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 498 | if clusterCount >= 7: |
| 499 | jsonStr6 = main.ONOS6cli.topologyEventsMetrics() |
| 500 | jsonStr7 = main.ONOS7cli.topologyEventsMetrics() |
| 501 | jsonObj6 = json.loads( jsonStr6 ) |
| 502 | jsonObj7 = json.loads( jsonStr7 ) |
| 503 | graphTimestamp6 = \ |
| 504 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 505 | graphTimestamp7 = \ |
| 506 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 507 | deviceTimestamp6 = \ |
| 508 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 509 | deviceTimestamp7 = \ |
| 510 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 511 | deltaDevice6 = int( deviceTimestamp6 ) - int( t0Tcp ) |
| 512 | deltaDevice7 = int( deviceTimestamp7 ) - int( t0Tcp ) |
| 513 | deltaGraph6 = int( graphTimestamp6 ) - int( t0Tcp ) |
| 514 | deltaGraph7 = int( graphTimestamp7 ) - int( t0Tcp ) |
| 515 | deltaOfpGraph6 = int( graphTimestamp6 ) - int( t0Ofp ) |
| 516 | deltaOfpGraph7 = int( graphTimestamp7 ) - int( t0Ofp ) |
| 517 | deltaOfpDevice6 = float( deviceTimestamp6 ) -\ |
| 518 | float( t0Ofp ) |
| 519 | deltaOfpDevice7 = float( deviceTimestamp7 ) -\ |
| 520 | float( t0Ofp ) |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 521 | |
| 522 | if deltaGraph6 > thresholdMin and\ |
| 523 | deltaGraph6 < thresholdMax and i >= iterIgnore: |
| 524 | endToEndLatNodeIter[5][i] = deltaGraph6 |
| 525 | main.log.info("ONOS6 iter"+str(i)+" end-to-end: "+ |
| 526 | str(deltaGraph6)+" ms") |
| 527 | |
| 528 | #TODO: |
| 529 | if deltaOfpGraph6 > thresholdMin and\ |
| 530 | deltaOfpGraph6 < thresholdMax and i >= iterIgnore: |
| 531 | ofpToGraphLatNodeIter[5][i] = deltaOfpGraph6 |
| 532 | main.log.info("ONOS6 iter"+str(i)+" ofp-to-graph: "+ |
| 533 | str(deltaOfpGraph6)+" ms") |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 534 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 535 | if deltaGraph7 > thresholdMin and\ |
| 536 | deltaGraph7 < thresholdMax and i >= iterIgnore: |
| 537 | endToEndLatNodeIter[6][i] = deltaGraph7 |
| 538 | main.log.info("ONOS7 iter"+str(i)+" end-to-end: "+ |
| 539 | str(deltaGraph7)+" ms") |
| 540 | |
| 541 | if deltaOfpGraph7 > thresholdMin and\ |
| 542 | deltaOfpGraph7 < thresholdMax and i >= iterIgnore: |
| 543 | ofpToGraphLatNodeIter[6][i] = deltaOfpGraph7 |
| 544 | main.log.info("ONOS7 iter"+str(i)+" ofp-to-graph: "+ |
| 545 | str(deltaOfpGraph7)+" ms") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 546 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 547 | main.step( "Remove switch from controller" ) |
| 548 | main.Mininet1.deleteSwController( "s1" ) |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 549 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 550 | time.sleep( 5 ) |
| 551 | |
| 552 | # END of for loop iteration |
| 553 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 554 | #str( round( numpy.std( latencyT0ToDeviceList ), 1 ) ) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 555 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 556 | endToEndAvg = 0 |
| 557 | ofpToGraphAvg = 0 |
| 558 | endToEndList = [] |
| 559 | ofpToGraphList = [] |
andrewonlab | 6986416 | 2014-11-11 16:28:48 -0500 | [diff] [blame] | 560 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 561 | for node in range( 0, clusterCount ): |
| 562 | # The latency 2d array was initialized to 0. |
| 563 | # If an iteration was ignored, then we have some 0's in |
| 564 | # our calculation. To avoid having this interfere with our |
| 565 | # results, we must delete any index where 0 is found... |
| 566 | # WARN: Potentially, we could have latency that hovers at |
| 567 | # 0 ms once we have optimized code. FIXME for when this is |
| 568 | # the case. Being able to obtain sub-millisecond accuracy |
| 569 | # can prevent this from happening |
| 570 | for item in endToEndLatNodeIter[node]: |
| 571 | if item > 0.0: |
| 572 | endToEndList.append(item) |
| 573 | for item in ofpToGraphLatNodeIter[node]: |
| 574 | if item > 0.0: |
| 575 | ofpToGraphList.append(item) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 576 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 577 | endToEndAvg = numpy.mean(endToEndList) |
| 578 | ofpToGraphAvg = numpy.mean(ofpToGraphList) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 579 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 580 | main.log.report( " - Node "+str(node+1)+" Summary - " ) |
| 581 | main.log.report( " End-to-end Avg: "+ |
| 582 | str(round(endToEndAvg,2))+" ms"+ |
| 583 | " End-to-end Std dev: "+ |
| 584 | str(round(numpy.std(endToEndList),2))+" ms") |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 585 | #main.log.report( " Ofp-to-graph Avg: "+ |
| 586 | # str(round(ofpToGraphAvg,2))+" ms"+ |
| 587 | # " Ofp-to-graph Std dev: "+ |
| 588 | # str(round(numpy.std(ofpToGraphList),2))+ |
| 589 | # " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 590 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 591 | if debugMode == 'on': |
| 592 | main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log", |
| 593 | "/tmp/", copyFileName="sw_lat_karaf" ) |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 594 | |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 595 | #TODO: correct assert |
| 596 | assertion = main.TRUE |
| 597 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 598 | utilities.assert_equals( expect=main.TRUE, actual=assertion, |
| 599 | onpass="Switch latency test successful", |
| 600 | onfail="Switch latency test failed" ) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 601 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 602 | def CASE3( self, main ): |
| 603 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 604 | Bring port up / down and measure latency. |
| 605 | Port enable / disable is simulated by ifconfig up / down |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 606 | |
| 607 | In ONOS-next, we must ensure that the port we are |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 608 | manipulating is connected to another switch with a valid |
| 609 | connection. Otherwise, graph view will not be updated. |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 610 | """ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 611 | import time |
| 612 | import subprocess |
| 613 | import os |
| 614 | import requests |
| 615 | import json |
andrewonlab | 4f50ec9 | 2014-11-11 14:24:45 -0500 | [diff] [blame] | 616 | import numpy |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 617 | global clusterCount |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 618 | global runNum |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 619 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 620 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 621 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 622 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 623 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 624 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 625 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
| 626 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 627 | assertion = main.TRUE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 628 | # Number of iterations of case |
| 629 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 630 | iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] ) |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 631 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 632 | # Timestamp 'keys' for json metrics output. |
| 633 | # These are subject to change, hence moved into params |
| 634 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 635 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 636 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 637 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 638 | postToDB = main.params[ 'DB' ][ 'postToDB' ] |
| 639 | resultPath = main.params[ 'DB' ][ 'portEventResultPath' ] |
| 640 | timeToPost = time.strftime("%Y-%m-%d %H:%M:%S") |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 641 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 642 | localTime = time.strftime( '%x %X' ) |
| 643 | localTime = localTime.replace( "/", "" ) |
| 644 | localTime = localTime.replace( " ", "_" ) |
| 645 | localTime = localTime.replace( ":", "" ) |
| 646 | if debugMode == 'on': |
| 647 | main.ONOS1.tsharkPcap( "eth0", |
| 648 | "/tmp/port_lat_pcap_" + localTime ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 649 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 650 | # Threshold for this test case |
| 651 | upThresholdStr = main.params[ 'TEST' ][ 'portUpThreshold' ] |
| 652 | downThresholdStr = main.params[ 'TEST' ][ 'portDownThreshold' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 653 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 654 | upThresholdObj = upThresholdStr.split( "," ) |
| 655 | downThresholdObj = downThresholdStr.split( "," ) |
| 656 | |
| 657 | upThresholdMin = int( upThresholdObj[ 0 ] ) |
| 658 | upThresholdMax = int( upThresholdObj[ 1 ] ) |
| 659 | |
| 660 | downThresholdMin = int( downThresholdObj[ 0 ] ) |
| 661 | downThresholdMax = int( downThresholdObj[ 1 ] ) |
| 662 | |
| 663 | # NOTE: Some hardcoded variables you may need to configure |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 664 | # besides the params |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 665 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 666 | tsharkPortStatus = "OFP 130 Port Status" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 667 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 668 | tsharkPortUp = "/tmp/tshark_port_up.txt" |
| 669 | tsharkPortDown = "/tmp/tshark_port_down.txt" |
| 670 | interfaceConfig = "s1-eth1" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 671 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 672 | main.log.report( "Port enable / disable latency" ) |
| 673 | main.log.report( "Simulated by ifconfig up / down" ) |
| 674 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 675 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 676 | main.step( "Assign switches s1 and s2 to controller 1" ) |
| 677 | main.Mininet1.assignSwController( sw="1", ip1=ONOS1Ip, |
| 678 | port1=defaultSwPort ) |
| 679 | main.Mininet1.assignSwController( sw="2", ip1=ONOS1Ip, |
| 680 | port1=defaultSwPort ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 681 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 682 | # Give enough time for metrics to propagate the |
| 683 | # assign controller event. Otherwise, these events may |
| 684 | # carry over to our measurements |
| 685 | time.sleep( 15 ) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 686 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 687 | portUpDeviceToOfpList = [] |
| 688 | portUpGraphToOfpList = [] |
| 689 | portDownDeviceToOfpList = [] |
| 690 | portDownGraphToOfpList = [] |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 691 | |
| 692 | # Initialize 2d array filled with 0's |
| 693 | # arraySizeFormat[clusterCount][numIter] |
| 694 | portUpDevNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
| 695 | portUpGraphNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
| 696 | portDownDevNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
| 697 | portDownGraphNodeIter = numpy.zeros(( clusterCount, int(numIter) )) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 698 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 699 | for i in range( 0, int( numIter ) ): |
| 700 | main.step( "Starting wireshark capture for port status down" ) |
| 701 | main.ONOS1.tsharkGrep( tsharkPortStatus, |
| 702 | tsharkPortDown ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 703 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 704 | time.sleep( 5 ) |
| 705 | |
| 706 | # Disable interface that is connected to switch 2 |
| 707 | main.step( "Disable port: " + interfaceConfig ) |
| 708 | main.Mininet1.handle.sendline( "sh ifconfig " + |
| 709 | interfaceConfig + " down" ) |
| 710 | main.Mininet1.handle.expect( "mininet>" ) |
| 711 | |
| 712 | time.sleep( 3 ) |
| 713 | main.ONOS1.tsharkStop() |
| 714 | |
| 715 | # Copy tshark output file from ONOS to TestON instance |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 716 | #/tmp directory |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 717 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 718 | tsharkPortDown + " /tmp/" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 719 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 720 | fPortDown = open( tsharkPortDown, 'r' ) |
| 721 | # Get first line of port down event from tshark |
| 722 | fLine = fPortDown.readline() |
| 723 | objDown = fLine.split( " " ) |
| 724 | if len( fLine ) > 0: |
| 725 | # NOTE: objDown[ 1 ] is a very unreliable |
| 726 | # way to determine the timestamp. If |
| 727 | # results seem way off, check the object |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 728 | # itself by printing it out |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 729 | timestampBeginPtDown = int( float( objDown[ 1 ] ) * 1000 ) |
| 730 | # For some reason, wireshark decides to record the |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 731 | # timestamp at the 3rd object position instead of |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 732 | # 2nd at unpredictable times. This statement is |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 733 | # used to capture that odd behavior and use the |
| 734 | # correct epoch time |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 735 | if timestampBeginPtDown < 1400000000000: |
| 736 | timestampBeginPtDown = \ |
| 737 | int( float( objDown[ 2 ] ) * 1000 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 738 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 739 | main.log.info( "Port down begin timestamp: " + |
| 740 | str( timestampBeginPtDown ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 741 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 742 | main.log.info( "Tshark output file returned unexpected" + |
| 743 | " results: " + str( objDown ) ) |
| 744 | timestampBeginPtDown = 0 |
| 745 | fPortDown.close() |
| 746 | |
| 747 | main.step( "Obtain t1 by metrics call" ) |
| 748 | jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics() |
| 749 | jsonObj1 = json.loads( jsonStrUp1 ) |
| 750 | # Obtain graph timestamp. This timestsamp captures |
| 751 | # the epoch time at which the topology graph was updated. |
| 752 | graphTimestamp1 = \ |
| 753 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 754 | # Obtain device timestamp. This timestamp captures |
| 755 | # the epoch time at which the device event happened |
| 756 | deviceTimestamp1 = \ |
| 757 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 758 | # Get delta between graph event and OFP |
| 759 | ptDownGraphToOfp1 = int( graphTimestamp1 ) -\ |
| 760 | int( timestampBeginPtDown ) |
| 761 | # Get delta between device event and OFP |
| 762 | ptDownDeviceToOfp1 = int( deviceTimestamp1 ) -\ |
| 763 | int( timestampBeginPtDown ) |
| 764 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 765 | if ptDownGraphToOfp1 > downThresholdMin and\ |
| 766 | ptDownGraphToOfp1 < downThresholdMax and i > iterIgnore: |
| 767 | portDownGraphNodeIter[0][i] = ptDownGraphToOfp1 |
| 768 | main.log.info("iter"+str(i)+" port down graph-to-ofp: "+ |
| 769 | str(ptDownGraphToOfp1)+" ms") |
| 770 | else: |
| 771 | main.log.info("iter"+str(i)+" skipped. Result: "+ |
| 772 | str(ptDownGraphToOfp1)+" ms") |
| 773 | if ptDownDeviceToOfp1 > downThresholdMin and\ |
| 774 | ptDownDeviceToOfp1 < downThresholdMax and i > iterIgnore: |
| 775 | portDownDevNodeIter[0][i] = ptDownDeviceToOfp1 |
| 776 | main.log.info("iter"+str(i)+" port down device-to-ofp: "+ |
| 777 | str(ptDownDeviceToOfp1)+" ms") |
| 778 | else: |
| 779 | main.log.info("iter"+str(i)+" skipped. Result: "+ |
| 780 | str(ptDownDeviceToOfp1)+" ms") |
| 781 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 782 | if clusterCount >= 3: |
| 783 | jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics() |
| 784 | jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics() |
| 785 | jsonObj2 = json.loads( jsonStrUp2 ) |
| 786 | jsonObj3 = json.loads( jsonStrUp3 ) |
| 787 | graphTimestamp2 = \ |
| 788 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 789 | graphTimestamp3 = \ |
| 790 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 791 | deviceTimestamp2 = \ |
| 792 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 793 | deviceTimestamp3 = \ |
| 794 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 795 | ptDownGraphToOfp2 = int( graphTimestamp2 ) -\ |
| 796 | int( timestampBeginPtDown ) |
| 797 | ptDownGraphToOfp3 = int( graphTimestamp3 ) -\ |
| 798 | int( timestampBeginPtDown ) |
| 799 | ptDownDeviceToOfp2 = int( deviceTimestamp2 ) -\ |
| 800 | int( timestampBeginPtDown ) |
| 801 | ptDownDeviceToOfp3 = int( deviceTimestamp3 ) -\ |
| 802 | int( timestampBeginPtDown ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 803 | |
| 804 | if ptDownGraphToOfp2 > downThresholdMin and\ |
| 805 | ptDownGraphToOfp2 < downThresholdMax and i > iterIgnore: |
| 806 | portDownGraphNodeIter[1][i] = ptDownGraphToOfp2 |
| 807 | main.log.info("ONOS2 iter"+str(i)+" graph-to-ofp: "+ |
| 808 | str(ptDownGraphToOfp2)+" ms") |
| 809 | |
| 810 | if ptDownDeviceToOfp2 > downThresholdMin and\ |
| 811 | ptDownDeviceToOfp2 < downThresholdMax and i > iterIgnore: |
| 812 | portDownDevNodeIter[1][i] = ptDownDeviceToOfp2 |
| 813 | main.log.info("ONOS2 iter"+str(i)+" device-to-ofp: "+ |
| 814 | str(ptDownDeviceToOfp2)+" ms") |
| 815 | |
| 816 | if ptDownGraphToOfp3 > downThresholdMin and\ |
| 817 | ptDownGraphToOfp3 < downThresholdMax and i > iterIgnore: |
| 818 | portDownGraphNodeIter[2][i] = ptDownGraphToOfp3 |
| 819 | main.log.info("ONOS3 iter"+str(i)+" graph-to-ofp: "+ |
| 820 | str(ptDownGraphToOfp3)+" ms") |
| 821 | |
| 822 | if ptDownDeviceToOfp3 > downThresholdMin and\ |
| 823 | ptDownDeviceToOfp3 < downThresholdMax and i > iterIgnore: |
| 824 | portDownDevNodeIter[2][i] = ptDownDeviceToOfp3 |
| 825 | main.log.info("ONOS3 iter"+str(i)+" device-to-ofp: "+ |
| 826 | str(ptDownDeviceToOfp3)+" ms") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 827 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 828 | if clusterCount >= 5: |
| 829 | jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics() |
| 830 | jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics() |
| 831 | jsonObj4 = json.loads( jsonStrUp4 ) |
| 832 | jsonObj5 = json.loads( jsonStrUp5 ) |
| 833 | graphTimestamp4 = \ |
| 834 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 835 | graphTimestamp5 = \ |
| 836 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 837 | deviceTimestamp4 = \ |
| 838 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 839 | deviceTimestamp5 = \ |
| 840 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 841 | ptDownGraphToOfp4 = int( graphTimestamp4 ) -\ |
| 842 | int( timestampBeginPtDown ) |
| 843 | ptDownGraphToOfp5 = int( graphTimestamp5 ) -\ |
| 844 | int( timestampBeginPtDown ) |
| 845 | ptDownDeviceToOfp4 = int( deviceTimestamp4 ) -\ |
| 846 | int( timestampBeginPtDown ) |
| 847 | ptDownDeviceToOfp5 = int( deviceTimestamp5 ) -\ |
| 848 | int( timestampBeginPtDown ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 849 | |
| 850 | if ptDownGraphToOfp4 > downThresholdMin and\ |
| 851 | ptDownGraphToOfp4 < downThresholdMax and i > iterIgnore: |
| 852 | portDownGraphNodeIter[3][i] = ptDownGraphToOfp4 |
| 853 | main.log.info("ONOS4 iter"+str(i)+" graph-to-ofp: "+ |
| 854 | str(ptDownGraphToOfp4)+" ms") |
| 855 | |
| 856 | if ptDownDeviceToOfp4 > downThresholdMin and\ |
| 857 | ptDownDeviceToOfp4 < downThresholdMax and i > iterIgnore: |
| 858 | portDownDevNodeIter[3][i] = ptDownDeviceToOfp4 |
| 859 | main.log.info("ONOS4 iter"+str(i)+" device-to-ofp: "+ |
| 860 | str(ptDownDeviceToOfp4)+" ms") |
| 861 | |
| 862 | if ptDownGraphToOfp5 > downThresholdMin and\ |
| 863 | ptDownGraphToOfp5 < downThresholdMax and i > iterIgnore: |
| 864 | portDownGraphNodeIter[4][i] = ptDownGraphToOfp5 |
| 865 | main.log.info("ONOS5 iter"+str(i)+" graph-to-ofp: "+ |
| 866 | str(ptDownGraphToOfp5)+" ms") |
| 867 | |
| 868 | if ptDownDeviceToOfp5 > downThresholdMin and\ |
| 869 | ptDownDeviceToOfp5 < downThresholdMax and i > iterIgnore: |
| 870 | portDownDevNodeIter[4][i] = ptDownDeviceToOfp5 |
| 871 | main.log.info("ONOS5 iter"+str(i)+" device-to-ofp: "+ |
| 872 | str(ptDownDeviceToOfp5)+" ms") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 873 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 874 | if clusterCount >= 7: |
| 875 | jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics() |
| 876 | jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics() |
| 877 | jsonObj6 = json.loads( jsonStrUp6 ) |
| 878 | jsonObj7 = json.loads( jsonStrUp7 ) |
| 879 | graphTimestamp6 = \ |
| 880 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 881 | graphTimestamp7 = \ |
| 882 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 883 | deviceTimestamp6 = \ |
| 884 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 885 | deviceTimestamp7 = \ |
| 886 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 887 | ptDownGraphToOfp6 = int( graphTimestamp6 ) -\ |
| 888 | int( timestampBeginPtDown ) |
| 889 | ptDownGraphToOfp7 = int( graphTimestamp7 ) -\ |
| 890 | int( timestampBeginPtDown ) |
| 891 | ptDownDeviceToOfp6 = int( deviceTimestamp6 ) -\ |
| 892 | int( timestampBeginPtDown ) |
| 893 | ptDownDeviceToOfp7 = int( deviceTimestamp7 ) -\ |
| 894 | int( timestampBeginPtDown ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 895 | |
| 896 | if ptDownGraphToOfp6 > downThresholdMin and\ |
| 897 | ptDownGraphToOfp6 < downThresholdMax and i > iterIgnore: |
| 898 | portDownGraphNodeIter[5][i] = ptDownGraphToOfp6 |
| 899 | main.log.info("ONOS6 iter"+str(i)+" graph-to-ofp: "+ |
| 900 | str(ptDownGraphToOfp6)+" ms") |
| 901 | |
| 902 | if ptDownDeviceToOfp6 > downThresholdMin and\ |
| 903 | ptDownDeviceToOfp6 < downThresholdMax and i > iterIgnore: |
| 904 | portDownDevNodeIter[5][i] = ptDownDeviceToOfp6 |
| 905 | main.log.info("ONOS6 iter"+str(i)+" device-to-ofp: "+ |
| 906 | str(ptDownDeviceToOfp6)+" ms") |
| 907 | |
| 908 | if ptDownGraphToOfp7 > downThresholdMin and\ |
| 909 | ptDownGraphToOfp7 < downThresholdMax and i > iterIgnore: |
| 910 | portDownGraphNodeIter[6][i] = ptDownGraphToOfp7 |
| 911 | main.log.info("ONOS7 iter"+str(i)+" graph-to-ofp: "+ |
| 912 | str(ptDownGraphToOfp7)+" ms") |
| 913 | |
| 914 | if ptDownDeviceToOfp7 > downThresholdMin and\ |
| 915 | ptDownDeviceToOfp7 < downThresholdMax and i > iterIgnore: |
| 916 | portDownDevNodeIter[6][i] = ptDownDeviceToOfp7 |
| 917 | main.log.info("ONOS7 iter"+str(i)+" device-to-ofp: "+ |
| 918 | str(ptDownDeviceToOfp7)+" ms") |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 919 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 920 | time.sleep( 3 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 921 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 922 | # Port up events |
| 923 | main.step( "Enable port and obtain timestamp" ) |
| 924 | main.step( "Starting wireshark capture for port status up" ) |
| 925 | main.ONOS1.tsharkGrep( tsharkPortStatus, tsharkPortUp ) |
| 926 | time.sleep( 5 ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 927 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 928 | main.Mininet1.handle.sendline( "sh ifconfig " + |
| 929 | interfaceConfig + " up" ) |
| 930 | main.Mininet1.handle.expect( "mininet>" ) |
| 931 | |
| 932 | # Allow time for tshark to capture event |
| 933 | time.sleep( 5 ) |
| 934 | main.ONOS1.tsharkStop() |
| 935 | |
| 936 | time.sleep( 3 ) |
| 937 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 938 | tsharkPortUp + " /tmp/" ) |
| 939 | fPortUp = open( tsharkPortUp, 'r' ) |
| 940 | fLine = fPortUp.readline() |
| 941 | objUp = fLine.split( " " ) |
| 942 | if len( fLine ) > 0: |
| 943 | timestampBeginPtUp = int( float( objUp[ 1 ] ) * 1000 ) |
| 944 | if timestampBeginPtUp < 1400000000000: |
| 945 | timestampBeginPtUp = \ |
| 946 | int( float( objUp[ 2 ] ) * 1000 ) |
| 947 | main.log.info( "Port up begin timestamp: " + |
| 948 | str( timestampBeginPtUp ) ) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 949 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 950 | main.log.info( "Tshark output file returned unexpected" + |
| 951 | " results." ) |
| 952 | timestampBeginPtUp = 0 |
| 953 | fPortUp.close() |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 954 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 955 | # Obtain metrics shortly afterwards |
| 956 | # This timestsamp captures |
| 957 | # the epoch time at which the topology graph was updated. |
| 958 | main.step( "Obtain t1 by REST call" ) |
| 959 | jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics() |
| 960 | jsonObj1 = json.loads( jsonStrUp1 ) |
| 961 | graphTimestamp1 = \ |
| 962 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 963 | # Obtain device timestamp. This timestamp captures |
| 964 | # the epoch time at which the device event happened |
| 965 | deviceTimestamp1 = \ |
| 966 | jsonObj1[ deviceTimestamp ][ 'value' ] |
| 967 | # Get delta between graph event and OFP |
| 968 | ptUpGraphToOfp1 = int( graphTimestamp1 ) -\ |
| 969 | int( timestampBeginPtUp ) |
| 970 | # Get delta between device event and OFP |
| 971 | ptUpDeviceToOfp1 = int( deviceTimestamp1 ) -\ |
| 972 | int( timestampBeginPtUp ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 973 | |
| 974 | if ptUpGraphToOfp1 > upThresholdMin and\ |
| 975 | ptUpGraphToOfp1 < upThresholdMax and i > iterIgnore: |
| 976 | portUpGraphNodeIter[0][i] = ptUpGraphToOfp1 |
| 977 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 978 | str(ptUpGraphToOfp1)+" ms") |
| 979 | else: |
| 980 | main.log.info("iter"+str(i)+" skipped. Result: "+ |
| 981 | str(ptUpGraphToOfp1)+" ms") |
| 982 | |
| 983 | if ptUpDeviceToOfp1 > upThresholdMin and\ |
| 984 | ptUpDeviceToOfp1 < upThresholdMax and i > iterIgnore: |
| 985 | portUpDevNodeIter[0][i] = ptUpDeviceToOfp1 |
| 986 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 987 | str(ptUpDeviceToOfp1)+" ms") |
| 988 | else: |
| 989 | main.log.info("iter"+str(i)+" skipped. Result: "+ |
| 990 | str(ptUpDeviceToOfp1)+" ms") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 991 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 992 | if clusterCount >= 3: |
| 993 | jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics() |
| 994 | jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics() |
| 995 | jsonObj2 = json.loads( jsonStrUp2 ) |
| 996 | jsonObj3 = json.loads( jsonStrUp3 ) |
| 997 | graphTimestamp2 = \ |
| 998 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 999 | graphTimestamp3 = \ |
| 1000 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 1001 | deviceTimestamp2 = \ |
| 1002 | jsonObj2[ deviceTimestamp ][ 'value' ] |
| 1003 | deviceTimestamp3 = \ |
| 1004 | jsonObj3[ deviceTimestamp ][ 'value' ] |
| 1005 | ptUpGraphToOfp2 = int( graphTimestamp2 ) -\ |
| 1006 | int( timestampBeginPtUp ) |
| 1007 | ptUpGraphToOfp3 = int( graphTimestamp3 ) -\ |
| 1008 | int( timestampBeginPtUp ) |
| 1009 | ptUpDeviceToOfp2 = int( deviceTimestamp2 ) -\ |
| 1010 | int( timestampBeginPtUp ) |
| 1011 | ptUpDeviceToOfp3 = int( deviceTimestamp3 ) -\ |
| 1012 | int( timestampBeginPtUp ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1013 | |
| 1014 | if ptUpGraphToOfp2 > upThresholdMin and\ |
| 1015 | ptUpGraphToOfp2 < upThresholdMax and i > iterIgnore: |
| 1016 | portUpGraphNodeIter[1][i] = ptUpGraphToOfp2 |
| 1017 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1018 | str(ptUpGraphToOfp2)+" ms") |
| 1019 | |
| 1020 | if ptUpDeviceToOfp2 > upThresholdMin and\ |
| 1021 | ptUpDeviceToOfp2 < upThresholdMax and i > iterIgnore: |
| 1022 | portUpDevNodeIter[1][i] = ptUpDeviceToOfp2 |
| 1023 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1024 | str(ptUpDeviceToOfp2)+" ms") |
| 1025 | |
| 1026 | if ptUpGraphToOfp3 > upThresholdMin and\ |
| 1027 | ptUpGraphToOfp3 < upThresholdMax and i > iterIgnore: |
| 1028 | portUpGraphNodeIter[2][i] = ptUpGraphToOfp3 |
| 1029 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1030 | str(ptUpGraphToOfp3)+" ms") |
| 1031 | |
| 1032 | if ptUpDeviceToOfp3 > upThresholdMin and\ |
| 1033 | ptUpDeviceToOfp3 < upThresholdMax and i > iterIgnore: |
| 1034 | portUpDevNodeIter[2][i] = ptUpDeviceToOfp3 |
| 1035 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1036 | str(ptUpDeviceToOfp3)+" ms") |
andrewonlab | b1998c5 | 2014-11-10 13:31:43 -0500 | [diff] [blame] | 1037 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1038 | if clusterCount >= 5: |
| 1039 | jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics() |
| 1040 | jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics() |
| 1041 | jsonObj4 = json.loads( jsonStrUp4 ) |
| 1042 | jsonObj5 = json.loads( jsonStrUp5 ) |
| 1043 | graphTimestamp4 = \ |
| 1044 | jsonObj4[ graphTimestamp ][ 'value' ] |
| 1045 | graphTimestamp5 = \ |
| 1046 | jsonObj5[ graphTimestamp ][ 'value' ] |
| 1047 | deviceTimestamp4 = \ |
| 1048 | jsonObj4[ deviceTimestamp ][ 'value' ] |
| 1049 | deviceTimestamp5 = \ |
| 1050 | jsonObj5[ deviceTimestamp ][ 'value' ] |
| 1051 | ptUpGraphToOfp4 = int( graphTimestamp4 ) -\ |
| 1052 | int( timestampBeginPtUp ) |
| 1053 | ptUpGraphToOfp5 = int( graphTimestamp5 ) -\ |
| 1054 | int( timestampBeginPtUp ) |
| 1055 | ptUpDeviceToOfp4 = int( deviceTimestamp4 ) -\ |
| 1056 | int( timestampBeginPtUp ) |
| 1057 | ptUpDeviceToOfp5 = int( deviceTimestamp5 ) -\ |
| 1058 | int( timestampBeginPtUp ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1059 | |
| 1060 | if ptUpGraphToOfp4 > upThresholdMin and\ |
| 1061 | ptUpGraphToOfp4 < upThresholdMax and i > iterIgnore: |
| 1062 | portUpGraphNodeIter[3][i] = ptUpGraphToOfp4 |
| 1063 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1064 | str(ptUpGraphToOfp4)+" ms") |
| 1065 | |
| 1066 | if ptUpDeviceToOfp4 > upThresholdMin and\ |
| 1067 | ptUpDeviceToOfp4 < upThresholdMax and i > iterIgnore: |
| 1068 | portUpDevNodeIter[3][i] = ptUpDeviceToOfp4 |
| 1069 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1070 | str(ptUpDeviceToOfp4)+" ms") |
| 1071 | |
| 1072 | if ptUpGraphToOfp5 > upThresholdMin and\ |
| 1073 | ptUpGraphToOfp5 < upThresholdMax and i > iterIgnore: |
| 1074 | portUpGraphNodeIter[4][i] = ptUpGraphToOfp5 |
| 1075 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1076 | str(ptUpGraphToOfp5)+" ms") |
| 1077 | |
| 1078 | if ptUpDeviceToOfp5 > upThresholdMin and\ |
| 1079 | ptUpDeviceToOfp5 < upThresholdMax and i > iterIgnore: |
| 1080 | portUpDevNodeIter[4][i] = ptUpDeviceToOfp5 |
| 1081 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1082 | str(ptUpDeviceToOfp5)+" ms") |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1083 | |
| 1084 | if clusterCount >= 7: |
| 1085 | jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics() |
| 1086 | jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics() |
| 1087 | jsonObj6 = json.loads( jsonStrUp6 ) |
| 1088 | jsonObj7 = json.loads( jsonStrUp7 ) |
| 1089 | graphTimestamp6 = \ |
| 1090 | jsonObj6[ graphTimestamp ][ 'value' ] |
| 1091 | graphTimestamp7 = \ |
| 1092 | jsonObj7[ graphTimestamp ][ 'value' ] |
| 1093 | deviceTimestamp6 = \ |
| 1094 | jsonObj6[ deviceTimestamp ][ 'value' ] |
| 1095 | deviceTimestamp7 = \ |
| 1096 | jsonObj7[ deviceTimestamp ][ 'value' ] |
| 1097 | ptUpGraphToOfp6 = int( graphTimestamp6 ) -\ |
| 1098 | int( timestampBeginPtUp ) |
| 1099 | ptUpGraphToOfp7 = int( graphTimestamp7 ) -\ |
| 1100 | int( timestampBeginPtUp ) |
| 1101 | ptUpDeviceToOfp6 = int( deviceTimestamp6 ) -\ |
| 1102 | int( timestampBeginPtUp ) |
| 1103 | ptUpDeviceToOfp7 = int( deviceTimestamp7 ) -\ |
| 1104 | int( timestampBeginPtUp ) |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1105 | |
| 1106 | if ptUpGraphToOfp6 > upThresholdMin and\ |
| 1107 | ptUpGraphToOfp6 < upThresholdMax and i > iterIgnore: |
| 1108 | portUpGraphNodeIter[5][i] = ptUpGraphToOfp6 |
| 1109 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1110 | str(ptUpGraphToOfp6)+" ms") |
| 1111 | |
| 1112 | if ptUpDeviceToOfp6 > upThresholdMin and\ |
| 1113 | ptUpDeviceToOfp6 < upThresholdMax and i > iterIgnore: |
| 1114 | portUpDevNodeIter[5][i] = ptUpDeviceToOfp6 |
| 1115 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1116 | str(ptUpDeviceToOfp6)+" ms") |
| 1117 | |
| 1118 | if ptUpGraphToOfp7 > upThresholdMin and\ |
| 1119 | ptUpGraphToOfp7 < upThresholdMax and i > iterIgnore: |
| 1120 | portUpGraphNodeIter[6][i] = ptUpGraphToOfp7 |
| 1121 | main.log.info("iter"+str(i)+" port up graph-to-ofp: "+ |
| 1122 | str(ptUpGraphToOfp7)+" ms") |
| 1123 | |
| 1124 | if ptUpDeviceToOfp7 > upThresholdMin and\ |
| 1125 | ptUpDeviceToOfp7 < upThresholdMax and i > iterIgnore: |
| 1126 | portUpDevNodeIter[6][i] = ptUpDeviceToOfp7 |
| 1127 | main.log.info("iter"+str(i)+" port up device-to-ofp: "+ |
| 1128 | str(ptUpDeviceToOfp7)+" ms") |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1129 | |
| 1130 | # END ITERATION FOR LOOP |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1131 | |
| 1132 | portUpDevList = [] |
| 1133 | portUpGraphList = [] |
| 1134 | portDownDevList = [] |
| 1135 | portDownGraphList = [] |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1136 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1137 | portUpDevAvg = 0 |
| 1138 | portUpGraphAvg = 0 |
| 1139 | portDownDevAvg = 0 |
| 1140 | portDownGraphAvg = 0 |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1141 | |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 1142 | dbCmdList = [] |
| 1143 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1144 | for node in range( 0, clusterCount ): |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1145 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1146 | # NOTE: |
| 1147 | # Currently the 2d array is initialized with 0's. |
| 1148 | # We want to avoid skewing our results if the array |
| 1149 | # was not modified with the correct latency. |
| 1150 | for item in portUpDevNodeIter[node]: |
| 1151 | if item > 0.0: |
| 1152 | portUpDevList.append(item) |
| 1153 | for item in portUpGraphNodeIter[node]: |
| 1154 | if item > 0.0: |
| 1155 | portUpGraphList.append(item) |
| 1156 | for item in portDownDevNodeIter[node]: |
| 1157 | if item > 0.0: |
| 1158 | portDownDevList.append(item) |
| 1159 | for item in portDownGraphNodeIter[node]: |
| 1160 | if item > 0.0: |
| 1161 | portDownGraphList.append(item) |
| 1162 | |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 1163 | portUpDevAvg = round(numpy.mean(portUpDevList), 2) |
| 1164 | portUpGraphAvg = round(numpy.mean(portUpGraphList), 2) |
| 1165 | portDownDevAvg = round(numpy.mean(portDownDevList), 2) |
| 1166 | portDownGraphAvg = round(numpy.mean(portDownGraphList), 2) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1167 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1168 | main.log.report( " - Node "+str(node+1)+" Summary - " ) |
| 1169 | #main.log.report( " Port up ofp-to-device "+ |
| 1170 | # str(round(portUpDevAvg, 2))+" ms") |
| 1171 | main.log.report( " Port up ofp-to-graph "+ |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 1172 | str(portUpGraphAvg)+" ms") |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1173 | #main.log.report( " Port down ofp-to-device "+ |
| 1174 | # str(round(portDownDevAvg, 2))+" ms") |
| 1175 | main.log.report( " Port down ofp-to-graph "+ |
andrewonlab | 86e9e08 | 2015-02-13 12:07:39 -0500 | [diff] [blame^] | 1176 | str(portDownGraphAvg)+" ms") |
| 1177 | |
| 1178 | dbCmdList.append( |
| 1179 | "INSERT INTO port_latency_tests VALUES(" |
| 1180 | "'"+timeToPost+"','port_latency_results'," |
| 1181 | ""+runNum+","+str(clusterCount)+",'baremetal"+str(node+1)+"'," |
| 1182 | ""+str(portUpGraphAvg)+",0,"+str(portDownGraphAvg)+",0);" |
| 1183 | ) |
| 1184 | |
| 1185 | #Write to file for posting to DB |
| 1186 | fResult = open(resultPath, 'a') |
| 1187 | for line in dbCmdList: |
| 1188 | if line: |
| 1189 | fResult.write(line+"\n") |
| 1190 | fResult.close() |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1191 | |
| 1192 | # Remove switches from controller for next test |
| 1193 | main.Mininet1.deleteSwController( "s1" ) |
| 1194 | main.Mininet1.deleteSwController( "s2" ) |
| 1195 | |
andrewonlab | d5367a4 | 2015-01-30 14:46:17 -0500 | [diff] [blame] | 1196 | #TODO: correct assertion |
| 1197 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1198 | utilities.assert_equals( |
| 1199 | expect=main.TRUE, |
| 1200 | actual=assertion, |
| 1201 | onpass="Port discovery latency calculation successful", |
| 1202 | onfail="Port discovery test failed" ) |
| 1203 | |
| 1204 | def CASE4( self, main ): |
| 1205 | """ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1206 | Link down event using loss rate 100% |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1207 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1208 | Important: |
| 1209 | Use a simple 2 switch topology with 1 link between |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1210 | the two switches. Ensure that mac addresses of the |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1211 | switches are 1 / 2 respectively |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1212 | """ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1213 | import time |
| 1214 | import subprocess |
| 1215 | import os |
| 1216 | import requests |
| 1217 | import json |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1218 | import numpy |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1219 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1220 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1221 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1222 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1223 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1224 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1225 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1226 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1227 | # Number of iterations of case |
| 1228 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1229 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1230 | # Timestamp 'keys' for json metrics output. |
| 1231 | # These are subject to change, hence moved into params |
| 1232 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 1233 | linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ] |
| 1234 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1235 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1236 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1237 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1238 | localTime = time.strftime( '%x %X' ) |
| 1239 | localTime = localTime.replace( "/", "" ) |
| 1240 | localTime = localTime.replace( " ", "_" ) |
| 1241 | localTime = localTime.replace( ":", "" ) |
| 1242 | if debugMode == 'on': |
| 1243 | main.ONOS1.tsharkPcap( "eth0", |
| 1244 | "/tmp/link_lat_pcap_" + localTime ) |
| 1245 | |
| 1246 | # Threshold for this test case |
| 1247 | upThresholdStr = main.params[ 'TEST' ][ 'linkUpThreshold' ] |
| 1248 | downThresholdStr = main.params[ 'TEST' ][ 'linkDownThreshold' ] |
| 1249 | |
| 1250 | upThresholdObj = upThresholdStr.split( "," ) |
| 1251 | downThresholdObj = downThresholdStr.split( "," ) |
| 1252 | |
| 1253 | upThresholdMin = int( upThresholdObj[ 0 ] ) |
| 1254 | upThresholdMax = int( upThresholdObj[ 1 ] ) |
| 1255 | |
| 1256 | downThresholdMin = int( downThresholdObj[ 0 ] ) |
| 1257 | downThresholdMax = int( downThresholdObj[ 1 ] ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1258 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1259 | assertion = main.TRUE |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1260 | # Link event timestamp to system time list |
| 1261 | linkDownLinkToSystemList = [] |
| 1262 | linkUpLinkToSystemList = [] |
| 1263 | # Graph event timestamp to system time list |
| 1264 | linkDownGraphToSystemList = [] |
| 1265 | linkUpGraphToSystemList = [] |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1266 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1267 | main.log.report( "Link up / down discovery latency between " + |
| 1268 | "two switches" ) |
| 1269 | main.log.report( "Simulated by setting loss-rate 100%" ) |
| 1270 | main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" ) |
| 1271 | main.log.report( "Total iterations of test: " + str( numIter ) ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1272 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1273 | main.step( "Assign all switches" ) |
| 1274 | main.Mininet1.assignSwController( sw="1", |
| 1275 | ip1=ONOS1Ip, port1=defaultSwPort ) |
| 1276 | main.Mininet1.assignSwController( sw="2", |
| 1277 | ip1=ONOS1Ip, port1=defaultSwPort ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1278 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1279 | main.step( "Verifying switch assignment" ) |
| 1280 | resultS1 = main.Mininet1.getSwController( sw="s1" ) |
| 1281 | resultS2 = main.Mininet1.getSwController( sw="s2" ) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 1282 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1283 | # Allow time for events to finish before taking measurements |
| 1284 | time.sleep( 10 ) |
| 1285 | |
| 1286 | linkDown1 = False |
| 1287 | linkDown2 = False |
| 1288 | linkDown3 = False |
| 1289 | # Start iteration of link event test |
| 1290 | for i in range( 0, int( numIter ) ): |
| 1291 | main.step( "Getting initial system time as t0" ) |
| 1292 | |
| 1293 | # System time in epoch ms |
| 1294 | timestampLinkDownT0 = time.time() * 1000 |
| 1295 | # Link down is simulated by 100% loss rate using traffic |
| 1296 | # control command |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1297 | main.Mininet1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1298 | "sh tc qdisc add dev s1-eth1 root netem loss 100%" ) |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1299 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1300 | # TODO: Iterate through 'links' command to verify that |
| 1301 | # link s1 -> s2 went down ( loop timeout 30 seconds ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1302 | # on all 3 ONOS instances |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1303 | main.log.info( "Checking ONOS for link update" ) |
| 1304 | loopCount = 0 |
| 1305 | while( not ( linkDown1 and linkDown2 and linkDown3 ) |
| 1306 | and loopCount < 30 ): |
| 1307 | jsonStr1 = main.ONOS1cli.links() |
| 1308 | jsonStr2 = main.ONOS2cli.links() |
| 1309 | jsonStr3 = main.ONOS3cli.links() |
| 1310 | |
| 1311 | if not ( jsonStr1 and jsonStr2 and jsonStr3 ): |
| 1312 | main.log.error( "CLI command returned error " ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1313 | break |
| 1314 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1315 | jsonObj1 = json.loads( jsonStr1 ) |
| 1316 | jsonObj2 = json.loads( jsonStr2 ) |
| 1317 | jsonObj3 = json.loads( jsonStr3 ) |
| 1318 | for obj1 in jsonObj1: |
| 1319 | if '01' not in obj1[ 'src' ][ 'device' ]: |
| 1320 | linkDown1 = True |
| 1321 | main.log.info( "Link down from " + |
| 1322 | "s1 -> s2 on ONOS1 detected" ) |
| 1323 | for obj2 in jsonObj2: |
| 1324 | if '01' not in obj2[ 'src' ][ 'device' ]: |
| 1325 | linkDown2 = True |
| 1326 | main.log.info( "Link down from " + |
| 1327 | "s1 -> s2 on ONOS2 detected" ) |
| 1328 | for obj3 in jsonObj3: |
| 1329 | if '01' not in obj3[ 'src' ][ 'device' ]: |
| 1330 | linkDown3 = True |
| 1331 | main.log.info( "Link down from " + |
| 1332 | "s1 -> s2 on ONOS3 detected" ) |
| 1333 | |
| 1334 | loopCount += 1 |
| 1335 | # If CLI doesn't like the continuous requests |
| 1336 | # and exits in this loop, increase the sleep here. |
| 1337 | # Consequently, while loop timeout will increase |
| 1338 | time.sleep( 1 ) |
| 1339 | |
| 1340 | # Give time for metrics measurement to catch up |
| 1341 | # NOTE: May need to be configured more accurately |
| 1342 | time.sleep( 10 ) |
| 1343 | # If we exited the while loop and link down 1,2,3 are still |
| 1344 | # false, then ONOS has failed to discover link down event |
| 1345 | if not ( linkDown1 and linkDown2 and linkDown3 ): |
| 1346 | main.log.info( "Link down discovery failed" ) |
| 1347 | |
| 1348 | linkDownLatGraph1 = 0 |
| 1349 | linkDownLatGraph2 = 0 |
| 1350 | linkDownLatGraph3 = 0 |
| 1351 | linkDownLatDevice1 = 0 |
| 1352 | linkDownLatDevice2 = 0 |
| 1353 | linkDownLatDevice3 = 0 |
| 1354 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1355 | assertion = main.FALSE |
| 1356 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1357 | jsonTopoMetrics1 =\ |
| 1358 | main.ONOS1cli.topologyEventsMetrics() |
| 1359 | jsonTopoMetrics2 =\ |
| 1360 | main.ONOS2cli.topologyEventsMetrics() |
| 1361 | jsonTopoMetrics3 =\ |
| 1362 | main.ONOS3cli.topologyEventsMetrics() |
| 1363 | jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 ) |
| 1364 | jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 ) |
| 1365 | jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1366 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1367 | main.log.info( "Obtaining graph and device timestamp" ) |
| 1368 | graphTimestamp1 = \ |
| 1369 | jsonTopoMetrics1[ graphTimestamp ][ 'value' ] |
| 1370 | graphTimestamp2 = \ |
| 1371 | jsonTopoMetrics2[ graphTimestamp ][ 'value' ] |
| 1372 | graphTimestamp3 = \ |
| 1373 | jsonTopoMetrics3[ graphTimestamp ][ 'value' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1374 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1375 | linkTimestamp1 = \ |
| 1376 | jsonTopoMetrics1[ linkTimestamp ][ 'value' ] |
| 1377 | linkTimestamp2 = \ |
| 1378 | jsonTopoMetrics2[ linkTimestamp ][ 'value' ] |
| 1379 | linkTimestamp3 = \ |
| 1380 | jsonTopoMetrics3[ linkTimestamp ][ 'value' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1381 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1382 | if graphTimestamp1 and graphTimestamp2 and\ |
| 1383 | graphTimestamp3 and linkTimestamp1 and\ |
| 1384 | linkTimestamp2 and linkTimestamp3: |
| 1385 | linkDownLatGraph1 = int( graphTimestamp1 ) -\ |
| 1386 | int( timestampLinkDownT0 ) |
| 1387 | linkDownLatGraph2 = int( graphTimestamp2 ) -\ |
| 1388 | int( timestampLinkDownT0 ) |
| 1389 | linkDownLatGraph3 = int( graphTimestamp3 ) -\ |
| 1390 | int( timestampLinkDownT0 ) |
| 1391 | |
| 1392 | linkDownLatLink1 = int( linkTimestamp1 ) -\ |
| 1393 | int( timestampLinkDownT0 ) |
| 1394 | linkDownLatLink2 = int( linkTimestamp2 ) -\ |
| 1395 | int( timestampLinkDownT0 ) |
| 1396 | linkDownLatLink3 = int( linkTimestamp3 ) -\ |
| 1397 | int( timestampLinkDownT0 ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1398 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1399 | main.log.error( "There was an error calculating" + |
| 1400 | " the delta for link down event" ) |
| 1401 | linkDownLatGraph1 = 0 |
| 1402 | linkDownLatGraph2 = 0 |
| 1403 | linkDownLatGraph3 = 0 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1404 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1405 | linkDownLatDevice1 = 0 |
| 1406 | linkDownLatDevice2 = 0 |
| 1407 | linkDownLatDevice3 = 0 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1408 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1409 | main.log.info( "Link down latency ONOS1 iteration " + |
| 1410 | str( i ) + " (end-to-end): " + |
| 1411 | str( linkDownLatGraph1 ) + " ms" ) |
| 1412 | main.log.info( "Link down latency ONOS2 iteration " + |
| 1413 | str( i ) + " (end-to-end): " + |
| 1414 | str( linkDownLatGraph2 ) + " ms" ) |
| 1415 | main.log.info( "Link down latency ONOS3 iteration " + |
| 1416 | str( i ) + " (end-to-end): " + |
| 1417 | str( linkDownLatGraph3 ) + " ms" ) |
| 1418 | |
| 1419 | main.log.info( "Link down latency ONOS1 iteration " + |
| 1420 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1421 | str( linkDownLatLink1 ) + " ms" ) |
| 1422 | main.log.info( "Link down latency ONOS2 iteration " + |
| 1423 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1424 | str( linkDownLatLink2 ) + " ms" ) |
| 1425 | main.log.info( "Link down latency ONOS3 iteration " + |
| 1426 | str( i ) + " (link-event-to-system-timestamp): " + |
| 1427 | str( linkDownLatLink3 ) ) |
| 1428 | |
| 1429 | # Calculate avg of node calculations |
| 1430 | linkDownLatGraphAvg =\ |
| 1431 | ( linkDownLatGraph1 + |
| 1432 | linkDownLatGraph2 + |
| 1433 | linkDownLatGraph3 ) / 3 |
| 1434 | linkDownLatLinkAvg =\ |
| 1435 | ( linkDownLatLink1 + |
| 1436 | linkDownLatLink2 + |
| 1437 | linkDownLatLink3 ) / 3 |
| 1438 | |
| 1439 | # Set threshold and append latency to list |
| 1440 | if linkDownLatGraphAvg > downThresholdMin and\ |
| 1441 | linkDownLatGraphAvg < downThresholdMax: |
| 1442 | linkDownGraphToSystemList.append( |
| 1443 | linkDownLatGraphAvg ) |
| 1444 | else: |
| 1445 | main.log.info( "Link down latency exceeded threshold" ) |
| 1446 | main.log.info( "Results for iteration " + str( i ) + |
| 1447 | "have been omitted" ) |
| 1448 | if linkDownLatLinkAvg > downThresholdMin and\ |
| 1449 | linkDownLatLinkAvg < downThresholdMax: |
| 1450 | linkDownLinkToSystemList.append( |
| 1451 | linkDownLatLinkAvg ) |
| 1452 | else: |
| 1453 | main.log.info( "Link down latency exceeded threshold" ) |
| 1454 | main.log.info( "Results for iteration " + str( i ) + |
| 1455 | "have been omitted" ) |
| 1456 | |
| 1457 | # NOTE: To remove loss rate and measure latency: |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1458 | # 'sh tc qdisc del dev s1-eth1 root' |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1459 | timestampLinkUpT0 = time.time() * 1000 |
| 1460 | main.Mininet1.handle.sendline( "sh tc qdisc del dev " + |
| 1461 | "s1-eth1 root" ) |
| 1462 | main.Mininet1.handle.expect( "mininet>" ) |
| 1463 | |
| 1464 | main.log.info( "Checking ONOS for link update" ) |
| 1465 | |
| 1466 | linkDown1 = True |
| 1467 | linkDown2 = True |
| 1468 | linkDown3 = True |
| 1469 | loopCount = 0 |
| 1470 | while( ( linkDown1 and linkDown2 and linkDown3 ) |
| 1471 | and loopCount < 30 ): |
| 1472 | jsonStr1 = main.ONOS1cli.links() |
| 1473 | jsonStr2 = main.ONOS2cli.links() |
| 1474 | jsonStr3 = main.ONOS3cli.links() |
| 1475 | if not ( jsonStr1 and jsonStr2 and jsonStr3 ): |
| 1476 | main.log.error( "CLI command returned error " ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1477 | break |
| 1478 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1479 | jsonObj1 = json.loads( jsonStr1 ) |
| 1480 | jsonObj2 = json.loads( jsonStr2 ) |
| 1481 | jsonObj3 = json.loads( jsonStr3 ) |
| 1482 | |
| 1483 | for obj1 in jsonObj1: |
| 1484 | if '01' in obj1[ 'src' ][ 'device' ]: |
| 1485 | linkDown1 = False |
| 1486 | main.log.info( "Link up from " + |
| 1487 | "s1 -> s2 on ONOS1 detected" ) |
| 1488 | for obj2 in jsonObj2: |
| 1489 | if '01' in obj2[ 'src' ][ 'device' ]: |
| 1490 | linkDown2 = False |
| 1491 | main.log.info( "Link up from " + |
| 1492 | "s1 -> s2 on ONOS2 detected" ) |
| 1493 | for obj3 in jsonObj3: |
| 1494 | if '01' in obj3[ 'src' ][ 'device' ]: |
| 1495 | linkDown3 = False |
| 1496 | main.log.info( "Link up from " + |
| 1497 | "s1 -> s2 on ONOS3 detected" ) |
| 1498 | |
| 1499 | loopCount += 1 |
| 1500 | time.sleep( 1 ) |
| 1501 | |
| 1502 | if ( linkDown1 and linkDown2 and linkDown3 ): |
| 1503 | main.log.info( "Link up discovery failed" ) |
| 1504 | |
| 1505 | linkUpLatGraph1 = 0 |
| 1506 | linkUpLatGraph2 = 0 |
| 1507 | linkUpLatGraph3 = 0 |
| 1508 | linkUpLatDevice1 = 0 |
| 1509 | linkUpLatDevice2 = 0 |
| 1510 | linkUpLatDevice3 = 0 |
| 1511 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1512 | assertion = main.FALSE |
| 1513 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1514 | jsonTopoMetrics1 =\ |
| 1515 | main.ONOS1cli.topologyEventsMetrics() |
| 1516 | jsonTopoMetrics2 =\ |
| 1517 | main.ONOS2cli.topologyEventsMetrics() |
| 1518 | jsonTopoMetrics3 =\ |
| 1519 | main.ONOS3cli.topologyEventsMetrics() |
| 1520 | jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 ) |
| 1521 | jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 ) |
| 1522 | jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1523 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1524 | main.log.info( "Obtaining graph and device timestamp" ) |
| 1525 | graphTimestamp1 = \ |
| 1526 | jsonTopoMetrics1[ graphTimestamp ][ 'value' ] |
| 1527 | graphTimestamp2 = \ |
| 1528 | jsonTopoMetrics2[ graphTimestamp ][ 'value' ] |
| 1529 | graphTimestamp3 = \ |
| 1530 | jsonTopoMetrics3[ graphTimestamp ][ 'value' ] |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1531 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1532 | linkTimestamp1 = \ |
| 1533 | jsonTopoMetrics1[ linkTimestamp ][ 'value' ] |
| 1534 | linkTimestamp2 = \ |
| 1535 | jsonTopoMetrics2[ linkTimestamp ][ 'value' ] |
| 1536 | linkTimestamp3 = \ |
| 1537 | jsonTopoMetrics3[ linkTimestamp ][ 'value' ] |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1538 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1539 | if graphTimestamp1 and graphTimestamp2 and\ |
| 1540 | graphTimestamp3 and linkTimestamp1 and\ |
| 1541 | linkTimestamp2 and linkTimestamp3: |
| 1542 | linkUpLatGraph1 = int( graphTimestamp1 ) -\ |
| 1543 | int( timestampLinkUpT0 ) |
| 1544 | linkUpLatGraph2 = int( graphTimestamp2 ) -\ |
| 1545 | int( timestampLinkUpT0 ) |
| 1546 | linkUpLatGraph3 = int( graphTimestamp3 ) -\ |
| 1547 | int( timestampLinkUpT0 ) |
| 1548 | |
| 1549 | linkUpLatLink1 = int( linkTimestamp1 ) -\ |
| 1550 | int( timestampLinkUpT0 ) |
| 1551 | linkUpLatLink2 = int( linkTimestamp2 ) -\ |
| 1552 | int( timestampLinkUpT0 ) |
| 1553 | linkUpLatLink3 = int( linkTimestamp3 ) -\ |
| 1554 | int( timestampLinkUpT0 ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1555 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1556 | main.log.error( "There was an error calculating" + |
| 1557 | " the delta for link down event" ) |
| 1558 | linkUpLatGraph1 = 0 |
| 1559 | linkUpLatGraph2 = 0 |
| 1560 | linkUpLatGraph3 = 0 |
kelvin-onlab | 8a83258 | 2015-01-16 17:06:11 -0800 | [diff] [blame] | 1561 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1562 | linkUpLatDevice1 = 0 |
| 1563 | linkUpLatDevice2 = 0 |
| 1564 | linkUpLatDevice3 = 0 |
| 1565 | |
| 1566 | if debugMode == 'on': |
| 1567 | main.log.info( "Link up latency ONOS1 iteration " + |
| 1568 | str( i ) + " (end-to-end): " + |
| 1569 | str( linkUpLatGraph1 ) + " ms" ) |
| 1570 | main.log.info( "Link up latency ONOS2 iteration " + |
| 1571 | str( i ) + " (end-to-end): " + |
| 1572 | str( linkUpLatGraph2 ) + " ms" ) |
| 1573 | main.log.info( "Link up latency ONOS3 iteration " + |
| 1574 | str( i ) + " (end-to-end): " + |
| 1575 | str( linkUpLatGraph3 ) + " ms" ) |
| 1576 | |
| 1577 | main.log.info( |
| 1578 | "Link up latency ONOS1 iteration " + |
| 1579 | str( i ) + |
| 1580 | " (link-event-to-system-timestamp): " + |
| 1581 | str( linkUpLatLink1 ) + |
| 1582 | " ms" ) |
| 1583 | main.log.info( |
| 1584 | "Link up latency ONOS2 iteration " + |
| 1585 | str( i ) + |
| 1586 | " (link-event-to-system-timestamp): " + |
| 1587 | str( linkUpLatLink2 ) + |
| 1588 | " ms" ) |
| 1589 | main.log.info( |
| 1590 | "Link up latency ONOS3 iteration " + |
| 1591 | str( i ) + |
| 1592 | " (link-event-to-system-timestamp): " + |
| 1593 | str( linkUpLatLink3 ) ) |
| 1594 | |
| 1595 | # Calculate avg of node calculations |
| 1596 | linkUpLatGraphAvg =\ |
| 1597 | ( linkUpLatGraph1 + |
| 1598 | linkUpLatGraph2 + |
| 1599 | linkUpLatGraph3 ) / 3 |
| 1600 | linkUpLatLinkAvg =\ |
| 1601 | ( linkUpLatLink1 + |
| 1602 | linkUpLatLink2 + |
| 1603 | linkUpLatLink3 ) / 3 |
| 1604 | |
| 1605 | # Set threshold and append latency to list |
| 1606 | if linkUpLatGraphAvg > upThresholdMin and\ |
| 1607 | linkUpLatGraphAvg < upThresholdMax: |
| 1608 | linkUpGraphToSystemList.append( |
| 1609 | linkUpLatGraphAvg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1610 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1611 | main.log.info( "Link up latency exceeded threshold" ) |
| 1612 | main.log.info( "Results for iteration " + str( i ) + |
| 1613 | "have been omitted" ) |
| 1614 | if linkUpLatLinkAvg > upThresholdMin and\ |
| 1615 | linkUpLatLinkAvg < upThresholdMax: |
| 1616 | linkUpLinkToSystemList.append( |
| 1617 | linkUpLatLinkAvg ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1618 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1619 | main.log.info( "Link up latency exceeded threshold" ) |
| 1620 | main.log.info( "Results for iteration " + str( i ) + |
| 1621 | "have been omitted" ) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1622 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1623 | # Calculate min, max, avg of list and report |
| 1624 | linkDownMin = min( linkDownGraphToSystemList ) |
| 1625 | linkDownMax = max( linkDownGraphToSystemList ) |
| 1626 | linkDownAvg = sum( linkDownGraphToSystemList ) / \ |
| 1627 | len( linkDownGraphToSystemList ) |
| 1628 | linkUpMin = min( linkUpGraphToSystemList ) |
| 1629 | linkUpMax = max( linkUpGraphToSystemList ) |
| 1630 | linkUpAvg = sum( linkUpGraphToSystemList ) / \ |
| 1631 | len( linkUpGraphToSystemList ) |
| 1632 | linkDownStdDev = \ |
| 1633 | str( round( numpy.std( linkDownGraphToSystemList ), 1 ) ) |
| 1634 | linkUpStdDev = \ |
| 1635 | str( round( numpy.std( linkUpGraphToSystemList ), 1 ) ) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1636 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1637 | main.log.report( "Link down latency " + |
| 1638 | "Avg: " + str( linkDownAvg ) + " ms " + |
| 1639 | "Std Deviation: " + linkDownStdDev + " ms" ) |
| 1640 | main.log.report( "Link up latency " + |
| 1641 | "Avg: " + str( linkUpAvg ) + " ms " + |
| 1642 | "Std Deviation: " + linkUpStdDev + " ms" ) |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1643 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1644 | utilities.assert_equals( |
| 1645 | expect=main.TRUE, |
| 1646 | actual=assertion, |
| 1647 | onpass="Link discovery latency calculation successful", |
| 1648 | onfail="Link discovery latency case failed" ) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1649 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1650 | def CASE5( self, main ): |
| 1651 | """ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1652 | 100 Switch discovery latency |
| 1653 | |
| 1654 | Important: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1655 | This test case can be potentially dangerous if |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1656 | your machine has previously set iptables rules. |
| 1657 | One of the steps of the test case will flush |
| 1658 | all existing iptables rules. |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1659 | Note: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1660 | You can specify the number of switches in the |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1661 | params file to adjust the switch discovery size |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1662 | ( and specify the corresponding topology in Mininet1 |
| 1663 | .topo file ) |
| 1664 | """ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1665 | import time |
| 1666 | import subprocess |
| 1667 | import os |
| 1668 | import requests |
| 1669 | import json |
| 1670 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1671 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1672 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1673 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1674 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 1675 | ONOSUser = main.params[ 'CTRL' ][ 'user' ] |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1676 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1677 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1678 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1679 | # Number of iterations of case |
| 1680 | numIter = main.params[ 'TEST' ][ 'numIter' ] |
| 1681 | numSw = main.params[ 'TEST' ][ 'numSwitch' ] |
andrewonlab | 58f7d70 | 2014-11-07 13:21:19 -0500 | [diff] [blame] | 1682 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1683 | # Timestamp 'keys' for json metrics output. |
| 1684 | # These are subject to change, hence moved into params |
| 1685 | deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ] |
| 1686 | graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ] |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1687 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1688 | debugMode = main.params[ 'TEST' ][ 'debugMode' ] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1689 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1690 | localTime = time.strftime( '%X' ) |
| 1691 | localTime = localTime.replace( "/", "" ) |
| 1692 | localTime = localTime.replace( " ", "_" ) |
| 1693 | localTime = localTime.replace( ":", "" ) |
| 1694 | if debugMode == 'on': |
| 1695 | main.ONOS1.tsharkPcap( "eth0", |
| 1696 | "/tmp/100_sw_lat_pcap_" + localTime ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1697 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1698 | # Threshold for this test case |
| 1699 | swDiscThresholdStr = main.params[ 'TEST' ][ 'swDisc100Threshold' ] |
| 1700 | swDiscThresholdObj = swDiscThresholdStr.split( "," ) |
| 1701 | swDiscThresholdMin = int( swDiscThresholdObj[ 0 ] ) |
| 1702 | swDiscThresholdMax = int( swDiscThresholdObj[ 1 ] ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1703 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1704 | tsharkOfpOutput = "/tmp/tshark_ofp_" + numSw + "sw.txt" |
| 1705 | tsharkTcpOutput = "/tmp/tshark_tcp_" + numSw + "sw.txt" |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1706 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1707 | tsharkOfpResultList = [] |
| 1708 | tsharkTcpResultList = [] |
| 1709 | |
| 1710 | swDiscoveryLatList = [] |
| 1711 | |
| 1712 | main.case( numSw + " Switch discovery latency" ) |
| 1713 | main.step( "Assigning all switches to ONOS1" ) |
| 1714 | for i in range( 1, int( numSw ) + 1 ): |
| 1715 | main.Mininet1.assignSwController( |
| 1716 | sw=str( i ), |
| 1717 | ip1=ONOS1Ip, |
| 1718 | port1=defaultSwPort ) |
| 1719 | |
| 1720 | # Ensure that nodes are configured with ptpd |
| 1721 | # Just a warning message |
| 1722 | main.log.info( "Please check ptpd configuration to ensure" + |
| 1723 | " All nodes' system times are in sync" ) |
| 1724 | time.sleep( 5 ) |
| 1725 | |
| 1726 | for i in range( 0, int( numIter ) ): |
| 1727 | |
| 1728 | main.step( "Set iptables rule to block incoming sw connections" ) |
| 1729 | # Set iptables rule to block incoming switch connections |
| 1730 | # The rule description is as follows: |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1731 | # Append to INPUT rule, |
| 1732 | # behavior DROP that matches following: |
| 1733 | # * packet type: tcp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1734 | # * source IP: MN1Ip |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1735 | # * destination PORT: 6633 |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1736 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1737 | "sudo iptables -A INPUT -p tcp -s " + MN1Ip + |
| 1738 | " --dport " + defaultSwPort + " -j DROP" ) |
| 1739 | main.ONOS1.handle.expect( "\$" ) |
| 1740 | # Append to OUTPUT rule, |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1741 | # behavior DROP that matches following: |
| 1742 | # * packet type: tcp |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1743 | # * source IP: MN1Ip |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1744 | # * destination PORT: 6633 |
| 1745 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1746 | "sudo iptables -A OUTPUT -p tcp -s " + MN1Ip + |
| 1747 | " --dport " + defaultSwPort + " -j DROP" ) |
| 1748 | main.ONOS1.handle.expect( "\$" ) |
| 1749 | # Give time to allow rule to take effect |
| 1750 | # NOTE: Sleep period may need to be configured |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 1751 | # based on the number of switches in the topology |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1752 | main.log.info( "Please wait for switch connection to " + |
| 1753 | "time out" ) |
| 1754 | time.sleep( 60 ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1755 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1756 | # Gather vendor OFP with tshark |
| 1757 | main.ONOS1.tsharkGrep( "OFP 86 Vendor", |
| 1758 | tsharkOfpOutput ) |
| 1759 | main.ONOS1.tsharkGrep( "TCP 74 ", |
| 1760 | tsharkTcpOutput ) |
| 1761 | |
| 1762 | # NOTE: Remove all iptables rule quickly ( flush ) |
| 1763 | # Before removal, obtain TestON timestamp at which |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1764 | # removal took place |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1765 | # ( ensuring nodes are configured via ptp ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1766 | # sudo iptables -F |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1767 | |
| 1768 | t0System = time.time() * 1000 |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1769 | main.ONOS1.handle.sendline( |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1770 | "sudo iptables -F" ) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1771 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1772 | # Counter to track loop count |
| 1773 | counterLoop = 0 |
| 1774 | counterAvail1 = 0 |
| 1775 | counterAvail2 = 0 |
| 1776 | counterAvail3 = 0 |
| 1777 | onos1Dev = False |
| 1778 | onos2Dev = False |
| 1779 | onos3Dev = False |
| 1780 | while counterLoop < 60: |
| 1781 | # Continue to check devices for all device |
| 1782 | # availability. When all devices in all 3 |
| 1783 | # ONOS instances indicate that devices are available |
| 1784 | # obtain graph event timestamp for t1. |
| 1785 | deviceStrObj1 = main.ONOS1cli.devices() |
| 1786 | deviceStrObj2 = main.ONOS2cli.devices() |
| 1787 | deviceStrObj3 = main.ONOS3cli.devices() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1788 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1789 | deviceJson1 = json.loads( deviceStrObj1 ) |
| 1790 | deviceJson2 = json.loads( deviceStrObj2 ) |
| 1791 | deviceJson3 = json.loads( deviceStrObj3 ) |
| 1792 | |
| 1793 | for device1 in deviceJson1: |
| 1794 | if device1[ 'available' ]: |
| 1795 | counterAvail1 += 1 |
| 1796 | if counterAvail1 == int( numSw ): |
| 1797 | onos1Dev = True |
| 1798 | main.log.info( "All devices have been " + |
| 1799 | "discovered on ONOS1" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1800 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1801 | counterAvail1 = 0 |
| 1802 | for device2 in deviceJson2: |
| 1803 | if device2[ 'available' ]: |
| 1804 | counterAvail2 += 1 |
| 1805 | if counterAvail2 == int( numSw ): |
| 1806 | onos2Dev = True |
| 1807 | main.log.info( "All devices have been " + |
| 1808 | "discovered on ONOS2" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1809 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1810 | counterAvail2 = 0 |
| 1811 | for device3 in deviceJson3: |
| 1812 | if device3[ 'available' ]: |
| 1813 | counterAvail3 += 1 |
| 1814 | if counterAvail3 == int( numSw ): |
| 1815 | onos3Dev = True |
| 1816 | main.log.info( "All devices have been " + |
| 1817 | "discovered on ONOS3" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1818 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1819 | counterAvail3 = 0 |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1820 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1821 | if onos1Dev and onos2Dev and onos3Dev: |
| 1822 | main.log.info( "All devices have been discovered " + |
| 1823 | "on all ONOS instances" ) |
| 1824 | jsonStrTopologyMetrics1 =\ |
| 1825 | main.ONOS1cli.topologyEventsMetrics() |
| 1826 | jsonStrTopologyMetrics2 =\ |
| 1827 | main.ONOS2cli.topologyEventsMetrics() |
| 1828 | jsonStrTopologyMetrics3 =\ |
| 1829 | main.ONOS3cli.topologyEventsMetrics() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1830 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1831 | # Exit while loop if all devices discovered |
| 1832 | break |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1833 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1834 | counterLoop += 1 |
| 1835 | # Give some time in between CLI calls |
| 1836 | #( will not affect measurement ) |
| 1837 | time.sleep( 3 ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1838 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1839 | main.ONOS1.tsharkStop() |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1840 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1841 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 1842 | tsharkOfpOutput + " /tmp/" ) |
| 1843 | os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" + |
| 1844 | tsharkTcpOutput + " /tmp/" ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1845 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1846 | # TODO: Automate OFP output analysis |
| 1847 | # Debug mode - print out packets captured at runtime |
| 1848 | if debugMode == 'on': |
| 1849 | ofpFile = open( tsharkOfpOutput, 'r' ) |
| 1850 | main.log.info( "Tshark OFP Vendor output: " ) |
| 1851 | for line in ofpFile: |
| 1852 | tsharkOfpResultList.append( line ) |
| 1853 | main.log.info( line ) |
| 1854 | ofpFile.close() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1855 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1856 | tcpFile = open( tsharkTcpOutput, 'r' ) |
| 1857 | main.log.info( "Tshark TCP 74 output: " ) |
| 1858 | for line in tcpFile: |
| 1859 | tsharkTcpResultList.append( line ) |
| 1860 | main.log.info( line ) |
| 1861 | tcpFile.close() |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1862 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1863 | jsonObj1 = json.loads( jsonStrTopologyMetrics1 ) |
| 1864 | jsonObj2 = json.loads( jsonStrTopologyMetrics2 ) |
| 1865 | jsonObj3 = json.loads( jsonStrTopologyMetrics3 ) |
| 1866 | |
| 1867 | graphTimestamp1 = \ |
| 1868 | jsonObj1[ graphTimestamp ][ 'value' ] |
| 1869 | graphTimestamp2 = \ |
| 1870 | jsonObj2[ graphTimestamp ][ 'value' ] |
| 1871 | graphTimestamp3 = \ |
| 1872 | jsonObj3[ graphTimestamp ][ 'value' ] |
| 1873 | |
| 1874 | graphLat1 = int( graphTimestamp1 ) - int( t0System ) |
| 1875 | graphLat2 = int( graphTimestamp2 ) - int( t0System ) |
| 1876 | graphLat3 = int( graphTimestamp3 ) - int( t0System ) |
| 1877 | |
| 1878 | avgGraphLat = \ |
| 1879 | ( int( graphLat1 ) + |
| 1880 | int( graphLat2 ) + |
| 1881 | int( graphLat3 ) ) / 3 |
| 1882 | |
| 1883 | if avgGraphLat > swDiscThresholdMin \ |
| 1884 | and avgGraphLat < swDiscThresholdMax: |
| 1885 | swDiscoveryLatList.append( |
| 1886 | avgGraphLat ) |
andrewonlab | e5bcef9 | 2014-11-06 17:53:20 -0500 | [diff] [blame] | 1887 | else: |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1888 | main.log.info( "100 Switch discovery latency " + |
| 1889 | "exceeded the threshold." ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1890 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1891 | # END ITERATION FOR LOOP |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1892 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1893 | swLatMin = min( swDiscoveryLatList ) |
| 1894 | swLatMax = max( swDiscoveryLatList ) |
| 1895 | swLatAvg = sum( swDiscoveryLatList ) /\ |
| 1896 | len( swDiscoveryLatList ) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1897 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1898 | main.log.report( "100 Switch discovery lat " + |
| 1899 | "Min: " + str( swLatMin ) + " ms" + |
| 1900 | "Max: " + str( swLatMax ) + " ms" + |
| 1901 | "Avg: " + str( swLatAvg ) + " ms" ) |
| 1902 | |
| 1903 | def CASE6( self, main ): |
| 1904 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1905 | Increase number of nodes and initiate CLI |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1906 | """ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1907 | import time |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1908 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1909 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1910 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 1911 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 1912 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 1913 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 1914 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 1915 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1916 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1917 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1918 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1919 | global clusterCount |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1920 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1921 | # Cluster size increased everytime the case is defined |
| 1922 | clusterCount += 2 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1923 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1924 | main.log.report( "Increasing cluster size to " + |
| 1925 | str( clusterCount ) ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1926 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1927 | installResult = main.FALSE |
| 1928 | if clusterCount == 3: |
| 1929 | main.log.info( "Installing nodes 2 and 3" ) |
| 1930 | node2Result = \ |
| 1931 | main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 1932 | node3Result = \ |
| 1933 | main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 1934 | installResult = node2Result and node3Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1935 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1936 | time.sleep( 5 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1937 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1938 | main.ONOS2cli.startOnosCli( ONOS2Ip ) |
| 1939 | main.ONOS3cli.startOnosCli( ONOS3Ip ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1940 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1941 | elif clusterCount == 5: |
| 1942 | main.log.info( "Installing nodes 4 and 5" ) |
| 1943 | node4Result = \ |
| 1944 | main.ONOSbench.onosInstall( node=ONOS4Ip ) |
| 1945 | node5Result = \ |
| 1946 | main.ONOSbench.onosInstall( node=ONOS5Ip ) |
| 1947 | installResult = node4Result and node5Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1948 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1949 | time.sleep( 5 ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1950 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1951 | main.ONOS4cli.startOnosCli( ONOS4Ip ) |
| 1952 | main.ONOS5cli.startOnosCli( ONOS5Ip ) |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1953 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1954 | elif clusterCount == 7: |
andrewonlab | 6763069 | 2015-01-29 20:16:01 -0500 | [diff] [blame] | 1955 | main.log.info( "Installing nodes 6 and 7" ) |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1956 | node6Result = \ |
| 1957 | main.ONOSbench.onosInstall( node=ONOS6Ip ) |
| 1958 | node7Result = \ |
| 1959 | main.ONOSbench.onosInstall( node=ONOS7Ip ) |
| 1960 | installResult = node6Result and node7Result |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1961 | |
andrewonlab | 79244cc | 2015-01-26 01:11:49 -0500 | [diff] [blame] | 1962 | time.sleep( 5 ) |
| 1963 | |
| 1964 | main.ONOS6cli.startOnosCli( ONOS6Ip ) |
| 1965 | main.ONOS7cli.startOnosCli( ONOS7Ip ) |