Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter a PCAP file from packet ISO/OSI layer
    primarykey
    data
    text
    <p>I need to split a PCAP file in two different files: the first one should include all (and only) the packets directed to the application layer of the ISO/OSI model, while the second one includes all the other ones.</p> <p>I'm using Scapy to apply the filter:</p> <pre><code>pkts = PcapReader(infile) applayerpkts = (pkt for pkt in pkts if pkt.haslayer(Raw)) lowlayerspkts = (pkt for pkt in pkts if not pkt.haslayer(Raw)) wrpcap(applayerfilename, applayerpkts) wrpcap(lowlayersfilename, lowlayerspkts) </code></pre> <p>using <code>pkt.haslayer(Raw)</code> method, since that layer should be included only on packets directed to the application layer.</p> <p>What's the problem? I've noticed that the sum of <code>applayerfilename</code> + <code>lowlayersfilename</code> (in file size) is different (lower) from the file size of <code>infile</code>.</p> <p>The reported method is also computationally expensive (and I've got a list of PCAP of ~1.5GB each one), since <code>infile</code> is parsed twice.</p> <p>I'd prefer to apply a different filter, parsing one time the input PCAP. I could use the <code>PcapReader</code> class and manually parsing the PCAP, but I don't know how to generate a PCAP to pass to the <code>wrpcap(...)</code> method.</p> <p>Edit: I've also tried with this solution:</p> <pre><code>pkts = PcapReader(infile) app_pkts = [] low_pkts = [] for p in pkts: if p.haslayer(Raw): app_pkts.append(p) else: low_pkts.append(p) wrpcap(applayerfilename, app_pkts) wrpcap(lowlayersfilename, low_pkts) </code></pre> <p>but it doesn't work, since it consumes too much memory because of the size of my input PCAP...</p> <p>Does an <code>append_to_pcap(filename, packet)</code> like function exists (<code>wrpcap(...)</code> function doesn't work as an append)?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload