add manual padding to 60 bytes with zeros
authorYaroslav Brustinov <[email protected]>
Fri, 4 Mar 2016 15:10:33 +0000 (17:10 +0200)
committerYaroslav Brustinov <[email protected]>
Fri, 4 Mar 2016 15:10:33 +0000 (17:10 +0200)
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
scripts/exp/pcap.pcap
scripts/exp/pcap_with_vm.pcap
scripts/exp/syn_attack.pcap
scripts/exp/udp_1pkt_range_clients_split_garp.pcap

index a3430c7..6a2e268 100644 (file)
@@ -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):
index c41fa0c..5aa544a 100644 (file)
@@ -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:
index 34a2e9b..b13275e 100644 (file)
Binary files a/scripts/exp/pcap.pcap and b/scripts/exp/pcap.pcap differ
index a278dd8..a7a2d2b 100644 (file)
Binary files a/scripts/exp/pcap_with_vm.pcap and b/scripts/exp/pcap_with_vm.pcap differ
index aa420d2..84da36a 100644 (file)
Binary files a/scripts/exp/syn_attack.pcap and b/scripts/exp/syn_attack.pcap differ
index dde0c6d..627bcd5 100644 (file)
Binary files a/scripts/exp/udp_1pkt_range_clients_split_garp.pcap and b/scripts/exp/udp_1pkt_range_clients_split_garp.pcap differ