C++

template<class T>
class fftw::allocator
#include <FFTW.hh>

Allocator for FFTW-aligned memory.

Template Parameters
  • T: type of objects to allocate.

Public Types

using pointer = T*
using const_pointer = const T*
using void_pointer = void*
using const_void_pointer = const void*
using value_type = T
using size_type = size_t
using difference_type = ptrdiff_t

Public Functions

allocator() noexcept
allocator(const allocator &rhs) noexcept
template<class U>
allocator(const allocator<U> &rhs) noexcept
~allocator()
pointer allocate(size_type n, const_void_pointer hint = 0)
void deallocate(pointer p, size_type n)
size_type max_size() const noexcept
template<class U, class ...Args>
void construct(U *p, Args&&... args)
template<class U>
void destroy(U *p)
struct AutoGain
#include <AutoGain.hh>

PHY TX parameters.

Public Functions

AutoGain()
AutoGain(const AutoGain &other)
AutoGain(AutoGain &&other)
AutoGain &operator=(const AutoGain &other)
AutoGain &operator=(AutoGain &&other)
float getAutoSoftTXGainClipFrac(void) const

Get the fraction of unclipped IQ values. Defaults to 0.999.

void setAutoSoftTXGainClipFrac(float frac)

Set the fraction of unclipped IQ values. Defaults to 0.999.

This sets the fraction of values guaranteed to be unclipped when the 0dBFS soft TX gain is automatically determined. For example, a value of 0.99 ensures that 99% of the values will fall below 1, i.e., the 99th percentile is unclipped.

float getSoftTXGain(void) const

Get soft TX gain (multiplicative factor).

void setSoftTXGain(float g)

Set soft TX gain (multiplicative factor).

Parameters
  • g: The soft gain (multiplicative factor).

float getSoftTXGain0dBFS(void) const

Get soft TX gain (dB).

void setSoftTXGain0dBFS(float dB)

Set soft TX gain (dBFS).

Parameters
  • dB: The soft gain (dBFS).

void recalc0dBFSEstimate(unsigned nsamples)

Recalculate the 0dBFS estimate.

Parameters
  • nsamples: The number of samples used to estimate 0dBFS

bool needCalcAutoSoftGain0dBFS(void) const

Do we need to calculate auto-gain?

void autoSoftGain0dBFS(float g, std::shared_ptr<IQBuf> buf)

Calculate soft TX gain necessary for 0 dBFS.

Parameters
  • g: Gain applied to buf.

  • buf: The IQ buffer for which we are calculating soft gain.

Private Members

std::atomic<float> g_0dBFS_

Multiplicative TX gain necessary for 0dBFS.

std::atomic<float> auto_soft_tx_gain_clip_frac_

Fraction of unclipped IQ values. Defaults to 0.999.

std::shared_mutex mutex_

Mutex protecting private members.

unsigned nestimates_0dBFS_

Number of samples to take to estimate g_0dBFS.

Mean<float> g_0dBFS_estimate_

Estimate of multiplicative TX gain necessary for 0dBFS.

class barrier

Public Functions

barrier(unsigned count)
barrier() = delete
~barrier() = default
void wait(void)

Private Members

const unsigned count_

Number of threads in barrier syncrhonization group.

std::atomic<unsigned> arrived_

Number of threads that have arrived at the barrier.

std::atomic<unsigned> generation_

Current barrier generation.

class Liquid::BaseNCO : public NCO

Subclassed by Liquid::NCO, Liquid::VCO

Public Functions

BaseNCO(liquid_ncotype type, double dtheta)
BaseNCO(BaseNCO &&nco)
BaseNCO() = delete
BaseNCO(const BaseNCO&) = delete
~BaseNCO()
BaseNCO &operator=(BaseNCO &&nco)
BaseNCO &operator=(const BaseNCO&) = delete
void reset (double dtheta) overridefinal

Reset NCO state with given frequency in radians per sample.

double getFrequency (void) overridefinal

Get frequency in radians per sample.

void setFrequency (double dtheta) overridefinal

Set frequency in radians per sample.

double getPhase (void) overridefinal

Get phase in radians.

void setPhase (double theta) overridefinal

Set phase in radians.

std::complex< float > mix_up (const std::complex< float > in) overridefinal

Mix a single sample up.

std::complex< float > mix_down (const std::complex< float > in) overridefinal

Mix a single sample down.

void mix_up (const std::complex< float > *in, std::complex< float > *out, size_t count) overridefinal

Mix a signal up.

void mix_down (const std::complex< float > *in, std::complex< float > *out, size_t count) overridefinal

Mix a signal down.

Private Members

nco_crcf nco_
template<class D, class P, class T>
class BasePort
#include <Element.hh>

Base class representing a port attached to an Element.

Subclassed by Port< D, P, T >

Public Functions

BasePort(Element &element, std::function<void(void)> connected, std::function<void(void)> disconnected)
~BasePort() = default
Element &element(void)

Return this Port’s Element.

BasePort<typename D::Flip, P, T> *partner(void)

Return this Port’s partner Port.

bool isConnected(void)

Return true if the Port is connected.

Protected Functions

void connected(void)

Safely indicate that the port was connected.

void disconnected(void)

Safely indicate that the port was disconnected.

Protected Attributes

Element &element_

The Element to which this Port is attached.

BasePort<typename D::Flip, P, T> *partner_

This Port’s partner Port.

std::function<void(void)> connected_

Called when the port is connected.

std::function<void(void)> disconnected_

Called when the port is disconnected.

Friends

friend class Port< typename D::Flip, P, T >
friend class BasePort< typename D::Flip, P, T >
class BlockSignal
#include <Util.hh>

Atomically block a signal.

Public Functions

BlockSignal(int sig)

Save current signal mask and block a signal.

Parameters
  • sig: The signal to block

BlockSignal() = delete
~BlockSignal()

Restore original signal mask.

void unblockAndPause(void)

Atomically unblock signal and pause until we receive a signal.

Protected Attributes

sigset_t orig_mask_

Original signal mask before we blocked a signal.

template<typename T>
class buffer

Public Types

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = value_type&
using const_reference = const value_type&
using pointer = value_type*
using const_pointer = const value_type*
using iterator = value_type*
using const_iterator = const value_type*

Public Functions

buffer()
buffer(size_type count)
buffer(const T *data, size_type count)
buffer(const buffer &other)
buffer(buffer &&other) noexcept
~buffer()
buffer &operator=(const buffer &other)
buffer &operator=(buffer &&other) noexcept
reference at(size_type pos)
const_reference at(size_type pos) const
reference operator[](size_type pos)
const_reference operator[](size_type pos) const
reference front(void)
const_reference front(void) const
reference back(void)
const_reference back(void) const
value_type *data() noexcept
const value_type *data() const noexcept
iterator begin(void) noexcept
const_iterator begin(void) const noexcept
const_iterator cbegin(void) const noexcept
iterator end(void) noexcept
const_iterator end(void) const noexcept
const_iterator cend(void) const noexcept
bool empty(void) const noexcept
size_type size(void) const noexcept
size_type max_size(void) const noexcept
void reserve(size_type new_cap)
size_type capacity(void) const noexcept
void shrink_to_fit(void)
void clear(void) noexcept
void push_back(const T &value)
void push_back(T &&value)
template<class ...Args>
reference emplace_back(Args&&... args)
void pop_back(void)
void resize(size_type count)
void swap(buffer<T> &other)
void append(size_type count)

Private Members

T *data_
size_t size_
size_t capacity_
class BufferDecoder : public FLACMemoryDecoder

Public Functions

BufferDecoder(const char *encoded, size_t n)
~BufferDecoder() = default

Public Members

buffer<fc32_t> decoded_sig

Buffer for decoded signal.

Protected Functions

size_t size(void) override

Get size of buffer holding decoded data.

float *data(void) override

Get pointer to buffer holding decoded data.

void resize(size_t size) override

Resize buffer holding decoded data.

class BufferEncoder : public FLACMemoryEncoder

Public Functions

BufferEncoder()
~BufferEncoder() = default

Public Members

buffer<char> encoded_bytes

Buffer for encoded data.

Protected Functions

size_t size(void) override

Get size of buffer holding encoded.

char *data(void) override

Get pointer to buffer holding encoded.

void resize(size_t size) override

Resize buffer holding encoded data.

struct Channel

Public Functions

Channel()
Channel(double fc_, double bw_)
bool operator==(const Channel &other) const
bool operator!=(const Channel &other) const
bool operator<(const Channel &other) const
bool operator>(const Channel &other) const
bool intersects(const Channel &other) const

Public Members

double fc

Frequency shift from center.

double bw

Bandwidth.

class ChannelDemodulator
#include <Channelizer.hh>

Demodulate packets from a channel.

Public Types

using callback_type = PHY::PacketDemodulator::callback_type

Public Functions

ChannelDemodulator(PHY &phy, const Channel &channel, const std::vector<C> &taps, double rx_rate)
ChannelDemodulator() = delete
~ChannelDemodulator() = default
void setCallback(callback_type callback)

Set demodulation callback.

void reset(void) = 0

Reset internal state.

void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, float rx_rate) = 0

Set timestamp for demodulation.

Parameters
  • timestamp: The timestamp for future samples.

  • snapshot_off: The snapshot offset associated with the given timestamp.

  • offset: The offset of the first sample that will be demodulated. Can be negative!

  • rx_rate: RX rate (Hz)

void demodulate(const std::complex<float> *data, size_t count) = 0

Demodulate data with given parameters.

Protected Attributes

Channel channel_

Channel we are demodulating.

double rate_

Resampling rate.

double fshift_

Frequency shift.

std::shared_ptr<PHY::PacketDemodulator> demod_

Our demodulator.

class Channelizer : public Element
#include <Channelizer.hh>

Base class for channelizers.

Subclassed by FDChannelizer, OverlapTDChannelizer, TDChannelizer

Public Functions

Channelizer(std::shared_ptr<PHY> phy, double rx_rate, const Channels &channels)
~Channelizer() = default
double getRXRate(void)

Get the RX sample rate.

void setRXRate(double rate)

Set the RX sample rate.

Parameters
  • rate: The rate.

const Channels &getChannels(void) const

Get channels.

void setChannels(const Channels &channels)

Set channels.

void push(const std::shared_ptr<IQBuf> &buf) = 0

Add an IQ buffer to demodulate.

Parameters
  • buf: The IQ samples to demodulate

void reconfigure(void) = 0

Reconfigure for new RX parameters.

Public Members

RadioOut<Push> source

Demodulated packets.

Protected Attributes

std::shared_ptr<PHY> phy_

PHY we use for demodulation.

double rx_rate_

RX sample rate.

Channels channels_

Radio channels.

class ChannelModulator
#include <Synthesizer.hh>

Modulate packets for a channel.

This class is responsible for modulating packets and synthesizing a channel from the modulated packet.

Subclassed by FDChannelModulator, TDChannelModulator

Public Functions

ChannelModulator(PHY &phy, unsigned chanidx, const Channel &channel, const std::vector<C> &taps, double tx_rate)
ChannelModulator() = delete
~ChannelModulator() = default
void modulate(std::shared_ptr<NetPacket> pkt, float g, ModPacket &mpkt) = 0

Modulate a packet to produce IQ samples.

Parameters

Protected Attributes

const unsigned chanidx_

Index of channel we are modulating.

const Channel channel_

Channel we are modulating.

const double rate_

Resampling rate.

const double fshift_

Frequency shift.

std::shared_ptr<PHY::PacketModulator> mod_

Packet modulator.

class ChannelSynthesizer : public Synthesizer
#include <ChannelSynthesizer.hh>

A single-channel synthesizer.

Subclassed by ParallelChannelSynthesizer< ChannelModulator >

Public Types

using container_type = ModPacketQueue<>::container_type

Public Functions

ChannelSynthesizer(std::shared_ptr<PHY> phy, double tx_rate, const Channels &channels)
~ChannelSynthesizer() = default
std::optional<size_t> getHighWaterMark(void) const

Get high-water mark.

void setHighWaterMark(std::optional<size_t> mark)

Set high-water mark.

size_t try_pop(container_type &mpkts, size_t max_samples, bool overfill)

Pop modulated packets.

size_t try_pop(container_type &mpkts)

Pop all modulated packets.

size_t pop(container_type &mpkts)

Pop all modulated packets.

Protected Attributes

std::optional<size_t> chanidx_

Index of channel we should synthesize.

ModPacketQueue queue_

Queue.

class Clock : public MonoClock
#include <Clock.hh>

A wall-clock clock.

Public Types

using duration = std::chrono::seconds
using rep = duration::rep
using period = duration::period
using time_point = time_point_t<wall_tag>

Public Functions

MonoClock::time_point getTimeOffset(void)

Get time offset.

void setTimeOffset(const MonoClock::time_point &offset)

Set time offset.

double getSkew(void)

Get skew.

void setSkew(double skew)

set skew.

Public Static Functions

time_point now() noexcept

Get the current wall-clock time.

MonoClock::time_point to_mono_time(const time_point &t) noexcept

Return the monotonic time corresponding to wall-clock time.

time_point to_wall_time(const MonoClock::time_point &t) noexcept

Return the wall-clock time corresponding to monotonic time.

void setUSRP(uhd::usrp::multi_usrp::sptr usrp)

Set the USRP used for clock operations.

Parameters

void releaseUSRP(void)

Release the USRP used for clock operations.

Public Static Attributes

const bool is_steady = false

Private Static Attributes

uhd::time_spec_t offset_

The offset between the USRP’s clock and wall-clock time.

double skew_

Clock skew.

class CompressionBuffer : public buffer<unsigned char>

Public Functions

CompressionBuffer() = delete
CompressionBuffer(NetPacket &pkt_)
void copyBytesOut(size_t count)
template<class T>
void copyOut(const T &val)
void flush(void)

Public Members

NetPacket &pkt
CompressionFlags flags
size_t inoff
size_t outoff
struct CompressionFlags
#include <Packet.hh>

Packet compression flags.

Public Members

uint8_t type

Type of compression used.

uint8_t ipaddr_type

Type of IP address compression used.

uint8_t read_ttl

Read IP TTL field.

uint8_t unused

Unused flags.

class Controller : public Element
#include <Controller.hh>

A MAC controller.

Subclassed by DummyController, SmartController

Public Functions

Controller(std::shared_ptr<Net> net)
~Controller() = default
Controller() = delete
std::shared_ptr<NetQueue> getNetQueue(void)

Get the controller’s network queue.

void setNetQueue(std::shared_ptr<NetQueue> q)

Set the controller’s network queue.

void setMinChannelBandwidth(double min_bw)

Set minimum channel bandwidth.

bool pull(std::shared_ptr<NetPacket> &pkt) = 0

Pull a packet from the network to be sent next over the radio.

This function is automatically called when a packet is requested from the net_out port.

void kick(void)

Kick the controller.

void received(std::shared_ptr<RadioPacket> &&pkt) = 0

Process demodulated packets.

This function is automatically called to process packets received on on the radio_in port.

void disconnect(void)

Called when net_out is disconnected. By default, this disconnects net_in so that any pending pulls will terminate.

void missed(std::shared_ptr<NetPacket> &&pkt)

Notify controller that a packet missed its transmission slot.

This function is called by the MAC when a packet has missed its transmission slot.

void transmitted(std::list<std::unique_ptr<ModPacket>> &mpkts)

Notify controller of transmitted packets.

Public Members

NetIn<Pull> net_in

Input port for packets coming from the network.

NetOut<Pull> net_out

Output port for network packets processed by the controller.

RadioIn<Push> radio_in

Input port for demodulated packets coming from the radio.

RadioOut<Push> radio_out

Output port for demodulated packets processed by the controller.

Protected Attributes

std::shared_ptr<Net> net_

The Net we’re attached to.

std::shared_ptr<NetQueue> netq_

Network queue with high-priority sub-queue.

double min_channel_bandwidth_

Bandwidth of the smallest channel.

struct ControlMsg
#include <Packet.hh>

A Control message.

Public Types

enum Type

Values:

enumerator kHello
enumerator kTimestamp
enumerator kTimestampEcho
enumerator kReceiverStats
enumerator kNak
enumerator kSelectiveAck
enumerator kSetUnack
using Nak = Seq

Public Members

struct ControlMsg::TimestampEcho PACKED
uint8_t type
Hello hello
Timestamp timestamp
TimestampEcho timestamp_echo
ReceiverStats receiver_stats
Nak nak
SelectiveAck ack
SetUnack unack
union ControlMsg::[anonymous] [anonymous]
struct darpa_mgenhdr
#include <mgen.h>

A DARPA-variant MGEN packet header.

Public Members

uint16_t messageSize
uint8_t version
uint8_t flags
uint32_t mgenFlowId
uint32_t sequenceNumber
uint32_t reserved
mgen_secs_t txTimeSeconds
mgen_usecs_t txTimeMicroseconds
struct darpa_mgenrest

Public Members

int8_t tos
int32_t latitude
int32_t longitude
int32_t altitude
uint8_t gpsStatus
uint8_t reserved
uint16_t payloadLen
class DecompressionBuffer : public buffer<unsigned char>

Public Functions

DecompressionBuffer() = delete
DecompressionBuffer(RadioPacket &pkt_)
void copyBytesOut(size_t count)
template<class T>
void copyOut(const T &val)
template<class T>
T read(void)
void flush(void)

Public Members

RadioPacket &pkt
CompressionFlags flags
size_t inoff
size_t outoff
class Demodulator

Subclassed by Liquid::Demodulator

Public Types

using callback_t = std::function<bool(bool, bool, bool, const Header*, void*, size_t, void*)>

The type of demodulation callbacks.

Public Functions

Demodulator() = default
~Demodulator() = default
unsigned getOversampleRate(void)
bool isFrameOpen(void) = 0

Is a frame currently being demodulated?

Return

true if a frame is currently being demodulated, false otherwise.

void print(void) = 0

Print description of demodulator to stdout.

void reset(void) = 0

Reset demodulator state.

void demodulate(const std::complex<float> *in, const size_t n, callback_t cb) = 0

Demodulate IQ data.

Parameters
  • in: Pointer to IQ data to demodulate

  • n: Number of IQ samples to demodulate

  • cb: Demodulation callback

class Liquid::Demodulator : public Demodulator

Subclassed by Liquid::FlexFrameDemodulator, Liquid::NewFlexFrameDemodulator, Liquid::OFDMDemodulator, Liquid::PHY::PacketDemodulator

Public Functions

Demodulator(const MCS &header_mcs, bool soft_header, bool soft_payload)
Demodulator() = delete
~Demodulator() = default
const MCS &getHeaderMCS() const
void setHeaderMCS(const MCS &mcs)
bool getSoftHeader() const
void setSoftHeader(bool soft)
bool getSoftPayload() const
void setSoftPayload(bool soft)
void demodulate(const std::complex<float> *in, const size_t n, callback_t cb) override

Demodulate IQ data.

Parameters
  • in: Pointer to IQ data to demodulate

  • n: Number of IQ samples to demodulate

  • cb: Demodulation callback

Protected Functions

void demodulateSamples(const std::complex<float> *in, const size_t n) = 0

Demodulate samples.

int callback(unsigned char *header_, int header_valid_, int header_test_, unsigned char *payload_, unsigned int payload_len_, int payload_valid_, framesyncstats_s stats_)

Callback function for liquid demodulator.

void reconfigureHeader(void) = 0

Reconfigure demodulator based on new header parameters.

void reconfigureSoftDecode(void) = 0

Reconfigure demodulator based on new soft decoding parameters.

Protected Attributes

MCS header_mcs_

Header MCS.

bool soft_header_

Flag indicating whether or not to use soft decoding for header.

bool soft_payload_

Flag indicating whether or not to use soft decoding for payload.

callback_t cb_

Demodulation callback.

Protected Static Functions

int liquid_callback(unsigned char *header_, int header_valid_, int header_test_, unsigned char *payload_, unsigned int payload_len_, int payload_valid_, framesyncstats_s stats_, void *userdata_)

Callback function for liquid demodulator.

template<class T, class C>
class Dragon::Downsampler : public Dragon::Pfb<T, C>, public Resampler<T, T>
#include <Polyphase.hh>

A downsampler that uses a polyphase filter bank.

Public Functions

Downsampler(unsigned m, const std::vector<C> &taps)

Construct a downsampler.

Parameters
  • m: The downsampling rate

  • taps: The taps for the prototype FIR filter, which should have unity gain.

Downsampler() = delete
~Downsampler() = default
double getRate(void) const override
double getDelay(void) const override
size_t neededOut(size_t count) const override
void reset(void) override
size_t resample (const T *in, size_t count, T *out) overridefinal

Protected Functions

void reconfigure(void) override

Reconfigure filter bank for current number of channels and taps.

Protected Attributes

unsigned m_

Downsampling rate.

unsigned idx_

Input sample index.

class DummyController : public Controller
#include <DummyController.hh>

A Dummy MAC controller that just passes packets.

Public Functions

DummyController(std::shared_ptr<Net> net)
~DummyController() = default
bool pull(std::shared_ptr<NetPacket> &pkt) override

Pull a packet from the network to be sent next over the radio.

This function is automatically called when a packet is requested from the net_out port.

void received(std::shared_ptr<RadioPacket> &&pkt) override

Process demodulated packets.

This function is automatically called to process packets received on on the radio_in port.

Private Members

spinlock_mutex seqs_mutex_

Mutex for sequence numbers.

std::unordered_map<NodeId, Seq> seqs_

Receive windows.

class heap::element

Subclassed by TimerQueue::Timer

Public Functions

element()
bool in_heap() const
bool is_top() const

Public Members

size_type heap_index
class Element
#include <Element.hh>

A packet processing element.

Subclassed by Channelizer, Controller, FlowPerformance, PacketCompressor, Processor< T >, Processor< std::shared_ptr< NetPacket > >, Queue< T >, Synthesizer, TunTap

Public Functions

Element() = default
~Element() = default
template<class T>
class EMA : public Estimator<T>
#include <Estimator.hh>

Estimate a value by calculating an exponential moving average.

The EMA

estimator updates an exponetially weighted moving average with a weight alpha. Optionally, it can make an estimate using an average until mean_until samples have been collected. As a guideline, choosing alpha to be 2/(n+1) means the first n data points “will represent about 86% of the total

weight in the calculation EMA.”

See: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average

Public Functions

EMA(T alpha)

Create and EMA estimator.

Parameters
  • alpha: The weight used to update the EMA

EMA(T alpha, T initial_value, unsigned mean_until)

Create and EMA estimator.

Parameters
  • alpha: The weight used to update the EMA

  • initial_value: The initial value of the EMA

  • mean_until: The number of samples before which we estimate using a mean instead of an EMA

EMA() = delete
T getValue(void) const override

Return the value of the estimator.

unsigned getNSamples(void) const override

Return the number of samples used in the estimate.

void reset(T x) override

Reset the estimator with an initial value.

void update(T x) override

Update the estimator with a new value.

Private Members

T value_
unsigned nsamples_
unsigned mean_until_
T alpha_
struct SendWindow::Entry : public TimerQueue::Timer

Public Functions

Entry(SendWindow &sendw)
~Entry() = default
void operator=(std::shared_ptr<NetPacket> &p)
operator bool()
operator std::shared_ptr<NetPacket>()
void reset(void)
bool mayDrop(const std::optional<size_t> &max_retransmissions)

Return true if we MAY drop this window entry.

We MAY drop an entry if: 1) It is NOT a SYN packet, because in that case it is needed to initiate a connection. We always retransmit SYN packets.

