forked from chaudron/ovs_perf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovs_performance.py
executable file
·4433 lines (3605 loc) · 169 KB
/
ovs_performance.py
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
#
# Copyright 2017 "OVS Performance" Authors
#
# 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.
#
# Files name:
# ovs_performance.py
#
# Description:
# Simple script to run the OVS performance tests
#
# Author:
# Eelco Chaudron
#
# Initial Created:
# 17 January 2017
#
# Notes:
# - Install the spur python module
# dnf install python-spur
# - Install the XenaPythonLib from https://github.com/fleitner/XenaPythonLib
# cd XenaPythonLib/
# sudo python setup.py install
# - Install natsort and enum modules
# pip install natsort enum34
# - Install matplotlib
# dnf install python-matplotlib
# - Install latest Scapy
# pip install scapy
# - Install netaddr
# pip install netaddr
#
# Example:
#
#
# TODOs:
# - Add tunnel test cases (Geneve and VXLAN)
# - Add check after test to see all OF flows got packets (i.e. n_packets != 0)
# - Add option to stop trying more packet sizes once maximum performance
# of link is reached (i.e. two consecutive runs @ wire speed)
# - Add option to maximize traffic rate (PPS, and/or % based on port speed)
# - Add some VLAN test cases
# - Add a Bi-directional PVP test [phy0-vf0-VM-vf1-phy1]
# - Add option to run traffic part multiple(3) times to calculate deviation,
# and add error bars to the graphs
#
#
# Imports
#
import argparse
import csv
import datetime
import inspect
import os
import logging
import numpy as np
import re
import spur
import sys
import time
#
# Imports from simpel shell API
#
from dut_ssh_shell import DutSshShell
#
# Import general traffic_generator library
#
from traffic_generator_base import TrafficFlowType
from traffic_generator import TrafficGenerator, TrafficGeneratorType
#
# Imports from Matplot, by default disable the tk interface
#
import matplotlib
matplotlib.use('Agg')
#
# Imports from natural sort
#
from natsort import natsorted
#
# Imports from distutils
#
from distutils.version import StrictVersion
# In Python 2, raw_input() returns a string, and input() tries
# to run the input as a Python expression.
# Since getting a string was almost always what we wanted,
# Python 3 does that with input()
# The following line checks the Python version being used to
# stick to raw_input() for Python2 and input() for Python3
if sys.version_info[0] == 3:
raw_input = input
#
# Default configuration
#
DEFAULT_TESTER_TYPE = 'xena'
DEFAULT_TESTER_SERVER_ADDRESS = ''
DEFAULT_TESTER_INTERFACE = ''
DEFAULT_SECOND_TESTER_INTERFACE = ''
DEFAULT_DUT_ADDRESS = ''
DEFAULT_DUT_LOGIN_USER = 'root'
DEFAULT_DUT_LOGIN_PASSWORD = 'root'
DEFAULT_DUT_VM_ADDRESS = ''
DEFAULT_DUT_SECOND_VM_ADDRESS = ''
DEFAULT_DUT_VM_NIC_PCI_ADDRESS = ''
DEFAULT_DUT_VM_LOGIN_USER = 'root'
DEFAULT_DUT_VM_LOGIN_PASSWORD = 'root'
DEFAULT_PHYSICAL_INTERFACE = ''
DEFAULT_SECOND_PHYSICAL_INTERFACE = ''
DEFAULT_PACKET_LIST = '64, 128, 256, 512, 768, 1024, 1514'
DEFAULT_VIRTUAL_INTERFACE = ''
DEFAULT_SECOND_VIRTUAL_INTERFACE = ''
DEFAULT_RUN_TIME = 20
DEFAULT_STREAM_LIST = '10, 1000, 10000, 100000, 1000000'
DEFAULT_BRIDGE_NAME = 'ovs_pvp_br0'
DEFAULT_WARM_UP_TIMEOUT = 360
DEFAULT_DST_MAC_ADDRESS = '00:00:02:00:00:00'
DEFAULT_SRC_MAC_ADDRESS = '00:00:01:00:00:00'
#
# Run simple traffic test Virtual to Virtual
#
def test_v2v(nr_of_flows, packet_sizes):
v2v_tx_results = list()
v2v_rx_results = list()
cpu_results = list()
for packet_size in packet_sizes:
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2})] START".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size))
##################################################
lprint(" * Create OVS OpenFlow rules...")
create_ovs_of_rules(nr_of_flows,
of_interfaces[config.virtual_interface],
of_interfaces[config.second_virtual_interface])
##################################################
lprint(" * Start packet receiver on second VM...")
start_traffic_rx_on_vm(config.dut_second_vm_address,
config.dut_second_vm_nic_pci)
##################################################
lprint(" * Start CPU monitoring on DUT...")
start_cpu_monitoring()
##################################################
lprint(" * Start packet generation for {0} seconds...".format(config.run_time))
start_traffic_tx_on_vm(config.dut_vm_address,
nr_of_flows, packet_size)
time.sleep(config.run_time)
##################################################
lprint(" * Stop CPU monitoring on DUT...")
stop_cpu_monitoring()
##################################################
lprint(" * Stopping packet stream on VM1...")
stop_traffic_tx_on_vm(config.dut_vm_address)
##################################################
lprint(" * Stop packet receiver on VM2...")
stop_traffic_rx_on_vm(config.dut_second_vm_address)
##################################################
lprint(" * Gathering statistics...")
of_dump_port_to_logfile(config.bridge_name)
vm_pkts_sec = get_traffic_rx_stats_from_vm(config.dut_second_vm_address)
vm_tx_pkts_sec = get_traffic_tx_stats_from_vm(config.dut_vm_address)
lprint(" - Transmit rate on VM: {:,} pps".format(vm_tx_pkts_sec))
lprint(" ! Result, average: {:,} pps".format(vm_pkts_sec))
cpu_results.append(get_cpu_monitoring_stats())
v2v_tx_results.append(vm_tx_pkts_sec)
v2v_rx_results.append(vm_pkts_sec)
##################################################
lprint(" * Restoring state for next test...")
# dut_shell.dut_exec('sh -c "ovs-ofctl del-flows {0} && ovs-appctl dpctl/del-flows"'.\
# format(config.bridge_name),
# die_on_error=True)
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2})] END".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size))
flow_str = get_flow_type_short()
flow_file_str = get_flow_type_name()
create_multiple_graph(packet_sizes, {'Send Rate': v2v_tx_results,
'Receive Rate': v2v_rx_results},
"Packet size", "Packets/second",
"Virtual to Virtual with {} {} flows".format(nr_of_flows, flow_str),
"test_v2v_{}_{}".format(nr_of_flows, flow_file_str), None,
cpu_utilization={'Receive Rate': cpu_results})
create_multiple_graph(packet_sizes, {'Send Rate': v2v_tx_results,
'Receive Rate': v2v_rx_results},
"Packet size", "Packets/second",
"Virtual to Virtual with {} {} flows".format(nr_of_flows, flow_str),
"test_v2v_{}_{}_ref".format(nr_of_flows, flow_file_str),
[phy_speed], cpu_utilization={'Receive Rate': cpu_results})
return v2v_rx_results, cpu_results
#
# Calculate loss percentage
#
def calc_loss_percentage(results):
value = 100 - (float(results["total_rx_pkts"])
/ float(results["total_tx_pkts"])
* 100)
if value < 0:
value = 0
return value
#
# Get the PVP results for a single binary search iteration
#
def PVP_binary_search_single_run(test_value, **kwargs):
packet_size = kwargs.get("packet_size", 64)
nr_of_streams = kwargs.get("nr_of_streams", 10)
results = test_p2v2p_single_packet_size(nr_of_streams, packet_size,
decrease_rate=100 - test_value)
results["traffic_rate"] = test_value
lprint(" > Zero pkt loss: pkt {}, load {:.6f}%, miss {:.6f}%".
format(packet_size, test_value,
calc_loss_percentage(results)))
return results
#
# Run the NFV mobile tests for a binary search iteration
#
def PVP_binary_search_itteration_result(result_values, test_value, **kwargs):
return calc_loss_percentage(result_values[test_value])
#
# binary search to find the highest value where the results are less or equal
# to the required_result.
#
# It will return all the data sets returned by the run_test_function,
# and index which one is matching the above. -1 means it was not found!
#
def binary_search(min_value, max_value, required_result,
run_test_function,
get_results_function,
**kwargs):
step = kwargs.pop("bs_step", 1)
results = dict()
#
# Need values from max to min, but in low to high order
#
values = np.arange(max_value, min_value-min(min_value, step), -step)
values = values[::-1]
if len(values) <= 1:
return results, -1
#
# Here we do a binary like search until the min and max values are one
# apart. When this happens we closed in to the highest possible value to
# get the results, or if both are not matching we can not achieve the
# requested.
#
current_min = 0
current_max = len(values) - 1
while True:
if current_min == current_max - 1:
break
current_test = int(current_min + ((current_max - current_min) / 2))
results[values[current_test]] = run_test_function(values[current_test],
**kwargs)
result = get_results_function(results, values[current_test], **kwargs)
if result > required_result:
current_max = current_test
else:
current_min = current_test
if not values[current_max] in results:
results[values[current_max]] = run_test_function(values[current_max],
**kwargs)
if get_results_function(results, values[current_max],
**kwargs) <= required_result:
return results, values[current_max]
if not values[current_min] in results:
results[values[current_min]] = run_test_function(values[current_min],
**kwargs)
if get_results_function(results, values[current_min],
**kwargs) <= required_result:
return results, values[current_min]
return results, -1
#
# Run simple traffic test Physical to VM back to Physical
#
def test_p2v2p_single_packet_size(nr_of_flows, packet_size, **kwargs):
decrease_rate = kwargs.get("decrease_rate", 0)
assert (decrease_rate >= 0 or decrease_rate < 100)
decrease_rate *= 10000
results = dict()
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2}, rate={3:.2f}%)] START".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size, (1000000 - decrease_rate) / 10000))
##################################################
lprint(" * Create OVS OpenFlow rules...")
create_ovs_bidirectional_of_rules(nr_of_flows,
of_interfaces[config.physical_interface],
of_interfaces[config.virtual_interface])
##################################################
lprint(" * Initializing packet generation...")
tester.configure_traffic_stream(config.tester_interface,
get_traffic_generator_flow(),
nr_of_flows, packet_size,
traffic_dst_mac=config.dst_mac_address,
traffic_src_mac=config.src_mac_address,
percentage=1000000 - decrease_rate)
##################################################
if config.warm_up:
lprint(" * Doing flow table warm-up...")
start_vm_time = datetime.datetime.now()
start_traffic_loop_on_vm(config.dut_vm_address,
config.dut_vm_nic_pci)
tester.start_traffic(config.tester_interface)
warm_up_done = warm_up_verify(nr_of_flows * 2,
config.warm_up_timeout)
tester.stop_traffic(config.tester_interface)
if not warm_up_done and not config.warm_up_no_fail:
sys.exit(-1)
##################################################
lprint(" * Clear all statistics...")
tester.clear_statistics(config.tester_interface)
pp_tx_start, pp_tx_drop_start, pp_rx_start, pp_rx_drop_start \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])
vp_tx_start, vp_tx_drop_start, vp_rx_start, vp_rx_drop_start \
= get_of_port_packet_stats(of_interfaces[config.virtual_interface])
##################################################
if not config.warm_up:
lprint(" * Start packet receiver on VM...")
start_traffic_loop_on_vm(config.dut_vm_address,
config.dut_vm_nic_pci)
warm_up_time = 0
else:
# warm_up_time is the total time it takes from the start of the
# VM at warm-up till we would normally start the loop back VM.
# This values is used to remove warm-up statistics.
warm_up_time = int(np.ceil((datetime.datetime.now() -
start_vm_time).total_seconds()))
lprint(" * Determine warm op time, {} seconds...".
format(warm_up_time))
##################################################
lprint(" * Start CPU monitoring on DUT...")
start_cpu_monitoring()
##################################################
lprint(" * Start packet generation for {0} seconds...".format(config.run_time))
tester.start_traffic(config.tester_interface)
for i in range(1, config.run_time):
time.sleep(1)
tester.take_rx_statistics_snapshot(config.tester_interface)
##################################################
lprint(" * Stop CPU monitoring on DUT...")
stop_cpu_monitoring()
##################################################
lprint(" * Stopping packet stream...")
tester.stop_traffic(config.tester_interface)
time.sleep(1)
##################################################
lprint(" * Stop packet receiver on VM...")
stop_traffic_loop_on_vm(config.dut_vm_address)
##################################################
lprint(" * Gathering statistics...")
tester.take_statistics_snapshot(config.tester_interface)
full_tx_stats = tester.get_tx_statistics_snapshots(config.tester_interface)
full_rx_stats = tester.get_rx_statistics_snapshots(config.tester_interface)
slogger.debug(" full_tx_stats={}".format(full_tx_stats))
slogger.debug(" full_rx_stats={}".format(full_rx_stats))
pp_tx_end, pp_tx_drop_end, pp_rx_end, pp_rx_drop_end \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])
vp_tx_end, vp_tx_drop_end, vp_rx_end, vp_rx_drop_end \
= get_of_port_packet_stats(of_interfaces[config.virtual_interface])
pp_rx = pp_rx_end - pp_rx_start
pp_tx = pp_tx_end - pp_tx_start
pp_rx_drop = pp_rx_drop_end - pp_rx_drop_start
pp_tx_drop = pp_tx_drop_end - pp_tx_drop_start
vp_rx = vp_rx_end - vp_rx_start
vp_tx = vp_tx_end - vp_tx_start
vp_rx_drop = vp_rx_drop_end - vp_rx_drop_start
vp_tx_drop = vp_tx_drop_end - vp_tx_drop_start
vm_pkts_sec = get_traffic_rx_stats_from_vm(config.dut_vm_address,
skip_samples=warm_up_time)
packets_tx = full_tx_stats[sorted(full_tx_stats.keys())[-1]]['pt_total']['packets']
packets_rx = full_rx_stats[sorted(full_rx_stats.keys())[-1]]['pr_total']['packets']
lprint(" - Packets send by Tester : {:-20,}".format(packets_tx))
lprint(" - Packets received by physical: {:-20,} [Lost {:,}, Drop {:,}]".
format(pp_rx, packets_tx - pp_rx, pp_rx_drop))
lprint(" - Packets received by virtual : {:-20,} [Lost {:,}, Drop {:,}]".
format(vp_tx, pp_rx - vp_tx, vp_tx_drop))
lprint(" - Packets send by virtual : {:-20,} [Lost {:,}, Drop {:,}]".
format(vp_rx, vp_tx - vp_rx, vp_rx_drop))
lprint(" - Packets send by physical : {:-20,} [Lost {:,}, Drop {:,}]".
format(pp_tx, vp_rx - pp_tx, pp_tx_drop))
lprint(" - Packets received by Tester : {:-20,} [Lost {:,}]".
format(packets_rx, pp_tx - packets_rx))
lprint(" - Receive rate on VM: {:,} pps".format(vm_pkts_sec))
rx_pkts_sec = get_packets_per_second_from_traffic_generator_rx_stats(full_rx_stats)
lprint(" ! Result, average: {:,} pps".format(rx_pkts_sec))
##################################################
lprint(" * Restoring state for next test...")
tester.unconfigure_traffic_stream(config.tester_interface)
# dut_shell.dut_exec('sh -c "ovs-ofctl del-flows {0} && ovs-appctl dpctl/del-flows"'.\
# format(config.bridge_name),
# die_on_error=True)
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2})] END".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size))
results["cpu_stats"] = get_cpu_monitoring_stats()
results["rx_packets_second"] = rx_pkts_sec
results["total_tx_pkts"] = packets_tx
results["total_rx_pkts"] = packets_rx
return results
#
# Run simple traffic test Physical to VM back to Physical
#
def test_p2v2p(nr_of_flows, packet_sizes):
p2v2p_results = list()
cpu_results = list()
for packet_size in packet_sizes:
results = test_p2v2p_single_packet_size(nr_of_flows, packet_size,
decrease_rate=100 -
config.traffic_rate)
cpu_results.append(results["cpu_stats"])
p2v2p_results.append(results["rx_packets_second"])
create_single_graph(packet_sizes, p2v2p_results,
"Packet size", "Packets/second",
"Physical to Virtual back to Physical with {} {} "
"flows{}".format(nr_of_flows, get_flow_type_short(),
get_traffic_rate_str()),
"test_p2v2p_{}_{}".format(nr_of_flows,
get_flow_type_name()),
phy_speed,
cpu_utilization=cpu_results)
return p2v2p_results, cpu_results
#
# Run simple traffic test Physical to VM back to Physical
#
def test_p2v2p_zero_loss(stream_size_list, packet_size_list, **kwargs):
csv_handle = kwargs.pop("csv_handle", None)
zero_loss_step = kwargs.pop("zero_loss_step", 1)
flow_str = get_flow_type_short()
flow_file_str = get_flow_type_name()
test_results = dict()
for nr_of_streams in stream_size_list:
test_results[nr_of_streams] = dict()
for packet_size in packet_size_list:
results, index = binary_search(
1, 100, 0.00001,
PVP_binary_search_single_run,
PVP_binary_search_itteration_result,
bs_step=zero_loss_step,
packet_size=packet_size,
nr_of_streams=nr_of_streams)
for dump_index in natsorted(list(results.keys())):
result = results[dump_index]
lprint(
" > Results: load {:.6f}%, rate {} pps, miss {:.6f}%".
format(result["traffic_rate"],
result["rx_packets_second"],
calc_loss_percentage(result)))
if index >= 1:
test_results[nr_of_streams][packet_size] = \
results[index]
lprint(" ! Zero pkt loss @ pkt {}, load {:.6f}%, "
"miss {:.6f}%, rx rate {:,.0f} pps".
format(packet_size, index,
calc_loss_percentage(
results[index]),
test_results[nr_of_streams][packet_size]
["rx_packets_second"]))
else:
test_results[nr_of_streams][packet_size] = results[min(results)]
lprint(" ! Zero pkt loss for {} bytes, NOT reached!!".
format(packet_size))
pvp0_results, pvp0_cpu_results, pvp0_traffic_rate, pvp0_loss_rate \
= get_result_sets_from_zero_loss_results(test_results)
#
# Write the per flow size graphs
#
create_single_graph(
packet_size_list, pvp0_results[nr_of_streams],
"Packet size", "Packets/second",
"Physical to Virtual back to Physical Zero Loss "
"with {} {} flows".format(nr_of_streams, flow_str),
"test_p2v2p_zero_{}_{}".format(nr_of_streams, flow_file_str),
phy_speed,
cpu_utilization=pvp0_cpu_results[nr_of_streams],
zero_loss_traffic_rate=pvp0_traffic_rate[nr_of_streams],
zero_loss_loss_rate=pvp0_loss_rate[nr_of_streams]
)
#
# This might look like a wrong indentation, but we would like to update
# the graph every stream run so we have a graph in case of a failure.
#
create_multiple_graph(packet_size_list, pvp0_results,
"Packet size", "Packets/second",
"Physical to Virtual to Physical Zero Loss, {}".
format(flow_str),
"test_p2v2p_zero_all_{}".
format(flow_file_str),
None, cpu_utilization=pvp0_cpu_results)
create_multiple_graph(packet_size_list, pvp0_results,
"Packet size", "Packets/second",
"Physical to Virtual to Physical Zero Loss, {}".
format(flow_str),
"test_p2v2p_zero_all_{}_ref".
format(flow_file_str),
[phy_speed],
cpu_utilization=pvp0_cpu_results)
if csv_handle is not None:
csv_write_test_results(
csv_handle,
'Zero Loss Physical to Virtual to Physical test',
stream_size_list, packet_size_list,
pvp0_results, pvp0_cpu_results, loss_rate=pvp0_loss_rate,
traffic_rate=pvp0_traffic_rate)
#
# Run simple traffic test Physical to VM
#
def test_p2v(nr_of_flows, packet_sizes):
p2v_results = list()
cpu_results = list()
for packet_size in packet_sizes:
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2}, rate={3:.3f}%)]"
" START".format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size, config.traffic_rate))
##################################################
lprint(" * Create OVS OpenFlow rules...")
create_ovs_of_rules(nr_of_flows,
of_interfaces[config.physical_interface],
of_interfaces[config.virtual_interface])
##################################################
lprint(" * Initializing packet generation...")
tester.configure_traffic_stream(config.tester_interface,
get_traffic_generator_flow(),
nr_of_flows, packet_size,
traffic_dst_mac=config.dst_mac_address,
traffic_src_mac=config.src_mac_address,
percentage=config.traffic_rate * 10000)
##################################################
if config.warm_up:
lprint(" * Doing flow table warm-up...")
tester.start_traffic(config.tester_interface)
warm_up_done = warm_up_verify(nr_of_flows, config.warm_up_timeout)
tester.stop_traffic(config.tester_interface)
if not warm_up_done and not config.warm_up_no_fail:
sys.exit(-1)
##################################################
lprint(" * Clear all statistics...")
tester.clear_statistics(config.tester_interface)
pp_rx_start \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])[2]
vp_tx_start, vp_tx_drop_start \
= get_of_port_packet_stats(of_interfaces[config.virtual_interface])[0:2]
##################################################
lprint(" * Start packet receiver on VM...")
start_traffic_rx_on_vm(config.dut_vm_address,
config.dut_vm_nic_pci)
##################################################
lprint(" * Start CPU monitoring on DUT...")
start_cpu_monitoring()
##################################################
lprint(" * Start packet generation for {0} seconds...".format(config.run_time))
tester.start_traffic(config.tester_interface)
for i in range(1, config.run_time):
time.sleep(1)
##################################################
lprint(" * Stop CPU monitoring on DUT...")
stop_cpu_monitoring()
##################################################
lprint(" * Stopping packet stream...")
tester.stop_traffic(config.tester_interface)
time.sleep(1)
##################################################
lprint(" * Stop packet receiver on VM...")
stop_traffic_rx_on_vm(config.dut_vm_address)
##################################################
lprint(" * Gathering statistics...")
tester.take_tx_statistics_snapshot(config.tester_interface)
full_tx_stats = tester.get_tx_statistics_snapshots(config.tester_interface)
slogger.debug(" full_tx_stats={}".format(full_tx_stats))
pp_rx_end \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])[2]
vp_tx_end, vp_tx_drop_end \
= get_of_port_packet_stats(of_interfaces[config.virtual_interface])[0:2]
pp_rx = pp_rx_end - pp_rx_start
vp_tx = vp_tx_end - vp_tx_start
vp_tx_drop = vp_tx_drop_end - vp_tx_drop_start
vm_pkts_sec = get_traffic_rx_stats_from_vm(config.dut_vm_address)
packets_tx = full_tx_stats[sorted(full_tx_stats.keys())[-1]]['pt_total']['packets']
lprint(" - Packets send by Tester {:,}".format(packets_tx))
lprint(" - Packets received by physical port {:,} [Lost {:,}]".
format(pp_rx, packets_tx - pp_rx))
lprint(" - Packets received by virtual port {:,} [Lost {:,}]".
format(vp_tx, pp_rx - vp_tx))
lprint(" - Packets dropped by virtual port {:,}".
format(vp_tx_drop))
lprint(" ! Result, average: {:,} pps".format(vm_pkts_sec))
p2v_results.append(vm_pkts_sec)
cpu_results.append(get_cpu_monitoring_stats())
##################################################
lprint(" * Restoring state for next test...")
tester.unconfigure_traffic_stream(config.tester_interface)
# dut_shell.dut_exec('sh -c "ovs-ofctl del-flows {0} && ovs-appctl dpctl/del-flows"'.\
# format(config.bridge_name),
# die_on_error=True)
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2})] END".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size))
create_single_graph(packet_sizes, p2v_results,
"Packet size", "Packets/second",
"Physical to Virtual with {} {} flows{}".
format(nr_of_flows, get_flow_type_short(),
get_traffic_rate_str()),
"test_p2v_{}_{}".
format(nr_of_flows, get_flow_type_name()),
phy_speed, cpu_utilization=cpu_results)
return p2v_results, cpu_results
#
# Run simple traffic test Physical to Physical
#
def test_p2p(nr_of_flows, packet_sizes):
p2p_results = list()
cpu_results = list()
for packet_size in packet_sizes:
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2}, rate={3:.3f}%))]"
" START".format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size, config.traffic_rate))
##################################################
lprint(" * Create OVS OpenFlow rules...")
create_ovs_of_rules(nr_of_flows,
of_interfaces[config.physical_interface],
of_interfaces[config.second_physical_interface])
##################################################
lprint(" * Initializing packet generation...")
tester.configure_traffic_stream(config.tester_interface,
get_traffic_generator_flow(),
nr_of_flows, packet_size,
traffic_dst_mac=config.dst_mac_address,
traffic_src_mac=config.src_mac_address,
percentage=config.traffic_rate * 10000)
##################################################
if config.warm_up:
lprint(" * Doing flow table warm-up...")
tester.start_traffic(config.tester_interface)
warm_up_done = warm_up_verify(nr_of_flows, config.warm_up_timeout)
tester.stop_traffic(config.tester_interface)
if not warm_up_done and not config.warm_up_no_fail:
sys.exit(-1)
##################################################
lprint(" * Clear all statistics...")
tester.clear_statistics(config.tester_interface)
tester.clear_statistics(config.second_tester_interface)
pp_tx_start, pp_tx_drop_start, pp_rx_start, pp_rx_drop_start \
= get_of_port_packet_stats(
of_interfaces[config.physical_interface])
rpp_tx_start, rpp_tx_drop_start, rpp_rx_start, rpp_rx_drop_start \
= get_of_port_packet_stats(
of_interfaces[config.second_physical_interface])
##################################################
lprint(" * Start CPU monitoring on DUT...")
start_cpu_monitoring()
##################################################
lprint(" * Start packet generation for {0} seconds...".
format(config.run_time))
tester.start_traffic(config.tester_interface)
for i in range(1, config.run_time):
time.sleep(1)
tester.take_rx_statistics_snapshot(config.second_tester_interface)
##################################################
lprint(" * Stop CPU monitoring on DUT...")
stop_cpu_monitoring()
##################################################
lprint(" * Stopping packet stream...")
tester.stop_traffic(config.tester_interface)
time.sleep(1)
##################################################
lprint(" * Gathering statistics...")
tester.take_tx_statistics_snapshot(config.tester_interface)
tester.take_rx_statistics_snapshot(config.second_tester_interface)
full_tx_stats = tester.get_tx_statistics_snapshots(
config.tester_interface)
full_rx_stats = tester.get_rx_statistics_snapshots(
config.second_tester_interface)
slogger.debug(" full_tx_stats={}".format(full_tx_stats))
slogger.debug(" full_rx_stats={}".format(full_rx_stats))
pp_tx_end, pp_tx_drop_end, pp_rx_end, pp_rx_drop_end \
= get_of_port_packet_stats(
of_interfaces[config.physical_interface])
rpp_tx_end, rpp_tx_drop_end, rpp_rx_end, rpp_rx_drop_end \
= get_of_port_packet_stats(
of_interfaces[config.second_physical_interface])
pp_rx = pp_rx_end - pp_rx_start
pp_rx_drop = pp_rx_drop_end - pp_rx_drop_start
rpp_tx = rpp_tx_end - rpp_tx_start
rpp_tx_drop = rpp_tx_drop_end - rpp_tx_drop_start
packets_tx = full_tx_stats[sorted(full_tx_stats.keys())[-1]]['pt_total']['packets']
packets_rx = full_rx_stats[sorted(full_rx_stats.keys())[-1]]['pr_total']['packets']
lprint(" - Packets send by Tester : {:-20,}".format(packets_tx))
lprint(" - Packets received by physical : {:-20,} [Lost {:,}, Drop {:,}]".
format(pp_rx, packets_tx - pp_rx, pp_rx_drop))
lprint(" - Packets send by second physical: {:-20,} [Lost {:,}, Drop {:,}]".
format(rpp_tx, pp_rx - rpp_tx, rpp_tx_drop))
lprint(" - Packets received by Tester : {:-20,} [Lost {:,}]".
format(packets_rx, rpp_tx - packets_rx))
rx_pkts_sec = get_packets_per_second_from_traffic_generator_rx_stats(full_rx_stats)
lprint(" ! Result, average: {:,} pps".format(rx_pkts_sec))
p2p_results.append(rx_pkts_sec)
cpu_results.append(get_cpu_monitoring_stats())
##################################################
lprint(" * Restoring state for next test...")
tester.unconfigure_traffic_stream(config.tester_interface)
# dut_shell.dut_exec('sh -c "ovs-ofctl del-flows {0} && ovs-appctl dpctl/del-flows"'.\
# format(config.bridge_name),
# die_on_error=True)
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2})] END".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size))
create_single_graph(packet_sizes, p2p_results,
"Packet size", "Packets/second",
"Physical to Physical with {} {} flows{}".
format(nr_of_flows, get_flow_type_short(),
get_traffic_rate_str()),
"test_p2p_{}_{}".
format(nr_of_flows, get_flow_type_name()),
phy_speed, cpu_utilization=cpu_results)
return p2p_results, cpu_results
#
# Run simple traffic test Physical loopback
#
def test_p_single_packet_size(nr_of_flows, packet_size, **kwargs):
decrease_rate = kwargs.get("decrease_rate", 0)
assert (decrease_rate >= 0 or decrease_rate < 100)
decrease_rate *= 10000
results = dict()
##################################################
lprint("- [TEST: {0}(flows={1}, packet_size={2}, rate={3:.2f}%)] START".
format(inspect.currentframe().f_code.co_name,
nr_of_flows, packet_size, (1000000 - decrease_rate) / 10000))
##################################################
lprint(" * Create OVS OpenFlow rules...")
create_ovs_of_rules(nr_of_flows,
of_interfaces[config.physical_interface],
"IN_PORT")
##################################################
lprint(" * Initializing packet generation...")
tester.configure_traffic_stream(config.tester_interface,
get_traffic_generator_flow(),
nr_of_flows, packet_size,
traffic_dst_mac=config.dst_mac_address,
traffic_src_mac=config.src_mac_address,
percentage=1000000 - decrease_rate)
##################################################
if config.warm_up:
lprint(" * Doing flow table warm-up...")
tester.start_traffic(config.tester_interface)
warm_up_done = warm_up_verify(nr_of_flows,
config.warm_up_timeout)
tester.stop_traffic(config.tester_interface)
if not warm_up_done and not config.warm_up_no_fail:
sys.exit(-1)
##################################################
lprint(" * Clear all statistics...")
tester.clear_statistics(config.tester_interface)
pp_tx_start, pp_tx_drop_start, pp_rx_start, pp_rx_drop_start \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])
##################################################
lprint(" * Start CPU monitoring on DUT...")
start_cpu_monitoring()
##################################################
lprint(" * Start packet generation for {0} seconds...".format(config.run_time))
tester.start_traffic(config.tester_interface)
for i in range(1, config.run_time):
time.sleep(1)
tester.take_rx_statistics_snapshot(config.tester_interface)
##################################################
lprint(" * Stop CPU monitoring on DUT...")
stop_cpu_monitoring()
##################################################
lprint(" * Stopping packet stream...")
tester.stop_traffic(config.tester_interface)
time.sleep(1)
##################################################
lprint(" * Gathering statistics...")
tester.take_statistics_snapshot(config.tester_interface)
full_tx_stats = tester.get_tx_statistics_snapshots(config.tester_interface)
full_rx_stats = tester.get_rx_statistics_snapshots(config.tester_interface)
slogger.debug(" full_tx_stats={}".format(full_tx_stats))
slogger.debug(" full_rx_stats={}".format(full_rx_stats))
pp_tx_end, pp_tx_drop_end, pp_rx_end, pp_rx_drop_end \
= get_of_port_packet_stats(of_interfaces[config.physical_interface])
pp_rx = pp_rx_end - pp_rx_start
pp_tx = pp_tx_end - pp_tx_start
pp_rx_drop = pp_rx_drop_end - pp_rx_drop_start