Top Related Projects
A Swiss army knife for your daily Linux network plumbing.
Stenographer is a packet capture solution which aims to quickly spool all packets to disk, then provide simple, fast access to subsets of those packets. Discussion/announcements at stenographer@googlegroups.com
Scapy: the Python-based interactive packet manipulation program & library.
Read-only mirror of Wireshark's Git repository at https://gitlab.com/wireshark/wireshark. ⚠️ GitHub won't let us disable pull requests. ⚠️ THEY WILL BE IGNORED HERE ⚠️ Upload them at GitLab instead.
Data Plane Development Kit
the TCPdump network dissector
Quick Overview
PF_RING is a high-speed packet capture, filtering, and analysis library for Linux systems. It's designed to improve the performance of packet capture and processing applications, offering both kernel-level and user-space implementations for maximum flexibility and efficiency.
Pros
- High-performance packet capture and processing capabilities
- Supports both kernel and user-space implementations
- Offers zero-copy operations for improved efficiency
- Provides APIs for easy integration with existing applications
Cons
- Limited to Linux systems
- Requires kernel modifications for full functionality
- May have a steeper learning curve compared to simpler packet capture libraries
- Documentation can be sparse or outdated in some areas
Code Examples
- Initializing PF_RING and opening a device:
#include <pfring.h>
pfring *ring;
char *device = "eth0";
ring = pfring_open(device, 1518, PF_RING_PROMISC);
if (ring == NULL) {
fprintf(stderr, "pfring_open error\n");
return -1;
}
- Capturing packets in a loop:
struct pfring_pkthdr hdr;
u_char *buffer;
while (1) {
if (pfring_recv(ring, &buffer, 0, &hdr, 0) > 0) {
// Process the packet
printf("Received packet of %d bytes\n", hdr.len);
}
}
- Filtering packets using PF_RING:
char *bpf_filter = "tcp and port 80";
if (pfring_set_bpf_filter(ring, bpf_filter) != 0) {
fprintf(stderr, "pfring_set_bpf_filter error\n");
return -1;
}
Getting Started
To get started with PF_RING:
-
Install PF_RING from the official repository:
git clone https://github.com/ntop/PF_RING.git cd PF_RING/kernel make sudo make install
-
Load the PF_RING kernel module:
sudo insmod ./pf_ring.ko
-
Compile your application with PF_RING support:
gcc -o my_app my_app.c -lpfring -lpcap
-
Run your application with root privileges:
sudo ./my_app
Remember to check the PF_RING documentation for more detailed instructions and advanced usage scenarios.
Competitor Comparisons
A Swiss army knife for your daily Linux network plumbing.
Pros of netsniff-ng
- Lightweight and efficient packet capture and analysis tool
- Supports zero-copy packet capture for high-performance networking
- Includes a suite of networking utilities beyond packet capture
Cons of netsniff-ng
- Less extensive documentation compared to PF_RING
- Smaller community and fewer third-party integrations
- Limited support for advanced packet processing features
Code Comparison
netsniff-ng:
static int receive_packet(struct ring *ring, struct frame_map *hdr,
void **pkt, int *truncated)
{
*pkt = ((uint8_t *) hdr) + hdr->tp_h.tp_mac;
*truncated = (hdr->tp_h.tp_snaplen < hdr->tp_h.tp_len);
return hdr->tp_h.tp_snaplen;
}
PF_RING:
int pfring_recv(pfring *ring, u_char** buffer, u_int buffer_len,
struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet)
{
if(ring == NULL)
return -1;
return(ring->recv(ring, buffer, buffer_len, hdr, wait_for_incoming_packet));
}
Both code snippets demonstrate packet receiving functionality, but PF_RING's API appears more abstracted and user-friendly, while netsniff-ng's implementation is more low-level and performance-oriented.
Stenographer is a packet capture solution which aims to quickly spool all packets to disk, then provide simple, fast access to subsets of those packets. Discussion/announcements at stenographer@googlegroups.com
Pros of Stenographer
- Designed specifically for packet capture and indexing, optimized for fast retrieval
- Supports efficient querying of captured packets based on various criteria
- Provides a simple command-line interface for easy interaction
Cons of Stenographer
- Limited to packet capture and indexing, lacks advanced packet processing features
- May require more storage space due to its focus on full packet capture
Code Comparison
Stenographer (Go):
func (s *Stenographer) WritePacket(packet *pcap.Packet) error {
// Write packet to disk and update index
}
PF_RING (C):
int pfring_send(pfring *ring, const u_char *pkt, u_int pkt_len, u_int8_t flush_packet) {
// Send packet using PF_RING
}
Key Differences
- PF_RING is a general-purpose packet processing framework, while Stenographer focuses on packet capture and indexing
- PF_RING offers lower-level access to network packets and supports various packet processing tasks
- Stenographer provides better querying capabilities for captured packets
- PF_RING is written in C, while Stenographer is written in Go
Use Cases
- PF_RING: Network monitoring, traffic analysis, and packet manipulation
- Stenographer: Forensic analysis, security investigations, and network troubleshooting requiring historical packet data
Scapy: the Python-based interactive packet manipulation program & library.
Pros of Scapy
- High-level packet manipulation library with intuitive Python interface
- Versatile for packet crafting, sniffing, and network scanning
- Extensive protocol support and easy extensibility
Cons of Scapy
- Slower performance compared to low-level libraries like PF_RING
- Limited scalability for high-speed packet processing
- Requires more system resources for complex operations
Code Comparison
Scapy (Python):
from scapy.all import *
packet = IP(dst="8.8.8.8")/TCP(dport=80)
send(packet)
PF_RING (C):
#include <pfring.h>
pfring *ring = pfring_open("eth0", 1500, PF_RING_PROMISC);
pfring_enable_ring(ring);
pfring_recv(ring, &buffer, sizeof(buffer), &hdr, 0);
Key Differences
- Scapy offers a higher-level abstraction, while PF_RING provides low-level packet access
- PF_RING focuses on high-speed packet processing, whereas Scapy prioritizes ease of use
- Scapy is more suitable for rapid prototyping and analysis, while PF_RING excels in production environments requiring maximum performance
Read-only mirror of Wireshark's Git repository at https://gitlab.com/wireshark/wireshark. ⚠️ GitHub won't let us disable pull requests. ⚠️ THEY WILL BE IGNORED HERE ⚠️ Upload them at GitLab instead.
Pros of Wireshark
- User-friendly GUI for packet analysis and network troubleshooting
- Extensive protocol support and decoding capabilities
- Cross-platform compatibility (Windows, macOS, Linux)
Cons of Wireshark
- Higher resource consumption for real-time packet capture
- Limited performance for high-speed network monitoring
- Less suitable for embedded systems or low-resource environments
Code Comparison
Wireshark (C):
void
proto_register_http(void)
{
static hf_register_info hf[] = {
{ &hf_http_request_method, { "Request Method", "http.request.method", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_http_request_uri, { "Request URI", "http.request.uri", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
}
PF_RING (C):
int pfring_set_direction(pfring *ring, packet_direction direction) {
if(ring == NULL)
return(-1);
return(ring->set_direction(ring, direction));
}
The code snippets show that Wireshark focuses on protocol dissection and analysis, while PF_RING emphasizes low-level packet capture and manipulation.
Data Plane Development Kit
Pros of DPDK
- Higher performance and lower latency for packet processing
- More extensive hardware support, especially for modern NICs
- Larger community and ecosystem with frequent updates
Cons of DPDK
- Steeper learning curve and more complex implementation
- Requires dedicated CPU cores, potentially increasing power consumption
- Less suitable for general-purpose networking tasks
Code Comparison
PF_RING example:
#include <pfring.h>
pfring *ring = pfring_open("eth0", 1500, PF_RING_PROMISC);
pfring_enable_ring(ring);
pfring_recv(ring, &buffer, sizeof(buffer), &hdr, 0);
DPDK example:
#include <rte_eal.h>
#include <rte_ethdev.h>
rte_eal_init(argc, argv);
rte_eth_rx_burst(port_id, 0, &rx_bufs[0], MAX_PKT_BURST);
rte_pktmbuf_free(rx_bufs[i]);
Both PF_RING and DPDK are powerful packet processing frameworks, but they cater to different use cases. PF_RING is more user-friendly and suitable for general networking tasks, while DPDK offers superior performance for specialized high-speed packet processing applications at the cost of increased complexity and resource usage.
the TCPdump network dissector
Pros of tcpdump
- Widely used and well-established network packet analyzer
- Lightweight and easy to install on various systems
- Extensive documentation and community support
Cons of tcpdump
- Limited packet processing capabilities compared to PF_RING
- May struggle with high-speed network traffic analysis
- Lacks advanced features like zero-copy packet capture
Code Comparison
tcpdump:
while (packets_captured < max_packets && !interrupted) {
struct pcap_pkthdr header;
const u_char *packet = pcap_next(handle, &header);
if (packet == NULL) {
continue;
}
process_packet(packet, &header);
}
PF_RING:
while (1) {
if ((rc = pfring_recv(pd, &buffer_p, 0, &hdr, 0)) > 0) {
if (rc == 1) {
process_packet(buffer_p, &hdr);
}
} else {
if (rc == PF_RING_ERROR_RING_EMPTY) {
usleep(1);
}
}
}
PF_RING offers more advanced packet capture and processing capabilities, making it suitable for high-speed network analysis. tcpdump, on the other hand, is simpler to use and more widely supported, making it a good choice for basic network troubleshooting and analysis tasks.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PF_RINGâ¢
Introduction
PF_RING⢠is a Linux kernel module and user-space framework that allows you to process packets at high-rates while providing you a consistent API for packet processing applications.
Who needs PF_RING�
Basically everyone who has to handle many packets per second. The term âmanyâ changes according to the hardware you use for traffic analysis. It can range from 80k pkt/sec on a 1,2GHz ARM to more than 20M pkt/sec per core on a low-end 2,5GHz Xeon. PF_RING⢠not only enables you to capture packets faster, it also captures packets more efficiently preserving CPU cycles.
Documentation
If you want to learn more about PF_RING⢠please visit the User's Guide and the API Documentation.
Details
For more information about PF_RING⢠and other ntop technologies, please visit http://ntop.org
License
PF_RING⢠kernel module and drivers are distributed under the GNU GPLv2 license, LGPLv2.1 for the user-space PF_RING library, and are available in source code format.
Top Related Projects
A Swiss army knife for your daily Linux network plumbing.
Stenographer is a packet capture solution which aims to quickly spool all packets to disk, then provide simple, fast access to subsets of those packets. Discussion/announcements at stenographer@googlegroups.com
Scapy: the Python-based interactive packet manipulation program & library.
Read-only mirror of Wireshark's Git repository at https://gitlab.com/wireshark/wireshark. ⚠️ GitHub won't let us disable pull requests. ⚠️ THEY WILL BE IGNORED HERE ⚠️ Upload them at GitLab instead.
Data Plane Development Kit
the TCPdump network dissector
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot