Repository navigation
Expand file tree
/
Copy pathlf_interop_throughput.py
More file actions
executable file
·5654 lines (5034 loc) · 320 KB
/
Copy pathlf_interop_throughput.py
File metadata and controls
executable file
·5654 lines (5034 loc) · 320 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
EXAMPLE-17:
Command Line Interface to run download scenario with a background ping on the real clients
python3 lf_interop_throughput.py --mgr 192.168.207.75 --mgr_port 8080 --upstream_port eth1 --test_duration 1m --download 1000000 --traffic_type lf_tcp
--device_list 1.20,1.59,1.65 --enable_bg_ping --bg_ping_target 1.1.eth1
EXAMPLE-18:
Command Line Interface to run download scenario while the robot moves through the points (continuous robot run, no band steering)
python3 lf_interop_throughput.py --mgr 192.168.207.78 --mgr_port 8080 --upstream_port eth1 --download 1000000 --traffic_type lf_udp
--robot_ip 192.168.204.144 --coordinate 3,4 --measurement_mode continuous --total_cycles 2
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_interop_ping = importlib.import_module("py-scripts.lf_interop_ping")
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
_last_appended_rows = {}
def append_latest_row(dataframe, csv_path):
"""Append a new last row once, without rewriting the CSV."""
if dataframe.empty:
return
latest_row = dataframe.tail(1)
row_signature = latest_row.to_csv(index=False, header=False)
csv_path = os.path.abspath(csv_path)
if _last_appended_rows.get(csv_path) == row_signature:
return
write_header = not os.path.exists(csv_path) or os.path.getsize(csv_path) == 0
latest_row.to_csv(csv_path, mode='a', header=write_header, index=False)
_last_appended_rows[csv_path] = row_signature
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, measurement_mode="per_point"):
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
# measurement mode: 'per_point' stops and measures at each point, 'continuous' keeps traffic running while the robot moves.
# Band steering always moves continuously; do_bandsteering only adds the BSSID tracking report.
self.is_continuous_run = do_bandsteering or measurement_mode == "continuous"
self.total_cycles = total_cycles
self.bssids = bssids if bssids else []
# Keep monitoring output stable when a client disconnects or temporarily disappears
# from LANforge. Reports still retain one row per configured client.
# Track CX availability and state changes across monitoring iterations.
self.missing_cx_logged = set()
self.cx_missing_until_running = set()
self.all_devices_stopped = False
self.missing_signal_logged = set()
self.last_cx_status = {}
self.cx_has_run = set()
self.device_issue_log = []
self.actual_monitoring_duration_seconds = 0
self.monitoring_started_with_available_cx = False
self.stopped_by_user = False
self.pre_monitoring_missing_logged = False
self.last_monitor_url = None
self.last_monitor_present_keys = []
self.current_iteration_cxs = []
self.monitor_start_time = None
self.background_ping = None
# 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 = []
# One (coordinate, cycle) tuple per point actually visited, so a
# multi-cycle run can report every visit instead of just the last.
self.coordinate_visits = []
# Points whose measurement ran to the end (not cut short by Stop) - matches the
# webGUI's own "point finished" rule, which decides whether it captures a heatmap.
self.coordinates_finished = []
self.current_cycle = 1
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 record_device_issue(self, device, issue, api_response=""):
"""Append a timestamped device/issue entry, later written out as clients_issue.csv."""
if isinstance(api_response, (dict, list, tuple)):
api_response = json.dumps(api_response, sort_keys=True, default=str)
self.device_issue_log.append({
"Time": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
"Device": device,
"Issue": issue,
"API Response": api_response,
})
def should_stop_for_missing_cx(self, active_cxs=None, timeout=40, poll_interval=5):
"""Return True when every CX active in this iteration fails to recover."""
if self.stop_test:
logger.info("Stop already requested; skipping missing-CX recovery wait.")
return True
active_cxs = set(active_cxs or self.current_iteration_cxs)
if not active_cxs:
return False
if not active_cxs.issubset(self.missing_cx_logged):
return False
logger.warning("All CXs active in the current iteration are missing from monitoring data.")
if not self.wait_for_any_cx_recovery(active_cxs, timeout, poll_interval):
logger.error("No active CX recovered after the retry window; skipping the current iteration.")
if self.is_continuous_run:
self.stop_test = True
self.all_devices_stopped = True
if self.robo_ip:
self.robot.update_nav_data_for_all_cxs_stopped()
return True
return self.stop_test
def wait_for_any_cx_recovery(self, active_cxs, timeout=40, poll_interval=5):
"""Wait briefly for a CX to recover, while honoring WebUI stop requests."""
active_cxs = set(active_cxs)
wait_start = datetime.now()
while (datetime.now() - wait_start).total_seconds() < timeout:
time.sleep(poll_interval)
if self.dowebgui:
running_file = os.path.join(
self.result_dir, "../../Running_instances/{}_{}_running.json".format(self.ip, self.test_name))
try:
with open(running_file, 'r') as file:
if json.load(file).get("status") != "Running":
logger.info("Test was stopped by the user during the CX recovery wait.")
self.stop_test = True
self.stopped_by_user = True
return True
except (FileNotFoundError, json.JSONDecodeError) as error:
logger.warning("Unable to read WebUI test status during CX recovery: %s", error)
self.get_layer3_endp_data(active_cxs)
elapsed = (datetime.now() - wait_start).total_seconds()
if not active_cxs.issubset(self.missing_cx_logged):
logger.info("Device(s) responded again after {:.0f}s, resuming.".format(elapsed))
return True
logger.warning("Still no devices responding after {:.0f}s, retrying...".format(elapsed))
return False
def format_monitoring_duration(self):
"""Render self.actual_monitoring_duration_seconds as an 'Xm Ys' string for logging."""
total_seconds = int(self.actual_monitoring_duration_seconds)
minutes, seconds = divmod(total_seconds, 60)
return "{}m {}s".format(minutes, seconds)
def ensure_monitoring_data_collected(self):
"""Require monitoring data unless the user explicitly stopped the test."""
if not self.monitoring_started_with_available_cx and not self.stopped_by_user:
raise RuntimeError("All active CXs were missing in every iteration; no monitoring data was collected.")
def precheck_all_created_cx_endpoints(self, timeout=40, poll_interval=5):
"""Require at least one created CX endpoint before starting iterations."""
# Validate global endpoint availability independently of CX run state.
all_created_cxs = set(self.cx_profile.created_cx.keys())
if not all_created_cxs:
raise RuntimeError("No CXs were created; monitoring cannot start.")
self.get_layer3_endp_data(all_created_cxs)
if not all_created_cxs.issubset(self.missing_cx_logged):
return True
logger.warning("All created CX endpoints are missing before monitoring; retrying before starting iterations.")
if self.wait_for_any_cx_recovery(all_created_cxs, timeout, poll_interval):
return not self.stop_test
raise RuntimeError(
"All {} created CX(s) are missing before monitoring; no endpoint was available after retries.".format(
len(all_created_cxs)))
def append_stopped_monitor_row(self, dataframe, iteration, incremental_capacity_list, overall_start_time):
"""Append a final Stopped row when WebUI stops during endpoint retries."""
if (not dataframe.empty and 'status' in dataframe.columns and
dataframe.iloc[-1].get('status') == 'Stopped'):
return dataframe
timestamp = datetime.now().strftime("%d/%m %I:%M:%S %p")
row = {column: 0 for column in dataframe.columns}
row.update({'Iteration': iteration + 1, 'TIMESTAMP': timestamp,
'Start_time': overall_start_time.strftime("%d/%m %I:%M:%S %p"),
'End_time': timestamp, 'Remaining_Time': 0,
'Incremental_list': ', '.join(str(n) for n in incremental_capacity_list),
'status': 'Stopped'})
if 'Angle' in dataframe.columns:
row['Angle'] = self.current_angle if self.current_angle is not None else 0
dataframe.loc[len(dataframe)] = [row[column] for column in dataframe.columns]
if self.dowebgui:
runtime_csv = 'overall_throughput.csv' if self.group_name else 'throughput_data.csv'
if self.robo_ip and self.current_coordinate is not None:
runtime_csv = '{}_{}'.format(self.current_coordinate, runtime_csv)
dataframe.to_csv(os.path.join(self.result_dir, runtime_csv), index=False)
return dataframe
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 not self.precheck_all_created_cx_endpoints():
self.stop()
return
# continuous robot run (band steering or measurement mode 'continuous'): traffic runs while the robot moves
if self.is_continuous_run:
# 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("Starting cycle {} of {}".format(curr_cycle, self.total_cycles))
# Iterate through all the points and monitoring throughput,bandsteering stats and as well as robot position
for coord in coordinate_list_with_robo:
if self.stop_test:
logger.info("Stopping continuous robot run because all CXs are missing or the test was stopped.")
break
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 self.stop_test or 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 abort or self.stop_test:
break
if coord == self.coordinate_list[0]:
logger.info("Completed cycle {} of {}".format(curr_cycle, self.total_cycles))
curr_cycle += 1
if curr_cycle > int(self.total_cycles):
logger.info("Completed all {} cycles".format(self.total_cycles))
else:
logger.info("Starting cycle {} of {}".format(curr_cycle, self.total_cycles))
if not matched:
continue
# Generate the report only when monitoring collected rows.
collected_dataframes = [df for df in all_dataframes if isinstance(df, pd.DataFrame)]
if not collected_dataframes or all(df.empty for df in collected_dataframes):
self.stop()
if args.postcleanup:
self.cleanup()
raise RuntimeError("All active CXs were missing; no continuous robot run monitoring data was collected.")
all_dataframes = pd.concat(collected_dataframes, 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()
self.ensure_monitoring_data_collected()
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)
# 0/negative would skip every visit and leave the report inputs unset - run at least one cycle
total_cycles = max(1, int(self.total_cycles)) if self.total_cycles else 1
points_per_cycle = len(self.coordinate_list)
for visit_index, coord in enumerate(self.coordinate_list * total_cycles):
self.current_cycle = (visit_index // points_per_cycle) + 1
self.robot.current_cycle = self.current_cycle
if total_cycles > 1 and visit_index % points_per_cycle == 0:
logger.info("Starting cycle {} of {}".format(self.current_cycle, total_cycles))
if self.stop_test:
logger.info("Stopping robot run because all CXs are missing or the test was stopped.")
break
# 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
if coord not in self.coordinates_completed:
self.coordinates_completed.append(coord)
self.coordinate_visits.append((coord, self.current_cycle))
if total_cycles > 1:
logger.info("Reached the point {} (cycle {} of {})".format(coord, self.current_cycle, total_cycles))
else:
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)
# Multi-cycle: wipe the previous cycle's rows from the per-coordinate CSV the webGUI polls, the moment we arrive
# before CX setup. Its last row still reads status 'Stopped' from the prior visit, so without this
# the webGUI charts that stale data and marks this visit finished before it has run.
if total_cycles > 1 and self.dowebgui and not self.group_name and self.result_dir:
individual_df.to_csv('{}/{}_throughput_data.csv'.format(self.result_dir, coord), index=False)
individual_df.to_csv('{}_throughput_data.csv'.format(coord), index=False)
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)
elif not args.do_interopability and i != 0:
# Reset the previous cumulative CX set before the next capacity.
self.stop_specific(created_cx_lists_keys[:incremental_capacity_list[i - 1]])
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:
# Start cumulative CXs for capacity tests or isolated CXs for interoperability.
if args.do_interopability:
self.start_specific(to_run_cxs[i])
else:
self.start_specific(created_cx_lists_keys[:incremental_capacity_list[i]])
# Determine device names based on the current iteration
if args.do_interopability and args.load_type != "wc_intended_load":
device_names = list(to_run_cxs[i])
else:
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
# Stop the whole robot run on a user stop or an unrecoverable CX loss.
if test_stopped_by_user:
break
if coord not in self.coordinates_finished:
self.coordinates_finished.append(coord)
# Beyond the first cycle, a later revisit to this same coordinate overwrites {coord}_throughput_data.csv
# before generate_report_robo reads it, so preserve this visit's data under a cycle-tagged name.
if total_cycles > 1:
visit_csv = '{}_throughput_data.csv'.format(self.current_coordinate)
if os.path.exists(visit_csv):
shutil.copyfile(visit_csv, 'coordinate_{}_cycle_{}_throughput_data.csv'.format(self.current_coordinate, self.current_cycle))
self.stop()
if args.postcleanup:
self.cleanup()
self.ensure_monitoring_data_collected()
# Mark nav_data.json as completed for the 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'
# Last cycle the robot actually reached a point in - the loop bumps current_cycle before its stop checks,
# so a stop at a cycle boundary must not report the cycle that never started.
navdata['current_cycle'] = self.coordinate_visits[-1][1] if self.coordinate_visits else 1
navdata['total_cycles'] = total_cycles
with open(nav_data, 'w') as x:
json.dump(navdata, x, indent=4)
# Test_status=Completed above only means "measurements done" - the webGUI still has to
# upload the final heatmap screenshots. report_generated tells the webGUI when the report is actually on disk.
report_generated = False
try:
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()
report_generated = True
finally:
if args.dowebgui:
with open(nav_data, 'r') as x:
navdata = json.load(x)
navdata['report_generated'] = report_generated
with open(nav_data, 'w') as x:
json.dump(navdata, x, indent=4)
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 = {