katgpucbf.send module
Shared utilities for sending data over SPEAD.
- class katgpucbf.send.DescriptorSender(stream: spead2.send.asyncio.AsyncStream, descriptors: Heap, interval: float, first_interval: float | None = None, *, substreams: Iterable[int] = (0,))[source]
Bases:
objectManage sending descriptors at regular intervals.
The descriptors are first sent once immediately, then after first_interval seconds, then every interval seconds. Using a different first_interval makes it possible to stagger different senders so that their descriptors do not all arrive at a common receiver at the same time.
The descriptors are sent with zero rate, which means they will not affect the timing of other packets in the same stream.
- Parameters:
stream – The stream to which the descriptor will be sent. It will be sent to all substreams simultaneously.
descriptors – The descriptor heap to send.
interval – Interval (in seconds) between sending descriptors.
first_interval – Delay (in seconds) immediately after starting. If not specified, it defaults to interval.
substreams – Substream indices to which descriptors are sent. If not specified, send only to the first substream.
- katgpucbf.send.send_rate(packet_header: int, packet_payload: int, heap_payload: int, heap_interval: float, send_rate_factor: float) float[source]
Compute the send rate (in bytes per second) to pass to spead2.
- Parameters:
packet_header – Overhead bytes in each SPEAD packet, including the SPEAD header (but excluding UDP/IP etc headers)
packet_payload – Number of payload bytes that should be included in each packet
heap_payload – Number of payload bytes in each heap
heap_interval – Time (in seconds) between sending heaps (or 0 for as fast as possible)
send_rate_factor – Safety factor by which the transmission rate should exceed the incoming data rate