class

Packetz::Capture

Inherits Reference / Object

The Capture class is responsible for all of the supported capturing operations provided by LibPcap in a clean, friendly API.

Simply start a new capture object called cap, with all the defaults:

cap = Packetz::Capture.new

If you want to start customizing the capture object during initialization, you have a few ways to do that to change the interface, snapshot_length, promiscuous_mode and timeout_ms values of a capture.

Listen specifically on the en0 network interface:

cap = Packetz::Capture.new("en0")

Listen with alll the default options, but in promiscuous mode:

cap = Packetz::Capture.new(promiscuous_mode = true)

Change the default snapshot length from 65535 to half that size.

cap = Packetz::Capture.new(snapshot_length: 65535/2)

Constructors

new(interface : String = Packetz.interfaces.default, snapshot_length : Int32 = 65535, promiscuous_mode : Bool | Int32 = 0, timeout_ms : Int32 = 1, monitor_mode : Bool = false)

The #initialize method takes care of setting up a new Capture object.

Source

Instance methods

each
Source
enable_monitor_mode!
Source
immediate_mode!
Source
immediate_mode=(value : Int32)
Source
immediate_mode=(value : Bool)
Source
immediate_mode?
Source
interface

Provides access to underlying interface string.

Source
interface=(interface : String)

Set the network interface to a given string.

Source
microsecond_timestamp_precision!
Source
microsecond_timestamp_precision?
Source
monitor_mode
Source
monitor_mode=(value : Bool)
Source
monitor_mode?
Source
nanosecond_timestamp_precision!
Source
nanosecond_timestamp_precision?
Source
next
Source
non_blocking_mode!
Source
non_blocking_mode=(value : Int32)
Source
non_blocking_mode=(value : Bool)
Source
non_blocking_mode?
Source
promiscuous_mode
Source
promiscuous_mode!
Source
promiscuous_mode=(value : Bool)
Source
promiscuous_mode=(value : Int32)
Source
promiscuous_mode?
Source
reset!
Source
snapshot_length
Source
snapshot_length=(value : Int32)
Source
start!

Handles activating the actual packet capturing.

Source
started?
Source
stop!
Source
stopped?
Source
supports_monitor_mode?
Source
timeout_ms
Source
timeout_ms=(value : Int32)
Source
timestamp_precision
Source