diff options
Diffstat (limited to 'src/plugins/nat/extras/nat_test_fast_path.py')
-rw-r--r-- | src/plugins/nat/extras/nat_test_fast_path.py | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/plugins/nat/extras/nat_test_fast_path.py b/src/plugins/nat/extras/nat_test_fast_path.py index e869d40872a..fb880fb9e96 100644 --- a/src/plugins/nat/extras/nat_test_fast_path.py +++ b/src/plugins/nat/extras/nat_test_fast_path.py @@ -2,7 +2,6 @@ from trex_stl_lib.api import * class STLS1: - def create_stream(self): # base_pkt = Ether()/IP(dst="2.2.0.1")/UDP(dport=12) @@ -24,37 +23,46 @@ 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), - name="stuple", limit_flows=100), - STLVmTupleGen(ip_min="2.0.0.1", ip_max="2.255.255.254", - port_min=1025, port_max=65535, - # name="dtuple", limit_flows=100000000), - name="dtuple", limit_flows=100), - - # 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), + name="stuple", + limit_flows=100, + ), + STLVmTupleGen( + ip_min="2.0.0.1", + ip_max="2.255.255.254", + port_min=1025, + port_max=65535, + # name="dtuple", limit_flows=100000000), + name="dtuple", + limit_flows=100, + ), + # 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 - pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm) + pkt = STLPktBuilder(pkt=base_pkt / pad, vm=vm) return STLStream(packet=pkt, mode=STLTXCont()) |