summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/helper-scripts/openstackrapid/rapid.py
blob: 1a0ea41ce05fe57ca348d2070e9e9174b43bbc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
#!/usr/bin/python

##
## Copyright (c) 2010-2017 Intel Corporation
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##

import sys
import time
import subprocess
import getopt
from prox_ctrl import prox_ctrl

version="17.04.19"
stack = "rapidTestEnv" #Default string for stack
yaml = "rapid.yaml" #Default string for yaml file
key = "prox" # This is also the default in the yaml file....
flavor = "prox_flavor" # This is also the default in the yaml file....
image = "rapidVM" # This is also the default in the yaml file....
image_file = "rapidVM.qcow2"
network = "dpdk-network" # This is also the default in the yaml file....
subnet = "dpdk-subnet" #Hardcoded at this moment

def usage():
	print("usage: rapid       [--version] [-v]")
	print("                   [--stack STACK_NAME]")
	print("                   [--yaml YAML_FILE]")
	print("                   [--key KEY_NAME]")
	print("                   [--flavor FLAVOR_NAME]")
	print("                   [--image IMAGE_NAME]")
	print("                   [--image_file IMAGE_FILE]")
	print("                   [--network NETWORK]")
	print("                   [-h] [--help]")
	print("")
	print("Command-line interface to RAPID")
	print("")
	print("optional arguments:")
	print("  -v,  --version           Show program's version number and exit")
	print("  --stack STACK_NAME       Specify a name for the heat stack. Default is rapidTestEnv.")
	print("  --yaml YAML_FILE         Specify the yaml file to be used. Default is rapid.yaml.")
	print("  --key KEY_NAME           Specify the key to be used. Default is prox.")
	print("  --flavor FLAVOR_NAME     Specify the flavor to be used. Default is prox_flavor.")
	print("  --image IMAGE_NAME       Specify the image to be used. Default is rapidVM.")
	print("  --image_file IMAGE_FILE  Specify the image qcow2 file to be used. Default is rapidVM.qcow2.")
	print("  --network NETWORK        Specify the network name to be used for the dataplane. Default is dpdk-network.")
	print("  -h, --help               Show help message and exit.")
	print("")
	print("To delete the rapid stack, type the following command")
	print("   openstack stack delete --yes --wait DPTestEnv")
	print("Note that rapidTestEnv is the default stack name. Replace with STACK_NAME if needed")

try:
	opts, args = getopt.getopt(sys.argv[1:], "vh", ["version","help", "yaml=","stack=","key=","flavor=","image=","network="])
except getopt.GetoptError as err:
	print("===========================================")
	print str(err)
	print("===========================================")
	usage()
	sys.exit(2)
if args:
	usage()
	sys.exit(2)
for opt, arg in opts:
	if opt in ("-h", "--help"):
		usage()
		sys.exit()
	if opt in ("-v", "--version"):
		print("Rapid Automated Performance Indication for Dataplane "+version)
		sys.exit()
	if opt in ("--stack"):
		stack = arg
		print ("Using '"+stack+"' as name for the stack")
	elif opt in ("--yaml"):
		yaml = arg
		print ("Using stack: "+yaml)
	elif opt in ("--key"):
		key = arg
		print ("Using key: "+key)
	elif opt in ("--flavor"):
		flavor = arg
		print ("Using flavor: "+flavor)
	elif opt in ("--image"):
		image = arg
		print ("Using image: "+image)
	elif opt in ("--image_file"):
		image_file = arg
		print ("Using qcow2 file: "+image_file)
	elif opt in ("--network"):
		network = arg
		print ("Using network: "+ network)

print("Checking image: "+image)
cmd = 'openstack image show '+image+' |grep "status " | tr -s " " | cut -d" " -f 4'
ImageExist = subprocess.check_output(cmd , shell=True).strip()
if ImageExist == 'active':
	print("Image already available")
