Module ouster.pcap

Copyright (c) 2021, Ouster, Inc. All rights reserved.

Pcap tools to record/read/write Ouster sensor data.

record(packets, pcap_path, *, src_ip='', dst_ip='', lidar_port=7502, imu_port=7503, use_sll_encapsulation=False)[source]

Record a sequence of sensor packets to a pcap file.

  • packets (Iterable[Union[ImuPacket, LidarPacket]]) – A (finite!) sequence of packets

  • pcap_path (str) – Path of the output pcap file

  • src_ip (str) – Source IP to use for all packets

  • dst_ip (str) – Destination IP to use for all packets

  • lidar_port (int) – Src/dst port to use for lidar packets

  • imu_port (int) – Src/dst port to use for imu packets

  • use_sll_encapsulation (bool) – Use sll encapsulation

Return type



Number of packets captured

class Pcap(pcap_path, info, *, rate=0.0, lidar_port=None, imu_port=None, loop=False, _soft_id_check=False)[source]

Read a sensor packet stream out of a pcap file as an iterator.

Read a single sensor data stream from a packet capture.

Packet captures can contain arbitrary network traffic or even multiple valid sensor data streams. To avoid passing invalid data to the user, this class assumes that lidar and/or imu packets are associated with distinct destination ports, which may be recorded in the sensor metadata or specified explicitly.

When not specified, ports are guessed by sampling some packets and looking for the expected packet size based on the sensor metadata. If packets that might be valid sensor data appear on multiple ports, one is chosen arbitrarily. See _guess_ports for details. on the heuristics.

Packets with the selected destination port that clearly don’t match the metadata (e.g. wrong size or init_id) will be silently ignored.

When a rate is specified, output packets in (a multiple of) real time using the pcap packet capture timestamps.

  • info (SensorInfo) – Sensor metadata

  • pcap_path (str) – File path of recorded pcap

  • rate (float) – Output packets in real time, if non-zero

  • lidar_port (Optional[int]) – Specify the destination port of lidar packets

  • imu_port (Optional[int]) – Specify the destination port of imu packets

  • loop (bool) – Specify whether to reload the PCAP file when the end is reached

  • _soft_id_check (bool) – if True, don’t skip lidar packets buffers on init_id/sn mismatch

property metadata: ouster.client._client.SensorInfo

Metadata associated with the packet stream.

Return type


property ports: Tuple[int, int]

Specified or inferred ports associated with lidar and imu data.

Values <= 0 indicate that no lidar or imu data will be read.

Return type

Tuple[int, int]


Restart playback from beginning. Thread-safe.

Return type


property closed: bool

Check if source is closed. Thread-safe.

Return type



Release resources. Thread-safe.

Return type