summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYichen Wang <yicwang@cisco.com>2020-04-17 16:06:40 -0700
committerYichen Wang <yicwang@cisco.com>2020-04-26 12:56:19 -0700
commitf5dad1934237c978e802ea1fd941f5dc195c3011 (patch)
treeb541debba0640f783ef7a2604b3f307a6d827720
parentae6e172471fef8bef60d497eedaf199966ffb799 (diff)
[NFVBENCH-165] Use STLVmFixIpv4 to fix inner IP/UDP payload
Change-Id: Ib9a5defcf06a32dbd30215635778abcb438785b1 Signed-off-by: Yichen Wang <yicwang@cisco.com>
-rw-r--r--nfvbench/traffic_gen/trex_gen.py12
-rw-r--r--test/mock_trex.py1
2 files changed, 9 insertions, 4 deletions
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index 0ecad1e..de9500a 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -47,6 +47,7 @@ from trex.stl.api import STLScVmRaw
from trex.stl.api import STLStream
from trex.stl.api import STLTXCont
from trex.stl.api import STLVmFixChecksumHw
+from trex.stl.api import STLVmFixIpv4
from trex.stl.api import STLVmFlowVar
from trex.stl.api import STLVmFlowVarRepeatableRandom
from trex.stl.api import STLVmWrFlowVar
@@ -471,10 +472,13 @@ class TRex(AbstractTrafficGenerator):
dst_fv_port,
STLVmWrFlowVar(fv_name="p_dst", pkt_offset="UDP:{}.dport".format(encap_level)),
]
- for encap in range(int(encap_level), -1, -1):
- vm_param.append(STLVmFixChecksumHw(l3_offset="IP:{}".format(encap),
- l4_offset="UDP:{}".format(encap),
- l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP))
+ # Use HW Offload to calculate the outter IP/UDP packet
+ vm_param.append(STLVmFixChecksumHw(l3_offset="IP:0",
+ l4_offset="UDP:0",
+ l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP))
+ # Use software to fix the inner IP/UDP payload for VxLAN packets
+ if int(encap_level):
+ vm_param.append(STLVmFixIpv4(offset="IP:1"))
pad = max(0, frame_size - len(pkt_base)) * 'x'
return STLPktBuilder(pkt=pkt_base / pad,
diff --git a/test/mock_trex.py b/test/mock_trex.py
index 4f0271a..49fe5a9 100644
--- a/test/mock_trex.py
+++ b/test/mock_trex.py
@@ -52,6 +52,7 @@ except ImportError:
api_mod.STLStream = STLDummy
api_mod.STLTXCont = STLDummy
api_mod.STLVmFixChecksumHw = STLDummy
+ api_mod.STLVmFixIpv4 = STLDummy
api_mod.STLVmFlowVar = STLDummy
api_mod.STLVmFlowVarRepeatableRandom = STLDummy
api_mod.STLVmWrFlowVar = STLDummy