bool shouldDrop(const std::optional<size_t> &max_retransmissions)

Return true if we SHOULD drop this window entry.

We SHOULD drop an entry if: 1) It is NOT a SYN packet, because in that case it is needed to initiate a connection. We always retransmit SYN packets. AND 2) It has exceeded the maximum number of allowed retransmissions. 3) OR it has passed its deadline.

void operator()() override

Public Members

SendWindow &sendw

The send window.

std::shared_ptr<NetPacket> pkt

The packet received in this window entry.

MonoClock::time_point timestamp

Timestamp of last transmission of this packet.

struct RecvWindow::Entry

Public Functions

Entry()
void operator=(std::shared_ptr<RadioPacket> &&p)
void alreadyDelivered(void)
void reset(void)

Public Members

bool received

Was this entry in the window received?

bool delivered

Was this entry in the window delivered?

std::shared_ptr<RadioPacket> pkt

The packet received in this window entry.

template<class T>
class Estimator
#include <Estimator.hh>

A statistical estimator.

Subclassed by EMA< T >, Mean< T >, TimeWindowEstimator< Clock, T >, WindowedMean< T >

Public Functions

~Estimator() = default
T getValue(void) const = 0

Return the value of the estimator.

unsigned getNSamples(void) const = 0

Return the number of samples used in the estimate.

void reset(T x) = 0

Reset the estimator with an initial value.

void update(T x) = 0

Update the estimator with a new value.

struct EventEntry

Generic event.

Public Members

double timestamp
const char *event
struct ExtendedHeader
#include <Header.hh>

Extended header that appears in radio payload.

Public Members

NodeId src

Source.

NodeId dest

Destination.

Seq ack

Sequence number we are ACK’ing or NAK’ing.

uint16_t data_len

Length of the packet payload.

The packet payload may be padded or contain control data. This field gives the size of the data portion of the payload.

class ExtensibleDataSet

Public Functions

ExtensibleDataSet(const H5::CommonFG &loc, const std::string &name, const H5::DataType &dt)
~ExtensibleDataSet()
void reserve(size_t size)
void write(const void *buf, size_t n)

Private Members

H5::DataSet ds_
H5::DataType dt_
size_t size_
size_t capacity_
class FDChannelizer::FDChannelDemodulator : public ChannelDemodulator

Channel state for time-domain demodulation.

Public Functions

FDChannelDemodulator(PHY &phy, const Channel &channel, const std::vector<C> &taps, double rate)
FDChannelDemodulator() = default
~FDChannelDemodulator() = default
void updateSeq(unsigned seq)

Update IQ buffer sequence number.

void reset(void) override
void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, float rx_rate) override
void demodulate(const std::complex<float> *data, size_t count) override

Protected Attributes

unsigned seq_

Channel IQ buffer sequence number.

unsigned X_

Oversample factor.

unsigned D_

Decimation factor.

int Nrot_

Number of FFT bins to rotate.

size_t delay_

Filter delay.

fftw::FFT<C> ifft_

IFFT.

fftw::vector<C> temp_

Vector containing rotated FFT input.

fftw::vector<C> H_

Frequency-domain filter.

class FDChannelizer : public Channelizer
#include <FDChannelizer.hh>

A frequency-domain channelizer.

Public Functions

FDChannelizer(std::shared_ptr<PHY> phy, double rx_rate, const Channels &channels, unsigned int nthreads)
~FDChannelizer()
void push(const std::shared_ptr<IQBuf>&) override

Add an IQ buffer to demodulate.

Parameters
  • buf: The IQ samples to demodulate

void reconfigure(void) override

Reconfigure for new RX parameters.

void stop(void)

Stop demodulating.

Public Static Attributes

constexpr unsigned P = 25 * 512 + 1

Filter length.

We need two factors of 5 because we need to support 25MHz bandwidth. The remaining factors of 2 get us to a filter of order 12800, which is about how many taps we need for a 50kHz passband transition in 80MHz of bandwidth.

constexpr unsigned V = 4

Overlap factor.

constexpr unsigned N = V * (P - 1)

Length of FFT.

constexpr unsigned O = P - 1

Size of FFT overlap.

constexpr unsigned L = N - (P - 1)

Number of new samples consumed per input block.

Private Functions

void fftWorker(void)

Worker that converts packets from time domain to frequency domain.

void demodWorker(unsigned tid)

A demodulation worker.

Private Members

unsigned nthreads_

Number of demodulation threads.

bool done_

Flag that is true when we should finish processing.

std::atomic<bool> reconfigure_

Flag that is true when we are reconfiguring.

barrier reconfigure_sync_

Reconfiguration barrier.

std::mutex wake_mutex_

Mutex for waking demodulators.

std::condition_variable wake_cond_

Condition variable for waking demodulators.

ringbuffer<std::shared_ptr<IQBuf>, LOGR> tdbufs_

Time-domain IQ buffers to demodulate.

spinlock_mutex demod_mutex_

Mutex for demodulation state.

std::vector<std::unique_ptr<FDChannelDemodulator>> demods_

Channel state for demodulation.

std::unique_ptr<ringbuffer<Slot, LOGR>[]> slots_

Frequency-domain packets to demodulate.

std::thread fft_thread_

FFT worker thread.

std::vector<std::thread> demod_threads_

Demodulation worker threads.

std::shared_ptr<Logger> logger_

A reference to the global logger.

Private Static Attributes

constexpr unsigned LOGR = 4

Log of size of ring buffers.

class FDChannelModulator : public ChannelModulator
#include <FDChannelModulator.hh>

Channel state for frequency-domain modulation.

Public Types

using C = std::complex<float>
using Upsampler = FDUpsampler<C, P, V>

Public Functions

FDChannelModulator(PHY &phy, unsigned chanidx, const Channel &channel, const std::vector<C> &taps, double tx_rate)
FDChannelModulator() = delete
~FDChannelModulator() = default
void modulate (std::shared_ptr< NetPacket > pkt, float g, ModPacket &mpkt) overridefinal

Modulate a packet to produce IQ samples.

Parameters

Public Static Attributes

constexpr unsigned P = 25 * 64 + 1

Filter length.

We need two factors of 5 because we need to support 25MHz bandwidth. The rest of the factors of 2 are for good measure.

constexpr unsigned V = 8

Overlap factor.

constexpr auto N = Upsampler::N

Protected Attributes

Upsampler upsampler_

Frequency domain upsampler.

Upsampler::ToTimeDomain timedomain_

OLS time domain converter.

class FDMA : public MAC
#include <FDMA.hh>

A FDMA MAC.

Public Functions

FDMA(std::shared_ptr<USRP> usrp, std::shared_ptr<PHY> phy, std::shared_ptr<Controller> controller, std::shared_ptr<SnapshotCollector> collector, std::shared_ptr<Channelizer> channelizer, std::shared_ptr<ChannelSynthesizer> synthesizer, double period)
~FDMA()
FDMA(const FDMA&) = delete
FDMA(FDMA&&) = delete
FDMA &operator=(const FDMA&) = delete
FDMA &operator=(FDMA&&) = delete
void stop(void) override

Stop processing packets.

void reconfigure(void) override

Reconfigure the MAC when after parameters change.

Private Functions

void txWorker(void)

Worker preparing slots for transmission.

Private Members

double premod_

Amount of data to pre-modulate (sec)

std::shared_ptr<ChannelSynthesizer> channel_synthesizer_

Out channel synthesizer.

std::thread rx_thread_

Thread running rxWorker.

std::thread tx_thread_

Thread running txWorker.

std::thread tx_notifier_thread_

Thread running txNotifier.

template<typename T, unsigned P, unsigned V>
class FDUpsampler

Public Functions

FDUpsampler(unsigned X_, unsigned I_, int Nrot_)
FDUpsampler() = delete
void reset(size_t npartial = 0)
void upsampleBlock(T *out)
size_t upsample(const T *in, size_t count, T *out, const float g, bool flush, size_t &nsamples, size_t max_nsamples, size_t &fdnsamples)
size_t npending(void)

Return number of pending output samples in buffer.

Public Members

const unsigned X

Oversample factor.

const unsigned I

Interpolation factor.

const int Nrot

Number of bins to rotate.

fftw::FFT<T> fft

FFT.

size_t fftoff

Offset into FFT input at which to place new data.

Public Static Attributes

constexpr unsigned N = V * (P - 1)

Length of FFT.

constexpr unsigned O = P - 1

Size of FFT overlap.

constexpr unsigned L = N - 2 * O

Number of new samples consumed per input block.

template<class T>
class fftw::FFT

Public Functions

FFT(unsigned N, int sign, unsigned flags)
~FFT()
unsigned getSize(void) const
void execute(void)
void execute(const T *in, T *out)
template<>
class fftw::FFT<std::complex<float>>

Public Types

using C = std::complex<float>

Public Functions

FFT(unsigned N, int sign, unsigned flags)
~FFT()
unsigned getSize(void) const
void execute(void)
void execute(const C *in, C *out)

Public Members

vector<C> in
vector<C> out

Protected Attributes

unsigned N_

Size of FFT.

fftwf_plan plan_

FFTW plan.

template<class I, class O>
class Filter

Subclassed by FIR< I, O, C >, IIR< I, O, C >

Public Functions

Filter() = default
~Filter() = default
float getGroupDelay(float fc) const = 0

Get filter group delay.

void reset(void) = 0

Reset filter state.

void execute(const I *in, O *out, size_t n) = 0

Execute the filter.

template<class I, class O, class C>
class FIR : public Filter<I, O>

Subclassed by Liquid::FIR< I, O, C >

Public Functions

FIR() = default
~FIR() = default
float getDelay(void) const = 0

Get filter delay.

const std::vector<C> &getTaps(void) const = 0

Get taps.

void setTaps(const std::vector<C> &taps) = 0

Set taps.

template<class T, class C>
class Dragon::FIR : public FIR<T, T, C>

Public Functions

FIR(const std::vector<C> &taps)
FIR() = delete
~FIR() = default
float getGroupDelay (float fc) const overridefinal

Get filter group delay.

void reset (void) overridefinal

Reset filter state.

void execute (const T *x, T *y, size_t n) overridefinal

Execute the filter.

float getDelay (void) const overridefinal

Get filter delay.

const std::vector< C > & getTaps (void) const overridefinal

Get taps.

void setTaps (const std::vector< C > &taps) overridefinal

Set taps.

Protected Functions

void in(T x)

Add a sample to the FIR window.

T out(void)

Compute FIR output using current window.

Protected Attributes

std::vector<C>::size_type n_

Window size/number of filter taps.

Window<T> w_

Sample window.

std::vector<C> taps_

Filter taps.

std::vector<C, XSIMD_DEFAULT_ALLOCATOR(C)> rtaps_

Filter taps, reversed.

float delay_

Delay.

template<class I, class O, class C>
class Liquid::FIR : public FIR<I, O, C>
#include <Filter.hh>

An FIR filter.

Public Functions

FIR() = delete
FIR(FIR &&f)
FIR(const std::vector<C> &h)
~FIR()
FIR &operator=(const std::vector<C> &h)
FIR &operator=(FIR &&f)
FIR &operator=(const FIR&) = delete
float getGroupDelay (float fc) const overridefinal

Get filter group delay.

void reset (void) overridefinal

Reset filter state.

void execute (const I *in, O *out, size_t n) overridefinal

Execute the filter.

float getDelay (void) const overridefinal

Get filter delay.

const std::vector< C > & getTaps (void) const overridefinal

Get taps.

void setTaps (const std::vector< C > &taps) overridefinal

Set taps.

C getScale() const

Get output scaling for filter.

Return

Scaling factor applied to each output sample

void setScale(C scale)

Set output scaling for filter.

Parameters
  • scale: Scaling factor applied to each output sample

void print(void) const

Print filter object information to stdout.

template<>
class Liquid::FIR<C, C, C> : public FIR<C, C, C>

Public Functions

FIR() = delete
FIR(FIR &&f)
FIR(const std::vector<C> &taps)
~FIR()
FIR &operator=(const std::vector<C> &taps)
FIR &operator=(FIR &&f)
FIR &operator=(const FIR&) = delete
float getGroupDelay (float fc) const overridefinal

Get filter group delay.

void reset (void) overridefinal

Reset filter state.

void execute (const C *in, C *out, size_t n) overridefinal

Execute the filter.

float getDelay (void) const overridefinal

Get filter delay.

const std::vector< C > & getTaps (void) const overridefinal

Get taps.

void setTaps (const std::vector< C > &taps) overridefinal

Set taps.

C getScale() const
void setScale(C scale)
void print(void) const

Protected Attributes

std::vector<C> taps_

Filter taps.

firfilt_cccf q_

Liquid filter object.

float delay_

Filter delay.

template<class T, class Set = std::unordered_set<uint16_t>>
class Firewall : public Processor<T>
#include <Firewall.hh>

A flow processor.

Public Functions

Firewall()
~Firewall() = default
bool getEnabled(void)

Get enabled flagd.

void setEnabled(bool enabled)

Set enabled flag.

bool getAllowBroadcasts(void)

Get flag indicating whether or not bradcast packets are allowed.

void setAllowBroadcasts(bool allowed)

Set flag indicating whether or not bradcast packets are allowed.

Set getAllowedPorts(void)

Get allowed ports.

void setAllowedPorts(const Set &allowed)

Set allowed ports.

Protected Functions

bool process(T &pkt) override

Filter a packet.

Protected Attributes

spinlock_mutex mutex_

Mutex for ports.

bool enabled_

Is the fireweall enabled?

bool allow_broadcasts_

Should we allow broadcast packets?

Set allowed_

allowed ports

class FLACException : public exception

Public Functions

FLACException(const char *msg)
~FLACException() = default
const char *what() const

Protected Attributes

const char *msg_

The FLAC error message.

class FLACMemoryDecoder : public Stream

Subclassed by BufferDecoder, PyArrayDecoder

Public Functions

FLACMemoryDecoder(const char *encoded, size_t n)
~FLACMemoryDecoder() = default
void decode(void)

Protected Functions

size_t size(void) = 0

Get size of buffer holding decoded data.

float *data(void) = 0

Get pointer to buffer holding decoded data.

void resize(size_t size) = 0

Resize buffer holding decoded data.

FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override
FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) override
FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) override
FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) override
bool eof_callback() override
FLAC__StreamDecoderWriteStatus write_callback(const FLAC__Frame *frame, const FLAC__int32 *const buffer[]) override
void metadata_callback(const FLAC__StreamMetadata *metadata) override
void error_callback(FLAC__StreamDecoderErrorStatus status) override

Protected Attributes

const char *encoded_

Buffer holding encoded data.

size_t encoded_size_

Size of encoded data.

size_t encoded_off_

Offset into buffer holding encoded data.

size_t off_

Offset into buffer holding decoded data.

class FLACMemoryEncoder : public Stream

Subclassed by BufferEncoder, PyArrayEncoder

Public Functions

FLACMemoryEncoder()
~FLACMemoryEncoder() = default
void encode(unsigned compression_level, const fc32_t *sig, size_t n)

Protected Functions

size_t size(void) = 0

Get size of buffer holding encoded.

char *data(void) = 0

Get pointer to buffer holding encoded.

void resize(size_t size) = 0

Resize buffer holding encoded data.

FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override
FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame) override
FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) override
FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) override
void metadata_callback(const FLAC__StreamMetadata *metadata) override

Protected Attributes

size_t off_

Offset into buffer at which to write data.

struct Header::Flags
#include <Header.hh>

Packet flags.

Public Members

uint8_t syn

Set if the packet is the first in a new connection.

uint8_t ack

Set if the packet is ACKing.

uint8_t has_data

Set if the packet has data.

uint8_t has_control

Set if the packet has control data.

uint8_t compressed

Set if the packet is compressed.

uint8_t unused

Unused flags.

class Liquid::FlexFrame : public Liquid::PHY
#include <FlexFrame.hh>

A PHY thats uses the liquid-usrp flexframegen code.

Public Functions

FlexFrame(const MCS &header_mcs, const std::vector<std::pair<MCS, AutoGain>> &mcs_table, bool soft_header, bool soft_payload)
~FlexFrame() = default
unsigned getMinRXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for demodulation.

Return

The minimum RX oversample rate

unsigned getMinTXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for modulation.

Return

The minimum TX oversample rate

Protected Functions

std::shared_ptr<::PHY::PacketDemodulator> mkPacketDemodulator(void) override

Create a Demodulator for this PHY.

std::shared_ptr<::PHY::PacketModulator> mkPacketModulator(void) override

Create a Modulator for this PHY.

std::unique_ptr<Liquid::Modulator> mkLiquidModulator(void) override

Create underlying liquid modulator object.

class Liquid::FlexFrameDemodulator : public virtual Liquid::Demodulator

Subclassed by Liquid::FlexFrame::PacketDemodulator

Public Functions

FlexFrameDemodulator(const MCS &header_mcs, bool soft_header, bool soft_payload)
~FlexFrameDemodulator()
FlexFrameDemodulator() = delete
FlexFrameDemodulator(const FlexFrameDemodulator&) = delete
FlexFrameDemodulator(FlexFrameDemodulator&&) = delete
FlexFrameDemodulator &operator==(const FlexFrameDemodulator&) = delete
FlexFrameDemodulator &operator!=(const FlexFrameDemodulator&) = delete
unsigned getOversampleRate(void) override
bool isFrameOpen(void) override

Is a frame currently being demodulated?

Return

true if a frame is currently being demodulated, false otherwise.

void print(void) override

Print description of demodulator to stdout.

void reset(void) override

Reset demodulator state.

void demodulateSamples(const std::complex<float> *buf, const size_t n) override

Demodulate samples.

Protected Functions

void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

void reconfigureSoftDecode(void) override

Reconfigure demodulator based on new soft decoding parameters.

Protected Attributes

origflexframesync fs_
class Liquid::FlexFrameModulator : public virtual Liquid::Modulator

Subclassed by Liquid::FlexFrame::PacketModulator

Public Functions

FlexFrameModulator(const MCS &header_mcs)
~FlexFrameModulator()
FlexFrameModulator() = delete
FlexFrameModulator(const FlexFrameModulator&) = delete
FlexFrameModulator(FlexFrameModulator&&) = delete
FlexFrameModulator &operator=(const FlexFrameModulator&) = delete
FlexFrameModulator &operator=(FlexFrameModulator&&) = delete
void print(void) override

Print description of modulator to stdout.

void assemble(const Header *header, const void *payload, const size_t payload_len) override

Assemble data for modulation.

Parameters
  • header: Pointer to header

  • payload: Pointer to payload

  • payload_len: Number of bytes in payload

unsigned getOversampleRate(void) override
size_t assembledSize(void) override

Return size of assembled data.

size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

bool modulateSamples(std::complex<float> *buf, size_t &nw) override

Modulate assembled packet.

Parameters
  • out: Pointer to output buffer for IQ data

  • n: Reference to variable that will hold number of samples produced

Public Static Attributes

constexpr size_t NGEN = 2

Protected Functions

void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

void reconfigurePayload(void) override

Reconfigure modulator based on new payload parameters.

Protected Attributes

origflexframegen fg_
class FlowPerformance : public Element
#include <FlowPerformance.hh>

A flow performance measurement element.

Public Functions

FlowPerformance(double mp)
FlowPerformance() = delete
~FlowPerformance() = default
double getMeasurementPeriod(void) const

Get measurement period.

std::optional<double> getStart(void) const

Get start time.

void setStart(std::optional<double> &start)

Set start time.

FlowStatsMap getSources(bool reset)

Return flow source statistics.

FlowStatsMap getSinks(bool reset)

Return flow sink statistics.

MandateMap getMandates(void)

Get mandates.

void setMandates(const MandateMap &mandates)

Set mandates.

Public Members

NetIn<Push> net_in

Network packet input port.

NetOut<Push> net_out

Network packet output port.

RadioIn<Push> radio_in

Radio packet input port.

RadioOut<Push> radio_out

Radio packet output port.

Protected Functions

void netPush(std::shared_ptr<NetPacket> &&pkt)

Handle a network packet.

void radioPush(std::shared_ptr<RadioPacket> &&pkt)

Handle a radio packet.

FlowStatsMap getFlowStatsMap(FlowStatsMap &stats, spinlock_mutex &mutex, bool reset)

Return a copy of a FlowStatsMap, resetting it if necessary.

FlowStats &findFlow(FlowStatsMap &stats, Packet &pkt)

Find a flow’s entry in statistics map.

Protected Attributes

double mp_

Measurement period.

std::optional<double> start_

Start time.

spinlock_mutex sources_mutex_

Mutex for sources.

FlowStatsMap sources_

Flow source info.

spinlock_mutex sinks_mutex_

Mutex for sinks.

FlowStatsMap sinks_

Flow sink info.

spinlock_mutex mandates_mutex_

Mandates mutex.

MandateMap mandates_

Mandates.

struct FlowStats
#include <FlowPerformance.hh>

Statistics for a single flow.

Public Functions

FlowStats(FlowUID flow_uid, NodeId src, NodeId dest)
FlowStats() = delete
void record(Packet &pkt, size_t mp)

Record statistics for a packet.

void setMandate(const Mandate &mandate)

Set a flow’s mandates.

Public Members

FlowUID flow_uid

Flow UID.

NodeId src

Flow source.

NodeId dest

Flow destination.

std::optional<double> mandated_latency

Flow mandated latency.

std::optional<size_t> low_mp

Lowest MP modified.

std::vector<MPStats> stats

Flow statistics for each measurement period.

class Gain

Public Functions

Gain(void)
~Gain() = default
Gain &operator=(const Gain &other)
float getLinearGain(void) const
void setLinearGain(float g)
float getDbGain(void) const
void setDbGain(float dB)

Protected Attributes

std::atomic<float> g_
struct Header
#include <Header.hh>

PHY packet header.

Public Members

NodeId curhop

Current hop.

NodeId nexthop

Next hop.

Seq seq

Packet sequence number.

struct Header::Flags flags
template<class T, class Container = std::vector<std::reference_wrapper<T>>, class Compare = std::less<T>>
class heap

Public Types

using container_type = Container
using value_compare = Compare
using size_type = typename Container::size_type
using reference = T&
using const_reference = const T&

Public Functions

heap()
~heap() = default
heap &operator=(const heap &other)
heap &operator=(heap &&other)
reference top()
bool empty() const
size_type size() const
void push(T &value)
void pop()
void remove(T &value)
void update(T &value)
void swap(heap &other)

Protected Functions

void make_heap()

Construct a heap from unordered elements.

void remove_heap(size_type index)

Remove element at the given index.

void update_heap(size_type index)

Move item at given index to proper heap position.

void up_heap(size_type index)

Move item at the given index up the heap to the proper index.

void down_heap(size_type index)

Move item at the given index down the heap to the proper index.

void swap_heap(size_type index1, size_type index2)

Swap the elements at the given heap indices.

Protected Attributes

Container c

Protected Static Functions

constexpr size_type parent(size_type i)
constexpr size_type left(size_type i)
constexpr size_type right(size_type i)
struct ControlMsg::Hello

Public Members

bool is_gateway
template<class I, class O, class C>
class IIR : public Filter<I, O>

Subclassed by Liquid::IIR< I, O, C >

Public Functions

IIR() = default
~IIR() = default
template<class I, class O, class C>
class Liquid::IIR : public IIR<I, O, C>
#include <Filter.hh>

An IIR filter.

Public Functions

IIR() = delete
IIR(IIR &&f)
IIR(const C *b, unsigned Nb, const C *a, unsigned Na)

Initialize filter with feedforward and feedback constants.

IIR(const C *sos, unsigned N)

