Additional 4 Bytes from FCS/CRC

560 views
Skip to first unread message

aparn...@gmail.com

unread,
Jun 27, 2016, 6:28:30 PM6/27/16
to TRex Traffic Generator
Hi,

I'm feeding a Wireshark PCAP file as in the following script to my DUT :

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, direction = 0, ipg_usec = 10.0, loop_count = 1, **kwargs):

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__), '256pkts.pcap'))


I have obtained this pcap file (256pkts.pcap) as a captured output from IXIA IxExplorer after doing a loopback. This packet capture already contains 4 Bytes of CRC / FCS. Now, the issue I'm facing is that, TRex also adds 4 Bytes of CRC, thus only 4 Bytes are stripped by the NIC and the 4 Bytes of CRC added already in IXIA is considered as part of the packet data, which results in my application on the DUT dropping the packets. Is there any way by which I can disable adding the extra 4 bytes of CRC from TRex? Or is there a way to remove the CRC from the pcap file on Wireshark? I tried googling for a way to remove it from Wireshark but no luck so far.

Thanks and Regards,
Aparna

hanoh haim

unread,
Jun 28, 2016, 6:48:01 AM6/28/16
to Aparna Suri, TRex Traffic Generator
Hi 
Scapy template packets and pcap file are expected to be without CRC.

Follow the  STLPktBuilder remove_fcs=True example 


    def set_pcap_file (self, pcap_file):
        """
        Load raw pcap file into a buffer. Loads only the first packet.

        :parameters:
            pcap_file : file_name

        :raises:
            + :exc:`AssertionError`, if packet is empty.

        """
        f_path = self._get_pcap_file_path (pcap_file)

        p=RawPcapReader(f_path)
        was_set = False

        for pkt in p:
            was_set=True;
            self.pkt_raw = pkt[0]  <<== remove 4 bytes in case remove_fcs is True
            break



Hanoh



--
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+u...@googlegroups.com.
To post to this group, send email to trex...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trex-tgn/8bf552c4-bddd-4aac-ae19-6a83c5c5fb63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Hanoh
Sent from my iPhone

Aparna Suri

unread,
Jun 28, 2016, 12:03:16 PM6/28/16
to hanoh haim, TRex Traffic Generator
Thanks for the reply. I see that in the initialization constructor of the STLPktBuilder class, remove_fcs is set to True by default. So, when the load_pcap file calls the STLPktBuilder class constructor, remove_fcs should already be true right? I tried setting it manually to true and it had no impact on my application. It still has 4 Bytes of CRC in the PCAP plus the 4 Bytes added by TRex.

Thanks and Regards,
Aparna

hanoh haim

unread,
Jun 28, 2016, 12:33:00 PM6/28/16
to Aparna Suri, TRex Traffic Generator
Yes, it does not have an effect in case of pcap
But I've sent the line in the code that you can fix this 

Hanoh

Itay Marom

unread,
Jun 28, 2016, 1:13:27 PM6/28/16
to hanoh haim, TRex Traffic Generator, Aparna Suri

Hi,

editcap or tshark can remove crc from the pcap.

Itay

Aparna Suri

unread,
Jun 28, 2016, 1:24:13 PM6/28/16
to Itay Marom, hanoh haim, TRex Traffic Generator
Thanks for the replies. I tried the editcap method already a while back and it worked. I was curious to find a way to get it done within the TRex library. Anyway, thanks Hanoh and Itay for the help.

Regards,
Aparna
Reply all
Reply to author
Forward
0 new messages