Class UDPGenerator

Class Documentation

class UDPGenerator

Generates a stream of UDP packets according to the UDPFormat. The UDP packet stream is generated with zero’d data, but the metadata from the specified UDPFormat is used.

Public Functions

UDPGenerator() = default

Construct a new UDPGenerator object.

UDPGenerator(std::string host, int port)

Construct a new UDPGenerator object.

Parameters
  • host – IPv4 address for destination packets

  • port – UDP port number for destination packets

~UDPGenerator()

Destroy the UDPGenerator object.

void add_induced_error(uint32_t packet_number, ska::pst::recv::FailureType failure_type)

Induce an error into the generated UDP packet stream.

Parameters
  • packet_number – packet at which to induce the error

  • failure_type – type of failure to induce

void add_induced_error_rate(ska::pst::recv::FailureType failure_type, double rate)

Induce a packet validity error at random with an average rate of packet loss.

Parameters
  • failure_type – type of failure to induce

  • rate – the fractional number of packets that should have validity flag set.

void add_validity_error(uint32_t packet_number, ska::pst::recv::ValidityType validity_type)

Induce a CBF validity flag into the generated UDP packet stream.

Parameters
  • packet_number – packet at which to induce the error

  • validity_type – type of validity failure to induce

void add_validity_error_rate(ska::pst::recv::ValidityType validity_type, double rate)

Induce a CBF validity flag at random with an average rate of packet loss.

Parameters
  • validity_type – type of validity flag to induce

  • rate – the fractional number of packets that should have validity flag set.

void configure_beam(const ska::pst::common::AsciiHeader &beam_config)

Process fixed configuration and perform resource allocation. Configures the generator using the fixed configuration parameters that are common to all observations and available at launch. Configures the UDPFormat and UDPStats instances. Opens the UDP socket to transmit UDP packets.

Parameters

beam_config – fixed configuration parameters

void configure_scan(const ska::pst::common::AsciiHeader &scan_config)

Processes the runtime configuration parameters in the header. Prepares the format with the runtime configuration parameters.

Parameters

scan_config – dynamic configuration parameters

void transmit(float tobs, float data_rate, bool second_boundary = true)

Transmit the UDP data stream, returning once all data have been sent. Will terminate early if keep_transmitting is set to false.

Parameters
  • tobs – duration of the data transmission in seconds.

  • data_rate – data rate for the data transmission in bytes per second

  • second_boundary – wait for the next second boundary before starting transmitting, default is true

inline void stop_transmit()

Stop transmitting data immediately.

void start_monitor_thread()

Start the monitoring thread that reports data transmission statistics.

void stop_monitor_thread()

Stop the monitoring thread that reports data transmission statistics.

void monitor_method()

Monitor the data transmission performance.

void set_start_packet_sequence_number(uint64_t psn)

Set the starting packet sequence number.

Parameters

psn – packet sequence number of the first packet generated

void set_beam_id(uint64_t beam_id)

set the expected beam id for the packet stream

void set_scan_id(uint64_t scan_id)

set the expected scan id for the packet stream

inline double get_bytes_per_second() const

Get the bytes per second computed from the scan configuration.

Returns

double-precision bytes per second in the output data stream

UDPStats &get_stats()

Return a reference to the UDP statistics management object.

Returns

UDPStats& UDP statistics management object

inline const std::map<std::string, std::string> &get_log_context() const

return mapped diagnostic context key/value pairs

Protected Attributes

uint64_t beam_id = {0}

Expected beam id for the packet stream.

uint64_t scan_id = {0}

Expected scan id for the packet stream.

std::shared_ptr<UDPFormat> format = {nullptr}

UDP format provides the mapping from UDP metadata to memory addresses.

UDPHeader udp_header

UDP Header provides the encoding of UDP packets.

std::shared_ptr<common::PacketGenerator> data_generator = {nullptr}

Optional PacketGenerator sets the data and weights of each UDP packet.

UDPSocketSend sock

UDP sending socket.

UDPStats stats

statistics of UDP transmission performance

std::string data_host

destination IPv4 address for the data stream

int data_port = {0}

destination UDP port for the data stream

std::string local_host

!local IPv4 address for the interface which will transmit the data stream

double bytes_per_second = {0}

number of bytes per second in the data stream