blob: 7f464aca6f86d59892b7557085ff0a7026eccc6d [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
30 # Set initial cluster count
31 clusterCount = 1
andrewonlaba57a3042015-01-23 13:53:05 -050032 ##
andrewonlab2a6c9342014-10-16 13:40:15 -040033
andrewonlab79244cc2015-01-26 01:11:49 -050034 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab2a6c9342014-10-16 13:40:15 -040035
andrewonlab79244cc2015-01-26 01:11:49 -050036 gitPull = main.params[ 'GIT' ][ 'autoPull' ]
37 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080038
andrewonlab79244cc2015-01-26 01:11:49 -050039 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
40 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
41 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
42 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
43 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
44 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
45 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
46
47 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
48 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
49
50 topoCfgFile = main.params[ 'TEST' ][ 'topoConfigFile' ]
51 topoCfgName = main.params[ 'TEST' ][ 'topoConfigName' ]
52
53 mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ]
andrewonlaba57a3042015-01-23 13:53:05 -050054
andrewonlab79244cc2015-01-26 01:11:49 -050055 main.case( "Setting up test environment" )
56 main.log.info( "Copying topology event accumulator config" +
57 " to ONOS /package/etc" )
58 main.ONOSbench.handle.sendline( "cp ~/" +
59 topoCfgFile +
60 " ~/ONOS/tools/package/etc/" +
61 topoCfgName )
62 main.ONOSbench.handle.expect( "\$" )
andrewonlab6c8bbeb2014-11-14 12:43:48 -050063
andrewonlab79244cc2015-01-26 01:11:49 -050064 main.log.report( "Setting up test environment" )
andrewonlab2a6c9342014-10-16 13:40:15 -040065
andrewonlab79244cc2015-01-26 01:11:49 -050066 main.step( "Cleaning previously installed ONOS if any" )
67 main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip )
68 main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip )
69 main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip )
70 main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip )
71 main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip )
andrewonlab67630692015-01-29 20:16:01 -050072 main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
andrewonlab0e1825c2014-11-20 20:07:00 -050073
andrewonlab79244cc2015-01-26 01:11:49 -050074 main.step( "Creating cell file" )
75 cellFileResult = main.ONOSbench.createCellFile(
76 BENCHIp, cellName, MN1Ip,
77 "onos-core,onos-app-metrics,onos-app-gui",
78 ONOS1Ip )
andrewonlab2a6c9342014-10-16 13:40:15 -040079
andrewonlab79244cc2015-01-26 01:11:49 -050080 main.step( "Applying cell file to environment" )
81 cellApplyResult = main.ONOSbench.setCell( cellName )
82 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab6c8bbeb2014-11-14 12:43:48 -050083
andrewonlab79244cc2015-01-26 01:11:49 -050084 # NOTE: This step may be removed after proper
kelvin-onlab8a832582015-01-16 17:06:11 -080085 # copy cat log functionality
andrewonlab79244cc2015-01-26 01:11:49 -050086 main.step( "Removing raft/copy-cat logs from ONOS nodes" )
87 main.ONOSbench.onosRemoveRaftLogs()
88 time.sleep( 30 )
kelvin-onlab8a832582015-01-16 17:06:11 -080089
andrewonlab79244cc2015-01-26 01:11:49 -050090 main.step( "Git checkout and pull " + checkoutBranch )
91 if gitPull == 'on':
92 # checkoutResult = \
93 # main.ONOSbench.gitCheckout( checkoutBranch )
94 checkoutResult = main.TRUE
95 pullResult = main.ONOSbench.gitPull()
andrewonlab2a6c9342014-10-16 13:40:15 -040096 else:
andrewonlab79244cc2015-01-26 01:11:49 -050097 checkoutResult = main.TRUE
98 pullResult = main.TRUE
99 main.log.info( "Skipped git checkout and pull" )
andrewonlab2a6c9342014-10-16 13:40:15 -0400100
andrewonlab79244cc2015-01-26 01:11:49 -0500101 main.log.report( "Commit information - " )
102 main.ONOSbench.getVersion( report=True )
andrewonlab92844342014-11-18 16:39:11 -0500103
andrewonlab79244cc2015-01-26 01:11:49 -0500104 main.step( "Using mvn clean & install" )
105 if mvnCleanInstall == 'on':
106 mvnResult = main.ONOSbench.cleanInstall()
107 elif mvnCleanInstall == 'off':
108 main.log.info("mci turned off by settings")
109 mvnResult = main.TRUE
andrewonlab2a6c9342014-10-16 13:40:15 -0400110
andrewonlab79244cc2015-01-26 01:11:49 -0500111 main.step( "Set cell for ONOS cli env" )
112 main.ONOS1cli.setCell( cellName )
113 # main.ONOS2cli.setCell( cellName )
114 # main.ONOS3cli.setCell( cellName )
andrewonlabb1998c52014-11-10 13:31:43 -0500115
andrewonlab79244cc2015-01-26 01:11:49 -0500116 main.step( "Creating ONOS package" )
117 packageResult = main.ONOSbench.onosPackage()
andrewonlab2a6c9342014-10-16 13:40:15 -0400118
andrewonlab79244cc2015-01-26 01:11:49 -0500119 main.step( "Installing ONOS package" )
120 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
121 #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
122 #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
andrewonlab2a6c9342014-10-16 13:40:15 -0400123
andrewonlab79244cc2015-01-26 01:11:49 -0500124 time.sleep( 10 )
andrewonlabe9fb6722014-10-24 12:20:35 -0400125
andrewonlab79244cc2015-01-26 01:11:49 -0500126 main.step( "Start onos cli" )
127 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
128 #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
129 #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlabe9fb6722014-10-24 12:20:35 -0400130
andrewonlab79244cc2015-01-26 01:11:49 -0500131 utilities.assert_equals( expect=main.TRUE,
132 actual=cellFileResult and cellApplyResult and
133 verifyCellResult and checkoutResult and
134 pullResult and mvnResult and
135 install1Result, # and install2Result and
136 # install3Result,
137 onpass="Test Environment setup successful",
138 onfail="Failed to setup test environment" )
andrewonlab2a6c9342014-10-16 13:40:15 -0400139
andrewonlab79244cc2015-01-26 01:11:49 -0500140 def CASE2( self, main ):
141 """
andrewonlabba44bcf2014-10-16 16:54:41 -0400142 Assign s1 to ONOS1 and measure latency
andrewonlab79244cc2015-01-26 01:11:49 -0500143
andrewonlab3a7c3c72014-10-24 17:21:03 -0400144 There are 4 levels of latency measurements to this test:
andrewonlab79244cc2015-01-26 01:11:49 -0500145 1 ) End-to-end measurement: Complete end-to-end measurement
146 from TCP ( SYN/ACK ) handshake to Graph change
147 2 ) OFP-to-graph measurement: 'ONOS processing' snippet of
andrewonlab3a7c3c72014-10-24 17:21:03 -0400148 measurement from OFP Vendor message to Graph change
andrewonlab79244cc2015-01-26 01:11:49 -0500149 3 ) OFP-to-device measurement: 'ONOS processing without
andrewonlab3a7c3c72014-10-24 17:21:03 -0400150 graph change' snippet of measurement from OFP vendor
151 message to Device change timestamp
andrewonlab79244cc2015-01-26 01:11:49 -0500152 4 ) T0-to-device measurement: Measurement that includes
153 the switch handshake to devices timestamp without
154 the graph view change. ( TCP handshake -> Device
155 change )
156 """
andrewonlabba44bcf2014-10-16 16:54:41 -0400157 import time
andrewonlabe6745342014-10-17 14:29:13 -0400158 import subprocess
159 import json
160 import requests
161 import os
andrewonlab4f50ec92014-11-11 14:24:45 -0500162 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500163 global clusterCount
andrewonlabba44bcf2014-10-16 16:54:41 -0400164
andrewonlab79244cc2015-01-26 01:11:49 -0500165 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
166 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
167 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
168 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
169 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
170 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
171 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlabe6745342014-10-17 14:29:13 -0400172
andrewonlab79244cc2015-01-26 01:11:49 -0500173 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4b5c8b92014-11-10 16:04:33 -0500174
andrewonlab79244cc2015-01-26 01:11:49 -0500175 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab226024e2014-10-24 16:01:32 -0400176
andrewonlab79244cc2015-01-26 01:11:49 -0500177 # Number of iterations of case
178 numIter = main.params[ 'TEST' ][ 'numIter' ]
179 # Number of first 'x' iterations to ignore:
180 iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
andrewonlab58f7d702014-11-07 13:21:19 -0500181
andrewonlab79244cc2015-01-26 01:11:49 -0500182 # Timestamp 'keys' for json metrics output.
183 # These are subject to change, hence moved into params
184 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
185 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500186
andrewonlab79244cc2015-01-26 01:11:49 -0500187 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
188 onosLog = main.params[ 'TEST' ][ 'onosLogFile' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800189
andrewonlab79244cc2015-01-26 01:11:49 -0500190 # Threshold for the test
191 thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ]
192 thresholdObj = thresholdStr.split( "," )
193 thresholdMin = int( thresholdObj[ 0 ] )
194 thresholdMax = int( thresholdObj[ 1 ] )
andrewonlab226024e2014-10-24 16:01:32 -0400195
andrewonlab79244cc2015-01-26 01:11:49 -0500196 # List of switch add latency collected from
197 # all iterations
198 latencyEndToEndList = []
199 latencyOfpToGraphList = []
200 latencyOfpToDeviceList = []
201 latencyT0ToDeviceList = []
202 latencyTcpToOfpList = []
andrewonlabba44bcf2014-10-16 16:54:41 -0400203
andrewonlab67630692015-01-29 20:16:01 -0500204 # Initialize 2d array for [node][iteration] storage
205 endToEndLatNodeIter = numpy.zeros(( clusterCount, int(numIter) ))
206 ofpToGraphLatNodeIter = numpy.zeros(( clusterCount, int(numIter) ))
207 # tcp-to-ofp measurements are same throughout each iteration
208 tcpToOfpLatIter = []
209
andrewonlab79244cc2015-01-26 01:11:49 -0500210 # Directory/file to store tshark results
211 tsharkOfOutput = "/tmp/tshark_of_topo.txt"
212 tsharkTcpOutput = "/tmp/tshark_tcp_topo.txt"
213
214 # String to grep in tshark output
215 tsharkTcpString = "TCP 74 " + defaultSwPort
216 tsharkOfString = "OFP 86 Vendor"
217
218 # Initialize assertion to TRUE
andrewonlabe6745342014-10-17 14:29:13 -0400219 assertion = main.TRUE
andrewonlabb1998c52014-11-10 13:31:43 -0500220
andrewonlab79244cc2015-01-26 01:11:49 -0500221 localTime = time.strftime( '%x %X' )
222 localTime = localTime.replace( "/", "" )
223 localTime = localTime.replace( " ", "_" )
224 localTime = localTime.replace( ":", "" )
225 if debugMode == 'on':
226 main.ONOS1.tsharkPcap( "eth0",
227 "/tmp/single_sw_lat_pcap_" + localTime )
andrewonlab58f7d702014-11-07 13:21:19 -0500228
andrewonlab79244cc2015-01-26 01:11:49 -0500229 main.log.info( "Debug mode is on" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400230
andrewonlab79244cc2015-01-26 01:11:49 -0500231 main.log.report( "Latency of adding one switch to controller" )
232 main.log.report( "First " + str( iterIgnore ) + " iterations ignored" +
233 " for jvm warmup time" )
234 main.log.report( "Total iterations of test: " + str( numIter ) )
andrewonlabba44bcf2014-10-16 16:54:41 -0400235
andrewonlab79244cc2015-01-26 01:11:49 -0500236 for i in range( 0, int( numIter ) ):
237 main.log.info( "Starting tshark capture" )
238
239 #* TCP [ ACK, SYN ] is used as t0A, the
240 # very first "exchange" between ONOS and
andrewonlabba44bcf2014-10-16 16:54:41 -0400241 # the switch for end-to-end measurement
andrewonlab79244cc2015-01-26 01:11:49 -0500242 #* OFP [ Stats Reply ] is used for t0B
andrewonlabba44bcf2014-10-16 16:54:41 -0400243 # the very last OFP message between ONOS
244 # and the switch for ONOS measurement
andrewonlab79244cc2015-01-26 01:11:49 -0500245 main.ONOS1.tsharkGrep( tsharkTcpString,
246 tsharkTcpOutput )
247 main.ONOS1.tsharkGrep( tsharkOfString,
248 tsharkOfOutput )
andrewonlabba44bcf2014-10-16 16:54:41 -0400249
andrewonlab79244cc2015-01-26 01:11:49 -0500250 # Wait and ensure tshark is started and
251 # capturing
252 time.sleep( 10 )
andrewonlabba44bcf2014-10-16 16:54:41 -0400253
andrewonlab79244cc2015-01-26 01:11:49 -0500254 main.log.info( "Assigning s1 to controller" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400255
andrewonlab79244cc2015-01-26 01:11:49 -0500256 main.Mininet1.assignSwController(
257 sw="1",
258 ip1=ONOS1Ip,
259 port1=defaultSwPort )
andrewonlabba44bcf2014-10-16 16:54:41 -0400260
andrewonlab79244cc2015-01-26 01:11:49 -0500261 # Wait and ensure switch is assigned
262 # before stopping tshark
263 time.sleep( 30 )
andrewonlabba44bcf2014-10-16 16:54:41 -0400264
andrewonlab79244cc2015-01-26 01:11:49 -0500265 main.log.info( "Stopping all Tshark processes" )
266 main.ONOS1.stopTshark()
kelvin-onlab8a832582015-01-16 17:06:11 -0800267
andrewonlab79244cc2015-01-26 01:11:49 -0500268 # tshark output is saved in ONOS. Use subprocess
269 # to copy over files to TestON for parsing
270 main.log.info( "Copying over tshark files" )
271
272 # TCP CAPTURE ****
273 # Copy the tshark output from ONOS machine to
274 # TestON machine in tsharkTcpOutput directory>file
275 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
276 tsharkTcpOutput + " /tmp/" )
277 tcpFile = open( tsharkTcpOutput, 'r' )
278 tempText = tcpFile.readline()
279 tempText = tempText.split( " " )
280
281 main.log.info( "Object read in from TCP capture: " +
282 str( tempText ) )
283 if len( tempText ) > 1:
284 t0Tcp = float( tempText[ 1 ] ) * 1000.0
andrewonlabe6745342014-10-17 14:29:13 -0400285 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500286 main.log.error( "Tshark output file for TCP" +
287 " returned unexpected results" )
288 t0Tcp = 0
andrewonlabe6745342014-10-17 14:29:13 -0400289 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500290
291 tcpFile.close()
andrewonlabe6745342014-10-17 14:29:13 -0400292 #****************
andrewonlabba44bcf2014-10-16 16:54:41 -0400293
andrewonlab79244cc2015-01-26 01:11:49 -0500294 # OF CAPTURE ****
295 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
296 tsharkOfOutput + " /tmp/" )
297 ofFile = open( tsharkOfOutput, 'r' )
298
299 lineOfp = ""
300 # Read until last line of file
andrewonlabe6745342014-10-17 14:29:13 -0400301 while True:
andrewonlab79244cc2015-01-26 01:11:49 -0500302 tempText = ofFile.readline()
303 if tempText != '':
304 lineOfp = tempText
andrewonlabe6745342014-10-17 14:29:13 -0400305 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500306 break
307 obj = lineOfp.split( " " )
308
309 main.log.info( "Object read in from OFP capture: " +
310 str( lineOfp ) )
311
312 if len( lineOfp ) > 1:
313 t0Ofp = float( obj[ 1 ] ) * 1000.0
andrewonlabe6745342014-10-17 14:29:13 -0400314 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500315 main.log.error( "Tshark output file for OFP" +
316 " returned unexpected results" )
317 t0Ofp = 0
andrewonlabe6745342014-10-17 14:29:13 -0400318 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500319
320 ofFile.close()
andrewonlabe6745342014-10-17 14:29:13 -0400321 #****************
andrewonlab867212a2014-10-22 20:13:38 -0400322
andrewonlab79244cc2015-01-26 01:11:49 -0500323 jsonStr1 = main.ONOS1cli.topologyEventsMetrics()
324 # Initialize scale-out variables
325 jsonStr2 = ""
326 jsonStr3 = ""
327 jsonStr4 = ""
328 jsonStr5 = ""
329 jsonStr6 = ""
330 jsonStr7 = ""
andrewonlabe9fb6722014-10-24 12:20:35 -0400331
andrewonlab79244cc2015-01-26 01:11:49 -0500332 jsonObj1 = json.loads( jsonStr1 )
333 # Initialize scale-out variables
334 jsonObj2 = ""
335 jsonObj3 = ""
336 jsonObj4 = ""
337 jsonObj5 = ""
338 jsonObj6 = ""
339 jsonObj7 = ""
kelvin-onlab8a832582015-01-16 17:06:11 -0800340
andrewonlab79244cc2015-01-26 01:11:49 -0500341 # Obtain graph timestamp. This timestsamp captures
342 # the epoch time at which the topology graph was updated.
343 graphTimestamp1 = \
344 jsonObj1[ graphTimestamp ][ 'value' ]
345 # Obtain device timestamp. This timestamp captures
346 # the epoch time at which the device event happened
347 deviceTimestamp1 = \
348 jsonObj1[ deviceTimestamp ][ 'value' ]
349
350 # t0 to device processing latency
351 deltaDevice1 = int( deviceTimestamp1 ) - int( t0Tcp )
andrewonlab79244cc2015-01-26 01:11:49 -0500352 # t0 to graph processing latency ( end-to-end )
353 deltaGraph1 = int( graphTimestamp1 ) - int( t0Tcp )
andrewonlab79244cc2015-01-26 01:11:49 -0500354 # ofp to graph processing latency ( ONOS processing )
355 deltaOfpGraph1 = int( graphTimestamp1 ) - int( t0Ofp )
andrewonlab79244cc2015-01-26 01:11:49 -0500356 # ofp to device processing latency ( ONOS processing )
357 deltaOfpDevice1 = float( deviceTimestamp1 ) - float( t0Ofp )
andrewonlab67630692015-01-29 20:16:01 -0500358 # tcp to ofp processing latency ( switch connection )
359 deltaTcpOfp1 = int(t0Ofp) - int(t0Tcp)
360
361 if deltaTcpOfp1 > thresholdMin and deltaTcpOfp1 < thresholdMax\
362 and i >= iterIgnore:
363 tcpToOfpLatIter.append(deltaTcpOfp1)
364 main.log.info("iter"+str(i)+" tcp-to-ofp: "+
365 str(deltaTcpOfp1)+" ms")
366 else:
367 tcpToOfpLatIter.append(0)
368 main.log.info("iter"+str(i)+" tcp-to-ofp: "+
369 str(deltaTcpOfp1)+" ms - ignored this iteration")
370
371 # Store initial measurements in data array
372 #This measurement is for node 1
373
374 if deltaGraph1 > thresholdMin and deltaGraph1 < thresholdMax\
375 and i >= iterIgnore:
376 endToEndLatNodeIter[0][i] = deltaGraph1
377 main.log.info("ONOS1 iter"+str(i)+" end-to-end: "+
378 str(deltaGraph1)+" ms")
379 else:
380 main.log.info("ONOS1 iter"+str(i)+" end-to-end: "+
381 str(deltaGraph1)+" ms - ignored this iteration")
382
383
384 if deltaOfpGraph1 > thresholdMin and deltaOfpGraph1 < thresholdMax\
385 and i >= iterIgnore:
386 ofpToGraphLatNodeIter[0][i] = deltaOfpGraph1
387
388 main.log.info("ONOS1 iter"+str(i)+" ofp-to-graph: "+
389 str(deltaOfpGraph1)+" ms")
andrewonlab79244cc2015-01-26 01:11:49 -0500390
391 # TODO: Create even cluster number events
392
393 # Include scale-out measurements when applicable
394 if clusterCount >= 3:
395 jsonStr2 = main.ONOS2cli.topologyEventsMetrics()
396 jsonStr3 = main.ONOS3cli.topologyEventsMetrics()
397 jsonObj2 = json.loads( jsonStr2 )
398 jsonObj3 = json.loads( jsonStr3 )
399 graphTimestamp2 = \
400 jsonObj2[ graphTimestamp ][ 'value' ]
401 graphTimestamp3 = \
402 jsonObj3[ graphTimestamp ][ 'value' ]
403 deviceTimestamp2 = \
404 jsonObj2[ deviceTimestamp ][ 'value' ]
405 deviceTimestamp3 = \
406 jsonObj3[ deviceTimestamp ][ 'value' ]
407 deltaDevice2 = int( deviceTimestamp2 ) - int( t0Tcp )
408 deltaDevice3 = int( deviceTimestamp3 ) - int( t0Tcp )
409 deltaGraph2 = int( graphTimestamp2 ) - int( t0Tcp )
410 deltaGraph3 = int( graphTimestamp3 ) - int( t0Tcp )
411 deltaOfpGraph2 = int( graphTimestamp2 ) - int( t0Ofp )
412 deltaOfpGraph3 = int( graphTimestamp3 ) - int( t0Ofp )
413 deltaOfpDevice2 = float( deviceTimestamp2 ) -\
414 float( t0Ofp )
415 deltaOfpDevice3 = float( deviceTimestamp3 ) -\
416 float( t0Ofp )
andrewonlaba57a3042015-01-23 13:53:05 -0500417
andrewonlab67630692015-01-29 20:16:01 -0500418 if deltaGraph2 > thresholdMin and\
419 deltaGraph2 < thresholdMax and i >= iterIgnore:
420 endToEndLatNodeIter[1][i] = deltaGraph2
421 main.log.info("ONOS2 iter"+str(i)+" end-to-end: "+
422 str(deltaGraph2)+" ms")
423
424 if deltaOfpGraph2 > thresholdMin and\
425 deltaOfpGraph2 < thresholdMax and i >= iterIgnore:
426 ofpToGraphLatNodeIter[1][i] = deltaOfpGraph2
427 main.log.info("ONOS2 iter"+str(i)+" ofp-to-graph: "+
428 str(deltaOfpGraph2)+" ms")
429
430 if deltaGraph3 > thresholdMin and\
431 deltaGraph3 < thresholdMax and i >= iterIgnore:
432 endToEndLatNodeIter[2][i] = deltaGraph3
433 main.log.info("ONOS3 iter"+str(i)+" end-to-end: "+
434 str(deltaGraph3)+" ms")
435
436 if deltaOfpGraph3 > thresholdMin and\
437 deltaOfpGraph3 < thresholdMax and i >= iterIgnore:
438 ofpToGraphLatNodeIter[2][i] = deltaOfpGraph3
439 main.log.info("ONOS3 iter"+str(i)+" ofp-to-graph: "+
440 str(deltaOfpGraph3)+" ms")
441
andrewonlab79244cc2015-01-26 01:11:49 -0500442 if clusterCount >= 5:
443 jsonStr4 = main.ONOS4cli.topologyEventsMetrics()
444 jsonStr5 = main.ONOS5cli.topologyEventsMetrics()
445 jsonObj4 = json.loads( jsonStr4 )
446 jsonObj5 = json.loads( jsonStr5 )
447 graphTimestamp4 = \
448 jsonObj4[ graphTimestamp ][ 'value' ]
449 graphTimestamp5 = \
450 jsonObj5[ graphTimestamp ][ 'value' ]
451 deviceTimestamp4 = \
452 jsonObj4[ deviceTimestamp ][ 'value' ]
453 deviceTimestamp5 = \
454 jsonObj5[ deviceTimestamp ][ 'value' ]
455 deltaDevice4 = int( deviceTimestamp4 ) - int( t0Tcp )
456 deltaDevice5 = int( deviceTimestamp5 ) - int( t0Tcp )
457 deltaGraph4 = int( graphTimestamp4 ) - int( t0Tcp )
458 deltaGraph5 = int( graphTimestamp5 ) - int( t0Tcp )
459 deltaOfpGraph4 = int( graphTimestamp4 ) - int( t0Ofp )
460 deltaOfpGraph5 = int( graphTimestamp5 ) - int( t0Ofp )
461 deltaOfpDevice4 = float( deviceTimestamp4 ) -\
462 float( t0Ofp )
463 deltaOfpDevice5 = float( deviceTimestamp5 ) -\
464 float( t0Ofp )
andrewonlab67630692015-01-29 20:16:01 -0500465
466 if deltaGraph4 > thresholdMin and\
467 deltaGraph4 < thresholdMax and i >= iterIgnore:
468 endToEndLatNodeIter[3][i] = deltaGraph4
469 main.log.info("ONOS4 iter"+str(i)+" end-to-end: "+
470 str(deltaGraph4)+" ms")
471
472 #TODO:
473 if deltaOfpGraph4 > thresholdMin and\
474 deltaOfpGraph4 < thresholdMax and i >= iterIgnore:
475 ofpToGraphLatNodeIter[3][i] = deltaOfpGraph4
476 main.log.info("ONOS4 iter"+str(i)+" ofp-to-graph: "+
477 str(deltaOfpGraph4)+" ms")
andrewonlaba57a3042015-01-23 13:53:05 -0500478
andrewonlab67630692015-01-29 20:16:01 -0500479 if deltaGraph5 > thresholdMin and\
480 deltaGraph5 < thresholdMax and i >= iterIgnore:
481 endToEndLatNodeIter[4][i] = deltaGraph5
482 main.log.info("ONOS5 iter"+str(i)+" end-to-end: "+
483 str(deltaGraph5)+" ms")
484
485 if deltaOfpGraph5 > thresholdMin and\
486 deltaOfpGraph5 < thresholdMax and i >= iterIgnore:
487 ofpToGraphLatNodeIter[4][i] = deltaOfpGraph5
488 main.log.info("ONOS5 iter"+str(i)+" ofp-to-graph: "+
489 str(deltaOfpGraph5)+" ms")
490
andrewonlab79244cc2015-01-26 01:11:49 -0500491 if clusterCount >= 7:
492 jsonStr6 = main.ONOS6cli.topologyEventsMetrics()
493 jsonStr7 = main.ONOS7cli.topologyEventsMetrics()
494 jsonObj6 = json.loads( jsonStr6 )
495 jsonObj7 = json.loads( jsonStr7 )
496 graphTimestamp6 = \
497 jsonObj6[ graphTimestamp ][ 'value' ]
498 graphTimestamp7 = \
499 jsonObj7[ graphTimestamp ][ 'value' ]
500 deviceTimestamp6 = \
501 jsonObj6[ deviceTimestamp ][ 'value' ]
502 deviceTimestamp7 = \
503 jsonObj7[ deviceTimestamp ][ 'value' ]
504 deltaDevice6 = int( deviceTimestamp6 ) - int( t0Tcp )
505 deltaDevice7 = int( deviceTimestamp7 ) - int( t0Tcp )
506 deltaGraph6 = int( graphTimestamp6 ) - int( t0Tcp )
507 deltaGraph7 = int( graphTimestamp7 ) - int( t0Tcp )
508 deltaOfpGraph6 = int( graphTimestamp6 ) - int( t0Ofp )
509 deltaOfpGraph7 = int( graphTimestamp7 ) - int( t0Ofp )
510 deltaOfpDevice6 = float( deviceTimestamp6 ) -\
511 float( t0Ofp )
512 deltaOfpDevice7 = float( deviceTimestamp7 ) -\
513 float( t0Ofp )
andrewonlab67630692015-01-29 20:16:01 -0500514
515 if deltaGraph6 > thresholdMin and\
516 deltaGraph6 < thresholdMax and i >= iterIgnore:
517 endToEndLatNodeIter[5][i] = deltaGraph6
518 main.log.info("ONOS6 iter"+str(i)+" end-to-end: "+
519 str(deltaGraph6)+" ms")
520
521 #TODO:
522 if deltaOfpGraph6 > thresholdMin and\
523 deltaOfpGraph6 < thresholdMax and i >= iterIgnore:
524 ofpToGraphLatNodeIter[5][i] = deltaOfpGraph6
525 main.log.info("ONOS6 iter"+str(i)+" ofp-to-graph: "+
526 str(deltaOfpGraph6)+" ms")
andrewonlaba57a3042015-01-23 13:53:05 -0500527
andrewonlab67630692015-01-29 20:16:01 -0500528 if deltaGraph7 > thresholdMin and\
529 deltaGraph7 < thresholdMax and i >= iterIgnore:
530 endToEndLatNodeIter[6][i] = deltaGraph7
531 main.log.info("ONOS7 iter"+str(i)+" end-to-end: "+
532 str(deltaGraph7)+" ms")
533
534 if deltaOfpGraph7 > thresholdMin and\
535 deltaOfpGraph7 < thresholdMax and i >= iterIgnore:
536 ofpToGraphLatNodeIter[6][i] = deltaOfpGraph7
537 main.log.info("ONOS7 iter"+str(i)+" ofp-to-graph: "+
538 str(deltaOfpGraph7)+" ms")
andrewonlabba44bcf2014-10-16 16:54:41 -0400539
andrewonlab79244cc2015-01-26 01:11:49 -0500540 main.step( "Remove switch from controller" )
541 main.Mininet1.deleteSwController( "s1" )
andrewonlabf47993a2014-10-24 17:56:01 -0400542
andrewonlab79244cc2015-01-26 01:11:49 -0500543 time.sleep( 5 )
544
545 # END of for loop iteration
546
andrewonlab67630692015-01-29 20:16:01 -0500547 #str( round( numpy.std( latencyT0ToDeviceList ), 1 ) )
andrewonlabc15c9582014-10-24 16:35:52 -0400548
andrewonlab67630692015-01-29 20:16:01 -0500549 endToEndAvg = 0
550 ofpToGraphAvg = 0
551 endToEndList = []
552 ofpToGraphList = []
andrewonlab69864162014-11-11 16:28:48 -0500553
andrewonlab67630692015-01-29 20:16:01 -0500554 for node in range( 0, clusterCount ):
555 # The latency 2d array was initialized to 0.
556 # If an iteration was ignored, then we have some 0's in
557 # our calculation. To avoid having this interfere with our
558 # results, we must delete any index where 0 is found...
559 # WARN: Potentially, we could have latency that hovers at
560 # 0 ms once we have optimized code. FIXME for when this is
561 # the case. Being able to obtain sub-millisecond accuracy
562 # can prevent this from happening
563 for item in endToEndLatNodeIter[node]:
564 if item > 0.0:
565 endToEndList.append(item)
566 for item in ofpToGraphLatNodeIter[node]:
567 if item > 0.0:
568 ofpToGraphList.append(item)
andrewonlabc15c9582014-10-24 16:35:52 -0400569
andrewonlab67630692015-01-29 20:16:01 -0500570 endToEndAvg = numpy.mean(endToEndList)
571 ofpToGraphAvg = numpy.mean(ofpToGraphList)
andrewonlabc15c9582014-10-24 16:35:52 -0400572
andrewonlab67630692015-01-29 20:16:01 -0500573 main.log.report( " - Node "+str(node+1)+" Summary - " )
574 main.log.report( " End-to-end Avg: "+
575 str(round(endToEndAvg,2))+" ms"+
576 " End-to-end Std dev: "+
577 str(round(numpy.std(endToEndList),2))+" ms")
578 main.log.report( " Ofp-to-graph Avg: "+
579 str(round(ofpToGraphAvg,2))+" ms"+
580 " Ofp-to-graph Std dev: "+
581 str(round(numpy.std(ofpToGraphList),2))+
582 " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400583
andrewonlab79244cc2015-01-26 01:11:49 -0500584 if debugMode == 'on':
585 main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log",
586 "/tmp/", copyFileName="sw_lat_karaf" )
andrewonlabb1998c52014-11-10 13:31:43 -0500587
andrewonlab67630692015-01-29 20:16:01 -0500588 #TODO: correct assert
589 assertion = main.TRUE
590
andrewonlab79244cc2015-01-26 01:11:49 -0500591 utilities.assert_equals( expect=main.TRUE, actual=assertion,
592 onpass="Switch latency test successful",
593 onfail="Switch latency test failed" )
andrewonlabba44bcf2014-10-16 16:54:41 -0400594
andrewonlab79244cc2015-01-26 01:11:49 -0500595 def CASE3( self, main ):
596 """
andrewonlab8d29f122014-10-22 17:15:04 -0400597 Bring port up / down and measure latency.
598 Port enable / disable is simulated by ifconfig up / down
andrewonlab79244cc2015-01-26 01:11:49 -0500599
600 In ONOS-next, we must ensure that the port we are
andrewonlab393531a2014-10-27 18:36:26 -0400601 manipulating is connected to another switch with a valid
602 connection. Otherwise, graph view will not be updated.
andrewonlab79244cc2015-01-26 01:11:49 -0500603 """
andrewonlab8d29f122014-10-22 17:15:04 -0400604 import time
605 import subprocess
606 import os
607 import requests
608 import json
andrewonlab4f50ec92014-11-11 14:24:45 -0500609 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500610 global clusterCount
andrewonlab2a6c9342014-10-16 13:40:15 -0400611
andrewonlab79244cc2015-01-26 01:11:49 -0500612 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
613 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
614 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
615 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab8d29f122014-10-22 17:15:04 -0400616
andrewonlab79244cc2015-01-26 01:11:49 -0500617 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
618
andrewonlab8790abb2014-11-06 13:51:54 -0500619 assertion = main.TRUE
andrewonlab79244cc2015-01-26 01:11:49 -0500620 # Number of iterations of case
621 numIter = main.params[ 'TEST' ][ 'numIter' ]
andrewonlab58f7d702014-11-07 13:21:19 -0500622
andrewonlab79244cc2015-01-26 01:11:49 -0500623 # Timestamp 'keys' for json metrics output.
624 # These are subject to change, hence moved into params
625 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
626 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
andrewonlab393531a2014-10-27 18:36:26 -0400627
andrewonlab79244cc2015-01-26 01:11:49 -0500628 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500629
andrewonlab79244cc2015-01-26 01:11:49 -0500630 localTime = time.strftime( '%x %X' )
631 localTime = localTime.replace( "/", "" )
632 localTime = localTime.replace( " ", "_" )
633 localTime = localTime.replace( ":", "" )
634 if debugMode == 'on':
635 main.ONOS1.tsharkPcap( "eth0",
636 "/tmp/port_lat_pcap_" + localTime )
andrewonlabe5bcef92014-11-06 17:53:20 -0500637
andrewonlab79244cc2015-01-26 01:11:49 -0500638 # Threshold for this test case
639 upThresholdStr = main.params[ 'TEST' ][ 'portUpThreshold' ]
640 downThresholdStr = main.params[ 'TEST' ][ 'portDownThreshold' ]
andrewonlabe5bcef92014-11-06 17:53:20 -0500641
andrewonlab79244cc2015-01-26 01:11:49 -0500642 upThresholdObj = upThresholdStr.split( "," )
643 downThresholdObj = downThresholdStr.split( "," )
644
645 upThresholdMin = int( upThresholdObj[ 0 ] )
646 upThresholdMax = int( upThresholdObj[ 1 ] )
647
648 downThresholdMin = int( downThresholdObj[ 0 ] )
649 downThresholdMax = int( downThresholdObj[ 1 ] )
650
651 # NOTE: Some hardcoded variables you may need to configure
andrewonlab393531a2014-10-27 18:36:26 -0400652 # besides the params
andrewonlab8d29f122014-10-22 17:15:04 -0400653
andrewonlab79244cc2015-01-26 01:11:49 -0500654 tsharkPortStatus = "OFP 130 Port Status"
andrewonlab8d29f122014-10-22 17:15:04 -0400655
andrewonlab79244cc2015-01-26 01:11:49 -0500656 tsharkPortUp = "/tmp/tshark_port_up.txt"
657 tsharkPortDown = "/tmp/tshark_port_down.txt"
658 interfaceConfig = "s1-eth1"
andrewonlab8d29f122014-10-22 17:15:04 -0400659
andrewonlab79244cc2015-01-26 01:11:49 -0500660 main.log.report( "Port enable / disable latency" )
661 main.log.report( "Simulated by ifconfig up / down" )
662 main.log.report( "Total iterations of test: " + str( numIter ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400663
andrewonlab79244cc2015-01-26 01:11:49 -0500664 main.step( "Assign switches s1 and s2 to controller 1" )
665 main.Mininet1.assignSwController( sw="1", ip1=ONOS1Ip,
666 port1=defaultSwPort )
667 main.Mininet1.assignSwController( sw="2", ip1=ONOS1Ip,
668 port1=defaultSwPort )
andrewonlab8d29f122014-10-22 17:15:04 -0400669
andrewonlab79244cc2015-01-26 01:11:49 -0500670 # Give enough time for metrics to propagate the
671 # assign controller event. Otherwise, these events may
672 # carry over to our measurements
673 time.sleep( 15 )
andrewonlab393531a2014-10-27 18:36:26 -0400674
andrewonlab79244cc2015-01-26 01:11:49 -0500675 portUpDeviceToOfpList = []
676 portUpGraphToOfpList = []
677 portDownDeviceToOfpList = []
678 portDownGraphToOfpList = []
andrewonlab8d29f122014-10-22 17:15:04 -0400679
andrewonlab79244cc2015-01-26 01:11:49 -0500680 for i in range( 0, int( numIter ) ):
681 main.step( "Starting wireshark capture for port status down" )
682 main.ONOS1.tsharkGrep( tsharkPortStatus,
683 tsharkPortDown )
andrewonlab8d29f122014-10-22 17:15:04 -0400684
andrewonlab79244cc2015-01-26 01:11:49 -0500685 time.sleep( 5 )
686
687 # Disable interface that is connected to switch 2
688 main.step( "Disable port: " + interfaceConfig )
689 main.Mininet1.handle.sendline( "sh ifconfig " +
690 interfaceConfig + " down" )
691 main.Mininet1.handle.expect( "mininet>" )
692
693 time.sleep( 3 )
694 main.ONOS1.tsharkStop()
695
696 # Copy tshark output file from ONOS to TestON instance
kelvin-onlab8a832582015-01-16 17:06:11 -0800697 #/tmp directory
andrewonlab79244cc2015-01-26 01:11:49 -0500698 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
699 tsharkPortDown + " /tmp/" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800700
andrewonlab79244cc2015-01-26 01:11:49 -0500701 fPortDown = open( tsharkPortDown, 'r' )
702 # Get first line of port down event from tshark
703 fLine = fPortDown.readline()
704 objDown = fLine.split( " " )
705 if len( fLine ) > 0:
706 # NOTE: objDown[ 1 ] is a very unreliable
707 # way to determine the timestamp. If
708 # results seem way off, check the object
andrewonlaba57a3042015-01-23 13:53:05 -0500709 # itself by printing it out
andrewonlab79244cc2015-01-26 01:11:49 -0500710 timestampBeginPtDown = int( float( objDown[ 1 ] ) * 1000 )
711 # For some reason, wireshark decides to record the
andrewonlaba57a3042015-01-23 13:53:05 -0500712 # timestamp at the 3rd object position instead of
andrewonlab79244cc2015-01-26 01:11:49 -0500713 # 2nd at unpredictable times. This statement is
andrewonlaba57a3042015-01-23 13:53:05 -0500714 # used to capture that odd behavior and use the
715 # correct epoch time
andrewonlab79244cc2015-01-26 01:11:49 -0500716 if timestampBeginPtDown < 1400000000000:
717 timestampBeginPtDown = \
718 int( float( objDown[ 2 ] ) * 1000 )
andrewonlaba57a3042015-01-23 13:53:05 -0500719
andrewonlab79244cc2015-01-26 01:11:49 -0500720 main.log.info( "Port down begin timestamp: " +
721 str( timestampBeginPtDown ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400722 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500723 main.log.info( "Tshark output file returned unexpected" +
724 " results: " + str( objDown ) )
725 timestampBeginPtDown = 0
726 fPortDown.close()
727
728 main.step( "Obtain t1 by metrics call" )
729 jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
730 jsonObj1 = json.loads( jsonStrUp1 )
731 # Obtain graph timestamp. This timestsamp captures
732 # the epoch time at which the topology graph was updated.
733 graphTimestamp1 = \
734 jsonObj1[ graphTimestamp ][ 'value' ]
735 # Obtain device timestamp. This timestamp captures
736 # the epoch time at which the device event happened
737 deviceTimestamp1 = \
738 jsonObj1[ deviceTimestamp ][ 'value' ]
739 # Get delta between graph event and OFP
740 ptDownGraphToOfp1 = int( graphTimestamp1 ) -\
741 int( timestampBeginPtDown )
742 # Get delta between device event and OFP
743 ptDownDeviceToOfp1 = int( deviceTimestamp1 ) -\
744 int( timestampBeginPtDown )
745
746 if clusterCount >= 3:
747 jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
748 jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
749 jsonObj2 = json.loads( jsonStrUp2 )
750 jsonObj3 = json.loads( jsonStrUp3 )
751 graphTimestamp2 = \
752 jsonObj2[ graphTimestamp ][ 'value' ]
753 graphTimestamp3 = \
754 jsonObj3[ graphTimestamp ][ 'value' ]
755 deviceTimestamp2 = \
756 jsonObj2[ deviceTimestamp ][ 'value' ]
757 deviceTimestamp3 = \
758 jsonObj3[ deviceTimestamp ][ 'value' ]
759 ptDownGraphToOfp2 = int( graphTimestamp2 ) -\
760 int( timestampBeginPtDown )
761 ptDownGraphToOfp3 = int( graphTimestamp3 ) -\
762 int( timestampBeginPtDown )
763 ptDownDeviceToOfp2 = int( deviceTimestamp2 ) -\
764 int( timestampBeginPtDown )
765 ptDownDeviceToOfp3 = int( deviceTimestamp3 ) -\
766 int( timestampBeginPtDown )
andrewonlaba57a3042015-01-23 13:53:05 -0500767 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500768 ptDownGraphToOfp2 = 0
769 ptDownGraphToOfp3 = 0
770 ptDownDeviceToOfp2 = 0
771 ptDownDeviceToOfp3 = 0
andrewonlab393531a2014-10-27 18:36:26 -0400772
andrewonlab79244cc2015-01-26 01:11:49 -0500773 if clusterCount >= 5:
774 jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
775 jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
776 jsonObj4 = json.loads( jsonStrUp4 )
777 jsonObj5 = json.loads( jsonStrUp5 )
778 graphTimestamp4 = \
779 jsonObj4[ graphTimestamp ][ 'value' ]
780 graphTimestamp5 = \
781 jsonObj5[ graphTimestamp ][ 'value' ]
782 deviceTimestamp4 = \
783 jsonObj4[ deviceTimestamp ][ 'value' ]
784 deviceTimestamp5 = \
785 jsonObj5[ deviceTimestamp ][ 'value' ]
786 ptDownGraphToOfp4 = int( graphTimestamp4 ) -\
787 int( timestampBeginPtDown )
788 ptDownGraphToOfp5 = int( graphTimestamp5 ) -\
789 int( timestampBeginPtDown )
790 ptDownDeviceToOfp4 = int( deviceTimestamp4 ) -\
791 int( timestampBeginPtDown )
792 ptDownDeviceToOfp5 = int( deviceTimestamp5 ) -\
793 int( timestampBeginPtDown )
andrewonlaba57a3042015-01-23 13:53:05 -0500794 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500795 ptDownGraphToOfp4 = 0
796 ptDownGraphToOfp5 = 0
797 ptDownDeviceToOfp4 = 0
798 ptDownDeviceToOfp5 = 0
andrewonlab393531a2014-10-27 18:36:26 -0400799
andrewonlab79244cc2015-01-26 01:11:49 -0500800 if clusterCount >= 7:
801 jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
802 jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
803 jsonObj6 = json.loads( jsonStrUp6 )
804 jsonObj7 = json.loads( jsonStrUp7 )
805 graphTimestamp6 = \
806 jsonObj6[ graphTimestamp ][ 'value' ]
807 graphTimestamp7 = \
808 jsonObj7[ graphTimestamp ][ 'value' ]
809 deviceTimestamp6 = \
810 jsonObj6[ deviceTimestamp ][ 'value' ]
811 deviceTimestamp7 = \
812 jsonObj7[ deviceTimestamp ][ 'value' ]
813 ptDownGraphToOfp6 = int( graphTimestamp6 ) -\
814 int( timestampBeginPtDown )
815 ptDownGraphToOfp7 = int( graphTimestamp7 ) -\
816 int( timestampBeginPtDown )
817 ptDownDeviceToOfp6 = int( deviceTimestamp6 ) -\
818 int( timestampBeginPtDown )
819 ptDownDeviceToOfp7 = int( deviceTimestamp7 ) -\
820 int( timestampBeginPtDown )
andrewonlaba57a3042015-01-23 13:53:05 -0500821 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500822 ptDownGraphToOfp6 = 0
823 ptDownGraphToOfp7 = 0
824 ptDownDeviceToOfp6 = 0
825 ptDownDeviceToOfp7 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -0800826
andrewonlab79244cc2015-01-26 01:11:49 -0500827 time.sleep( 3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500828
andrewonlab79244cc2015-01-26 01:11:49 -0500829 # Caluclate average across clusters
830 ptDownGraphToOfpAvg =\
831 ( int( ptDownGraphToOfp1 ) +
832 int( ptDownGraphToOfp2 ) +
833 int( ptDownGraphToOfp3 ) +
834 int( ptDownGraphToOfp4 ) +
835 int( ptDownGraphToOfp5 ) +
836 int( ptDownGraphToOfp6 ) +
837 int( ptDownGraphToOfp7 ) ) / clusterCount
838 ptDownDeviceToOfpAvg = \
839 ( int( ptDownDeviceToOfp1 ) +
840 int( ptDownDeviceToOfp2 ) +
841 int( ptDownDeviceToOfp3 ) +
842 int( ptDownDeviceToOfp4 ) +
843 int( ptDownDeviceToOfp5 ) +
844 int( ptDownDeviceToOfp6 ) +
845 int( ptDownDeviceToOfp7 ) ) / clusterCount
andrewonlab393531a2014-10-27 18:36:26 -0400846
andrewonlab79244cc2015-01-26 01:11:49 -0500847 if ptDownGraphToOfpAvg > downThresholdMin and \
848 ptDownGraphToOfpAvg < downThresholdMax:
849 portDownGraphToOfpList.append(
850 ptDownGraphToOfpAvg )
851 main.log.info( "Port down: graph to ofp avg: " +
852 str( ptDownGraphToOfpAvg ) + " ms" )
andrewonlab393531a2014-10-27 18:36:26 -0400853 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500854 main.log.info( "Average port down graph-to-ofp result" +
855 " exceeded the threshold: " +
856 str( ptDownGraphToOfpAvg ) )
andrewonlab393531a2014-10-27 18:36:26 -0400857
andrewonlab79244cc2015-01-26 01:11:49 -0500858 if ptDownDeviceToOfpAvg > 0 and \
859 ptDownDeviceToOfpAvg < 1000:
860 portDownDeviceToOfpList.append(
861 ptDownDeviceToOfpAvg )
862 main.log.info( "Port down: device to ofp avg: " +
863 str( ptDownDeviceToOfpAvg ) + " ms" )
andrewonlab3622beb2014-10-28 16:07:56 -0400864 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500865 main.log.info( "Average port down device-to-ofp result" +
866 " exceeded the threshold: " +
867 str( ptDownDeviceToOfpAvg ) )
andrewonlab3622beb2014-10-28 16:07:56 -0400868
andrewonlab79244cc2015-01-26 01:11:49 -0500869 # Port up events
870 main.step( "Enable port and obtain timestamp" )
871 main.step( "Starting wireshark capture for port status up" )
872 main.ONOS1.tsharkGrep( tsharkPortStatus, tsharkPortUp )
873 time.sleep( 5 )
andrewonlab8d29f122014-10-22 17:15:04 -0400874
andrewonlab79244cc2015-01-26 01:11:49 -0500875 main.Mininet1.handle.sendline( "sh ifconfig " +
876 interfaceConfig + " up" )
877 main.Mininet1.handle.expect( "mininet>" )
878
879 # Allow time for tshark to capture event
880 time.sleep( 5 )
881 main.ONOS1.tsharkStop()
882
883 time.sleep( 3 )
884 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
885 tsharkPortUp + " /tmp/" )
886 fPortUp = open( tsharkPortUp, 'r' )
887 fLine = fPortUp.readline()
888 objUp = fLine.split( " " )
889 if len( fLine ) > 0:
890 timestampBeginPtUp = int( float( objUp[ 1 ] ) * 1000 )
891 if timestampBeginPtUp < 1400000000000:
892 timestampBeginPtUp = \
893 int( float( objUp[ 2 ] ) * 1000 )
894 main.log.info( "Port up begin timestamp: " +
895 str( timestampBeginPtUp ) )
andrewonlab8d29f122014-10-22 17:15:04 -0400896 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500897 main.log.info( "Tshark output file returned unexpected" +
898 " results." )
899 timestampBeginPtUp = 0
900 fPortUp.close()
andrewonlab393531a2014-10-27 18:36:26 -0400901
andrewonlab79244cc2015-01-26 01:11:49 -0500902 # Obtain metrics shortly afterwards
903 # This timestsamp captures
904 # the epoch time at which the topology graph was updated.
905 main.step( "Obtain t1 by REST call" )
906 jsonStrUp1 = main.ONOS1cli.topologyEventsMetrics()
907 jsonObj1 = json.loads( jsonStrUp1 )
908 graphTimestamp1 = \
909 jsonObj1[ graphTimestamp ][ 'value' ]
910 # Obtain device timestamp. This timestamp captures
911 # the epoch time at which the device event happened
912 deviceTimestamp1 = \
913 jsonObj1[ deviceTimestamp ][ 'value' ]
914 # Get delta between graph event and OFP
915 ptUpGraphToOfp1 = int( graphTimestamp1 ) -\
916 int( timestampBeginPtUp )
917 # Get delta between device event and OFP
918 ptUpDeviceToOfp1 = int( deviceTimestamp1 ) -\
919 int( timestampBeginPtUp )
andrewonlab393531a2014-10-27 18:36:26 -0400920
andrewonlab79244cc2015-01-26 01:11:49 -0500921 if clusterCount >= 3:
922 jsonStrUp2 = main.ONOS2cli.topologyEventsMetrics()
923 jsonStrUp3 = main.ONOS3cli.topologyEventsMetrics()
924 jsonObj2 = json.loads( jsonStrUp2 )
925 jsonObj3 = json.loads( jsonStrUp3 )
926 graphTimestamp2 = \
927 jsonObj2[ graphTimestamp ][ 'value' ]
928 graphTimestamp3 = \
929 jsonObj3[ graphTimestamp ][ 'value' ]
930 deviceTimestamp2 = \
931 jsonObj2[ deviceTimestamp ][ 'value' ]
932 deviceTimestamp3 = \
933 jsonObj3[ deviceTimestamp ][ 'value' ]
934 ptUpGraphToOfp2 = int( graphTimestamp2 ) -\
935 int( timestampBeginPtUp )
936 ptUpGraphToOfp3 = int( graphTimestamp3 ) -\
937 int( timestampBeginPtUp )
938 ptUpDeviceToOfp2 = int( deviceTimestamp2 ) -\
939 int( timestampBeginPtUp )
940 ptUpDeviceToOfp3 = int( deviceTimestamp3 ) -\
941 int( timestampBeginPtUp )
andrewonlaba57a3042015-01-23 13:53:05 -0500942 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500943 ptUpGraphToOfp2 = 0
944 ptUpGraphToOfp3 = 0
945 ptUpDeviceToOfp2 = 0
946 ptUpDeviceToOfp3 = 0
andrewonlabb1998c52014-11-10 13:31:43 -0500947
andrewonlab79244cc2015-01-26 01:11:49 -0500948 if clusterCount >= 5:
949 jsonStrUp4 = main.ONOS4cli.topologyEventsMetrics()
950 jsonStrUp5 = main.ONOS5cli.topologyEventsMetrics()
951 jsonObj4 = json.loads( jsonStrUp4 )
952 jsonObj5 = json.loads( jsonStrUp5 )
953 graphTimestamp4 = \
954 jsonObj4[ graphTimestamp ][ 'value' ]
955 graphTimestamp5 = \
956 jsonObj5[ graphTimestamp ][ 'value' ]
957 deviceTimestamp4 = \
958 jsonObj4[ deviceTimestamp ][ 'value' ]
959 deviceTimestamp5 = \
960 jsonObj5[ deviceTimestamp ][ 'value' ]
961 ptUpGraphToOfp4 = int( graphTimestamp4 ) -\
962 int( timestampBeginPtUp )
963 ptUpGraphToOfp5 = int( graphTimestamp5 ) -\
964 int( timestampBeginPtUp )
965 ptUpDeviceToOfp4 = int( deviceTimestamp4 ) -\
966 int( timestampBeginPtUp )
967 ptUpDeviceToOfp5 = int( deviceTimestamp5 ) -\
968 int( timestampBeginPtUp )
andrewonlab3622beb2014-10-28 16:07:56 -0400969 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500970 ptUpGraphToOfp4 = 0
971 ptUpGraphToOfp5 = 0
972 ptUpDeviceToOfp4 = 0
973 ptUpDeviceToOfp5 = 0
974
975 if clusterCount >= 7:
976 jsonStrUp6 = main.ONOS6cli.topologyEventsMetrics()
977 jsonStrUp7 = main.ONOS7cli.topologyEventsMetrics()
978 jsonObj6 = json.loads( jsonStrUp6 )
979 jsonObj7 = json.loads( jsonStrUp7 )
980 graphTimestamp6 = \
981 jsonObj6[ graphTimestamp ][ 'value' ]
982 graphTimestamp7 = \
983 jsonObj7[ graphTimestamp ][ 'value' ]
984 deviceTimestamp6 = \
985 jsonObj6[ deviceTimestamp ][ 'value' ]
986 deviceTimestamp7 = \
987 jsonObj7[ deviceTimestamp ][ 'value' ]
988 ptUpGraphToOfp6 = int( graphTimestamp6 ) -\
989 int( timestampBeginPtUp )
990 ptUpGraphToOfp7 = int( graphTimestamp7 ) -\
991 int( timestampBeginPtUp )
992 ptUpDeviceToOfp6 = int( deviceTimestamp6 ) -\
993 int( timestampBeginPtUp )
994 ptUpDeviceToOfp7 = int( deviceTimestamp7 ) -\
995 int( timestampBeginPtUp )
andrewonlab3622beb2014-10-28 16:07:56 -0400996 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500997 ptUpGraphToOfp6 = 0
998 ptUpGraphToOfp7 = 0
999 ptUpDeviceToOfp6 = 0
1000 ptUpDeviceToOfp7 = 0
1001
1002 ptUpGraphToOfpAvg = \
1003 ( int( ptUpGraphToOfp1 ) +
1004 int( ptUpGraphToOfp2 ) +
1005 int( ptUpGraphToOfp3 ) +
1006 int( ptUpGraphToOfp4 ) +
1007 int( ptUpGraphToOfp5 ) +
1008 int( ptUpGraphToOfp6 ) +
1009 int( ptUpGraphToOfp7 ) ) / clusterCount
1010
1011 ptUpDeviceToOfpAvg = \
1012 ( int( ptUpDeviceToOfp1 ) +
1013 int( ptUpDeviceToOfp2 ) +
1014 int( ptUpDeviceToOfp3 ) +
1015 int( ptUpDeviceToOfp4 ) +
1016 int( ptUpDeviceToOfp5 ) +
1017 int( ptUpDeviceToOfp6 ) +
1018 int( ptUpDeviceToOfp7 ) ) / clusterCount
1019
1020 if ptUpGraphToOfpAvg > upThresholdMin and \
1021 ptUpGraphToOfpAvg < upThresholdMax:
1022 portUpGraphToOfpList.append(
1023 ptUpGraphToOfpAvg )
1024 main.log.info( "Port down: graph to ofp avg: " +
1025 str( ptUpGraphToOfpAvg ) + " ms" )
1026 else:
1027 main.log.info( "Average port up graph-to-ofp result" +
1028 " exceeded the threshold: " +
1029 str( ptUpGraphToOfpAvg ) )
1030
1031 if ptUpDeviceToOfpAvg > upThresholdMin and \
1032 ptUpDeviceToOfpAvg < upThresholdMax:
1033 portUpDeviceToOfpList.append(
1034 ptUpDeviceToOfpAvg )
1035 main.log.info( "Port up: device to ofp avg: " +
1036 str( ptUpDeviceToOfpAvg ) + " ms" )
1037 else:
1038 main.log.info( "Average port up device-to-ofp result" +
1039 " exceeded the threshold: " +
1040 str( ptUpDeviceToOfpAvg ) )
1041
1042 # END ITERATION FOR LOOP
1043
1044 # Check all list for latency existence and set assertion
1045 if ( portDownGraphToOfpList and portDownDeviceToOfpList
1046 and portUpGraphToOfpList and portUpDeviceToOfpList ):
andrewonlab8790abb2014-11-06 13:51:54 -05001047 assertion = main.TRUE
andrewonlab8790abb2014-11-06 13:51:54 -05001048
andrewonlab79244cc2015-01-26 01:11:49 -05001049 main.log.report( "Cluster size: " + str( clusterCount ) +
1050 " node(s)" )
1051 # Calculate and report latency measurements
1052 portDownGraphToOfpMin = min( portDownGraphToOfpList )
1053 portDownGraphToOfpMax = max( portDownGraphToOfpList )
1054 portDownGraphToOfpAvg = \
1055 ( sum( portDownGraphToOfpList ) /
1056 len( portDownGraphToOfpList ) )
1057 portDownGraphToOfpStdDev = \
1058 str( round( numpy.std( portDownGraphToOfpList ), 1 ) )
andrewonlababb11c32014-11-04 15:03:24 -05001059
andrewonlab79244cc2015-01-26 01:11:49 -05001060 main.log.report( "Port down graph-to-ofp " +
1061 "Avg: " + str( portDownGraphToOfpAvg ) + " ms " +
1062 "Std Deviation: " + portDownGraphToOfpStdDev + " ms" )
1063
1064 portDownDeviceToOfpMin = min( portDownDeviceToOfpList )
1065 portDownDeviceToOfpMax = max( portDownDeviceToOfpList )
1066 portDownDeviceToOfpAvg = \
1067 ( sum( portDownDeviceToOfpList ) /
1068 len( portDownDeviceToOfpList ) )
1069 portDownDeviceToOfpStdDev = \
1070 str( round( numpy.std( portDownDeviceToOfpList ), 1 ) )
1071
1072 main.log.report(
1073 "Port down device-to-ofp " +
1074 "Avg: " +
1075 str( portDownDeviceToOfpAvg ) +
1076 " ms " +
1077 "Std Deviation: " +
1078 portDownDeviceToOfpStdDev +
1079 " ms" )
1080
1081 portUpGraphToOfpMin = min( portUpGraphToOfpList )
1082 portUpGraphToOfpMax = max( portUpGraphToOfpList )
1083 portUpGraphToOfpAvg = \
1084 ( sum( portUpGraphToOfpList ) /
1085 len( portUpGraphToOfpList ) )
1086 portUpGraphToOfpStdDev = \
1087 str( round( numpy.std( portUpGraphToOfpList ), 1 ) )
1088
1089 main.log.report( "Port up graph-to-ofp " +
1090 "Avg: " + str( portUpGraphToOfpAvg ) + " ms " +
1091 "Std Deviation: " + portUpGraphToOfpStdDev + " ms" )
1092
1093 portUpDeviceToOfpMin = min( portUpDeviceToOfpList )
1094 portUpDeviceToOfpMax = max( portUpDeviceToOfpList )
1095 portUpDeviceToOfpAvg = \
1096 ( sum( portUpDeviceToOfpList ) /
1097 len( portUpDeviceToOfpList ) )
1098 portUpDeviceToOfpStdDev = \
1099 str( round( numpy.std( portUpDeviceToOfpList ), 1 ) )
1100
1101 main.log.report( "Port up device-to-ofp " +
1102 "Avg: " + str( portUpDeviceToOfpAvg ) + " ms " +
1103 "Std Deviation: " + portUpDeviceToOfpStdDev + " ms" )
1104
1105 # Remove switches from controller for next test
1106 main.Mininet1.deleteSwController( "s1" )
1107 main.Mininet1.deleteSwController( "s2" )
1108
1109 utilities.assert_equals(
1110 expect=main.TRUE,
1111 actual=assertion,
1112 onpass="Port discovery latency calculation successful",
1113 onfail="Port discovery test failed" )
1114
1115 def CASE4( self, main ):
1116 """
andrewonlab3622beb2014-10-28 16:07:56 -04001117 Link down event using loss rate 100%
andrewonlab79244cc2015-01-26 01:11:49 -05001118
andrewonlab53b641c2014-10-31 19:44:44 -04001119 Important:
1120 Use a simple 2 switch topology with 1 link between
andrewonlab79244cc2015-01-26 01:11:49 -05001121 the two switches. Ensure that mac addresses of the
andrewonlab53b641c2014-10-31 19:44:44 -04001122 switches are 1 / 2 respectively
andrewonlab79244cc2015-01-26 01:11:49 -05001123 """
andrewonlab3622beb2014-10-28 16:07:56 -04001124 import time
1125 import subprocess
1126 import os
1127 import requests
1128 import json
andrewonlab79244cc2015-01-26 01:11:49 -05001129 import numpy
andrewonlab3622beb2014-10-28 16:07:56 -04001130
andrewonlab79244cc2015-01-26 01:11:49 -05001131 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1132 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1133 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1134 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab58f7d702014-11-07 13:21:19 -05001135
andrewonlab79244cc2015-01-26 01:11:49 -05001136 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001137
andrewonlab79244cc2015-01-26 01:11:49 -05001138 # Number of iterations of case
1139 numIter = main.params[ 'TEST' ][ 'numIter' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001140
andrewonlab79244cc2015-01-26 01:11:49 -05001141 # Timestamp 'keys' for json metrics output.
1142 # These are subject to change, hence moved into params
1143 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
1144 linkTimestamp = main.params[ 'JSON' ][ 'linkTimestamp' ]
1145 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001146
andrewonlab79244cc2015-01-26 01:11:49 -05001147 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001148
andrewonlab79244cc2015-01-26 01:11:49 -05001149 localTime = time.strftime( '%x %X' )
1150 localTime = localTime.replace( "/", "" )
1151 localTime = localTime.replace( " ", "_" )
1152 localTime = localTime.replace( ":", "" )
1153 if debugMode == 'on':
1154 main.ONOS1.tsharkPcap( "eth0",
1155 "/tmp/link_lat_pcap_" + localTime )
1156
1157 # Threshold for this test case
1158 upThresholdStr = main.params[ 'TEST' ][ 'linkUpThreshold' ]
1159 downThresholdStr = main.params[ 'TEST' ][ 'linkDownThreshold' ]
1160
1161 upThresholdObj = upThresholdStr.split( "," )
1162 downThresholdObj = downThresholdStr.split( "," )
1163
1164 upThresholdMin = int( upThresholdObj[ 0 ] )
1165 upThresholdMax = int( upThresholdObj[ 1 ] )
1166
1167 downThresholdMin = int( downThresholdObj[ 0 ] )
1168 downThresholdMax = int( downThresholdObj[ 1 ] )
andrewonlabe5bcef92014-11-06 17:53:20 -05001169
andrewonlab3622beb2014-10-28 16:07:56 -04001170 assertion = main.TRUE
andrewonlab79244cc2015-01-26 01:11:49 -05001171 # Link event timestamp to system time list
1172 linkDownLinkToSystemList = []
1173 linkUpLinkToSystemList = []
1174 # Graph event timestamp to system time list
1175 linkDownGraphToSystemList = []
1176 linkUpGraphToSystemList = []
andrewonlab3622beb2014-10-28 16:07:56 -04001177
andrewonlab79244cc2015-01-26 01:11:49 -05001178 main.log.report( "Link up / down discovery latency between " +
1179 "two switches" )
1180 main.log.report( "Simulated by setting loss-rate 100%" )
1181 main.log.report( "'tc qdisc add dev <intfs> root netem loss 100%'" )
1182 main.log.report( "Total iterations of test: " + str( numIter ) )
andrewonlab3622beb2014-10-28 16:07:56 -04001183
andrewonlab79244cc2015-01-26 01:11:49 -05001184 main.step( "Assign all switches" )
1185 main.Mininet1.assignSwController( sw="1",
1186 ip1=ONOS1Ip, port1=defaultSwPort )
1187 main.Mininet1.assignSwController( sw="2",
1188 ip1=ONOS1Ip, port1=defaultSwPort )
andrewonlab3622beb2014-10-28 16:07:56 -04001189
andrewonlab79244cc2015-01-26 01:11:49 -05001190 main.step( "Verifying switch assignment" )
1191 resultS1 = main.Mininet1.getSwController( sw="s1" )
1192 resultS2 = main.Mininet1.getSwController( sw="s2" )
andrewonlab3622beb2014-10-28 16:07:56 -04001193
andrewonlab79244cc2015-01-26 01:11:49 -05001194 # Allow time for events to finish before taking measurements
1195 time.sleep( 10 )
1196
1197 linkDown1 = False
1198 linkDown2 = False
1199 linkDown3 = False
1200 # Start iteration of link event test
1201 for i in range( 0, int( numIter ) ):
1202 main.step( "Getting initial system time as t0" )
1203
1204 # System time in epoch ms
1205 timestampLinkDownT0 = time.time() * 1000
1206 # Link down is simulated by 100% loss rate using traffic
1207 # control command
kelvin-onlab8a832582015-01-16 17:06:11 -08001208 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001209 "sh tc qdisc add dev s1-eth1 root netem loss 100%" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001210
andrewonlab79244cc2015-01-26 01:11:49 -05001211 # TODO: Iterate through 'links' command to verify that
1212 # link s1 -> s2 went down ( loop timeout 30 seconds )
andrewonlababb11c32014-11-04 15:03:24 -05001213 # on all 3 ONOS instances
andrewonlab79244cc2015-01-26 01:11:49 -05001214 main.log.info( "Checking ONOS for link update" )
1215 loopCount = 0
1216 while( not ( linkDown1 and linkDown2 and linkDown3 )
1217 and loopCount < 30 ):
1218 jsonStr1 = main.ONOS1cli.links()
1219 jsonStr2 = main.ONOS2cli.links()
1220 jsonStr3 = main.ONOS3cli.links()
1221
1222 if not ( jsonStr1 and jsonStr2 and jsonStr3 ):
1223 main.log.error( "CLI command returned error " )
andrewonlab53b641c2014-10-31 19:44:44 -04001224 break
1225 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001226 jsonObj1 = json.loads( jsonStr1 )
1227 jsonObj2 = json.loads( jsonStr2 )
1228 jsonObj3 = json.loads( jsonStr3 )
1229 for obj1 in jsonObj1:
1230 if '01' not in obj1[ 'src' ][ 'device' ]:
1231 linkDown1 = True
1232 main.log.info( "Link down from " +
1233 "s1 -> s2 on ONOS1 detected" )
1234 for obj2 in jsonObj2:
1235 if '01' not in obj2[ 'src' ][ 'device' ]:
1236 linkDown2 = True
1237 main.log.info( "Link down from " +
1238 "s1 -> s2 on ONOS2 detected" )
1239 for obj3 in jsonObj3:
1240 if '01' not in obj3[ 'src' ][ 'device' ]:
1241 linkDown3 = True
1242 main.log.info( "Link down from " +
1243 "s1 -> s2 on ONOS3 detected" )
1244
1245 loopCount += 1
1246 # If CLI doesn't like the continuous requests
1247 # and exits in this loop, increase the sleep here.
1248 # Consequently, while loop timeout will increase
1249 time.sleep( 1 )
1250
1251 # Give time for metrics measurement to catch up
1252 # NOTE: May need to be configured more accurately
1253 time.sleep( 10 )
1254 # If we exited the while loop and link down 1,2,3 are still
1255 # false, then ONOS has failed to discover link down event
1256 if not ( linkDown1 and linkDown2 and linkDown3 ):
1257 main.log.info( "Link down discovery failed" )
1258
1259 linkDownLatGraph1 = 0
1260 linkDownLatGraph2 = 0
1261 linkDownLatGraph3 = 0
1262 linkDownLatDevice1 = 0
1263 linkDownLatDevice2 = 0
1264 linkDownLatDevice3 = 0
1265
andrewonlab53b641c2014-10-31 19:44:44 -04001266 assertion = main.FALSE
1267 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001268 jsonTopoMetrics1 =\
1269 main.ONOS1cli.topologyEventsMetrics()
1270 jsonTopoMetrics2 =\
1271 main.ONOS2cli.topologyEventsMetrics()
1272 jsonTopoMetrics3 =\
1273 main.ONOS3cli.topologyEventsMetrics()
1274 jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 )
1275 jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 )
1276 jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 )
andrewonlab53b641c2014-10-31 19:44:44 -04001277
andrewonlab79244cc2015-01-26 01:11:49 -05001278 main.log.info( "Obtaining graph and device timestamp" )
1279 graphTimestamp1 = \
1280 jsonTopoMetrics1[ graphTimestamp ][ 'value' ]
1281 graphTimestamp2 = \
1282 jsonTopoMetrics2[ graphTimestamp ][ 'value' ]
1283 graphTimestamp3 = \
1284 jsonTopoMetrics3[ graphTimestamp ][ 'value' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001285
andrewonlab79244cc2015-01-26 01:11:49 -05001286 linkTimestamp1 = \
1287 jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
1288 linkTimestamp2 = \
1289 jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
1290 linkTimestamp3 = \
1291 jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001292
andrewonlab79244cc2015-01-26 01:11:49 -05001293 if graphTimestamp1 and graphTimestamp2 and\
1294 graphTimestamp3 and linkTimestamp1 and\
1295 linkTimestamp2 and linkTimestamp3:
1296 linkDownLatGraph1 = int( graphTimestamp1 ) -\
1297 int( timestampLinkDownT0 )
1298 linkDownLatGraph2 = int( graphTimestamp2 ) -\
1299 int( timestampLinkDownT0 )
1300 linkDownLatGraph3 = int( graphTimestamp3 ) -\
1301 int( timestampLinkDownT0 )
1302
1303 linkDownLatLink1 = int( linkTimestamp1 ) -\
1304 int( timestampLinkDownT0 )
1305 linkDownLatLink2 = int( linkTimestamp2 ) -\
1306 int( timestampLinkDownT0 )
1307 linkDownLatLink3 = int( linkTimestamp3 ) -\
1308 int( timestampLinkDownT0 )
andrewonlab53b641c2014-10-31 19:44:44 -04001309 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001310 main.log.error( "There was an error calculating" +
1311 " the delta for link down event" )
1312 linkDownLatGraph1 = 0
1313 linkDownLatGraph2 = 0
1314 linkDownLatGraph3 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -08001315
andrewonlab79244cc2015-01-26 01:11:49 -05001316 linkDownLatDevice1 = 0
1317 linkDownLatDevice2 = 0
1318 linkDownLatDevice3 = 0
andrewonlab53b641c2014-10-31 19:44:44 -04001319
andrewonlab79244cc2015-01-26 01:11:49 -05001320 main.log.info( "Link down latency ONOS1 iteration " +
1321 str( i ) + " (end-to-end): " +
1322 str( linkDownLatGraph1 ) + " ms" )
1323 main.log.info( "Link down latency ONOS2 iteration " +
1324 str( i ) + " (end-to-end): " +
1325 str( linkDownLatGraph2 ) + " ms" )
1326 main.log.info( "Link down latency ONOS3 iteration " +
1327 str( i ) + " (end-to-end): " +
1328 str( linkDownLatGraph3 ) + " ms" )
1329
1330 main.log.info( "Link down latency ONOS1 iteration " +
1331 str( i ) + " (link-event-to-system-timestamp): " +
1332 str( linkDownLatLink1 ) + " ms" )
1333 main.log.info( "Link down latency ONOS2 iteration " +
1334 str( i ) + " (link-event-to-system-timestamp): " +
1335 str( linkDownLatLink2 ) + " ms" )
1336 main.log.info( "Link down latency ONOS3 iteration " +
1337 str( i ) + " (link-event-to-system-timestamp): " +
1338 str( linkDownLatLink3 ) )
1339
1340 # Calculate avg of node calculations
1341 linkDownLatGraphAvg =\
1342 ( linkDownLatGraph1 +
1343 linkDownLatGraph2 +
1344 linkDownLatGraph3 ) / 3
1345 linkDownLatLinkAvg =\
1346 ( linkDownLatLink1 +
1347 linkDownLatLink2 +
1348 linkDownLatLink3 ) / 3
1349
1350 # Set threshold and append latency to list
1351 if linkDownLatGraphAvg > downThresholdMin and\
1352 linkDownLatGraphAvg < downThresholdMax:
1353 linkDownGraphToSystemList.append(
1354 linkDownLatGraphAvg )
1355 else:
1356 main.log.info( "Link down latency exceeded threshold" )
1357 main.log.info( "Results for iteration " + str( i ) +
1358 "have been omitted" )
1359 if linkDownLatLinkAvg > downThresholdMin and\
1360 linkDownLatLinkAvg < downThresholdMax:
1361 linkDownLinkToSystemList.append(
1362 linkDownLatLinkAvg )
1363 else:
1364 main.log.info( "Link down latency exceeded threshold" )
1365 main.log.info( "Results for iteration " + str( i ) +
1366 "have been omitted" )
1367
1368 # NOTE: To remove loss rate and measure latency:
andrewonlab53b641c2014-10-31 19:44:44 -04001369 # 'sh tc qdisc del dev s1-eth1 root'
andrewonlab79244cc2015-01-26 01:11:49 -05001370 timestampLinkUpT0 = time.time() * 1000
1371 main.Mininet1.handle.sendline( "sh tc qdisc del dev " +
1372 "s1-eth1 root" )
1373 main.Mininet1.handle.expect( "mininet>" )
1374
1375 main.log.info( "Checking ONOS for link update" )
1376
1377 linkDown1 = True
1378 linkDown2 = True
1379 linkDown3 = True
1380 loopCount = 0
1381 while( ( linkDown1 and linkDown2 and linkDown3 )
1382 and loopCount < 30 ):
1383 jsonStr1 = main.ONOS1cli.links()
1384 jsonStr2 = main.ONOS2cli.links()
1385 jsonStr3 = main.ONOS3cli.links()
1386 if not ( jsonStr1 and jsonStr2 and jsonStr3 ):
1387 main.log.error( "CLI command returned error " )
andrewonlababb11c32014-11-04 15:03:24 -05001388 break
1389 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001390 jsonObj1 = json.loads( jsonStr1 )
1391 jsonObj2 = json.loads( jsonStr2 )
1392 jsonObj3 = json.loads( jsonStr3 )
1393
1394 for obj1 in jsonObj1:
1395 if '01' in obj1[ 'src' ][ 'device' ]:
1396 linkDown1 = False
1397 main.log.info( "Link up from " +
1398 "s1 -> s2 on ONOS1 detected" )
1399 for obj2 in jsonObj2:
1400 if '01' in obj2[ 'src' ][ 'device' ]:
1401 linkDown2 = False
1402 main.log.info( "Link up from " +
1403 "s1 -> s2 on ONOS2 detected" )
1404 for obj3 in jsonObj3:
1405 if '01' in obj3[ 'src' ][ 'device' ]:
1406 linkDown3 = False
1407 main.log.info( "Link up from " +
1408 "s1 -> s2 on ONOS3 detected" )
1409
1410 loopCount += 1
1411 time.sleep( 1 )
1412
1413 if ( linkDown1 and linkDown2 and linkDown3 ):
1414 main.log.info( "Link up discovery failed" )
1415
1416 linkUpLatGraph1 = 0
1417 linkUpLatGraph2 = 0
1418 linkUpLatGraph3 = 0
1419 linkUpLatDevice1 = 0
1420 linkUpLatDevice2 = 0
1421 linkUpLatDevice3 = 0
1422
andrewonlababb11c32014-11-04 15:03:24 -05001423 assertion = main.FALSE
1424 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001425 jsonTopoMetrics1 =\
1426 main.ONOS1cli.topologyEventsMetrics()
1427 jsonTopoMetrics2 =\
1428 main.ONOS2cli.topologyEventsMetrics()
1429 jsonTopoMetrics3 =\
1430 main.ONOS3cli.topologyEventsMetrics()
1431 jsonTopoMetrics1 = json.loads( jsonTopoMetrics1 )
1432 jsonTopoMetrics2 = json.loads( jsonTopoMetrics2 )
1433 jsonTopoMetrics3 = json.loads( jsonTopoMetrics3 )
andrewonlababb11c32014-11-04 15:03:24 -05001434
andrewonlab79244cc2015-01-26 01:11:49 -05001435 main.log.info( "Obtaining graph and device timestamp" )
1436 graphTimestamp1 = \
1437 jsonTopoMetrics1[ graphTimestamp ][ 'value' ]
1438 graphTimestamp2 = \
1439 jsonTopoMetrics2[ graphTimestamp ][ 'value' ]
1440 graphTimestamp3 = \
1441 jsonTopoMetrics3[ graphTimestamp ][ 'value' ]
andrewonlababb11c32014-11-04 15:03:24 -05001442
andrewonlab79244cc2015-01-26 01:11:49 -05001443 linkTimestamp1 = \
1444 jsonTopoMetrics1[ linkTimestamp ][ 'value' ]
1445 linkTimestamp2 = \
1446 jsonTopoMetrics2[ linkTimestamp ][ 'value' ]
1447 linkTimestamp3 = \
1448 jsonTopoMetrics3[ linkTimestamp ][ 'value' ]
andrewonlababb11c32014-11-04 15:03:24 -05001449
andrewonlab79244cc2015-01-26 01:11:49 -05001450 if graphTimestamp1 and graphTimestamp2 and\
1451 graphTimestamp3 and linkTimestamp1 and\
1452 linkTimestamp2 and linkTimestamp3:
1453 linkUpLatGraph1 = int( graphTimestamp1 ) -\
1454 int( timestampLinkUpT0 )
1455 linkUpLatGraph2 = int( graphTimestamp2 ) -\
1456 int( timestampLinkUpT0 )
1457 linkUpLatGraph3 = int( graphTimestamp3 ) -\
1458 int( timestampLinkUpT0 )
1459
1460 linkUpLatLink1 = int( linkTimestamp1 ) -\
1461 int( timestampLinkUpT0 )
1462 linkUpLatLink2 = int( linkTimestamp2 ) -\
1463 int( timestampLinkUpT0 )
1464 linkUpLatLink3 = int( linkTimestamp3 ) -\
1465 int( timestampLinkUpT0 )
andrewonlababb11c32014-11-04 15:03:24 -05001466 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001467 main.log.error( "There was an error calculating" +
1468 " the delta for link down event" )
1469 linkUpLatGraph1 = 0
1470 linkUpLatGraph2 = 0
1471 linkUpLatGraph3 = 0
kelvin-onlab8a832582015-01-16 17:06:11 -08001472
andrewonlab79244cc2015-01-26 01:11:49 -05001473 linkUpLatDevice1 = 0
1474 linkUpLatDevice2 = 0
1475 linkUpLatDevice3 = 0
1476
1477 if debugMode == 'on':
1478 main.log.info( "Link up latency ONOS1 iteration " +
1479 str( i ) + " (end-to-end): " +
1480 str( linkUpLatGraph1 ) + " ms" )
1481 main.log.info( "Link up latency ONOS2 iteration " +
1482 str( i ) + " (end-to-end): " +
1483 str( linkUpLatGraph2 ) + " ms" )
1484 main.log.info( "Link up latency ONOS3 iteration " +
1485 str( i ) + " (end-to-end): " +
1486 str( linkUpLatGraph3 ) + " ms" )
1487
1488 main.log.info(
1489 "Link up latency ONOS1 iteration " +
1490 str( i ) +
1491 " (link-event-to-system-timestamp): " +
1492 str( linkUpLatLink1 ) +
1493 " ms" )
1494 main.log.info(
1495 "Link up latency ONOS2 iteration " +
1496 str( i ) +
1497 " (link-event-to-system-timestamp): " +
1498 str( linkUpLatLink2 ) +
1499 " ms" )
1500 main.log.info(
1501 "Link up latency ONOS3 iteration " +
1502 str( i ) +
1503 " (link-event-to-system-timestamp): " +
1504 str( linkUpLatLink3 ) )
1505
1506 # Calculate avg of node calculations
1507 linkUpLatGraphAvg =\
1508 ( linkUpLatGraph1 +
1509 linkUpLatGraph2 +
1510 linkUpLatGraph3 ) / 3
1511 linkUpLatLinkAvg =\
1512 ( linkUpLatLink1 +
1513 linkUpLatLink2 +
1514 linkUpLatLink3 ) / 3
1515
1516 # Set threshold and append latency to list
1517 if linkUpLatGraphAvg > upThresholdMin and\
1518 linkUpLatGraphAvg < upThresholdMax:
1519 linkUpGraphToSystemList.append(
1520 linkUpLatGraphAvg )
andrewonlab8790abb2014-11-06 13:51:54 -05001521 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001522 main.log.info( "Link up latency exceeded threshold" )
1523 main.log.info( "Results for iteration " + str( i ) +
1524 "have been omitted" )
1525 if linkUpLatLinkAvg > upThresholdMin and\
1526 linkUpLatLinkAvg < upThresholdMax:
1527 linkUpLinkToSystemList.append(
1528 linkUpLatLinkAvg )
andrewonlab8790abb2014-11-06 13:51:54 -05001529 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001530 main.log.info( "Link up latency exceeded threshold" )
1531 main.log.info( "Results for iteration " + str( i ) +
1532 "have been omitted" )
andrewonlab53b641c2014-10-31 19:44:44 -04001533
andrewonlab79244cc2015-01-26 01:11:49 -05001534 # Calculate min, max, avg of list and report
1535 linkDownMin = min( linkDownGraphToSystemList )
1536 linkDownMax = max( linkDownGraphToSystemList )
1537 linkDownAvg = sum( linkDownGraphToSystemList ) / \
1538 len( linkDownGraphToSystemList )
1539 linkUpMin = min( linkUpGraphToSystemList )
1540 linkUpMax = max( linkUpGraphToSystemList )
1541 linkUpAvg = sum( linkUpGraphToSystemList ) / \
1542 len( linkUpGraphToSystemList )
1543 linkDownStdDev = \
1544 str( round( numpy.std( linkDownGraphToSystemList ), 1 ) )
1545 linkUpStdDev = \
1546 str( round( numpy.std( linkUpGraphToSystemList ), 1 ) )
andrewonlababb11c32014-11-04 15:03:24 -05001547
andrewonlab79244cc2015-01-26 01:11:49 -05001548 main.log.report( "Link down latency " +
1549 "Avg: " + str( linkDownAvg ) + " ms " +
1550 "Std Deviation: " + linkDownStdDev + " ms" )
1551 main.log.report( "Link up latency " +
1552 "Avg: " + str( linkUpAvg ) + " ms " +
1553 "Std Deviation: " + linkUpStdDev + " ms" )
andrewonlab4e124482014-11-04 13:37:25 -05001554
andrewonlab79244cc2015-01-26 01:11:49 -05001555 utilities.assert_equals(
1556 expect=main.TRUE,
1557 actual=assertion,
1558 onpass="Link discovery latency calculation successful",
1559 onfail="Link discovery latency case failed" )
andrewonlab8790abb2014-11-06 13:51:54 -05001560
andrewonlab79244cc2015-01-26 01:11:49 -05001561 def CASE5( self, main ):
1562 """
andrewonlabb54b85b2014-10-28 18:43:57 -04001563 100 Switch discovery latency
1564
1565 Important:
andrewonlab79244cc2015-01-26 01:11:49 -05001566 This test case can be potentially dangerous if
andrewonlab16ce4852014-10-30 13:41:09 -04001567 your machine has previously set iptables rules.
1568 One of the steps of the test case will flush
1569 all existing iptables rules.
andrewonlab8790abb2014-11-06 13:51:54 -05001570 Note:
andrewonlab79244cc2015-01-26 01:11:49 -05001571 You can specify the number of switches in the
andrewonlab8790abb2014-11-06 13:51:54 -05001572 params file to adjust the switch discovery size
andrewonlab79244cc2015-01-26 01:11:49 -05001573 ( and specify the corresponding topology in Mininet1
1574 .topo file )
1575 """
andrewonlabb54b85b2014-10-28 18:43:57 -04001576 import time
1577 import subprocess
1578 import os
1579 import requests
1580 import json
1581
andrewonlab79244cc2015-01-26 01:11:49 -05001582 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1583 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1584 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1585 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
1586 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlabb54b85b2014-10-28 18:43:57 -04001587
andrewonlab79244cc2015-01-26 01:11:49 -05001588 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab16ce4852014-10-30 13:41:09 -04001589
andrewonlab79244cc2015-01-26 01:11:49 -05001590 # Number of iterations of case
1591 numIter = main.params[ 'TEST' ][ 'numIter' ]
1592 numSw = main.params[ 'TEST' ][ 'numSwitch' ]
andrewonlab58f7d702014-11-07 13:21:19 -05001593
andrewonlab79244cc2015-01-26 01:11:49 -05001594 # Timestamp 'keys' for json metrics output.
1595 # These are subject to change, hence moved into params
1596 deviceTimestamp = main.params[ 'JSON' ][ 'deviceTimestamp' ]
1597 graphTimestamp = main.params[ 'JSON' ][ 'graphTimestamp' ]
andrewonlabe5bcef92014-11-06 17:53:20 -05001598
andrewonlab79244cc2015-01-26 01:11:49 -05001599 debugMode = main.params[ 'TEST' ][ 'debugMode' ]
andrewonlab53b641c2014-10-31 19:44:44 -04001600
andrewonlab79244cc2015-01-26 01:11:49 -05001601 localTime = time.strftime( '%X' )
1602 localTime = localTime.replace( "/", "" )
1603 localTime = localTime.replace( " ", "_" )
1604 localTime = localTime.replace( ":", "" )
1605 if debugMode == 'on':
1606 main.ONOS1.tsharkPcap( "eth0",
1607 "/tmp/100_sw_lat_pcap_" + localTime )
andrewonlabb54b85b2014-10-28 18:43:57 -04001608
andrewonlab79244cc2015-01-26 01:11:49 -05001609 # Threshold for this test case
1610 swDiscThresholdStr = main.params[ 'TEST' ][ 'swDisc100Threshold' ]
1611 swDiscThresholdObj = swDiscThresholdStr.split( "," )
1612 swDiscThresholdMin = int( swDiscThresholdObj[ 0 ] )
1613 swDiscThresholdMax = int( swDiscThresholdObj[ 1 ] )
andrewonlabe5bcef92014-11-06 17:53:20 -05001614
andrewonlab79244cc2015-01-26 01:11:49 -05001615 tsharkOfpOutput = "/tmp/tshark_ofp_" + numSw + "sw.txt"
1616 tsharkTcpOutput = "/tmp/tshark_tcp_" + numSw + "sw.txt"
andrewonlabb54b85b2014-10-28 18:43:57 -04001617
andrewonlab79244cc2015-01-26 01:11:49 -05001618 tsharkOfpResultList = []
1619 tsharkTcpResultList = []
1620
1621 swDiscoveryLatList = []
1622
1623 main.case( numSw + " Switch discovery latency" )
1624 main.step( "Assigning all switches to ONOS1" )
1625 for i in range( 1, int( numSw ) + 1 ):
1626 main.Mininet1.assignSwController(
1627 sw=str( i ),
1628 ip1=ONOS1Ip,
1629 port1=defaultSwPort )
1630
1631 # Ensure that nodes are configured with ptpd
1632 # Just a warning message
1633 main.log.info( "Please check ptpd configuration to ensure" +
1634 " All nodes' system times are in sync" )
1635 time.sleep( 5 )
1636
1637 for i in range( 0, int( numIter ) ):
1638
1639 main.step( "Set iptables rule to block incoming sw connections" )
1640 # Set iptables rule to block incoming switch connections
1641 # The rule description is as follows:
andrewonlab53b641c2014-10-31 19:44:44 -04001642 # Append to INPUT rule,
1643 # behavior DROP that matches following:
1644 # * packet type: tcp
andrewonlab79244cc2015-01-26 01:11:49 -05001645 # * source IP: MN1Ip
andrewonlab53b641c2014-10-31 19:44:44 -04001646 # * destination PORT: 6633
andrewonlabb54b85b2014-10-28 18:43:57 -04001647 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001648 "sudo iptables -A INPUT -p tcp -s " + MN1Ip +
1649 " --dport " + defaultSwPort + " -j DROP" )
1650 main.ONOS1.handle.expect( "\$" )
1651 # Append to OUTPUT rule,
andrewonlab53b641c2014-10-31 19:44:44 -04001652 # behavior DROP that matches following:
1653 # * packet type: tcp
andrewonlab79244cc2015-01-26 01:11:49 -05001654 # * source IP: MN1Ip
andrewonlab53b641c2014-10-31 19:44:44 -04001655 # * destination PORT: 6633
1656 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001657 "sudo iptables -A OUTPUT -p tcp -s " + MN1Ip +
1658 " --dport " + defaultSwPort + " -j DROP" )
1659 main.ONOS1.handle.expect( "\$" )
1660 # Give time to allow rule to take effect
1661 # NOTE: Sleep period may need to be configured
andrewonlab8790abb2014-11-06 13:51:54 -05001662 # based on the number of switches in the topology
andrewonlab79244cc2015-01-26 01:11:49 -05001663 main.log.info( "Please wait for switch connection to " +
1664 "time out" )
1665 time.sleep( 60 )
andrewonlabb54b85b2014-10-28 18:43:57 -04001666
andrewonlab79244cc2015-01-26 01:11:49 -05001667 # Gather vendor OFP with tshark
1668 main.ONOS1.tsharkGrep( "OFP 86 Vendor",
1669 tsharkOfpOutput )
1670 main.ONOS1.tsharkGrep( "TCP 74 ",
1671 tsharkTcpOutput )
1672
1673 # NOTE: Remove all iptables rule quickly ( flush )
1674 # Before removal, obtain TestON timestamp at which
andrewonlab16ce4852014-10-30 13:41:09 -04001675 # removal took place
andrewonlab79244cc2015-01-26 01:11:49 -05001676 # ( ensuring nodes are configured via ptp )
andrewonlabb54b85b2014-10-28 18:43:57 -04001677 # sudo iptables -F
andrewonlab79244cc2015-01-26 01:11:49 -05001678
1679 t0System = time.time() * 1000
andrewonlab16ce4852014-10-30 13:41:09 -04001680 main.ONOS1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001681 "sudo iptables -F" )
andrewonlabb54b85b2014-10-28 18:43:57 -04001682
andrewonlab79244cc2015-01-26 01:11:49 -05001683 # Counter to track loop count
1684 counterLoop = 0
1685 counterAvail1 = 0
1686 counterAvail2 = 0
1687 counterAvail3 = 0
1688 onos1Dev = False
1689 onos2Dev = False
1690 onos3Dev = False
1691 while counterLoop < 60:
1692 # Continue to check devices for all device
1693 # availability. When all devices in all 3
1694 # ONOS instances indicate that devices are available
1695 # obtain graph event timestamp for t1.
1696 deviceStrObj1 = main.ONOS1cli.devices()
1697 deviceStrObj2 = main.ONOS2cli.devices()
1698 deviceStrObj3 = main.ONOS3cli.devices()
andrewonlab16ce4852014-10-30 13:41:09 -04001699
andrewonlab79244cc2015-01-26 01:11:49 -05001700 deviceJson1 = json.loads( deviceStrObj1 )
1701 deviceJson2 = json.loads( deviceStrObj2 )
1702 deviceJson3 = json.loads( deviceStrObj3 )
1703
1704 for device1 in deviceJson1:
1705 if device1[ 'available' ]:
1706 counterAvail1 += 1
1707 if counterAvail1 == int( numSw ):
1708 onos1Dev = True
1709 main.log.info( "All devices have been " +
1710 "discovered on ONOS1" )
andrewonlab16ce4852014-10-30 13:41:09 -04001711 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001712 counterAvail1 = 0
1713 for device2 in deviceJson2:
1714 if device2[ 'available' ]:
1715 counterAvail2 += 1
1716 if counterAvail2 == int( numSw ):
1717 onos2Dev = True
1718 main.log.info( "All devices have been " +
1719 "discovered on ONOS2" )
andrewonlab16ce4852014-10-30 13:41:09 -04001720 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001721 counterAvail2 = 0
1722 for device3 in deviceJson3:
1723 if device3[ 'available' ]:
1724 counterAvail3 += 1
1725 if counterAvail3 == int( numSw ):
1726 onos3Dev = True
1727 main.log.info( "All devices have been " +
1728 "discovered on ONOS3" )
andrewonlab16ce4852014-10-30 13:41:09 -04001729 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001730 counterAvail3 = 0
andrewonlab16ce4852014-10-30 13:41:09 -04001731
andrewonlab79244cc2015-01-26 01:11:49 -05001732 if onos1Dev and onos2Dev and onos3Dev:
1733 main.log.info( "All devices have been discovered " +
1734 "on all ONOS instances" )
1735 jsonStrTopologyMetrics1 =\
1736 main.ONOS1cli.topologyEventsMetrics()
1737 jsonStrTopologyMetrics2 =\
1738 main.ONOS2cli.topologyEventsMetrics()
1739 jsonStrTopologyMetrics3 =\
1740 main.ONOS3cli.topologyEventsMetrics()
andrewonlab16ce4852014-10-30 13:41:09 -04001741
andrewonlab79244cc2015-01-26 01:11:49 -05001742 # Exit while loop if all devices discovered
1743 break
andrewonlab16ce4852014-10-30 13:41:09 -04001744
andrewonlab79244cc2015-01-26 01:11:49 -05001745 counterLoop += 1
1746 # Give some time in between CLI calls
1747 #( will not affect measurement )
1748 time.sleep( 3 )
andrewonlab16ce4852014-10-30 13:41:09 -04001749
andrewonlab79244cc2015-01-26 01:11:49 -05001750 main.ONOS1.tsharkStop()
andrewonlab53b641c2014-10-31 19:44:44 -04001751
andrewonlab79244cc2015-01-26 01:11:49 -05001752 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
1753 tsharkOfpOutput + " /tmp/" )
1754 os.system( "scp " + ONOSUser + "@" + ONOS1Ip + ":" +
1755 tsharkTcpOutput + " /tmp/" )
andrewonlab16ce4852014-10-30 13:41:09 -04001756
andrewonlab79244cc2015-01-26 01:11:49 -05001757 # TODO: Automate OFP output analysis
1758 # Debug mode - print out packets captured at runtime
1759 if debugMode == 'on':
1760 ofpFile = open( tsharkOfpOutput, 'r' )
1761 main.log.info( "Tshark OFP Vendor output: " )
1762 for line in ofpFile:
1763 tsharkOfpResultList.append( line )
1764 main.log.info( line )
1765 ofpFile.close()
andrewonlab16ce4852014-10-30 13:41:09 -04001766
andrewonlab79244cc2015-01-26 01:11:49 -05001767 tcpFile = open( tsharkTcpOutput, 'r' )
1768 main.log.info( "Tshark TCP 74 output: " )
1769 for line in tcpFile:
1770 tsharkTcpResultList.append( line )
1771 main.log.info( line )
1772 tcpFile.close()
andrewonlab16ce4852014-10-30 13:41:09 -04001773
andrewonlab79244cc2015-01-26 01:11:49 -05001774 jsonObj1 = json.loads( jsonStrTopologyMetrics1 )
1775 jsonObj2 = json.loads( jsonStrTopologyMetrics2 )
1776 jsonObj3 = json.loads( jsonStrTopologyMetrics3 )
1777
1778 graphTimestamp1 = \
1779 jsonObj1[ graphTimestamp ][ 'value' ]
1780 graphTimestamp2 = \
1781 jsonObj2[ graphTimestamp ][ 'value' ]
1782 graphTimestamp3 = \
1783 jsonObj3[ graphTimestamp ][ 'value' ]
1784
1785 graphLat1 = int( graphTimestamp1 ) - int( t0System )
1786 graphLat2 = int( graphTimestamp2 ) - int( t0System )
1787 graphLat3 = int( graphTimestamp3 ) - int( t0System )
1788
1789 avgGraphLat = \
1790 ( int( graphLat1 ) +
1791 int( graphLat2 ) +
1792 int( graphLat3 ) ) / 3
1793
1794 if avgGraphLat > swDiscThresholdMin \
1795 and avgGraphLat < swDiscThresholdMax:
1796 swDiscoveryLatList.append(
1797 avgGraphLat )
andrewonlabe5bcef92014-11-06 17:53:20 -05001798 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001799 main.log.info( "100 Switch discovery latency " +
1800 "exceeded the threshold." )
andrewonlab16ce4852014-10-30 13:41:09 -04001801
andrewonlab79244cc2015-01-26 01:11:49 -05001802 # END ITERATION FOR LOOP
andrewonlab16ce4852014-10-30 13:41:09 -04001803
andrewonlab79244cc2015-01-26 01:11:49 -05001804 swLatMin = min( swDiscoveryLatList )
1805 swLatMax = max( swDiscoveryLatList )
1806 swLatAvg = sum( swDiscoveryLatList ) /\
1807 len( swDiscoveryLatList )
andrewonlab16ce4852014-10-30 13:41:09 -04001808
andrewonlab79244cc2015-01-26 01:11:49 -05001809 main.log.report( "100 Switch discovery lat " +
1810 "Min: " + str( swLatMin ) + " ms" +
1811 "Max: " + str( swLatMax ) + " ms" +
1812 "Avg: " + str( swLatAvg ) + " ms" )
1813
1814 def CASE6( self, main ):
1815 """
andrewonlaba57a3042015-01-23 13:53:05 -05001816 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -05001817 """
andrewonlaba57a3042015-01-23 13:53:05 -05001818 import time
andrewonlaba57a3042015-01-23 13:53:05 -05001819
andrewonlab79244cc2015-01-26 01:11:49 -05001820 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1821 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1822 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1823 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
1824 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
1825 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
1826 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001827
andrewonlab79244cc2015-01-26 01:11:49 -05001828 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001829
andrewonlab79244cc2015-01-26 01:11:49 -05001830 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001831
andrewonlab79244cc2015-01-26 01:11:49 -05001832 # Cluster size increased everytime the case is defined
1833 clusterCount += 2
andrewonlaba57a3042015-01-23 13:53:05 -05001834
andrewonlab79244cc2015-01-26 01:11:49 -05001835 main.log.report( "Increasing cluster size to " +
1836 str( clusterCount ) )
andrewonlaba57a3042015-01-23 13:53:05 -05001837
andrewonlab79244cc2015-01-26 01:11:49 -05001838 installResult = main.FALSE
1839 if clusterCount == 3:
1840 main.log.info( "Installing nodes 2 and 3" )
1841 node2Result = \
1842 main.ONOSbench.onosInstall( node=ONOS2Ip )
1843 node3Result = \
1844 main.ONOSbench.onosInstall( node=ONOS3Ip )
1845 installResult = node2Result and node3Result
andrewonlaba57a3042015-01-23 13:53:05 -05001846
andrewonlab79244cc2015-01-26 01:11:49 -05001847 time.sleep( 5 )
andrewonlaba57a3042015-01-23 13:53:05 -05001848
andrewonlab79244cc2015-01-26 01:11:49 -05001849 main.ONOS2cli.startOnosCli( ONOS2Ip )
1850 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlaba57a3042015-01-23 13:53:05 -05001851
andrewonlab79244cc2015-01-26 01:11:49 -05001852 elif clusterCount == 5:
1853 main.log.info( "Installing nodes 4 and 5" )
1854 node4Result = \
1855 main.ONOSbench.onosInstall( node=ONOS4Ip )
1856 node5Result = \
1857 main.ONOSbench.onosInstall( node=ONOS5Ip )
1858 installResult = node4Result and node5Result
andrewonlaba57a3042015-01-23 13:53:05 -05001859
andrewonlab79244cc2015-01-26 01:11:49 -05001860 time.sleep( 5 )
andrewonlaba57a3042015-01-23 13:53:05 -05001861
andrewonlab79244cc2015-01-26 01:11:49 -05001862 main.ONOS4cli.startOnosCli( ONOS4Ip )
1863 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlaba57a3042015-01-23 13:53:05 -05001864
andrewonlab79244cc2015-01-26 01:11:49 -05001865 elif clusterCount == 7:
andrewonlab67630692015-01-29 20:16:01 -05001866 main.log.info( "Installing nodes 6 and 7" )
andrewonlab79244cc2015-01-26 01:11:49 -05001867 node6Result = \
1868 main.ONOSbench.onosInstall( node=ONOS6Ip )
1869 node7Result = \
1870 main.ONOSbench.onosInstall( node=ONOS7Ip )
1871 installResult = node6Result and node7Result
andrewonlaba57a3042015-01-23 13:53:05 -05001872
andrewonlab79244cc2015-01-26 01:11:49 -05001873 time.sleep( 5 )
1874
1875 main.ONOS6cli.startOnosCli( ONOS6Ip )
1876 main.ONOS7cli.startOnosCli( ONOS7Ip )