From 2a3171f73e838fccbc82d2d8553e36c7c3820e28 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Fri, 4 Mar 2016 17:10:33 +0200 Subject: add manual padding to 60 bytes with zeros --- .../stl/trex_stl_lib/trex_stl_packet_builder_scapy.py | 14 ++++++-------- .../stl/trex_stl_lib/trex_stl_streams.py | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl') 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 a3430c79..6a2e268f 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 @@ -950,20 +950,18 @@ 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 # regular scapy packet - elif self.pkt: - self.pkt.build() - - else: + elif not self.pkt: # should not reach here raise CTRexPacketBuildException(-11, 'empty packet') - + if self.remove_fcs and self.pkt.lastlayer().name == 'Padding': + self.pkt.lastlayer().underlayer.remove_payload() + if len(self.pkt) < 60: # simulator can write padding with non-zeros, set it explicit + self.pkt /= Padding('\x00' * (60 - len(self.pkt))) + self.pkt.build() self.is_pkt_built = True def _pkt_layer_offset (self,layer_name): diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index c41fa0c2..5aa544ab 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -344,8 +344,6 @@ class STLStream(object): imports_arr = [] if 'MPLS(' in packet_command: imports_arr.append('from scapy.contrib.mpls import MPLS') - if 'VXLAN(' in packet_command: - imports_arr.append('from scapy.contrib.mpls import MPLS') imports = '\n'.join(imports_arr) if payload: -- cgit 1.2.3-korg