diff options
author | Vratko Polak <vrpolak@cisco.com> | 2022-04-25 10:22:05 +0200 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2022-05-03 15:23:47 +0000 |
commit | 1daa6fdc0bae284dee1b61f34534e59b60b7526a (patch) | |
tree | 6314e011a8f029c4332586d5fd05b51d1a69a89c /GPL/traffic_profiles | |
parent | cd417be7f836eb9346fad4f87bd4f75dc1d9a429 (diff) |
feat(astf): Support framesizes for ASTF
- No support for IMIX.
+ Fix a bad bug in padding (most ASTF profiles had wrong frame sizes).
+ Fix a big typo in TCP PPS profiles (s->c was not data, just RST).
+ Control transaction size via ASTF_N_DATA_FRAMES env variable.
- Default value 5 leads to transactions smaller than before.
+ It ensures transaction is one burst (per direction) even for jumbo.
+ Edit autogen to set supported frame sizes based on suite id.
+ Both TCP and UDP use the same values:
+ 64B for CPS (exact for UDP, nominal for TCP).
+ 100B, 1518B and 9000B for TPUT and PPS.
- TCP TPUT achievable minimum is 70B.
+ Used 100B to leave room for possible IPv6 ASTF tests.
+ Separate function for code reused by vpp and trex tests.
- I do not really like the new "copy and edit" approach added here.
+ But it is a quick edit, better autogen refactor is low priority.
+ Consider both established and transitory sessions as valid.
- Mostly for compatibility with 2202 behavior and to avoid ramp-ups.
- Assuming both session states have similar enough VPP CPU overhead.
+ Added a TODO to investigate and maybe reconsider later.
+ Update the state timeout value to 240s.
+ That is the default for TCP (for transitory state).
- UDP could keep using 300s.
+ But I prefer UDP and TCP to behave as similarly as possible.
+ Use TRex tunables to get the exact frame size (for data packets).
- It is not clear why the recipe for MSS has to be this complicated.
+ Move code away from profile init, as frame size is not known there.
+ Change internal profile API, so values related to MSS are passed.
+ Lower ramp-up rate for TCP TPUT tests.
+ Because without lower rate, jumbo fails on packet loss in ramp-up.
+ UDP TPUT ramp-up rate also lowered (just to keep suites more similar).
+ Distinguish one-direction and aggregated average frame size.
+ Update keyword documentation where the distiction matters.
+ One-direction is needed for turning bandwidth limit to TPS limit.
+ Aggregated is needed for correct NDRPDR bandwidth result value.
- TCP TPUT will always be few percent below bidirectional maximum.
+ That is unavoidable, as one direction sends more control packets.
+ Add runtime consistency checks so future refactors are safer.
+ Fail if padding requested would be negative.
+ Fail if suite claims unexpected values for packets per transaction.
+ Edit the 4 types of ASTF profiles to keep them similar to each other.
+ Move UDP TPUT limit value from a field back to direct argument.
+ Stop pretending first UDP packet is not data.
+ Apply small improvements where convenient.
+ Replace "aggregate" with "aggregated" where possible.
+ To lower probability of any future typos in variable names.
+ Avoid calling Set Numeric Frame Sizes twice.
+ Code formatting, keyword documentation, code comments, ...
+ Add TODOs for less important code quality improvements.
- Postpone updating of methodology pages to a subsequent change.
Change-Id: I4b381e5210e69669f972326202fdcc5a2c9c923b
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'GPL/traffic_profiles')
21 files changed, 617 insertions, 640 deletions
diff --git a/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py b/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py index e36e52c2c1..cb8fd763e6 100644 --- a/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py +++ b/GPL/traffic_profiles/trex/profile_trex_astf_base_class.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,13 +46,9 @@ class TrafficProfileBaseClass: ] } - def __init__(self): - # Default values of required parameters; can be overwritten in - # "get_profile" method. - self.framesize = 64 - self._pcap_dir = u"" - - # If needed, add your own parameters. + # TODO: Declare and document fields in a contructor to make pylint happier. + # TODO: Consider passing the values to define_profile(), + # instead of keeping (and documenting) them as instance fields here. @property def pcap_dir(self): @@ -72,7 +68,7 @@ class TrafficProfileBaseClass: :param current_length: Current length of the packet. :param required_length: Required length of the packet. If set to 0 then - self.framesize value is used. + self.framesize value is used. :type current_length: int :type required_length: int :returns: The generated padding. @@ -82,20 +78,25 @@ class TrafficProfileBaseClass: # use random.randrange(0, len(self.STREAM_TABLE[self.framesize])) ? if not required_length: required_length = self.framesize - - return str(choices(ascii_letters, k=required_length - current_length)) + missing = required_length - current_length + if missing < 0: + msg = f"Cannot to pad from {current_length} to {required_length}." + raise RuntimeError(msg) + padding = u"".join(choices(ascii_letters, k=missing)) + return padding def define_profile(self): """Define profile to be used by T-Rex astf traffic generator. This method MUST return: - return ip_gen, templates, cap_list + return ip_gen, templates, kwargs - templates or cap_list CAN be None. + templates or kwargs CAN be None. + Kwargs can be used to define PCAP file, set MSS, ... :returns: IP generator and profile templates or list of pcap files for - traffic generator. + traffic generator. :rtype: tuple """ raise NotImplementedError @@ -108,15 +109,14 @@ class TrafficProfileBaseClass: :returns: Traffic profile. :rtype: trex.astf.trex_astf_profile.ASTFProfile """ - ip_gen, templates, cap_list = self.define_profile() - - # In most cases you will not have to change the code below: + ip_gen, templates, kwargs = self.define_profile() + if kwargs is None: + kwargs = dict() - # profile profile = ASTFProfile( default_ip_gen=ip_gen, templates=templates, - cap_list=cap_list + **kwargs ) return profile @@ -127,11 +127,13 @@ class TrafficProfileBaseClass: If needed, add your own parameters. :param kwargs: Key-value pairs used by "create_profile" method while - creating the profile. + creating the profile. + :type kwargs: dict :returns: Traffic profile. :rtype: trex.astf.trex_astf_profile.ASTFProfile """ self.framesize = kwargs[u"framesize"] + self.n_data_frames = kwargs[u"n_data_frames"] self._pcap_dir = kwargs.get( u"pcap_dir", u"/opt/trex-core-2.88/scripts/avl" ) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h-pps.py index 70fcaa06bb..546e11bb5e 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,22 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.3.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.3.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - self.data_size = 11111 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -73,31 +57,44 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.3.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.3.255" + + # Headers length, not sure why TRex needs 32B for segment header. + real_headers_size = 70 # 18B L2 + 20B IPv4 + 32B TCP. + trex_headers_size = real_headers_size - 12 # As if TCP header is 20B. + trex_mss = self.framesize - trex_headers_size + real_mss = trex_mss - 12 # TRex honors segment header+data limit. + data_size = self.n_data_frames * real_mss + # client commands prog_c = ASTFProgram() prog_c.connect() - prog_c.send(u"1" * self.data_size) - prog_c.recv(self.data_size) + prog_c.send(u"1" * data_size) + prog_c.recv(data_size) # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.recv(data_size) + prog_s.send(u"1" * data_size) # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -108,12 +105,25 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=64512, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) - return ip_gen, template, None + globinfo = ASTFGlobalInfo() + # Ensure correct data frame size. + globinfo.tcp.mss = trex_mss + # Ensure the whole transaction is a single burst (per direction). + globinfo.tcp.initwnd = self.n_data_frames + # Ensure buffers are large enough so starting window works. + globinfo.tcp.txbufsize = data_size + globinfo.tcp.rxbufsize = data_size + kwargs = dict( + default_c_glob_info=globinfo, + default_s_glob_info=globinfo, + ) + + return ip_gen, template, kwargs def register(): diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h.py index 2e4fca2af0..4c6a15ac7d 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-1024h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,21 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.3.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.3.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -72,6 +57,14 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # No data, no way to manipulate frame sizes via MSS. + + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.3.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.3.255" + # client commands prog_c = ASTFProgram() # send syn @@ -88,17 +81,17 @@ class TrafficProfile(TrafficProfileBaseClass): # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -109,7 +102,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=64512, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h-pps.py index 19402bab95..565ccac3d5 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,22 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.63.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.63.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - self.data_size = 11111 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -73,31 +57,44 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.63.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.63.255" + + # Headers length, not sure why TRex needs 32B for segment header. + real_headers_size = 70 # 18B L2 + 20B IPv4 + 32B TCP. + trex_headers_size = real_headers_size - 12 # As if TCP header is 20B. + trex_mss = self.framesize - trex_headers_size + real_mss = trex_mss - 12 # TRex honors segment header+data limit. + data_size = self.n_data_frames * real_mss + # client commands prog_c = ASTFProgram() prog_c.connect() - prog_c.send(u"1" * self.data_size) - prog_c.recv(self.data_size) + prog_c.send(u"1" * data_size) + prog_c.recv(data_size) # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.recv(data_size) + prog_s.send(u"1" * data_size) # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -108,12 +105,25 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=1032192, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) - return ip_gen, template, None + globinfo = ASTFGlobalInfo() + # Ensure correct data frame size. + globinfo.tcp.mss = trex_mss + # Ensure the whole transaction is a single burst (per direction). + globinfo.tcp.initwnd = self.n_data_frames + # Ensure buffers are large enough so starting window works. + globinfo.tcp.txbufsize = data_size + globinfo.tcp.rxbufsize = data_size + kwargs = dict( + default_c_glob_info=globinfo, + default_s_glob_info=globinfo, + ) + + return ip_gen, template, kwargs def register(): diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h.py index 8f4d12ee6a..728ad5b0d9 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-16384h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,21 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.63.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.63.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -72,6 +57,14 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # No data, no way to manipulate frame sizes via MSS. + + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.63.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.63.255" + # client commands prog_c = ASTFProgram() # send syn @@ -88,17 +81,17 @@ class TrafficProfile(TrafficProfileBaseClass): # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -109,7 +102,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=1032192, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h-pps.py index 2a174307ec..54b38a43a9 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,22 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"172.16.0.0" - self.p1_src_end_ip = u"172.19.255.255" - self.p1_dst_start_ip = u"20.16.0.0" - self.p1_dst_end_ip = u"20.19.255.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - self.data_size = 11111 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -73,31 +57,44 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # IPs used in packet headers. + p1_src_start_ip = u"172.16.0.0" + p1_src_end_ip = u"172.19.255.255" + p1_dst_start_ip = u"20.16.0.0" + p1_dst_end_ip = u"20.19.255.255" + + # Headers length, not sure why TRex needs 32B for segment header. + real_headers_size = 70 # 18B L2 + 20B IPv4 + 32B TCP. + trex_headers_size = real_headers_size - 12 # As if TCP header is 20B. + trex_mss = self.framesize - trex_headers_size + real_mss = trex_mss - 12 # TRex honors segment header+data limit. + data_size = self.n_data_frames * real_mss + # client commands prog_c = ASTFProgram() prog_c.connect() - prog_c.send(u"1" * self.data_size) - prog_c.recv(self.data_size) + prog_c.send(u"1" * data_size) + prog_c.recv(data_size) # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.recv(data_size) + prog_s.send(u"1" * data_size) # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -108,12 +105,25 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=16515072, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) - return ip_gen, template, None + globinfo = ASTFGlobalInfo() + # Ensure correct data frame size. + globinfo.tcp.mss = trex_mss + # Ensure the whole transaction is a single burst (per direction). + globinfo.tcp.initwnd = self.n_data_frames + # Ensure buffers are large enough so starting window works. + globinfo.tcp.txbufsize = data_size + globinfo.tcp.rxbufsize = data_size + kwargs = dict( + default_c_glob_info=globinfo, + default_s_glob_info=globinfo, + ) + + return ip_gen, template, kwargs def register(): diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h.py index 344bc7dcac..ec4870a95e 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-262144h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,21 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"172.16.0.0" - self.p1_src_end_ip = u"172.19.255.255" - self.p1_dst_start_ip = u"20.16.0.0" - self.p1_dst_end_ip = u"20.19.255.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -72,6 +57,14 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # No data, no way to manipulate frame sizes via MSS. + + # IPs used in packet headers. + p1_src_start_ip = u"172.16.0.0" + p1_src_end_ip = u"172.19.255.255" + p1_dst_start_ip = u"20.16.0.0" + p1_dst_end_ip = u"20.19.255.255" + # client commands prog_c = ASTFProgram() # send syn @@ -88,17 +81,17 @@ class TrafficProfile(TrafficProfileBaseClass): # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -109,7 +102,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=16515072, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h-pps.py index 6999dee6f9..0108edbcd5 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,22 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.15.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.15.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - self.data_size = 11111 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -73,31 +57,44 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.15.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.15.255" + + # Headers length, not sure why TRex needs 32B for segment header. + real_headers_size = 70 # 18B L2 + 20B IPv4 + 32B TCP. + trex_headers_size = real_headers_size - 12 # As if TCP header is 20B. + trex_mss = self.framesize - trex_headers_size + real_mss = trex_mss - 12 # TRex honors segment header+data limit. + data_size = self.n_data_frames * real_mss + # client commands prog_c = ASTFProgram() prog_c.connect() - prog_c.send(u"1" * self.data_size) - prog_c.recv(self.data_size) + prog_c.send(u"1" * data_size) + prog_c.recv(data_size) # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.recv(data_size) + prog_s.send(u"1" * data_size) # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -108,12 +105,25 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=258048, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) - return ip_gen, template, None + globinfo = ASTFGlobalInfo() + # Ensure correct data frame size. + globinfo.tcp.mss = trex_mss + # Ensure the whole transaction is a single burst (per direction). + globinfo.tcp.initwnd = self.n_data_frames + # Ensure buffers are large enough so starting window works. + globinfo.tcp.txbufsize = data_size + globinfo.tcp.rxbufsize = data_size + kwargs = dict( + default_c_glob_info=globinfo, + default_s_glob_info=globinfo, + ) + + return ip_gen, template, kwargs def register(): diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h.py index 4278e3d099..6124baa6a1 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-4096h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,21 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.15.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.15.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -72,6 +57,14 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # No data, no way to manipulate frame sizes via MSS. + + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.15.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.15.255" + # client commands prog_c = ASTFProgram() # send syn @@ -88,17 +81,17 @@ class TrafficProfile(TrafficProfileBaseClass): # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -109,7 +102,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=258048, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h-pps.py index 6b3bbd4c9f..54de3e500d 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,22 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.255.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.255.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - self.data_size = 11111 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -73,31 +57,44 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.255.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.255.255" + + # Headers length, not sure why TRex needs 32B for segment header. + real_headers_size = 70 # 18B L2 + 20B IPv4 + 32B TCP. + trex_headers_size = real_headers_size - 12 # As if TCP header is 20B. + trex_mss = self.framesize - trex_headers_size + real_mss = trex_mss - 12 # TRex honors segment header+data limit. + data_size = self.n_data_frames * real_mss + # client commands prog_c = ASTFProgram() prog_c.connect() - prog_c.send(u"1" * self.data_size) - prog_c.recv(self.data_size) + prog_c.send(u"1" * data_size) + prog_c.recv(data_size) # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.recv(data_size) + prog_s.send(u"1" * data_size) # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -108,12 +105,25 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=4128768, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) - return ip_gen, template, None + globinfo = ASTFGlobalInfo() + # Ensure correct data frame size. + globinfo.tcp.mss = trex_mss + # Ensure the whole transaction is a single burst (per direction). + globinfo.tcp.initwnd = self.n_data_frames + # Ensure buffers are large enough so starting window works. + globinfo.tcp.txbufsize = data_size + globinfo.tcp.rxbufsize = data_size + kwargs = dict( + default_c_glob_info=globinfo, + default_s_glob_info=globinfo, + ) + + return ip_gen, template, kwargs def register(): diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h.py index 1be78d8c42..13c6ee8f38 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4tcp-65536h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -47,21 +47,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.255.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.255.255" - - # Headers length; not used in this profile, just for the record of - # header length for TCP packet with 0B payload - self.headers_size = 58 # 14B l2 + 20B ipv4 + 24B tcp incl. 4B options - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -72,6 +57,14 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ + # No data, no way to manipulate frame sizes via MSS. + + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.255.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.255.255" + # client commands prog_c = ASTFProgram() # send syn @@ -88,17 +81,17 @@ class TrafficProfile(TrafficProfileBaseClass): # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -109,7 +102,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=4128768, # TODO: set via input parameter - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h-pps.py index 667385ffbf..135e7fbdc7 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,84 +46,80 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.3.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.3.255" - - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B UDP - - self.udp_data = u"" - - self.n_data = 32 # TODO: set via input parameter - self.m_delay = 2000000 # delay 2000s (2,000,000 ms) - self.u_delay = 1000 * self.m_delay # delay 2000s (2,000,000,000 us) - self.limit = 64512 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. This method MUST return: - return ip_gen, templates + return ip_gen, templates, None :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ - if self.framesize == 64: - self.udp_data += self._gen_padding(self.headers_size, 72) - if self.framesize == 1518: - self.udp_data += self._gen_padding(self.headers_size, 1514) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.3.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.3.255" + + # The difference between data size and frame size. + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # TODO: Use the "connection protocol" from CPS traffic profile? + # Currently, the first data packet is all DUT sees about the session. + + # Avoid sending keepalives. + m_delay = 2000000 # delay 2000s (2,000,000 ms) + + # Data, not padded yet. + udp_data = u"" + # Pad the data to achieve the intended frame size. + udp_data += self._gen_padding(headers_size) + + # Safety check, the current programs send at least 1 packet. + if self.n_data_frames < 1: + raise RuntimeError("n_data_frames < 1: {self.n_data_frames}") # Client program. prog_c = ASTFProgram(stream=False) - prog_c.set_keepalive_msg(self.m_delay) - prog_c.send_msg(self.udp_data) - # No delay, PPS tests combine connect and data send (no data receive). - prog_c.set_var(u"var1", self.n_data) + prog_c.set_keepalive_msg(m_delay) + prog_c.set_var(u"var1", self.n_data_frames) prog_c.set_label(u"a:") - prog_c.send_msg(self.udp_data) + prog_c.send_msg(udp_data) prog_c.jmp_nz(u"var1", u"a:") # We should read the server response, # but no reason to overload client workers even more. # Server program. prog_s = ASTFProgram(stream=False) - prog_s.set_keepalive_msg(self.m_delay) + prog_s.set_keepalive_msg(m_delay) # If server closes too soon, new instances are started # leading in too much replies. To prevent that, we need to recv all. - prog_s.recv_msg(1 + self.n_data) + prog_s.recv_msg(self.n_data_frames) # In packet loss scenarios, some instances never get here. # This maybe increases server traffic duration, # but no other way if we want to avoid # TRex creating a second instance of the same server. - prog_s.send_msg(self.udp_data) - prog_s.set_var(u"var2", self.n_data) + prog_s.set_var(u"var2", self.n_data_frames) prog_s.set_label(u"b:") - prog_s.send_msg(self.udp_data) + prog_s.send_msg(udp_data) prog_s.jmp_nz(u"var2", u"b:") # VPP never duplicates packets, # so it is safe to close the server instance now. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -133,8 +129,8 @@ class TrafficProfile(TrafficProfileBaseClass): temp_c = ASTFTCPClientTemplate( program=prog_c, ip_gen=ip_gen, - limit=self.limit, - port=8080 + limit=64512, # TODO: Any benefit of making this configurable? + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h.py index 78ee8f31fc..a1282adf2f 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-1024h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -49,26 +49,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.3.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.3.255" - - # UDP messages - self.udp_req = u"GET" - self.udp_res = u"ACK" - - # Headers length - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B udp - - # No need to set keepalive, both programs end just after start&send. - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -78,13 +58,29 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates ASTFProfile(). :rtype: tuple """ - self.udp_req += self._gen_padding(self.headers_size + len(self.udp_req)) - self.udp_res += self._gen_padding(self.headers_size + len(self.udp_res)) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.3.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.3.255" + + # Headers length + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # UDP messages, not padded yet. + udp_req = u"GET" + udp_res = u"ACK" + + # Padd to the required frame size. + udp_req += self._gen_padding(headers_size + len(udp_req)) + udp_res += self._gen_padding(headers_size + len(udp_res)) + + # No need to set keepalive, both programs end just after start&send. # client commands prog_c = ASTFProgram(stream=False) # send REQ message - prog_c.send_msg(self.udp_req) + prog_c.send_msg(udp_req) # No need to process the response, seeing L2 counter is enough. # Client program can end here. @@ -93,22 +89,22 @@ class TrafficProfile(TrafficProfileBaseClass): # When server instance is created means REQ is visible in L2 counter. # No need to receive explicitly? # send RES message - prog_s.send_msg(self.udp_res) + prog_s.send_msg(udp_res) # Server program can end here. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -119,7 +115,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=64512, # TODO: set via input parameter ? - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h-pps.py index 1739fcca31..05976bc45c 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,84 +46,80 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.63.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.63.255" - - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B UDP - - self.udp_data = u"" - - self.n_data = 32 # TODO: set via input parameter - self.m_delay = 2000000 # delay 2000s (2,000,000 ms) - self.u_delay = 1000 * self.m_delay # delay 2000s (2,000,000,000 us) - self.limit = 1032192 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. This method MUST return: - return ip_gen, templates + return ip_gen, templates, None :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ - if self.framesize == 64: - self.udp_data += self._gen_padding(self.headers_size, 72) - if self.framesize == 1518: - self.udp_data += self._gen_padding(self.headers_size, 1514) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.63.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.63.255" + + # The difference between data size and frame size. + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # TODO: Use the "connection protocol" from CPS traffic profile? + # Currently, the first data packet is all DUT sees about the session. + + # Avoid sending keepalives. + m_delay = 2000000 # delay 2000s (2,000,000 ms) + + # Data, not padded yet. + udp_data = u"" + # Pad the data to achieve the intended frame size. + udp_data += self._gen_padding(headers_size) + + # Safety check, the current programs send at least 1 packet. + if self.n_data_frames < 1: + raise RuntimeError("n_data_frames < 1: {self.n_data_frames}") # Client program. prog_c = ASTFProgram(stream=False) - prog_c.set_keepalive_msg(self.m_delay) - prog_c.send_msg(self.udp_data) - # No delay, PPS tests combine connect and data send (no data receive). - prog_c.set_var(u"var1", self.n_data) + prog_c.set_keepalive_msg(m_delay) + prog_c.set_var(u"var1", self.n_data_frames) prog_c.set_label(u"a:") - prog_c.send_msg(self.udp_data) + prog_c.send_msg(udp_data) prog_c.jmp_nz(u"var1", u"a:") # We should read the server response, # but no reason to overload client workers even more. # Server program. prog_s = ASTFProgram(stream=False) - prog_s.set_keepalive_msg(self.m_delay) + prog_s.set_keepalive_msg(m_delay) # If server closes too soon, new instances are started # leading in too much replies. To prevent that, we need to recv all. - prog_s.recv_msg(1 + self.n_data) + prog_s.recv_msg(self.n_data_frames) # In packet loss scenarios, some instances never get here. # This maybe increases server traffic duration, # but no other way if we want to avoid # TRex creating a second instance of the same server. - prog_s.send_msg(self.udp_data) - prog_s.set_var(u"var2", self.n_data) + prog_s.set_var(u"var2", self.n_data_frames) prog_s.set_label(u"b:") - prog_s.send_msg(self.udp_data) + prog_s.send_msg(udp_data) prog_s.jmp_nz(u"var2", u"b:") # VPP never duplicates packets, # so it is safe to close the server instance now. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -133,8 +129,8 @@ class TrafficProfile(TrafficProfileBaseClass): temp_c = ASTFTCPClientTemplate( program=prog_c, ip_gen=ip_gen, - limit=self.limit, - port=8080 + limit=1032192, # TODO: Any benefit of making this configurable? + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h.py index 7d35a68db6..3a1793a617 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-16384h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -49,26 +49,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.63.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.63.255" - - # UDP messages - self.udp_req = u"GET" - self.udp_res = u"ACK" - - # Headers length - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B udp - - # No need to set keepalive, both programs end just after start&send. - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -78,13 +58,29 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates ASTFProfile(). :rtype: tuple """ - self.udp_req += self._gen_padding(self.headers_size + len(self.udp_req)) - self.udp_res += self._gen_padding(self.headers_size + len(self.udp_res)) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.63.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.63.255" + + # Headers length + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # UDP messages, not padded yet. + udp_req = u"GET" + udp_res = u"ACK" + + # Padd to the required frame size. + udp_req += self._gen_padding(headers_size + len(udp_req)) + udp_res += self._gen_padding(headers_size + len(udp_res)) + + # No need to set keepalive, both programs end just after start&send. # client commands prog_c = ASTFProgram(stream=False) # send REQ message - prog_c.send_msg(self.udp_req) + prog_c.send_msg(udp_req) # No need to process the response, seeing L2 counter is enough. # Client program can end here. @@ -93,22 +89,22 @@ class TrafficProfile(TrafficProfileBaseClass): # When server instance is created means REQ is visible in L2 counter. # No need to receive explicitly? # send RES message - prog_s.send_msg(self.udp_res) + prog_s.send_msg(udp_res) # Server program can end here. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -119,7 +115,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=1032192, # TODO: set via input parameter ? - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h-pps.py index 9445b11565..801db90095 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,84 +46,80 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"172.16.0.0" - self.p1_src_end_ip = u"172.19.255.255" - self.p1_dst_start_ip = u"20.16.0.0" - self.p1_dst_end_ip = u"20.19.255.255" - - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B UDP - - self.udp_data = u"" - - self.n_data = 32 # TODO: set via input parameter - self.m_delay = 2000000 # delay 2000s (2,000,000 ms) - self.u_delay = 1000 * self.m_delay # delay 2000s (2,000,000,000 us) - self.limit = 16515072 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. This method MUST return: - return ip_gen, templates + return ip_gen, templates, None :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ - if self.framesize == 64: - self.udp_data += self._gen_padding(self.headers_size, 72) - if self.framesize == 1518: - self.udp_data += self._gen_padding(self.headers_size, 1514) + # IPs used in packet headers. + p1_src_start_ip = u"172.16.0.0" + p1_src_end_ip = u"172.19.255.255" + p1_dst_start_ip = u"20.16.0.0" + p1_dst_end_ip = u"20.19.255.255" + + # The difference between data size and frame size. + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # TODO: Use the "connection protocol" from CPS traffic profile? + # Currently, the first data packet is all DUT sees about the session. + + # Avoid sending keepalives. + m_delay = 2000000 # delay 2000s (2,000,000 ms) + + # Data, not padded yet. + udp_data = u"" + # Pad the data to achieve the intended frame size. + udp_data += self._gen_padding(headers_size) + + # Safety check, the current programs send at least 1 packet. + if self.n_data_frames < 1: + raise RuntimeError("n_data_frames < 1: {self.n_data_frames}") # Client program. prog_c = ASTFProgram(stream=False) - prog_c.set_keepalive_msg(self.m_delay) - prog_c.send_msg(self.udp_data) - # No delay, PPS tests combine connect and data send (no data receive). - prog_c.set_var(u"var1", self.n_data) + prog_c.set_keepalive_msg(m_delay) + prog_c.set_var(u"var1", self.n_data_frames) prog_c.set_label(u"a:") - prog_c.send_msg(self.udp_data) + prog_c.send_msg(udp_data) prog_c.jmp_nz(u"var1", u"a:") # We should read the server response, # but no reason to overload client workers even more. # Server program. prog_s = ASTFProgram(stream=False) - prog_s.set_keepalive_msg(self.m_delay) + prog_s.set_keepalive_msg(m_delay) # If server closes too soon, new instances are started # leading in too much replies. To prevent that, we need to recv all. - prog_s.recv_msg(1 + self.n_data) + prog_s.recv_msg(self.n_data_frames) # In packet loss scenarios, some instances never get here. # This maybe increases server traffic duration, # but no other way if we want to avoid # TRex creating a second instance of the same server. - prog_s.send_msg(self.udp_data) - prog_s.set_var(u"var2", self.n_data) + prog_s.set_var(u"var2", self.n_data_frames) prog_s.set_label(u"b:") - prog_s.send_msg(self.udp_data) + prog_s.send_msg(udp_data) prog_s.jmp_nz(u"var2", u"b:") # VPP never duplicates packets, # so it is safe to close the server instance now. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -133,8 +129,8 @@ class TrafficProfile(TrafficProfileBaseClass): temp_c = ASTFTCPClientTemplate( program=prog_c, ip_gen=ip_gen, - limit=self.limit, - port=8080 + limit=16515072, # TODO: Any benefit of making this configurable? + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h.py index 8fe8f02a91..2203cf3d0b 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-262144h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -49,26 +49,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"172.16.0.0" - self.p1_src_end_ip = u"172.19.255.255" - self.p1_dst_start_ip = u"20.16.0.0" - self.p1_dst_end_ip = u"20.19.255.255" - - # UDP messages - self.udp_req = u"GET" - self.udp_res = u"ACK" - - # Headers length - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B udp - - # No need to set keepalive, both programs end just after start&send. - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -78,13 +58,29 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates ASTFProfile(). :rtype: tuple """ - self.udp_req += self._gen_padding(self.headers_size + len(self.udp_req)) - self.udp_res += self._gen_padding(self.headers_size + len(self.udp_res)) + # IPs used in packet headers. + p1_src_start_ip = u"172.16.0.0" + p1_src_end_ip = u"172.19.255.255" + p1_dst_start_ip = u"20.16.0.0" + p1_dst_end_ip = u"20.19.255.255" + + # Headers length + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # UDP messages, not padded yet. + udp_req = u"GET" + udp_res = u"ACK" + + # Padd to the required frame size. + udp_req += self._gen_padding(headers_size + len(udp_req)) + udp_res += self._gen_padding(headers_size + len(udp_res)) + + # No need to set keepalive, both programs end just after start&send. # client commands prog_c = ASTFProgram(stream=False) # send REQ message - prog_c.send_msg(self.udp_req) + prog_c.send_msg(udp_req) # No need to process the response, seeing L2 counter is enough. # Client program can end here. @@ -93,22 +89,22 @@ class TrafficProfile(TrafficProfileBaseClass): # When server instance is created means REQ is visible in L2 counter. # No need to receive explicitly? # send RES message - prog_s.send_msg(self.udp_res) + prog_s.send_msg(udp_res) # Server program can end here. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -119,7 +115,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=16515072, # TODO: set via input parameter ? - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h-pps.py index 00dbeee308..5de25273ef 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,84 +46,80 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.15.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.15.255" - - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B UDP - - self.udp_data = u"" - - self.n_data = 32 # TODO: set via input parameter - self.m_delay = 2000000 # delay 2000s (2,000,000 ms) - self.u_delay = 1000 * self.m_delay # delay 2000s (2,000,000,000 us) - self.limit = 258048 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. This method MUST return: - return ip_gen, templates + return ip_gen, templates, None :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ - if self.framesize == 64: - self.udp_data += self._gen_padding(self.headers_size, 72) - if self.framesize == 1518: - self.udp_data += self._gen_padding(self.headers_size, 1514) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.15.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.15.255" + + # The difference between data size and frame size. + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # TODO: Use the "connection protocol" from CPS traffic profile? + # Currently, the first data packet is all DUT sees about the session. + + # Avoid sending keepalives. + m_delay = 2000000 # delay 2000s (2,000,000 ms) + + # Data, not padded yet. + udp_data = u"" + # Pad the data to achieve the intended frame size. + udp_data += self._gen_padding(headers_size) + + # Safety check, the current programs send at least 1 packet. + if self.n_data_frames < 1: + raise RuntimeError("n_data_frames < 1: {self.n_data_frames}") # Client program. prog_c = ASTFProgram(stream=False) - prog_c.set_keepalive_msg(self.m_delay) - prog_c.send_msg(self.udp_data) - # No delay, PPS tests combine connect and data send (no data receive). - prog_c.set_var(u"var1", self.n_data) + prog_c.set_keepalive_msg(m_delay) + prog_c.set_var(u"var1", self.n_data_frames) prog_c.set_label(u"a:") - prog_c.send_msg(self.udp_data) + prog_c.send_msg(udp_data) prog_c.jmp_nz(u"var1", u"a:") # We should read the server response, # but no reason to overload client workers even more. # Server program. prog_s = ASTFProgram(stream=False) - prog_s.set_keepalive_msg(self.m_delay) + prog_s.set_keepalive_msg(m_delay) # If server closes too soon, new instances are started # leading in too much replies. To prevent that, we need to recv all. - prog_s.recv_msg(1 + self.n_data) + prog_s.recv_msg(self.n_data_frames) # In packet loss scenarios, some instances never get here. # This maybe increases server traffic duration, # but no other way if we want to avoid # TRex creating a second instance of the same server. - prog_s.send_msg(self.udp_data) - prog_s.set_var(u"var2", self.n_data) + prog_s.set_var(u"var2", self.n_data_frames) prog_s.set_label(u"b:") - prog_s.send_msg(self.udp_data) + prog_s.send_msg(udp_data) prog_s.jmp_nz(u"var2", u"b:") # VPP never duplicates packets, # so it is safe to close the server instance now. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -133,8 +129,8 @@ class TrafficProfile(TrafficProfileBaseClass): temp_c = ASTFTCPClientTemplate( program=prog_c, ip_gen=ip_gen, - limit=self.limit, - port=8080 + limit=258048, # TODO: Any benefit of making this configurable? + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h.py index 2285a633b0..81c074e5e3 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-4096h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -49,26 +49,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.15.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.15.255" - - # UDP messages - self.udp_req = u"GET" - self.udp_res = u"ACK" - - # Headers length - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B udp - - # No need to set keepalive, both programs end just after start&send. - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -78,13 +58,29 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates ASTFProfile(). :rtype: tuple """ - self.udp_req += self._gen_padding(self.headers_size + len(self.udp_req)) - self.udp_res += self._gen_padding(self.headers_size + len(self.udp_res)) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.15.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.15.255" + + # Headers length + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # UDP messages, not padded yet. + udp_req = u"GET" + udp_res = u"ACK" + + # Padd to the required frame size. + udp_req += self._gen_padding(headers_size + len(udp_req)) + udp_res += self._gen_padding(headers_size + len(udp_res)) + + # No need to set keepalive, both programs end just after start&send. # client commands prog_c = ASTFProgram(stream=False) # send REQ message - prog_c.send_msg(self.udp_req) + prog_c.send_msg(udp_req) # No need to process the response, seeing L2 counter is enough. # Client program can end here. @@ -93,22 +89,22 @@ class TrafficProfile(TrafficProfileBaseClass): # When server instance is created means REQ is visible in L2 counter. # No need to receive explicitly? # send RES message - prog_s.send_msg(self.udp_res) + prog_s.send_msg(udp_res) # Server program can end here. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -119,7 +115,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=258048, # TODO: set via input parameter ? - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h-pps.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h-pps.py index 3b6c3c7e55..73270607c1 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h-pps.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h-pps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -46,84 +46,80 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self, **kwargs): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.255.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.255.255" - - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B UDP - - self.udp_data = u"" - - self.n_data = 32 # TODO: set via input parameter - self.m_delay = 2000000 # delay 2000s (2,000,000 ms) - self.u_delay = 1000 * self.m_delay # delay 2000s (2,000,000,000 us) - self.limit = 4128768 - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. This method MUST return: - return ip_gen, templates + return ip_gen, templates, None :returns: IP generator and profile templates for ASTFProfile(). :rtype: tuple """ - if self.framesize == 64: - self.udp_data += self._gen_padding(self.headers_size, 72) - if self.framesize == 1518: - self.udp_data += self._gen_padding(self.headers_size, 1514) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.255.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.255.255" + + # The difference between data size and frame size. + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # TODO: Use the "connection protocol" from CPS traffic profile? + # Currently, the first data packet is all DUT sees about the session. + + # Avoid sending keepalives. + m_delay = 2000000 # delay 2000s (2,000,000 ms) + + # Data, not padded yet. + udp_data = u"" + # Pad the data to achieve the intended frame size. + udp_data += self._gen_padding(headers_size) + + # Safety check, the current programs send at least 1 packet. + if self.n_data_frames < 1: + raise RuntimeError("n_data_frames < 1: {self.n_data_frames}") # Client program. prog_c = ASTFProgram(stream=False) - prog_c.set_keepalive_msg(self.m_delay) - prog_c.send_msg(self.udp_data) - # No delay, PPS tests combine connect and data send (no data receive). - prog_c.set_var(u"var1", self.n_data) + prog_c.set_keepalive_msg(m_delay) + prog_c.set_var(u"var1", self.n_data_frames) prog_c.set_label(u"a:") - prog_c.send_msg(self.udp_data) + prog_c.send_msg(udp_data) prog_c.jmp_nz(u"var1", u"a:") # We should read the server response, # but no reason to overload client workers even more. # Server program. prog_s = ASTFProgram(stream=False) - prog_s.set_keepalive_msg(self.m_delay) + prog_s.set_keepalive_msg(m_delay) # If server closes too soon, new instances are started # leading in too much replies. To prevent that, we need to recv all. - prog_s.recv_msg(1 + self.n_data) + prog_s.recv_msg(self.n_data_frames) # In packet loss scenarios, some instances never get here. # This maybe increases server traffic duration, # but no other way if we want to avoid # TRex creating a second instance of the same server. - prog_s.send_msg(self.udp_data) - prog_s.set_var(u"var2", self.n_data) + prog_s.set_var(u"var2", self.n_data_frames) prog_s.set_label(u"b:") - prog_s.send_msg(self.udp_data) + prog_s.send_msg(udp_data) prog_s.jmp_nz(u"var2", u"b:") # VPP never duplicates packets, # so it is safe to close the server instance now. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -133,8 +129,8 @@ class TrafficProfile(TrafficProfileBaseClass): temp_c = ASTFTCPClientTemplate( program=prog_c, ip_gen=ip_gen, - limit=self.limit, - port=8080 + limit=4128768, # TODO: Any benefit of making this configurable? + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) diff --git a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h.py b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h.py index 327cc36e01..f1ee9125f2 100644 --- a/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h.py +++ b/GPL/traffic_profiles/trex/trex-astf-ethip4udp-65536h.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -49,26 +49,6 @@ from profile_trex_astf_base_class import TrafficProfileBaseClass class TrafficProfile(TrafficProfileBaseClass): """Traffic profile.""" - def __init__(self): - """Initialization and setting of profile parameters.""" - - super(TrafficProfileBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"192.168.0.0" - self.p1_src_end_ip = u"192.168.255.255" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.255.255" - - # UDP messages - self.udp_req = u"GET" - self.udp_res = u"ACK" - - # Headers length - self.headers_size = 42 # 14B l2 + 20B ipv4 + 8B udp - - # No need to set keepalive, both programs end just after start&send. - def define_profile(self): """Define profile to be used by advanced stateful traffic generator. @@ -78,13 +58,29 @@ class TrafficProfile(TrafficProfileBaseClass): :returns: IP generator and profile templates ASTFProfile(). :rtype: tuple """ - self.udp_req += self._gen_padding(self.headers_size + len(self.udp_req)) - self.udp_res += self._gen_padding(self.headers_size + len(self.udp_res)) + # IPs used in packet headers. + p1_src_start_ip = u"192.168.0.0" + p1_src_end_ip = u"192.168.255.255" + p1_dst_start_ip = u"20.0.0.0" + p1_dst_end_ip = u"20.0.255.255" + + # Headers length + headers_size = 46 # 18B L2 + 20B IPv4 + 8B UDP. + + # UDP messages, not padded yet. + udp_req = u"GET" + udp_res = u"ACK" + + # Padd to the required frame size. + udp_req += self._gen_padding(headers_size + len(udp_req)) + udp_res += self._gen_padding(headers_size + len(udp_res)) + + # No need to set keepalive, both programs end just after start&send. # client commands prog_c = ASTFProgram(stream=False) # send REQ message - prog_c.send_msg(self.udp_req) + prog_c.send_msg(udp_req) # No need to process the response, seeing L2 counter is enough. # Client program can end here. @@ -93,22 +89,22 @@ class TrafficProfile(TrafficProfileBaseClass): # When server instance is created means REQ is visible in L2 counter. # No need to receive explicitly? # send RES message - prog_s.send_msg(self.udp_res) + prog_s.send_msg(udp_res) # Server program can end here. # ip generators ip_gen_c = ASTFIPGenDist( - ip_range=[self.p1_src_start_ip, self.p1_src_end_ip], - distribution=u"seq" + ip_range=[p1_src_start_ip, p1_src_end_ip], + distribution=u"seq", ) ip_gen_s = ASTFIPGenDist( - ip_range=[self.p1_dst_start_ip, self.p1_dst_end_ip], - distribution=u"seq" + ip_range=[p1_dst_start_ip, p1_dst_end_ip], + distribution=u"seq", ) ip_gen = ASTFIPGen( glob=ASTFIPGenGlobal(ip_offset=u"0.0.0.1"), dist_client=ip_gen_c, - dist_server=ip_gen_s + dist_server=ip_gen_s, ) # server association @@ -119,7 +115,7 @@ class TrafficProfile(TrafficProfileBaseClass): program=prog_c, ip_gen=ip_gen, limit=4128768, # TODO: set via input parameter ? - port=8080 + port=8080, ) temp_s = ASTFTCPServerTemplate(program=prog_s, assoc=s_assoc) template = ASTFTemplate(client_template=temp_c, server_template=temp_s) |