Initialize filter with second-order-sections.

~IIR()
IIR &operator=(const IIR&) = delete
IIR &operator=(IIR&&) = delete
float getGroupDelay (float fc) const overridefinal

Get filter group delay.

void reset (void) overridefinal

Reset filter state.

void execute (const C *in, C *out, size_t n) overridefinal
void print(void) const

Print filter object information to stdout.

template<>
class Liquid::IIR<C, C, C> : public IIR<C, C, C>

Public Functions

IIR() = delete
IIR(IIR &&f)
IIR(const C *b, unsigned Nb, const C *a, unsigned Na)
IIR(const C *sos, unsigned N)
~IIR()
IIR &operator=(const IIR&) = delete
IIR &operator=(IIR&&) = delete
float getGroupDelay (float fc) const overridefinal

Get filter group delay.

void reset (void) overridefinal

Reset filter state.

void execute (const C *in, C *out, size_t n) overridefinal

Execute the filter.

void print(void) const

Print filter object information to stdout.

Protected Attributes

iirfilt_cccf q_
struct In
#include <Element.hh>

Type tag for input ports.

Public Types

using Flip = Out
struct Packet::InternalFlags
#include <Packet.hh>

Internal flags.

Public Members

uint8_t invalid_header

Set if the packet had invalid header.

uint8_t invalid_payload

Set if the packet had invalid payload.

uint8_t retransmission

Set if the packet is a retransmission.

uint8_t has_seq

Set if the packet has an assigned sequence number.

uint8_t has_selective_ack

Set if the packet contains a selective ACK.

uint8_t timestamp

Set if this packet should be timestamped.

struct IQBuf : public buffer<std::complex<float>>
#include <IQBuffer.hh>

A buffer of IQ samples.

Public Functions

IQBuf(size_t sz)
IQBuf(const IQBuf &other)
IQBuf(IQBuf &&other)
IQBuf(const buffer<std::complex<float>> &other)
IQBuf(buffer<std::complex<float>> &&other)
IQBuf(const std::complex<float> *data, size_t n)
~IQBuf() noexcept
IQBuf &operator=(const IQBuf&) = delete
IQBuf &operator=(IQBuf&&) = delete
void waitToStartFilling(void)

Wait for the buffer to start filling.

void zero(void)

Zero all data in the buffer.

void gain(const float g)

Apply a gain.

Parameters
  • g: The multiplicative gain.

void power(float &peak_power, float &avg_power)

Compute peak and average power.

Public Members

MonoClock::time_point timestamp

Timestamp of the first sample.

unsigned seq

Sequence number of current slot.

float fc

Sample center frequency.

float fs

Sample rate.

size_t delay

Signal delay.

std::atomic<size_t> nsamples

Number of samples received so far.

This value is valid untile the buffer is marked complete.

std::atomic<bool> complete

Flag that is true when receive is completed.

std::optional<ssize_t> snapshot_off

Offset from beginning of the current snapshot.

size_t undersample

Number of undersamples at the beginning of the buffer. That is, this is how many samples we missed relative to the requested RX start time at the beginning of the RX.

size_t oversample

Number oversamples at the end of buffer. That is, this is how many samples we missed relative to the requested RX end time at the end of the RX.

template<>
struct is_holder_type<T, std::shared_ptr<T>> : public true_type
class Packet::iterator : public std::iterator<std::input_iterator_tag, ControlMsg>

Public Functions

iterator(const Packet &pkt)
iterator(const Packet &pkt, int)
~iterator() = default
iterator() = delete
bool operator==(const iterator &other)
bool operator!=(const iterator &other)
iterator &operator++()
iterator &operator++(int)
const ControlMsg &operator*()
const ControlMsg *operator->()

Private Members

const Packet &pkt_
uint16_t ctrl_len_
const unsigned char *ctrl_ptr_
ControlMsg ctrl_
struct MAC::Load
#include <MAC.hh>

MAC load, measured as samples transmitted over time.

Public Functions

void reset(size_t nchannels)

Public Members

Clock::time_point start

Start of load measurement period.

Clock::time_point end

End of load measurement period.

std::vector<size_t> nsamples

Load per channel measured in number of samples.

class Logger

Public Types

enum Source

Values:

enumerator kSlots = 0
enumerator kRecvPackets = 1
enumerator kRecvSymbols = 2
enumerator kSentPackets = 3
enumerator kSentIQ = 4
enumerator kEvents = 5

Public Functions

Logger(Clock::time_point t_start)
~Logger()
Logger() = delete
Logger(const Logger&) = delete
Logger(Logger&&) = delete
Logger &operator=(const Logger&) = delete
Logger &operator=(Logger&&) = delete
void open(const std::string &filename)
void stop(void)
void close(void)
bool getCollectSource(Source src)
void setCollectSource(Source src, bool collect)
void setAttribute(const std::string &name, const std::string &val)
void setAttribute(const std::string &name, uint8_t val)
void setAttribute(const std::string &name, uint32_t val)
void setAttribute(const std::string &name, double val)
void logSlot(std::shared_ptr<IQBuf> buf, float bw)
void logSnapshot(std::shared_ptr<Snapshot> snapshot)
void logRecv(const Clock::time_point &t, int32_t start_samples, int32_t end_samples, bool header_valid, bool payload_valid, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, float evm, float rssi, float cfo, float fc, float bw, float demod_latency, uint32_t size, buffer<std::complex<float>> *buf)
void logSend(const Clock::time_point &t, unsigned nretrans, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, float fc, float bw, double mod_latency, uint32_t size, std::shared_ptr<IQBuf> buf, size_t offset, size_t nsamples)
void logLinkLayerDrop(const Clock::time_point &t, unsigned nretrans, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, uint32_t size)
void logQueueDrop(const Clock::time_point &t, unsigned nretrans, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, uint32_t size)
void logEvent(const Clock::time_point &t, const std::string &event)

Private Types

enum DropType

Values:

enumerator kNotDropped = 0
enumerator kLinkLayerDrop
enumerator kQueueDrop

Private Functions

void worker(void)

Log worker.

H5::Attribute createOrOpenAttribute(const std::string &name, const H5::DataType &data_type, const H5::DataSpace &data_space)
void logSlot_(std::shared_ptr<IQBuf> buf, float bw)
void logSnapshot_(std::shared_ptr<Snapshot> snapshot)
void logRecv_(const Clock::time_point &t, int32_t start_samples, int32_t end_samples, bool header_valid, bool payload_valid, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, float evm, float rssi, float cfo, float fc, float bw, float demod_latency, uint32_t size, buffer<std::complex<float>> *buf)
void logSend_(const Clock::time_point &t, DropType dropped, unsigned nretrans, const Header &hdr, const ExtendedHeader &ehdr, uint32_t mgen_flow_uid, uint32_t mgen_seqno, unsigned mcsidx, float fc, float bw, double mod_latency, uint32_t size, std::shared_ptr<IQBuf> buf, size_t offset, size_t nsamples)
void logEvent_(const Clock::time_point &t, const std::string &event)

Private Members

bool is_open_
H5::H5File file_
std::unique_ptr<ExtensibleDataSet> slots_
std::unique_ptr<ExtensibleDataSet> snapshots_
std::unique_ptr<ExtensibleDataSet> selftx_
std::unique_ptr<ExtensibleDataSet> recv_
std::unique_ptr<ExtensibleDataSet> send_
std::unique_ptr<ExtensibleDataSet> event_
Clock::time_point t_start_
MonoClock::time_point t_last_slot_
uint32_t sources_

Data sources we collect.

bool done_

Flag indicating we should terminate the logger.

SafeQueue<std::function<void(void)>> log_q_

Pending log entries.

std::thread worker_thread_

Log worker thread.

class MAC
#include <MAC.hh>

A MAC protocol.

Subclassed by FDMA, SlottedMAC

Public Functions

MAC(std::shared_ptr<USRP> usrp, std::shared_ptr<PHY> phy, std::shared_ptr<Controller> controller, std::shared_ptr<SnapshotCollector> collector, std::shared_ptr<Channelizer> channelizer, std::shared_ptr<Synthesizer> synthesizer, double rx_period)
~MAC() = default
MAC() = delete
MAC(const MAC&) = delete
MAC &operator=(const MAC&) = delete
MAC &operator=(MAC&&) = delete
const std::shared_ptr<Channelizer> &getChannelizer(void)

Get the MAC’s channelizer.

const std::shared_ptr<Synthesizer> &getSynthesizer(void)

Get the MAC’s synthesizer.

bool canTransmit(void) const

Can this MAC transmit.

Return

true if we can transmit, false otherwise

const Schedule &getSchedule(void) const

Get MAC schedule.

void setSchedule(const Schedule &schedule)

Set MAC schedule.

void setSchedule(const Schedule::sched_type &schedule)

Set MAC schedule.

void setMinChannelBandwidth(double min_bw)

Set minimum channel bandwidth.

Load getLoad(void)

Get current load.

Load popLoad(void)

Get current load and reset load counters.

void reconfigure(void)

Reconfigure the MAC when after parameters change.

void stop(void) = 0

Stop processing packets.

Protected Functions

void rxWorker(void)

Worker receiving packets.

void txNotifier(void)

Worker handling notification for transmitted slots.

Protected Attributes

std::shared_ptr<USRP> usrp_

Our USRP device.

std::shared_ptr<PHY> phy_

Our PHY.

std::shared_ptr<Controller> controller_

Our controller.

std::shared_ptr<SnapshotCollector> snapshot_collector_

Our snapshot collector.

std::shared_ptr<Channelizer> channelizer_

Our channelizer.

std::shared_ptr<Synthesizer> synthesizer_

Our synthesizer.

bool done_

Flag indicating if we should stop processing packets.

bool can_transmit_

Flag indicating whether or not we can transmit.

This is used, in particular, for the TDMA MAC, which may not have a slot

double rx_rate_

RX rate.

double tx_rate_

TX rate.

double rx_period_

Length of RX period (sec)

size_t rx_period_samps_

Number of RX samples in an RX period.

size_t rx_bufsize_

RX buffer size.

Schedule schedule_

The MAC schedule.

double min_chan_bw_

The minimum channel bandwidth (Hz)

std::optional<double> tx_fc_off_

TX center frequency offset from RX center frequency.

If the TX and RX rates are different, this is non-empty and contains the frequency of the channel we transmit on.

std::shared_ptr<Logger> logger_

A reference to the global logger.

spinlock_mutex load_mutex_

Mutex for load.

Load load_

Number of sent samples.

std::mutex tx_records_mutex_

Mutex for transmission records.

std::condition_variable tx_records_cond_

Condition variable protecting transmission records.

std::queue<TXRecord> tx_records_

Queue of transmission records.

struct Mandate

Public Functions

Mandate() = delete
Mandate(FlowUID flow_uid_, double hold_period_, int point_value_, std::optional<double> max_latency_s_, std::optional<double> min_throughput_bps_, std::optional<double> file_transfer_deadline_s_)
~Mandate() = default
bool isThroughput() const

Is this a throughput mandate?

bool isFileTransfer() const

Is this a file transfer mandate?

Public Members

FlowUID flow_uid

Flow UID.

double hold_period

Period over which to measure outcome metrics (sec)

int point_value

Point value.

std::optional<double> max_latency_s

Maximum latency allowed for a packet (sec)

std::optional<double> min_throughput_bps

Minimum throughput (bps)

std::optional<double> file_transfer_deadline_s

File transfer delivery deadline (sec)

unsigned achieved_duration

Achieved duration.

double scalar_performace

Scalar performance.

std::optional<double> mandated_latency

Flow mandated latency.

std::vector<NodeId> radio_ids

Nodes in flow.

template<class T>
class MandateQueue : public Queue<T>
#include <MandateQueue.hh>

A queue that obeys mandates.

Public Types

enum QueueType

Values:

enumerator FIFO = 0
enumerator LIFO
using Priority = std::pair<int, double>

