Class UDPFormat

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public common::PacketLayout

Derived Types

Class Documentation

class UDPFormat : public common::PacketLayout

Abstract base class for UDPFormats of the CBF/PSR data format.

Subclassed by ska::pst::recv::LowPST, ska::pst::recv::LowTestVector, ska::pst::recv::MidPST

Public Types

enum PacketState

Enumeration of the different types of received packet state Ok Packet received in good order Malformed Packet header is invalid and does not conform to the ICD definition Misdirected Packet header is valid but belongs to a different beam or sub-band Misordered Packet sequence number is wildly out of order. Ignored Packet is valid but preceeds the start_psn, so it is simply ignored whilst waiting for the start of the stream.

Values:

enumerator Ok
enumerator Malformed
enumerator Misdirected
enumerator Misordered
enumerator Ignored
typedef struct ska::pst::recv::UDPFormat::data_and_weights data_and_weights_t

Convenience structure for data and weights used for offsets and sizes.

Public Functions

UDPFormat()

Construct a new UDPFormat object.

~UDPFormat() = default

Destroy the UDPFormat object.

void validate_configure_beam(const ska::pst::common::AsciiHeader &beam_config, ska::pst::common::ValidationContext *context)
void validate_configure_scan(const ska::pst::common::AsciiHeader &scan_config, ska::pst::common::ValidationContext *context)
virtual void configure_beam(const ska::pst::common::AsciiHeader &beam_config)

Configure the UDPFormat from the fixed configuration.

Parameters

beam_config

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

Prepare the UDPFormat once the complete header has been provided. Includes the fixed and dynamic configuration parameters.

Parameters

scan_config – complete set of meta-data for the observation

void conclude()

Conclude the format. Releases any allocated resources, resets internal state.

void reset()

Reset the Format. Set the prepared state to false.

uint64_t get_samples_for_bytes(uint64_t nbytes)

Return the number of samples that correspond to the specified number of bytes.

Parameters

nbytes – Number of bytes to use in calculation

Returns

uint64_t Number of samples that match the specified bytes

uint64_t get_resolution()

Return the resolution of the UDPFormat which corresponds to the minimum block size.

Returns

uint64_t data mininmumresolution in bytes

uint64_t get_weights_resolution()

Return the minimum resolution of the weights in UDPFormat. Corresponds to the minimum block size for the weights.

Returns

uint64_t weights minimum resolution in bytes

void encode_header(char *buf)

Encode the contents of the.

Parameters

buf

PacketState process_stream_start(char *buffer)

check whether the data stream has started by virtue of the first packet being received

Parameters

buffer – pointer to buffer container received UDP packet payload

Returns

PacketState return value indicating status: OK, IGNORE or MALFORMED

inline ska::pst::common::Time get_start_timestamp()

Get the start timestamp for the packet stream.

Returns

ska::pst::common::Time timestamp of the start of the packet stream

virtual PacketState decode_packet(char *buffer, data_and_weights_t *offsets, data_and_weights_t *received)

Decode the received UDP packet and determine it’s location within the data stream.

Parameters
  • buffer – pointer to buffer containing received UDP packet payload

  • offsets – offsets of the data and weights in their repsective data streams

  • received – size of the data and weights portions of the payload

Returns

PacketState status of the received packet (e.g. OK, IGNORE, MALFORMED)

virtual void insert_last_packet(char *data, char *weights)

copy the most recently received packet data to the provided buffer

Parameters

buffer – pointer to buffer

void clear_scales_buffer(char *buffer, uint64_t bufsz)

Reset all of the scales values in the weights buffer to NAN.

Parameters
  • buffer – pointer to the weights buffer

  • bufsz – size of the weights buffer in bytes

void print_packet_header()

print the description of the UDP packet header

inline unsigned get_os_numerator() const

Get the oversampling numerator of the UDP format.

Returns

unsigned numerator of the oversampling ratio

inline unsigned get_os_denominator() const

Get the os denominator of the UDP format.

Returns

unsigned denominator of the oversampling ratio

