From f5dad1934237c978e802ea1fd941f5dc195c3011 Mon Sep 17 00:00:00 2001 From: Yichen Wang Date: Fri, 17 Apr 2020 16:06:40 -0700 Subject: [NFVBENCH-165] Use STLVmFixIpv4 to fix inner IP/UDP payload Change-Id: Ib9a5defcf06a32dbd30215635778abcb438785b1 Signed-off-by: Yichen Wang --- nfvbench/traffic_gen/trex_gen.py | 12 ++++++++---- test/mock_trex.py | 1 + 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 -- cgit 1.2.3-korg