else:
	print('Creating image ...')
	cmd = 'openstack image create --disk-format qcow2 --container-format bare --public --file ./'+image_file+ ' ' +image+' |grep "status " | tr -s " " | cut -d" " -f 4'
	ImageExist = subprocess.check_output(cmd , shell=True).strip()
	if ImageExist == 'active':
		print('Image created and active')
		cmd = 'openstack image set --property hw_vif_multiqueue_enabled="true" ' +image
		subprocess.check_call(cmd , shell=True)
	else :
		raise Exception("Failed to create image")

print("Checking key: "+key)
cmd = 'openstack keypair show '+key+' |grep "name " | tr -s " " | cut -d" " -f 4'
KeyExist = subprocess.check_output(cmd , shell=True).strip()
if KeyExist == key:
	print("Key already installed")
else:
	print('Creating key ...')
	cmd = 'openstack keypair create '+ key + '>' +key+'.pem'
	subprocess.check_call(cmd , shell=True)
	cmd = 'chmod 600 ' +key+'.pem'
	subprocess.check_call(cmd , shell=True)
	cmd = 'openstack keypair show '+key+' |grep "name " | tr -s " " | cut -d" " -f 4'
	KeyExist = subprocess.check_output(cmd , shell=True).strip()
	if KeyExist == key:
		print("Key created")
	else :
		raise Exception("Failed to create key: " + key)

print("Checking flavor: "+flavor)
cmd = 'openstack flavor show '+flavor+' |grep "name " | tr -s " " | cut -d" " -f 4'
FlavorExist = subprocess.check_output(cmd , shell=True).strip()
if FlavorExist == flavor:
	print("Flavor already installed")
else:
	print('Creating flavor ...')
	cmd = 'openstack flavor create '+flavor+' --ram 8192 --disk 80 --vcpus 4 |grep "name " | tr -s " " | cut -d" " -f 4'
	FlavorExist = subprocess.check_output(cmd , shell=True).strip()
	if FlavorExist == flavor:
		cmd = 'openstack flavor set '+ flavor +' --property hw:mem_page_size="large" --property hw:cpu_policy="dedicated" --property hw:cpu_threads_policy="isolate"'
		subprocess.check_call(cmd , shell=True)
		print("Flavor created")
	else :
		raise Exception("Failed to create flavor: " + flavor)

print("Checking network: "+network)
cmd = 'openstack network show '+network+' |grep "status " | tr -s " " | cut -d" " -f 4'
NetworkExist = subprocess.check_output(cmd , shell=True).strip()
if NetworkExist == 'ACTIVE':
	print("Network already active")
else:
	print('Creating network ...')
	cmd = 'openstack network create '+network+' |grep "status " | tr -s " " | cut -d" " -f 4'
	NetworkExist = subprocess.check_output(cmd , shell=True).strip()
	if NetworkExist == 'ACTIVE':
		print("Network created")
	else :
		raise Exception("Failed to create network: " + network)

print("Checking subnet: "+subnet)
cmd = 'neutron subnet-show '+ subnet+' |grep "name " | tr -s " " | cut -d" " -f 4'
SubnetExist = subprocess.check_output(cmd , shell=True).strip()
if SubnetExist == subnet:
	print("Subnet already exists")
else:
	print('Creating subnet ...')
	cmd = 'neutron subnet-create --name '+ subnet+ ' ' +network+' 10.10.10.0/24 |grep "name " | tr -s " " | cut -d" " -f 4'
	SubnetExist = subprocess.check_output(cmd , shell=True).strip()
	if SubnetExist == subnet:
		print("Subnet created")
	else :
		raise Exception("Failed to create subnet: " + subnet)

