aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/extras/nat_test_slow_path_with_latency.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /src/plugins/nat/extras/nat_test_slow_path_with_latency.py
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/plugins/nat/extras/nat_test_slow_path_with_latency.py')
-rw-r--r--src/plugins/nat/extras/nat_test_slow_path_with_latency.py81
1 files changed, 46 insertions, 35 deletions
diff --git a/src/plugins/nat/extras/nat_test_slow_path_with_latency.py b/src/plugins/nat/extras/nat_test_slow_path_with_latency.py
index 6c7663434c5..0c08e7a5e80 100644
--- a/src/plugins/nat/extras/nat_test_slow_path_with_latency.py
+++ b/src/plugins/nat/extras/nat_test_slow_path_with_latency.py
@@ -2,7 +2,6 @@ from trex_stl_lib.api import *
class STLS1:
-
def create_stream(self, port_id):
# base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12)
@@ -24,49 +23,61 @@ class STLS1:
# return STLStream(packet=pkt, mode=STLTXCont())
- vm = STLScVmRaw([STLVmTupleGen(ip_min="10.0.0.1", ip_max="10.255.255.254",
- port_min=1025, port_max=65535,
- name="stuple", limit_flows=10000),
- STLVmTupleGen(ip_min="2.0.0.1", ip_max="2.255.255.254",
- port_min=1025, port_max=65535,
- name="dtuple", limit_flows=100000000),
-
- # write ip to packet IP.src
- STLVmWrFlowVar(fv_name="stuple.ip",
- pkt_offset="IP.src"),
- STLVmWrFlowVar(fv_name="dtuple.ip",
- pkt_offset="IP.dst"),
- # fix checksum
- STLVmFixIpv4(offset="IP"),
- # write udp.port
- STLVmWrFlowVar(fv_name="stuple.port",
- pkt_offset="UDP.sport"),
- STLVmWrFlowVar(fv_name="dtuple.port",
- pkt_offset="UDP.dport"),
- ]
- )
-
- base_pkt = Ether()/IP(src="16.0.0.1", dst="2.0.0.1")/UDP(dport=12, sport=1025)
+ vm = STLScVmRaw(
+ [
+ STLVmTupleGen(
+ ip_min="10.0.0.1",
+ ip_max="10.255.255.254",
+ port_min=1025,
+ port_max=65535,
+ name="stuple",
+ limit_flows=10000,
+ ),
+ STLVmTupleGen(
+ ip_min="2.0.0.1",
+ ip_max="2.255.255.254",
+ port_min=1025,
+ port_max=65535,
+ name="dtuple",
+ limit_flows=100000000,
+ ),
+ # write ip to packet IP.src
+ STLVmWrFlowVar(fv_name="stuple.ip", pkt_offset="IP.src"),
+ STLVmWrFlowVar(fv_name="dtuple.ip", pkt_offset="IP.dst"),
+ # fix checksum
+ STLVmFixIpv4(offset="IP"),
+ # write udp.port
+ STLVmWrFlowVar(fv_name="stuple.port", pkt_offset="UDP.sport"),
+ STLVmWrFlowVar(fv_name="dtuple.port", pkt_offset="UDP.dport"),
+ ]
+ )
+
+ base_pkt = (
+ Ether() / IP(src="16.0.0.1", dst="2.0.0.1") / UDP(dport=12, sport=1025)
+ )
pad = Padding()
if len(base_pkt) < 64:
pad_len = 64 - len(base_pkt)
- pad.load = '\x00' * pad_len
+ pad.load = "\x00" * pad_len
- pad = max(0, 64 - len(base_pkt)) * 'x'
- pad_latency = max(0, (64-4) - len(base_pkt)) * 'x'
+ pad = max(0, 64 - len(base_pkt)) * "x"
+ pad_latency = max(0, (64 - 4) - len(base_pkt)) * "x"
- pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
+ pkt = STLPktBuilder(pkt=base_pkt / pad, vm=vm)
- return [STLStream(packet=pkt, mode=STLTXCont()),
- # latency stream
- STLStream(packet = STLPktBuilder(pkt = base_pkt/pad_latency),
- mode = STLTXCont(pps=1000),
- flow_stats = STLFlowLatencyStats(pg_id = 12+port_id))
- ]
+ return [
+ STLStream(packet=pkt, mode=STLTXCont()),
+ # latency stream
+ STLStream(
+ packet=STLPktBuilder(pkt=base_pkt / pad_latency),
+ mode=STLTXCont(pps=1000),
+ flow_stats=STLFlowLatencyStats(pg_id=12 + port_id),
+ ),
+ ]
def get_streams(self, direction=0, **kwargs):
# return [self.create_stream()]
- return self.create_stream(kwargs['port_id'])
+ return self.create_stream(kwargs["port_id"])
# dynamic load - used for trex console or simulator