PCAP Doesn't Lie Part 4

It’s time for the final part of the Network Security Monitoring (NSM) series. This post will cover the last two areas where packet capture will be lost: during processing and while writing to disk.

During Process

Once you’re able to get packets from the network to the interface with minimal packet loss, the next problem is processing them fast enough so that packets aren't dropped while waiting to be processed. There are two ways to solve this problem: hardware and software.

The most obvious factor in reducing packet loss is hardware: more CPU threads and RAM generally improve performance. However, even the best hardware has limits—real gains come from software optimization.


The most effective software configuration for minimizing packet loss is PF_RING, a high-performance packet capture framework for Linux. PF_RING enhances how monitoring tools ingest and process network traffic via a custom kernel module and an optimized socket interface, thereby bypassing traditional packet-capture bottlenecks. This enables packets to move efficiently from the NIC into RAM with minimal CPU overhead, while larger amounts of RAM allow for bigger buffers and fewer dropped packets.

PF_RING also integrates seamlessly with libpcap, the standard packet capture library used by many network analysis tools. Because PF_RING provides a libpcap-compatible interface, applications that rely on libpcap can take advantage of PF_RING’s performance improvements with little to no modification. In this setup, libpcap serves as the abstraction layer for packet capture, while PF_RING accelerates the underlying packet acquisition. This means that virtually any tool built on libpcap can leverage PF_RING to achieve higher throughput and reduced packet loss without requiring significant changes to the application itself. Any networking monitoring software that uses libpcap, Zeek, Snort, or Suricta for example, can utilize PF_RING.



To optimize CPU usage, we will be using Zeek as our example. Zeek is an open-source network security monitoring framework that performs deep packet inspection and generates structured logs. Each Zeek process is single-threaded, so scalability comes from deploying multiple worker processes. Each worker is pinned to a CPU thread and processes a load-balanced subset of traffic—via AF_PACKET fanout or external load balancing—allowing Zeek to fully utilize available CPU threads. More threads mean more workers, faster packet analysis, and fewer dropped packets. 


Combining PF_RING, which efficiently leverages RAM, with Zeek, which utilizes CPU threads, creates a highly effective packet processing pipeline. Normally, packets are copied into kernel buffers before processing, which adds overhead and increases the risk of drops. With PF_RING’s zero-copy (ZC) mode, packets are placed directly into shared memory regions, reducing copies and optimizing RAM usage—especially in high-throughput environments (10–100 Gbps). PF_RING also supports clustering and load balancing, distributing packets across multiple queues or processes to scale horizontally across CPU threads. When paired with Zeek, PF_RING acts as the packet-acquisition layer, feeding traffic streams to multiple Zeek workers. Each worker is pinned to a CPU thread, enabling parallel analysis while maintaining flow consistency. This combination maximizes both RAM and CPU utilization, significantly reducing packet loss. In our example we used Zeek, however 



Writing to Disk

The final place where packets can be lost in a network security monitoring (NSM) system is during writes to the hard drive. Faster drives help reduce this risk. Ten to fifteen years ago, magnetic hard drives offered the most storage for the price, but their write speeds were significantly slower than modern solid-state drives (SSDs). At that time, NSM engineers had to balance the risk of dropping packets against the amount of data they wanted to retain. Today, with SSDs becoming more affordable and cloud-based object storage solutions like AWS S3 providing cost-effective long-term retention, this is less of a concern.

It’s also important to consider whether disks are configured in a redundant array of independent disks (RAID). Depending on the RAID level and media type, write speeds may increase or decrease. Below is a chart showing native and RAID write speeds for different storage media.

 

PF_RING further helps prevent packet loss during disk writes by decoupling packet capture from downstream processing and I/O operations. It uses high-performance, RAM-based ring buffers to temporarily store packets as they arrive from the NIC. This buffering allows short bursts of traffic or slower disk writes to be absorbed without dropping packets. Data is queued in memory and processed asynchronously, significantly reducing the likelihood of packet loss.

Summary

Following this series of posts will help reduce packet loss in your NSM solution. I hope you have found it helpful.
















Comments

Popular posts from this blog

Mapping CIS Critical Controls to Gartner Markets

Malware Can Hide But It Must Run

PCAP Doesn't Lie Part 2