print("Checking Stack: "+stack)
cmd = 'openstack stack show '+stack+' |grep "stack_status " | tr -s " " | cut -d" " -f 4'
StackRunning = subprocess.check_output(cmd , shell=True).strip()
if StackRunning == '':
	print('Creating Stack ...')
	cmd = 'openstack stack create -t '+ yaml +  ' --parameter flavor="'+flavor  +'" --parameter key="'+ key + '" --parameter image="'+image  + '" --parameter dpdk_network="'+network+'" --wait '+stack +' |grep "stack_status " | tr -s " " | cut -d" " -f 4'
	StackRunning = subprocess.check_output(cmd , shell=True).strip()
if StackRunning != 'CREATE_COMPLETE':
	raise Exception("Failed to create stack")

print('Stack running')
genName=stack+'-gen'
sutName=stack+'-sut'
cmd = 'nova list | grep  '+ genName +' | tr -s " " | cut -d " " -f 4'
genVMName = subprocess.check_output(cmd , shell=True).strip()
print('Generator: '+ genVMName)
cmd = 'nova list | grep  '+ sutName +' | tr -s " " | cut -d " " -f 4'
sutVMName = subprocess.check_output(cmd , shell=True).strip()
print('SUT:       '+ sutVMName)
cmd='nova show ' + genVMName + ' | grep "dpdk-network" | tr -s " " | cut -d" " -f 5'
genDPIP = subprocess.check_output(cmd , shell=True).strip()
cmd='nova show ' + genVMName + ' | grep "admin_internal_net" | tr -s " " | cut -d" " -f 6'
genAdminIP = subprocess.check_output(cmd , shell=True).strip()
cmd='nova show ' + sutVMName + ' | grep "dpdk-network" | tr -s " " | cut -d" " -f 5'
sutDPIP = subprocess.check_output(cmd , shell=True).strip()
cmd='nova show ' + sutVMName + ' | grep "admin_internal_net" | tr -s " " | cut -d" " -f 6'
sutAdminIP = subprocess.check_output(cmd , shell=True).strip()

#========================================================================
def connect_socket(client):
	attempts = 1
	print("Trying to connect to PROX (just launched) on %s, attempt: %d"
			% (client.ip(), attempts))
	sock = None
	while True:
		sock = client.prox_sock()
		if sock is not None:
			break
		attempts += 1
		if attempts > 20:
			raise Exception("Failed to connect to PROX on %s after %d attempts"
					% (client.ip(), attempts))
		time.sleep(10)
		print("Trying to connect to PROX (just launched) on %s, attempt: %d"
				% (client.ip(), attempts))
	print("Connected to PROX on %s" % client.ip())
	return sock

def connect_client(client):
	attempts = 1
	print ("Trying to connect to VM which was just launched on %s, attempt: %d"
			% (client.ip(), attempts))
	while True:
		try:
			client.connect()
			break
		except RuntimeWarning, ex:
			attempts += 1
			if attempts > 20:
				raise Exception("Failed to connect to VM after %d attempts:\n%s"
						% (attempts, ex))
			time.sleep(15)
			print ("Trying to connect to VM which was just launched on %s, attempt: %d"
					% (client.ip(), attempts))
	print("Connected to VM on %s" % client.ip())


