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