Module ouster.sdk.pcap
Copyright (c) 2021, Ouster, Inc. All rights reserved.
Pcap tools to record/read/write Ouster sensor data.
- record(packets, pcap_path, *, src_ip='127.0.0.1', dst_ip='127.0.0.1', lidar_port=7502, imu_port=7503, use_sll_encapsulation=False)[source]
Record a sequence of sensor packets to a pcap file.
- Parameters:
packets (
Iterable
[Packet
]) – A (finite!) sequence of packetspcap_path (
str
) – Path of the output pcap filesrc_ip (
str
) – Source IP to use for all packetsdst_ip (
str
) – Destination IP to use for all packetslidar_port (
int
) – Src/dst port to use for lidar packetsimu_port (
int
) – Src/dst port to use for imu packetsuse_sll_encapsulation (
bool
) – Use sll encapsulation
- Return type:
int
- Returns:
Number of packets captured
- class Pcap(pcap_path, info, *, rate=0.0, loop=False, soft_id_check=False)[source]
Deprecated: 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.
- Parameters:
info (
SensorInfo
) – Sensor metadatapcap_path (
str
) – File path of recorded pcaprate (
float
) – Output packets in real time, if non-zerolidar_port – Specify the destination port of lidar packets
imu_port – Specify the destination port of imu packets
loop (
bool
) – Specify whether to reload the PCAP file when the end is reachedsoft_id_check (
bool
) – if True, don’t skip lidar packets buffers on init_id/sn mismatch
- property metadata: SensorInfo
Metadata associated with the packet stream.
- property ports: Tuple[int, int]
Specified or inferred ports associated with lidar and imu data.
Values of 0 indicate that no data of that type will be read.
- property closed: bool
Check if source is closed. Thread-safe.