summaryrefslogtreecommitdiffstats
path: root/scripts/stl
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-18 06:15:53 -0500
committerimarom <imarom@cisco.com>2016-02-18 06:15:53 -0500
commitc6f710bc844e812fe448f7a2850fe15058328777 (patch)
tree2368d9d438a4dc0357d5c136190b414d77bf0c24 /scripts/stl
parenta5788f0e036baa9c28eab4abb705affc89abc498 (diff)
profiles for PCAPs
Diffstat (limited to 'scripts/stl')
-rw-r--r--scripts/stl/pcap.py26
-rw-r--r--scripts/stl/pcap_with_vm.py48
-rw-r--r--scripts/stl/sample.pcapbin0 -> 98768 bytes
3 files changed, 74 insertions, 0 deletions
diff --git a/scripts/stl/pcap.py b/scripts/stl/pcap.py
new file mode 100644
index 00000000..d4b88a53
--- /dev/null
+++ b/scripts/stl/pcap.py
@@ -0,0 +1,26 @@
+import os
+from trex_stl_lib.api import *
+
+# PCAP profile
+class STLPcap(object):
+
+ def __init__ (self, pcap_file):
+ self.pcap_file = pcap_file
+
+ def get_streams (self,
+ ipg_usec = 10.0,
+ loop_count = 1):
+
+ profile = STLProfile.load_pcap(self.pcap_file, ipg_usec = ipg_usec, loop_count = loop_count)
+
+ return profile.get_streams()
+
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ # get file relative to profile dir
+ return STLPcap(os.path.join(os.path.dirname(__file__), 'sample.pcap'))
+
+
+
diff --git a/scripts/stl/pcap_with_vm.py b/scripts/stl/pcap_with_vm.py
new file mode 100644
index 00000000..7962d2b2
--- /dev/null
+++ b/scripts/stl/pcap_with_vm.py
@@ -0,0 +1,48 @@
+import os
+from trex_stl_lib.api import *
+
+# PCAP profile
+class STLPcap(object):
+
+ def __init__ (self, pcap_file):
+ self.pcap_file = pcap_file
+
+ def create_vm (self, ip_src_range, ip_dst_range):
+ if not ip_src_range and not ip_dst_range:
+ return None
+
+ vm = [STLVmFixIpv4(offset = "IP")]
+
+ if ip_src_range:
+ vm += [STLVmFlowVar(name="src", min_value = ip_src_range['start'], max_value = ip_src_range['end'], size = 4, op = "inc"),
+ STLVmWrFlowVar(fv_name="src",pkt_offset= "IP.src")
+ ]
+
+ if ip_dst_range:
+ vm += [STLVmFlowVar(name="dst", min_value = ip_dst_range['start'], max_value = ip_dst_range['end'], size = 4, op = "inc"),
+ STLVmWrFlowVar(fv_name="dst",pkt_offset= "IP.dst")
+ ]
+
+ return vm
+
+
+ def get_streams (self,
+ ipg_usec = 10.0,
+ loop_count = 1,
+ ip_src_range = None,
+ ip_dst_range = {'start' : '10.0.0.1', 'end': '10.0.0.254'}):
+
+ vm = self.create_vm(ip_src_range, ip_dst_range)
+ profile = STLProfile.load_pcap(self.pcap_file, ipg_usec = ipg_usec, loop_count = loop_count, vm = vm)
+
+ return profile.get_streams()
+
+
+
+# dynamic load - used for trex console or simulator
+def register():
+ # get file relative to profile dir
+ return STLPcap(os.path.join(os.path.dirname(__file__), 'sample.pcap'))
+
+
+
diff --git a/scripts/stl/sample.pcap b/scripts/stl/sample.pcap
new file mode 100644
index 00000000..2cb9d893
--- /dev/null
+++ b/scripts/stl/sample.pcap
Binary files differ