def run_testA():
	global genclient
	global sutclient
	ip = genDPIP.split('.')
	hexgenDPIP=hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2)
	ip = sutDPIP.split('.')
	hexsutDPIP=hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2)
	with open("parameters.lua", "w") as f:
		f.write('gen_hex_ip="'+hexgenDPIP+'"\n')
		f.write('sut_hex_ip="'+hexsutDPIP+'"\n')
		f.write('gen_ip="'+genDPIP+'"\n')
		f.write('sut_ip="'+sutDPIP+'"\n')
		f.close
	genclient.scp_put('./gen.cfg', '/root/gen.cfg')
	sutclient.scp_put('./sut.cfg', '/root/sut.cfg')
	genclient.scp_put('./parameters.lua', '/root/parameters.lua')
	sutclient.scp_put('./parameters.lua', '/root/parameters.lua')
	print("Config files copied")
	cmd = '/root/prox/build/prox -e -t -o cli -f /root/gen.cfg'
	genclient.fork_cmd(cmd, 'PROX GEN')
	cmd = '/root/prox/build/prox -t -o cli -f /root/sut.cfg'
	sutclient.fork_cmd(cmd, 'PROX SUT')
	gensock = connect_socket(genclient)
	sutsock = connect_socket(sutclient)
	new_speed = 100
	attempts = 0
	cores = [1,2]
	gencores = [1]
	gensock.reset_stats()
	sutsock.reset_stats()
	gensock.start([2])
	print("+---------------------------------------------------------------------------------------------------------+")
	print("| Generator is sending UDP (1 flow) packets (64 bytes) to SUT. SUT sends packets back                     |")
	print("+------+-----------------+----------------+----------------+----------------+----------------+------------+")
	print("| Test | Speed requested | Req to Generate|  Sent by Gen   | Forward by SUT |  Rec. by Gen   | Result     |")
	print("+------+-----------------+----------------+----------------+----------------+----------------+------------+")
	while (new_speed > 0.1):
		attempts += 1
		# Start generating packets at requested speed (in % of a 10Gb/s link)
		gensock.speed(new_speed, gencores)
		gensock.start(gencores)
		time.sleep(1)
		# Get statistics now that the generation is stable and NO ARP messages any more
		old_sut_rx, old_sut_tx, old_sut_drop, old_sut_tsc, sut_tsc_hz = sutsock.core_stats([1])
		old_rx, old_tx, old_drop, old_tsc, tsc_hz = gensock.core_stats(cores)
		time.sleep(10)
		# Get statistics after some execution time
		new_rx, new_tx, new_drop, new_tsc, tsc_hz = gensock.core_stats(cores)
		new_sut_rx, new_sut_tx, new_sut_drop, new_sut_tsc, sut_tsc_hz = sutsock.core_stats([1])
		time.sleep(1)
		# Stop generating
		gensock.stop(gencores)
		drop = new_drop-old_drop # drop is all packets dropped by all tasks. This includes packets dropped at the generator task + packets dropped by the nop task. In steady state, this equals to the number of packets received by this VM
		rx = new_rx - old_rx     # rx is all packets received by the nop task = all packets received in the gen VM
		tx = new_tx - old_tx  	 # tx is all generated packets actually accepted by the interface
		tsc = new_tsc - old_tsc  # time difference between the 2 measurements, expressed in cycles.
		sut_rx = new_sut_rx - old_sut_rx
		sut_tx = new_sut_tx - old_sut_tx
		sut_tsc = new_sut_tsc - old_sut_tsc
		if (tx == 0):
			raise Exception("TX = 0")
		drop_rate = round(((drop-rx) * 100.0)/(tx+drop-rx),1)
		pps_req_tx = round((tx+drop-rx)*tsc_hz*1.0/(tsc*1000000),5)
		pps_tx = round(tx*tsc_hz*1.0/(tsc*1000000),5)
		pps_rx = round(rx*tsc_hz*1.0/(tsc*1000000),5)
		pps_sut_tx = round(sut_tx*sut_tsc_hz*1.0/(sut_tsc*1000000),5)
		if ((drop_rate) < 1):
			# This will stop the test when number of dropped packets is below a certain percentage
			print("+------+-----------------+----------------+----------------+----------------+----------------+------------+")
			print('|{:>5}'.format(str(attempts))+" | "+ '{:>14}'.format(str(new_speed)) + '% | '+ '{:>9}'.format(str(pps_req_tx))+' Mpps | '+ '{:>9}'.format(str(pps_tx)) +' Mpps | ' + '{:>9}'.format(str(pps_sut_tx)) +' Mpps | '+ '{:>9}'.format(str(pps_rx))+" Mpps | SUCCESS    |")
			print("+------+-----------------+----------------+----------------+----------------+----------------+------------+")
			break
		else:
			print('|{:>5}'.format(str(attempts))+" | "+ '{:>14}'.format(str(new_speed)) + '% | '+ '{:>9}'.format(str(pps_req_tx))+' Mpps | '+ '{:>9}'.format(str(pps_tx)) +' Mpps | ' + '{:>9}'.format(str(pps_sut_tx)) +' Mpps | '+ '{:>9}'.format(str(pps_rx))+" Mpps | FAILED     |")
		# Following calculates the ratio for the new speed to be applied
		# On the Y axis, we will find the ratio, a number between 0 and 1
		# On the x axis, we find the % of dropped packets, a number between 0 and 100
		# 2 lines are drawn and we take the minumun of these lines to calculate the ratio
		# One line goes through (0,y0) and (p,q)
		# The second line goes through (p,q) and (100,y100)
		y0=0.99
		y100=0.1
		p=15
		q=.9
		ratio = min((q-y0)/p*drop_rate+y0,(q-y100)/(p-100)*drop_rate+q-p*(q-y100)/(p-100))
		new_speed = (int(new_speed*ratio*100)+0.5)/100
	gensock.quit()
	sutsock.quit()
	time.sleep(2)
	print("")

