blob: 0f37909576c1fd8de3e3c91d2b658f7f34988494 [file] [log] [blame]
andrewonlab79244cc2015-01-26 01:11:49 -05001# TopoPerfNext
andrewonlab2a6c9342014-10-16 13:40:15 -04002#
andrewonlab79244cc2015-01-26 01:11:49 -05003# Topology Performance test for ONOS-next
andrewonlab2a6c9342014-10-16 13:40:15 -04004#
andrewonlab79244cc2015-01-26 01:11:49 -05005# andrew@onlab.us
andrewonlab4f50ec92014-11-11 14:24:45 -05006#
andrewonlab79244cc2015-01-26 01:11:49 -05007# If your machine does not come with numpy
8# run the following command:
9# sudo apt-get install python-numpy python-scipy
andrewonlab2a6c9342014-10-16 13:40:15 -040010
11import time
12import sys
13import os
14import re
15
andrewonlab79244cc2015-01-26 01:11:49 -050016
andrewonlab2a6c9342014-10-16 13:40:15 -040017class TopoPerfNext:
andrewonlab79244cc2015-01-26 01:11:49 -050018
19 def __init__( self ):
andrewonlab2a6c9342014-10-16 13:40:15 -040020 self.default = ''
21
andrewonlab79244cc2015-01-26 01:11:49 -050022 def CASE1( self, main ):
23 """
andrewonlab2a6c9342014-10-16 13:40:15 -040024 ONOS startup sequence
andrewonlab79244cc2015-01-26 01:11:49 -050025 """
andrewonlabe9fb6722014-10-24 12:20:35 -040026 import time
andrewonlab79244cc2015-01-26 01:11:49 -050027
28 # Global cluster count for scale-out purposes
29 global clusterCount
andrewonlab86e9e082015-02-13 12:07:39 -050030 #TODO: fix run number implementation
31 global runNum
andrewonlabc8aea6d2015-02-19 20:09:30 -050032 global timeToPost
33
34 #Test run time
35 timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
andrewonlab79244cc2015-01-26 01:11:49 -050036 # Set initial cluster count
37 clusterCount = 1
andrewonlaba57a3042015-01-23 13:53:05 -050038 ##
andrewonlab2a6c9342014-10-16 13:40:15 -040039
andrewonlab86e9e082015-02-13 12:07:39 -050040 runNum = time.strftime("%d%H%M%S")
41
andrewonlab79244cc2015-01-26 01:11:49 -050042 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab2a6c9342014-10-16 13:40:15 -040043
andrewonlab79244cc2015-01-26 01:11:49 -050044 gitPull = main.params[ 'GIT' ][ 'autoPull' ]
45 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080046
andrewonlab79244cc2015-01-26 01:11:49 -050047 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
andrewonlabc8aea6d2015-02-19 20:09:30 -050061 portEventResultPath = main.params[ 'DB' ][ 'portEventResultPath' ]
62 switchEventResultPath = main.params[ 'DB' ][ 'switchEventResultPath' ]
63
andrewonlab79244cc2015-01-26 01:11:49 -050064 mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ]
andrewonlaba57a3042015-01-23 13:53:05 -050065
andrewonlab79244cc2015-01-26 01:11:49 -050066 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( "\$" )
andrewonlab6c8bbeb2014-11-14 12:43:48 -050074
andrewonlab79244cc2015-01-26 01:11:49 -050075 main.log.report( "Setting up test environment" )
andrewonlab2a6c9342014-10-16 13:40:15 -040076
andrewonlab5b954b02015-02-05 13:03:46 -050077 main.step( "Starting mininet topology " )
78 main.Mininet1.startNet()
79
andrewonlab79244cc2015-01-26 01:11:49 -050080 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 )
andrewonlab67630692015-01-29 20:16:01 -050086 main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
andrewonlab0e1825c2014-11-20 20:07:00 -050087
andrewonlabc8aea6d2015-02-19 20:09:30 -050088 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
andrewonlab79244cc2015-01-26 01:11:49 -050096 main.step( "Creating cell file" )
97 cellFileResult = main.ONOSbench.createCellFile(
98 BENCHIp, cellName, MN1Ip,
andrewonlabc8aea6d2015-02-19 20:09:30 -050099 ("onos-core,onos-api,webconsole,onos-app-metrics,onos-app-gui,"
100 "onos-cli,onos-openflow"),
andrewonlab79244cc2015-01-26 01:11:49 -0500101 ONOS1Ip )
andrewonlab2a6c9342014-10-16 13:40:15 -0400102
andrewonlab79244cc2015-01-26 01:11:49 -0500103 main.step( "Applying cell file to environment" )
104 cellApplyResult = main.ONOSbench.setCell( cellName )
105 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab6c8bbeb2014-11-14 12:43:48 -0500106
andrewonlab79244cc2015-01-26 01:11:49 -0500107 # NOTE: This step may be removed after proper
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 # copy cat log functionality
andrewonlab79244cc2015-01-26 01:11:49 -0500109 main.step( "Removing raft/copy-cat logs from ONOS nodes" )
110 main.ONOSbench.onosRemoveRaftLogs()
111 time.sleep( 30 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800112
andrewonlab79244cc2015-01-26 01:11:49 -0500113 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()
andrewonlab2a6c9342014-10-16 13:40:15 -0400119 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500120 checkoutResult = main.TRUE
121 pullResult = main.TRUE
122 main.log.info( "Skipped git checkout and pull" )
andrewonlab2a6c9342014-10-16 13:40:15 -0400123
andrewonlab79244cc2015-01-26 01:11:49 -0500124 main.log.report( "Commit information - " )
125 main.ONOSbench.getVersion( report=True )
andrewonlab92844342014-11-18 16:39:11 -0500126
andrewonlab79244cc2015-01-26 01:11:49 -0500127 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
andrewonlab2a6c9342014-10-16 13:40:15 -0400133
andrewonlab79244cc2015-01-26 01:11:49 -0500134 main.step( "Set cell for ONOS cli env" )
135 main.ONOS1cli.setCell( cellName )
andrewonlabb1998c52014-11-10 13:31:43 -0500136
andrewonlab79244cc2015-01-26 01:11:49 -0500137 main.step( "Creating ONOS package" )
138 packageResult = main.ONOSbench.onosPackage()
andrewonlab2a6c9342014-10-16 13:40:15 -0400139
andrewonlab79244cc2015-01-26 01:11:49 -0500140 main.step( "Installing ONOS package" )
141 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
andrewonlab2a6c9342014-10-16 13:40:15 -0400142
andrewonlab79244cc2015-01-26 01:11:49 -0500143 time.sleep( 10 )
andrewonlabe9fb6722014-10-24 12:20:35 -0400144
andrewonlab79244cc2015-01-26 01:11:49 -0500145 main.step( "Start onos cli" )
146 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
andrewonlabe9fb6722014-10-24 12:20:35 -0400147
andrewonlab79244cc2015-01-26 01:11:49 -0500148 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" )
andrewonlab2a6c9342014-10-16 13:40:15 -0400156
andrewonlab79244cc2015-01-26 01:11:49 -0500157 def CASE2( self, main ):
158 """
andrewonlabba44bcf2014-10-16 16:54:41 -0400159 Assign s1 to ONOS1 and measure latency
andrewonlab79244cc2015-01-26 01:11:49 -0500160
andrewonlab3a7c3c72014-10-24 17:21:03 -0400161 There are 4 levels of latency measurements to this test:
andrewonlab79244cc2015-01-26 01:11:49 -0500162 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
andrewonlab3a7c3c72014-10-24 17:21:03 -0400165 measurement from OFP Vendor message to Graph change
andrewonlab79244cc2015-01-26 01:11:49 -0500166 3 ) OFP-to-device measurement: 'ONOS processing without
andrewonlab3a7c3c72014-10-24 17:21:03 -0400167 graph change' snippet of measurement from OFP vendor
168 message to Device change timestamp
andrewonlab79244cc2015-01-26 01:11:49 -0500169 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 """
andrewonlabba44bcf2014-10-16 16:54:41 -0400174 import time
andrewonlabe6745342014-10-17 14:29:13 -0400175 import subprocess
176 import json
177 import requests
178 import os
andrewonlab4f50ec92014-11-11 14:24:45 -0500179 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500180 global clusterCount
andrewonlabc8aea6d2015-02-19 20:09:30 -0500181 global timeToPost
andrewonlabba44bcf2014-10-16 16:54:41 -0400182
andrewonlab79244cc2015-01-26 01:11:49 -0500183 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' ]
andrewonlabe6745342014-10-17 14:29:13 -0400190
andrewonlab79244cc2015-01-26 01:11:49 -0500191 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4b5c8b92014-11-10 16:04:33 -0500192
andrewonlab79244cc2015-01-26 01:11:49 -0500193 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab226024e2014-10-24 16:01:32 -0400194
andrewonlab79244cc2015-01-26 01:11:49 -0500195 # 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' ] )
andrewonlab58f7d702014-11-07 13:21:19 -0500199
andrewonlab79244cc2015-01-26 01:11:49 -0500200 # 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' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500204
andrewonlab79244cc2015-01-26 01:11:49 -0500205 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
206 onosLog = main.params[ 'TEST' ][ 'onosLogFile' ]
andrewonlabc8aea6d2015-02-19 20:09:30 -0500207 resultPath = main.params[ 'DB' ][ 'switchEventResultPath' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800208
andrewonlab79244cc2015-01-26 01:11:49 -0500209 # Threshold for the test
210 thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ]
211 thresholdObj = thresholdStr.split( "," )
212 thresholdMin = int( thresholdObj[ 0 ] )
213 thresholdMax = int( thresholdObj[ 1 ] )
andrewonlab226024e2014-10-24 16:01:32 -0400214
andrewonlab79244cc2015-01-26 01:11:49 -0500215 # List of switch add latency collected from
216 # all iterations
217 latencyEndToEndList = []
218 latencyOfpToGraphList = []
219 latencyOfpToDeviceList = []
220 latencyT0ToDeviceList = []
221 latencyTcpToOfpList = []
andrewonlabba44bcf2014-10-16 16:54:41 -0400222
andrewonlab67630692015-01-29 20:16:01 -0500223 # 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
andrewonlab79244cc2015-01-26 01:11:49 -0500229 # 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
andrewonlabe6745342014-10-17 14:29:13 -0400238 assertion = main.TRUE
andrewonlabb1998c52014-11-10 13:31:43 -0500239
andrewonlab79244cc2015-01-26 01:11:49 -0500240 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 )
andrewonlab58f7d702014-11-07 13:21:19 -0500247
andrewonlab79244cc2015-01-26 01:11:49 -0500248 main.log.info( "Debug mode is on" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400249
andrewonlab79244cc2015-01-26 01:11:49 -0500250 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 ) )
andrewonlabba44bcf2014-10-16 16:54:41 -0400254
andrewonlab79244cc2015-01-26 01:11:49 -0500255 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
andrewonlabba44bcf2014-10-16 16:54:41 -0400260 # the switch for end-to-end measurement
andrewonlab79244cc2015-01-26 01:11:49 -0500261 #* OFP [ Stats Reply ] is used for t0B
andrewonlabba44bcf2014-10-16 16:54:41 -0400262 # the very last OFP message between ONOS
263 # and the switch for ONOS measurement
andrewonlab79244cc2015-01-26 01:11:49 -0500264 main.ONOS1.tsharkGrep( tsharkTcpString,
265 tsharkTcpOutput )
266 main.ONOS1.tsharkGrep( tsharkOfString,
267 tsharkOfOutput )
andrewonlabba44bcf2014-10-16 16:54:41 -0400268
andrewonlab79244cc2015-01-26 01:11:49 -0500269 # Wait and ensure tshark is started and
270 # capturing
271 time.sleep( 10 )
andrewonlabba44bcf2014-10-16 16:54:41 -0400272
andrewonlab79244cc2015-01-26 01:11:49 -0500273 main.log.info( "Assigning s1 to controller" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400274
andrewonlab79244cc2015-01-26 01:11:49 -0500275 main.Mininet1.assignSwController(
276 sw="1",
277 ip1=ONOS1Ip,
278 port1=defaultSwPort )
andrewonlabba44bcf2014-10-16 16:54:41 -0400279
andrewonlab79244cc2015-01-26 01:11:49 -0500280 # Wait and ensure switch is assigned
281 # before stopping tshark
282 time.sleep( 30 )
andrewonlabba44bcf2014-10-16 16:54:41 -0400283
andrewonlab79244cc2015-01-26 01:11:49 -0500284 main.log.info( "Stopping all Tshark processes" )
285 main.ONOS1.stopTshark()
kelvin-onlab8a832582015-01-16 17:06:11 -0800286
andrewonlab79244cc2015-01-26 01:11:49 -0500287 # 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
andrewonlabe6745342014-10-17 14:29:13 -0400304 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500305 main.log.error( "Tshark output file for TCP" +
306 " returned unexpected results" )
307 t0Tcp = 0
andrewonlabe6745342014-10-17 14:29:13 -0400308 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500309
310 tcpFile.close()
andrewonlabe6745342014-10-17 14:29:13 -0400311 #****************
andrewonlabba44bcf2014-10-16 16:54:41 -0400312
andrewonlab79244cc2015-01-26 01:11:49 -0500313 # 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
andrewonlabe6745342014-10-17 14:29:13 -0400320 while True:
andrewonlab79244cc2015-01-26 01:11:49 -0500321 tempText = ofFile.readline()
322 if tempText != '':
323 lineOfp = tempText
andrewonlabe6745342014-10-17 14:29:13 -0400324 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500325 break
326 obj = lineOfp.split( " " )
327
328 main.log.info( "Object read in from OFP capture: " +
329 str( lineOfp ) )
330
andrewonlab5b954b02015-02-05 13:03:46 -0500331 if len( obj ) > 1:
andrewonlab79244cc2015-01-26 01:11:49 -0500332 t0Ofp = float( obj[ 1 ] ) * 1000.0
andrewonlabe6745342014-10-17 14:29:13 -0400333 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500334 main.log.error( "Tshark output file for OFP" +
335 " returned unexpected results" )
336 t0Ofp = 0
andrewonlabe6745342014-10-17 14:29:13 -0400337 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500338
339 ofFile.close()
andrewonlabe6745342014-10-17 14:29:13 -0400340 #****************
andrewonlab867212a2014-10-22 20:13:38 -0400341
andrewonlab79244cc2015-01-26 01:11:49 -0500342 jsonStr1 = main.ONOS1cli.topologyEventsMetrics()
343 # Initialize scale-out variables
344 jsonStr2 = ""
345 jsonStr3 = ""
346 jsonStr4 = ""
347 jsonStr5 = ""
348 jsonStr6 = ""
349 jsonStr7 = ""
andrewonlabe9fb6722014-10-24 12:20:35 -0400350
andrewonlab79244cc2015-01-26 01:11:49 -0500351 jsonObj1 = json.loads( jsonStr1 )
352 # Initialize scale-out variables
353 jsonObj2 = ""
354 jsonObj3 = ""
355 jsonObj4 = ""
356 jsonObj5 = ""
357 jsonObj6 = ""
358 jsonObj7 = ""
kelvin-onlab8a832582015-01-16 17:06:11 -0800359
andrewonlab79244cc2015-01-26 01:11:49 -0500360 # 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 )
andrewonlab79244cc2015-01-26 01:11:49 -0500371 # t0 to graph processing latency ( end-to-end )
372 deltaGraph1 = int( graphTimestamp1 ) - int( t0Tcp )
andrewonlab79244cc2015-01-26 01:11:49 -0500373 # ofp to graph processing latency ( ONOS processing )
374 deltaOfpGraph1 = int( graphTimestamp1 ) - int( t0Ofp )
andrewonlab79244cc2015-01-26 01:11:49 -0500375 # ofp to device processing latency ( ONOS processing )
376 deltaOfpDevice1 = float( deviceTimestamp1 ) - float( t0Ofp )
andrewonlab67630692015-01-29 20:16:01 -0500377 # 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")
andrewonlab79244cc2015-01-26 01:11:49 -0500409
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 )
andrewonlaba57a3042015-01-23 13:53:05 -0500436
andrewonlab67630692015-01-29 20:16:01 -0500437 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
andrewonlab79244cc2015-01-26 01:11:49 -0500461 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 )
andrewonlab67630692015-01-29 20:16:01 -0500484
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")
andrewonlaba57a3042015-01-23 13:53:05 -0500497
andrewonlab67630692015-01-29 20:16:01 -0500498 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
andrewonlab79244cc2015-01-26 01:11:49 -0500510 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 )
andrewonlab67630692015-01-29 20:16:01 -0500533
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")
andrewonlaba57a3042015-01-23 13:53:05 -0500546
andrewonlab67630692015-01-29 20:16:01 -0500547 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")
andrewonlabc8aea6d2015-02-19 20:09:30 -0500558
559 main.log.info("Switch up discovery latency")
560
561 main.log.info("Starting tshark capture")
andrewonlabba44bcf2014-10-16 16:54:41 -0400562
andrewonlab79244cc2015-01-26 01:11:49 -0500563 main.step( "Remove switch from controller" )
564 main.Mininet1.deleteSwController( "s1" )
andrewonlabf47993a2014-10-24 17:56:01 -0400565
andrewonlabc8aea6d2015-02-19 20:09:30 -0500566 #TODO: del controller does not have an OFP message.
567 # However, we can capture TCP Fin,Ack as T0
568
andrewonlab79244cc2015-01-26 01:11:49 -0500569 time.sleep( 5 )
570
571 # END of for loop iteration
572
andrewonlab67630692015-01-29 20:16:01 -0500573 #str( round( numpy.std( latencyT0ToDeviceList ), 1 ) )
andrewonlabc15c9582014-10-24 16:35:52 -0400574
andrewonlab67630692015-01-29 20:16:01 -0500575 endToEndAvg = 0
576 ofpToGraphAvg = 0
577 endToEndList = []
578 ofpToGraphList = []
andrewonlabc8aea6d2015-02-19 20:09:30 -0500579 dbCmdList = []
andrewonlab69864162014-11-11 16:28:48 -0500580
andrewonlab67630692015-01-29 20:16:01 -0500581 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)
andrewonlabc15c9582014-10-24 16:35:52 -0400596
andrewonlabc8aea6d2015-02-19 20:09:30 -0500597 endToEndAvg = round(numpy.mean(endToEndList), 2)
andrewonlab67630692015-01-29 20:16:01 -0500598 ofpToGraphAvg = numpy.mean(ofpToGraphList)
andrewonlabc8aea6d2015-02-19 20:09:30 -0500599 endToEndStd = round(numpy.std(endToEndList), 2)
andrewonlabc15c9582014-10-24 16:35:52 -0400600
andrewonlab67630692015-01-29 20:16:01 -0500601 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: "+
andrewonlabc8aea6d2015-02-19 20:09:30 -0500605 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 )
andrewonlabd5367a42015-01-30 14:46:17 -0500613 #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")
andrewonlab226024e2014-10-24 16:01:32 -0400618
andrewonlab79244cc2015-01-26 01:11:49 -0500619 if debugMode == 'on':
620 main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log",
621 "/tmp/", copyFileName="sw_lat_karaf" )
andrewonlabc8aea6d2015-02-19 20:09:30 -0500622
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()
andrewonlabb1998c52014-11-10 13:31:43 -0500629
andrewonlab67630692015-01-29 20:16:01 -0500630 #TODO: correct assert
631 assertion = main.TRUE
632
andrewonlab79244cc2015-01-26 01:11:49 -0500633 utilities.assert_equals( expect=main.TRUE, actual=assertion,
634 onpass="Switch latency test successful",
635 onfail="Switch latency test failed" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400636
andrewonlab79244cc2015-01-26 01:11:49 -0500637 def CASE3( self, main ):
638 """
andrewonlab8d29f122014-10-22 17:15:04 -0400639 Bring port up / down and measure latency.
640 Port enable / disable is simulated by ifconfig up / down
andrewonlab79244cc2015-01-26 01:11:49 -0500641
642 In ONOS-next, we must ensure that the port we are
andrewonlab393531a2014-10-27 18:36:26 -0400643 manipulating is connected to another switch with a valid
644 connection. Otherwise, graph view will not be updated.
andrewonlab79244cc2015-01-26 01:11:49 -0500645 """
andrewonlab8d29f122014-10-22 17:15:04 -0400646 import time
647 import subprocess
648 import os
649 import requests
650 import json
andrewonlab4f50ec92014-11-11 14:24:45 -0500651 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500652 global clusterCount
andrewonlab86e9e082015-02-13 12:07:39 -0500653 global runNum
andrewonlabc8aea6d2015-02-19 20:09:30 -0500654 global timeToPost
andrewonlab2a6c9342014-10-16 13:40:15 -0400655
andrewonlab79244cc2015-01-26 01:11:49 -0500656 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
657 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
658 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
659 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab8d29f122014-10-22 17:15:04 -0400660
andrewonlab79244cc2015-01-26 01:11:49 -0500661 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
662
andrewonlab8790abb2014-11-06 13:51:54 -0500663 assertion = main.TRUE
andrewonlab79244cc2015-01-26 01:11:49 -0500664 # Number of iterations of case
665 numIter = main.params[ 'TEST' ][ 'numIter' ]
andrewonlabd5367a42015-01-30 14:46:17 -0500666 iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
andrewonlab58f7d702014-11-07 13:21:19 -0500667
andrewonlab79244cc2015-01-26 01:11:49 -0500668 # 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' ]
andrewonlab393531a2014-10-27 18:36:26 -0400672
andrewonlab79244cc2015-01-26 01:11:49 -0500673 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlab86e9e082015-02-13 12:07:39 -0500674 postToDB = main.params[ 'DB' ][ 'postToDB' ]
675 resultPath = main.params[ 'DB' ][ 'portEventResultPath' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500676
andrewonlab79244cc2015-01-26 01:11:49 -0500677 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 )
andrewonlabe5bcef92014-11-06 17:53:20 -0500684
andrewonlab79244cc2015-01-26 01:11:49 -0500685 # Threshold for this test case
686 upThresholdStr = main.params[ 'TEST' ][ 'portUpThreshold' ]
687 downThresholdStr = main.params[ 'TEST' ][ 'portDownThreshold' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500688
andrewonlab79244cc2015-01-26 01:11:49 -0500689 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
andrewonlab393531a2014-10-27 18:36:26 -0400699 # besides the params
andrewonlab8d29f122014-10-22 17:15:04 -0400700
andrewonlab79244cc2015-01-26 01:11:49 -0500701 tsharkPortStatus = "OFP 130 Port Status"
andrewonlab8d29f122014-10-22 17:15:04 -0400702
andrewonlab79244cc2015-01-26 01:11:49 -0500703 tsharkPortUp = "/tmp/tshark_port_up.txt"
704 tsharkPortDown = "/tmp/tshark_port_down.txt"
705 interfaceConfig = "s1-eth1"
andrewonlab8d29f122014-10-22 17:15:04 -0400706
andrewonlab79244cc2015-01-26 01:11:49 -0500707 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 ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400710
andrewonlab79244cc2015-01-26 01:11:49 -0500711 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 )
andrewonlab8d29f122014-10-22 17:15:04 -0400716
andrewonlab79244cc2015-01-26 01:11:49 -0500717 # 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 )
andrewonlab393531a2014-10-27 18:36:26 -0400721
andrewonlab79244cc2015-01-26 01:11:49 -0500722 portUpDeviceToOfpList = []
723 portUpGraphToOfpList = []
724 portDownDeviceToOfpList = []
725 portDownGraphToOfpList = []
andrewonlabd5367a42015-01-30 14:46:17 -0500726
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) ))
andrewonlab8d29f122014-10-22 17:15:04 -0400733
andrewonlab79244cc2015-01-26 01:11:49 -0500734 for i in range( 0, int( numIter ) ):
735 main.step( "Starting wireshark capture for port status down" )
736 main.ONOS1.tsharkGrep( tsharkPortStatus,
737 tsharkPortDown )
andrewonlab8d29f122014-10-22 17:15:04 -0400738
andrewonlab79244cc2015-01-26 01:11:49 -0500739 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-onlab8a832582015-01-16 17:06:11 -0800751 #/tmp directory
andrewonlab79244cc2015-01-26 01:11:49 -0500752 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
753 tsharkPortDown + " /tmp/" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800754
andrewonlab79244cc2015-01-26 01:11:49 -0500755 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
andrewonlaba57a3042015-01-23 13:53:05 -0500763 # itself by printing it out
andrewonlab79244cc2015-01-26 01:11:49 -0500764 timestampBeginPtDown = int( float( objDown[ 1 ] ) * 1000 )
765 # For some reason, wireshark decides to record the
andrewonlaba57a3042015-01-23 13:53:05 -0500766 # timestamp at the 3rd object position instead of
andrewonlab79244cc2015-01-26 01:11:49 -0500767 # 2nd at unpredictable times. This statement is
andrewonlaba57a3042015-01-23 13:53:05 -0500768 # used to capture that odd behavior and use the
769 # correct epoch time
andrewonlab79244cc2015-01-26 01:11:49 -0500770 if timestampBeginPtDown < 1400000000000:
771 timestampBeginPtDown = \
772 int( float( objDown[ 2 ] ) * 1000 )
andrewonlaba57a3042015-01-23 13:53:05 -0500773
andrewonlab79244cc2015-01-26 01:11:49 -0500774 main.log.info( "Port down begin timestamp: " +
775 str( timestampBeginPtDown ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400776 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500777 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
andrewonlabd5367a42015-01-30 14:46:17 -0500800 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
andrewonlab79244cc2015-01-26 01:11:49 -0500817 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 )
andrewonlabd5367a42015-01-30 14:46:17 -0500838
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")
andrewonlab393531a2014-10-27 18:36:26 -0400862
andrewonlab79244cc2015-01-26 01:11:49 -0500863 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 )
andrewonlabd5367a42015-01-30 14:46:17 -0500884
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")
andrewonlab393531a2014-10-27 18:36:26 -0400908
andrewonlab79244cc2015-01-26 01:11:49 -0500909 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 )
andrewonlabd5367a42015-01-30 14:46:17 -0500930
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-onlab8a832582015-01-16 17:06:11 -0800954
andrewonlab79244cc2015-01-26 01:11:49 -0500955 time.sleep( 3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500956
andrewonlab79244cc2015-01-26 01:11:49 -0500957 # 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 )
andrewonlab8d29f122014-10-22 17:15:04 -0400962
andrewonlab79244cc2015-01-26 01:11:49 -0500963 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 ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400984 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500985 main.log.info( "Tshark output file returned unexpected" +
986 " results." )
987 timestampBeginPtUp = 0
988 fPortUp.close()
andrewonlab393531a2014-10-27 18:36:26 -0400989
andrewonlab79244cc2015-01-26 01:11:49 -0500990 # 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 )
andrewonlabd5367a42015-01-30 14:46:17 -05001008
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")
andrewonlab393531a2014-10-27 18:36:26 -04001026
andrewonlab79244cc2015-01-26 01:11:49 -05001027 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 )
andrewonlabd5367a42015-01-30 14:46:17 -05001048
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")
andrewonlabb1998c52014-11-10 13:31:43 -05001072
andrewonlab79244cc2015-01-26 01:11:49 -05001073 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 )
andrewonlabd5367a42015-01-30 14:46:17 -05001094
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")
andrewonlab79244cc2015-01-26 01:11:49 -05001118
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 )
andrewonlabd5367a42015-01-30 14:46:17 -05001140
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")
andrewonlab79244cc2015-01-26 01:11:49 -05001164
1165 # END ITERATION FOR LOOP
andrewonlabd5367a42015-01-30 14:46:17 -05001166
1167 portUpDevList = []
1168 portUpGraphList = []
1169 portDownDevList = []
1170 portDownGraphList = []
andrewonlab79244cc2015-01-26 01:11:49 -05001171
andrewonlabd5367a42015-01-30 14:46:17 -05001172 portUpDevAvg = 0
1173 portUpGraphAvg = 0
1174 portDownDevAvg = 0
1175 portDownGraphAvg = 0
andrewonlab8790abb2014-11-06 13:51:54 -05001176
andrewonlab86e9e082015-02-13 12:07:39 -05001177 dbCmdList = []
1178
andrewonlabd5367a42015-01-30 14:46:17 -05001179 for node in range( 0, clusterCount ):
andrewonlababb11c32014-11-04 15:03:24 -05001180
andrewonlabd5367a42015-01-30 14:46:17 -05001181 # 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
andrewonlab86e9e082015-02-13 12:07:39 -05001198 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)
andrewonlab79244cc2015-01-26 01:11:49 -05001202
andrewonlabc8aea6d2015-02-19 20:09:30 -05001203 portUpStdDev = round(numpy.std(portUpGraphList),2)
1204 portDownStdDev = round(numpy.std(portDownGraphList),2)
1205
andrewonlabd5367a42015-01-30 14:46:17 -05001206 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 "+
andrewonlab86e9e082015-02-13 12:07:39 -05001210 str(portUpGraphAvg)+" ms")
andrewonlabd5367a42015-01-30 14:46:17 -05001211 #main.log.report( " Port down ofp-to-device "+
1212 # str(round(portDownDevAvg, 2))+" ms")
1213 main.log.report( " Port down ofp-to-graph "+
andrewonlab86e9e082015-02-13 12:07:39 -05001214 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)+"',"
andrewonlabc8aea6d2015-02-19 20:09:30 -05001220 ""+str(portUpGraphAvg)+","+str(portUpStdDev)+
1221 ","+str(portDownGraphAvg)+","+str(portDownStdDev)+");"
andrewonlab86e9e082015-02-13 12:07:39 -05001222 )
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()
andrewonlab79244cc2015-01-26 01:11:49 -05001230
andrewonlabc8aea6d2015-02-19 20:09:30 -05001231 print dbCmdList
1232
andrewonlab79244cc2015-01-26 01:11:49 -05001233 # Remove switches from controller for next test
1234 main.Mininet1.deleteSwController( "s1" )
1235 main.Mininet1.deleteSwController( "s2" )
1236
andrewonlabd5367a42015-01-30 14:46:17 -05001237 #TODO: correct assertion
1238
andrewonlab79244cc2015-01-26 01:11:49 -05001239 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 """
andrewonlab3622beb2014-10-28 16:07:56 -04001247 Link down event using loss rate 100%
andrewonlab79244cc2015-01-26 01:11:49 -05001248
andrewonlab53b641c2014-10-31 19:44:44 -04001249 Important:
1250 Use a simple 2 switch topology with 1 link between
andrewonlab79244cc2015-01-26 01:11:49 -05001251 the two switches. Ensure that mac addresses of the
andrewonlab53b641c2014-10-31 19:44:44 -04001252 switches are 1 / 2 respectively
andrewonlab79244cc2015-01-26 01:11:49 -05001253 """
andrewonlab3622beb2014-10-28 16:07:56 -04001254 import time
1255 import subprocess
1256 import os
1257 import requests
1258 import json
andrewonlab79244cc2015-01-26 01:11:49 -05001259 import numpy
andrewonlab3622beb2014-10-28 16:07:56 -04001260
andrewonlab79244cc2015-01-26 01:11:49 -05001261 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1262 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1263 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1264 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab58f7d702014-11-07 13:21:19 -05001265
andrewonlab79244cc2015-01-26 01:11:49 -05001266 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001267
andrewonlab79244cc2015-01-26 01:11:49 -05001268 # Number of iterations of case
1269 numIter = main.params[ 'TEST' ][ 'numIter' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001270
andrewonlab79244cc2015-01-26 01:11:49 -05001271 # 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' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001276
andrewonlab79244cc2015-01-26 01:11:49 -05001277 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001278
andrewonlab79244cc2015-01-26 01:11:49 -05001279 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 ] )
andrewonlabe5bcef92014-11-06 17:53:20 -05001299
andrewonlab3622beb2014-10-28 16:07:56 -04001300 assertion = main.TRUE
andrewonlab79244cc2015-01-26 01:11:49 -05001301 # Link event timestamp to system time list
1302 linkDownLinkToSystemList = []
1303 linkUpLinkToSystemList = []
1304 # Graph event timestamp to system time list
1305 linkDownGraphToSystemList = []
1306 linkUpGraphToSystemList = []
andrewonlab3622beb2014-10-28 16:07:56 -04001307
andrewonlab79244cc2015-01-26 01:11:49 -05001308 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 ) )
andrewonlab3622beb2014-10-28 16:07:56 -04001313
andrewonlab79244cc2015-01-26 01:11:49 -05001314 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 )
andrewonlab3622beb2014-10-28 16:07:56 -04001319
andrewonlab79244cc2015-01-26 01:11:49 -05001320 main.step( "Verifying switch assignment" )
1321 resultS1 = main.Mininet1.getSwController( sw="s1" )
1322 resultS2 = main.Mininet1.getSwController( sw="s2" )
andrewonlab3622beb2014-10-28 16:07:56 -04001323
andrewonlab79244cc2015-01-26 01:11:49 -05001324 # 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-onlab8a832582015-01-16 17:06:11 -08001338 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001339 "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001340
andrewonlab79244cc2015-01-26 01:11:49 -05001341 # TODO: Iterate through 'links' command to verify that
1342 # link s1 -> s2 went down ( loop timeout 30 seconds )
andrewonlababb11c32014-11-04 15:03:24 -05001343 # on all 3 ONOS instances
andrewonlab79244cc2015-01-26 01:11:49 -05001344 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 " )
andrewonlab53b641c2014-10-31 19:44:44 -04001354 break
1355 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001356 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
andrewonlab53b641c2014-10-31 19:44:44 -04001396 assertion = main.FALSE
1397 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001398 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 )
andrewonlab53b641c2014-10-31 19:44:44 -04001407
andrewonlab79244cc2015-01-26 01:11:49 -05001408 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' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001415
andrewonlab79244cc2015-01-26 01:11:49 -05001416 linkTimestamp1 = \
1417 jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
1418 linkTimestamp2 = \
1419 jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
1420 linkTimestamp3 = \
1421 jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001422
andrewonlab79244cc2015-01-26 01:11:49 -05001423 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 )
andrewonlab53b641c2014-10-31 19:44:44 -04001439 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001440 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-onlab8a832582015-01-16 17:06:11 -08001445
andrewonlab79244cc2015-01-26 01:11:49 -05001446 linkDownLatDevice1 = 0
1447 linkDownLatDevice2 = 0
1448 linkDownLatDevice3 = 0
andrewonlab53b641c2014-10-31 19:44:44 -04001449
andrewonlab79244cc2015-01-26 01:11:49 -05001450 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:
andrewonlab53b641c2014-10-31 19:44:44 -04001499 # 'sh tc qdisc del dev s1-eth1 root'
andrewonlab79244cc2015-01-26 01:11:49 -05001500 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 " )
andrewonlababb11c32014-11-04 15:03:24 -05001518 break
1519 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001520 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
andrewonlababb11c32014-11-04 15:03:24 -05001553 assertion = main.FALSE
1554 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001555 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 )
andrewonlababb11c32014-11-04 15:03:24 -05001564
andrewonlab79244cc2015-01-26 01:11:49 -05001565 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' ]
andrewonlababb11c32014-11-04 15:03:24 -05001572
andrewonlab79244cc2015-01-26 01:11:49 -05001573 linkTimestamp1 = \
1574 jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
1575 linkTimestamp2 = \
1576 jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
1577 linkTimestamp3 = \
1578 jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
andrewonlababb11c32014-11-04 15:03:24 -05001579
andrewonlab79244cc2015-01-26 01:11:49 -05001580 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 )
andrewonlababb11c32014-11-04 15:03:24 -05001596 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001597 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-onlab8a832582015-01-16 17:06:11 -08001602
andrewonlab79244cc2015-01-26 01:11:49 -05001603 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 )
andrewonlab8790abb2014-11-06 13:51:54 -05001651 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001652 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 )
andrewonlab8790abb2014-11-06 13:51:54 -05001659 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001660 main.log.info( "Link up latency exceeded threshold" )
1661 main.log.info( "Results for iteration " + str( i ) +
1662 "have been omitted" )
andrewonlab53b641c2014-10-31 19:44:44 -04001663
andrewonlab79244cc2015-01-26 01:11:49 -05001664 # 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 ) )
andrewonlababb11c32014-11-04 15:03:24 -05001677
andrewonlab79244cc2015-01-26 01:11:49 -05001678 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" )
andrewonlab4e124482014-11-04 13:37:25 -05001684
andrewonlab79244cc2015-01-26 01:11:49 -05001685 utilities.assert_equals(
1686 expect=main.TRUE,
1687 actual=assertion,
1688 onpass="Link discovery latency calculation successful",
1689 onfail="Link discovery latency case failed" )
andrewonlab8790abb2014-11-06 13:51:54 -05001690
andrewonlab79244cc2015-01-26 01:11:49 -05001691 def CASE5( self, main ):
1692 """
andrewonlabb54b85b2014-10-28 18:43:57 -04001693 100 Switch discovery latency
1694
1695 Important:
andrewonlab79244cc2015-01-26 01:11:49 -05001696 This test case can be potentially dangerous if
andrewonlab16ce4852014-10-30 13:41:09 -04001697 your machine has previously set iptables rules.
1698 One of the steps of the test case will flush
1699 all existing iptables rules.
andrewonlab8790abb2014-11-06 13:51:54 -05001700 Note:
andrewonlab79244cc2015-01-26 01:11:49 -05001701 You can specify the number of switches in the
andrewonlab8790abb2014-11-06 13:51:54 -05001702 params file to adjust the switch discovery size
andrewonlab79244cc2015-01-26 01:11:49 -05001703 ( and specify the corresponding topology in Mininet1
1704 .topo file )
1705 """
andrewonlabb54b85b2014-10-28 18:43:57 -04001706 import time
1707 import subprocess
1708 import os
1709 import requests
1710 import json
1711
andrewonlab79244cc2015-01-26 01:11:49 -05001712 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' ]
andrewonlabb54b85b2014-10-28 18:43:57 -04001717
andrewonlab79244cc2015-01-26 01:11:49 -05001718 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab16ce4852014-10-30 13:41:09 -04001719
andrewonlab79244cc2015-01-26 01:11:49 -05001720 # Number of iterations of case
1721 numIter = main.params[ 'TEST' ][ 'numIter' ]
1722 numSw = main.params[ 'TEST' ][ 'numSwitch' ]
andrewonlab58f7d702014-11-07 13:21:19 -05001723
andrewonlab79244cc2015-01-26 01:11:49 -05001724 # 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' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001728
andrewonlab79244cc2015-01-26 01:11:49 -05001729 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001730
andrewonlab79244cc2015-01-26 01:11:49 -05001731 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 )
andrewonlabb54b85b2014-10-28 18:43:57 -04001738
andrewonlab79244cc2015-01-26 01:11:49 -05001739 # 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 ] )
andrewonlabe5bcef92014-11-06 17:53:20 -05001744
andrewonlab79244cc2015-01-26 01:11:49 -05001745 tsharkOfpOutput = "/tmp/tshark_ofp_" + numSw + "sw.txt"
1746 tsharkTcpOutput = "/tmp/tshark_tcp_" + numSw + "sw.txt"
andrewonlabb54b85b2014-10-28 18:43:57 -04001747
andrewonlab79244cc2015-01-26 01:11:49 -05001748 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:
andrewonlab53b641c2014-10-31 19:44:44 -04001772 # Append to INPUT rule,
1773 # behavior DROP that matches following:
1774 # * packet type: tcp
andrewonlab79244cc2015-01-26 01:11:49 -05001775 # * source IP: MN1Ip
andrewonlab53b641c2014-10-31 19:44:44 -04001776 # * destination PORT: 6633
andrewonlabb54b85b2014-10-28 18:43:57 -04001777 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001778 "sudo iptables -A INPUT -p tcp -s " + MN1Ip +
1779 " --dport " + defaultSwPort + " -j DROP" )
1780 main.ONOS1.handle.expect( "\$" )
1781 # Append to OUTPUT rule,
andrewonlab53b641c2014-10-31 19:44:44 -04001782 # behavior DROP that matches following:
1783 # * packet type: tcp
andrewonlab79244cc2015-01-26 01:11:49 -05001784 # * source IP: MN1Ip
andrewonlab53b641c2014-10-31 19:44:44 -04001785 # * destination PORT: 6633
1786 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001787 "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
andrewonlab8790abb2014-11-06 13:51:54 -05001792 # based on the number of switches in the topology
andrewonlab79244cc2015-01-26 01:11:49 -05001793 main.log.info( "Please wait for switch connection to " +
1794 "time out" )
1795 time.sleep( 60 )
andrewonlabb54b85b2014-10-28 18:43:57 -04001796
andrewonlab79244cc2015-01-26 01:11:49 -05001797 # 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
andrewonlab16ce4852014-10-30 13:41:09 -04001805 # removal took place
andrewonlab79244cc2015-01-26 01:11:49 -05001806 # ( ensuring nodes are configured via ptp )
andrewonlabb54b85b2014-10-28 18:43:57 -04001807 # sudo iptables -F
andrewonlab79244cc2015-01-26 01:11:49 -05001808
1809 t0System = time.time() * 1000
andrewonlab16ce4852014-10-30 13:41:09 -04001810 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001811 "sudo iptables -F" )
andrewonlabb54b85b2014-10-28 18:43:57 -04001812
andrewonlab79244cc2015-01-26 01:11:49 -05001813 # 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()
andrewonlab16ce4852014-10-30 13:41:09 -04001829
andrewonlab79244cc2015-01-26 01:11:49 -05001830 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" )
andrewonlab16ce4852014-10-30 13:41:09 -04001841 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001842 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" )
andrewonlab16ce4852014-10-30 13:41:09 -04001850 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001851 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" )
andrewonlab16ce4852014-10-30 13:41:09 -04001859 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001860 counterAvail3 = 0
andrewonlab16ce4852014-10-30 13:41:09 -04001861
andrewonlab79244cc2015-01-26 01:11:49 -05001862 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()
andrewonlab16ce4852014-10-30 13:41:09 -04001871
andrewonlab79244cc2015-01-26 01:11:49 -05001872 # Exit while loop if all devices discovered
1873 break
andrewonlab16ce4852014-10-30 13:41:09 -04001874
andrewonlab79244cc2015-01-26 01:11:49 -05001875 counterLoop += 1
1876 # Give some time in between CLI calls
1877 #( will not affect measurement )
1878 time.sleep( 3 )
andrewonlab16ce4852014-10-30 13:41:09 -04001879
andrewonlab79244cc2015-01-26 01:11:49 -05001880 main.ONOS1.tsharkStop()
andrewonlab53b641c2014-10-31 19:44:44 -04001881
andrewonlab79244cc2015-01-26 01:11:49 -05001882 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
1883 tsharkOfpOutput + " /tmp/" )
1884 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
1885 tsharkTcpOutput + " /tmp/" )
andrewonlab16ce4852014-10-30 13:41:09 -04001886
andrewonlab79244cc2015-01-26 01:11:49 -05001887 # 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()
andrewonlab16ce4852014-10-30 13:41:09 -04001896
andrewonlab79244cc2015-01-26 01:11:49 -05001897 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()
andrewonlab16ce4852014-10-30 13:41:09 -04001903
andrewonlab79244cc2015-01-26 01:11:49 -05001904 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 )
andrewonlabe5bcef92014-11-06 17:53:20 -05001928 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001929 main.log.info( "100 Switch discovery latency " +
1930 "exceeded the threshold." )
andrewonlab16ce4852014-10-30 13:41:09 -04001931
andrewonlab79244cc2015-01-26 01:11:49 -05001932 # END ITERATION FOR LOOP
andrewonlab16ce4852014-10-30 13:41:09 -04001933
andrewonlab79244cc2015-01-26 01:11:49 -05001934 swLatMin = min( swDiscoveryLatList )
1935 swLatMax = max( swDiscoveryLatList )
1936 swLatAvg = sum( swDiscoveryLatList ) /\
1937 len( swDiscoveryLatList )
andrewonlab16ce4852014-10-30 13:41:09 -04001938
andrewonlab79244cc2015-01-26 01:11:49 -05001939 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 """
andrewonlaba57a3042015-01-23 13:53:05 -05001946 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -05001947 """
andrewonlaba57a3042015-01-23 13:53:05 -05001948 import time
andrewonlaba57a3042015-01-23 13:53:05 -05001949
andrewonlab79244cc2015-01-26 01:11:49 -05001950 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' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001957
andrewonlab79244cc2015-01-26 01:11:49 -05001958 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001959
andrewonlab79244cc2015-01-26 01:11:49 -05001960 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001961
andrewonlab79244cc2015-01-26 01:11:49 -05001962 # Cluster size increased everytime the case is defined
1963 clusterCount += 2
andrewonlaba57a3042015-01-23 13:53:05 -05001964
andrewonlab79244cc2015-01-26 01:11:49 -05001965 main.log.report( "Increasing cluster size to " +
1966 str( clusterCount ) )
andrewonlaba57a3042015-01-23 13:53:05 -05001967
andrewonlab79244cc2015-01-26 01:11:49 -05001968 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
andrewonlaba57a3042015-01-23 13:53:05 -05001976
andrewonlab79244cc2015-01-26 01:11:49 -05001977 time.sleep( 5 )
andrewonlaba57a3042015-01-23 13:53:05 -05001978
andrewonlab79244cc2015-01-26 01:11:49 -05001979 main.ONOS2cli.startOnosCli( ONOS2Ip )
1980 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlaba57a3042015-01-23 13:53:05 -05001981
andrewonlab79244cc2015-01-26 01:11:49 -05001982 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
andrewonlaba57a3042015-01-23 13:53:05 -05001989
andrewonlab79244cc2015-01-26 01:11:49 -05001990 time.sleep( 5 )
andrewonlaba57a3042015-01-23 13:53:05 -05001991
andrewonlab79244cc2015-01-26 01:11:49 -05001992 main.ONOS4cli.startOnosCli( ONOS4Ip )
1993 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlaba57a3042015-01-23 13:53:05 -05001994
andrewonlab79244cc2015-01-26 01:11:49 -05001995 elif clusterCount == 7:
andrewonlab67630692015-01-29 20:16:01 -05001996 main.log.info( "Installing nodes 6 and 7" )
andrewonlab79244cc2015-01-26 01:11:49 -05001997 node6Result = \
1998 main.ONOSbench.onosInstall( node=ONOS6Ip )
1999 node7Result = \
2000 main.ONOSbench.onosInstall( node=ONOS7Ip )
2001 installResult = node6Result and node7Result
andrewonlaba57a3042015-01-23 13:53:05 -05002002
andrewonlab79244cc2015-01-26 01:11:49 -05002003 time.sleep( 5 )
2004
2005 main.ONOS6cli.startOnosCli( ONOS6Ip )
2006 main.ONOS7cli.startOnosCli( ONOS7Ip )