summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-04 03:46:39 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-04 03:46:39 +0200
commita842b4cfd27f03db83c0bb8ed10816465cc510ad (patch)
tree34596b6959c36a2e16f9dc29131f72a20ba03b34 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
parentf749b4358cfedd1ef7e0b58f69f63ee4d00554ea (diff)
ignore python3 cache, generated code files
add option to export Profile (and thus stream too) to Python code add for each profile in functional tests generating it to Python code and comparing to same pcap result add loading Prifile via add_streams() fix IMIX rates in HLTAPI used with line % and bps Scapy packet builder: fixes to load of pcap/yaml - use MAC from pcap (with flag), remove FCS (with flag), support for VM with offsets by name
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py15
1 files changed, 10 insertions, 5 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 dc787263..a3430c79 100644
--- 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
@@ -674,7 +674,7 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
When path_relative_to_profile is True load pcap file from path relative to the profile
"""
- def __init__(self, pkt = None, pkt_buffer = None, vm = None, path_relative_to_profile = False):
+ def __init__(self, pkt = None, pkt_buffer = None, vm = None, path_relative_to_profile = False, build_raw = True, remove_fcs = True):
"""
Instantiate a CTRexPktBuilder object
@@ -688,8 +688,10 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
self.pkt_raw = None # from raw pcap file
self.vm_scripts = [] # list of high level instructions
self.vm_low_level = None
+ self.is_pkt_built = False
self.metadata=""
self.path_relative_to_profile = path_relative_to_profile
+ self.remove_fcs = remove_fcs
if pkt != None and pkt_buffer != None:
@@ -709,13 +711,17 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
self.add_command(vm if isinstance(vm, CTRexScRaw) else CTRexScRaw(vm))
+ # raw source build to see MAC presence/ fields offset by name in VM
+ if build_raw and self.pkt_raw and not self.pkt:
+ self.__lazy_build_packet()
+
# if we have packet and VM - compile now
if (self.pkt or self.pkt_raw) and (self.vm_scripts):
self.compile()
def dump_vm_data_as_yaml(self):
- print yaml.dump(self.get_vm_data(), default_flow_style=False)
+ print yaml.dump(self.get_vm_data(), default_flow_style=False)
def get_vm_data(self):
"""
@@ -861,9 +867,6 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
self.vm_low_level = CTRexVmEngine()
-
- # before VM compile set this to false
- self.is_pkt_built = False
# compile the VM
for sc in self.vm_scripts:
@@ -947,6 +950,8 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
# for buffer, promote to a scapy packet
if self.pkt_raw:
self.pkt = Ether(self.pkt_raw)
+ if self.remove_fcs and self.pkt.lastlayer().name == 'Padding':
+ self.pkt.lastlayer().underlayer.remove_payload()
self.pkt.build()
self.pkt_raw = None