def run_testB():
	global genclient
	global sutclient
	ip = genDPIP.split('.')
	hexgenDPIP=hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2)
	ip = sutDPIP.split('.')
	hexsutDPIP=hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2)
	with open("parameters.lua", "w") as f:
		f.write('gen_hex_ip="'+hexgenDPIP+'"\n')
		f.write('sut_hex_ip="'+hexsutDPIP+'"\n')
		f.write('gen_ip="'+genDPIP+'"\n')
		f.write('sut_ip="'+sutDPIP+'"\n')
		f.close
	genclient.scp_put('./gen.cfg', '/root/gen.cfg')
	sutclient.scp_put('./sut.cfg', '/root/sut.cfg')
	genclient.scp_put('./parameters.lua', '/root/parameters.lua')
	sutclient.scp_put('./parameters.lua', '/root/parameters.lua')
	print("Config files copied")
	cmd = '/root/prox/build/prox -e -t -o cli -f /root/gen.cfg'
	genclient.fork_cmd(cmd, 'PROX GEN')
	cmd = '/root/prox/build/prox -t -o cli -f /root/sut.cfg'
	sutclient.fork_cmd(cmd, 'PROX SUT')
	gensock = connect_socket(genclient)
	sutsock = connect_socket(sutclient)
	print("+----------------------------------------------------------------------------------------------+")
	print("| UDP, 64 bytes, different number of flows by randomizing SRC & DST UDP port                   |")
	print("+--------+-----------------+----------------+----------------+----------------+----------------+")
	print("| Flows  | Speed requested | Req to Generate|  Sent by Gen   | Forward by SUT |  Rec. by Gen   |")
	print("+--------+-----------------+----------------+----------------+----------------+----------------+")
	cores = [1,2]
	gencores = [1]
	gensock.start([2])
	new_speed = 100
	# To generate a desired number of flows, PROX will randomize the bits in source and destination ports, as specified by the bit masks in the flows variable. 
	flows={128:['0000000000000XXX','000000000000XXXX'],1024:['00000000000XXXXX','00000000000XXXXX'],8192:['0000000000XXXXXX','000000000XXXXXXX'],65535:['00000000XXXXXXXX','00000000XXXXXXXX'],524280:['0000000XXXXXXXXX','000000XXXXXXXXXX']}
	for flow_number in sorted(flows.iterkeys()):
		#new_speed = 100 Commented out: Not starting from 100% since we are trying more flows, so speed will not be higher than the speed achieved in previous loop
		attempts = 0
		gensock.reset_stats()
		sutsock.reset_stats()
		source_port,destination_port = flows[flow_number]
		gensock.set_random(gencores,0,34,source_port,2)
		gensock.set_random(gencores,0,36,destination_port,2)
		while (new_speed > 0.1):
			attempts += 1
			# Start generating packets at requested speed (in % of a 10Gb/s link)
			gensock.speed(new_speed, gencores)
			gensock.start(gencores)
			time.sleep(1)
			# Get statistics now that the generation is stable and NO ARP messages any more
			old_sut_rx, old_sut_tx, old_sut_drop, old_sut_tsc, sut_tsc_hz = sutsock.core_stats([1])
			old_rx, old_tx, old_drop, old_tsc, tsc_hz = gensock.core_stats(cores)
			time.sleep(10)
			# Get statistics after some execution time
			new_rx, new_tx, new_drop, new_tsc, tsc_hz = gensock.core_stats(cores)
			new_sut_rx, new_sut_tx, new_sut_drop, new_sut_tsc, sut_tsc_hz = sutsock.core_stats([1])
			time.sleep(1)
			# Stop generating
			gensock.stop(gencores)
			drop = new_drop-old_drop # drop is all packets dropped by all tasks. This includes packets dropped at the generator task + packets dropped by the nop task. In steady state, this equals to the number of packets received by this VM
			rx = new_rx - old_rx     # rx is all packets received by the nop task = all packets received in the gen VM
			tx = new_tx - old_tx  	 # tx is all generated packets actually accepted by the interface
			tsc = new_tsc - old_tsc  # time difference between the 2 measurements, expressed in cycles.
			sut_rx = new_sut_rx - old_sut_rx
			sut_tx = new_sut_tx - old_sut_tx
			sut_tsc = new_sut_tsc - old_sut_tsc
			if (tx == 0):
				raise Exception("TX = 0")
			drop_rate = round(((drop-rx) * 100.0)/(tx+drop-rx),1)
			pps_req_tx = round((tx+drop-rx)*tsc_hz*1.0/(tsc*1000000),5)
			pps_tx = round(tx*tsc_hz*1.0/(tsc*1000000),5)
			pps_rx = round(rx*tsc_hz*1.0/(tsc*1000000),5)
			pps_sut_tx = round(sut_tx*sut_tsc_hz*1.0/(sut_tsc*1000000),5)
			if ((drop_rate) < 1):
				# This will stop the test when number of dropped packets is below a certain percentage
				print('|{:>7}'.format(str(flow_number))+" | "+ '{:>14}'.format(str(new_speed)) + '% | '+ '{:>9}'.format(str(pps_req_tx))+' Mpps | '+ '{:>9}'.format(str(pps_tx)) +' Mpps | ' + '{:>9}'.format(str(pps_sut_tx)) +' Mpps | '+ '{:>9}'.format(str(pps_rx))+" Mpps |")
				print("+--------+-----------------+----------------+----------------+----------------+----------------+")
				break
			# Following calculates the ratio for the new speed to be applied
			# On the Y axis, we will find the ratio, a number between 0 and 1
			# On the x axis, we find the % of dropped packets, a number between 0 and 100
			# 2 lines are drawn and we take the minumun of these lines to calculate the ratio
			# One line goes through (0,y0) and (p,q)
			# The second line goes through (p,q) and (100,y100)
			y0=0.99
			y100=0.1
			p=15
			q=.9
			ratio = min((q-y0)/p*drop_rate+y0,(q-y100)/(p-100)*drop_rate+q-p*(q-y100)/(p-100))
			new_speed = (int(new_speed*ratio*100)+0.5)/100
	gensock.quit()
	sutsock.quit()
	time.sleep(2)
	print("")

#========================================================================
genclient = prox_ctrl(genAdminIP, key+'.pem')
connect_client(genclient)
sutclient = prox_ctrl(sutAdminIP, key+'.pem')
connect_client(sutclient)
#####################################################################################
run_testA()
run_testB()
#####################################################################################
genclient.close()
sutclient.close()