-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathtest_l3_longevity.py
More file actions
executable file
·3884 lines (3445 loc) · 178 KB
/
test_l3_longevity.py
File metadata and controls
executable file
·3884 lines (3445 loc) · 178 KB
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/env python3
"""
## NAME: test_l3_longevity.py
Host AP reference : https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
## PURPOSE:
Supports creating user-specified amount stations on multiple radios
Supports configuring upload and download requested rates and PDU sizes.
Supports generating KPI data
Supports generating connections with different ToS values.
Supports generating tcp and/or UDP traffic types.
Supports iterating over different PDU sizes
Supports iterating over different requested tx rates
(configurable as total or per-connection value)
Supports iterating over attenuation values.
Supports testing connection between two ethernet connection - L3 dataplane
## EXAMPLE:
### Example command using attenuator
./test_l3_longevity.py --test_duration 5m --polling_interval 1s --upstream_port 1.1.eth2 \
--radio 'radio==1.1.wiphy1,stations==1,ssid==TCH-XB7,ssid_pw==comcast123,security==wpa2' \
--radio 'radio==1.1.wiphy2,stations==1,ssid==TCH-XB7,ssid_pw==comcast123,security==wpa2' \
--radio 'radio==1.1.wiphy3,stations==1,ssid==TCH-XB7,ssid_pw==comcast123,security==wpa2' \
--radio 'radio==1.1.wiphy4,stations==1,ssid==TCH-XB7,ssid_pw==comcast123,security==wpa2' \
--endp_type lf_udp --ap_read --ap_scheduler_stats --ap_ofdma_stats --side_a_min_bps=20000 --side_b_min_bps=400000000 \
--attenuators 1.1.<serial number>.1 \
--atten_vals 20,21,40,41
### Example using upsteam eth1 downstream eth2
./test_l3_longevity.py --test_duration 20s --polling_interval 1s --upstream_port 1.1.eth1 --downstream_port 1.1.eth2
--endp_type lf --rates_are_totals --side_a_min_bps=10000000,0 --side_a_min_pdu=1000 --side_b_min_bps=0,300000000 --side_b_min_pdu=1000
### Example using wifi_settings
./test_l3_longevity.py --lfmgr 192.168.100.116 --local_lf_report_dir
/home/lanforge/html-reports/ --test_duration 15s --polling_interval 5s
--upstream_port 1.1.eth2
--radio "radio==1.1.wiphy1 stations==4 ssid==asus11ax-5 ssid_pw==hello123 security==wpa2
wifi_mode==0 wifi_settings==wifi_settings
enable_flags==('ht160_enable'|'wpa2_enable'|'80211u_enable'|'create_admin_down')"
--endp_type lf_udp --rates_are_totals --side_a_min_bps=20000 --side_b_min_bps=300000000
--test_rig CT-US-001 --test_tag 'l3_longevity'
Example : Have the stations continue to run after the completion of the script
./test_l3_longevity.py --lfmgr 192.168.0.101 --endp_type 'lf_udp,lf_tcp' --tos BK --upstream_port 1.1.eth2
--radio 'radio==wiphy1 stations==2 ssid==asus_2g ssid_pw==lf_asus_2g security==wpa2'
--test_duration 30s --polling_interval 5s
--side_a_min_bps 256000 --side_b_min_bps 102400000
--no_stop_traffic
Example : Have script use existing stations from previous run where traffic was not stopped and also create new stations and
leave traffic running
./test_l3_longevity.py --lfmgr 192.168.0.101 --endp_type 'lf_udp,lf_tcp' --tos BK --upstream_port 1.1.eth2
--radio 'radio==wiphy0 stations==2 ssid==asus_5g ssid_pw==lf_asus_5g security==wpa2'
--sta_start_offset 1000
--test_duration 30s --polling_interval 5s
--side_a_min_bps 256000 --side_b_min_bps 102400000
--use_existing_station_list
--existing_station_list '1.1.sta0000,1.1.sta0001'
--no_stop_traffic
## COPYRIGHT:
Copyright 2021 Candela Technologies Inc
INCLUDE_IN_README
"""
import argparse
import csv
import datetime
import importlib
import os
import random
import sys
import time
from pprint import pformat
import logging
import itertools
import traceback
import pandas as pd
import pexpect
import serial
from pexpect_serial import SerialSpawn
import paramiko
if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
lf_report = importlib.import_module("py-scripts.lf_report")
lf_kpi_csv = importlib.import_module("py-scripts.lf_kpi_csv")
lf_logger_config = importlib.import_module("py-scripts.lf_logger_config")
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
realm = importlib.import_module("py-json.realm")
Realm = realm.Realm
# used for Attenuator and possible vap testing testing
lf_attenuator = importlib.import_module("py-scripts.lf_atten_mod_test")
# modify_vap = importlib.import_module("py-scripts.modify_vap")
lf_modify_radio = importlib.import_module("py-scripts.lf_modify_radio")
# cleanup library
lf_cleanup = importlib.import_module("py-scripts.lf_cleanup")
logger = logging.getLogger(__name__)
# This class handles running the test and generating reports.
class L3VariableTime(Realm):
def __init__(self,
endp_types,
args,
tos,
side_b,
side_a,
radio_name_list,
number_of_stations_per_radio_list,
ssid_list,
ssid_password_list,
ssid_security_list,
wifi_mode_list,
enable_flags_list,
station_lists,
name_prefix,
outfile,
reset_port_enable_list,
reset_port_time_min_list,
reset_port_time_max_list,
side_a_min_rate=None,
side_a_max_rate=None,
side_b_min_rate=None,
side_b_max_rate=None,
side_a_min_pdu=None,
side_a_max_pdu=None,
side_b_min_pdu=None,
side_b_max_pdu=None,
user_tags=None,
rates_are_totals=False,
mconn=1,
attenuators=None,
atten_vals=None,
number_template="00",
test_duration="256s",
collect_layer3_data=False,
polling_interval="60s",
lfclient_host="localhost",
lfclient_port=8080,
debug=False,
# kpi_csv object to set kpi values during the test
kpi_csv=None,
ap_scheduler_stats=False,
ap_ofdma_stats=False,
ap_read=False,
ap_scheme='serial',
ap_port='/dev/ttyUSB0',
ap_baud='115200',
ap_ip='localhost',
ap_ssh_port='22',
ap_user=None,
ap_passwd=None,
ap_if_2g=None,
ap_if_5g=None,
ap_if_6g=None,
ap_cmd_6g='wl -i wl2 bs_data',
ap_cmd_5g='wl -i wl1 bs_data',
ap_cmd_2g='wl -i wl0 bs_data',
ap_cmd_ul_6g='wl -i wl2 rx_report',
ap_cmd_ul_5g='wl -i wl1 rx_report',
ap_cmd_ul_2g='wl -i wl0 rx_report',
ap_chanim_cmd_6g='wl -i wl2 chanim_stats',
ap_chanim_cmd_5g='wl -i wl1 chanim_stats',
ap_chanim_cmd_2g='wl -i wl0 chanim_stats',
ap_test_mode=False,
_exit_on_error=False,
_exit_on_fail=False,
_proxy_str=None,
_capture_signal_list=None,
no_cleanup=False,
use_existing_station_lists=False,
existing_station_lists=None,
wait_for_ip_sec="120s"):
self.eth_endps = []
self.cx_names = []
self.total_stas = 0
if side_a_min_rate is None:
side_a_min_rate = [56000]
if side_a_max_rate is None:
side_a_max_rate = [0]
if side_b_min_rate is None:
side_b_min_rate = [56000]
if side_b_max_rate is None:
side_b_max_rate = [0]
if side_a_min_pdu is None:
side_a_min_pdu = ["MTU"]
if side_a_max_pdu is None:
side_a_max_pdu = [0]
if side_b_min_pdu is None:
side_b_min_pdu = ["MTU"]
if side_b_max_pdu is None:
side_b_max_pdu = [0]
if user_tags is None:
user_tags = []
if attenuators is None:
attenuators = []
if atten_vals is None:
atten_vals = []
if _capture_signal_list is None:
_capture_signal_list = []
super().__init__(lfclient_host=lfclient_host,
lfclient_port=lfclient_port,
debug_=debug,
_exit_on_error=_exit_on_error,
_exit_on_fail=_exit_on_fail,
_proxy_str=_proxy_str,
_capture_signal_list=_capture_signal_list)
# kpi_csv object to set kpi.csv values
self.kpi_csv = kpi_csv
self.tos = tos.split(",")
self.endp_types = endp_types.split(",")
self.side_b = side_b
self.side_a = side_a
# if it is a dataplane test the side_a is not none and an ethernet port
if self.side_a is not None:
self.dataplane = True
else:
self.dataplane = False
self.ssid_list = ssid_list
self.ssid_password_list = ssid_password_list
self.wifi_mode_list = wifi_mode_list
self.enable_flags_list = enable_flags_list
self.station_lists = station_lists
self.ssid_security_list = ssid_security_list
self.reset_port_enable_list = reset_port_enable_list
self.reset_port_time_min_list = reset_port_time_min_list
self.reset_port_time_max_list = reset_port_time_max_list
self.number_template = number_template
self.name_prefix = name_prefix
self.test_duration = test_duration
self.collect_layer3_data = collect_layer3_data
self.radio_name_list = radio_name_list
self.number_of_stations_per_radio_list = number_of_stations_per_radio_list
# self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on)
self.polling_interval_seconds = self.duration_time_to_seconds(
polling_interval)
self.cx_profile = self.new_l3_cx_profile()
self.multicast_profile = self.new_multicast_profile()
self.multicast_profile.name_prefix = "MLT-"
self.station_profiles = []
self.args = args
self.outfile = outfile
self.csv_started = False
self.epoch_time = int(time.time())
self.debug = debug
self.mconn = mconn
self.user_tags = user_tags
self.side_a_min_rate = side_a_min_rate
self.side_a_max_rate = side_a_max_rate
self.side_b_min_rate = side_b_min_rate
self.side_b_max_rate = side_b_max_rate
self.side_a_min_pdu = side_a_min_pdu
self.side_a_max_pdu = side_a_max_pdu
self.side_b_min_pdu = side_b_min_pdu
self.side_b_max_pdu = side_b_max_pdu
self.rates_are_totals = rates_are_totals
self.cx_count = 0
self.station_count = 0
self.no_cleanup = no_cleanup
self.use_existing_station_lists = use_existing_station_lists
self.existing_station_lists = existing_station_lists
self.wait_for_ip_sec = self.duration_time_to_seconds(wait_for_ip_sec)
self.attenuators = attenuators
self.atten_vals = atten_vals
if ((len(self.atten_vals) > 0) and (
self.atten_vals[0] != -1) and (len(self.attenuators) == 0)):
raise ValueError("ERROR: Attenuation values configured, but no Attenuator EIDs specified.\n")
logger.critical(
"ERROR: Attenuation values configured, but no Attenuator EIDs specified.\n")
self.cx_profile.mconn = mconn
self.cx_profile.side_a_min_bps = side_a_min_rate[0]
self.cx_profile.side_a_max_bps = side_a_max_rate[0]
self.cx_profile.side_b_min_bps = side_b_min_rate[0]
self.cx_profile.side_b_max_bps = side_b_max_rate[0]
# ap interface commands
self.ap_scheduler_stats = ap_scheduler_stats
self.ap_ofdma_stats = ap_ofdma_stats
self.ap_read = ap_read
self.ap_scheme = ap_scheme
self.ap_test_mode = ap_test_mode
self.ap_port = ap_port
self.ap_baud = ap_baud
self.ap_ip = ap_ip
self.ap_ssh_port = ap_ssh_port
self.ap_user = ap_user
self.ap_passwd = ap_passwd
# TODO refactor to be based on single command
# and vary interface
self.ap_if_6g = ap_if_6g
self.ap_if_5g = ap_if_5g
self.ap_if_2g = ap_if_2g
self.ap_cmd_6g = ap_cmd_6g
self.ap_cmd_5g = ap_cmd_5g
self.ap_cmd_2g = ap_cmd_2g
self.ap_cmd_ul_6g = ap_cmd_ul_6g
self.ap_cmd_ul_5g = ap_cmd_ul_5g
self.ap_cmd_ul_2g = ap_cmd_ul_2g
self.ap_chanim_cmd_6g = ap_chanim_cmd_6g
self.ap_chanim_cmd_5g = ap_chanim_cmd_5g
self.ap_chanim_cmd_2g = ap_chanim_cmd_2g
self.ap_dump_clear_6g = 'wl -i wl2 dump_clear'
self.ap_dump_clear_5g = 'wl -i wl1 dump_clear'
self.ap_dump_clear_2g = 'wl -i wl0 dump_clear'
self.ap_dump_umsched_6g = 'wl -i wl2 dump umsched'
self.ap_dump_umsched_5g = 'wl -i wl1 dump umsched'
self.ap_dump_umsched_2g = 'wl -i wl0 dump umsched'
self.ap_dump_msched_6g = 'wl -i wl2 dump msched'
self.ap_dump_msched_5g = 'wl -i wl1 dump msched'
self.ap_dump_msched_2g = 'wl -i wl0 dump msched'
self.ap_muinfo_6g = 'wl -i wl2 muinfo -v'
self.ap_muinfo_5g = 'wl -i wl1 muinfo -v'
self.ap_muinfo_2g = 'wl -i wl0 muinfo -v'
self.ap_6g_umsched = ""
self.ap_6g_msched = ""
self.ap_5g_umsched = ""
self.ap_5g_msched = ""
self.ap_24g_umsched = ""
self.ap_24g_msched = ""
self.ap_ofdma_6g = ""
self.ap_ofdma_5g = ""
self.ap_ofdma_24g = ""
# TODO reduce commands to just vary based on interface
if self.ap_if_6g != 'wl2':
self.ap_cmd_6g = self.ap_cmd_6g.replace('wl2', self.ap_if_6g)
self.ap_cmd_ul_6g = self.ap_cmd_ul_6g.replace('wl2', self.ap_if_6g)
self.ap_chanim_cmd_6g = self.ap_chanim_cmd_6g.replace('wl2', self.ap_if_6g)
self.ap_dump_clear_6g = self.ap_dump_clear_6g.replace('wl2', self.ap_if_6g)
self.ap_dump_umsched_6g = self.ap_dump_umsched_6g.replace('wl2', self.ap_if_6g)
self.ap_dump_msched_6g = self.ap_dump_msched_6g.replace('wl2', self.ap_if_6g)
self.ap_muinfo_6g = self.ap_muinfo_6g.replace('wl2', self.ap_if_6g)
if self.ap_if_5g != 'wl1':
self.ap_cmd_5g = self.ap_cmd_5g.replace('wl1', self.ap_if_5g)
self.ap_cmd_ul_5g = self.ap_cmd_ul_5g.replace('wl1', self.ap_if_5g)
self.ap_chanim_cmd_5g = self.ap_chanim_cmd_5g.replace('wl1', self.ap_if_5g)
self.ap_dump_clear_5g = self.ap_dump_clear_5g.replace('wl1', self.ap_if_5g)
self.ap_dump_umsched_5g = self.ap_dump_umsched_5g.replace('wl1', self.ap_if_5g)
self.ap_dump_msched_5g = self.ap_dump_msched_5g.replace('wl1', self.ap_if_5g)
self.ap_muinfo_5g = self.ap_muinfo_5g.replace('wl1', self.ap_if_5g)
if self.ap_if_2g != 'wl0':
self.ap_cmd_2g = self.ap_cmd_2g.replace('wl0', self.ap_if_2g)
self.ap_cmd_ul_2g = self.ap_cmd_ul_2g.replace('wl0', self.ap_if_2g)
self.ap_chanim_cmd_2g = self.ap_chanim_cmd_2g.replace('wl0', self.ap_if_2g)
self.ap_dump_clear_2g = self.ap_dump_clear_2g.replace('wl0', self.ap_if_2g)
self.ap_dump_umsched_2g = self.ap_dump_umsched_2g.replace('wl0', self.ap_if_2g)
self.ap_dump_msched_2g = self.ap_dump_msched_2g.replace('wl0', self.ap_if_2g)
self.ap_muinfo_2g = self.ap_muinfo_2g.replace('wl0', self.ap_if_2g)
# Lookup key is port-eid name
self.port_csv_files = {}
self.port_csv_writers = {}
self.ul_port_csv_files = {}
self.ul_port_csv_writers = {}
self.l3_csv_files = {}
self.l3_csv_writers = {}
# the --ap_read will use these headers
self.ap_stats_col_titles = [
"Station Address",
"Dl-PHY-Mbps",
"Dl-Data-Mbps",
"Dl-Air-Use",
"Dl-Data-Use",
"Dl-Retries",
"Dl-BW",
"Dl-MCS",
"Dl-NSS",
"Dl-OFDMA",
"Dl-MU-MIMO",
"Dl-Channel-Utilization"]
self.ap_stats_ul_col_titles = [
"UL Station Address",
"Ul-rssi",
"Ul-tid",
"Ul-ampdu",
"Ul-mpdu",
"Ul-Data-Mbps",
"Ul-PHY-Mbps",
"UL-BW",
"Ul-MCS",
"Ul-NSS",
"Ul-OOW",
"Ul-HOLES",
"Ul-DUP",
"Ul-Retries",
"Ul-OFDMA",
"Ul-Tones",
"Ul-AIR"]
dur = self.duration_time_to_seconds(self.test_duration)
if self.polling_interval_seconds > dur + 1:
self.polling_interval_seconds = dur - 1
# Full spread-sheet data
if self.outfile is not None:
# create csv results writer and open results file to be written to.
results = self.outfile[:-4] # take off .csv part of outfile
results = results + "-results.csv"
self.csv_results_file = open(results, "w")
self.csv_results_writer = csv.writer(self.csv_results_file, delimiter=",")
# if it is a dataplane test the side_a is not None and an ethernet port
# if side_a is None then side_a is radios
if not self.dataplane:
for (
radio_,
ssid_,
ssid_password_,
ssid_security_,
mode_,
enable_flags_,
reset_port_enable_,
reset_port_time_min_,
reset_port_time_max_) in zip(
radio_name_list,
ssid_list,
ssid_password_list,
ssid_security_list,
wifi_mode_list,
enable_flags_list,
reset_port_enable_list,
reset_port_time_min_list,
reset_port_time_max_list):
self.station_profile = self.new_station_profile()
self.station_profile.lfclient_url = self.lfclient_url
self.station_profile.ssid = ssid_
self.station_profile.ssid_pass = ssid_password_
self.station_profile.security = ssid_security_
self.station_profile.number_template = self.number_template
self.station_profile.mode = mode_
self.station_profile.desired_add_sta_flags = enable_flags_.copy()
self.station_profile.desired_add_sta_flags_mask = enable_flags_.copy()
# place the enable and disable flags
# self.station_profile.desired_add_sta_flags = self.enable_flags
# self.station_profile.desired_add_sta_flags_mask = self.enable_flags
self.station_profile.set_reset_extra(
reset_port_enable=reset_port_enable_,
test_duration=self.duration_time_to_seconds(
self.test_duration),
reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),
reset_port_max_time=self.duration_time_to_seconds(reset_port_time_max_))
self.station_profiles.append(self.station_profile)
# Use existing station list is similiar to no rebuild
if self.use_existing_station_lists:
for existing_station_list in self.existing_station_lists:
self.station_profile = self.new_station_profile()
self.station_profile.station_names.append(existing_station_list)
self.station_profiles.append(self.station_profile)
else:
pass
self.multicast_profile.host = self.lfclient_host
self.cx_profile.host = self.lfclient_host
self.cx_profile.port = self.lfclient_port
self.cx_profile.name_prefix = self.name_prefix
self.lf_endps = None
self.udp_endps = None
self.tcp_endps = None
# def ap_serial(self,command)
def ap_ssh(self, command):
# in python3 bytes and str are two different types. str is used to reporesnt any
# type of string (also unicoe), when you encode()
# something, you confvert it from it's str represnetation to it's bytes reprrestnetation for a specific
# endoding
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.ap_ip, port=self.ap_ssh_port, username=self.ap_user, password=self.ap_passwd, timeout=5)
stdin, stdout, steerr = ssh.exec_command(command)
output = stdout.read()
logger.debug("command: {command} output: {output}".format(command=command, output=output))
output = output.decode('utf-8', 'ignore')
logger.debug("after utf-8 ignoer command: {command} output: {output}".format(command=command, output=output))
ssh.close()
return output
def get_ap_6g_umsched(self):
return self.ap_6g_umsched
def get_ap_6g_msched(self):
return self.ap_6g_msched
def get_ap_5g_umsched(self):
return self.ap_5g_umsched
def get_ap_5g_msched(self):
return self.ap_5g_msched
def get_ap_24g_umsched(self):
return self.ap_5g_umsched
def get_ap_24g_msched(self):
return self.ap_5g_msched
def get_ap_ofdma_6g(self):
return self.ap_ofdma_6g
def get_ap_ofdma_5g(self):
return self.ap_ofdma_5g
def get_ap_ofdma_24g(self):
return self.ap_ofdma_24g
def get_results_csv(self):
# print("self.csv_results_file {}".format(self.csv_results_file.name))
return self.csv_results_file.name
def get_l3_stats_for_cx(self, data):
type = data["type"]
state = data["state"]
pkt_rx_a = int(data['pkt rx a'])
pkt_rx_b = int(data['pkt rx b'])
bps_rx_a = int(data['bps rx a'])
bps_rx_b = int(data['bps rx b'])
rx_drop_percent_a = int(data['rx drop % a'])
rx_drop_percent_b = int(data['rx drop % b'])
drop_pkts_a = int(data['drop pkts a'])
drop_pkts_b = int(data['drop pkts b'])
avg_rtt = int(data['avg rtt'])
rpt_timer = data['rpt timer']
eid = data['eid']
return type, state, pkt_rx_a, pkt_rx_b, bps_rx_a, bps_rx_b, rx_drop_percent_a, rx_drop_percent_b, drop_pkts_a, drop_pkts_b, avg_rtt, rpt_timer, eid
# Find avg latency, jitter for connections using specified port.
def get_endp_stats_for_port(self, port_eid, endps):
lat = 0
jit = 0
total_dl_rate = 0
total_dl_rate_ll = 0
total_dl_pkts_ll = 0
total_ul_rate = 0
total_ul_rate_ll = 0
total_ul_pkts_ll = 0
count = 0
sta_name = 'no_station'
# logger.debug("endp-stats-for-port, port-eid: {}".format(port_eid))
eid = self.name_to_eid(port_eid)
logger.info(
"port_eid: {port_eid} eid: {eid}".format(
port_eid=port_eid,
eid=eid))
# Convert all eid elements to strings
eid[0] = str(eid[0])
eid[1] = str(eid[1])
eid[2] = str(eid[2])
for endp in endps:
logger.info(pformat(endp))
eid_endp = endp["eid"].split(".")
logger.info(
"Comparing eid:{eid} to endp-id {eid_endp}".format(eid=eid, eid_endp=eid_endp))
# Look through all the endpoints (endps), to find the port the port_eid is using.
# The port_eid that has the same Shelf, Resource, and Port as the eid_endp (looking at all the endps)
# Then read the eid_endp to get the delay, jitter and rx rate
# Note: the endp eid is shelf.resource.port.endp-id, the eid can be treated somewhat as
# child class of port-eid , and look up the port the eid is using.
if eid[0] == eid_endp[0] and eid[1] == eid_endp[1] and eid[2] == eid_endp[2]:
lat += int(endp["delay"])
jit += int(endp["jitter"])
name = endp["name"]
logger.debug("endp name {name}".format(name=name))
sta_name = name.replace('-A', '')
# only the -A endpoint will be found so need to look
count += 1
logger.debug(
"Matched: name: {name} eid:{eid} to endp-id {eid_endp}".format(
name=name, eid=eid, eid_endp=eid_endp))
else:
name = endp["name"]
logger.debug(
"No Match: name: {name} eid:{eid} to endp-id {eid_endp}".format(
name=name, eid=eid, eid_endp=eid_endp))
if count > 1:
lat = int(lat / count)
jit = int(jit / count)
# need to loop though again to find the upload and download per station
# if the name matched
for endp in endps:
if sta_name in endp["name"]:
name = endp["name"]
if name.endswith("-A"):
logger.debug("name has -A")
total_dl_rate += int(endp["rx rate"])
total_dl_rate_ll += int(endp["rx rate ll"])
total_dl_pkts_ll += int(endp["rx pkts ll"])
# -B upload side
else:
total_ul_rate += int(endp["rx rate"])
total_ul_rate_ll += int(endp["rx rate ll"])
total_ul_pkts_ll += int(endp["rx pkts ll"])
return lat, jit, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll
# Query all endpoints to generate rx and other stats, returned
# as an array of objects.
def __get_rx_values(self):
endp_list = self.json_get(
"endp?fields=name,eid,delay,jitter,rx+rate,rx+rate+ll,rx+bytes,rx+drop+%25,rx+pkts+ll",
debug_=False)
logger.debug("endp_list: {}".format(endp_list))
endp_rx_drop_map = {}
endp_rx_map = {}
our_endps = {}
endps = []
total_ul = 0
total_ul_ll = 0
total_dl = 0
total_dl_ll = 0
for e in self.multicast_profile.get_mc_names():
our_endps[e] = e
for e in self.cx_profile.created_endp.keys():
our_endps[e] = e
for endp_name in endp_list['endpoint']:
if endp_name != 'uri' and endp_name != 'handler':
for item, endp_value in endp_name.items():
if item in our_endps or self.use_existing_station_lists:
endps.append(endp_value)
logger.info("endpoint: {item} value:\n".format(item=item))
logger.info(pformat(endp_value))
for value_name, value in endp_value.items():
if value_name == 'rx bytes':
endp_rx_map[item] = value
if value_name == 'rx rate':
endp_rx_map[item] = value
if value_name == 'rx rate ll':
endp_rx_map[item] = value
if value_name == 'rx pkts ll':
endp_rx_map[item] = value
if value_name == 'rx drop %':
endp_rx_drop_map[item] = value
if value_name == 'rx rate':
# This hack breaks for mcast or if someone names endpoints weirdly.
if item.endswith("-A"):
total_dl += int(value)
else:
total_ul += int(value)
if value_name == 'rx rate ll':
# This hack breaks for mcast or if someone
# names endpoints weirdly.
if item.endswith("-A"):
total_dl_ll += int(value)
else:
total_ul_ll += int(value)
logger.debug("total-dl: {total_dl}, total-ul: {total_ul}\n".format(total_dl=total_dl, total_ul=total_ul))
return endp_rx_map, endp_rx_drop_map, endps, total_dl, total_ul, total_dl_ll, total_ul_ll
# This script supports resetting ports, allowing one to test AP/controller under data load
# while bouncing wifi stations. Check here to see if we should reset
# ports.
def reset_port_check(self):
for station_profile in self.station_profiles:
if station_profile.reset_port_extra_data['reset_port_enable']:
if not station_profile.reset_port_extra_data['reset_port_timer_started']:
logger.info(
"reset_port_timer_started {}".format(
station_profile.reset_port_extra_data['reset_port_timer_started']))
logger.info(
"reset_port_time_min: {}".format(
station_profile.reset_port_extra_data['reset_port_time_min']))
logger.info(
"reset_port_time_max: {}".format(
station_profile.reset_port_extra_data['reset_port_time_max']))
station_profile.reset_port_extra_data['seconds_till_reset'] = random.randint(
station_profile.reset_port_extra_data['reset_port_time_min'],
station_profile.reset_port_extra_data['reset_port_time_max'])
station_profile.reset_port_extra_data['reset_port_timer_started'] = True
logger.info(
"on radio {} seconds_till_reset {}".format(
station_profile.add_sta_data['radio'],
station_profile.reset_port_extra_data['seconds_till_reset']))
else:
station_profile.reset_port_extra_data[
'seconds_till_reset'] = station_profile.reset_port_extra_data['seconds_till_reset'] - 1
logger.info(
"radio: {} countdown seconds_till_reset {}".format(
station_profile.add_sta_data['radio'],
station_profile.reset_port_extra_data['seconds_till_reset']))
if ((
station_profile.reset_port_extra_data['seconds_till_reset'] <= 0)):
station_profile.reset_port_extra_data['reset_port_timer_started'] = False
port_to_reset = random.randint(
0, len(station_profile.station_names) - 1)
logger.info(
"reset on radio {} station: {}".format(
station_profile.add_sta_data['radio'],
station_profile.station_names[port_to_reset]))
self.reset_port(
station_profile.station_names[port_to_reset])
# Common code to generate timestamp for CSV files.
def time_stamp(self):
return time.strftime('%m_%d_%Y_%H_%M_%S',
time.localtime(self.epoch_time))
# Cleanup any older config that a previous run of this test may have
# created.
def pre_cleanup(self):
'''
self.cx_profile.cleanup_prefix()
self.multicast_profile.cleanup_prefix()
self.total_stas = 0
for station_list in self.station_lists:
for sta in station_list:
self.rm_port(sta, check_exists=True)
self.total_stas += 1
'''
cleanup = lf_cleanup.lf_clean(host=self.lfclient_host, port=self.lfclient_port, resource='all')
cleanup.sanitize_all()
# Make sure they are gone
count = 0
while count < 10:
more = False
for station_list in self.station_lists:
for sta in station_list:
rv = self.rm_port(sta, check_exists=True)
if rv:
more = True
if not more:
break
count += 1
time.sleep(5)
def gather_port_eids(self):
rv = [self.side_b]
for station_profile in self.station_profiles:
rv = rv + station_profile.station_names
return rv
# Create stations and connections/endpoints. If rebuild is true, then
# only update connections/endpoints.
def build(self, rebuild=False):
index = 0
self.station_count = 0
self.udp_endps = []
self.tcp_endps = []
self.eth_endps = []
if rebuild:
# if we are just re-applying new cx values, then no need to rebuild
# stations, so allow skipping it.
# Do clean cx lists so that when we re-apply them we get same endp name
# as we had previously
self.cx_profile.clean_cx_lists()
self.multicast_profile.clean_mc_lists()
if self.dataplane:
for etype in self.endp_types:
for _tos in self.tos:
logger.info(
"Creating connections for endpoint type: %s TOS: %s cx-count: %s" %
(etype, _tos, self.cx_profile.get_cx_count()))
# use brackes on [self.side_a] to make it a list
these_cx, these_endp = self.cx_profile.create(
endp_type=etype, side_a=[
self.side_a], side_b=self.side_b, sleep_time=0, tos=_tos)
if etype == "lf_udp" or etype == "lf_udp6":
self.udp_endps = self.udp_endps + these_endp
elif etype == "lf":
self.lf_endps = self.eth_endps + these_endp
else:
self.tcp_endps = self.tcp_endps + these_endp
# after we create cxs, append to global variable
self.cx_names.append(these_cx)
else:
for station_profile in self.station_profiles:
if not rebuild and not self.use_existing_station_lists:
station_profile.use_security(
station_profile.security,
station_profile.ssid,
station_profile.ssid_pass)
station_profile.set_number_template(
station_profile.number_template)
logger.info(
"Creating stations on radio %s" %
(self.radio_name_list[index]))
station_profile.create(
radio=self.radio_name_list[index],
sta_names_=self.station_lists[index],
debug=self.debug,
sleep_time=0)
index += 1
self.station_count += len(station_profile.station_names)
# Build/update connection types
for etype in self.endp_types:
if etype == "mc_udp" or etype == "mc_udp6":
logger.info(
"Creating Multicast connections for endpoint type: %s" %
etype)
self.multicast_profile.create_mc_tx(
etype, self.side_b, etype)
self.multicast_profile.create_mc_rx(
etype, side_rx=station_profile.station_names)
else:
for _tos in self.tos:
logger.info("Creating connections for endpoint type: {etype} TOS: {tos} cx-count: {cx_count}".format(
etype=etype, tos=_tos, cx_count=self.cx_profile.get_cx_count()))
these_cx, these_endp = self.cx_profile.create(
endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos)
if etype == "lf_udp" or etype == "lf_udp6":
self.udp_endps = self.udp_endps + these_endp
else:
self.tcp_endps = self.tcp_endps + these_endp
# after we create the cxs, append to global
self.cx_names.append(these_cx)
self.cx_count = self.cx_profile.get_cx_count()
if self.dataplane:
self._pass(
"PASS: CX build finished: created/updated: %s connections." %
self.cx_count)
else:
self._pass(
"PASS: Stations & CX build finished: created/updated: %s stations and %s connections." %
(self.station_count, self.cx_count))
def ap_custom_cmd(self, ap_custom_cmd):
ap_results = ""
try:
# configure the serial interface
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
ss = SerialSpawn(ser)
ss.sendline(str(ap_custom_cmd))
# do not detete line, waits for output
ss.expect([pexpect.TIMEOUT], timeout=1)
ap_results = ss.before.decode('utf-8', 'ignore')
logger.info(
"ap_custom_cmd: {ap_custom_cmd} ap_results {ap_results}".format(
ap_custom_cmd=ap_custom_cmd, ap_results=ap_results))
except Exception as x:
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
logger.error("ap_custom_cmd: {} WARNING unable to read AP ".format(ap_custom_cmd))
return ap_results
'''
def lanforge_login(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.lanforge_ip, port=22, username=self.user,
password=self.password, timeout=300)
command=self.command
stdin,stdout,stderr=ssh.exec_command(command)
output=stdout.read()
ssh.close()
return output
'''
def read_ap_stats_6g(self):
# 6ghz: wl -i wl2 bs_data
ap_stats_6g = ""
try:
# TODO - add paramiko.SSHClient
if self.ap_scheme == 'serial':
# configure the serial interface
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
ss = SerialSpawn(ser)
ss.sendline(str(self.ap_cmd_6g))
# do not detete line, waits for output
ss.expect([pexpect.TIMEOUT], timeout=1)
ap_stats_6g = ss.before.decode('utf-8', 'ignore')
logger.debug("ap_stats_6g serial from AP: {}".format(ap_stats_6g))
elif self.ap_scheme == 'ssh':
ap_stats_6g = self.ap_ssh(str(self.ap_cmd_6g))
logger.debug("ap_stats_6g ssh from AP : {}".format(ap_stats_6g))
except Exception as x:
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
logger.error("WARNING: ap_stats_6g unable to read AP")
return ap_stats_6g
# update for ssh
def read_ap_stats_5g(self):
# 5ghz: wl -i wl1 bs_data
ap_stats_5g = ""
try:
if self.ap_scheme == 'serial':
# configure the serial interface
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
ss = SerialSpawn(ser)
ss.sendline(str(self.ap_cmd_5g))
# do not detete line, waits for output
ss.expect([pexpect.TIMEOUT], timeout=1)
ap_stats_5g = ss.before.decode('utf-8', 'ignore')
print("ap_stats_5g serial from AP: {}".format(ap_stats_5g))
elif self.ap_scheme == 'ssh':
ap_stats_5g = self.ap_ssh(str(self.ap_cmd_5g))
print("ap_stats_5g ssh from AP : {}".format(ap_stats_5g))
except Exception as x:
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
logger.error("WARNING: ap_stats_5g unable to read AP")
return ap_stats_5g
def read_ap_stats_2g(self):
# 2.4ghz# wl -i wl0 bs_data
ap_stats_2g = ""
try:
if self.ap_scheme == 'serial':
# configure the serial interface
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
ss = SerialSpawn(ser)
ss.sendline(str(self.ap_cmd_2g))
# do not detete line, waits for output
ss.expect([pexpect.TIMEOUT], timeout=1)
ap_stats_2g = ss.before.decode('utf-8', 'ignore')
print("ap_stats_2g from AP: {}".format(ap_stats_2g))
elif self.ap_scheme == 'ssh':
ap_stats_2g = self.ap_ssh(str(self.ap_cmd_2g))
print("ap_stats_5g ssh from AP : {}".format(ap_stats_2g))
except Exception as x:
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
logger.error("ap_stats_2g unable to read AP")
return ap_stats_2g
def read_ap_chanim_stats_6g(self):
# 5ghz: wl -i wl1 chanim_stats
ap_chanim_stats_6g = ""
try:
if self.ap_scheme == 'serial':
# configure the serial interface
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
ss = SerialSpawn(ser)
ss.sendline(str(self.ap_chanim_cmd_6g))
# do not detete line, waits for output
ss.expect([pexpect.TIMEOUT], timeout=1)
ap_chanim_stats_6g = ss.before.decode('utf-8', 'ignore')
print("read_ap_chanim_stats_6g {}".format(ap_chanim_stats_6g))
elif self.ap_scheme == 'ssh':
ap_chanim_stats_6g = self.ap_ssh(str(self.ap_chanim_cmd_6g))
except Exception as x:
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
logger.warning("read_ap_chanim_stats_6g unable to read AP")
return ap_chanim_stats_6g
def read_ap_chanim_stats_5g(self):
# 5ghz: wl -i wl1 chanim_stats
ap_chanim_stats_5g = ""
try:
if self.ap_scheme == 'serial':