UDP Sender

class gpype.backend.sinks.udp_sender.UDPSender[source]

Bases: Sink

UDP sender for real-time data transmission.

Transmits data as float64 numpy arrays via UDP packets to a configurable target address, optionally re-framed through a buffer.

DEFAULT_IP = '127.0.0.1'

Default target IP address (localhost)

DEFAULT_PORT = 56000

Default target UDP port number

class Configuration[source]

Bases: Configuration

Configuration class for UDPSender parameters.

class Keys[source]

Bases: Keys

Configuration keys for UDP sender settings.

IP = 'ip'

IP address configuration key

PORT = 'port'

Port number configuration key

class OptionalKeys[source]

Bases: OptionalKeys

Optional configuration keys.

The sender may forward data at its incoming frame size, so the output frame size must not be declared as required.

FRAME_SIZE_OUT = 'frame_size_out'

Output frame size configuration key

__init__(ip=None, port=None, frame_size_out=None, edge_id=None, **kwargs)[source]

Initialize UDP sender with target address and port.

Parameters:
  • ip (Optional[str]) – Target IP address. Defaults to localhost if None.

  • port (Optional[int]) – Target port number. Defaults to DEFAULT_PORT if None.

  • frame_size_out (Optional[int]) – Output frame size. If None, data is sent with its original frame size. If specified, data is buffered and sent when frame_size_out samples are accumulated.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional arguments for parent INode.

start()[source]

Start UDP sender and initialize socket connection.

Creates UDP socket and configures target address from configuration.

Raises:

OSError – If socket creation fails.

stop()[source]

Stop UDP sender and clean up socket resources.

setup(data, port_context_in)[source]

Setup method for pipeline initialization.

Initializes the output buffer if frame_size_out is configured.

Parameters:
  • data (dict[str, ndarray]) – Input data arrays from connected ports.

  • port_context_in (dict[str, dict]) – Context information from input ports.

Return type:

dict[str, dict]

Returns:

Empty dictionary (sink node has no output context).

step(data)[source]

Process and transmit data via UDP.

If frame_size_out is configured, accumulates data in buffer and sends when the output frame size is reached. Otherwise, sends immediately.

Parameters:

data (dict[str, ndarray]) – Input data arrays. Uses default input port. Expected shape: (frame_size_in, channels)

Return type:

dict[str, ndarray]

Returns:

Empty dictionary (sink node has no output).