diff options
Diffstat (limited to 'GPL/traffic_profiles')
190 files changed, 6453 insertions, 3986 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 427060ffee..55aedd0543 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,13 +127,15 @@ 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.86/scripts/avl" + u"pcap_dir", u"/opt/trex-core-3.03/scripts/avl" ) return self.create_profile() diff --git a/GPL/traffic_profiles/trex/profile_trex_stateless_scale_class.py b/GPL/traffic_profiles/trex/profile_trex_stateless_scale_class.py new file mode 100644 index 0000000000..33cf090da2 --- /dev/null +++ b/GPL/traffic_profiles/trex/profile_trex_stateless_scale_class.py @@ -0,0 +1,196 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Base class for stream profiles for T-rex traffic generator. +""" + +import socket +import struct + +from random import choice +from string import ascii_letters + +from trex.stl.api import * + + +class TrafficStreamsScaleClass: + """Base class for stream profiles for T-rex traffic generator.""" + + STREAM_TABLE = { + "IMIX_v4": [ + {"size": 60, "pps": 28, "isg": 0}, + {"size": 590, "pps": 20, "isg": 0.1}, + {"size": 1514, "pps": 4, "isg": 0.2} + ], + "IMIX_v4_1": [ + {"size": 64, "pps": 28, "isg": 0}, + {"size": 570, "pps": 16, "isg": 0.1}, + {"size": 1518, "pps": 4, "isg": 0.2} + ] + } + + def __init__(self): + # Default value of frame size, it will be overwritten by the value of + # "framesize" parameter of "get_streams" method. + self.framesize = 64 + + # If needed, add your own parameters. + + def _gen_payload(self, length): + """Generate payload. + + If needed, implement your own algorithm. + + :param length: Length of generated payload. + :type length: int + :returns: The generated payload. + :rtype: str + """ + payload = "" + for _ in range(length): + payload += choice(ascii_letters) + + return payload + + def _get_start_end_ipv6(self, start_ip, end_ip): + """Get start host and number of hosts from IPv6 as integer. + + :param start_ip: Start IPv6. + :param end_ip: End IPv6. + :type start_ip: string + :type end_ip: string + :return: Start host, number of hosts. + :rtype tuple of int + :raises: ValueError if start_ip is greater then end_ip. + :raises: socket.error if the IP addresses are not valid IPv6 addresses. + """ + try: + ip1 = socket.inet_pton(socket.AF_INET6, start_ip) + ip2 = socket.inet_pton(socket.AF_INET6, end_ip) + + hi1, lo1 = struct.unpack("!QQ", ip1) + hi2, lo2 = struct.unpack("!QQ", ip2) + + if ((hi1 << 64) | lo1) > ((hi2 << 64) | lo2): + raise ValueError("IPv6: start_ip is greater then end_ip") + + return lo1, abs(int(lo1) - int(lo2)) + + except socket.error as err: + print(err) + raise + + def define_packets(self): + """Define the packets to be sent from the traffic generator. + + This method MUST return: + + return base_pkt_a, base_pkt_b, vm1, vm2 + + vm1 and vm2 CAN be None. + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + raise NotImplementedError + + def create_streams(self): + """Create traffic streams. + + Implement your own traffic streams. + + :returns: Traffic streams. + :rtype: list + """ + pkts, vms = self.define_packets() + + # Frame size is defined as an integer, e.g. 64, 1518: + if isinstance(self.framesize, int): + pkt_streams = list() + lat_streams = list() + for i in range(len(pkts)): + payload_len = max(0, self.framesize - len(pkts[i]) - 4) + + pkt = STLPktBuilder( + pkt=pkts[i] / self._gen_payload(payload_len), + vm=vms[i] + ) + pkt_lat = STLPktBuilder( + pkt=pkts[i] / self._gen_payload(payload_len), + vm=vms[i] + ) + pkt_streams.append( + STLStream( + packet=pkt, + isg=10.0 * (i // (len(pkts) // 2)), + mode=STLTXCont(pps=9000) + ) + ) + lat_streams.append( + STLStream( + packet=pkt_lat, + isg=10.0 * (i // (len(pkts) // 2)), + flow_stats=STLFlowLatencyStats(pg_id=i), + mode=STLTXCont(pps=9000) + ) + ) + + streams = list() + streams.extend(pkt_streams) + streams.extend(lat_streams) + return streams + + # Frame size is defined as a string, e.g.IMIX_v4_1: + elif isinstance(self.framesize, str): + pkt_streams = list() + for i in range(len(pkts)): + for stream in self.STREAM_TABLE[self.framesize]: + payload_len = max(0, stream["size"] - len(pkts[i]) - 4) + + pkt = STLPktBuilder( + pkt=pkts[i] / self._gen_payload(payload_len), + vm=vms[i] + ) + pkt_streams.append( + STLStream( + packet=pkt, + isg=stream["isg"], + mode=STLTXCont(pps=stream["pps"]) + ) + ) + return pkt_streams + + def get_streams(self, **kwargs): + """Get traffic streams created by "create_streams" method. + + If needed, add your own parameters. + + :param kwargs: Key-value pairs used by "create_streams" method while + creating streams. + :returns: Traffic streams. + :rtype: list + """ + self.framesize = kwargs["framesize"] + self.rate = kwargs["rate"] + + return self.create_streams() 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..9c3ab873c1 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,50 @@ 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.set_var(u"var1", self.n_data_frames) + prog_c.set_label(u"a1:") + prog_c.send(u"1" * real_mss) + prog_c.recv(real_mss) + prog_c.jmp_nz(u"var1", u"a1:") # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.set_var(u"var2", self.n_data_frames) + prog_s.set_label(u"a2:") + prog_s.recv(real_mss) + prog_s.send(u"1" * real_mss) + prog_s.jmp_nz(u"var2", u"a2:") # 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 +111,22 @@ 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 + globinfo.tcp.txbufsize = trex_mss + globinfo.tcp.rxbufsize = trex_mss + 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..ae5879a98f 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,50 @@ 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.set_var(u"var1", self.n_data_frames) + prog_c.set_label(u"a1:") + prog_c.send(u"1" * real_mss) + prog_c.recv(real_mss) + prog_c.jmp_nz(u"var1", u"a1:") # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.set_var(u"var2", self.n_data_frames) + prog_s.set_label(u"a2:") + prog_s.recv(real_mss) + prog_s.send(u"1" * real_mss) + prog_s.jmp_nz(u"var2", u"a2:") # 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 +111,22 @@ 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 + globinfo.tcp.txbufsize = trex_mss + globinfo.tcp.rxbufsize = trex_mss + 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..46468386b1 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,50 @@ 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.set_var(u"var1", self.n_data_frames) + prog_c.set_label(u"a1:") + prog_c.send(u"1" * real_mss) + prog_c.recv(real_mss) + prog_c.jmp_nz(u"var1", u"a1:") # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.set_var(u"var2", self.n_data_frames) + prog_s.set_label(u"a2:") + prog_s.recv(real_mss) + prog_s.send(u"1" * real_mss) + prog_s.jmp_nz(u"var2", u"a2:") # 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 +111,22 @@ 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 + globinfo.tcp.txbufsize = trex_mss + globinfo.tcp.rxbufsize = trex_mss + 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..35e961495d 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,50 @@ 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.set_var(u"var1", self.n_data_frames) + prog_c.set_label(u"a1:") + prog_c.send(u"1" * real_mss) + prog_c.recv(real_mss) + prog_c.jmp_nz(u"var1", u"a1:") # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.set_var(u"var2", self.n_data_frames) + prog_s.set_label(u"a2:") + prog_s.recv(real_mss) + prog_s.send(u"1" * real_mss) + prog_s.jmp_nz(u"var2", u"a2:") # 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 +111,22 @@ 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 + globinfo.tcp.txbufsize = trex_mss + globinfo.tcp.rxbufsize = trex_mss + 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..5dcfb70cb7 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,50 @@ 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.set_var(u"var1", self.n_data_frames) + prog_c.set_label(u"a1:") + prog_c.send(u"1" * real_mss) + prog_c.recv(real_mss) + prog_c.jmp_nz(u"var1", u"a1:") # server commands prog_s = ASTFProgram() prog_s.accept() - prog_c.recv(self.data_size) - prog_c.send(u"1" * self.data_size) + prog_s.set_var(u"var2", self.n_data_frames) + prog_s.set_label(u"a2:") + prog_s.recv(real_mss) + prog_s.send(u"1" * real_mss) + prog_s.jmp_nz(u"var2", u"a2:") # 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 +111,22 @@ 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 + globinfo.tcp.txbufsize = trex_mss + globinfo.tcp.rxbufsize = trex_mss + 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 2dc7c81131..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 = 1200000 # delay 1200s (1,200,000 ms) - self.u_delay = 1000 * self.m_delay # delay 1200s (1,200,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 0061ae31d4..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 = 1200000 # delay 1200s (1,200,000 ms) - self.u_delay = 1000 * self.m_delay # delay 1200s (1,200,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 ebfdced27f..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 = 1200000 # delay 1200s (1,200,000 ms) - self.u_delay = 1000 * self.m_delay # delay 1200s (1,200,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 018bb7fa2a..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 = 1200000 # delay 1200s (1,200,000 ms) - self.u_delay = 1000 * self.m_delay # delay 1200s (1,200,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 f65c60b6a5..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 = 1200000 # delay 1200s (1,200,000 ms) - self.u_delay = 1000 * self.m_delay # delay 1200s (1,200,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) diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py b/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py deleted file mode 100644 index f5da9d95b7..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip4asym-ip4src254.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Direction 0 --> 1: - - Packet: ETH / IP / - - Source IP address range: 10.10.10.1 - 10.10.10.254 - - Destination IP address range: 20.20.20.1 - - Direction 1 --> 0: - - Packet: ETH / DOT1Q / IP / - - Source IP address range: 20.20.20.1 - 20.20.20.254 - - Destination IP address range: 10.10.10.1 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # VLAN ID - self.vlan_id = 10 - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.10.10.1" - self.p1_src_end_ip = u"10.10.10.254" - self.p1_dst_start_ip = u"20.20.20.1" - - self.p2_src_start_ip = u"20.20.20.1" - self.p2_src_end_ip = u"20.20.20.254" - self.p2_dst_start_ip = u"10.10.10.1" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - Dot1Q( - vlan=self.vlan_id - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py deleted file mode 100644 index 2882027f4c..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py +++ /dev/null @@ -1,171 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: | ETH | IP | - - Direction 0 --> 1: - - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:27:0f - - Source IP address range: 10.0.0.2 - 10.0.39.17 - - Destination IP address range: 20.0.0.1 - - Direction 1 --> 0: - - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:27:0f - - Source IP address range: 20.0.0.2 - 20.0.39.17 - - Destination IP address range: 10.0.0.1 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - self.clients = 10000 - - # MACs used in packet headers. - self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.2" - self.p1_src_end_ip = u"10.0.39.17" - self.p1_dst_start_ip = u"20.0.0.1" - - self.p2_src_start_ip = u"20.0.0.2" - self.p2_src_end_ip = u"20.0.39.17" - self.p2_dst_start_ip = u"10.0.0.1" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether( - src=self.p1_src_start_mac - ) / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether( - src=self.p2_src_start_mac - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset=8 - ), - STLVmFlowVar( - name=u"src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset=8 - ), - STLVmFlowVar( - name=u"src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :returns: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py deleted file mode 100644 index 7792236269..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc500kdst500k.py +++ /dev/null @@ -1,225 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f - - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f - - Source IP address range: 10.0.0.0 - 10.7.161.31 - - Destination IP address range: 20.0.0.0 - 20.7.161.31 - - Direction 1 --> 0: - - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f - - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f - - Source IP address range: 20.0.0.0 - 20.7.161.31 - - Destination IP address range: 10.0.0.0 - 10.7.161.31 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - self.clients = 500000 - - # MACs used in packet headers. - self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.0" - self.p1_src_end_ip = u"10.7.161.31" - - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.7.161.31" - - self.p2_src_start_ip = u"20.0.0.0" - self.p2_src_end_ip = u"20.7.161.31" - - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.7.161.31" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether( - src=self.p1_src_start_mac, - dst=self.p1_dst_start_mac - ) / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether( - src=self.p2_src_start_mac, - dst=self.p2_dst_start_mac - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst100000.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst100000.py deleted file mode 100644 index e1ef224a6b..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst100000.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.1.134.159 - - Direction 1 --> 0: - - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.1.134.159 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.1" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.1.134.159" - - self.p2_src_start_ip = u"20.0.0.1" - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.1.134.159" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000000.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000000.py deleted file mode 100644 index 139cccd561..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000000.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.15.66.63 - - Direction 1 --> 0: - - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.15.66.63 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.1" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.15.66.63" - - self.p2_src_start_ip = u"20.0.0.1" - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.15.66.63" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4src253.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4src253.py deleted file mode 100644 index e1741f98e9..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4src253.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.10.10.2 - 10.10.10.254 - - Destination IP address range: 20.20.20.2 - - Direction 1 --> 0: - - Source IP address range: 20.20.20.2 - 20.20.20.254 - - Destination IP address range: 10.10.10.2 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.10.10.2" - self.p1_src_end_ip = u"10.10.10.254" - self.p1_dst_start_ip = u"20.20.20.2" - - self.p2_src_start_ip = u"20.20.20.2" - self.p2_src_end_ip = u"20.20.20.254" - self.p2_dst_start_ip = u"10.10.10.2" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"src", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc50kdst50k.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc50kdst50k.py deleted file mode 100644 index e56576ae11..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc50kdst50k.py +++ /dev/null @@ -1,225 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f - - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f - - Source IP address range: 10.0.0.0 - 10.0.195.79 - - Destination IP address range: 20.0.0.0 - 20.0.195.79 - - Direction 1 --> 0: - - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f - - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f - - Source IP address range: 20.0.0.0 - 20.0.195.79 - - Destination IP address range: 10.0.0.0 - 10.0.195.79 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - self.clients = 50000 - - # MACs used in packet headers. - self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.0" - self.p1_src_end_ip = u"10.0.195.79" - - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.195.79" - - self.p2_src_start_ip = u"20.0.0.0" - self.p2_src_end_ip = u"20.0.195.79" - - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.0.195.79" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether( - src=self.p1_src_start_mac, - dst=self.p1_dst_start_mac - ) / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether( - src=self.p2_src_start_mac, - dst=self.p2_dst_start_mac - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py deleted file mode 100644 index d71c2d6eab..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc5kdst5k.py +++ /dev/null @@ -1,225 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 - - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 - - Source IP address range: 10.0.0.0 - 10.0.19.135 - - Destination IP address range: 20.0.0.0 - 20.0.19.135 - - Direction 1 --> 0: - - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 - - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 - - Source IP address range: 20.0.0.0 - 20.0.19.135 - - Destination IP address range: 10.0.0.0 - 10.0.19.135 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - self.clients = 5000 - - # MACs used in packet headers. - self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.0" - self.p1_src_end_ip = u"10.0.19.135" - - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.19.135" - - self.p2_src_start_ip = u"20.0.0.0" - self.p2_src_end_ip = u"20.0.19.135" - - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.0.19.135" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether( - src=self.p1_src_start_mac, - dst=self.p1_dst_start_mac - ) / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether( - src=self.p2_src_start_mac, - dst=self.p2_dst_start_mac - ) / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p1_src_start_ip, - max_value=self.p1_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"mac_src", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmFlowVar( - name=u"mac_dst", - min_value=0, - max_value=self.clients-1, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"mac_src", - pkt_offset= 8 - ), - STLVmWrFlowVar( - fv_name=u"mac_dst", - pkt_offset= 2 - ), - STLVmFlowVar( - name=u"ip_src", - min_value=self.p2_src_start_ip, - max_value=self.p2_src_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_src", - pkt_offset=u"IP.src" - ), - STLVmFlowVar( - name=u"ip_dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1000u15p.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1000u15p.py deleted file mode 100644 index 32ed9c08f7..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1000u15p.py +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / UDP - - Direction 0 --> 1: - - Source IP address range: 20.0.0.0 - 20.0.3.231 - - Destination IP address range: 12.0.0.2 - - Source UDP port range: 1024 - 1038 - - Destination UDP port range: 1024 - - Direction 1 --> 0: - - Source IP address range: 12.0.0.2 - - Destination IP address range: 200.0.0.0 - - Source UDP port range: 1024 - - Destination UDP port range: 1024 - 16023 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"20.0.0.0" - self.p1_src_end_ip = u"20.0.3.231" - self.p1_dst_start_ip = u"12.0.0.2" - - self.p2_src_start_ip = u"12.0.0.2" - self.p2_src_end_ip = u"12.0.0.2" - self.p2_dst_start_ip = u"200.0.0.0" - - # UDP ports used in packet headers. - self.p1_src_start_udp_port = 1024 - self.p1_src_end_udp_port = 1038 - self.p1_dst_start_udp_port = 1024 - - self.p2_src_start_udp_port = 1024 - self.p2_dst_start_udp_port = 1024 - self.p2_dst_end_udp_port = 16023 - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | UDP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=17 - ) / - UDP( - sport=self.p1_src_start_udp_port, - dport=self.p1_dst_start_udp_port - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=17 - ) / - UDP( - sport=self.p2_src_start_udp_port, - dport=self.p2_dst_start_udp_port - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmTupleGen( - ip_min=self.p1_src_start_ip, - ip_max=self.p1_src_end_ip, - port_min=self.p1_src_start_udp_port, - port_max=self.p1_src_end_udp_port, - name=u"tuple" - ), - STLVmWrFlowVar( - fv_name=u"tuple.ip", - pkt_offset=u"IP.src" - ), - STLVmFixIpv4( - offset=u"IP" - ), - STLVmWrFlowVar( - fv_name=u"tuple.port", - pkt_offset=u"UDP.sport" - ) - ] - ) - # Direction 0 --> 1 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"dport", - min_value=self.p2_dst_start_udp_port, - max_value=self.p2_dst_end_udp_port, - size=2, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"dport", - pkt_offset=u"UDP.dport" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u1000p-conc.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u1000p-conc.py deleted file mode 100644 index 25dddb7de2..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u1000p-conc.py +++ /dev/null @@ -1,199 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / UDP - - Direction 0 --> 1: - - Source IP address range: 10.10.10.2 - 10.10.10.11 - - Destination IP address range: 20.20.20.2 - 20.20.20.11 - - Source UDP port range: 1001 - 2000 - - Destination UDP port range: 2001 - 3000 - - Direction 1 --> 0: - - Source IP address range: 20.20.20.2 - 20.20.20.11 - - Destination IP address range: 10.10.10.2 - 10.10.10.11 - - Source UDP port range: 2001 - 3000 - - Destination UDP port range: 1001 - 2000 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.10.10.2" - self.p1_src_end_ip = u"10.10.10.11" - self.p1_dst_start_ip = u"20.20.20.2" - self.p1_dst_end_ip = u"20.20.20.11" - - self.p2_src_start_ip = u"20.20.20.2" - self.p2_src_end_ip = u"20.20.20.11" - self.p2_dst_start_ip = u"10.10.10.2" - self.p2_dst_end_ip = u"10.10.10.11" - - # UDP ports used in packet headers. - self.p1_src_start_udp_port = 1001 - self.p1_src_end_udp_port = 2000 - self.p1_dst_start_udp_port = 2001 - self.p1_dst_end_udp_port = 3000 - - self.p2_src_start_udp_port = 2001 - self.p2_src_end_udp_port = 3000 - self.p2_dst_start_udp_port = 1001 - self.p2_dst_end_udp_port = 2000 - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | UDP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=17 - ) / - UDP( - sport=self.p1_src_start_udp_port, - dport=self.p1_dst_start_udp_port - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=17 - ) / - UDP( - sport=self.p2_src_start_udp_port, - dport=self.p2_dst_start_udp_port - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmTupleGen( - ip_min=self.p1_src_start_ip, - ip_max=self.p1_src_end_ip, - port_min=self.p1_src_start_udp_port, - port_max=self.p1_src_end_udp_port, - name=u"tuple1_src" - ), - STLVmTupleGen( - ip_min=self.p1_dst_start_ip, - ip_max=self.p1_dst_end_ip, - port_min=self.p1_dst_start_udp_port, - port_max=self.p1_dst_end_udp_port, - name=u"tuple1_dst" - ), - STLVmWrFlowVar( - fv_name=u"tuple1_src.ip", - pkt_offset=u"IP.src" - ), - STLVmWrFlowVar( - fv_name=u"tuple1_dst.ip", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ), - STLVmWrFlowVar( - fv_name=u"tuple1_src.port", - pkt_offset=u"UDP.sport" - ), - STLVmWrFlowVar( - fv_name=u"tuple1_dst.port", - pkt_offset=u"UDP.dport" - ) - ] - ) - # Direction 0 --> 1 - vm2 = STLScVmRaw( - [ - STLVmTupleGen( - ip_min=self.p2_src_start_ip, - ip_max=self.p2_src_end_ip, - port_min=self.p2_src_start_udp_port, - port_max=self.p2_src_end_udp_port, - name=u"tuple2_src" - ), - STLVmTupleGen( - ip_min=self.p2_dst_start_ip, - ip_max=self.p2_dst_end_ip, - port_min=self.p2_dst_start_udp_port, - port_max=self.p2_dst_end_udp_port, - name=u"tuple2_dst" - ), - STLVmWrFlowVar( - fv_name=u"tuple2_src.ip", - pkt_offset=u"IP.src" - ), - STLVmWrFlowVar( - fv_name=u"tuple2_dst.ip", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ), - STLVmWrFlowVar( - fv_name=u"tuple2_src.port", - pkt_offset=u"UDP.sport" - ), - STLVmWrFlowVar( - fv_name=u"tuple2_dst.port", - pkt_offset=u"UDP.dport" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip6-ip6src253.py b/GPL/traffic_profiles/trex/trex-stl-3n-ethip6-ip6src253.py deleted file mode 100644 index 124f57e2be..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip6-ip6src253.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::2 - 2001:1::FE - - Destination IP address range: 2001:2::2 - - Direction 1 --> 0: - - Source IP address range: 2001:2::2 - 2001:2::FE - - Destination IP address range: 2001:1::2 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::2" - self.p1_src_end_ip = u"2001:1::FE" - self.p1_dst_start_ip = u"2001:2::2" - - self.p2_src_start_ip = u"2001:2::2" - self.p2_src_end_ip = u"2001:2::FE" - self.p2_dst_start_ip = u"2001:1::2" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_src_start_ip, - self.p1_src_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_src_start_ip, - self.p2_src_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_src", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_src", - pkt_offset=u"IPv6.src", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_src", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_src", - pkt_offset=u"IPv6.src", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan100ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan100ip4src254ip4dst254.py index ae8d9ea112..45f2f6c9e9 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan100ip4src254ip4dst254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan100ip4src254ip4dst254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan10ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan10ip4src254ip4dst254.py index 9ed8f69817..5b8afc3336 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan10ip4src254ip4dst254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan10ip4src254ip4dst254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan1ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-2.py index 4e28f32c4c..f5a8050ae2 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan1ip4src254ip4dst254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py index fcd4067be6..54e4c6470e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254.py index a4ffecf3d4..3561850068 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1ip4src254ip4dst254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan1kip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1kip4src254ip4dst254.py index 3ba51899a4..58aab36e26 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-dot1qip4-vlan1kip4src254ip4dst254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4-vlan1kip4src254ip4dst254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4src254.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4asym-ip4src254.py index 8afc3b6fd5..f95ebc371b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4src254.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4asym-ip4src254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -25,11 +25,12 @@ Stream profile: - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - Direction 0 --> 1: + - Packet: ETH / IP / - Source IP address range: 10.10.10.1 - 10.10.10.254 - Destination IP address range: 20.20.20.1 - Direction 1 --> 0: + - Packet: ETH / DOT1Q / IP / - Source IP address range: 20.20.20.1 - 20.20.20.254 - Destination IP address range: 10.10.10.1 """ @@ -46,6 +47,9 @@ class TrafficStreams(TrafficStreamsBaseClass): super(TrafficStreamsBaseClass, self).__init__() + # VLAN ID + self.vlan_id = 10 + # IPs used in packet headers. self.p1_src_start_ip = u"10.10.10.1" self.p1_src_end_ip = u"10.10.10.254" @@ -76,6 +80,9 @@ class TrafficStreams(TrafficStreamsBaseClass): # Direction 1 --> 0 base_pkt_b = ( Ether() / + Dot1Q( + vlan=self.vlan_id + ) / IP( src=self.p2_src_start_ip, dst=self.p2_dst_start_ip, diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src10udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src10udpsrcrnd.py index 03328fcfaa..ed2181ef3e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src10udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src10udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src1udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src1udpsrcrnd.py index e4e6f75e34..077b866b2b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src1udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src1udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src2udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src2udpsrcrnd.py index 121c0a82c0..2aff7fa867 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src2udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src2udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src4udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src4udpsrcrnd.py index 10739c335a..763c56bd0a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src4udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src4udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src6udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src6udpsrcrnd.py index 9723941150..54af270c63 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src6udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src6udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py index a1cf195bfa..0874a5efd6 100644 --- a/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip4vxlan-ip4src8udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -60,7 +60,7 @@ _VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") class VXLAN(Packet): - name=u"VXLAN" + name = u"VXLAN" fields_desc = [ FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), ThreeBytesField(u"vni", 0), @@ -295,4 +295,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip6asym-ip6src253.py b/GPL/traffic_profiles/trex/trex-stl-dot1qip6asym-ip6src253.py index a126e7a678..d8c0aa3fdd 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-dot1qip6asym-ip6src253.py +++ b/GPL/traffic_profiles/trex/trex-stl-dot1qip6asym-ip6src253.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-1024t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-1024t.py index 42c015272d..4613283605 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-1024t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-1024t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-16t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-16t.py index 151ae505c8..48c4e75401 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-16t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-16t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-1t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-1t.py index a62577e292..23a32f5177 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-1t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-1t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-256t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-256t.py index 8098f919d5..4d53ea5140 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-256t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-256t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-4t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-4t.py index 975d204d7d..06616e18ec 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-4t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-4t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-64t.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-64t.py index fd1fa88a52..704ceb84b5 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-geneve-64t.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-geneve-64t.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-2p.py new file mode 100644 index 0000000000..1149a0403b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-2p.py @@ -0,0 +1,113 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.0.39.15", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.0.39.15", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-6p.py new file mode 100644 index 0000000000..34ca59fe84 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000-6p.py @@ -0,0 +1,141 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.0.39.15", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.0.39.15", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.0.39.15", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.0.39.15", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.0.39.15", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.0.39.15", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000.py deleted file mode 100644 index ef2dcde696..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd10000.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.0.39.15 - - Direction 1 --> 0: - - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.0.39.15 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.1" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.39.15" - - self.p2_src_start_ip = u"20.0.0.1" - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.0.39.15" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - seed=1, - # Cycle length. TRex does not allow any higher value. - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - # Using a different seed to be extra sure - # nothing useful gets cached. - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-2p.py new file mode 100644 index 0000000000..955e394c56 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-2p.py @@ -0,0 +1,113 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.1.134.159", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.1.134.159", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-6p.py new file mode 100644 index 0000000000..23de4e48a3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000-6p.py @@ -0,0 +1,141 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.1.134.159", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.1.134.159", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.1.134.159", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.1.134.159", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.1.134.159", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.1.134.159", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000.py deleted file mode 100644 index ff9077192f..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd100000.py +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.1.134.159 - - Direction 1 --> 0: - - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.1.134.159 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.1" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.1.134.159" - - self.p2_src_start_ip = u"20.0.0.1" - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.1.134.159" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - seed=1, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-2p.py new file mode 100644 index 0000000000..3a03303e60 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-2p.py @@ -0,0 +1,113 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.15.66.63", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.15.66.63", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-6p.py new file mode 100644 index 0000000000..141a5f2123 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000-6p.py @@ -0,0 +1,141 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.15.66.63", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.15.66.63", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.15.66.63", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.15.66.63", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.15.66.63", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.15.66.63", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000.py deleted file mode 100644 index 4a315c72ed..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst-rnd1000000.py +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / - - Direction 0 --> 1: - - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.15.66.63 - - Direction 1 --> 0: - - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.15.66.63 -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"10.0.0.1" - self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.15.66.63" - - self.p2_src_start_ip = u"20.0.0.1" - self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.15.66.63" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IP | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IP( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip, - proto=61 - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IP( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip, - proto=61 - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p1_dst_start_ip, - max_value=self.p1_dst_end_ip, - size=4, - seed=1, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"dst", - min_value=self.p2_dst_start_ip, - max_value=self.p2_dst_end_ip, - size=4, - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"dst", - pkt_offset=u"IP.dst" - ), - STLVmFixIpv4( - offset=u"IP" - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1-udir.py new file mode 100644 index 0000000000..1a52b30510 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1-udir.py @@ -0,0 +1,84 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address: 10.0.0.1 + - Destination IP address: 20.0.0.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_ip = u"10.0.0.1" + self.p1_dst_ip = u"20.0.0.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_ip, + dst=self.p1_dst_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + return base_pkt_a, base_pkt_b, None, None + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1.py index 371323ea4e..d73c8519ea 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst100.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100.py index 3b0594e293..fb45774007 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst100.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-1cnf.py index 9d15e9ea28..d11f5d5d9b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-2cnf.py index 7fefc279db..28756f3a16 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -163,4 +163,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-4cnf.py index e8fc20f488..6249612fc4 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-8cnf.py index ab2aaae36a..2e7d4d6f44 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-udir.py new file mode 100644 index 0000000000..fbba5d4c3b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000.py index ffc53930dd..554eb0bca4 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst1000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-1cnf.py index 90c741d7dc..97ea55a72b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-2cnf.py index 34a089abf1..8fc52f134e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-2p.py new file mode 100644 index 0000000000..2dda26ddaf --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-2p.py @@ -0,0 +1,110 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.0.39.15" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.0.39.15" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-4cnf.py index 24611f1ec6..c2a537a638 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-6p.py new file mode 100644 index 0000000000..94a47a8bb6 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-6p.py @@ -0,0 +1,134 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.0.39.15" + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.0.39.15" + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.0.39.15" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.0.39.15" + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.0.39.15" + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.0.39.15" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-8cnf.py index 8217450185..9b3d280f4a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-udir.py new file mode 100644 index 0000000000..f643f3e3cc --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst10000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000.py index fc6ac6ef57..29ebf97b80 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst10000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst10000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-2p.py new file mode 100644 index 0000000000..a8d223b854 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-2p.py @@ -0,0 +1,110 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.1.134.159" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.1.134.159" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-6p.py new file mode 100644 index 0000000000..76042447ca --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000-6p.py @@ -0,0 +1,134 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.1.134.159" + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.1.134.159" + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.1.134.159" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.1.134.159" + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.1.134.159" + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.1.134.159" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst100000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000.py index a16e26c335..312deccbc8 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst100000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst100000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-2p.py new file mode 100644 index 0000000000..f2e7938ff2 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-2p.py @@ -0,0 +1,110 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.15.66.63" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.15.66.63" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-6p.py new file mode 100644 index 0000000000..6474b43470 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000-6p.py @@ -0,0 +1,134 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IP / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "10.0.0.1", + "dst_start_ip": "20.0.0.0", + "dst_end_ip": "20.15.66.63" + }, + # Direction W --> E: + { + "src_start_ip": "30.0.0.1", + "dst_start_ip": "40.0.0.0", + "dst_end_ip": "40.15.66.63" + }, + # Direction W --> E: + { + "src_start_ip": "50.0.0.1", + "dst_start_ip": "60.0.0.0", + "dst_end_ip": "60.15.66.63" + }, + # Direction E --> W: + { + "src_start_ip": "20.0.0.1", + "dst_start_ip": "10.0.0.0", + "dst_end_ip": "10.15.66.63" + }, + # Direction E --> W: + { + "src_start_ip": "40.0.0.1", + "dst_start_ip": "30.0.0.0", + "dst_end_ip": "30.15.66.63" + }, + # Direction E --> W: + { + "src_start_ip": "60.0.0.1", + "dst_start_ip": "50.0.0.0", + "dst_end_ip": "50.15.66.63" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Base packets to be sent and transformation function. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + self.pkt_base.append( + Ether() / + IP( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"], + proto=61 + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.pkt_data[i]["dst_start_ip"], + max_value=self.pkt_data[i]["dst_end_ip"], + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-Rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst1000000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000.py index 37bc69d366..909da92426 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4dst1000000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst1000000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2-udir.py new file mode 100644 index 0000000000..f86306295b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2.py new file mode 100644 index 0000000000..864ad19f4e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst2.py @@ -0,0 +1,135 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.1 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.1" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-1cnf.py index 76a8299904..f8caca1181 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-2cnf.py index dff6e0209e..dc7c0ebc9e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-4cnf.py index c28e214995..84a920463a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-8cnf.py index 664e341b07..f4e9820091 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-udir.py new file mode 100644 index 0000000000..a076477d5f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000.py index 713a826366..7bedccf9a5 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst20000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst20000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst253.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst253.py index 1a129cc82b..b32433f817 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst253.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst253.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst253_l3fwd.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst253_l3fwd.py index 736e739da4..54ff7aba29 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst253_l3fwd.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst253_l3fwd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-1cnf.py index 66e0980e58..e03627113c 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-2cnf.py index 858ff84652..1f8a8398ae 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-4cnf.py index 42698bf7dc..ced715c16b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-udir.py new file mode 100644 index 0000000000..5f293a32ec --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.3 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.3" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4.py index 2a763b8fa7..ecec1bf353 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst4.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst4.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-1cnf.py index a52c3d91e8..7c3f6698af 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-2cnf.py index 78be186d91..8b76f33152 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -145,7 +145,7 @@ class TrafficStreams(TrafficStreamsBaseClass): STLVmWrFlowVar( fv_name=u"dst", pkt_offset=u"IP.dst" - ), + ), STLVmFixIpv4( offset=u"IP" ) @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-4cnf.py index e49ffeeacd..21768e9ef0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-8cnf.py index b09b024a16..47f087e11b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-udir.py new file mode 100644 index 0000000000..b76c9e1698 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40.py index 7ba4012694..d30d357bc9 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-1cnf.py index 1af2c4c841..6ac54334f8 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-2cnf.py index 4acd1faf40..882675afae 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-4cnf.py index 302bd20f3c..35ea970656 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-8cnf.py index e92efb927e..1ece5c3e2a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-udir.py new file mode 100644 index 0000000000..68543c8f7e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400.py index 72ed46e7f5..9bd7737be6 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst400.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst400.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-1cnf.py index 14e258552b..5e0fe7d9b0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-2cnf.py index ac0c503f67..784539c830 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-4cnf.py index 2c301efed2..f478e7001d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-8cnf.py index 96bc3fbb26..e31ad2bc74 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-udir.py new file mode 100644 index 0000000000..4e6f271ed4 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000.py index ac9fc74bb2..5a51902642 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst40000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst40000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-1cnf.py index 02620e00e9..a895626c82 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-2cnf.py index 03662d514e..e73426590e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-4cnf.py index d8f8e69a6d..4461963314 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-8cnf.py index 1c793b98a1..d7d2e2d1ec 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-udir.py new file mode 100644 index 0000000000..1d0d52a0a7 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000.py index 5677878102..1fe61837d4 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst5000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst5000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst500000.py index e8041098f7..051d566b20 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst10000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst500000.py @@ -1,4 +1,5 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Intel and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -28,10 +29,10 @@ Stream profile: - Packet: ETH / IP / - Direction 0 --> 1: - Source IP address range: 10.0.0.1 - - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Destination IP address range: 20.0.0.0 - 20.7.161.31 - Direction 1 --> 0: - Source IP address range: 20.0.0.1 - - Destination IP address range: 10.0.0.0 - 10.0.39.15 + - Destination IP address range: 10.0.0.0 - 10.7.161.31 """ from trex.stl.api import * @@ -49,11 +50,11 @@ class TrafficStreams(TrafficStreamsBaseClass): # IPs used in packet headers. self.p1_src_start_ip = u"10.0.0.1" self.p1_dst_start_ip = u"20.0.0.0" - self.p1_dst_end_ip = u"20.0.39.15" + self.p1_dst_end_ip = u"20.7.161.31" self.p2_src_start_ip = u"20.0.0.1" self.p2_dst_start_ip = u"10.0.0.0" - self.p2_dst_end_ip = u"10.0.39.15" + self.p2_dst_end_ip = u"10.7.161.31" def define_packets(self): """Defines the packets to be sent from the traffic generator. diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-1cnf.py index 43ef04ffbe..49d35f1da0 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-1cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-1cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-2cnf.py index 5a8c9f7f3d..a673b0bd98 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-2cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-2cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-4cnf.py index 5fc755b2d1..d9fc1a4718 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-4cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-4cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-8cnf.py index f655046bea..3674818810 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000-8cnf.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-8cnf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -164,4 +164,3 @@ def register(): :rtype: Object """ return TrafficStreams() - diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-udir.py new file mode 100644 index 0000000000..e037734f15 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000.py index d00fb76e78..e6e13343bb 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4dst60000.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst60000.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -96,7 +96,7 @@ class TrafficStreams(TrafficStreamsBaseClass): STLVmWrFlowVar( fv_name=u"dst", pkt_offset=u"IP.dst" - ), + ), STLVmFixIpv4( offset=u"IP" ) diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8-udir.py new file mode 100644 index 0000000000..c6d383cfd8 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8-udir.py @@ -0,0 +1,107 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.7 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.7" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw() + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8.py new file mode 100644 index 0000000000..7cbe1f9573 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4dst8.py @@ -0,0 +1,135 @@ +# Copyright (c) 2023 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.7 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.7 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.7" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.7" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src1000ip4dst1000.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src1000ip4dst1000.py new file mode 100644 index 0000000000..8a79cdd7f5 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src1000ip4dst1000.py @@ -0,0 +1,165 @@ +# Copyright (c) 2023 Intel and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.0 - 10.3.231.0 + - Destination IP address range: 20.0.0.0 - 20.3.231.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.0 - 20.3.231.0 + - Destination IP address range: 10.0.0.0 - 10.3.231.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.3.231.0" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.3.231.0" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.3.231.0" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.3.231.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src100ip4dst100.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src100ip4dst100.py new file mode 100644 index 0000000000..681e594136 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src100ip4dst100.py @@ -0,0 +1,165 @@ +# Copyright (c) 2023 Intel and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.0 - 10.0.99.0 + - Destination IP address range: 20.0.0.0 - 20.0.99.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.0 - 20.0.99.0 + - Destination IP address range: 10.0.0.0 - 10.0.99.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.99.0" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.99.0" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.99.0" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.99.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1u1p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src1ip4dst1.py index 3c2ae8f023..9a33b33522 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1u1p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src1ip4dst1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Intel and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -25,17 +25,13 @@ Stream profile: - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IP / UDP + - Packet: ETH / IP / - Direction 0 --> 1: - - Source IP address range: 20.0.0.0 - - Destination IP address range: 12.0.0.2 - - Source UDP port range: 1024 - - Destination UDP port range: 1024 + - Source IP address range: 10.0.0.0 + - Destination IP address range: 20.0.0.0 - Direction 1 --> 0: - - Source IP address range: 12.0.0.2 - - Destination IP address range: 200.0.0.0 - - Source UDP port range: 1024 - - Destination UDP port range: 1028 + - Source IP address range: 20.0.0.0 + - Destination IP address range: 10.0.0.0 """ from trex.stl.api import * @@ -51,23 +47,16 @@ class TrafficStreams(TrafficStreamsBaseClass): super(TrafficStreamsBaseClass, self).__init__() # IPs used in packet headers. - self.p1_src_ip = u"20.0.0.0" - self.p1_dst_ip = u"12.0.0.2" - - self.p2_src_ip = u"12.0.0.2" - self.p2_dst_ip = u"200.0.0.0" - - # UDP ports used in packet headers. - self.p1_src_udp_port = 1024 - self.p1_dst_udp_port = 1024 + self.p1_src_ip = u"10.0.0.0" + self.p1_dst_ip = u"20.0.0.0" - self.p2_src_udp_port = 1024 - self.p2_dst_udp_port = 1028 + self.p2_src_ip = u"20.0.0.0" + self.p2_dst_ip = u"10.0.0.0" def define_packets(self): """Defines the packets to be sent from the traffic generator. - Packet definition: | ETH | IP | UDP | + Packet definition: | ETH | IP | :returns: Packets to be sent from the traffic generator. :rtype: tuple @@ -79,11 +68,7 @@ class TrafficStreams(TrafficStreamsBaseClass): IP( src=self.p1_src_ip, dst=self.p1_dst_ip, - proto=17 - ) / - UDP( - sport=self.p1_src_udp_port, - dport=self.p1_dst_udp_port + proto=61 ) ) # Direction 1 --> 0 @@ -92,11 +77,7 @@ class TrafficStreams(TrafficStreamsBaseClass): IP( src=self.p2_src_ip, dst=self.p2_dst_ip, - proto=17 - ) / - UDP( - sport=self.p2_src_udp_port, - dport=self.p2_dst_udp_port + proto=61 ) ) diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4src253.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src253.py index e1741f98e9..bb287474f7 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-ip4src253.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src253.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4src254.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src254.py index 8afc3b6fd5..ce0c04f2e7 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-ip4src254.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src254.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src2ip4dst2.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src2ip4dst2.py new file mode 100644 index 0000000000..58d2c0a499 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src2ip4dst2.py @@ -0,0 +1,165 @@ +# Copyright (c) 2023 Intel and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.0 - 10.0.1.0 + - Destination IP address range: 20.0.0.0 - 20.0.1.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.0 - 20.0.1.0 + - Destination IP address range: 10.0.0.0 - 10.0.1.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.1.0" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.0" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.1.0" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src4ip4dst4.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src4ip4dst4.py new file mode 100644 index 0000000000..4f517a77ce --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src4ip4dst4.py @@ -0,0 +1,165 @@ +# Copyright (c) 2023 Intel and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.0 - 10.0.3.0 + - Destination IP address range: 20.0.0.0 - 20.0.3.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.0 - 20.0.3.0 + - Destination IP address range: 10.0.0.0 - 10.0.3.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.3.0" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.0" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.3.0" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src8ip4dst8.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src8ip4dst8.py new file mode 100644 index 0000000000..d11a7b50b5 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-ip4src8ip4dst8.py @@ -0,0 +1,165 @@ +# Copyright (c) 2023 Intel and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.0 - 10.0.7.0 + - Destination IP address range: 20.0.0.0 - 20.0.7.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.0 - 20.0.7.0 + - Destination IP address range: 10.0.0.0 - 10.0.7.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.7.0" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.7.0" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.7.0" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.7.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + step=256, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc100ip4src100.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc100ip4src100.py index f668e2ad19..8ec4a4b35d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc100ip4src100.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc100ip4src100.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc100kip4src100k.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc100kip4src100k.py index d3f10fc8ff..9a3c15de6d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc100kip4src100k.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc100kip4src100k.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc10kip4src10k.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc10kip4src10k.py index 2882027f4c..4968fc718b 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc10kip4src10k.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc10kip4src10k.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc500kdst500k.py index c2e37fd3cd..36d1a08e1e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4-macsrc500kdst500k.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc500kdst500k.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -150,11 +150,11 @@ class TrafficStreams(TrafficStreamsBaseClass): op=u"inc" ), STLVmWrFlowVar( - fv_name=u"ip_dst", - pkt_offset=u"IP.dst" + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" ), STLVmFixIpv4( - offset=u"IP" + offset=u"IP" ) ] ) diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc50kdst50k.py index 49d1032abb..6d41e67b0d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc50kdst50k.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc50kdst50k.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -124,11 +124,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -176,11 +176,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc5kdst5k.py index d71c2d6eab..0b053795d9 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc5kdst5k.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4-macsrc5kdst5k.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -125,11 +125,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", @@ -177,11 +177,11 @@ class TrafficStreams(TrafficStreamsBaseClass): ), STLVmWrFlowVar( fv_name=u"mac_src", - pkt_offset= 8 + pkt_offset=8 ), STLVmWrFlowVar( fv_name=u"mac_dst", - pkt_offset= 2 + pkt_offset=2 ), STLVmFlowVar( name=u"ip_src", diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-1000u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1000u15p.py index b8abc8a069..6e07b5175d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-1000u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1000u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-100u1000p-conc.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-100u1000p-conc.py index 081531bd91..4e860edf46 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-100u1000p-conc.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-100u1000p-conc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-100u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-100u15p.py index b870ce11d0..8f31e90d99 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-100u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-100u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p-udir.py index 210313f66a..30c6440dd8 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p-udir.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p-udir.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p.py index c104605d50..3b920cd3c8 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1024u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1048576u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1048576u63p.py index db9e317faf..a99d78e78d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1048576u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1048576u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-10u1000p-conc.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u1000p-conc.py index 6ba4c34340..aecef71d4c 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-10u1000p-conc.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u1000p-conc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u10p-conc.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u10p-conc.py index ba7fbc874d..406bce919f 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u10p-conc.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u10p-conc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u15p.py index 9b85dd529d..7506012069 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-10u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-10u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # @@ -92,7 +92,7 @@ class TrafficStreams(TrafficStreamsBaseClass): ) # Direction 1 --> 0 base_pkt_b = ( - Ether() / + Ether() / IP( src=self.p2_src_start_ip, dst=self.p2_dst_start_ip, @@ -130,7 +130,7 @@ class TrafficStreams(TrafficStreamsBaseClass): # Direction 0 --> 1 vm2 = STLScVmRaw( [ - STLVmFlowVar( + STLVmFlowVar( name=u"dport", min_value=self.p2_dst_start_udp_port, max_value=self.p2_dst_end_udp_port, diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p-udir.py index 7d9d4c6f4c..da826809f8 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p-udir.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p-udir.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p.py index 54d115e104..1c5d69fcda 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-16384u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1u15p.py index a58842b022..7fba7c4b85 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-1u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-1u1p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1u1p.py index 9a88d7fcea..229ea2218c 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-1u1p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-1u1p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-2000u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-2000u15p.py index 60b43b5e0b..1100bdd3ed 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-2000u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-2000u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p-udir.py index b499842dca..09f8e88f13 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p-udir.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p-udir.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p.py index 5277189148..406321b7cf 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-262144u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-4000u15p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4000u15p.py index 0e259992b6..7257dcc62d 100644 --- a/GPL/traffic_profiles/trex/trex-stl-3n-ethip4udp-4000u15p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4000u15p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p-udir.py index 202c123abb..7d441bf1e2 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p-udir.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p-udir.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p.py index 7c90dbe7ae..0c4613b93f 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-4096u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p-udir.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p-udir.py index d678517f78..9f3a1172d4 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p-udir.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p-udir.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p.py index e2ef21e047..be5e990c4e 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-65536u63p.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-lb.py b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-lb.py index f11b476aa6..850149fc61 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4udp-lb.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4udp-lb.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Intel and/or its affiliates. +# Copyright (c) 2023 Intel and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip4vxlan-ip4src1udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-stl-ethip4vxlan-ip4src1udpsrcrnd.py index 6c277c18bf..56a1ee3321 100644 --- a/GPL/traffic_profiles/trex/trex-stl-ethip4vxlan-ip4src1udpsrcrnd.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip4vxlan-ip4src1udpsrcrnd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-2p.py new file mode 100644 index 0000000000..e3d39cc31e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-2p.py @@ -0,0 +1,115 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::270F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::270F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-6p.py new file mode 100644 index 0000000000..564ffbb83d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd10000-6p.py @@ -0,0 +1,143 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::270F", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::270F", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::270F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::270F", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::270F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::270F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-2p.py new file mode 100644 index 0000000000..8948e785a4 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-2p.py @@ -0,0 +1,115 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::1:869F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::1:869F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-6p.py new file mode 100644 index 0000000000..374be384ef --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd100000-6p.py @@ -0,0 +1,143 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::1:869F", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::1:869F", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::1:869F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::1:869F", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::1:869F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::1:869F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-2p.py new file mode 100644 index 0000000000..735888d265 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-2p.py @@ -0,0 +1,115 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::F:423F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::F:423F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-6p.py new file mode 100644 index 0000000000..c0e3ee4ab5 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst-rnd1000000-6p.py @@ -0,0 +1,143 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::F:423F", + "seed": 1 + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::F:423F", + "seed": 2 + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::F:423F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::F:423F", + "seed": 2 + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::F:423F", + "seed": 1 + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::F:423F", + "seed": 2 + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + seed=self.pkt_data[i]["seed"], + limit=(2**24 - 1) + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-2p.py new file mode 100644 index 0000000000..7a02aac9f8 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-2p.py @@ -0,0 +1,112 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::270F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::270F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-6p.py new file mode 100644 index 0000000000..f72bc2365e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-6p.py @@ -0,0 +1,136 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::270F" + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::270F" + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::270F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::270F" + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::270F" + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::270F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-rnd.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-rnd.py deleted file mode 100644 index 0e335909f4..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000-rnd.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::270F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::270F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::270F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::270F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - seed=1, - # Cycle length. TRex does not allow any higher value. - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000.py deleted file mode 100644 index 9aa4fd5ee4..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst10000.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::270F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::270F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::270F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::270F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-2p.py new file mode 100644 index 0000000000..11279216a0 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-2p.py @@ -0,0 +1,112 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::1:869F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::1:869F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-6p.py new file mode 100644 index 0000000000..f1e0e4c9c7 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-6p.py @@ -0,0 +1,136 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::1:869F" + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::1:869F" + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::1:869F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::1:869F" + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::1:869F" + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::1:869F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-rnd.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-rnd.py deleted file mode 100644 index daa160d53a..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000-rnd.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::1:869F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::1:869F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::1:869F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::1:869F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - seed=1, - # Cycle length. TRex does not allow any higher value. - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000.py deleted file mode 100644 index f78d98c64f..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst100000.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::1:869F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::1:869F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::1:869F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::1:869F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-2p.py new file mode 100644 index 0000000000..0057c8b4b9 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-2p.py @@ -0,0 +1,112 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::F:423F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::F:423F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-6p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-6p.py new file mode 100644 index 0000000000..4a1307c510 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-6p.py @@ -0,0 +1,136 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Three parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::F:423F" + }, + # Direction W --> E: + { + "src_start_ip": "2300::1", + "dst_start_ip": "2400::0", + "dst_end_ip": "2400::F:423F" + }, + # Direction W --> E: + { + "src_start_ip": "2500::1", + "dst_start_ip": "2600::0", + "dst_end_ip": "2600::F:423F" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::F:423F" + }, + # Direction E --> W: + { + "src_start_ip": "2400::1", + "dst_start_ip": "2300::0", + "dst_end_ip": "2300::F:423F" + }, + # Direction E --> W: + { + "src_start_ip": "2600::1", + "dst_start_ip": "2500::0", + "dst_end_ip": "2500::F:423F" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8, + op="inc" + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-rnd.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-rnd.py deleted file mode 100644 index a372e1ae3b..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000-rnd.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::F:423F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::F:423F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::F:423F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::F:423F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - seed=1, - # Cycle length. TRex does not allow any higher value. - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVarRepeatableRandom( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - seed=2, - limit=(2**24 - 1) - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000.py deleted file mode 100644 index 572eed4256..0000000000 --- a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst1000000.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. -# -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later -# -# Licensed under the Apache License 2.0 or -# GNU General Public License v2.0 or later; you may not use this file -# except in compliance with one of these Licenses. You -# may obtain a copy of the Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html -# -# Note: If this file is linked with Scapy, which is GPLv2+, your use of it -# must be under GPLv2+. If at any point in the future it is no longer linked -# with Scapy (or other GPLv2+ licensed software), you are free to choose -# Apache 2. -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Stream profile for T-rex traffic generator. - -Stream profile: - - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. - - Packet: ETH / IPv6 / - - Direction 0 --> 1: - - Source IP address range: 2001:1::1 - - Destination IP address range: 2001:2::0 - 2001:2::F:423F - - Direction 1 --> 0: - - Source IP address range: 2001:2::1 - - Destination IP address range: 2001:1::0 - 2001:1::F:423F -""" - -from trex.stl.api import * -from profile_trex_stateless_base_class import TrafficStreamsBaseClass - - -class TrafficStreams(TrafficStreamsBaseClass): - """Stream profile.""" - - def __init__(self): - """Initialization and setting of streams' parameters.""" - - super(TrafficStreamsBaseClass, self).__init__() - - # IPs used in packet headers. - self.p1_src_start_ip = u"2001:1::1" - self.p1_dst_start_ip = u"2001:2::0" - self.p1_dst_end_ip = u"2001:2::F:423F" - - self.p2_src_start_ip = u"2001:2::1" - self.p2_dst_start_ip = u"2001:1::0" - self.p2_dst_end_ip = u"2001:1::F:423F" - - def define_packets(self): - """Defines the packets to be sent from the traffic generator. - - Packet definition: | ETH | IPv6 | - - :returns: Packets to be sent from the traffic generator. - :rtype: tuple - """ - - base_p1, count_p1 = self._get_start_end_ipv6( - self.p1_dst_start_ip, - self.p1_dst_end_ip - ) - base_p2, count_p2 = self._get_start_end_ipv6( - self.p2_dst_start_ip, - self.p2_dst_end_ip - ) - - # Direction 0 --> 1 - base_pkt_a = ( - Ether() / - IPv6( - src=self.p1_src_start_ip, - dst=self.p1_dst_start_ip - ) - ) - # Direction 1 --> 0 - base_pkt_b = ( - Ether() / - IPv6( - src=self.p2_src_start_ip, - dst=self.p2_dst_start_ip - ) - ) - - # Direction 0 --> 1 - vm1 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p1, - max_value=base_p1 + count_p1, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - # Direction 1 --> 0 - vm2 = STLScVmRaw( - [ - STLVmFlowVar( - name=u"ipv6_dst", - min_value=base_p2, - max_value=base_p2 + count_p2, - size=8, - op=u"inc" - ), - STLVmWrFlowVar( - fv_name=u"ipv6_dst", - pkt_offset=u"IPv6.dst", - offset_fixup=8 - ) - ] - ) - - return base_pkt_a, base_pkt_b, vm1, vm2 - - -def register(): - """Register this traffic profile to T-rex. - - Do not change this function. - - :return: Traffic streams. - :rtype: Object - """ - return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst500000-2p.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst500000-2p.py new file mode 100644 index 0000000000..d85f9a5f54 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6dst500000-2p.py @@ -0,0 +1,111 @@ +# Copyright (c) 2024 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Single parallel bi-directional streams sent as W --> E and E --> W + at the same time. + - Packet: ETH / IPv6 / +""" + +from trex.stl.api import * +from profile_trex_stateless_scale_class import TrafficStreamsScaleClass + + +class TrafficStreams(TrafficStreamsScaleClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsScaleClass, self).__init__() + + self.pkt_data = [ + # Direction W --> E: + { + "src_start_ip": "2100::1", + "dst_start_ip": "2200::0", + "dst_end_ip": "2200::7:a11f" + }, + # Direction E --> W: + { + "src_start_ip": "2200::1", + "dst_start_ip": "2100::0", + "dst_end_ip": "2100::7:a11f" + } + ] + self.pkt_base = [] + self.pkt_vm = [] + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + for i in range(len(self.pkt_data)): + base, count = self._get_start_end_ipv6( + self.pkt_data[i]["dst_start_ip"], + self.pkt_data[i]["dst_end_ip"] + ) + + self.pkt_base.append( + Ether() / + IPv6( + src=self.pkt_data[i]["src_start_ip"], + dst=self.pkt_data[i]["dst_start_ip"] + ) + ) + self.pkt_vm.append( + STLScVmRaw( + [ + STLVmFlowVar( + name="ipv6_dst", + min_value=base, + max_value=base + count, + size=8 + ), + STLVmWrFlowVar( + fv_name="ipv6_dst", + pkt_offset="IPv6.dst", + offset_fixup=8 + ) + ] + ) + ) + + return self.pkt_base, self.pkt_vm + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip6-ip6src253.py b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6src253.py index d67a4ab18c..3763a0977a 100644 --- a/GPL/traffic_profiles/trex/trex-stl-2n-ethip6-ip6src253.py +++ b/GPL/traffic_profiles/trex/trex-stl-ethip6-ip6src253.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # |