-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathlf_interop_throughput.py
More file actions
executable file
·5069 lines (4488 loc) · 284 KB
/
lf_interop_throughput.py
File metadata and controls
executable file
·5069 lines (4488 loc) · 284 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: lf_interop_throughput.py
PURPOSE: lf_interop_throughput.py will provide the available devices and allows user to run the wifi capacity test
on particular devices by specifying direction as upload, download and bidirectional including different types of loads and incremental capacity.
Will also run the interopability test on particular devices by specifying direction as upload, download and bidirectional.
TO PERFORM THROUGHPUT TEST:
EXAMPLE-1:
Command Line Interface to run download scenario with desired resources
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --device_list 1.10,1.12
EXAMPLE-2:
Command Line Interface to run download scenario with incremental capacity
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 1000000
--traffic_type lf_udp --incremental_capacity 1,2
EXAMPLE-3:
Command Line Interface to run upload scenario with packet size
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 0 --upload 1000000 --traffic_type lf_udp --packet_size 17 # noqa: E501
EXAMPLE-4:
Command Line Interface to run bi-directional scenario with load_type intended load
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 1000000 --upload 1000000
--traffic_type lf_udp --load_type wc_intended_load
EXAMPLE-5:
Command Line Interface to run bi-directional scenario with report_timer
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 1000000 --upload 1000000
--traffic_type lf_udp --report_timer 5s
EXAMPLE-6:
Command Line Interface to run bi-directional scenario in Interop web-GUI
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 1000000 --upload 1000000
--traffic_type lf_udp --report_timer 5s --dowebgui
EXAMPLE-7:
Command Line Interface to run the test with precleanup
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --precleanup
EXAMPLE-8:
Command Line Interface to run the test with postcleanup
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --postcleanup
EXAMPLE-9:
Command Line Interface to run the test with incremental_capacity by raising incremental flag
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --incremental
EXAMPLE-10:
Command Line Interface to run the test with expected pass/fail value
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--device_list 1.11,1.12,1.360,1.400 --expected_passfail_value 5
EXAMPLE-11:
Command Line Interface to run the test with expected pass/fail csv for individual device
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--device_list 1.11,1.12,1.360,1.400 --device_csv_name clab.csv
EXAMPLE-12:
Command Line Interface to run download scenario for Real clients with Groups and Profiles
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 100000000 --upload 100000000
--traffic_type lf_udp --report_timer 1s --device_csv clab.csv --file_name gr204 --group_name g3,g4 --profile_name n1,n1
EXAMPLE-13:
Command Line Interface to run download scenario for Real clients with device list and config
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000
--traffic_type lf_udp --ssid NETGEAR_2G_wpa2 --passwd Password@123 --security wpa2 --config --device_list 1.10,1.11,1.12
EXAMPLE-14:
Command Line Interface to run download scenario with desired resources at desired points using robo
python3 lf_interop_throughput.py --mgr 192.168.207.78 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--robot_ip 192.168.204.101 --coordinate 3,4
EXAMPLE-15:
Command Line Interface to run download scenario with desired resources at desired points with rotations using robo
python3 lf_interop_throughput.py --mgr 192.168.207.78 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--robot_ip 192.168.204.101 --coordinate 3,4 --rotation 30,60,90
EXAMPLE-16:
Command Line Interface to run download scenario with desired resources at desired points with bandsteering using robo
python3 lf_interop_throughput.py --mgr 192.168.207.78 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--robot_ip 192.168.204.144 --coordinate 3,4 --do_bandsteering --total_cycles 2 --bssids 94:A6:7E:74:26:33,94:A6:7E:74:26:22
TO PERFORM INTEROPABILITY TEST:
EXAMPLE-1:
Command Line Interface to run download scenario with desired resources
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --do_interopability --device_list 1.10,1.12 # noqa: E501
EXAMPLE-2:
Command Line Interface to run bi-directional scenario in Interop web-GUI
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --security wpa2 --upstream_port eth1 --test_duration 1m --download 1000000 --upload 1000000
--traffic_type lf_udp --do_interopability --dowebgui
EXAMPLE-3:
Command Line Interface to run the test with precleanup
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --do_interopability --precleanup
EXAMPLE-4:
Command Line Interface to run the test with postcleanup
python3 lf_interop_throughput.py --mgr 192.168.214.219 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp --do_interopability --postcleanup
EXAMPLE-5:
Command Line Interface to run the test with expected pass/fail value
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--device_list 1.11,1.12,1.360,1.400 --expected_passfail_value 5 --do_interopability
EXAMPLE-6:
Command Line Interface to run the test with expected pass/fail csv for individual device
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--device_list 1.11,1.12,1.360,1.400 --device_csv_name clab.csv --do_interopability
EXAMPLE-7:
Command Line Interface to run download scenario for Real clients with Groups and Profiles
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 100000000 --upload 100000000
--traffic_type lf_udp --report_timer 1s --device_csv clab.csv --file_name gr204 --group_name g3,g4 --profile_name n1,n1 --do_interopability
EXAMPLE-8:
Command Line Interface to run download scenario for Real clients with device list and config
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_udp
--ssid NETGEAR_2G_wpa2 --passwd Password@123 --security wpa2 --config --device_list 1.10,1.11,1.12 --do_interopability
EXAMPLE-9:
Command Line Interface to run the test with individual configuration
python3 lf_interop_throughput.py --mgr 192.168.204.74 --mgr_port 8080 --upstream_port eth0 --test_duration 30s --traffic_type lf_udp --ssid NETGEAR_2G_wpa2
--passwd Password@123 --security wpa2 --do_interopability --device_list 1.15,1.400 --download 10000000 --interopability_config
TO PERFORM TEST WITH IOT:
EXAMPLE-1:
Command Line Interface to run the Test along with IOT without device list
python3 -u lf_interop_throughput.py --mgr 192.168.204.75 --upstream_port eth1 --ssid "" --passwd "" --traffic_type lf_tcp --download 10000000 --upload 0 --test_duration 60
--packet_size 1500 --load_type wc_per_client_load --precleanup --postcleanup --iot_test --iot_iterations 1 --iot_delay 5 --iot_testname "testname"
EXAMPLE-2:
Command Line Interface to run the Test along with IOT with device list
python3 -u lf_interop_throughput.py --mgr 192.168.204.75 --upstream_port eth1 --ssid "" --passwd "" --traffic_type lf_tcp --download 10000000 --upload 0
--test_duration 60 --device_list 1.400 --test_name testname --packet_size 1500 --load_type wc_per_client_load --precleanup --postcleanup --iot_test --iot_iterations 1
--iot_delay 5 --iot_device_list "switch.smart_plug_1_socket_1,switch.smart_plug_2_socket_1" --iot_testname "testname" --iot_increment "1,5"
SCRIPT_CLASSIFICATION : Test
SCRIPT_CATEGORIES: Performance, Functional, Report Generation
NOTES:
1.Use './lf_interop_throughput.py --help' to see command line usage and options
2.Please enter the download or upload rate in bps
3.Inorder to perform intended load please pass 'wc_intended_load' in load_type argument.
4.Please pass incremental values seperated by commas ',' in incremental_capacity argument
5.Please enter packet_size in bps.
6.After passing cli, a list will be displayed on terminal which contains available resources to run test.
The following sentence will be displayed
Enter the desired resources to run the test:
Please enter the port numbers seperated by commas ','.
Example:
Enter the desired resources to run the test:1.10,1.11,1.12,1.13,1.202,1.203,1.303
STATUS: BETA RELEASE
VERIFIED_ON:
Working date - 26/07/2024
Build version - 5.4.8
kernel version - 6.2.16+
License: Free to distribute and modify. LANforge systems must be licensed.
Copyright (C) 2020-2026 Candela Technologies Inc.
"""
import sys
import os
import pandas as pd
import importlib
import logging
import json
import shutil
import asyncio
import csv
import matplotlib.pyplot as plt
import re
import threading
from collections import OrderedDict
from lf_base_robo import RobotClass
from collections import Counter
logger = logging.getLogger(__name__)
if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
if 'py-json' not in sys.path:
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
import time # noqa: E402
import argparse # noqa: E402
from LANforge import LFUtils # noqa: F401 E402
realm = importlib.import_module("py-json.realm")
Realm = realm.Realm
from lf_report import lf_report # noqa: E402
from lf_graph import lf_bar_graph_horizontal, lf_bar_graph # noqa: E402
# from lf_graph import lf_line_graph # noqa: E402
from datetime import datetime, timedelta # noqa: E402
DeviceConfig = importlib.import_module("py-scripts.DeviceConfig")
lf_logger_config = importlib.import_module("py-scripts.lf_logger_config")
iot_scripts_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../local/interop-webGUI/IoT/scripts/"))
if os.path.exists(iot_scripts_path):
sys.path.insert(0, iot_scripts_path)
from test_automation import Automation # noqa: E402
class Throughput(Realm):
def __init__(self,
tos,
ssid=None,
security=None,
password=None,
name_prefix=None,
upstream=None,
num_stations=10,
host="localhost",
port=8080,
test_name=None,
device_list=None,
result_dir=None,
ap_name="",
traffic_type=None,
incremental_capacity=None,
incremental=False,
# packet_size=None,
report_timer="2m",
direction="",
side_a_min_rate=0, side_a_max_rate=0,
side_b_min_rate=56, side_b_max_rate=0,
side_a_min_pdu=-1, side_b_min_pdu=-1,
number_template="00000",
test_duration="2m",
use_ht160=False,
load_type=None,
_debug_on=False,
dowebgui=False,
precleanup=False,
do_interopability=False,
get_live_view=False,
total_floors=0,
interopability_config=False,
ip="localhost",
csv_direction='',
device_csv_name=None,
expected_passfail_value=None,
file_name=None, group_name=None, profile_name=None,
eap_method=None,
eap_identity=None,
ieee80211=None,
ieee80211u=None,
ieee80211w=None,
enable_pkc=None,
bss_transition=None,
power_save=None,
disable_ofdma=None,
roam_ft_ds=None,
key_management=None,
pairwise=None,
private_key=None,
ca_cert=None,
client_cert=None,
pk_passwd=None,
pac_file=None,
wait_time=60,
config=False,
user_list=None, real_client_list=None, real_client_list1=None, hw_list=None, laptop_list=None, android_list=None, mac_list=None, windows_list=None, linux_list=None,
total_resources_list=None, working_resources_list=None, hostname_list=None, username_list=None, eid_list=None,
devices_available=None, input_devices_list=None, mac_id1_list=None, mac_id_list=None, overall_avg_rssi=None,
coordinate_list=None, rotation_enabled=None, robo_ip=None, angle_list=None, do_bandsteering=False, total_cycles=1, bssids=None, duration_to_skip=None):
super().__init__(lfclient_host=host,
lfclient_port=port)
self.ssid_list = []
self.signal_list = []
self.channel_list = []
self.mode_list = []
self.link_speed_list = []
self.background_run = None
self.stop_test = False
self.upstream = upstream
self.host = host
self.port = port
self.test_name = test_name
self.device_list = device_list if device_list is not None else []
self.result_dir = result_dir
self.ssid = ssid
self.security = security
self.password = password
self.num_stations = num_stations
self.ap_name = ap_name
self.traffic_type = traffic_type
self.direction = direction
self.tos = tos.split(",")
self.number_template = number_template
self.incremental_capacity = incremental_capacity
self.load_type = load_type
self.debug = _debug_on
self.name_prefix = name_prefix
self.test_duration = test_duration
self.report_timer = report_timer
self.station_profile = self.new_station_profile()
self.cx_profile = self.new_l3_cx_profile()
self.station_profile.lfclient_url = self.lfclient_url
self.station_profile.ssid = self.ssid
self.station_profile.ssid_pass = self.password
self.station_profile.security = self.security
self.station_profile.number_template_ = self.number_template
self.station_profile.debug = self.debug
self.station_profile.use_ht160 = use_ht160
self.cx_profile.host = self.host
self.cx_profile.port = self.port
self.cx_profile.name_prefix = self.name_prefix
self.cx_profile.side_a_min_bps = side_a_min_rate
self.cx_profile.side_a_max_bps = side_a_max_rate
self.cx_profile.side_b_min_bps = side_b_min_rate
self.cx_profile.side_b_max_bps = side_b_max_rate
self.cx_profile.side_a_min_pdu = side_a_min_pdu
self.cx_profile.side_b_min_pdu = side_b_min_pdu
self.hw_list = hw_list if hw_list is not None else []
self.laptop_list = laptop_list if laptop_list is not None else []
self.android_list = android_list if android_list is not None else []
self.mac_list = mac_list if mac_list is not None else []
self.windows_list = windows_list if windows_list is not None else []
self.linux_list = linux_list if linux_list is not None else []
self.total_resources_list = total_resources_list if total_resources_list is not None else []
self.working_resources_list = working_resources_list if working_resources_list is not None else []
self.hostname_list = hostname_list if hostname_list is not None else []
self.username_list = username_list if username_list is not None else []
self.eid_list = eid_list if eid_list is not None else []
self.devices_available = devices_available if devices_available is not None else []
self.input_devices_list = input_devices_list if input_devices_list is not None else []
self.real_client_list = real_client_list if real_client_list is not None else []
self.real_client_list1 = real_client_list1 if real_client_list1 is not None else []
self.user_list = user_list if user_list is not None else []
self.mac_id_list = mac_id_list if mac_id_list is not None else []
self.mac_id1_list = mac_id1_list if mac_id1_list is not None else []
self.overall_avg_rssi = overall_avg_rssi if overall_avg_rssi is not None else []
self.dowebgui = dowebgui
self.do_interopability = do_interopability
self.get_live_view = get_live_view
self.total_floors = total_floors
self.ip = ip
self.device_found = False
self.gave_incremental = False
self.incremental = incremental
self.precleanup = precleanup
self.csv_direction = csv_direction
self.expected_passfail_value = expected_passfail_value
self.device_csv_name = device_csv_name
self.file_name = file_name
self.group_name = group_name
self.profile_name = profile_name
# for advanced config
self.eap_method = eap_method
self.eap_identity = eap_identity
self.ieee80211 = ieee80211
self.ieee80211u = ieee80211u
self.ieee80211w = ieee80211w
self.enable_pkc = enable_pkc
self.bss_transition = bss_transition
self.power_save = power_save
self.disable_ofdma = disable_ofdma
self.roam_ft_ds = roam_ft_ds
self.key_management = key_management
self.pairwise = pairwise
self.private_key = private_key
self.ca_cert = ca_cert
self.client_cert = client_cert
self.pk_passwd = pk_passwd
self.pac_file = pac_file
self.wait_time = wait_time
self.config = config
self.configdevices = {}
self.group_device_map = {}
self.config_dict = {}
self.configured_devices_check = {}
self.interopability_config = interopability_config
self.do_bandsteering = do_bandsteering
self.total_cycles = total_cycles
self.bssids = bssids if bssids else []
# Variables related to Robo
self.robo_ip = robo_ip
self.angle_list = angle_list if angle_list else [0]
if self.robo_ip:
self.robot = RobotClass(robo_ip=self.robo_ip, angle_list=self.angle_list)
self.rotation_enabled = rotation_enabled
self.coordinate_list = coordinate_list if coordinate_list else [0]
self.current_coordinate = None
self.current_angle = None
self.charge_point_name = None
self.coordinates_completed = []
self.battery_log = {}
self.robot.time_to_reach = int(duration_to_skip) * 60
self.robot.coordinate_list = self.coordinate_list
self.robot.total_cycles = self.total_cycles
def perform_robo(self, args, clients_to_run):
"""
Execute robot-assisted throughput testing across multiple coordinates and angles.
The robot navigates to each configured coordinate, monitors battery status,
optionally performs angle-based rotation,on selected clients and generates
final performance reports.
Args:
args (Namespace): Parsed command-line arguments
clients_to_run (list): List of client identifiers used for throughput testing.
Returns:
None
"""
if args.dowebgui and args.coordinate is not None:
base_dir = os.path.dirname(os.path.dirname(args.result_dir))
nav_data = os.path.join(base_dir, 'nav_data.json') # To generate nav_data.json in webgui folder
with open(nav_data, "w") as file:
json.dump({}, file)
self.robot.nav_data_path = nav_data
self.robot.runtime_dir = args.result_dir
self.robot.ip = args.mgr
self.robot.testname = args.test_name
iterations_before_test_stopped_by_user = []
test_stopped_by_user = False
# if band steering is enabled
if self.do_bandsteering:
# checking the battery status of robot before moving to a point
self.robot.wait_for_battery()
self.robot.total_cycles = self.total_cycles
self.robot.coordinate_list = self.coordinate_list
# Fetch coordinates list based on cycles
coordinate_list_with_robo = self.robot.get_coordinates_list()
if (len(coordinate_list_with_robo) == 0):
logger.info("Test aborted")
exit(1)
self.robot.do_bandsteering = True
is_device_configured = True
columns = []
to_run_cxs, to_run_cxs_len, created_cx_lists_keys, incremental_capacity_list = self.get_incremental_capacity_list()
if self.load_type == "wc_intended_load":
# Perform intended load for the current iteration
self.perform_intended_load(0, incremental_capacity_list)
for client in clients_to_run:
columns.extend([
f'Download{client}', f'Upload{client}',
f'Rx % Drop {client}', f'Tx % Drop{client}',
f'Average RTT {client}', f'RSSI {client}',
f'Tx-Rate {client}', f'Rx-Rate {client}', f'BSSID {client}', f'Channel {client}'
])
columns.extend([
'Overall Download', 'Overall Upload',
'Overall Rx % Drop', 'Overall Tx % Drop',
'Iteration', 'TIMESTAMP', 'Start_time',
'End_time', 'Remaining_Time',
'Incremental_list', 'status', 'Robot X', 'Robot Y', 'From Coordinate', 'To Coordinate'
])
individual_df = pd.DataFrame(columns=columns)
device_names = []
# start cx
for cx in to_run_cxs:
self.start_specific(cx)
device_names = created_cx_lists_keys[:to_run_cxs_len[-1][-1]]
overall_start_time = datetime.now()
overall_end_time = overall_start_time + timedelta(seconds=int(args.test_duration) * len(incremental_capacity_list))
curr_cycle = 1
logger.info("Current Cycle: {}".format(curr_cycle))
# Iterate through all the points and monitoring throughput,bandsteering stats and as well as robot position
for coord in coordinate_list_with_robo:
pause, stopped = self.robot.wait_for_battery(lambda: self.monitor(
0,
individual_df,
device_names,
incremental_capacity_list,
overall_start_time,
overall_end_time,
is_device_configured
)
)
if stopped:
break
matched, abort, all_dataframes = self.robot.move_to_coordinate(
coord,
monitor_function=lambda: self.monitor(
0,
individual_df,
device_names,
incremental_capacity_list,
overall_start_time,
overall_end_time,
is_device_configured
)
)
if coord == self.coordinate_list[0]:
curr_cycle += 1
if curr_cycle > int(self.total_cycles):
logger.info("Completed all {} cycles".format(self.total_cycles))
else:
logger.info("current cycle {}".format(curr_cycle))
if abort:
break
if not matched:
continue
# To add last entry in the csv
all_dataframes = pd.concat(
[df for df in all_dataframes if isinstance(df, pd.DataFrame)],
ignore_index=True
)
last_idx = all_dataframes.index[-1]
all_dataframes.loc[last_idx, "status"] = "Stopped"
last_row_df = all_dataframes.loc[[last_idx]]
if self.dowebgui:
last_row_df.to_csv(f"{args.result_dir}/throughput_data.csv", mode="a", header=False, index=False)
self.stop()
if args.postcleanup:
self.cleanup()
iterations_before_test_stopped_by_user.append(0)
self.generate_report(list(set(iterations_before_test_stopped_by_user)), incremental_capacity_list, data=all_dataframes, data1=to_run_cxs_len, report_path=self.result_dir)
if self.dowebgui:
# copying to home directory i.e home/user_name
self.copy_reports_to_home_dir()
exit(1)
# Loop through the coordinate list when coordinates are specified.
for coord in self.coordinate_list:
# checking the battery status of robot before moving to a point
pause_coord, test_stopped_by_user = self.robot.wait_for_battery()
if test_stopped_by_user:
break
# move the robot to specified coordinate and tracking the current coordinate and set of coordinates completed
matched, abort = self.robot.move_to_coordinate(coord)
if matched:
self.current_coordinate = coord
self.coordinates_completed.append(coord)
logger.info("Reached the point {}".format(coord))
if abort:
break
# To skip a point if there is an obstacle
if not matched:
continue
individual_dataframe_column = []
to_run_cxs, to_run_cxs_len, created_cx_lists_keys, incremental_capacity_list = self.get_incremental_capacity_list()
for i in range(len(clients_to_run)):
# Extend individual_dataframe_column with dynamically generated column names
individual_dataframe_column.extend([f'Download{clients_to_run[i]}', f'Upload{clients_to_run[i]}', f'Rx % Drop {clients_to_run[i]}',
f'Tx % Drop{clients_to_run[i]}', f'Average RTT {clients_to_run[i]}', f'RSSI {clients_to_run[i]}',
f'Tx-Rate {clients_to_run[i]} ', f'Rx-Rate {clients_to_run[i]}'])
if self.rotation_enabled:
individual_dataframe_column.extend(['Overall Download', 'Overall Upload', 'Overall Rx % Drop ', 'Overall Tx % Drop', 'Iteration',
'TIMESTAMP', 'Start_time', 'End_time', 'Remaining_Time', 'Incremental_list', 'Angle', 'status'])
else:
individual_dataframe_column.extend(['Overall Download', 'Overall Upload', 'Overall Rx % Drop ', 'Overall Tx % Drop', 'Iteration',
'TIMESTAMP', 'Start_time', 'End_time', 'Remaining_Time', 'Incremental_list', 'status'])
individual_df = pd.DataFrame(columns=individual_dataframe_column)
overall_start_time = datetime.now()
overall_end_time = overall_start_time + timedelta(seconds=int(args.test_duration) * len(incremental_capacity_list))
for i in range(len(to_run_cxs)):
is_device_configured = True
if args.do_interopability:
# To get resource of device under test in interopability
device_to_run_resource = self.extract_digits_until_alpha(to_run_cxs[i][0])
# Check the load type specified by the user
if args.load_type == "wc_intended_load":
# Perform intended load for the current iteration
self.perform_intended_load(i, incremental_capacity_list)
if i != 0:
# Stop throughput testing if not the first iteration
self.stop()
# Start specific connections for the current iteration
self.start_specific(created_cx_lists_keys[:incremental_capacity_list[i]])
else:
if args.do_interopability and i != 0:
self.stop_specific(to_run_cxs[i - 1])
time.sleep(5)
if args.interopability_config:
if args.do_interopability and i == 0:
# To disconnect all the selected devices at the starting selected
self.disconnect_all_devices()
if args.do_interopability and "iOS" not in to_run_cxs[i][0]:
logger.info("Configuring device of resource{}".format(to_run_cxs[i][0]))
# To configure device which is under test
is_device_configured = self.configure_specific([device_to_run_resource])
if is_device_configured:
self.start_specific(to_run_cxs[i])
# Determine device names based on the current iteration
device_names = created_cx_lists_keys[:to_run_cxs_len[i][-1]]
# Monitor throughput and capture all dataframes and test stop status
all_dataframes, test_stopped_by_user = self.monitor_for_robo(i, individual_df, device_names, incremental_capacity_list, overall_start_time, overall_end_time, is_device_configured)
if args.do_interopability and "iOS" not in to_run_cxs[i][0] and args.interopability_config:
# Disconnecting device after running the test
self.disconnect_all_devices([device_to_run_resource])
# Check if the test was stopped by the user
if test_stopped_by_user is False:
# Append current iteration index to iterations_before_test_stopped_by_user
iterations_before_test_stopped_by_user.append(i)
else:
# Append current iteration index to iterations_before_test_stopped_by_user
iterations_before_test_stopped_by_user.append(i)
break
# logger.info("connections download {}".format(connections_download))
# logger.info("connections upload {}".format(connections_upload))
self.stop()
if args.postcleanup:
self.cleanup()
# Clear navigation status fields in nav_data.json when the test completes from Web UI
if args.dowebgui:
with open(nav_data, 'r') as x:
navdata = json.load(x)
navdata['status'] = ''
navdata['Canbee_location'] = ''
navdata['Canbee_angle'] = ''
navdata['Test_status'] = 'Completed'
with open(nav_data, 'w') as x:
json.dump(navdata, x, indent=4)
self.generate_report_robo(list(set(iterations_before_test_stopped_by_user)), incremental_capacity_list, data=all_dataframes, data1=to_run_cxs_len, report_path=self.result_dir)
if self.dowebgui:
# copying to home directory i.e home/user_name
self.copy_reports_to_home_dir()
def os_type(self):
"""
Determines OS type of selected devices.
"""
response = self.json_get("/resource/all")
if "resources" not in response.keys():
logger.error("There are no real devices.")
exit(1)
for key, value in response.items():
if key == "resources":
for element in value:
for _, b in element.items():
if "Apple" in b['hw version']:
if b['kernel'] == '':
self.hw_list.append('iOS')
else:
self.hw_list.append(b['hw version'])
else:
self.hw_list.append(b['hw version'])
# print(self.hw_list)
for hw_version in self.hw_list:
if "Win" in hw_version:
self.windows_list.append(hw_version)
elif "Linux" in hw_version:
self.linux_list.append(hw_version)
elif "Apple" in hw_version:
self.mac_list.append(hw_version)
elif "iOS" in hw_version:
self.mac_list.append(hw_version)
else:
if hw_version != "":
self.android_list.append(hw_version)
self.laptop_list = self.windows_list + self.linux_list + self.mac_list
def disconnect_all_devices(self, devices_to_disconnect=None):
"""
Disconnects either all devices or a specific list of devices from Wi-Fi networks.
"""
obj = DeviceConfig.DeviceConfig(lanforge_ip=self.host, file_name=self.file_name, wait_time=self.wait_time)
# all_devices = obj.get_all_devices()
# GET ANDROIDS FROM DEVICE LIST
adb_obj = DeviceConfig.ADB_DEVICES(lanforge_ip=self.host)
async def do_disconnect():
all_devices = obj.get_all_devices()
# TO DISCONNECT ALL DEVICES
if devices_to_disconnect is None:
android_resources = [d for d in all_devices if d.get('os') == 'Android' and d.get('eid') in self.device_list]
if len(android_resources) > 0:
# TO STOP APP FOR ALL DEVICES FOR ANDROIDS
await adb_obj.stop_app(port_list=android_resources)
# TO FORGET ALL NETWORKS FOR ALL OS TYPES
await obj.connectivity(device_list=self.device_list, wifi_config=self.config_dict, disconnect=True)
if len(android_resources) > 0:
adb_obj.set_wifi_state(port_list=android_resources, state='disable')
# TO DISCONNECT SPECIFIC DEVICES
else:
android_resources = [d for d in all_devices if d.get('os') == 'Android' and d.get('eid') in devices_to_disconnect]
if len(android_resources) > 0:
# To disable stop app for androids
await adb_obj.stop_app(port_list=android_resources)
await obj.connectivity(device_list=devices_to_disconnect, wifi_config=self.config_dict, disconnect=True)
if len(android_resources) > 0:
# To disable wifi for androids
adb_obj.set_wifi_state(port_list=android_resources, state='disable')
asyncio.run(do_disconnect())
def configure_specific(self, device_to_configure_list):
"""
Configure specific devices using the provided list of device IDs or names.
"""
obj = DeviceConfig.DeviceConfig(lanforge_ip=self.host, file_name=self.file_name, wait_time=self.wait_time)
all_devices = obj.get_all_devices()
android_resources = [d for d in all_devices if (d.get('os') == 'Android') and d.get('eid') in device_to_configure_list]
laptop_resources = [d for d in all_devices if (d.get('os') != 'Android') and '1.' + d.get('resource') in device_to_configure_list]
devices_connected = asyncio.run(obj.connectivity(device_list=device_to_configure_list, wifi_config=self.config_dict))
if len(devices_connected) > 0:
if android_resources:
self.configured_devices_check[android_resources[0]['user-name']] = True
elif laptop_resources:
self.configured_devices_check[laptop_resources[0]['hostname']] = True
return True
else:
if android_resources:
self.configured_devices_check[android_resources[0]['user-name']] = False
elif laptop_resources:
self.configured_devices_check[laptop_resources[0]['hostname']] = False
return False
def extract_digits_until_alpha(self, s):
"""
Extracts digits (including decimals) from the start of a string until the first alphabet.
"""
match = re.match(r'^[\d.]+', s)
return match.group() if match else ''
def phantom_check(self):
"""
Checks for non-phantom resources and ports, categorizes them, and prepares a list of available devices for testing.
"""
port_eid_list, same_eid_list, original_port_list = [], [], []
interop_response = self.json_get("/adb")
obj = DeviceConfig.DeviceConfig(lanforge_ip=self.host, file_name=self.file_name, wait_time=self.wait_time)
upstream_port_ip = self.change_port_to_ip(self.upstream)
config_devices = {}
self.config_dict = {
'ssid': self.ssid,
'passwd': self.password,
'enc': self.security,
'eap_method': self.eap_method,
'eap_identity': self.eap_identity,
'ieee80211': self.ieee80211,
'ieee80211u': self.ieee80211u,
'ieee80211w': self.ieee80211w,
'enable_pkc': self.enable_pkc,
'bss_transition': self.bss_transition,
'power_save': self.power_save,
'disable_ofdma': self.disable_ofdma,
'roam_ft_ds': self.roam_ft_ds,
'key_management': self.key_management,
'pairwise': self.pairwise,
'private_key': self.private_key,
'ca_cert': self.ca_cert,
'client_cert': self.client_cert,
'pk_passwd': self.pk_passwd,
'pac_file': self.pac_file,
'server_ip': upstream_port_ip
}
# When groups and profiles specified for configuration
if self.group_name and self.file_name and self.device_list == [] and self.profile_name:
selected_groups = self.group_name.split(',')
selected_profiles = self.profile_name.split(',')
for i in range(len(selected_groups)):
config_devices[selected_groups[i]] = selected_profiles[i]
self.configdevices = config_devices
obj.initiate_group()
self.group_device_map = obj.get_groups_devices(data=selected_groups, groupdevmap=True)
# Configuration of group of devices for the corresponding profiles
self.device_list = asyncio.run(obj.connectivity(config_devices, upstream=upstream_port_ip))
# Configuration of devices with SSID,Password and Security when device list is specified
elif self.device_list != []:
all_devices = obj.get_all_devices()
self.device_list = self.device_list.split(',')
if self.config:
self.device_list = asyncio.run(obj.connectivity(device_list=self.device_list, wifi_config=self.config_dict))
# Configuration of devices with SSID , Password and Security when the device list is not specified
elif self.device_list == [] and self.config:
all_devices = obj.get_all_devices()
device_list = []
for device in all_devices:
if device["type"] == 'laptop':
device_list.append(device["shelf"] + '.' + device["resource"] + " " + device["hostname"])
else:
device_list.append(device["shelf"] + '.' + device["resource"] + " " + device["serial"])
logger.info("AVAILABLE RESOURCES {}".format(device_list))
self.device_list = input("Select the desired resources to run the test:").split(',')
if self.config:
self.device_list = asyncio.run(obj.connectivity(device_list=self.device_list, wifi_config=self.config_dict))
# Retrieve all resources from the LANforge
response = self.json_get("/resource/all")
if "resources" not in response.keys():
logger.error("There are no real devices.")
exit(1)
# Iterate over the response to categorize resources
for key, value in response.items():
if key == "resources":
for element in value:
for (_, b) in element.items():
# Check if the resource is not phantom
if b['phantom'] is False:
self.working_resources_list.append(b["hw version"])
# Categorize based on hw version (type of device)
if "Win" in b['hw version']:
self.eid_list.append(b['eid'])
self.windows_list.append(b['hw version'])
self.devices_available.append(b['eid'] + " " + 'Win' + " " + b['hostname'])
elif "Linux" in b['hw version']:
if 'ct' not in b['hostname']:
if 'lf' not in b['hostname']:
self.eid_list.append(b['eid'])
self.linux_list.append(b['hw version'])
self.devices_available.append(b['eid'] + " " + 'Lin' + " " + b['hostname'])
elif "Apple" in b['hw version']:
if b['kernel'] == '':
self.eid_list.append(b['eid'])
self.mac_list.append(b['hw version'])
if "devices" in interop_response.keys():
interop_devices = interop_response['devices']
# Extract usernames of devices that match the current eid
if len([v['user-name'] for d in interop_devices for k, v in d.items() if v.get('resource-id') == b['eid']]) == 0:
self.devices_available.append(b['eid'] + " " + 'iOS' + " " + b['hostname'])
# If username is found
else:
ios_username = [v['user-name'] for d in interop_devices for k, v in d.items() if v.get('resource-id') == b['eid']][0]
self.devices_available.append(b['eid'] + " " + 'iOS' + " " + ios_username)
else:
self.devices_available.append(b['eid'] + " " + 'iOS' + " " + b['hostname'])
else:
self.eid_list.append(b['eid'])
self.mac_list.append(b['hw version'])
# self.hostname_list.append(b['eid']+ " " +b['hostname'])
self.devices_available.append(b['eid'] + " " + 'Mac' + " " + b['hostname'])
else:
self.eid_list.append(b['eid'])
self.android_list.append(b['hw version'])
self.devices_available.append(b['eid'] + " " + 'android' + " " + b['user'])
# Retrieve all ports from the endpoint
response_port = self.json_get("/port/all")
if "interfaces" not in response_port.keys():
logger.error("Error: 'interfaces' key not found in port data")
exit(1)
# mac_id1_list=[]
# Iterate over port information to filter and categorize ports
for interface in response_port['interfaces']:
for port, port_data in interface.items():
# Select valid Wi-Fi ports: must be non-phantom, parent dev 'wiphy0', alias not 'p2p0';
# include down ports only when interopability_config is enabled
if (not port_data['phantom'] and ((not self.interopability_config and not port_data['down']) or (
self.interopability_config)) and port_data['parent dev'] == "wiphy0" and port_data['alias'] != 'p2p0'):
# Check if the port's parent device matches with an eid in the eid_list
for id in self.eid_list:
if id + '.' in port:
original_port_list.append(port)
port_eid_list.append(str(self.name_to_eid(port)[0]) + '.' + str(self.name_to_eid(port)[1]))
self.mac_id1_list.append(str(self.name_to_eid(port)[0]) + '.' + str(self.name_to_eid(port)[1]) + ' ' + port_data['mac'])
# Check for matching eids between eid_list and port_eid_list
for i in range(len(self.eid_list)):
for j in range(len(port_eid_list)):
if self.eid_list[i] == port_eid_list[j]:
same_eid_list.append(self.eid_list[i])
same_eid_list = [_eid + ' ' for _eid in same_eid_list]
for eid in same_eid_list:
for device in self.devices_available:
if eid in device:
self.user_list.append(device)
configure_list = []
if len(self.device_list) == 0 and self.config is False and self.group_name is None:
logger.info("AVAILABLE DEVICES TO RUN TEST : {}".format(self.user_list))
self.device_list = input("Select the desired resources to run the test:").split(',')
# If self.device_list is provided, check availability against devices_available
if len(self.device_list) != 0:
devices_list = self.device_list
available_list = []
not_available = []
# Iterate over each input device in devices_list
for input_device in devices_list:
found = False
# Check if input_device exists in devices_available
for device in self.devices_available:
if input_device + " " in device:
available_list.append(input_device)
found = True
break
if found is False:
not_available.append(input_device)
if self.device_list != "all":
logger.warning(input_device + " is not available to run the test")
for dev in available_list:
for user in self.user_list:
if dev == user.split(" ")[0]:
if user not in configure_list:
configure_list.append(user)
# If available_list is not empty, log info and set self.device_found to True
if len(available_list) > 0:
logger.info("Test is intiated on these devices {}".format(available_list))
devices_list = ','.join(available_list)
self.device_found = True
else:
devices_list = ""
self.device_found = False
if self.device_list != "all":
logger.warning("Test can not be initiated on any selected devices")
exit(1)
else:
devices_list = ","
# If no devices are selected or only comma is entered, log an error and return False
if devices_list == "all":
devices_list = ""
if (devices_list == ","):
logger.error("Selected Devices are not available in the lanforge")
return False, self.real_client_list
# Split devices_list into resource_eid_list
resource_eid_list = devices_list.split(',')
logger.info("devices list {} {}".format(devices_list, resource_eid_list))
resource_eid_list2 = [eid + ' ' for eid in resource_eid_list]
# Create resource_eid_list1 by appending dot to each eid in resource_eid_list
resource_eid_list1 = [resource + '.' for resource in resource_eid_list]
logger.info("resource eid list {}".format(resource_eid_list1))
# print("resource_eid_list2",resource_eid_list2)
# Iterate over resource_eid_list1 and original_port_list to populate input_devices_list
for eid in resource_eid_list1:
for ports_m in original_port_list:
if eid in ports_m:
self.input_devices_list.append(ports_m)
logger.info("INPUT DEVICES LIST {}".format(self.input_devices_list))
for i in resource_eid_list2:
for j in range(len(self.user_list)):
if i in self.user_list[j]:
self.real_client_list.append(self.user_list[j])
self.real_client_list1.append(self.user_list[j][:25])
# print("real_client_list",self.real_client_list)
# print("real_client_list1",self.real_client_list1)
self.num_stations = len(self.real_client_list)
# Iterate over resource_eid_list2 and mac_id1_list to populate mac_id_list
for eid in resource_eid_list2:
for i in self.mac_id1_list:
if eid in i:
self.mac_id_list.append(i.strip(eid + ' '))
# Runtime data for webui for configuration
if self.dowebgui and not self.interopability_config:
if len(configure_list) == 0:
logger.info("No device is available to run the test")
obj = {
"status": "Stopped",
"configuration_status": "configured"
}
self.updating_webui_runningjson(obj)
return False, self.real_client_list