PcapPlusPlus  20.08+
pcpp::PcapLiveDevice::DeviceConfiguration Struct Reference

#include <PcapLiveDevice.h>

Public Member Functions

 DeviceConfiguration (DeviceMode mode=Promiscuous, int packetBufferTimeoutMs=0, int packetBufferSize=0, PcapDirection direction=PCPP_INOUT, int snapshotLength=0)

Public Attributes

DeviceMode mode
int packetBufferTimeoutMs
int packetBufferSize
PcapDirection direction
int snapshotLength

Detailed Description

A struct that contains user configurable parameters for opening a device. All parameters have default values so the user isn't expected to set all parameters or understand exactly how they work

Constructor & Destructor Documentation

◆ DeviceConfiguration()

pcpp::PcapLiveDevice::DeviceConfiguration::DeviceConfiguration ( DeviceMode  mode = Promiscuous,
int  packetBufferTimeoutMs = 0,
int  packetBufferSize = 0,
PcapDirection  direction = PCPP_INOUT,
int  snapshotLength = 0 

A c'tor for this struct

[in]modeThe mode to open the device: promiscuous or non-promiscuous. Default value is promiscuous
[in]packetBufferTimeoutMsBuffer timeout in millisecond. Default value is 0 which means set timeout of 1 or -1 (depends on the platform)
[in]packetBufferSizeThe packet buffer size. Default value is 0 which means use the default value (varies between different OS's)
[in]directionDirection for capturing packets. Default value is INOUT which means capture both incoming and outgoing packets (not all platforms support this)
[in]snapshotLengthSnapshot length for capturing packets. Default value is 0 which means use the default value. A snapshot length of 262144 should be big enough for maximum-size Linux loopback packets (65549) and some USB packets captured with USBPcap (> 131072, < 262144). A snapshot length of 65535 should be sufficient, on most if not all networks, to capture all the data available from the packet.

Member Data Documentation

◆ direction

PcapDirection pcpp::PcapLiveDevice::DeviceConfiguration::direction

Set the direction for capturing packets. You can read more here: https://www.tcpdump.org/manpages/pcap.3pcap.html#lbAI.

◆ mode

DeviceMode pcpp::PcapLiveDevice::DeviceConfiguration::mode

Indicates whether to open the device in promiscuous or normal mode

◆ packetBufferSize

int pcpp::PcapLiveDevice::DeviceConfiguration::packetBufferSize

Set the packet buffer size. You can read more about the packet buffer here: https://www.tcpdump.org/manpages/pcap.3pcap.html . Any value of 100 or above is considered valid, otherwise the default value is used (which varies between different OS's). However, please notice that setting values which are too low or two high may result in failure to open the device. These too low or too high thresholds may vary between OS's, as an example please refer to this thread: https://stackoverflow.com/questions/11397367/issue-in-pcap-set-buffer-size

◆ packetBufferTimeoutMs

int pcpp::PcapLiveDevice::DeviceConfiguration::packetBufferTimeoutMs

Set the packet buffer timeout in milliseconds. You can read more here: https://www.tcpdump.org/manpages/pcap.3pcap.html . Any value above 0 is considered legal, otherwise a value of 1 or -1 is used (depends on the platform)

◆ snapshotLength

int pcpp::PcapLiveDevice::DeviceConfiguration::snapshotLength

Set the snapshot length. Snapshot length is the amount of data for each frame that is actually captured. Note that taking larger snapshots both increases the amount of time it takes to process packets and, effectively, decreases the amount of packet buffering. This may cause packets to be lost. Note also that taking smaller snapshots will discard data from protocols above the transport layer, which loses information that may be important. You can read more here: https://wiki.wireshark.org/SnapLen