From e75113147f082df4cd6315eaefffecb77b777bdc Mon Sep 17 00:00:00 2001 From: SushantBawiskar <72099364+SushantBawiskar@users.noreply.github.com> Date: Fri, 29 Jan 2021 20:58:14 +0530 Subject: [PATCH] Staging wifi 1337 (#7) * moved tcp,udp traffic generation to lf_lib * moved tcp,udp creation to lf_lib * moved tcp,udp traffic generation to lf_lib * Made changes in eap_connect to move TCP, UDP Creation to lf_lib. --- unit_tests/eap_connect.py | 37 ++++++------------------ unit_tests/lf_lib.py | 61 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 unit_tests/lf_lib.py diff --git a/unit_tests/eap_connect.py b/unit_tests/eap_connect.py index a9e0ca206..7b46307d4 100755 --- a/unit_tests/eap_connect.py +++ b/unit_tests/eap_connect.py @@ -30,6 +30,7 @@ from LANforge.lfcli_base import LFCliBase from LANforge.LFUtils import * import realm from realm import Realm +from lf_lib import * import pprint OPEN="open" @@ -180,29 +181,9 @@ class EAPConnect(LFCliBase): self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug, use_radius=True, hs20_enable=False) self._pass("PASS: Station build finished") - # Create UDP endpoints - self.l3_udp_profile = self.localrealm.new_l3_cx_profile() - self.l3_udp_profile.side_a_min_bps = 128000 - self.l3_udp_profile.side_b_min_bps = 128000 - self.l3_udp_profile.side_a_min_pdu = 1200 - self.l3_udp_profile.side_b_min_pdu = 1500 - self.l3_udp_profile.report_timer = 1000 - self.l3_udp_profile.name_prefix = "udp" - self.l3_udp_profile.create(endp_type="lf_udp", - side_a=list(self.localrealm.find_ports_like("%s*"%self.sta_prefix)), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) - - # Create TCP endpoints - self.l3_tcp_profile = self.localrealm.new_l3_cx_profile() - self.l3_tcp_profile.side_a_min_bps = 128000 - self.l3_tcp_profile.side_b_min_bps = 56000 - self.l3_tcp_profile.name_prefix = "tcp" - self.l3_tcp_profile.report_timer = 1000 - self.l3_tcp_profile.create(endp_type="lf_tcp", - side_a=list(self.localrealm.find_ports_like("%s*"%self.sta_prefix)), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) + self.create_traffic = createTraffic(self.localrealm, self.sta_prefix, self.resource, self.upstream_port) + self.create_traffic.lf_l3_udp_profile() + self.create_traffic.lf_l3_tcp_profile() def start(self): if self.station_profile is None: @@ -293,12 +274,12 @@ class EAPConnect(LFCliBase): # start cx traffic print("\nStarting CX Traffic") - self.l3_udp_profile.start_cx() - self.l3_tcp_profile.start_cx() + + self.create_traffic.l3_udp_profile.start_cx() + self.create_traffic.l3_tcp_profile.start_cx() time.sleep(1) - # Refresh stats - self.l3_udp_profile.refresh_cx() - self.l3_tcp_profile.refresh_cx() + self.create_traffic.l3_tcp_profile.refresh_cx() + self.create_traffic.l3_udp_profile.refresh_cx() def collect_endp_stats(self, endp_map): print("Collecting Data") diff --git a/unit_tests/lf_lib.py b/unit_tests/lf_lib.py new file mode 100644 index 000000000..2e89605ae --- /dev/null +++ b/unit_tests/lf_lib.py @@ -0,0 +1,61 @@ +# create TCP and UDP traffic, run it a short amount of time. + +######################################################################################################### +# Used by Nightly_Sanity and eap_connect ############################################################ +######################################################################################################### + +# create TCP and UDP traffic, run it a short amount of time, + +import sys + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append('../../py-json') + +import argparse +import LANforge +from LANforge import LFUtils +# from LANforge import LFCliBase +from LANforge import lfcli_base +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +import realm +from realm import Realm +import pprint + +class createTraffic: + + def __init__(self,localrealm, sta_prefix, resource, upstream_port): + self.localrealm = localrealm + self.sta_prefix = sta_prefix + self.resource = resource + self.upstream_port = upstream_port + self.l3_udp_profile = localrealm.new_l3_cx_profile() + self.l3_tcp_profile = localrealm.new_l3_cx_profile() + + def lf_l3_udp_profile(self): + # Create UDP endpoints + self.l3_udp_profile.side_a_min_bps = 128000 + self.l3_udp_profile.side_b_min_bps = 128000 + self.l3_udp_profile.side_a_min_pdu = 1200 + self.l3_udp_profile.side_b_min_pdu = 1500 + self.l3_udp_profile.report_timer = 1000 + self.l3_udp_profile.name_prefix = "udp" + self.l3_udp_profile.create(endp_type="lf_udp", + side_a=list(self.localrealm.find_ports_like("%s*" % self.sta_prefix)), + side_b="%d.%s" % (self.resource, self.upstream_port), + suppress_related_commands=True) + + def lf_l3_tcp_profile(self): + # Create TCP endpoints + self.l3_tcp_profile.side_a_min_bps = 128000 + self.l3_tcp_profile.side_b_min_bps = 56000 + self.l3_tcp_profile.name_prefix = "tcp" + self.l3_tcp_profile.report_timer = 1000 + self.l3_tcp_profile.create(endp_type="lf_tcp", + side_a=list(self.localrealm.find_ports_like("%s*" % self.sta_prefix)), + side_b="%d.%s" % (self.resource, self.upstream_port), + suppress_related_commands=True)