PacketCapture

The PacketCapture TANGO device can be used to remotely capture all traffic sent to it, and write the captured packets to a file.

Commands

PacketCapture.BeginCapture(capture_file_name: str) tuple[list[ResultCode], list[str]]

Begin a new packet capture session.

This will start a new background process that captures packets from the configured network interface to a capture file.

While a capture session is active, the capture_stats__* attributes will automatically update to reflect the current state of the capture.

This is a long-running command that returns as soon as the command is queued.

Parameters:

capture_file_name – Name of the file where captured packets will be written to.

Returns:

The ResultCode and message.

PacketCapture.EndCapture() tuple[list[ResultCode], list[str]]

End the active packet capture session.

This asynchronously terminates the background process and wait for it to exit.

After the capture is finished, the capture file is automatically moved from the capture_dir to the storage_dir before this command is considered finished.

This is a long-running command that returns as soon as the command is queued.

Returns:

The ResultCode and message.

Attributes

Read/Write Attributes

PacketCapture.bpf_filter

BPF filter applied by the kernel to filter which packets to capture.

PacketCapture.min_packet_size

Minimum size of the packets to capture. All incoming packets smaller than the minimum size will be ignored.

Read-Only Attributes

PacketCapture.ip_address

The IP address of the configured network interface.

PacketCapture.mac_address

The MAC address of the configured network interface.

PacketCapture.capture_active

Whether the device is currently capturing packets.

PacketCapture.capture_file

The name of the file where the packets are being captured to.

PacketCapture.capture_stats__file_size

The size of the capture file, in bytes.

PacketCapture.capture_stats__packets_received

The total number of packets received.

PacketCapture.capture_stats__packets_captured

The total number of packets captured.

PacketCapture.capture_stats__packets_dropped

The total number of packets dropped.

Properties

PacketCapture.interface: str

The name of the network interface to capture packets on.

This is a mandatory property.

PacketCapture.default_bpf_filter: str

Default value for the bpf_filter() attribute.

This is an optional property, and will default to "" if not set.

PacketCapture.default_min_packet_size: int

Default value for the min_packet_size() attribute.

This is an optional property, and will default to 0 if not set.

PacketCapture.capture_dir: str

Path to the directory where active captures are written to.

This is an optional property, and will default to /tmp if not set.

Note

Changing this property requires the device to re-initialise.

PacketCapture.storage_dir: str

Path to the directory where capture files are moved to after completion.

This is an optional property, and will default to /tmp if not set.

Note

Changing this property requires the device to re-initialise.