1 # Copyright (c) 2023 Cisco and/or its affiliates.
3 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5 # Licensed under the Apache License 2.0 or
6 # GNU General Public License v2.0 or later; you may not use this file
7 # except in compliance with one of these Licenses. You
8 # may obtain a copy of the Licenses at:
10 # http://www.apache.org/licenses/LICENSE-2.0
11 # https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13 # Note: If this file is linked with Scapy, which is GPLv2+, your use of it
14 # must be under GPLv2+. If at any point in the future it is no longer linked
15 # with Scapy (or other GPLv2+ licensed software), you are free to choose
18 # Unless required by applicable law or agreed to in writing, software
19 # distributed under the License is distributed on an "AS IS" BASIS,
20 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 # See the License for the specific language governing permissions and
22 # limitations under the License.
24 """Stream profile for T-rex traffic generator.
27 - Three parallel bi-directional streams sent as W --> E and E --> W
32 from trex.stl.api import *
33 from profile_trex_stateless_scale_class import TrafficStreamsScaleClass
36 class TrafficStreams(TrafficStreamsScaleClass):
40 """Initialization and setting of streams' parameters."""
42 super(TrafficStreamsScaleClass, self).__init__()
47 "src_start_ip": "10.0.0.1",
48 "dst_start_ip": "20.0.0.0",
49 "dst_end_ip": "20.1.134.159",
54 "src_start_ip": "30.0.0.1",
55 "dst_start_ip": "40.0.0.0",
56 "dst_end_ip": "40.1.134.159",
61 "src_start_ip": "50.0.0.1",
62 "dst_start_ip": "60.0.0.0",
63 "dst_end_ip": "60.1.134.159",
68 "src_start_ip": "20.0.0.1",
69 "dst_start_ip": "10.0.0.0",
70 "dst_end_ip": "10.1.134.159",
75 "src_start_ip": "40.0.0.1",
76 "dst_start_ip": "30.0.0.0",
77 "dst_end_ip": "30.1.134.159",
82 "src_start_ip": "60.0.0.1",
83 "dst_start_ip": "50.0.0.0",
84 "dst_end_ip": "50.1.134.159",
91 def define_packets(self):
92 """Defines the packets to be sent from the traffic generator.
94 Packet definition: | ETH | IP |
96 :returns: Base packets to be sent and transformation function.
99 for i in range(len(self.pkt_data)):
100 self.pkt_base.append(
103 src=self.pkt_data[i]["src_start_ip"],
104 dst=self.pkt_data[i]["dst_start_ip"],
113 min_value=self.pkt_data[i]["dst_start_ip"],
114 max_value=self.pkt_data[i]["dst_end_ip"],
116 seed=self.pkt_data[i]["seed"],
130 return self.pkt_base, self.pkt_vm
134 """Register this traffic profile to T-Rex.
136 Do not change this function.
138 :return: Traffic streams.
141 return TrafficStreams()