Priority value.

A priority is a pair, with the first number representing the priority of the “category” to which a queue belongs, and the second number representing the relative priority within the given category of queues. The second number is meant to reflect the “value” of a flow.

using QueuePriorities = std::vector<std::tuple<std::optional<FlowUID>, Priority, std::optional<double>, std::optional<unsigned>, std::optional<unsigned>>>

Public Functions

MandateQueue()
~MandateQueue()
void setSendWindowStatus(NodeId id, bool isOpen) override

Set whether or not a node’s send window is open.

bool getBonusPhase(void) const

Get flag indicating whether or not to have a bonus phase.

void setBonusPhase(bool bonus_phase)

Set flag indicating whether or not to have a bonus phase.

QueueType getFlowQueueType(FlowUID flow_uid) const

Get flow queue type.

void setFlowQueueType(FlowUID flow_uid, QueueType qtype)

Set flow queue priority.

Priority getFlowQueuePriority(FlowUID flow_uid) const

Get flow queue priority.

void setFlowQueuePriority(FlowUID flow_uid, const Priority &priority)

Set flow queue priority.

MandateMap getMandates(void)

Get mandates.

void setMandates(const MandateMap &mandates)

Set mandates.

QueuePriorities getQueuePriorities(void)

Get queue priorities.

void reset(void) override

Reset queue to empty state.

void push(T &&pkt) override

Push an element onto the queue.

void push_hi(T &&pkt) override

Push an element onto the high-priority queue.

void repush(T &&pkt) override

Re-queue and element.

bool pop(T &pkt) override

Pop an element from the queue.

void kick(void) override

Kick the queue.

void stop(void) override

Stop processing queue elements.

void updateMCS(NodeId id, const MCS *mcs) override

Notify queue of new MCS.

void setTransmissionDelay(double t) override

Set transmission delay.

double getTransmissionDelay(void) const override

Get transmission delay.

Public Static Attributes

constexpr Priority kHiQueuePriority = Priority(100, 0.0)

Priority for high-priority queue.

constexpr Priority kDefaultFlowQueuePriority = Priority(1, 0.0)

Default priority for per-flow queue.

constexpr Priority kDefaultQueuePriority = Priority(0, 0.0)

Priority for default queue.

constexpr double kMaxTokenFactor = 2.0

Factor specifying maximum tokens in token bucket relative to throughput requirement.

constexpr double kTokenFactor = 1.1

Factor specifying tokens added to token bucket relative to throughput requirement.

Protected Types

using Queues = std::vector<std::reference_wrapper<SubQueue>>

Protected Functions

void add_queue(SubQueue &subq)

Add a new queue.

void sort_queues(void)
SubQueue &queue_for(const T &pkt)

Protected Attributes

bool done_

Flag indicating that processing of the queue should stop.

std::atomic<bool> kicked_

Is the queue being kicked?

double transmission_delay_

Packet transmission delay in seconds.

bool bonus_phase_

Flag indicating whether or not to have a bonus phase.

std::mutex m_

Mutex protecting the queues.

std::condition_variable cond_

Condition variable protecting the queue.

MandateMap mandates_

Mandates.

SubQueue hiq_

The high-priority queue.

SubQueue defaultq_

The default queue.

unsigned nitems_

Number of enqueued items.

TimerQueue timer_queue_

Timer queue.

std::unordered_map<NodeId, double> node_rates_

Map from node ID to rate.

std::unordered_map<FlowUID, SubQueue> flow_qs_

Map from flow to queue.

bool need_sort_

Does the list of queues need to be sorted?

Queues qs_

Queues sorted by priority.

unsigned bonus_idx_

Position of last-served queue during bonus time.

struct MCS
#include <Modem.hh>

A modulation and coding scheme.

Subclassed by Liquid::MCS

Public Functions

MCS() = default
~MCS() = default
float getRate(void) const = 0

Get approximate rate in bps.

std::string description(void) const = 0

Get string representation.

struct Liquid::MCS : public MCS
#include <Modem.hh>

A liquid modulation and coding scheme.

Public Functions

MCS(crc_scheme check, fec_scheme fec0, fec_scheme fec1, modulation_scheme ms)
MCS()
bool operator==(const MCS &other) const
bool operator!=(const MCS &other) const
float getRate(void) const override

Get approximate rate in bps.

std::string description(void) const override

Get string representation.

Public Members

crc_scheme check

CRC.

fec_scheme fec0

FEC0 (inner FEC)

fec_scheme fec1

FEC1 (outer FEC)

modulation_scheme ms

Modulation scheme.

struct PHY::MCSEntry
#include <PHY.hh>

MCS entry.

Public Members

const MCS *mcs

MCS.

AutoGain autogain

auto-gain for this MCS

bool valid

Is this entry valid?

template<class T>
class Mean : public Estimator<T>
#include <Estimator.hh>

Estimate a value by calculating a mean.

Public Functions

Mean()
Mean(T initial_value)
T getValue(void) const override

Return the value of the estimator.

unsigned getNSamples(void) const override

Return the number of samples used in the estimate.

void reset(T x) override

Reset the estimator with an initial value.

void update(T x) override

Update the estimator with a new value.

void remove(T x)

Remove a value used to estimate the mean.

‘remove’ does not check that the value being removed from the estimate was used to update the estimate in the past.

Private Members

T value_
unsigned nsamples_
struct mgenaddr

Public Members

uint16_t dstPort
uint8_t dstAddrType
uint8_t dstAddrLen
struct mgenhdr
#include <mgen.h>

An MGEN packet header.

See: https://downloads.pf.itd.nrl.navy.mil/docs/mgen/mgen.html

Public Functions

uint16_t getMessageSize(void) const
uint32_t getFlowId(void) const
uint32_t getSequenceNumber(void) const
Clock::time_point getTimestamp(void) const

Public Members

uint16_t messageSize
uint8_t version
uint8_t flags
uint32_t mgenFlowId
uint32_t sequenceNumber
mgen_secs_t txTimeSeconds
mgen_usecs_t txTimeMicroseconds
struct mgenrest

Public Members

int32_t latitude
int32_t longitude
int32_t altitude
uint8_t gpsStatus
uint8_t reserved
uint16_t payloadLen
struct mgenstdaddr

Public Members

uint16_t dstPort
uint8_t dstAddrType
uint8_t dstAddrLen
u_int32_t dstIPAddr
uint16_t hostPort
uint8_t hostAddrType
uint8_t hostAddrLen
template<class T, class C>
class Dragon::MixingRationalResampler : public Dragon::RationalResampler<T, C>
#include <Polyphase.hh>

A rational resampler that uses a polyphase filter bank and performs mixing.

Public Functions

MixingRationalResampler(unsigned l, unsigned m, double rad, const std::vector<C> &taps)

Construct a polyphase rational resampler.

Parameters
  • l: The upsampling rate

  • m: The downsampling rate

  • rad: The frequency shift (radians)

  • taps: The taps for the prototype FIR filter. The filter must be designed to run at the upsampler rater.

MixingRationalResampler(double r, double rad, const std::vector<C> &taps)

Construct a polyphase rational resampler.

Parameters
  • r: The resampler rate

  • rad: Frequency shift (radians)

  • taps: The taps for the prototype FIR filter. The filter must be designed to run at the upsampler rater.

MixingRationalResampler() = delete
~MixingRationalResampler() = default
double getFreqShift(void)

Get frequency shift in radians.

void setFreqShift(double rad)

Set frequency shift in radians.

Parameters
  • rad: Frequency shift with respect to the highest sample rate out of the input and output rates. The resampler will internally compensate for non-unity upsampler and downsampler rates.

const std::vector<C> &getBandpassTaps(void) const

Get mixed (bandpass) prototype filter taps.

void reset(void) override
size_t resampleMixUp(const T *in, size_t count, T *out)
template<typename S>
size_t resampleMixUp(const T *in, size_t count, S scale, T *out)
size_t resampleMixDown(const T *in, size_t count, T *out)

Protected Functions

void reconfigure(void) override

Reconfigure filter bank for current number of channels and taps.

Protected Attributes

double rad_

Frequency shift in radians.

TableNCO nco_

NCO used for mixing.

struct ModPacket
#include <PHY.hh>

A modulated data packet to be sent over the radio.

Public Members

unsigned chanidx

Index of channel.

Channel channel

Channel.

size_t start

Offset of start of packet from start of slot, in number of samples.

size_t offset

Offset of start of packet from beginning of sample buffer.

size_t nsamples

Number of modulated samples.

double mod_latency

Modulation latency (sec)

std::shared_ptr<IQBuf> samples

Buffer containing the modulated samples.

std::shared_ptr<NetPacket> pkt

The un-modulated packet.

template<class T = std::unique_ptr<ModPacket>, class Container = std::list<T>>
class ModPacketQueue
#include <ModPacketQueue.hh>

A queue of modulated packets.

Public Types

using container_type = Container

Public Functions

ModPacketQueue()
~ModPacketQueue() = default
std::optional<size_t> getHighWaterMark(void) const
void setHighWaterMark(std::optional<size_t> high_water_mark)
void stop(void)
size_t try_pop(container_type &mpkts, size_t max_samples, bool overfill)
size_t try_pop(container_type &mpkts)
size_t pop(container_type &mpkts)
void push(T &&mpkt)
void kick(void)

Kick the queue to force progress.

Protected Attributes

std::atomic<bool> done_

Are we done with the queue?

std::atomic<bool> kicked_

Is the queue being kicked?

std::optional<size_t> high_water_mark_

Maximum number of IQ samples the queue may contain.

size_t nsamples_

Number of IQ samples the queue contains.

std::mutex mutex_

Mutex protecting the queue.

std::condition_variable producer_cond_

Producer condition variable.

std::condition_variable consumer_cond_

Consumer condition variable.

container_type queue_

Queue of modulated packets.

class Modulator

Subclassed by Liquid::Modulator

Public Functions

Modulator() = default
~Modulator() = default
unsigned getOversampleRate(void)
void print(void) = 0

Print description of modulator to stdout.

void assemble(const Header *header, const void *payload, const size_t payload_len) = 0

Assemble data for modulation.

Parameters
  • header: Pointer to header

  • payload: Pointer to payload

  • payload_len: Number of bytes in payload

size_t assembledSize(void) = 0

Return size of assembled data.

size_t maxModulatedSamples(void) = 0

Return maximum number of modulated samples that will be produced.

bool modulateSamples(std::complex<float> *out, size_t &n) = 0

Modulate assembled packet.

Parameters
  • out: Pointer to output buffer for IQ data

  • n: Reference to variable that will hold number of samples produced

class Liquid::Modulator : public Modulator

Subclassed by Liquid::FlexFrameModulator, Liquid::NewFlexFrameModulator, Liquid::OFDMModulator, Liquid::PHY::PacketModulator

Public Functions

Modulator(const MCS &header_mcs)
Modulator() = delete
~Modulator() = default
const MCS &getHeaderMCS() const
void setHeaderMCS(const MCS &mcs)
const MCS &getPayloadMCS() const
void setPayloadMCS(const MCS &mcs)

Protected Functions

void reconfigureHeader(void) = 0

Reconfigure modulator based on new header parameters.

void reconfigurePayload(void) = 0

Reconfigure modulator based on new payload parameters.

Protected Attributes

MCS header_mcs_

Header MCS.

MCS payload_mcs_

Payload MCS.

class MonoClock
#include <Clock.hh>

A monotonic clock.

Subclassed by Clock

Public Types

using duration = std::chrono::seconds
using rep = duration::rep
using period = duration::period
using time_point = time_point_t<mono_tag>

Public Functions

MonoClock::time_point getTimeZero(void)

Get time 0, for purposes of linear fit.

Public Static Functions

time_point now() noexcept

Get the current time. Guaranteed to be monotonic.

Public Static Attributes

const bool is_steady = true

Protected Static Attributes

uhd::time_spec_t t0_