inline unsigned get_destination() const

Get the CBF/PSR destination for the UDP format.

Returns

unsigned value of the CBF/PSR destination field

inline bool get_increment_psn_every_packet() const

Get the increment psn every packet value.

Returns

true UDP format expects PSN to increment every packet

Returns

false UDP format does not expect PSN to increment every packet

ska::pst::common::AsciiHeader &get_weights_scan_config()

return the scan configuration for the weights as a string

void set_scan_id(uint64_t scan_id)

set the expected scan id for the packet stream

inline bool is_misdirected()

return true if the packet is valid, but not meant to be received by this format

Protected Functions

virtual unsigned get_expected_nbit() = 0

Get the expected NBIT value for UDPFormat.

Returns

the expected NBIT value for the format.

virtual std::pair<unsigned, unsigned> get_expected_os_factor() = 0

Get the expected OS_FACTOR for the UDPFormat.

Returns

a pair of unsigned values. The first is the numerator and the second is the denominator.

inline void check_beam_configured(bool expected)

Check that the beam_configured attribute matches the expected value.

Throws

std::runtime_error – if the beam_configured attribute does not match the expected value

Parameters

expected – expected value of the beam_configured attribute

inline void check_scan_configured(bool expected)

Check that the scan_configured attribute matches the expected value.

Throws

std::runtime_error – if the scan_configured attribute does not match the expected value

Parameters

expected – expected value of the scan_configured attribute

inline void check_scan_started(bool expected)

Check that the scan_started attribute matches the expected value.

Throws

std::runtime_error – if the scan_started attribute does not match the expected value

Parameters

expected – expected value of the scan_started attribute

Protected Attributes

cbf_psr_packet_t packet = {nullptr, nullptr, nullptr}

struct of pointers to the header, weights and data of the current UDP packet.

unsigned beam_id = {0}

the beam number or beam identifier

uint64_t scan_id = {0}

the scan identifier

unsigned nant = {0}

number of antennae

unsigned nbeam = {0}

number of beams

unsigned ndim = {0}

number of dimensions

unsigned npol = {0}

number of polarisations

unsigned nbit = {0}

number of bits per dimension

unsigned os_numerator = {0}

oversampling numerator

unsigned os_denominator = {0}

oversampling denominator

unsigned start_channel = {0}

first channel

unsigned end_channel = {0}

last channel

unsigned nchan = {0}

number of channels

double tsamp = {0}

the sampling interval in microseconds

double bw = {0}

the bandwidth in MHz

double freq = {0}

the centre frequency in MHz

uint64_t bytes_per_second = {0}

the data rate in bytes per second

bool beam_configured = {false}

flag for format configuration, fixed time parameters received

bool scan_configured = {false}

flag for format preparation, fixed and runtime parameters received

bool scan_started = {false}

flag for the starting of the scan, specifically once a packet has been received and the start_psn attribute is set

unsigned data_channel_stride = {0}

Number of bytes per channel in UDPFormat data.

unsigned data_psn_stride = {0}

Number of bytes that span the data time samples associated with all packets of the sample Packet Sequence Number (PSN)

unsigned weights_channel_stride = {0}

Number of bytes per channel in UDPFormat weights.

unsigned weights_psn_stride = {0}

Number of bytes that span the weights time samples associated with all packets of the sample Packet Sequence Number (PSN)

uint32_t destination = {5}
int64_t start_psn = {-1}

The Packet Sequence Number (PSN) that is associated with the the start of data.

ska::pst::common::Time start_timestamp

The timestamp that corresponds to the start_psn.

ska::pst::common::AsciiHeader weights_beam_config

beam configuration for the weights stream of this format

ska::pst::common::AsciiHeader weights_scan_config

scan configuration for the weights stream of this format

uint64_t attoseconds_per_packet = {0}

number of attoseconds per packet

bool increment_psn_every_packet = {false}

increment the PSN on every single packet, only true in LowTestVector

struct data_and_weights

Convenience structure for data and weights used for offsets and sizes.

Public Members

int64_t data
int64_t weights