summaryrefslogtreecommitdiffstats
path: root/scripts/stl/tests
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-09-14 13:31:39 +0300
committerimarom <imarom@cisco.com>2016-09-25 15:00:45 +0300
commit0f1d226c5fc94d4d28665b9c1f3ffc2bac11cdfc (patch)
treed0c8daafdc943a4d2e7ebae9d9c16379e0e59d13 /scripts/stl/tests
parentce6d61aa2943bfa845a9d0f69e8b9353e0456794 (diff)
draft: new split algorithm
Diffstat (limited to 'scripts/stl/tests')
-rw-r--r--scripts/stl/tests/multi_core_test.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/scripts/stl/tests/multi_core_test.py b/scripts/stl/tests/multi_core_test.py
new file mode 100644
index 00000000..a0ec3b2d
--- /dev/null
+++ b/scripts/stl/tests/multi_core_test.py
@@ -0,0 +1,79 @@
+from trex_stl_lib.api import *
+import random
+
+class STLMultiCore(object):
+
+ def __init__ (self):
+ # default IMIX properties
+ self.streams_def = [ {'size': 300, 'pps': 2884, 'isg':0 },
+ #{'size': 590, 'pps': 20, 'isg':0.1 },
+ #{'size': 1514, 'pps': 4, 'isg':0.2 }
+ ]
+
+
+ def create_stream (self, size, pps, isg, vm ):
+ # Create base packet and pad it to size
+ base_pkt = Ether()/IP()/UDP()
+ pad = max(0, size - len(base_pkt)) * 'x'
+
+ pkt = STLPktBuilder(pkt = base_pkt/pad,
+ vm = vm)
+
+ return STLStream(isg = isg,
+ packet = pkt,
+ mode = STLTXCont(pps = pps))
+
+
+ def generate_var (self, rng, i):
+
+ d = {'name': str(i)}
+
+ d['size'] = rng.choice([1, 2, 4])
+ max_val = (1 << d['size'] * 8)
+
+ d['start'] = rng.randint(0, max_val - 1)
+ d['end'] = rng.randint(d['start'], max_val)
+ d['step'] = rng.randint(1, 1000)
+ d['op'] = rng.choice(['inc', 'dec'])
+
+ return d
+
+ def dump_var (self, var):
+ return 'name: {:}, start: {:}, end: {:}, size: {:}, op: {:}, step {:}'.format(var['name'], var['start'], var['end'], var['size'], var['op'], var['step'])
+
+
+ def get_streams (self, direction = 0, **kwargs):
+
+ rng = random.Random(kwargs.get('seed', 1))
+
+ # base offset
+ pkt_offset = 42
+ vm = []
+ print("\nusing the following vars:\n")
+ for i in range(10):
+ var = self.generate_var(rng, i)
+ print("at offset {:} - var: {:}".format(pkt_offset, self.dump_var(var)))
+ vm += [STLVmFlowVar(name = var['name'],
+ min_value = var['start'],
+ max_value = var['end'],
+ size = var['size'],
+ op = var['op']),
+ STLVmWrFlowVar(fv_name = var['name'], pkt_offset = pkt_offset),
+ ]
+ pkt_offset += var['size']
+
+
+
+
+ print("\n")
+ # create imix streams
+ return [self.create_stream(x['size'], x['pps'],x['isg'] , vm) for x in self.streams_def]
+
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ return STLMultiCore()
+
+
+