Time zero, for purposes of linear fit.

uhd::usrp::multi_usrp::sptr usrp_

The USRP used for clock operations.

struct MPStats
#include <FlowPerformance.hh>

Statistics for a single measurement period.

Public Functions

MPStats()

Public Members

size_t npackets

Number of packets sent/received.

size_t nbytes

Number of bytes sent/received.

struct MandateQueue::SubQueue::MPStats
#include <MandateQueue.hh>

Statistics for a single measurement period.

Public Functions

MPStats()

Public Members

size_t npackets

Number of packets enqueued.

size_t npackets_sent

Number of packets sent.

size_t nbytes

Number of bytes enqueued.

size_t nbytes_sent

Number of bytes sent.

class MultichannelSynthesizer::MultichannelModulator : public ChannelModulator, private FDUpsampler<C, P, V>

Channel modulator for multichannel modulation.

Public Functions

MultichannelModulator(PHY &phy, unsigned chanidx, const Channel &channel, const std::vector<C> &taps, double tx_rate)
MultichannelModulator() = delete
~MultichannelModulator() = default
void modulate(std::shared_ptr<NetPacket> pkt, const float g, ModPacket &mpkt) override
void nextSlot(const Slot *prev_slot, Slot &slot, const bool overfill)

Specify the next slot to modulate.

Parameters
  • prev_slot: The previous slot

  • slot: The new slot

  • overfill: true if this slot can be overfilled

bool fits(ModPacket &mpkt, const bool overfill)

Determine whether or not a modulated packet will fit in the current frequency domain buffer.

Return

true if the packet will fit in the slot, false otherwise If the packet will fit in the slot, nsamples is updated appropriately.

Parameters
  • mpkt: The modulated packet

  • overfill: Flag that is true if the slot can be overfilled

void setIQBuffer(std::shared_ptr<IQBuf> &&iqbuf)

Set current IQ buffer to be upsampled.

Parameters
  • iqbuf:

size_t upsampledSize(size_t n)

Calculate how many samples will be in upsampled signal. @param n Number of samples in original signal.

Return

Number of samples in upsampled signal.

size_t upsample(void)

Perform frequency-domain upsampling on current IQ buffer.

Return

Number of samples read from the input buffer.

void flush(Slot &slot)

Perform frequency-domain upsampling on current IQ buffer.

Parameters
  • slot: Current slot.

Public Members

spinlock_mutex mutex

Mutex for channel state.

std::shared_ptr<NetPacket> pkt

Packet whose modulated signal is the IQ buffer.

std::shared_ptr<IQBuf> iqbuf

IQ buffer being upsampled.

size_t iqbufoff

Offset of unmodulated data in IQ buffer.

IQBuf *fdbuf

Frequency domain buffer into which we upsample.

size_t delay

Number of time domain samples in the frequency domain buffer to delay.

size_t nsamples

Number of valid time-domain samples represented by data in the frequency domain buffer.

This represents the number of valid UN-overlapped time-domain samples represented by the FFT blocks in the frequency domain buffer.

size_t max_samples

Maximum number of time-domain samples.

size_t npartial

Number of time-domain samples represented by final FFT block that are included in nsamples.

std::optional<size_t> partial_fftoff

FFT buffer offset before flush of partial block.

size_t fdnsamples

Number of valid samples in the frequency-domain buffer.

This will be a multiple of N

class MultichannelSynthesizer : public SlotSynthesizer
#include <MultichannelSynthesizer.hh>

A frequency-domain, per-channel synthesizer.

Public Types

using Upsampler = FDUpsampler<C, P, V>

Public Functions

MultichannelSynthesizer(std::shared_ptr<PHY> phy, double tx_rate, const Channels &channels, size_t nthreads)
~MultichannelSynthesizer()
void modulate(const std::shared_ptr<Slot> &slot) override

Modulate a slot.

void finalize(Slot &slot) override

Finalize a slot.

This should be called after a slot is closed in order to finish any final computations necessary. It does not need to acquire teh slot’s mutex.

void stop(void) override

Stop modulating.

void reconfigure(void) override

Reconfigure for new TX parameters.

Public Static Attributes

constexpr unsigned P = 25 * 64 + 1

Filter length.

We need two factors of 5 because we need to support 25MHz bandwidth. The rest of the factors of 2 are for good measure.

constexpr unsigned V = 4

Overlap factor.

constexpr auto N = Upsampler::N
constexpr auto L = Upsampler::L
constexpr auto O = Upsampler::O

Private Functions

void modWorker(unsigned tid)

Thread modulating packets.

Private Members

unsigned nthreads_

Number of synthesizer threads.

std::atomic<bool> done_

Flag indicating if we should stop processing packets.

std::atomic<bool> reconfigure_

Flag that is true when we are reconfiguring.

barrier reconfigure_sync_

Reconfiguration barrier.

std::mutex wake_mutex_

Mutex for waking demodulators.

std::condition_variable wake_cond_

Condition variable for waking demodulators.

spinlock_mutex mods_mutex_

Mutex for demodulation state.

std::vector<std::unique_ptr<MultichannelModulator>> mods_

Channel state for demodulation.

std::shared_ptr<Slot> curslot_

Current slot that need to be synthesized.

std::vector<std::thread> mod_threads_

Threads running modWorker.

Upsampler::ToTimeDomain timedomain_

OLS time domain converter.

double tx_rate_copy_

TX sample rate.

Channels channels_copy_

Radio channels.

Schedule schedule_copy_

Radio schedule.

float g_multichan_

Gain necessary to compensate for simultaneous transmission.

template<class I, class O, class C>
class Liquid::MultiStageResampler : public Resampler<I, O>

Public Functions

MultiStageResampler(float rate, unsigned m, float fc, float As, unsigned npfb)

Create a liquid multi-stage resampler.

Parameters
  • rate: Resampling rate

  • m: Prototype filter semi-length

  • fc: Prototype filter cutoff frequency, in range (0, 0.5)

  • As: Stop-band attenuation

  • npfb: Number of filters in polyphase filterbank

MultiStageResampler(MultiStageResampler &&resamp)
~MultiStageResampler()
double getRate (void) const overridefinal
double getDelay (void) const overridefinal
size_t neededOut (size_t count) const overridefinal
void reset (void) overridefinal
size_t resample (const std::complex< float > *in, size_t count, std::complex< float > *out) overridefinal
void print(void)
template<>
class Liquid::MultiStageResampler<C, C, F> : public Resampler<C, C>

Public Functions

MultiStageResampler(float rate, unsigned m, float fc, float As, unsigned npfb)

Create a liquid multi-stage resampler.

Parameters
  • rate: Resampling rate

  • m: Prototype filter semi-length

  • fc: Prototype filter cutoff frequency, in range (0, 0.5)

  • As: Stop-band attenuation

  • npfb: Number of filters in polyphase filterbank

MultiStageResampler(const MultiStageResampler&) = delete
MultiStageResampler(MultiStageResampler &&resamp)
~MultiStageResampler()
MultiStageResampler &operator=(const MultiStageResampler&) = delete
MultiStageResampler &operator=(MultiStageResampler &&resamp)
double getRate (void) const overridefinal
double getDelay (void) const overridefinal
size_t neededOut (size_t count) const overridefinal
void reset (void) overridefinal
size_t resample (const std::complex< float > *in, size_t count, std::complex< float > *out) overridefinal
void print(void)

Protected Attributes

msresamp_crcf resamp_
double rate_
double delay_
class NCO

Subclassed by Liquid::BaseNCO, TableNCO

Public Functions

NCO() = default
~NCO() = default
double getFrequency(void) = 0

Get frequency in radians per sample.

void setFrequency(double dtheta) = 0

Set frequency in radians per sample.

double getPhase(void) = 0

Get phase in radians.

void setPhase(double theta) = 0

Set phase in radians.

void reset(double dtheta) = 0

Reset NCO state with given frequency in radians per sample.

std::complex<float> mix_up(const std::complex<float> in) = 0

Mix a single sample up.

std::complex<float> mix_down(const std::complex<float> in) = 0

Mix a single sample down.

void mix_up(const std::complex<float> *in, std::complex<float> *out, size_t count) = 0

Mix a signal up.

void mix_down(const std::complex<float> *in, std::complex<float> *out, size_t count) = 0

Mix a signal down.

class Liquid::NCO : public Liquid::BaseNCO
#include <NCO.hh>

A numerically-controlled oscillator (fast)

Public Functions

NCO(double dtheta)
NCO() = delete
NCO(const NCO&) = delete
NCO(NCO&&) = default
~NCO()
NCO &operator=(const NCO&) = delete
NCO &operator=(NCO&&) = default
class Net

Public Types

using NodeMap = std::map<NodeId, std::shared_ptr<Node>>

Public Functions

Net() = delete
Net(std::shared_ptr<TunTap> tuntap, NodeId nodeId)
~Net() = default
Net(const Net&) = delete
Net(Net&&) = delete
Net &operator=(const Net&) = delete
Net &operator=(Net&&) = delete
NodeId getMyNodeId(void) const

Get this node’s ID.

bool contains(NodeId nodeId)

Return true if node is in the network, false otherwise.

NodeMap getNodes(void)

Get nodes.

Return

A copy of the current node map.

Node &me(void)

Get the entry for this node.

std::shared_ptr<Node> getNode(NodeId nodeId)

Get the entry for a particular node in the network.

Node &operator[](NodeId nodeId)

Get the entry for a particular node in the network.

void foreach(std::function<void(Node&)> f)

Apply a function to each node.

std::optional<NodeId> getTimeMaster(void)

Get the node that is the time master.

Private Members

std::shared_ptr<TunTap> tuntap_

Our tun/tap interface.

const NodeId my_node_id_

This node’s ID.

std::mutex nodes_mutex_

Mutex protecting nodes in the network.

NodeMap nodes_

The nodes in the network.

class NetFilter : public Processor<std::shared_ptr<NetPacket>>

Public Functions

NetFilter(std::shared_ptr<Net> net, in_addr_t int_net, in_addr_t int_netmask, in_addr_t int_broadcast, in_addr_t ext_net, in_addr_t ext_netmask, in_addr_t ext_broadcast)
~NetFilter() = default

Protected Functions

bool process(std::shared_ptr<NetPacket> &pkt) override

Private Members

std::shared_ptr<Net> net_
in_addr_t int_net_

Internal IP network.

in_addr_t int_netmask_

Internal IP network mask.

in_addr_t int_broadcast_

Internal IP broadcast address.

in_addr_t ext_net_

External IP network.

in_addr_t ext_netmask_

External IP network mask.

in_addr_t ext_broadcast_

External IP broadcast address.

struct NetPacket : public Packet
#include <Packet.hh>

A packet received from the network.

Public Functions

NetPacket() = delete
NetPacket(size_t n)
bool deadlinePassed(const MonoClock::time_point &now)

Return true if the packet’s deadline has passed, false otherwise.

bool shouldDrop(const MonoClock::time_point &now)

Return true if this packet should be dropped, false otherwise.

Public Members

std::optional<MonoClock::time_point> deadline

Packet delivery deadline.

mcsidx_t mcsidx

MCS to use, given as an index into PHY’s MCS table.

float g

Multiplicative TX gain.

unsigned nretrans

Number of retransmissions.

std::optional<unsigned> mp

Measurement period to which this packet belongs.

class Liquid::NewFlexFrame : public Liquid::PHY
#include <NewFlexFrame.hh>

A PHY thats uses the liquid-usrp flexframegen code.

Public Functions

NewFlexFrame(const MCS &header_mcs, const std::vector<std::pair<MCS, AutoGain>> &mcs_table, bool soft_header, bool soft_payload)
~NewFlexFrame() = default
unsigned getMinRXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for demodulation.

Return

The minimum RX oversample rate

unsigned getMinTXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for modulation.

Return

The minimum TX oversample rate

Protected Functions

