aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/t-rex/t-rex-stateless.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2017-03-13 13:22:08 +0100
committerTibor Frank <tifrank@cisco.com>2017-04-18 11:24:44 +0200
commit28bab4e715a123199972bdc5f79f6a508a879fd6 (patch)
tree0b6c3a3aa71eb80143eae2c62086a61e153818c6 /resources/tools/t-rex/t-rex-stateless.py
parent4da982b7a0f5872de2cc721607894216a20892f4 (diff)
CSIT-545: Performance tests for SNAT
- High level definition (HLD) - Low level definition (LLD) - Add keywords to set SNAT - Add tests according to HLD, LLD Change-Id: I7bf0b1870ac9c3adb36bb6590be9a3eb4ea8aa9a Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/t-rex/t-rex-stateless.py')
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless.py118
1 files changed, 114 insertions, 4 deletions
diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py
index 504ef50eef..ae8d187670 100755
--- a/resources/tools/t-rex/t-rex-stateless.py
+++ b/resources/tools/t-rex/t-rex-stateless.py
@@ -172,12 +172,13 @@ def create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size):
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: list
+ :type traffic_options: dict
:type frame_size: int
:return: Packet instances.
:rtype: Tuple of STLPktBuilder
@@ -197,13 +198,91 @@ def create_streams(traffic_options, frame_size=64):
p1_dst_end_ip = traffic_options['p1_dst_end_ip']
p2_dst_end_ip = traffic_options['p2_dst_end_ip']
- 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)
+ 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 p1_dst_end_ip and p2_dst_end_ip:
+ 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,
@@ -524,6 +603,7 @@ def parse_args():
# 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",
@@ -534,10 +614,26 @@ def parse_args():
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",
@@ -549,6 +645,20 @@ def parse_args():
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()