summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py25
-rw-r--r--scripts/exp/stl_vm_enable0_cache_10-0-ex.erfbin0 -> 880 bytes
-rw-r--r--scripts/exp/stl_vm_enable1_cache_500-0-ex.erfbin0 -> 12936 bytes
-rw-r--r--scripts/stl/udp_1pkt_src_ip_split.py46
-rwxr-xr-xscripts/t-rex-64-debug-gdb2
5 files changed, 66 insertions, 7 deletions
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 8c711563..e12efaf9 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
--- /dev/null
+++ b/scripts/exp/stl_vm_enable0_cache_10-0-ex.erf
Binary files 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
--- /dev/null
+++ b/scripts/exp/stl_vm_enable1_cache_500-0-ex.erf
Binary files differ
diff --git a/scripts/stl/udp_1pkt_src_ip_split.py b/scripts/stl/udp_1pkt_src_ip_split.py
new file mode 100644
index 00000000..778ccf54
--- /dev/null
+++ b/scripts/stl/udp_1pkt_src_ip_split.py
@@ -0,0 +1,46 @@
+from trex_stl_lib.api import *
+
+
+# split the range of IP to cores
+#
+class STLS1(object):
+
+ def __init__ (self):
+ self.fsize =64;
+
+ def create_stream (self):
+ # create a base packet and pad it to size
+ size = self.fsize - 4; # no FCS
+
+ base_pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
+
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+ 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
+ ]
+ ,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,
+ vm = vm)
+ stream = STLStream(packet = pkt,
+ mode = STLTXCont())
+ #print(stream.to_code())
+ return stream
+
+
+ def get_streams (self, direction = 0, **kwargs):
+ # create 1 stream
+ return [ self.create_stream() ]
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLS1()
+
+
+
diff --git a/scripts/t-rex-64-debug-gdb b/scripts/t-rex-64-debug-gdb
index 087afb71..723bfe2f 100755
--- a/scripts/t-rex-64-debug-gdb
+++ b/scripts/t-rex-64-debug-gdb
@@ -1,4 +1,4 @@
#! /bin/bash
export LD_LIBRARY_PATH=`pwd`
-gdb --args ./_t-rex-64-debug $@
+/bin/gdb --args ./_t-rex-64-debug $@