aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2017-04-04 10:06:00 +0200
committerTibor Frank <tifrank@cisco.com>2017-06-05 07:40:28 +0200
commitb92b5be7d4bbbf523812f774bb2e539ab2081cf6 (patch)
tree61d967364e6eb9952616434b913648742e70fbc9 /resources
parent78e999f1203dc8b7c29c24b0178bb8c23edf4c52 (diff)
CSIT-524: Traffic generator using python profiles
Profile name structure: [trex|ixia]-[sl|sf]-[topo]-[packet structure]-[scale] - Traffic generator - T-rex (trex) or Ixia (ixia) - Stateless (sl) or statefull (sf) - Topology - 2-node topology (2n) or 3-node topology (3n) - Packet structure - eth | ip4/6 | udp - Scale - e.g. ip4dst1, ip6dst10000, 4000u15p Traffic types changed to stream profiles: - From: 2-node-bridge To: trex-sl-2n-ethip4-ip4src253 - From: 3-node-bridge To: trex-sl-3n-ethip4-ip4src254 - From: 3-node-IPv4-dst-1000000 To: trex-sl-3n-ethip4-ip4dst1000000 - From: 3-node-IPv4-dst-100000 To: trex-sl-3n-ethip4-ip4dst100000 - From: 3-node-IPv4-dst-10000 To: trex-sl-3n-ethip4-ip4dst10000 - From: 3-node-IPv4-dst-1000 To: trex-sl-3n-ethip4-ip4dst1000 - From: 3-node-IPv4-dst-100 To: trex-sl-3n-ethip4-ip4dst100 - From: 3-node-IPv4-dst-1 To: trex-sl-3n-ethip4-ip4dst1 - From: 3-node-IPv4 To: trex-sl-3n-ethip4-ip4src253 - From: 3-node-IPv6-dst-1000000 To: trex-sl-3n-ethip6-ip6dst1000000 - From: 3-node-IPv6-dst-100000 To: trex-sl-3n-ethip6-ip6dst100000 - From: 3-node-IPv6-dst-10000 To: trex-sl-3n-ethip6-ip6dst10000 - From: 3-node-IPv6 To: trex-sl-3n-ethip6-ip6src253 - From: 3-node-xconnect To: trex-sl-3n-ethip4-ip4src254 - From: 3-node-IPv4-SNAT-1000u-15p To: trex-sl-3n-ethip4udp-1000u15p - From: 3-node-IPv4-SNAT-100u-15p To: trex-sl-3n-ethip4udp-100u15p - From: 3-node-IPv4-SNAT-10u-15p To: trex-sl-3n-ethip4udp-10u15p - From: 3-node-IPv4-SNAT-1u-15p To: trex-sl-3n-ethip4udp-1u15p - From: 3-node-IPv4-SNAT-1u-1p To: trex-sl-3n-ethip4udp-1u1p - From: 3-node-IPv4-SNAT-2000u-15p To: trex-sl-3n-ethip4udp-2000u15p - From: 3-node-IPv4-SNAT-4000u-15p To: trex-sl-3n-ethip4udp-4000u15p Change-Id: If6a3cf204c93ff9f2cdccc5fd395e26b05483b58 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/TrafficGenerator.py408
-rw-r--r--resources/tools/report_gen/conf.py4
-rwxr-xr-xresources/tools/t-rex/stream_profiles/profile_trex_stateless_base_class.py211
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-2n-ethip4-ip4src253.py94
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1.py73
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst10000.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100000.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000000.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst253.py96
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src253.py94
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src254.py94
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1000u15p.py116
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-100u15p.py116
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-10u15p.py116
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u15p.py113
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u1p.py88
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-2000u15p.py116
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-4000u15p.py116
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst10000.py99
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst100000.py99
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst1000000.py99
-rwxr-xr-xresources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6src253.py99
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless-profile.py296
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless-stop.py20
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless.py698
27 files changed, 2650 insertions, 1095 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 8fb9191063..0f25ebe42e 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -103,7 +103,7 @@ class TrafficGenerator(object):
self._received = None
self._node = None
# T-REX interface order mapping
- self._ifaces_reordered = 0
+ self._ifaces_reordered = False
@property
def node(self):
@@ -222,7 +222,7 @@ class TrafficGenerator(object):
if1_mac, if2_mac = if2_mac, if1_mac
if1_pci, if2_pci = if2_pci, if1_pci
if1_adj_mac, if2_adj_mac = if2_adj_mac, if1_adj_mac
- self._ifaces_reordered = 1
+ self._ifaces_reordered = True
if1_mac_hex = "0x"+if1_mac.replace(":", ",0x")
if2_mac_hex = "0x"+if2_mac.replace(":", ",0x")
@@ -283,7 +283,7 @@ class TrafficGenerator(object):
# try again
max_startup_retries -= 1
# after max retries T-rex is still not responding to API
- # critical error occured
+ # critical error occurred
raise RuntimeError('t-rex-64 startup failed')
@staticmethod
@@ -319,7 +319,7 @@ class TrafficGenerator(object):
ssh = SSH()
ssh.connect(node)
- (ret, stdout, stderr) = ssh.exec_command(
+ (ret, _, _) = ssh.exec_command(
"sh -c '{}/resources/tools/t-rex/"
"t-rex-stateless-stop.py'".format(Constants.REMOTE_FW_DIR))
@@ -340,395 +340,39 @@ class TrafficGenerator(object):
:param warmup_time: Warmup time period.
:type duration: int
:type rate: str
- :type framesize: int
+ :type framesize: str
:type traffic_type: str
:type async_call: bool
:type latency: bool
:type warmup_time: int
:returns: Nothing
- :raises: NotImplementedError if traffic type is not supported.
:raises: RuntimeError in case of TG driver issue.
"""
ssh = SSH()
ssh.connect(self._node)
- _p0 = 1
- _p1 = 2
_async = "--async" if async_call else ""
_latency = "--latency" if latency else ""
-
- if self._ifaces_reordered != 0:
- _p0, _p1 = _p1, _p0
-
- if traffic_type in ["3-node-xconnect", "3-node-bridge"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.10.10.1 "
- "--p{4}_src_end_ip 10.10.10.254 "
- "--p{4}_dst_start_ip 20.20.20.1 "
- "--p{5}_src_start_ip 20.20.20.1 "
- "--p{5}_src_end_ip 20.20.20.254 "
- "--p{5}_dst_start_ip 10.10.10.1 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.10.10.2 "
- "--p{4}_src_end_ip 10.10.10.254 "
- "--p{4}_dst_start_ip 20.20.20.2 "
- "--p{5}_src_start_ip 20.20.20.2 "
- "--p{5}_src_end_ip 20.20.20.254 "
- "--p{5}_dst_start_ip 10.10.10.2 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4-dst-1"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.0.0.0 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.0.0.0 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4-dst-100"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.0.0.99 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.0.0.99 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4-dst-1000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.0.3.231 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.0.3.231 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-1u-1p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.0.0 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1024 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1028 "
- "--p{5}_dst_end_udp_port 1028 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-1u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.0.0 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 1038 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-10u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.0.9 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 1173 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-100u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.0.99 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 2523 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration) + 60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-1000u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.3.231 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 16023 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-2000u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.7.207 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 31022 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-SNAT-4000u-15p"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 20.0.0.0 "
- "--p{4}_src_end_ip 20.0.15.159 "
- "--p{4}_dst_start_ip 12.0.0.2 "
- "--p{5}_src_start_ip 12.0.0.2 "
- "--p{5}_src_end_ip 12.0.0.2 "
- "--p{5}_dst_start_ip 200.0.0.0 "
- "--p{4}_src_start_udp_port 1024 "
- "--p{4}_src_end_udp_port 1038 "
- "--p{4}_dst_start_udp_port 1024 "
- "--p{5}_src_start_udp_port 1024 "
- "--p{5}_dst_start_udp_port 1024 "
- "--p{5}_dst_end_udp_port 61022 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
-
- elif traffic_type in ["3-node-IPv4-dst-10000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.0.39.15 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.0.39.15 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4-dst-100000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.1.134.159 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.1.134.159 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv4-dst-1000000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.0.0.1 "
- "--p{4}_dst_start_ip 20.0.0.0 "
- "--p{4}_dst_end_ip 20.15.66.63 "
- "--p{5}_src_start_ip 20.0.0.1 "
- "--p{5}_dst_start_ip 10.0.0.0 "
- "--p{5}_dst_end_ip 10.15.66.63 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv6"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} -6 "
- "--p{4}_src_start_ip 2001:1::2 "
- "--p{4}_src_end_ip 2001:1::FE "
- "--p{4}_dst_start_ip 2001:2::2 "
- "--p{5}_src_start_ip 2001:2::2 "
- "--p{5}_src_end_ip 2001:2::FE "
- "--p{5}_dst_start_ip 2001:1::2 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv6-dst-10000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} -6 "
- "--p{4}_src_start_ip 2001:1::1 "
- "--p{4}_dst_start_ip 2001:2::0 "
- "--p{4}_dst_end_ip 2001:2::270F "
- "--p{5}_src_start_ip 2001:2::1 "
- "--p{5}_dst_start_ip 2001:1::0 "
- "--p{5}_dst_end_ip 2001:1::270F "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv6-dst-100000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} -6 "
- "--p{4}_src_start_ip 2001:1::1 "
- "--p{4}_dst_start_ip 2001:2::0 "
- "--p{4}_dst_end_ip 2001:2::1:869F "
- "--p{5}_src_start_ip 2001:2::1 "
- "--p{5}_dst_start_ip 2001:1::0 "
- "--p{5}_dst_end_ip 2001:1::1:869F "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["3-node-IPv6-dst-1000000"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} -6 "
- "--p{4}_src_start_ip 2001:1::1 "
- "--p{4}_dst_start_ip 2001:2::0 "
- "--p{4}_dst_end_ip 2001:2::F:423F "
- "--p{5}_src_start_ip 2001:2::1 "
- "--p{5}_dst_start_ip 2001:1::0 "
- "--p{5}_dst_end_ip 2001:1::F:423F "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- elif traffic_type in ["2-node-bridge"]:
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_src_start_ip 10.10.10.2 "
- "--p{4}_src_end_ip 10.10.10.254 "
- "--p{4}_dst_start_ip 20.20.20.2 "
- "--p{5}_src_start_ip 20.20.20.2 "
- "--p{5}_src_end_ip 20.20.20.254 "
- "--p{5}_dst_start_ip 10.10.10.2 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout = int(duration) + 60)
- elif traffic_type in ["3-node-IPv4-l3fwd"]:
- # add for the DPDK l3fwd routing test
- # please make sure the TG port 0 connect to the DUT port 0
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
- "--duration={1} -r {2} -s {3} "
- "--p{4}_dst_start_ip 2.1.1.2 "
- "--p{4}_dst_end_ip 2.1.1.254 "
- "--p{4}_src_start_ip 20.20.20.2 "
- "--p{5}_dst_start_ip 1.1.1.2 "
- "--p{5}_dst_end_ip 1.1.1.254 "
- "--p{5}_src_start_ip 10.10.10.2 "
- "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
- duration, rate, framesize,
- _p0, _p1, _async, _latency,
- warmup_time),
- timeout=int(duration)+60)
- else:
- raise NotImplementedError('Unsupported traffic type')
+ _p0, _p1 = (2, 1) if self._ifaces_reordered else (1, 2)
+
+ profile_path = ("{0}/resources/tools/t-rex/stream_profiles/"
+ "{1}.py".format(Constants.REMOTE_FW_DIR,
+ traffic_type))
+ (ret, stdout, _) = ssh.exec_command(
+ "sh -c "
+ "'{0}/resources/tools/t-rex/t-rex-stateless-profile.py "
+ "--profile {1} "
+ "--duration {2} "
+ "--frame_size {3} "
+ "--rate {4} "
+ "--warmup_time {5} "
+ "--port_0 {6} "
+ "--port_1 {7} "
+ "{8} " # --async
+ "{9}'". # --latency
+ format(Constants.REMOTE_FW_DIR, profile_path, duration, framesize,
+ rate, warmup_time, _p0 - 1, _p1 - 1, _async, _latency),
+ timeout=int(duration) + 60)
if int(ret) != 0:
raise RuntimeError('T-rex stateless runtime error')
@@ -800,7 +444,7 @@ class TrafficGenerator(object):
if node['subtype'] is None:
raise RuntimeError('TG subtype not defined')
elif node['subtype'] == NodeSubTypeTG.TREX:
- self.trex_stl_start_remote_exec(duration, rate, framesize,
+ self.trex_stl_start_remote_exec(int(duration), rate, framesize,
traffic_type, async_call, latency,
warmup_time=warmup_time)
else:
diff --git a/resources/tools/report_gen/conf.py b/resources/tools/report_gen/conf.py
index 50523d44e4..c28c404a34 100644
--- a/resources/tools/report_gen/conf.py
+++ b/resources/tools/report_gen/conf.py
@@ -68,7 +68,7 @@ rst_epilog = """
.. _tag documentation rst file: https://git.fd.io/csit/tree/docs/tag_documentation.rst?h=rls1704
.. _TRex intallation: https://git.fd.io/csit/tree/resources/tools/t-rex/t-rex-installer.sh?h=rls1704
-.. _TRex driver: https://git.fd.io/csit/tree/resources/tools/t-rex/t-rex-stateless.py?h=rls1704
+.. _TRex driver: https://git.fd.io/csit/tree/resources/tools/t-rex/t-rex-stateless-profile.py?h=rls1704
.. _CSIT Honeycomb Functional Tests Documentation: https://docs.fd.io/csit/rls1704/doc/tests.func.html
.. _CSIT Testpmd Performance Tests Documentation: https://docs.fd.io/csit/rls1704/doc/tests.perf.html
.. _CSIT VPP Functional Tests Documentation: https://docs.fd.io/csit/rls1704/doc/tests.func.html
@@ -97,7 +97,7 @@ pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
-#pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),]
+# pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),]
# -- Options for HTML output ----------------------------------------------
diff --git a/resources/tools/t-rex/stream_profiles/profile_trex_stateless_base_class.py b/resources/tools/t-rex/stream_profiles/profile_trex_stateless_base_class.py
new file mode 100755
index 0000000000..2d07e7fe9d
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/profile_trex_stateless_base_class.py
@@ -0,0 +1,211 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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 sys
+import socket
+import struct
+
+from random import choice
+from string import letters
+
+from trex_stl_lib.api import *
+
+
+class TrafficStreamsBaseClass(object):
+ """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(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
+ """
+
+ base_pkt_a, base_pkt_b, vm1, vm2 = self.define_packets()
+
+ # In most cases you will not have to change the code below:
+
+ # Frame size is defined as an integer, e.g. 64, 1518:
+ if isinstance(self.framesize, int):
+
+ # Create a base packet and pad it to size
+ payload_len = max(0, self.framesize - len(base_pkt_a) - 4) # No FCS
+
+ # Direction 0 --> 1
+ pkt_a = STLPktBuilder(
+ pkt=base_pkt_a / self._gen_payload(payload_len),
+ vm=vm1)
+ # Direction 1 --> 0
+ pkt_b = STLPktBuilder(
+ pkt=base_pkt_a / self._gen_payload(payload_len),
+ vm=vm2)
+
+ # Packets for latency measurement:
+ # Direction 0 --> 1
+ pkt_lat_a = STLPktBuilder(
+ pkt=base_pkt_a / self._gen_payload(payload_len))
+ # Direction 1 --> 0
+ pkt_lat_b = STLPktBuilder(
+ pkt=base_pkt_a / self._gen_payload(payload_len))
+
+ # Create the streams:
+ # Direction 0 --> 1
+ stream1 = STLStream(packet=pkt_a, mode=STLTXCont(pps=9000))
+ # Direction 1 --> 0
+ # second traffic stream with a phase of 10ns (inter-stream gap)
+ stream2 = STLStream(packet=pkt_b, isg=10.0,
+ mode=STLTXCont(pps=9000))
+
+ # Streams for latency measurement:
+ # Direction 0 --> 1
+ lat_stream1 = STLStream(packet=pkt_lat_a,
+ flow_stats=STLFlowLatencyStats(pg_id=0),
+ mode=STLTXCont(pps=9000))
+ # Direction 1 --> 0
+ # second traffic stream with a phase of 10ns (inter-stream gap)
+ lat_stream2 = STLStream(packet=pkt_lat_b, isg=10.0,
+ flow_stats=STLFlowLatencyStats(pg_id=1),
+ mode=STLTXCont(pps=9000))
+
+ return [stream1, stream2, lat_stream1, lat_stream2]
+
+ # Frame size is defined as a string, e.g.IMIX_v4_1:
+ elif isinstance(self.framesize, str):
+
+ stream1 = []
+ stream2 = []
+
+ for stream in self.STREAM_TABLE[self.framesize]:
+ payload_len = max(0, stream['size'] - len(base_pkt_a) - 4)
+ # Create a base packet and pad it to size
+ pkt_a = STLPktBuilder(
+ pkt=base_pkt_a / self._gen_payload(payload_len),
+ vm=vm1)
+ pkt_b = STLPktBuilder(
+ pkt=base_pkt_b / self._gen_payload(payload_len),
+ vm=vm2)
+
+ # Create the streams:
+ stream1.append(STLStream(packet=pkt_a,
+ isg=stream['isg'],
+ mode=STLTXCont(pps=stream['pps'])))
+ stream2.append(STLStream(packet=pkt_b,
+ isg=stream['isg'],
+ mode=STLTXCont(pps=stream['pps'])))
+ streams = list()
+ streams.extend(stream1)
+ streams.extend(stream2)
+
+ return 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']
+
+ return self.create_streams()
diff --git a/resources/tools/t-rex/stream_profiles/trex-sl-2n-ethip4-ip4src253.py b/resources/tools/t-rex/stream_profiles/trex-sl-2n-ethip4-ip4src253.py
new file mode 100755
index 0000000000..f9a030b9eb
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-2n-ethip4-ip4src253.py
@@ -0,0 +1,94 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '10.10.10.2'
+ self.p1_src_end_ip = '10.10.10.254'
+ self.p1_dst_start_ip = '20.20.20.2'
+
+ self.p2_src_start_ip = '20.20.20.2'
+ self.p2_src_end_ip = '20.20.20.254'
+ self.p2_dst_start_ip = '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="src",
+ min_value=self.p1_src_start_ip,
+ max_value=self.p1_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=self.p2_src_start_ip,
+ max_value=self.p2_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1.py
new file mode 100755
index 0000000000..68b492175b
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1.py
@@ -0,0 +1,73 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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
+ - Direction 1 --> 0:
+ - Source IP address range: 20.0.0.1
+ - Destination IP address range: 10.0.0.0
+"""
+
+from trex_stl_lib.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 = '10.0.0.1'
+ self.p1_dst_ip = '20.0.0.0'
+
+ self.p2_src_ip = '20.0.0.1'
+ self.p2_dst_ip = '10.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() /
+ IP(src=self.p2_src_ip, dst=self.p2_dst_ip, proto=61))
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100.py
new file mode 100755
index 0000000000..86f423a153
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.99
+ - Direction 1 --> 0:
+ - Source IP address range: 20.0.0.1
+ - Destination IP address range: 10.0.0.0 - 10.0.0.99
+"""
+
+from trex_stl_lib.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 = '10.0.0.1'
+ self.p1_dst_start_ip = '20.0.0.0'
+ self.p1_dst_end_ip = '20.0.0.99'
+
+ self.p2_src_start_ip = '20.0.0.1'
+ self.p2_dst_start_ip = '10.0.0.0'
+ self.p2_dst_end_ip = '10.0.0.99'
+
+ 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="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000.py
new file mode 100755
index 0000000000..569c06360f
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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
+ - Direction 1 --> 0:
+ - Source IP address range: 20.0.0.1
+ - Destination IP address range: 10.0.0.0 - 10.0.3.231
+"""
+
+from trex_stl_lib.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 = '10.0.0.1'
+ self.p1_dst_start_ip = '20.0.0.0'
+ self.p1_dst_end_ip = '20.0.3.231'
+
+ self.p2_src_start_ip = '20.0.0.1'
+ self.p2_dst_start_ip = '10.0.0.0'
+ self.p2_dst_end_ip = '10.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() /
+ IP(src=self.p2_src_start_ip,
+ dst=self.p2_dst_start_ip,
+ proto=61))
+
+ # Direction 0 --> 1
+ vm1 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst10000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst10000.py
new file mode 100755
index 0000000000..373076f596
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst10000.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '10.0.0.1'
+ self.p1_dst_start_ip = '20.0.0.0'
+ self.p1_dst_end_ip = '20.0.39.15'
+
+ self.p2_src_start_ip = '20.0.0.1'
+ self.p2_dst_start_ip = '10.0.0.0'
+ self.p2_dst_end_ip = '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([STLVmFlowVar(name="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100000.py
new file mode 100755
index 0000000000..3b27e9a9e0
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst100000.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '10.0.0.1'
+ self.p1_dst_start_ip = '20.0.0.0'
+ self.p1_dst_end_ip = '20.1.134.159'
+
+ self.p2_src_start_ip = '20.0.0.1'
+ self.p2_dst_start_ip = '10.0.0.0'
+ self.p2_dst_end_ip = '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="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000000.py
new file mode 100755
index 0000000000..076951b566
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst1000000.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '10.0.0.1'
+ self.p1_dst_start_ip = '20.0.0.0'
+ self.p1_dst_end_ip = '20.15.66.63'
+
+ self.p2_src_start_ip = '20.0.0.1'
+ self.p2_dst_start_ip = '10.0.0.0'
+ self.p2_dst_end_ip = '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="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst253.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst253.py
new file mode 100755
index 0000000000..684af82ce1
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4dst253.py
@@ -0,0 +1,96 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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: 20.20.20.2
+ - Destination IP address range: 2.1.1.2 - 2.1.1.254
+ - Direction 1 --> 0:
+ - Source IP address range: 10.10.10.2
+ - Destination IP address range: 1.1.1.2 - 1.1.1.254
+"""
+
+from trex_stl_lib.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 = '20.20.20.2'
+ self.p1_dst_start_ip = '2.1.1.2'
+ self.p1_dst_end_ip = '2.1.1.254'
+
+ self.p2_src_start_ip = '10.10.10.2'
+ self.p2_dst_start_ip = '1.1.1.2'
+ self.p2_dst_end_ip = '1.1.1.254'
+
+ 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="dst",
+ min_value=self.p1_dst_start_ip,
+ max_value=self.p1_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
+ min_value=self.p2_dst_start_ip,
+ max_value=self.p2_dst_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src253.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src253.py
new file mode 100755
index 0000000000..f9a030b9eb
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src253.py
@@ -0,0 +1,94 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '10.10.10.2'
+ self.p1_src_end_ip = '10.10.10.254'
+ self.p1_dst_start_ip = '20.20.20.2'
+
+ self.p2_src_start_ip = '20.20.20.2'
+ self.p2_src_end_ip = '20.20.20.254'
+ self.p2_dst_start_ip = '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="src",
+ min_value=self.p1_src_start_ip,
+ max_value=self.p1_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=self.p2_src_start_ip,
+ max_value=self.p2_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src254.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src254.py
new file mode 100755
index 0000000000..0a2a4a4564
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4-ip4src254.py
@@ -0,0 +1,94 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.1 - 10.10.10.254
+ - Destination IP address range: 20.20.20.1
+ - Direction 1 --> 0:
+ - Source IP address range: 20.20.20.1 - 20.20.20.254
+ - Destination IP address range: 10.10.10.1
+"""
+
+from trex_stl_lib.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 = '10.10.10.1'
+ self.p1_src_end_ip = '10.10.10.254'
+ self.p1_dst_start_ip = '20.20.20.1'
+
+ self.p2_src_start_ip = '20.20.20.1'
+ self.p2_src_end_ip = '20.20.20.254'
+ self.p2_dst_start_ip = '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() / IP(src=self.p2_src_start_ip,
+ dst=self.p2_dst_start_ip,
+ proto=61)
+
+ # Direction 0 --> 1
+ vm1 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=self.p1_src_start_ip,
+ max_value=self.p1_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="src",
+ min_value=self.p2_src_start_ip,
+ max_value=self.p2_src_end_ip,
+ size=4, op="inc"),
+ STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP")],
+ split_by_field="src")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1000u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1000u15p.py
new file mode 100755
index 0000000000..c9f6a27b89
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1000u15p.py
@@ -0,0 +1,116 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.3.231'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-100u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-100u15p.py
new file mode 100755
index 0000000000..87a5d3067d
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-100u15p.py
@@ -0,0 +1,116 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.0.99
+ - 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 - 2523
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.0.99'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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 = 2523
+
+ 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="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-10u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-10u15p.py
new file mode 100755
index 0000000000..74f2f0d1e5
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-10u15p.py
@@ -0,0 +1,116 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.0.9
+ - 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 - 1173
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.0.9'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ #self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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 = 1173
+
+ 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="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u15p.py
new file mode 100755
index 0000000000..220ec05e31
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u15p.py
@@ -0,0 +1,113 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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
+ - 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 - 1038
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.0.0'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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 = 1038
+
+ 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([
+ STLVmFlowVar(name="sport",
+ min_value=self.p1_src_start_udp_port,
+ max_value=self.p1_src_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="sport", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u1p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u1p.py
new file mode 100755
index 0000000000..939e4ce42c
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-1u1p.py
@@ -0,0 +1,88 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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
+ - Destination IP address range: 12.0.0.2
+ - Source UDP port range: 1024
+ - 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: 1028
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_dst_ip = '12.0.0.2'
+
+ self.p2_src_ip = '12.0.0.2'
+ self.p2_dst_ip = '200.0.0.0'
+
+ # UDP ports used in packet headers.
+ self.p1_src_udp_port = 1024
+ self.p1_dst_udp_port = 1024
+
+ self.p2_src_udp_port = 1024
+ self.p2_dst_udp_port = 1028
+
+ 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_ip, dst=self.p1_dst_ip, proto=17) /
+ UDP(sport=self.p1_src_udp_port,
+ dport=self.p1_dst_udp_port))
+ # Direction 1 --> 0
+ base_pkt_b = (Ether() /
+ 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))
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-2000u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-2000u15p.py
new file mode 100755
index 0000000000..7d5651812e
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-2000u15p.py
@@ -0,0 +1,116 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.7.207
+ - 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 - 31022
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.7.207'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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 = 31022
+
+ 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="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-4000u15p.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-4000u15p.py
new file mode 100755
index 0000000000..dab23b8627
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip4udp-4000u15p.py
@@ -0,0 +1,116 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.15.159
+ - 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 - 61022
+"""
+
+from trex_stl_lib.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 = '20.0.0.0'
+ self.p1_src_end_ip = '20.0.15.159'
+ self.p1_dst_start_ip = '12.0.0.2'
+
+ self.p2_src_start_ip = '12.0.0.2'
+ self.p2_src_end_ip = '12.0.0.2'
+ self.p2_dst_start_ip = '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 = 61022
+
+ 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="tuple"),
+ STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
+ STLVmFixIpv4(offset="IP"),
+ STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
+ ])
+ # Direction 0 --> 1
+ vm2 = STLScVmRaw([
+ STLVmFlowVar(name="dport",
+ min_value=self.p2_dst_start_udp_port,
+ max_value=self.p2_dst_end_udp_port,
+ size=2, op="inc"),
+ STLVmWrFlowVar(fv_name="dport", pkt_offset="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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst10000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst10000.py
new file mode 100755
index 0000000000..7a85ddfc05
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst10000.py
@@ -0,0 +1,99 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '2001:1::1'
+ self.p1_dst_start_ip = '2001:2::0'
+ self.p1_dst_end_ip = '2001:2::270F'
+
+ self.p2_src_start_ip = '2001:2::1'
+ self.p2_dst_start_ip = '2001:1::0'
+ self.p2_dst_end_ip = '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="ipv6_dst",
+ min_value=base_p1,
+ max_value=base_p1 + count_p1,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst",
+ min_value=base_p2,
+ max_value=base_p2 + count_p2,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst100000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst100000.py
new file mode 100755
index 0000000000..b1948c9de2
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst100000.py
@@ -0,0 +1,99 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '2001:1::1'
+ self.p1_dst_start_ip = '2001:2::0'
+ self.p1_dst_end_ip = '2001:2::1:869F'
+
+ self.p2_src_start_ip = '2001:2::1'
+ self.p2_dst_start_ip = '2001:1::0'
+ self.p2_dst_end_ip = '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="ipv6_dst",
+ min_value=base_p1,
+ max_value=base_p1 + count_p1,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst",
+ min_value=base_p2,
+ max_value=base_p2 + count_p2,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst1000000.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst1000000.py
new file mode 100755
index 0000000000..ace0dace76
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6dst1000000.py
@@ -0,0 +1,99 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '2001:1::1'
+ self.p1_dst_start_ip = '2001:2::0'
+ self.p1_dst_end_ip = '2001:2::F:423F'
+
+ self.p2_src_start_ip = '2001:2::1'
+ self.p2_dst_start_ip = '2001:1::0'
+ self.p2_dst_end_ip = '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="ipv6_dst",
+ min_value=base_p1,
+ max_value=base_p1 + count_p1,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst",
+ min_value=base_p2,
+ max_value=base_p2 + count_p2,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_dst",
+ pkt_offset="IPv6.dst",
+ offset_fixup=8)],
+ split_by_field="ipv6_dst")
+
+ 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/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6src253.py b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6src253.py
new file mode 100755
index 0000000000..be900ce2cc
--- /dev/null
+++ b/resources/tools/t-rex/stream_profiles/trex-sl-3n-ethip6-ip6src253.py
@@ -0,0 +1,99 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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_lib.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 = '2001:1::2'
+ self.p1_src_end_ip = '2001:1::FE'
+ self.p1_dst_start_ip = '2001:2::2'
+
+ self.p2_src_start_ip = '2001:2::2'
+ self.p2_src_end_ip = '2001:2::FE'
+ self.p2_dst_start_ip = '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="ipv6_src",
+ min_value=base_p1,
+ max_value=base_p1 + count_p1,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_src",
+ pkt_offset="IPv6.src",
+ offset_fixup=8)],
+ split_by_field="ipv6_src")
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_src",
+ min_value=base_p2,
+ max_value=base_p2 + count_p2,
+ size=8, op="inc"),
+ STLVmWrFlowVar(fv_name="ipv6_src",
+ pkt_offset="IPv6.src",
+ offset_fixup=8)],
+ split_by_field="ipv6_src")
+
+ 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/resources/tools/t-rex/t-rex-stateless-profile.py b/resources/tools/t-rex/t-rex-stateless-profile.py
new file mode 100755
index 0000000000..0bbd241f8b
--- /dev/null
+++ b/resources/tools/t-rex/t-rex-stateless-profile.py
@@ -0,0 +1,296 @@
+#!/usr/bin/python
+
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.
+
+"""This module gets a traffic profile together with other parameters, reads
+the profile and sends the traffic. At the end, it measures the packet loss and
+latency.
+"""
+
+import sys
+import argparse
+import json
+
+sys.path.insert(0, "/opt/trex-core-2.25/scripts/automation/"
+ "trex_control_plane/stl/")
+
+from trex_stl_lib.api import *
+
+
+def fmt_latency(lat_min, lat_avg, lat_max):
+ """Return formatted, rounded latency.
+
+ :param lat_min: Min latency
+ :param lat_avg: Average latency
+ :param lat_max: Max latency
+ :type lat_min: string
+ :type lat_avg: string
+ :type lat_max: string
+ :return: Formatted and rounded output "min/avg/max"
+ :rtype: string
+ """
+
+ try:
+ t_min = int(round(float(lat_min)))
+ except ValueError:
+ t_min = int(-1)
+ try:
+ t_avg = int(round(float(lat_avg)))
+ except ValueError:
+ t_avg = int(-1)
+ try:
+ t_max = int(round(float(lat_max)))
+ except ValueError:
+ t_max = int(-1)
+
+ return "/".join(str(tmp) for tmp in (t_min, t_avg, t_max))
+
+
+def simple_burst(profile_file, duration, framesize, rate, warmup_time, port_0,
+ port_1, latency, async_start=False):
+ """Send the traffic and measure packet loss and latency.
+
+ Procedure:
+ - reads the given traffic profile with streams,
+ - connects to the T-rex client,
+ - resets the ports,
+ - removes all existing streams,
+ - adds streams from the traffic profile to the ports,
+ - if the warm-up time is more than 0, sends the warm-up traffic, reads the
+ statistics,
+ - clears the statistics from the client,
+ - starts the traffic,
+ - waits for the defined time (or runs forever if async mode is defined),
+ - stops the traffic,
+ - reads and displays the statistics and
+ - disconnects from the client.
+
+ :param profile_file: A python module with T-rex traffic profile.
+ :param framesize: Frame size.
+ :param duration: Duration of traffic run in seconds (-1=infinite).
+ :param rate: Traffic rate [percentage, pps, bps].
+ :param warmup_time: Traffic warm-up time in seconds, 0 = disable.
+ :param port_0: Port 0 on the traffic generator.
+ :param port_1: Port 1 on the traffic generator.
+ :param latency: With latency stats.
+ :param async_start: Start the traffic and exit.
+ :type profile_file: str
+ :type framesize: int or str
+ :type duration: int
+ :type rate: str
+ :type warmup_time: int
+ :type port_0: int
+ :type port_1: int
+ :type latency: boo;
+ :type async_start: bool
+ """
+
+ client = None
+ total_rcvd = 0
+ total_sent = 0
+ lost_a = 0
+ lost_b = 0
+ lat_a = "-1/-1/-1"
+ lat_b = "-1/-1/-1"
+
+ # Read the profile:
+ try:
+ print("### Profile file:\n{}".format(profile_file))
+ profile = STLProfile.load(profile_file, direction=0, port_id=0,
+ framesize=framesize)
+ print("\n### Profiles ###\n")
+ print(profile.dump_to_yaml())
+ streams = profile.get_streams()
+ except STLError:
+ print("Error while loading profile '{0}'\n".format(profile_file))
+ sys.exit(1)
+
+ try:
+ # Create the client:
+ client = STLClient(verbose_level=LoggerApi.VERBOSE_QUIET)
+ # Connect to server:
+ client.connect()
+ # Prepare our ports (the machine has 0 <--> 1 with static route):
+ client.reset(ports=[port_0, port_1])
+ client.remove_all_streams(ports=[port_0, port_1])
+
+ if isinstance(framesize, int):
+ client.add_streams(streams[0], ports=[port_0])
+ client.add_streams(streams[1], ports=[port_1])
+ elif isinstance(framesize, str):
+ client.add_streams(streams[0:3], ports=[port_0])
+ client.add_streams(streams[3:6], ports=[port_1])
+ if latency:
+ try:
+ if isinstance(framesize, int):
+ client.add_streams(streams[2], ports=[port_0])
+ client.add_streams(streams[3], ports=[port_1])
+ elif isinstance(framesize, str):
+ latency = False
+ except STLError:
+ # Disable latency if NIC does not support requested stream type
+ print("##### FAILED to add latency streams #####")
+ latency = False
+ # Warm-up phase:
+ if warmup_time > 0:
+ # Clear the stats before injecting:
+ client.clear_stats()
+
+ # Choose rate and start traffic:
+ client.start(ports=[port_0, port_1], mult=rate,
+ duration=warmup_time)
+
+ # Block until done:
+ client.wait_on_traffic(ports=[port_0, port_1],
+ timeout=warmup_time+30)
+
+ if client.get_warnings():
+ for warning in client.get_warnings():
+ print(warning)
+
+ # Read the stats after the test:
+ stats = client.get_stats()
+
+ print("##### Warmup statistics #####")
+ print(json.dumps(stats, indent=4, separators=(',', ': '),
+ sort_keys=True))
+
+ lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
+ lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
+
+ print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
+ print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
+
+ # Clear the stats before injecting:
+ client.clear_stats()
+ lost_a = 0
+ lost_b = 0
+
+ # Choose rate and start traffic:
+ client.start(ports=[port_0, port_1], mult=rate, duration=duration)
+
+ if not async_start:
+ # Block until done:
+ client.wait_on_traffic(ports=[port_0, port_1], timeout=duration+30)
+
+ if client.get_warnings():
+ for warning in client.get_warnings():
+ print(warning)
+
+ # Read the stats after the test
+ stats = client.get_stats()
+
+ print("##### Statistics #####")
+ print(json.dumps(stats, indent=4, separators=(',', ': '),
+ sort_keys=True))
+
+ lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
+ lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
+
+ if latency:
+ lat_a = fmt_latency(
+ str(stats["latency"][0]["latency"]["total_min"]),
+ str(stats["latency"][0]["latency"]["average"]),
+ str(stats["latency"][0]["latency"]["total_max"]))
+ lat_b = fmt_latency(
+ str(stats["latency"][1]["latency"]["total_min"]),
+ str(stats["latency"][1]["latency"]["average"]),
+ str(stats["latency"][1]["latency"]["total_max"]))
+
+ total_sent = stats[0]["opackets"] + stats[1]["opackets"]
+ total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"]
+
+ print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
+ print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
+
+ except STLError as err:
+ sys.stderr.write("{0}\n".format(err))
+ sys.exit(1)
+
+ finally:
+ if async_start:
+ if client:
+ client.disconnect(stop_traffic=False, release_ports=True)
+ else:
+ if client:
+ client.disconnect()
+ print("rate={0}, totalReceived={1}, totalSent={2}, "
+ "frameLoss={3}, latencyStream0(usec)={4}, "
+ "latencyStream1(usec)={5}".
+ format(rate, total_rcvd, total_sent, lost_a + lost_b,
+ lat_a, lat_b))
+
+
+def main():
+ """Main function for the traffic generator using T-rex.
+
+ It verifies the given command line arguments and runs "simple_burst"
+ function.
+ """
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-p", "--profile",
+ required=True,
+ type=str,
+ help="Python traffic profile.")
+ parser.add_argument("-d", "--duration",
+ required=True,
+ type=int,
+ help="Duration of traffic run.")
+ parser.add_argument("-s", "--frame_size",
+ required=True,
+ help="Size of a Frame without padding and IPG.")
+ parser.add_argument("-r", "--rate",
+ required=True,
+ help="Traffic rate with included units (%, pps).")
+ parser.add_argument("-w", "--warmup_time",
+ type=int,
+ default=5,
+ help="Traffic warm-up time in seconds, 0 = disable.")
+ parser.add_argument("--port_0",
+ required=True,
+ type=int,
+ help="Port 0 on the traffic generator.")
+ parser.add_argument("--port_1",
+ required=True,
+ type=int,
+ help="Port 1 on the traffic generator.")
+ parser.add_argument("--async",
+ action="store_true",
+ default=False,
+ help="Non-blocking call of the script.")
+ parser.add_argument("--latency",
+ action="store_true",
+ default=False,
+ help="Add latency stream")
+ args = parser.parse_args()
+
+ try:
+ framesize = int(args.frame_size)
+ except ValueError:
+ framesize = args.frame_size
+
+ simple_burst(profile_file=args.profile,
+ duration=int(args.duration),
+ framesize=framesize,
+ rate=args.rate,
+ warmup_time=int(args.warmup_time),
+ port_0=int(args.port_0),
+ port_1=int(args.port_1),
+ latency=args.latency,
+ async_start=args.async)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/resources/tools/t-rex/t-rex-stateless-stop.py b/resources/tools/t-rex/t-rex-stateless-stop.py
index 0eee3e8cd5..cc008461e6 100755
--- a/resources/tools/t-rex/t-rex-stateless-stop.py
+++ b/resources/tools/t-rex/t-rex-stateless-stop.py
@@ -27,6 +27,7 @@ Functionality:
"""
import sys
+import json
sys.path.insert(0, "/opt/trex-core-2.25/scripts/automation/"+\
"trex_control_plane/stl/")
@@ -40,12 +41,9 @@ def stop_all_traffic_streams():
"""
# create client
- client = STLClient()
+ client = STLClient(verbose_level=LoggerApi.VERBOSE_QUIET)
try:
- # turn this off if too many logs
- #client.set_verbose("high")
-
# connect to server
client.connect()
@@ -55,18 +53,15 @@ def stop_all_traffic_streams():
# read the stats after the test
stats = client.get_stats()
- print "#####statistics (approx.)#####"
- print json.dumps(stats, indent=4,
- separators=(',', ': '), sort_keys=True)
+ print("#####statistics (approx.)#####")
+ print(json.dumps(stats, indent=4,
+ separators=(',', ': '), sort_keys=True))
lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
- total_sent = stats[0]["opackets"] + stats[1]["opackets"]
- total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"]
-
- print "\npackets lost from 0 --> 1: {0} pkts".format(lost_a)
- print "packets lost from 1 --> 0: {0} pkts".format(lost_b)
+ print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
+ print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
except STLError as ex_error:
print_error(str(ex_error))
@@ -76,7 +71,6 @@ def stop_all_traffic_streams():
client.disconnect()
-
def print_error(msg):
"""Print error message on stderr.
diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py
deleted file mode 100755
index fdee81de72..0000000000
--- a/resources/tools/t-rex/t-rex-stateless.py
+++ /dev/null
@@ -1,698 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2016 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# 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.
-
-"""This script uses T-REX stateless API to drive t-rex instance.
-
-Requirements:
-- T-REX: https://github.com/cisco-system-traffic-generator/trex-core
- - compiled and running T-REX process (eg. ./t-rex-64 -i -c 4)
- - trex_stl_lib.api library
-- Script must be executed on a node with T-REX instance
-- 2 interfaces must be configured in configuretion file /etc/trex_cfg.yaml
-
-##################### Example of /etc/trex_cfg.yaml ##########################
-- port_limit : 2 # numbers of ports to use
- version : 2
- interfaces : ["84:00.0","84:00.1"] # PCI address of interfaces
- port_info : # set eth mac addr
- - dest_mac : [0x90,0xe2,0xba,0x1f,0x97,0xd5] # port 0
- src_mac : [0x90,0xe2,0xba,0x1f,0x97,0xd4]
- - dest_mac : [0x90,0xe2,0xba,0x1f,0x97,0xd4] # port 1
- src_mac : [0x90,0xe2,0xba,0x1f,0x97,0xd5]
-##############################################################################
-
-Functionality:
-1. Configure traffic on running T-REX instance
-2. Clear statistics on all ports
-3. Ctart traffic with specified duration
-4. Print statistics to stdout
-
-"""
-
-import argparse
-import json
-import socket
-import string
-import struct
-import sys
-
-sys.path.insert(0, "/opt/trex-core-2.25/scripts/automation/"+\
- "trex_control_plane/stl/")
-from trex_stl_lib.api import *
-
-stream_table = {'IMIX_v4_1': [{'size': 64, 'pps': 28, 'isg':0},
- {'size': 570, 'pps': 16, 'isg':0.1},
- {'size': 1518, 'pps': 4, 'isg':0.2}]
- }
-
-def generate_payload(length):
- """Generate payload.
-
- :param length: Length of payload.
- :type length: int
- :return: Payload filled with chars.
- :rtype string
- """
-
- word = ''
- alphabet_size = len(string.letters)
- for i in range(length):
- word += string.letters[(i % alphabet_size)]
-
- return word
-
-
-def get_start_end_ipv6(start_ip, end_ip):
- """Get start and end host 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, end host.
- :rtype int
- """
-
- 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):
- print "IPv6: start_ip is greater then end_ip"
- sys.exit(2)
-
- max_p1 = abs(int(lo1) - int(lo2))
- base_p1 = lo1
- except AddressValueError as ex_error:
- print ex_error
- sys.exit(2)
-
- return base_p1, max_p1
-
-def create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size):
- """Create STLStream streams
-
- :param base_pkt_a: Base packet a for stream_a
- :param base_pkt_b: Base packet b for stream_b
- :param vm1: vm for stream_a
- :param vm2: vm for stream_b
- :param frame_size: frame size or name of traffic profile
- :type base_pkt_a: Eth (scapy)
- :type base_pkt_b: Eth (scapy)
- :type vm1: STLScVmRaw
- :type vm2: STLScVmRaw
- :frame_size: int or string
- :return: stream_a, stream_b, stream_a_latency, stream_b_latency
- :rtype: STLStream, STLStream, STLStream, STLStream
- """
-
- if type(frame_size) is int:
-
- fsize_no_fcs = frame_size - 4 # no FCS
- pkt_a = STLPktBuilder(pkt=base_pkt_a/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_a))), vm=vm1)
- pkt_b = STLPktBuilder(pkt=base_pkt_b/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_b))), vm=vm2)
- pkt_lat_a = STLPktBuilder(pkt=base_pkt_a/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_a))))
- pkt_lat_b = STLPktBuilder(pkt=base_pkt_b/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_b))))
- lat_stream1 = STLStream(packet=pkt_lat_a,
- flow_stats=STLFlowLatencyStats(pg_id=0),
- mode=STLTXCont(pps=9000))
- # second traffic stream with a phase of 10ns (inter stream gap)
- lat_stream2 = STLStream(packet=pkt_lat_b,
- isg=10.0,
- flow_stats=STLFlowLatencyStats(pg_id=1),
- mode=STLTXCont(pps=9000))
-
- stream1 = STLStream(packet=pkt_a,
- mode=STLTXCont(pps=9000))
- # second traffic stream with a phase of 10ns (inter stream gap)
- stream2 = STLStream(packet=pkt_b,
- isg=10.0,
- mode=STLTXCont(pps=9000))
- elif type(frame_size) is str:
- lat_stream1 = []
- lat_stream2 = []
- stream1 = []
- stream2 = []
-
- for x in stream_table[frame_size]:
- fsize_no_fcs = x['size'] - 4 # no FCS
- pkt_a = STLPktBuilder(pkt=base_pkt_a/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_a))), vm=vm1)
- pkt_b = STLPktBuilder(pkt=base_pkt_b/generate_payload(
- max(0, fsize_no_fcs-len(base_pkt_b))), vm=vm2)
-
- stream1.append(STLStream(packet=pkt_a,
- isg=x['isg'],
- mode=STLTXCont(pps=x['pps'])))
- stream2.append(STLStream(packet=pkt_b,
- isg=x['isg'],
- mode=STLTXCont(pps=x['pps'])))
-
- else:
- raise ValueError("Unknown frame_size type")
-
- return (stream1, stream2, lat_stream1, lat_stream2)
-
-
-def create_streams(traffic_options, frame_size=64):
- """Create two IP packets to be used in stream.
-
- :param traffic_options: Parameters for packets.
- :param frame_size: Size of L2 frame.
- :type traffic_options: dict
- :type frame_size: int
- :return: Packet instances.
- :rtype: Tuple of STLPktBuilder
- """
-
- if type(frame_size) is int and frame_size < 64:
- print_error("Frame min. size is 64B")
- sys.exit(1)
-
- p1_src_start_ip = traffic_options['p1_src_start_ip']
- p1_src_end_ip = traffic_options['p1_src_end_ip']
- p1_dst_start_ip = traffic_options['p1_dst_start_ip']
- p2_src_start_ip = traffic_options['p2_src_start_ip']
- p2_src_end_ip = traffic_options['p2_src_end_ip']
- p2_dst_start_ip = traffic_options['p2_dst_start_ip']
-
- p1_dst_end_ip = traffic_options['p1_dst_end_ip']
- p2_dst_end_ip = traffic_options['p2_dst_end_ip']
-
- try:
- p1_src_start_udp_port = traffic_options['p1_src_start_udp_port']
- p1_src_end_udp_port = traffic_options['p1_src_end_udp_port']
- p1_dst_start_udp_port = traffic_options['p1_dst_start_udp_port']
- p2_src_start_udp_port = traffic_options['p2_src_start_udp_port']
- p2_dst_start_udp_port = traffic_options['p2_dst_start_udp_port']
- p2_dst_end_udp_port = traffic_options['p2_dst_end_udp_port']
- ports_defined = True
- except KeyError:
- ports_defined = False
-
- if ports_defined:
- base_pkt_a = (Ether() /
- IP(src=p1_src_start_ip, dst=p1_dst_start_ip, proto=17) /
- UDP(sport=int(p1_src_start_udp_port),
- dport=int(p1_dst_start_udp_port)))
- base_pkt_b = (Ether() /
- IP(src=p2_src_start_ip, dst=p2_dst_start_ip, proto=17) /
- UDP(sport=int(p2_src_start_udp_port),
- dport=int(p2_dst_start_udp_port)))
- else:
- base_pkt_a = Ether() / IP(src=p1_src_start_ip, dst=p1_dst_start_ip,
- proto=61)
- base_pkt_b = Ether() / IP(src=p2_src_start_ip, dst=p2_dst_start_ip,
- proto=61)
-
- # The following code applies raw instructions to packet (IP src/dst
- # increment). It splits the generated traffic by "ip_src"/"ip_dst" variable
- # to cores and fix IPv4 header checksum.
- if ports_defined:
- if p1_src_start_udp_port != p1_src_end_udp_port and \
- p1_src_start_ip != p1_src_end_ip:
- vm1 = STLScVmRaw([
- STLVmTupleGen(ip_min=p1_src_start_ip,
- ip_max=p1_src_end_ip,
- port_min=int(p1_src_start_udp_port),
- port_max=int(p1_src_end_udp_port),
- name="tuple"),
- STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"),
- STLVmFixIpv4(offset="IP"),
- STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport")
- ])
- vm2 = STLScVmRaw([
- STLVmTupleGen(ip_min=p2_dst_start_ip,
- ip_max=p2_dst_start_ip,
- port_min=int(p2_dst_start_udp_port),
- port_max=int(p2_dst_end_udp_port),
- name="tuple"),
- STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.dst"),
- STLVmFixIpv4(offset="IP"),
- STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.dport")
- ])
- elif p1_src_start_udp_port != p1_src_end_udp_port:
- vm1 = STLScVmRaw([
- STLVmFlowVar(name="sport",
- min_value=int(p1_src_start_udp_port),
- max_value=int(p1_src_end_udp_port),
- size=2, op="inc"),
- STLVmWrFlowVar(fv_name="sport", pkt_offset="UDP.sport")
- ])
- vm2 = STLScVmRaw([
- STLVmFlowVar(name="dport",
- min_value=int(p2_dst_start_udp_port),
- max_value=int(p2_dst_end_udp_port),
- size=2, op="inc"),
- STLVmWrFlowVar(fv_name="dport", pkt_offset="UDP.dport")
- ])
- elif p1_src_start_udp_port == p1_src_end_udp_port:
- vm1 = STLScVmRaw([STLVmFlowVar(name="src",
- min_value=p1_src_start_ip,
- max_value=p1_src_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="src",
- pkt_offset="IP.src"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="src")
- vm2 = STLScVmRaw([STLVmFlowVar(name="src",
- min_value=p2_src_start_ip,
- max_value=p2_src_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="src",
- pkt_offset="IP.src"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="src")
- elif p1_dst_end_ip and p2_dst_end_ip:
- vm1 = STLScVmRaw([STLVmFlowVar(name="dst",
- min_value=p1_dst_start_ip,
- max_value=p1_dst_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="dst")
- vm2 = STLScVmRaw([STLVmFlowVar(name="dst",
- min_value=p2_dst_start_ip,
- max_value=p2_dst_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="dst", pkt_offset="IP.dst"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="dst")
- else:
- vm1 = STLScVmRaw([STLVmFlowVar(name="src",
- min_value=p1_src_start_ip,
- max_value=p1_src_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="src")
- vm2 = STLScVmRaw([STLVmFlowVar(name="src",
- min_value=p2_src_start_ip,
- max_value=p2_src_end_ip,
- size=4, op="inc"),
- STLVmWrFlowVar(fv_name="src", pkt_offset="IP.src"),
- STLVmFixIpv4(offset="IP"),
- ], split_by_field="src")
-
- return create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size)
-
-
-def create_streams_v6(traffic_options, frame_size=78):
- """Create two IPv6 packets to be used in stream.
-
- :param traffic_options: Parameters for packets.
- :param frame_size: Size of L2 frame.
- :type traffic_options: List
- :type frame_size: int
- :return: Packet instances.
- :rtype: Tuple of STLPktBuilder
- """
-
- if type(frame_size) is int and frame_size < 78:
- print_error("Frame min. size is 78B")
- sys.exit(2)
-
- p1_src_start_ip = traffic_options['p1_src_start_ip']
- p1_src_end_ip = traffic_options['p1_src_end_ip']
- p1_dst_start_ip = traffic_options['p1_dst_start_ip']
- p2_src_start_ip = traffic_options['p2_src_start_ip']
- p2_src_end_ip = traffic_options['p2_src_end_ip']
- p2_dst_start_ip = traffic_options['p2_dst_start_ip']
-
- p1_dst_end_ip = traffic_options['p1_dst_end_ip']
- p2_dst_end_ip = traffic_options['p2_dst_end_ip']
-
- base_pkt_a = Ether()/IPv6(src=p1_src_start_ip, dst=p1_dst_start_ip)
- base_pkt_b = Ether()/IPv6(src=p2_src_start_ip, dst=p2_dst_start_ip)
-
- # The following code applies raw instructions to packet (IP src/dst
- # increment). It splits the generated traffic by "ip_src"/"ip_dst" variable
- # to cores.
- if p1_dst_end_ip and p2_dst_end_ip:
- base_p1, max_p1 = get_start_end_ipv6(p1_dst_start_ip, p1_dst_end_ip)
- base_p2, max_p2 = get_start_end_ipv6(p2_dst_start_ip, p2_dst_end_ip)
-
- vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst",
- min_value=base_p1,
- max_value=max_p1+base_p1,
- size=8, op="inc"),
- STLVmWrFlowVar(fv_name="ipv6_dst",
- pkt_offset="IPv6.dst",
- offset_fixup=8)
- ]
- , split_by_field="ipv6_dst")
- vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_dst",
- min_value=base_p2,
- max_value=max_p2+base_p2,
- size=8, op="inc"),
- STLVmWrFlowVar(fv_name="ipv6_dst",
- pkt_offset="IPv6.dst",
- offset_fixup=8)
- ]
- , split_by_field="ipv6_dst")
- else:
- base_p1, max_p1 = get_start_end_ipv6(p1_src_start_ip, p1_src_end_ip)
- base_p2, max_p2 = get_start_end_ipv6(p2_src_start_ip, p2_src_end_ip)
-
- vm1 = STLScVmRaw([STLVmFlowVar(name="ipv6_src",
- min_value=base_p1,
- max_value=max_p1+base_p1,
- size=8, op="inc"),
- STLVmWrFlowVar(fv_name="ipv6_src",
- pkt_offset="IPv6.src",
- offset_fixup=8)
- ]
- , split_by_field="ipv6_src")
- vm2 = STLScVmRaw([STLVmFlowVar(name="ipv6_src",
- min_value=base_p2,
- max_value=max_p2+base_p2,
- size=8, op="inc"),
- STLVmWrFlowVar(fv_name="ipv6_src",
- pkt_offset="IPv6.src",
- offset_fixup=8)
- ]
- , split_by_field="ipv6_src")
-
- return create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size)
-
-def fmt_latency(lat_min, lat_avg, lat_max):
- """ Return formatted, rounded latency
-
- :param lat_min: Min latency
- :param lat_avg: Average latency
- :param lat_max: Max latency
- :type lat_min: string
- :type lat_avg: string
- :type lat_max: string
- :return: Formatted and rounded output "min/avg/max"
- :rtype: string
- """
-
- try:
- t_min = int(round(float(lat_min)))
- except ValueError:
- t_min = int(-1)
- try:
- t_avg = int(round(float(lat_avg)))
- except ValueError:
- t_avg = int(-1)
- try:
- t_max = int(round(float(lat_max)))
- except ValueError:
- t_max = int(-1)
-
- return "/".join(str(tmp) for tmp in (t_min, t_avg, t_max))
-
-def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate,
- warmup_time, async_start, latency):
- """Run the traffic with specific parameters.
-
- :param pkt_a: Base packet for stream 1.
- :param pkt_b: Base packet for stream 2.
- :param pkt_lat_a: Base packet for latency stream 1.
- :param pkt_lat_b: Base packet for latency stream 2.
- :param duration: Duration of traffic run in seconds (-1=infinite).
- :param rate: Rate of traffic run [percentage, pps, bps].
- :param warmup_time: Warm up duration.
- :param async_start: Start the traffic and exit.
- :param latency: With latency stats.
- :type pkt_a: STLPktBuilder
- :type pkt_b: STLPktBuilder
- :type pkt_lat_a: STLPktBuilder
- :type pkt_lat_b: STLPktBuilder
- :type duration: int
- :type rate: string
- :type warmup_time: int
- :type async_start: bool
- :type latency: bool
- :return: nothing
- """
-
- # create client
- client = STLClient()
-
- total_rcvd = 0
- total_sent = 0
- lost_a = 0
- lost_b = 0
- lat_a = "-1/-1/-1"
- lat_b = "-1/-1/-1"
-
- try:
- # turn this off if too many logs
- #client.set_verbose("high")
-
- # connect to server
- client.connect()
-
- # prepare our ports (my machine has 0 <--> 1 with static route)
- client.reset(ports=[0, 1])
-
- client.add_streams(stream_a, ports=[0])
- client.add_streams(stream_b, ports=[1])
-
- if latency:
- try:
- client.add_streams(stream_lat_a, ports=[0])
- client.add_streams(stream_lat_b, ports=[1])
- except:
- #Disable latency if NIC does not support requested stream type
- print "##### FAILED to add latency streams #####"
- latency = False
-
- #warmup phase
- if warmup_time > 0:
- # clear the stats before injecting
- client.clear_stats()
-
- # choose rate and start traffic
- client.start(ports=[0, 1], mult=rate, duration=warmup_time)
-
- # block until done
- client.wait_on_traffic(ports=[0, 1], timeout=(warmup_time+30))
-
- if client.get_warnings():
- for warning in client.get_warnings():
- print(warning)
-
- # read the stats after the test
- stats = client.get_stats()
-
- print "#####warmup statistics#####"
- print json.dumps(stats, indent=4,
- separators=(',', ': '), sort_keys=True)
- lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
- lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
-
- print "\npackets lost from 0 --> 1: {0} pkts".format(lost_a)
- print "packets lost from 1 --> 0: {0} pkts".format(lost_b)
-
- # clear the stats before injecting
- client.clear_stats()
- lost_a = 0
- lost_b = 0
-
- # choose rate and start traffic
- client.start(ports=[0, 1], mult=rate, duration=duration)
-
- if not async_start:
- # block until done
- client.wait_on_traffic(ports=[0, 1], timeout=(duration+30))
-
- if client.get_warnings():
- for warning in client.get_warnings():
- print(warning)
-
- # read the stats after the test
- stats = client.get_stats()
-
- print "#####statistics#####"
- print json.dumps(stats, indent=4,
- separators=(',', ': '), sort_keys=True)
- lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
- lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
-
- if latency:
- lat_a = fmt_latency(\
- str(stats["latency"][0]["latency"]["total_min"]),\
- str(stats["latency"][0]["latency"]["average"]),\
- str(stats["latency"][0]["latency"]["total_max"]))
- lat_b = fmt_latency(\
- str(stats["latency"][1]["latency"]["total_min"]),\
- str(stats["latency"][1]["latency"]["average"]),\
- str(stats["latency"][1]["latency"]["total_max"]))
-
- total_sent = stats[0]["opackets"] + stats[1]["opackets"]
- total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"]
-
- print "\npackets lost from 0 --> 1: {0} pkts".format(lost_a)
- print "packets lost from 1 --> 0: {0} pkts".format(lost_b)
-
- except STLError as ex_error:
- print_error(str(ex_error))
- sys.exit(1)
-
- finally:
- if async_start:
- client.disconnect(stop_traffic=False, release_ports=True)
- else:
- client.disconnect()
- print "rate={0}, totalReceived={1}, totalSent={2}, "\
- "frameLoss={3}, latencyStream0(usec)={4}, "\
- "latencyStream1(usec)={5}".format(rate, total_rcvd,\
- total_sent, lost_a+lost_b, lat_a, lat_b)
-
-
-def print_error(msg):
- """Print error message on stderr.
-
- :param msg: Error message to print.
- :type msg: string
- :return: nothing
- """
-
- sys.stderr.write(msg+'\n')
-
-
-def parse_args():
- """Parse arguments from cmd line.
-
- :return: Parsed arguments.
- :rtype ArgumentParser
- """
-
- parser = argparse.ArgumentParser()
- parser.add_argument("-d", "--duration", required=True, type=int,
- help="Duration of traffic run")
- parser.add_argument("-s", "--frame_size", required=True,
- help="Size of a Frame without padding and IPG")
- parser.add_argument("-r", "--rate", required=True,
- help="Traffic rate with included units (%, pps)")
- parser.add_argument("-6", "--use_IPv6", action="store_true",
- default=False,
- help="Use IPv6 traffic profile instead of IPv4")
- parser.add_argument("--async", action="store_true",
- default=False,
- help="Non-blocking call of the script")
- parser.add_argument("--latency", action="store_true",
- default=False,
- help="Add latency stream")
- parser.add_argument("-w", "--warmup_time", type=int,
- default=5,
- help="Traffic warmup time in seconds, 0 = disable")
-# parser.add_argument("--p1_src_mac",
-# help="Port 1 source MAC address")
-# parser.add_argument("--p1_dst_mac",
-# help="Port 1 destination MAC address")
-
- parser.add_argument("--p1_src_start_ip", required=True,
- help="Port 1 source start IP address")
- parser.add_argument("--p1_src_end_ip",
- default=False,
- help="Port 1 source end IP address")
- parser.add_argument("--p1_dst_start_ip", required=True,
- help="Port 1 destination start IP address")
- parser.add_argument("--p1_dst_end_ip",
- default=False,
- help="Port 1 destination end IP address")
-
- parser.add_argument("--p1_src_start_udp_port",
- default=None,
- help="Port 1 source start UDP port.")
- parser.add_argument("--p1_src_end_udp_port",
- default=None,
- help="Port 1 source end UDP port.")
-
- parser.add_argument("--p1_dst_start_udp_port",
- default=None,
- help="Port 1 destination start UDP port.")
- parser.add_argument("--p1_dst_end_udp_port",
- default=None,
- help="Port 1 destination end UDP port.")
-
-# parser.add_argument("--p2_src_mac",
-# help="Port 2 source MAC address")
-# parser.add_argument("--p2_dst_mac",
-# help="Port 2 destination MAC address")
-
- parser.add_argument("--p2_src_start_ip", required=True,
- help="Port 2 source start IP address")
- parser.add_argument("--p2_src_end_ip",
- default=False,
- help="Port 2 source end IP address")
- parser.add_argument("--p2_dst_start_ip", required=True,
- help="Port 2 destination start IP address")
- parser.add_argument("--p2_dst_end_ip",
- default=False,
- help="Port 2 destination end IP address")
-
- parser.add_argument("--p2_src_start_udp_port",
- default=None,
- help="Port 2 source start UDP port.")
- parser.add_argument("--p2_src_end_udp_port",
- default=None,
- help="Port 2 source end UDP port.")
-
- parser.add_argument("--p2_dst_start_udp_port",
- default=None,
- help="Port 2 destination start UDP port.")
- parser.add_argument("--p2_dst_end_udp_port",
- default=None,
- help="Port 2 destination end UDP port.")
-
- return parser.parse_args()
-
-
-def main():
- """Main function."""
-
- args = parse_args()
-
- _duration = args.duration
- _latency = args.latency
- if args.frame_size.isdigit():
- _frame_size = int(args.frame_size)
- else:
- _frame_size = args.frame_size
- _latency = False
- _rate = args.rate
- _use_ipv6 = args.use_IPv6
- _async_call = args.async
- _warmup_time = args.warmup_time
-
- _traffic_options = {}
- for attr in [a for a in dir(args) if a.startswith('p')]:
- if getattr(args, attr) is not None:
- _traffic_options[attr] = getattr(args, attr)
-
- if _use_ipv6:
- stream_a, stream_b, stream_lat_a, stream_lat_b = create_streams_v6(
- _traffic_options, frame_size=_frame_size)
- else:
- stream_a, stream_b, stream_lat_a, stream_lat_b = create_streams(
- _traffic_options, frame_size=_frame_size)
-
- simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b,
- _duration, _rate, _warmup_time, _async_call, _latency)
-
-if __name__ == "__main__":
- sys.exit(main())