From 8b4df27252f317b33e11a626997748971625a47c Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Sun, 8 May 2016 20:32:52 +0300 Subject: add cache to CP --- .../trex_stl_lib/trex_stl_packet_builder_scapy.py | 25 ++++++++++++++++----- scripts/exp/stl_vm_enable0_cache_10-0-ex.erf | Bin 0 -> 880 bytes scripts/exp/stl_vm_enable1_cache_500-0-ex.erf | Bin 0 -> 12936 bytes scripts/stl/udp_1pkt_src_ip_split.py | 5 +++-- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 scripts/exp/stl_vm_enable0_cache_10-0-ex.erf create mode 100644 scripts/exp/stl_vm_enable1_cache_500-0-ex.erf (limited to 'scripts') diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py index f8517a47..f06d5d70 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py @@ -185,7 +185,7 @@ class STLScVmRaw(CTRexScriptsBase): """ Raw instructions """ - def __init__(self,list_of_commands=None,split_by_field=None): + def __init__(self,list_of_commands=None,split_by_field=None,cache_size=None): """ Include a list of a basic instructions objects. @@ -196,6 +196,8 @@ class STLScVmRaw(CTRexScriptsBase): split_by_field : string by which field to split to threads + cache_size : uint16_t + In case it is bigger than zero, FE results will be cached - this will speedup of the program at the cost of limiting the number of possible packets to the number of cache. The cache size is limited to the pool size The following example splits the generated traffic by "ip_src" variable. @@ -218,13 +220,16 @@ class STLScVmRaw(CTRexScriptsBase): STLVmFixIpv4(offset = "IP"), # fix checksum ] - ,split_by_field = "ip_src" + ,split_by_field = "ip_src", + cache_size = 1000 ) """ super(STLScVmRaw, self).__init__() self.split_by_field = split_by_field + self.cache_size = cache_size + if list_of_commands==None: self.commands =[] else: @@ -339,6 +344,8 @@ class CTRexVmEngine(object): super(CTRexVmEngine, self).__init__() self.ins=[] self.split_by_var = '' + self.cache_size = 0 + # return as json def get_json (self): @@ -347,7 +354,10 @@ class CTRexVmEngine(object): for obj in self.ins: inst_array.append(obj.__dict__); - return {'instructions': inst_array, 'split_by_var': self.split_by_var} + d={'instructions': inst_array, 'split_by_var': self.split_by_var}; + if self.cache_size >0 : + d['cache']=self.cache_size + return d def add_ins (self,ins): #assert issubclass(ins, CTRexVmInsBase) @@ -1422,11 +1432,14 @@ class STLPktBuilder(CTrexPktBuilderInterface): # set split_by_var if obj.split_by_field : validate_type('obj.split_by_field', obj.split_by_field, str) - #if not vars.has_key(obj.split_by_field): - # raise CTRexPacketBuildException(-11,("variable %s does not exists. change split_by_var args ") % (var_name) ); - self.vm_low_level.split_by_var = obj.split_by_field + #set cache size + if obj.cache_size : + validate_type('obj.cache_size', obj.cache_size, int) + self.vm_low_level.cache_size = obj.cache_size + + # lazy packet build only on demand def __lazy_build_packet (self): diff --git a/scripts/exp/stl_vm_enable0_cache_10-0-ex.erf b/scripts/exp/stl_vm_enable0_cache_10-0-ex.erf new file mode 100644 index 00000000..1a0ba1f6 Binary files /dev/null and b/scripts/exp/stl_vm_enable0_cache_10-0-ex.erf differ diff --git a/scripts/exp/stl_vm_enable1_cache_500-0-ex.erf b/scripts/exp/stl_vm_enable1_cache_500-0-ex.erf new file mode 100644 index 00000000..73a1a963 Binary files /dev/null and b/scripts/exp/stl_vm_enable1_cache_500-0-ex.erf differ diff --git a/scripts/stl/udp_1pkt_src_ip_split.py b/scripts/stl/udp_1pkt_src_ip_split.py index d83da06e..778ccf54 100644 --- a/scripts/stl/udp_1pkt_src_ip_split.py +++ b/scripts/stl/udp_1pkt_src_ip_split.py @@ -18,10 +18,11 @@ class STLS1(object): vm = STLScVmRaw( [ STLVmFlowVar ( "ip_src", min_value="10.0.0.1", max_value="10.0.0.255", size=4, step=1,op="inc"), - STLVmWrFlowVar (fv_name="ip_src", pkt_offset= "IP.src" ) # write ip to packet IP.src - #STLVmFixIpv4(offset = "IP"), # fix checksum + STLVmWrFlowVar (fv_name="ip_src", pkt_offset= "IP.src" ), # write ip to packet IP.src + STLVmFixIpv4(offset = "IP") # fix checksum ] ,split_by_field = "ip_src" # split to cores base on the tuple generator + ,cache_size =255 # the cache size ); pkt = STLPktBuilder(pkt = base_pkt/pad, -- cgit 1.2.3-korg