std::shared_ptr<::PHY::PacketDemodulator> mkPacketDemodulator(void) override

Create a Demodulator for this PHY.

std::shared_ptr<::PHY::PacketModulator> mkPacketModulator(void) override

Create a Modulator for this PHY.

std::unique_ptr<Liquid::Modulator> mkLiquidModulator(void) override

Create underlying liquid modulator object.

class Liquid::NewFlexFrameDemodulator : public virtual Liquid::Demodulator

Subclassed by Liquid::NewFlexFrame::PacketDemodulator

Public Functions

NewFlexFrameDemodulator(const MCS &header_mcs, bool soft_header, bool soft_payload)
~NewFlexFrameDemodulator()
NewFlexFrameDemodulator() = delete
NewFlexFrameDemodulator(const NewFlexFrameDemodulator&) = delete
NewFlexFrameDemodulator(NewFlexFrameDemodulator&&) = delete
NewFlexFrameDemodulator &operator==(const NewFlexFrameDemodulator&) = delete
NewFlexFrameDemodulator &operator!=(const NewFlexFrameDemodulator&) = delete
unsigned getOversampleRate(void) override
bool isFrameOpen(void) override

Is a frame currently being demodulated?

Return

true if a frame is currently being demodulated, false otherwise.

void print(void) override

Print description of demodulator to stdout.

void reset(void) override

Reset demodulator state.

void demodulateSamples(const std::complex<float> *buf, const size_t n) override

Demodulate samples.

Protected Functions

void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

void reconfigureSoftDecode(void) override

Reconfigure demodulator based on new soft decoding parameters.

Protected Attributes

flexframesync fs_
class Liquid::NewFlexFrameModulator : public virtual Liquid::Modulator

Subclassed by Liquid::NewFlexFrame::PacketModulator

Public Functions

NewFlexFrameModulator(const MCS &header_mcs)
~NewFlexFrameModulator()
NewFlexFrameModulator() = delete
NewFlexFrameModulator(const NewFlexFrameModulator&) = delete
NewFlexFrameModulator(NewFlexFrameModulator&&) = delete
NewFlexFrameModulator &operator=(const NewFlexFrameModulator&) = delete
NewFlexFrameModulator &operator=(NewFlexFrameModulator&&) = delete
void print(void) override

Print description of modulator to stdout.

void assemble(const Header *header, const void *payload, const size_t payload_len) override

Assemble data for modulation.

Parameters
  • header: Pointer to header

  • payload: Pointer to payload

  • payload_len: Number of bytes in payload

unsigned getOversampleRate(void) override
size_t assembledSize(void) override

Return size of assembled data.

size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

bool modulateSamples(std::complex<float> *buf, size_t &nw) override

Modulate assembled packet.

Parameters
  • out: Pointer to output buffer for IQ data

  • n: Reference to variable that will hold number of samples produced

Public Static Attributes

constexpr size_t NGEN = 2

Protected Functions

void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

void reconfigurePayload(void) override

Reconfigure modulator based on new payload parameters.

Protected Attributes

flexframegen fg_
struct Node

Public Functions

Node(NodeId id)
Node() = delete
Node(const Node&) = delete
~Node() = default
void setSoftTXGain(float dB)

Set soft TX gain.

Parameters
  • dB: The soft gain (dBFS).

float getSoftTXGain(void) const

Get soft TX gain (dBFS).

Public Members

const NodeId id

Node ID.

bool is_gateway

Flag indicating whether or not this node is the gateway.

bool can_transmit

Flag indicating whether or not this node can transmit.

float g

Multiplicative TX gain as measured against 0 dBFS.

mcsidx_t mcsidx

MCS for this node.

std::mutex timestamps_mutex

Mutex protecting timestamps.

timestamp_vector timestamps

Timestamps received from this node.

template<class T>
class Noop : public Processor<T>
#include <Noop.hh>

A no-op packet-processor.

Public Functions

Noop() = default
~Noop() = default

Protected Functions

bool process(T &pkt) override
class Liquid::OFDM : public Liquid::PHY
#include <OFDM.hh>

A PHY thats uses the liquid-usrp ofdmflexframegen code.

Public Functions

OFDM(const MCS &header_mcs, const std::vector<std::pair<MCS, AutoGain>> &mcs_table, bool soft_header, bool soft_payload, unsigned int M, unsigned int cp_len, unsigned int taper_len, const std::optional<std::string> &p)

Construct an OFDM PHY.

Parameters
  • header_mcs: The MCS used to the packet header

  • mcs_table: The MCS table

  • soft_header: True if soft decoding should be used for header

  • soft_payload: True if soft decoding should be used for payload

  • M: The number of subcarriers.

  • cp_len: The cyclic prefix length

  • taper_len: The taper length (OFDM symbol overlap)

  • p: The subcarrier allocation (null, pilot, data). Should have M entries.

~OFDM() = default
unsigned getMinRXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for demodulation.

Return

The minimum RX oversample rate

unsigned getMinTXRateOversample(void) const override

Return the minimum oversample rate (with respect to PHY bandwidth) needed for modulation.

Return

The minimum TX oversample rate

Liquid::OFDMSubcarriers getSubcarriers(void) const

Protected Functions

std::shared_ptr<::PHY::PacketDemodulator> mkPacketDemodulator(void) override

Create a Demodulator for this PHY.

std::shared_ptr<::PHY::PacketModulator> mkPacketModulator(void) override

Create a Modulator for this PHY.

std::unique_ptr<Liquid::Modulator> mkLiquidModulator(void) override

Create underlying liquid modulator object.

Protected Attributes

unsigned int M_

The number of subcarriers.

unsigned int cp_len_

The cyclic prefix length.

unsigned int taper_len_

The taper length (OFDM symbol overlap)

Liquid::OFDMSubcarriers p_

The subcarrier allocation (null, pilot, data). Should have M entries.

class Liquid::OFDMDemodulator : public virtual Liquid::Demodulator

Subclassed by Liquid::OFDM::PacketDemodulator

Public Functions

OFDMDemodulator(const MCS &header_mcs, bool soft_header, bool soft_payload, unsigned M, unsigned cp_len, unsigned taper_len, const std::optional<OFDMSubcarriers> &p)
~OFDMDemodulator()
OFDMDemodulator() = delete
OFDMDemodulator(const OFDMDemodulator&) = delete
OFDMDemodulator(OFDMDemodulator&&) = delete
OFDMDemodulator &operator==(const OFDMDemodulator&) = delete
OFDMDemodulator &operator!=(const OFDMDemodulator&) = delete
bool isFrameOpen(void) override

Is a frame currently being demodulated?

Return

true if a frame is currently being demodulated, false otherwise.

void print(void) override

Print description of demodulator to stdout.

void reset(void) override

Reset demodulator state.

void demodulateSamples(const std::complex<float> *buf, const size_t n) override

Demodulate samples.

Protected Functions

void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

void reconfigureSoftDecode(void) override

Reconfigure demodulator based on new soft decoding parameters.

Protected Attributes

unsigned M_
unsigned cp_len_
unsigned taper_len_
OFDMSubcarriers p_
ofdmflexframesync fs_
class Liquid::OFDMModulator : public virtual Liquid::Modulator

Subclassed by Liquid::OFDM::PacketModulator

Public Functions

OFDMModulator(const MCS &header_mcs, unsigned M, unsigned cp_len, unsigned taper_len, const std::optional<OFDMSubcarriers> &p)
~OFDMModulator()
OFDMModulator() = delete
OFDMModulator(const OFDMModulator&) = delete
OFDMModulator(OFDMModulator&&) = delete
OFDMModulator &operator=(const OFDMModulator&) = delete
OFDMModulator &operator=(OFDMModulator&&) = delete
void print(void) override

Print description of modulator to stdout.

void assemble(const Header *header, const void *payload, const size_t payload_len) override

Assemble data for modulation.

Parameters
  • header: Pointer to header

  • payload: Pointer to payload

  • payload_len: Number of bytes in payload

size_t assembledSize(void) override

Return size of assembled data.

size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

bool modulateSamples(std::complex<float> *buf, size_t &nw) override

Modulate assembled packet.

Parameters
  • out: Pointer to output buffer for IQ data

  • n: Reference to variable that will hold number of samples produced

Protected Functions

void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

void reconfigurePayload(void) override

Reconfigure modulator based on new payload parameters.

Protected Attributes

unsigned M_
unsigned cp_len_
unsigned taper_len_
OFDMSubcarriers p_
ofdmflexframegen fg_
class Liquid::OFDMSubcarriers : public std::vector<char>

Public Functions

OFDMSubcarriers(unsigned int M)
OFDMSubcarriers(const std::string &scs)
OFDMSubcarriers(std::initializer_list<char> init)
OFDMSubcarriers() = delete
OFDMSubcarriers &operator=(const std::string &scs)
operator std::string() const
void validate(void)
struct Out
#include <Element.hh>

Type tag for output ports.

Public Types

using Flip = In
class OverlapTDChannelizer::OverlapTDChannelDemodulator : public ChannelDemodulator

Channel state for time-domain demodulation.

Public Functions

OverlapTDChannelDemodulator(PHY &phy, const Channel &channel, const std::vector<C> &taps, double rx_rate)
OverlapTDChannelDemodulator() = default
~OverlapTDChannelDemodulator() = default
void setChannel(const Channel &channel)

Set channel.

void reset(void) override
void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, float rx_rate) override
void demodulate(const std::complex<float> *data, size_t count) override

Protected Attributes

size_t delay_

Filter delay.

const double rx_rate_

RX rate.

const unsigned rx_oversample_

RX oversample factor.

IQBuf resamp_buf_

Resampling buffer.

Dragon::MixingRationalResampler<C, C> resamp_

Resampler.

class OverlapTDChannelizer : public Channelizer
#include <OverlapTDChannelizer.hh>

A time-domain channelizer that demodulates overlapping pairs of slots. This duplicates work (and leads to duplicate packets), but it allows us to parallelize demodulation of a single channel. We have to do this when demodulation is slow, such as when we use liquid’s resamplers.

Public Types

using C = std::complex<float>

Public Functions

OverlapTDChannelizer(std::shared_ptr<PHY> phy, double rx_rate, const Channels &channels, unsigned int nthreads)
~OverlapTDChannelizer()
void setChannels(const Channels &channels) override

Set channels.

void push(const std::shared_ptr<IQBuf>&) override

Add an IQ buffer to demodulate.

Parameters
  • buf: The IQ samples to demodulate

void reconfigure(void) override

Reconfigure for new RX parameters.

double getPrevDemod(void)

Return the portion of the end of the previous slot that we demodulate.

void setPrevDemod(double sec)

Set the portion of the end of the previous slot that we demodulate.

double getCurDemod(void)

Return the portion of the current slot that we demodulate.

void setCurDemod(double sec)

Set the portion of the current slot that we demodulate.

bool getEnforceOrdering(void)

Return flag indicating whether or not demodulation queue enforces packet order.

void setEnforceOrdering(bool enforce)

Set whether or not demodulation queue enforces packet order.

void stop(void)

Stop demodulating.

Private Functions

double getRXDownsampleRate(const Channel &channel)

Get RX downsample rate for given channel.

void demodWorker(std::atomic<bool> &reconfig)

A demodulation worker.

void netWorker(void)

The network send worker.

bool pop(RadioPacketQueue::barrier &b, unsigned &channel, std::shared_ptr<IQBuf> &buf1, std::shared_ptr<IQBuf> &buf2)

Get two slot’s worth of IQ data.

Return

Return true if pop was successful, false otherwise. Return two slot’s worth of IQ datathe previous slot, and the current slot. The previous slot is removed from the queue, whereas the current slot is kept in the queue because it becomes the new “previous” slot.

Parameters
  • b: The barrier before which network packets should be inserted.

  • channel: The channel to demodulate.

  • buf1: The buffer holding the previous slot’s IQ data.

  • buf2: The buffer holding the current slot’s IQ data.

void <