C++

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

Allocator for FFTW-aligned memory.

tparam 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

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

Log entry for LLC events.

Public Members

double timestamp

Event timestamp.

double mono_timestamp

Monotonic clock timestamp.

uint8_t type

Type of LLC entry.

uint8_t node

Node ID of other node.

uint16_t seq

Sequence number.

hvl_t sacks

Selective ACKs.

A selective ACK sequence is a list of tuples [start,end) representing selective ACKs from start (inclusive) to end (non-inclusive).

struct AutoGain
#include <AutoGain.hh>

PHY TX parameters.

Public Functions

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

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

inline 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.

inline float getSoftTXGain(void) const

Get soft TX gain (multiplicative factor).

inline void setSoftTXGain(float g)

Set soft TX gain (multiplicative factor).

Parameters

g – The soft gain (multiplicative factor).

inline float getSoftTXGain0dBFS(void) const

Get soft TX gain (dB).

inline void setSoftTXGain0dBFS(float dB)

Set soft TX gain (dBFS).

Parameters

dB – The soft gain (dBFS).

inline void recalc0dBFSEstimate(unsigned nsamples)

Recalculate the 0dBFS estimate.

Parameters

nsamples – The number of samples used to estimate 0dBFS

inline 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
  • gGain 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.

mutable 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

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

Private Members

const unsigned count_

Number of threads in barrier synchronization 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

inline BaseNCO(liquid_ncotype type, double dtheta)
inline BaseNCO(BaseNCO &&nco)
BaseNCO() = delete
BaseNCO(const BaseNCO&) = delete
inline virtual ~BaseNCO()
inline BaseNCO &operator=(BaseNCO &&nco)
BaseNCO &operator=(const BaseNCO&) = delete
inline virtual void reset(double dtheta) final override

Reset NCO state with given frequency in radians per sample.

inline virtual double getFrequency(void) final override

Get frequency in radians per sample.

inline virtual void setFrequency(double dtheta) final override

Set frequency in radians per sample.

inline virtual double getPhase(void) final override

Get phase in radians.

inline virtual void setPhase(double theta) final override

Set phase in radians.

inline virtual std::complex<float> mix_up(const std::complex<float> in) final override

Mix a single sample up.

inline virtual std::complex<float> mix_down(const std::complex<float> in) final override

Mix a single sample down.

inline virtual void mix_up(const std::complex<float> *in, std::complex<float> *out, size_t count) final override

Mix a signal up.

inline virtual void mix_down(const std::complex<float> *in, std::complex<float> *out, size_t count) final override

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.

Public Functions

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

Return this Port’s Element.

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

Return this Port’s partner Port.

inline bool isConnected(void)

Return true if the Port is connected.

Protected Functions

inline void connected(void)

Safely indicate that the port was connected.

inline 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 <threads.hh>

Atomically block a signal.

Public Functions

explicit 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

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

Private Members

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

Public Functions

BufferDecoder() = default
virtual ~BufferDecoder() = default

Public Members

buffer<fc32_t> decoded

Protected Functions

inline virtual size_t size(void) override

Get size of buffer holding decoded data.

inline virtual fc32_t *data(void) override

Get pointer to buffer holding decoded data.

inline virtual void resize(size_t size) override

Resize buffer holding decoded data.

class BufferEncoder : public FLACMemoryEncoder

Public Functions

BufferEncoder() = default
virtual ~BufferEncoder() = default

Public Members

class buffer<char> encoded

Protected Functions

inline virtual size_t size(void) override

Get size of buffer holding encoded.

inline virtual char *data(void) override

Get pointer to buffer holding encoded.

inline virtual void resize(size_t size) override

Resize buffer holding encoded data.

class Caps

Public Functions

inline Caps()
inline Caps(const Caps &other)
inline Caps(Caps &&other) noexcept
inline Caps(cap_t caps)
inline ~Caps()
inline Caps &operator=(const Caps &other)
inline Caps &operator=(Caps &&other) noexcept
inline Caps &operator=(cap_t caps) noexcept
inline void set_proc()
inline void clear()
inline cap_flag_value_t get_flag(cap_value_t cap, cap_flag_t flag)
inline void set_flag(cap_flag_t flag, const std::vector<cap_value_t> &caps)
inline void clear_flag(cap_flag_t flag)
inline void clear_flag(cap_flag_t flag, const std::vector<cap_value_t> &caps)

Protected Attributes

cap_t caps_
struct Channel

Public Functions

inline Channel()
inline Channel(double fc_, double bw_)
inline bool operator==(const Channel &other) const
inline bool operator!=(const Channel &other) const
inline bool operator<(const Channel &other) const
inline bool operator>(const Channel &other) const
inline 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

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

Set demodulation callback.

virtual void reset(void) = 0

Reset internal state.

virtual 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)

virtual 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

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

Get the RX sample rate.

inline virtual void setRXRate(double rate)

Set the RX sample rate.

Parameters

rate – The rate.

inline virtual const Channels &getChannels(void) const

Get channels.

inline virtual void setChannels(const Channels &channels)

Set channels.

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

Add an IQ buffer to demodulate.

Parameters

buf – The IQ samples to demodulate

virtual 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

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

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gGain to apply.

  • mpkt – The ModPacket in which to place modulated samples.

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

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

Get high-water mark.

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

Set high-water mark.

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

Pop modulated packets.

inline size_t try_pop(container_type &mpkts)

Pop all modulated packets.

inline 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
#include <Clock.hh>

A clock.

Subclassed by MonoClock, WallClock

Public Static Functions

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

Set the USRP used for clock operations.

Parameters

usrp – The USRP.

static void releaseUSRP(void)

Release the USRP used for clock operations.

Protected Static Functions

static inline uhd::time_spec_t getTimeNow() noexcept

Get the current UHD time.

static inline void setTimeNow(const uhd::time_spec_t &now) noexcept

Set the current UHD time.

Parameters

now – Current UHD time

Protected Static Attributes

static uhd::usrp::multi_usrp::sptr usrp_

The USRP used for clock operations.

static uhd::time_spec_t t0_

Time zero.

class CompressionBuffer : public buffer<unsigned char>

Public Functions

CompressionBuffer() = delete
inline CompressionBuffer(NetPacket &pkt_)
inline void copyBytesOut(size_t count)
template<class T>
inline void copyOut(const T &val)
inline 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

inline Controller(std::shared_ptr<RadioNet> radionet, size_t mtu)
virtual ~Controller() = default
Controller() = delete
inline std::shared_ptr<NetQueue> getNetQueue(void)

Get the controller’s network queue.

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

Set the controller’s network queue.

inline size_t getMTU() const

Get MTU.

inline virtual void setMinChannelBandwidth(double min_bw)

Set minimum channel bandwidth.

virtual 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.

inline virtual void kick(void)

Kick the controller.

virtual 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.

inline virtual void disconnect(void)

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

inline virtual 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.

inline virtual 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<RadioNet> radionet_

The Net we’re attached to.

std::shared_ptr<NetQueue> netq_

Network queue with high-priority sub-queue.

size_t mtu_

Network MTU.

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 kPing
enumerator kTimestamp
enumerator kTimestampSent
enumerator kTimestampRecv
enumerator kShortTermReceiverStats
enumerator kLongTermReceiverStats
enumerator kNak
enumerator kSelectiveAck
enumerator kSetUnack
using Nak = Seq

Public Members

struct ControlMsg::TimestampSent PACKED
struct ControlMsg::TimestampRecv PACKED
uint8_t type
Hello hello
Ping ping
Timestamp timestamp
TimestampSent timestamp_sent
TimestampRecv timestamp_recv
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
inline DecompressionBuffer(RadioPacket &pkt_)
inline void copyBytesOut(size_t count)
template<class T>
inline void copyOut(const T &val)
template<class T>
inline T read(void)
inline 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
virtual ~Demodulator() = default
inline virtual unsigned getOversampleRate(void)
virtual bool isFrameOpen(void) = 0

Is a frame currently being demodulated?

Returns

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

virtual void print(void) = 0

Print description of demodulator to stdout.

virtual void reset(void) = 0

Reset demodulator state.

virtual 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

inline Demodulator(const MCS &header_mcs, bool soft_header, bool soft_payload)
Demodulator() = delete
virtual ~Demodulator() = default
inline const MCS &getHeaderMCS() const
inline void setHeaderMCS(const MCS &mcs)
inline bool getSoftHeader() const
inline void setSoftHeader(bool soft)
inline bool getSoftPayload() const
inline void setSoftPayload(bool soft)
virtual 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

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

Demodulate samples.

virtual 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.

virtual void reconfigureHeader(void) = 0

Reconfigure demodulator based on new header parameters.

virtual 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

static 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 dragonradio::signal::Downsampler : public dragonradio::signal::Pfb<T, C>, public Resampler<T, T>
#include <Polyphase.hh>

A downsampler that uses a polyphase filter bank.

Public Functions

inline 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
virtual ~Downsampler() = default
inline virtual double getRate(void) const override
inline virtual double getDelay(void) const override
inline virtual size_t neededOut(size_t count) const override
inline virtual void reset(void) override
inline virtual size_t resample(const T *in, size_t count, T *out) final override

Protected Functions

inline virtual 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

inline DummyController(std::shared_ptr<RadioNet> radionet, size_t mtu)
virtual ~DummyController() = default
virtual 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.

virtual 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

std::mutex seqs_mutex_

Mutex for sequence numbers.

std::unordered_map<NodeId, Seq> seqs_

Receive windows.

class heap::element

Subclassed by TimerQueue::Timer

Public Functions

inline element()
inline bool in_heap() const
inline 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
virtual ~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

inline explicit EMA(T alpha)

Create and EMA estimator.

Parameters

alpha – The weight used to update the EMA

inline 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
inline T getValue(void) const override
inline unsigned getNSamples(void) const override
inline void reset(T x) override
inline virtual 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

inline Entry(SendWindow &sendw)
virtual ~Entry() = default
inline bool pending()

Does this entry have a pending packet to be sent?

inline void set(const std::shared_ptr<NetPacket> &p)

Set packet in send window entry.

Parameters

p – The packet.

inline std::shared_ptr<NetPacket> get()

Get packet in send window entry.

Returns

The packet.

inline void reset(void)

Release packet.

inline 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.

inline 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.

virtual 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.

This is the time at which the packet was queued for transmission, not the actual time at which it was transmitted, which is instead recorded in the packet itself.

struct RecvWindow::Entry

Public Functions

inline Entry()
inline void set(std::shared_ptr<RadioPacket> &&p)

Set packet in receive window entry.

Parameters

p – The packet.

inline void alreadyDelivered(void)
inline 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

virtual ~Estimator() = default
virtual operator bool() const = 0

Does the estimator have a value?

virtual T operator*() const = 0

Return the value of the estimator.

virtual std::optional<T> value(void) const = 0

Return the value of the estimator.

virtual T value_or(T &&default_value) const = 0

Return the value of the estimator or a default.

virtual size_t size(void) const = 0

Return the number of samples used in the estimate.

virtual void update(T x) = 0

Update the estimator with a new value.

struct EventEntry

Generic event.

Public Members

double timestamp

Event timestamp.

double mono_timestamp

Monotonic clock timestamp.

const char *event

Event description.

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 Group &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)
virtual ~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)
virtual ~FDChannelizer()
virtual void setChannels(const Channels &channels) override

Set channels.

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

Add an IQ buffer to demodulate.

Parameters

buf – The IQ samples to demodulate

virtual void reconfigure(void) override

Reconfigure for new RX parameters.

void stop(void)

Stop demodulating.

Public Static Attributes

static 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.

static constexpr unsigned V = 4

Overlap factor.

static constexpr unsigned N = V * (P - 1)

Length of FFT.

static constexpr unsigned O = P - 1

Size of FFT overlap.

static 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.

SafeQueue<std::shared_ptr<IQBuf>> tdbufs_

Time-domain IQ buffers to demodulate.

std::mutex demod_mutex_

Mutex for demodulation state.

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

Channel state for demodulation.

std::vector<std::unique_ptr<SafeQueue<Slot>>> 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

static 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

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

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gGain to apply.

  • mpkt – The ModPacket in which to place modulated samples.

Public Static Attributes

static 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.

static constexpr unsigned V = 8

Overlap factor.

static 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)
virtual ~FDMA()
FDMA(const FDMA&) = delete
FDMA(FDMA&&) = delete
FDMA &operator=(const FDMA&) = delete
FDMA &operator=(FDMA&&) = delete
inline bool getAccurateTXTimestamps(void) const
inline void setAccurateTXTimestamps(bool accurate)
inline double getTimedTXDelay(void) const
inline void setTimedTXDelay(double t)
virtual void stop(void) override

Stop processing packets.

virtual 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)

bool accurate_tx_timestamps_

Provide more accurate TX timestamps.

Providing more accurate TX timestamps may increase latency.

double timed_tx_delay_

Delay for timed TX (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

inline FDUpsampler(unsigned X_, unsigned I_, int Nrot_)
FDUpsampler() = delete
inline void reset(size_t npartial = 0)
inline void upsampleBlock(T *out)
inline 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)
inline 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

static constexpr unsigned N = V * (P - 1)

Length of FFT.

static constexpr unsigned O = P - 1

Size of FFT overlap.

static constexpr unsigned L = N - 2 * O

Number of new samples consumed per input block.

template<class T>
class fftw::FFT

Public Functions

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

Public Types

using C = std::complex<float>

Public Functions

inline FFT(unsigned N, int sign, unsigned flags)
inline virtual ~FFT()
inline unsigned getSize(void) const
inline void execute(void)
inline 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
virtual ~Filter() = default
virtual float getGroupDelay(float fc) const = 0

Get filter group delay.

virtual void reset(void) = 0

Reset filter state.

virtual 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
virtual ~FIR() = default
virtual float getDelay(void) const = 0

Get filter delay.

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

Get taps.

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

Set taps.

template<class T, class C>
class dragonradio::signal::FIR : public FIR<T, T, C>

Public Functions

inline FIR(const std::vector<C> &taps)
FIR() = delete
virtual ~FIR() = default
inline virtual float getGroupDelay(float fc) const final override

Get filter group delay.

inline virtual void reset(void) final override

Reset filter state.

inline virtual void execute(const T *x, T *y, size_t n) final override

Execute the filter.

inline virtual float getDelay(void) const final override

Get filter delay.

inline virtual const std::vector<C> &getTaps(void) const final override

Get taps.

inline virtual void setTaps(const std::vector<C> &taps) final override

Set taps.

Protected Functions

inline void in(T x)

Add a sample to the FIR window.

inline 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
inline FIR(FIR &&f)
inline FIR(const std::vector<C> &h)
inline virtual ~FIR()
inline FIR &operator=(const std::vector<C> &h)
inline FIR &operator=(FIR &&f)
FIR &operator=(const FIR&) = delete
inline virtual float getGroupDelay(float fc) const final override

Get filter group delay.

inline virtual void reset(void) final override

Reset filter state.

inline virtual void execute(const I *in, O *out, size_t n) final override

Execute the filter.

inline virtual float getDelay(void) const final override

Get filter delay.

inline virtual const std::vector<C> &getTaps(void) const final override

Get taps.

inline virtual void setTaps(const std::vector<C> &taps) final override

Set taps.

inline C getScale() const

Get output scaling for filter.

Returns

Scaling factor applied to each output sample

inline void setScale(C scale)

Set output scaling for filter.

Parameters

scale – Scaling factor applied to each output sample

inline 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
inline FIR(FIR &&f)
inline FIR(const std::vector<C> &taps)
inline virtual ~FIR()
inline FIR &operator=(const std::vector<C> &taps)
inline FIR &operator=(FIR &&f)
FIR &operator=(const FIR&) = delete
inline virtual float getGroupDelay(float fc) const final override

Get filter group delay.

inline virtual void reset(void) final override

Reset filter state.

inline virtual void execute(const C *in, C *out, size_t n) final override

Execute the filter.

inline virtual float getDelay(void) const final override

Get filter delay.

inline virtual const std::vector<C> &getTaps(void) const final override

Get taps.

inline virtual void setTaps(const std::vector<C> &taps) final override

Set taps.

inline C getScale() const
inline void setScale(C scale)
inline 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

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

Get enabled flagd.

inline void setEnabled(bool enabled)

Set enabled flag.

inline bool getAllowBroadcasts(void)

Get flag indicating whether or not bradcast packets are allowed.

inline void setAllowBroadcasts(bool allowed)

Set flag indicating whether or not bradcast packets are allowed.

inline Set getAllowedPorts(void)

Get allowed ports.

inline void setAllowedPorts(const Set &allowed)

Set allowed ports.

Protected Functions

inline virtual bool process(T &pkt) override

Filter a packet.

Protected Attributes

std::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

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

Protected Attributes

const char *msg_

The FLAC error message.

class FLACMemoryDecoder : public Stream

Subclassed by BufferDecoder, PyArrayDecoder

Public Functions

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

Protected Functions

virtual size_t size(void) = 0

Get size of buffer holding decoded data.

virtual fc32_t *data(void) = 0

Get pointer to buffer holding decoded data.

virtual void resize(size_t size) = 0

Resize buffer holding decoded data.

inline void check(bool ok)
inline void checkInit(FLAC__StreamDecoderInitStatus status)
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() = default
virtual ~FLACMemoryEncoder() = default
virtual void encode(const fc32_t *sig, size_t n)

Protected Functions

virtual size_t size(void) = 0

Get size of buffer holding encoded.

virtual char *data(void) = 0

Get pointer to buffer holding encoded.

virtual void resize(size_t size) = 0

Resize buffer holding encoded data.

inline void check(bool ok)
inline void checkInit(FLAC__StreamEncoderInitStatus status)
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_seq

Set if the packet is sequenced.

uint8_t has_control

Set if the packet has control data.

uint8_t compressed

Set if the packet is compressed.

uint8_t team

Unused flags.

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

A PHY thats uses the liquid-usrp flexframegen code.

Public Functions

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

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

Returns

The minimum RX oversample rate

inline virtual unsigned getMinTXRateOversample(void) const override

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

Returns

The minimum TX oversample rate

Protected Functions

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

Create a Demodulator for this PHY.

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

Create a Modulator for this PHY.

inline virtual 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

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

Is a frame currently being demodulated?

Returns

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

inline virtual void print(void) override

Print description of demodulator to stdout.

inline virtual void reset(void) override

Reset demodulator state.

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

Demodulate samples.

Protected Functions

inline virtual void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

inline virtual 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

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

Print description of modulator to stdout.

inline virtual 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

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

Return size of assembled data.

inline virtual size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

inline virtual 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

static constexpr size_t NGEN = 2

Protected Functions

inline virtual void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

inline virtual 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

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

Get measurement period.

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

Get start time.

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

Set start time.

inline FlowStatsMap getSources(bool reset)

Return flow source statistics.

inline FlowStatsMap getSinks(bool reset)

Return flow sink statistics.

inline 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, std::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.

std::mutex sources_mutex_

Mutex for sources.

FlowStatsMap sources_

Flow source info.

std::mutex sinks_mutex_

Mutex for sinks.

FlowStatsMap sinks_

Flow sink info.

std::mutex mandates_mutex_

Mandates mutex.

MandateMap mandates_

Mandates.

struct FlowStats
#include <FlowPerformance.hh>

Statistics for a single flow.

Public Functions

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

Record statistics for a packet.

inline 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

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

Protected Attributes

std::atomic<float> g_
struct GPSLocation

Public Functions

inline GPSLocation()

Public Members

double lat

Latitude.

double lon

Longitude.

double alt

Altitude.

double timestamp

Timestamp of last update.

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

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

Protected Functions

inline void make_heap()

Construct a heap from unordered elements.

inline void remove_heap(size_type index)

Remove element at the given index.

inline void update_heap(size_type index)

Move item at given index to proper heap position.

inline void up_heap(size_type index)

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

inline void down_heap(size_type index)

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

inline void swap_heap(size_type index1, size_type index2)

Swap the elements at the given heap indices.

Protected Attributes

Container c

Protected Static Functions

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

Public Members

bool is_gateway

Set to true if this is the gateway node.

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

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

Public Functions

IIR() = default
virtual ~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
inline IIR(IIR &&f)
inline IIR(const C *b, unsigned Nb, const C *a, unsigned Na)

Initialize filter with feedforward and feedback constants.

inline IIR(const C *sos, unsigned N)

Initialize filter with second-order-sections.

inline virtual ~IIR()
IIR &operator=(const IIR&) = delete
IIR &operator=(IIR&&) = delete
inline virtual float getGroupDelay(float fc) const final override

Get filter group delay.

inline virtual void reset(void) final override

Reset filter state.

inline void execute(const C *in, C *out, size_t n) final override
inline 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
inline IIR(IIR &&f)
inline IIR(const C *b, unsigned Nb, const C *a, unsigned Na)
inline IIR(const C *sos, unsigned N)
inline virtual ~IIR()
IIR &operator=(const IIR&) = delete
IIR &operator=(IIR&&) = delete
inline virtual float getGroupDelay(float fc) const final override

Get filter group delay.

inline virtual void reset(void) final override

Reset filter state.

inline virtual void execute(const C *in, C *out, size_t n) final override

Execute the filter.

inline 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 assigned_seq

Set if the packet has an assigned sequence number.

uint8_t need_selective_ack

Set if the packet needs a selective ACK.

uint8_t has_selective_ack

Set if the packet contains a selective ACK.

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

A buffer of IQ samples.

Public Functions

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

Wait for the buffer to start filling.

inline void zero(void)

Zero all data in the buffer.

inline void gain(const float g)

Apply a gain.

Parameters

g – The multiplicative gain.

inline void power(float &peak_power, float &avg_power)

Compute peak and average power.

Public Members

std::optional<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

inline void reset(size_t nchannels)

Public Members

WallClock::time_point start

Start of load measurement period.

WallClock::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

Logging sources.

Values:

enumerator kSlots
enumerator kTXRecords
enumerator kRecvPackets
enumerator kRecvSymbols
enumerator kSentPackets
enumerator kSentIQ
enumerator kEvents
enumerator kARQEvents

Public Functions

Logger(const WallClock::time_point &t_start, const MonoClock::time_point &mono_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)
inline bool getCollectSource(Source src)
inline 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, int64_t val)
void setAttribute(const std::string &name, uint64_t val)
void setAttribute(const std::string &name, double val)
inline void logSlot(const std::shared_ptr<IQBuf> &buf)
inline void logTXRecord(const std::optional<MonoClock::time_point> &t, size_t nsamples, double fs)
inline void logSnapshot(std::shared_ptr<Snapshot> snapshot)
inline void logRecv(const std::shared_ptr<RadioPacket> &pkt)
inline void logSend(const std::shared_ptr<NetPacket> &pkt)
inline void logLinkLayerDrop(const MonoClock::time_point &t, const std::shared_ptr<NetPacket> &pkt)
inline void logQueueDrop(const MonoClock::time_point &t, const std::shared_ptr<NetPacket> &pkt)
inline void logEvent(const MonoClock::time_point &t, const std::string &event)
inline void logEvent(const MonoClock::time_point &t, std::unique_ptr<char[]> event)
inline void logSendNAK(NodeId node, Seq seq)
inline void logSendSACK(const std::shared_ptr<NetPacket> &pkt, NodeId node, Seq unack)
inline void logNAK(const MonoClock::time_point &t, NodeId node, Seq seq)
inline void logRetransmissionNAK(const MonoClock::time_point &t, NodeId node, Seq seq)
inline void logSACK(const std::shared_ptr<RadioPacket> &pkt, NodeId node, Seq unack)
inline void logSNAK(const MonoClock::time_point &t, NodeId node, Seq seq)
inline void logACKTimeout(const MonoClock::time_point &t, NodeId node, Seq seq)

Private Types

enum DropType

Values:

enumerator kNotDropped
enumerator kLinkLayerDrop
enumerator kQueueDrop
enum ARQEventType

Values:

enumerator kSendNAK
enumerator kSendSACK
enumerator kNAK
enumerator kRetransmissionNAK
enumerator kSACK
enumerator kSNAK
enumerator kACKTimeout

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_(const IQBuf &buf)
void logTXRecord_(const std::optional<MonoClock::time_point> &t, size_t nsamples, double fs)
void logSnapshot_(std::shared_ptr<Snapshot> snapshot)
void logRecv_(RadioPacket &pkt)
void logSend_(const MonoClock::time_point &t, DropType dropped, NetPacket &pkt)
void logEvent_(const MonoClock::time_point &t, char *event)
void logARQEvent_(const MonoClock::time_point &t, ARQEventType type, NodeId node, Seq seq)
void logARQSACKEvent_(Packet &pkt, ARQEventType type, NodeId node, Seq unack)

Private Members

bool is_open_
H5::H5File file_
std::unique_ptr<ExtensibleDataSet> slots_
std::unique_ptr<ExtensibleDataSet> tx_records_
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_
std::unique_ptr<ExtensibleDataSet> arq_event_
WallClock::time_point t_start_
MonoClock::time_point mono_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)
virtual ~MAC() = default
MAC() = delete
MAC(const MAC&) = delete
MAC &operator=(const MAC&) = delete
MAC &operator=(MAC&&) = delete
inline const std::shared_ptr<Channelizer> &getChannelizer(void)

Get the MAC’s channelizer.

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

Get the MAC’s synthesizer.

inline virtual bool canTransmit(void) const

Can this MAC transmit.

Returns

true if we can transmit, false otherwise

inline virtual const Schedule &getSchedule(void) const

Get MAC schedule.

inline virtual void setSchedule(const Schedule &schedule)

Set MAC schedule.

inline virtual void setSchedule(const Schedule::sched_type &schedule)

Set MAC schedule.

inline virtual void setMinChannelBandwidth(double min_bw)

Set minimum channel bandwidth.

inline Load getLoad(void)

Get current load.

inline Load popLoad(void)

Get current load and reset load counters.

virtual void reconfigure(void)

Reconfigure the MAC when after parameters change.

virtual 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.

std::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
inline 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
inline bool isThroughput() const

Is this a throughput mandate?

inline 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
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

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

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

inline bool getBonusPhase(void) const

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

inline void setBonusPhase(bool bonus_phase)

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

inline QueueType getFlowQueueType(FlowUID flow_uid) const

Get flow queue type.

inline void setFlowQueueType(FlowUID flow_uid, QueueType qtype)

Set flow queue priority.

inline Priority getFlowQueuePriority(FlowUID flow_uid) const

Get flow queue priority.

inline void setFlowQueuePriority(FlowUID flow_uid, const Priority &priority)

Set flow queue priority.

inline MandateMap getMandates(void)

Get mandates.

inline void setMandates(const MandateMap &mandates)

Set mandates.

inline QueuePriorities getQueuePriorities(void)

Get queue priorities.

inline virtual void reset(void) override

Reset queue to empty state.

inline virtual void push(T &&pkt) override

Push an element onto the queue.

inline virtual void push_hi(T &&pkt) override

Push an element onto the high-priority queue.

inline virtual void repush(T &&pkt) override

Re-queue an element.

inline virtual bool pop(T &pkt) override

Pop an element from the queue.

inline virtual void kick(void) override

Kick the queue.

inline virtual void stop(void) override

Stop processing queue elements.

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

Notify queue of new MCS.

inline virtual void setTransmissionDelay(double t) override

Set transmission delay.

inline virtual double getTransmissionDelay(void) const override

Get transmission delay.

Public Static Attributes

static constexpr Priority kHiQueuePriority = Priority(100, 0.0)

Priority for high-priority queue.

static constexpr Priority kDefaultFlowQueuePriority = Priority(1, 0.0)

Default priority for per-flow queue.

static constexpr Priority kDefaultQueuePriority = Priority(0, 0.0)

Priority for default queue.

static constexpr double kMaxTokenFactor = 2.0

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

static 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

inline void add_queue(SubQueue &subq)

Add a new queue.

inline void sort_queues(void)
inline 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.

mutable std::mutex m_

Mutex protecting the queues.

std::condition_variable cond_

Condition variable protecting the queue.

std::set<NodeId> seen_nodes_

Flows on which we have seen traffic.

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
virtual ~MCS() = default
virtual float getRate(void) const = 0

Get approximate rate in bps.

virtual 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

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

Get approximate rate in bps.

inline virtual 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

inline Mean()
inline explicit Mean(T initial_value)
inline virtual operator bool() const override

Does the estimator have a value?

inline virtual T operator*() const override

Return the value of the estimator.

inline virtual std::optional<T> value(void) const override

Return the value of the estimator.

inline virtual T value_or(T &&default_value) const override

Return the value of the estimator or a default.

inline virtual size_t size(void) const override

Return the number of samples used in the estimate.

inline void reset(T x)

Reset the estimator with an initial value.

inline virtual void update(T x) override

Update the estimator with a new value.

inline 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

inline uint16_t getMessageSize(void) const
inline uint32_t getFlowId(void) const
inline uint32_t getSequenceNumber(void) const
inline WallClock::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 dragonradio::signal::MixingRationalResampler : public dragonradio::signal::RationalResampler<T, C>
#include <Polyphase.hh>

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

Public Functions

inline 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.

inline 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
virtual ~MixingRationalResampler() = default
inline double getFreqShift(void)

Get frequency shift in radians.

inline 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.

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

Get mixed (bandpass) prototype filter taps.

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

Protected Functions

inline virtual 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 beginning of TX record.

size_t offset

Offset of start of packet from beginning of sample buffer.

size_t nsamples

Number of modulated samples.

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

inline ModPacketQueue()
~ModPacketQueue() = default
inline std::optional<size_t> getHighWaterMark(void) const
inline void setHighWaterMark(std::optional<size_t> high_water_mark)
inline void stop(void)
inline size_t try_pop(container_type &mpkts, size_t max_samples, bool overfill)
inline size_t try_pop(container_type &mpkts)
inline size_t pop(container_type &mpkts)
inline void push(T &&mpkt)
inline 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
virtual ~Modulator() = default
inline virtual unsigned getOversampleRate(void)
virtual void print(void) = 0

Print description of modulator to stdout.

virtual 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

virtual size_t assembledSize(void) = 0

Return size of assembled data.

virtual size_t maxModulatedSamples(void) = 0

Return maximum number of modulated samples that will be produced.

virtual 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

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

Protected Functions

virtual void reconfigureHeader(void) = 0

Reconfigure modulator based on new header parameters.

virtual 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 : public Clock
#include <Clock.hh>

A monotonic 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 Static Functions

static inline time_point now() noexcept

Get the current time. Guaranteed to be monotonic.

Public Static Attributes

static const bool is_steady = true
struct MPStats
#include <FlowPerformance.hh>

Statistics for a single measurement period.

Public Functions

inline 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

inline 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.

Parameters
  • mpkt – The modulated packet

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

Returns

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

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

Set current IQ buffer to be upsampled.

Parameters

iqbuf

inline size_t upsampledSize(size_t n)

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

Returns

Number of samples in upsampled signal.

size_t upsample(void)

Perform frequency-domain upsampling on current IQ buffer.

Returns

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

std::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)
virtual ~MultichannelSynthesizer()
virtual void modulate(const std::shared_ptr<Slot> &slot) override

Modulate a slot.

virtual 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.

virtual void stop(void) override

Stop modulating.

virtual void reconfigure(void) override

Reconfigure for new TX parameters.

Public Static Attributes

static 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.

static constexpr unsigned V = 4

Overlap factor.

static constexpr auto N = Upsampler::N
static constexpr auto L = Upsampler::L
static 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.

std::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

inline 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

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

Public Functions

inline 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
inline MultiStageResampler(MultiStageResampler &&resamp)
inline virtual ~MultiStageResampler()
MultiStageResampler &operator=(const MultiStageResampler&) = delete
inline MultiStageResampler &operator=(MultiStageResampler &&resamp)
inline virtual double getRate(void) const final override
inline virtual double getDelay(void) const final override
inline virtual size_t neededOut(size_t count) const final override
inline virtual void reset(void) final override
virtual size_t resample(const std::complex<float> *in, size_t count, std::complex<float> *out) final override
inline void print(void)
size_t resample(const I *in, size_t count, O *out) = 0

Protected Attributes

msresamp_crcf resamp_
double rate_
double delay_
class NCO

Subclassed by liquid::BaseNCO, TableNCO

Public Functions

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

Get frequency in radians per sample.

virtual void setFrequency(double dtheta) = 0

Set frequency in radians per sample.

virtual double getPhase(void) = 0

Get phase in radians.

virtual void setPhase(double theta) = 0

Set phase in radians.

virtual void reset(double dtheta) = 0

Reset NCO state with given frequency in radians per sample.

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

Mix a single sample up.

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

Mix a single sample down.

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

Mix a signal up.

virtual 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

inline NCO(double dtheta)
NCO() = delete
NCO(const NCO&) = delete
NCO(NCO&&) = default
inline virtual ~NCO()
NCO &operator=(const NCO&) = delete
NCO &operator=(NCO&&) = default
class NetFilter : public Processor<std::shared_ptr<NetPacket>>

Public Functions

inline NetFilter(std::shared_ptr<RadioNet> radionet, 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)
virtual ~NetFilter() = default

Protected Functions

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

Private Members

std::shared_ptr<RadioNet> radionet_

The Net we use to filter packets.

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
inline explicit NetPacket(size_t n)
inline bool deadlinePassed(const MonoClock::time_point &now)

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

inline bool shouldDrop(const MonoClock::time_point &now)

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

void appendTimestamp(TimestampSeq tseq)

Append a Timestamp control message to a packet.

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.

float fc

Center frequency (Hz)

float bw

Bandwidth (Hz)

unsigned nretrans

Number of retransmissions.

std::optional<unsigned> mp

Measurement period to which this packet belongs.

std::optional<TimestampSeq> timestamp_seq

Packet timestamp.

size_t offset

Offset of start of packet from beginning of sample buffer.

size_t nsamples

Number of modulated samples.

std::shared_ptr<IQBuf> samples

IQ sample buffer containing modulated packet.

WallClock::time_point tuntap_timestamp

Wall-clock time when packet was read from tun/tap.

MonoClock::time_point enqueue_timestamp

Time when packet was enqueued.

MonoClock::time_point dequeue_start_timestamp

Dequeue start timestamp.

MonoClock::time_point dequeue_end_timestamp

Dequeue end timestamp.

MonoClock::time_point llc_timestamp

Time when packet exited LLC.

MonoClock::time_point mod_start_timestamp

Modulation start timestamp.

MonoClock::time_point mod_end_timestamp

Modulation end timestamp.

MonoClock::time_point tx_timestamp

Packet transmission timestamp.

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

A PHY thats uses the liquid-usrp flexframegen code.

Public Functions

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

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

Returns

The minimum RX oversample rate

inline virtual unsigned getMinTXRateOversample(void) const override

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

Returns

The minimum TX oversample rate

Protected Functions

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

Create a Demodulator for this PHY.

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

Create a Modulator for this PHY.

inline virtual 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

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

Is a frame currently being demodulated?

Returns

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

inline virtual void print(void) override

Print description of demodulator to stdout.

inline virtual void reset(void) override

Reset demodulator state.

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

Demodulate samples.

Protected Functions

inline virtual void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

inline virtual 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

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

Print description of modulator to stdout.

inline virtual 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

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

Return size of assembled data.

inline virtual size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

inline virtual 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

static constexpr size_t NGEN = 2

Protected Functions

inline virtual void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

inline virtual void reconfigurePayload(void) override

Reconfigure modulator based on new payload parameters.

Protected Attributes

flexframegen fg_
struct Node

Public Functions

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

Set soft TX gain.

Parameters

dB – The soft gain (dBFS).

inline float getSoftTXGain(void) const

Get soft TX gain (dBFS).

Public Members

const NodeId id

Node ID.

GPSLocation loc

Location.

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_map timestamps_sent

Timestamp sequences sent by this node.

timestamp_map timestamps_recv

Timestamp sequences received from this node.

timestampseq_set timestamps_echoed

Echoed timestamp sequences.

timestamps_map 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
virtual ~Noop() = default

Protected Functions

inline virtual 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

inline 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.

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

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

Returns

The minimum RX oversample rate

inline virtual unsigned getMinTXRateOversample(void) const override

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

Returns

The minimum TX oversample rate

inline liquid::OFDMSubcarriers getSubcarriers(void) const

Protected Functions

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

Create a Demodulator for this PHY.

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

Create a Modulator for this PHY.

inline virtual 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

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

Is a frame currently being demodulated?

Returns

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

inline virtual void print(void) override

Print description of demodulator to stdout.

inline virtual void reset(void) override

Reset demodulator state.

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

Demodulate samples.

Protected Functions

inline virtual void reconfigureHeader(void) override

Reconfigure demodulator based on new header parameters.

inline virtual 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

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

Print description of modulator to stdout.

inline virtual 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

inline virtual size_t assembledSize(void) override

Return size of assembled data.

inline virtual size_t maxModulatedSamples(void) override

Return maximum number of modulated samples that will be produced.

inline virtual 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

inline virtual void reconfigureHeader(void) override

Reconfigure modulator based on new header parameters.

inline virtual 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

explicit 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

inline OverlapTDChannelDemodulator(PHY &phy, const Channel &channel, const std::vector<C> &taps, double rx_rate)
virtual ~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.

dragonradio::signal::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)
virtual ~OverlapTDChannelizer()
virtual void setChannels(const Channels &channels) override

Set channels.

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

Add an IQ buffer to demodulate.

Parameters

buf – The IQ samples to demodulate

virtual void reconfigure(void) override

Reconfigure for new RX parameters.

inline double getPrevDemod(void)

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

inline void setPrevDemod(double sec)

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

inline double getCurDemod(void)

Return the portion of the current slot that we demodulate.

inline void setCurDemod(double sec)

Set the portion of the current slot that we demodulate.

inline bool getEnforceOrdering(void)

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

inline void setEnforceOrdering(bool enforce)

Set whether or not demodulation queue enforces packet order.

void stop(void)

Stop demodulating.

Private Functions

inline 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.

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.

Returns

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.

void nextWindow(void)

Move to the next demodulation window.

Private Members

double prev_demod_

What portion of the end of the previous slot should we demodulate (sec)?

size_t prev_demod_samps_

How many samples from the end of the previous slot should we demodulate?

double cur_demod_

What portion of the current slot should we demodulate (sec)?

size_t cur_demod_samps_

How many samples from the current slot should we demodulate?

bool enforce_ordering_

Should packets be output in the order they were actually received? Setting this to true increases latency!

bool done_

Flag that is true when we should finish processing.

RadioPacketQueue radio_q_

Queue of radio packets.

std::mutex iq_mutex_

Mutex protecting the queue of IQ buffers.

std::condition_variable iq_cond_

Condition variable protecting the queue of IQ buffers.

size_t iq_size_

The number of items in the queue of IQ buffers.

Channels::size_type iq_next_channel_

The next channel to demodulate.

std::list<std::shared_ptr<IQBuf>> iq_

The queue of IQ buffers.

std::vector<std::atomic<bool>> demod_reconfigure_

Reconfiguration flags.

std::vector<std::thread> demod_threads_

Demodulation worker threads.

std::thread net_thread_

Network send thread.

std::shared_ptr<Logger> logger_

A reference to the global logger.

struct Packet : public buffer<unsigned char>
#include <Packet.hh>

A packet.

Subclassed by NetPacket, RadioPacket

Public Functions

Packet() = delete
inline Packet(const Header &hdr_)
inline explicit Packet(size_t n)
inline Packet(const Header &hdr_, unsigned char *data, size_t n)
inline ExtendedHeader &ehdr(void)

Get extended header.

inline const ExtendedHeader &ehdr(void) const

Get extended header.

inline bool integrityIntact(void) const

Check packet integrity.

uint16_t getControlLen(void) const

Get length of control info.

void setControlLen(uint16_t ctrl_len)

Set length of control info.

inline void clearControl(void)

Clear control messages contained in packet.

void appendControl(const ControlMsg &ctrl)

Append a control message to a packet.

void removeLastControl(ControlMsg::Type type)

Remove last control message from a packet.

Blindly remove the last control message from a packet, assuming in has type type.

void appendHello(const ControlMsg::Hello &hello)

Append a Hello control message to a packet.

void appendPing(const ControlMsg::Ping &ping)

Append a Ping control message to a packet.

void appendTimestampSent(TimestampSeq tseq, const MonoClock::time_point &t_recv)

Append a Timestamp Sent control message to a packet.

void appendTimestampRecv(NodeId node_id, TimestampSeq tseq, const MonoClock::time_point &t_recv)

Append a Timestamp Received control message to a packet.

void appendShortTermReceiverStats(float short_evm, float short_rssi)

Append short-term receiver statistics control message to a packet.

void appendLongTermReceiverStats(float long_evm, float long_rssi)

Append long-term receiver statistics control message to a packet.

void appendNak(const Seq &seq)

Append a NAK control message to a packet.

void appendSelectiveAck(const Seq &begin, const Seq &end)

Append a selective ACK control message to a packet.

void appendSetUnack(const Seq &unack)

Append a “set unack” control message to a packet.

inline iterator begin() const

Return iterator to beginning control data.

inline iterator end() const

Return iterator to end of control data.

inline const struct ether_header *getEthernetHdr(void) const

Get Ethernet header.

Returns

A pointer to the Ethernet header or nullptr if this is not an Ethernet packet

inline const struct ip *getIPHdr(void) const

Get IP header.

Returns

A pointer to the IP header or nullptr if this is not an IP packet

inline struct ip *getIPHdr(void)

Get IP header.

Returns

A pointer to the IP header or nullptr if this is not an IP packet

inline const struct udphdr *getUDPHdr(void) const

Get UDP header.

Returns

A pointer to the UDP header or nullptr if this is not a UDP packet

inline struct udphdr *getUDPHdr(void)

Get UDP header.

Returns

A pointer to the UDP header or nullptr if this is not a UDP packet

inline const struct tcphdr *getTCPHdr(void) const

Get TCP header.

Returns

A pointer to the TCP header or nullptr if this is not a TCP packet

inline struct tcphdr *getTCPHdr(void)

Get TCP header.

Returns

A pointer to the TCP header or nullptr if this is not a TCP packet

const struct mgenhdr *getMGENHdr(void) const

Get MGEN header.

Returns

A pointer to the MGEN header or nullptr if this is not a MGEN packet

inline struct mgenhdr *getMGENHdr(void)

Get MGEN header.

Returns

A pointer to the MGEN header or nullptr if this is not a MGEN packet

size_t getPayloadSize(void) const

Get payload size.

Returns

The size of the data portion of a UDP or TCP packet.

inline bool isIP(void) const

Return true if this is an IP packet, false otherwise.

inline bool isIPProto(uint8_t proto) const

Return true if this is an IP packet of the specified IP protocol, false otherwise.

inline bool isTCP(void) const

Return true if this is a TCP packet, false otherwise.

inline bool isUDP(void) const

Return true if this is a UDP packet, false otherwise.

void initMGENInfo(void)

Initialize MGEN info.

Initialize flow and MGEN sequence number info

Public Members

Header hdr

Header.

std::optional<FlowUID> flow_uid

Flow UID.

std::optional<uint32_t> mgen_flow_uid

MGEN flow UID.

std::optional<uint32_t> mgen_seqno

MGEN sequence number.

MonoClock::time_point timestamp

Packet timestamp.

This timestamp is the (monotonic) time at which the packet entered the system. For network packets, it is the time the packet was read from the tun/tap interface, and for radio packets, it is the time at which the packet’s IQ data was read by the radio.

std::optional<WallClock::time_point> wall_timestamp

Wall-clock packet timestamp.

This timestamp is the wall-clock time at which the packet was created. Unlike the timestamp field, this field represents the time at which the packet was originally sent.

size_t payload_size

Payload size.

Returns

The size of the data portion of a UDP or TCP packet.

struct Packet::InternalFlags internal_flags
class PacketCompressor : public Element
#include <PacketCompressor.hh>

A packet compression element.

Public Functions

PacketCompressor() = delete
inline PacketCompressor(bool enabled, in_addr_t int_net, in_addr_t int_netmask, in_addr_t ext_net, in_addr_t ext_netmask)
virtual ~PacketCompressor() = default
inline bool getEnabled(void)

Get enabled flag.

inline void setEnabled(bool enabled)

Set enabled flag.

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)

Process a network packet.

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

Process a radio packet.

void compress(NetPacket &pkt)

Compress a network packet.

void decompress(RadioPacket &pkt)

Decompress a radio packet.

Protected Attributes

bool enabled_

Is packet compression enabled?

in_addr_t int_net_

Internal IP network.

in_addr_t int_netmask_

Internal IP network mask.

in_addr_t ext_net_

External IP network.

in_addr_t ext_netmask_

External IP network mask.

class liquid::OFDM::PacketDemodulator : public liquid::PHY::PacketDemodulator, protected liquid::OFDMDemodulator
#include <OFDM.hh>

Demodulate IQ data using a liquid-usrp flexframe.

Public Functions

inline PacketDemodulator(OFDM &phy)
virtual ~PacketDemodulator() = default
inline virtual bool isFrameOpen(void) final override

Is a frame currently being demodulated?

Returns

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

class liquid::FlexFrame::PacketDemodulator : public liquid::PHY::PacketDemodulator, protected liquid::FlexFrameDemodulator
#include <FlexFrame.hh>

Demodulate IQ data using a liquid-usrp flexframe.

Public Functions

inline PacketDemodulator(FlexFrame &phy)
virtual ~PacketDemodulator() = default
inline virtual bool isFrameOpen(void) final override

Is a frame currently being demodulated?

Returns

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

class liquid::NewFlexFrame::PacketDemodulator : public liquid::PHY::PacketDemodulator, protected liquid::NewFlexFrameDemodulator
#include <NewFlexFrame.hh>

Demodulate IQ data using a liquid-usrp flexframe.

Public Functions

inline PacketDemodulator(NewFlexFrame &phy)
virtual ~PacketDemodulator() = default
inline virtual bool isFrameOpen(void) final override

Is a frame currently being demodulated?

Returns

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

class PHY::PacketDemodulator
#include <PHY.hh>

Demodulate packets.

Subclassed by liquid::PHY::PacketDemodulator, PyPacketDemodulator

Public Types

using callback_type = std::function<void(std::shared_ptr<RadioPacket>&&)>

Public Functions

inline PacketDemodulator(PHY &phy)
virtual ~PacketDemodulator() = default
inline void setCallback(callback_type callback)

Set demodulation callback.

virtual bool isFrameOpen(void) = 0

Is a frame currently being demodulated?

Returns

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

virtual void reset(const Channel &channel) = 0

Reset the internal state of the demodulator.

Parameters

channel – The channel being demodulated.

virtual void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, size_t delay, float rate, 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!

  • delayFilter delay

  • rate – The rate of the resampler applied before data is passed to the demodulator.

  • rx_rate – The RX rate (Hz).

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

Demodulate IQ samples.

Parameters
  • data – The IQ data to demodulate

  • count – The number of samples to demodulate

Protected Attributes

PHY &phy_

Our PHY.

callback_type callback_

Demodulation callback.

class liquid::PHY::PacketDemodulator : public PHY::PacketDemodulator, protected virtual liquid::Demodulator

Subclassed by liquid::FlexFrame::PacketDemodulator, liquid::NewFlexFrame::PacketDemodulator, liquid::OFDM::PacketDemodulator

Public Functions

PacketDemodulator(PHY &phy, const MCS &header_mcs, bool soft_header, bool soft_payload)
virtual ~PacketDemodulator() = default
PacketDemodulator(const PacketDemodulator&) = delete
PacketDemodulator(PacketDemodulator&&) = delete
PacketDemodulator &operator=(const PacketDemodulator&) = delete
PacketDemodulator &operator=(PacketDemodulator&&) = delete
virtual void reset(const Channel &channel) final override

Reset the internal state of the demodulator.

Parameters

channel – The channel being demodulated.

virtual void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, size_t delay, float rate, float rx_rate) final override

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!

  • delayFilter delay

  • rate – The rate of the resampler applied before data is passed to the demodulator.

  • rx_rate – The RX rate (Hz).

inline virtual void demodulate(const std::complex<float> *data, size_t count) final override

Demodulate IQ samples.

Parameters
  • data – The IQ data to demodulate

  • count – The number of samples to demodulate

Protected Functions

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

Callback function for liquid demodulator.

Protected Attributes

Channel channel_

The channel being demodulated.

ssize_t delay_

Filter delay.

double resamp_rate_

Rate conversion from samples to full RX rate.

This is used internally purely to properly timestamp packets.

double rx_rate_

RX rate (Hz)

unsigned int internal_oversample_fact_

Internal resampling factor.

This is the factor by which the PHY internally oversamples, i.e., the samples seen by the Liquid demodulator are decimated by this amount. We need this quantity in order to properly track demod_off_ and friends.

MonoClock::time_point timestamp_

Timestamp of current slot.

std::optional<ssize_t> snapshot_off_

Snapshot offset of current slot.

ssize_t offset_

Sample offset of first provided sample from slot.

unsigned sample_start_

The sample number of the sample at offset in current slot.

unsigned sample_end_

The sample number of the last sample in current slot.

unsigned sample_

The sample counter.

std::shared_ptr<Logger> logger_

A reference to the global logger.

class liquid::FlexFrame::PacketModulator : public liquid::PHY::PacketModulator, protected liquid::FlexFrameModulator
#include <FlexFrame.hh>

Modulate IQ data using a liquid-usrp flexframe.

Public Functions

inline PacketModulator(FlexFrame &phy)
virtual ~PacketModulator() = default
class liquid::OFDM::PacketModulator : public liquid::PHY::PacketModulator, protected liquid::OFDMModulator
#include <OFDM.hh>

Modulate IQ data using a liquid-usrp ofdmflexframegen.

Public Functions

inline PacketModulator(OFDM &phy)
virtual ~PacketModulator() = default
class PHY::PacketModulator
#include <PHY.hh>

Modulate packets.

Subclassed by liquid::PHY::PacketModulator, PyPacketModulator

Public Functions

inline PacketModulator(PHY &phy)
virtual ~PacketModulator() = default
virtual void modulate(std::shared_ptr<NetPacket> pkt, const float gain, ModPacket &mpkt) = 0

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gain – Soft (multiplicative) gain to apply to modulated signal.

  • mpkt – The ModPacket in which to place modulated samples.

Protected Attributes

PHY &phy_

Our PHY.

class liquid::NewFlexFrame::PacketModulator : public liquid::PHY::PacketModulator, protected liquid::NewFlexFrameModulator
#include <NewFlexFrame.hh>

Modulate IQ data using a liquid-usrp flexframe.

Public Functions

inline PacketModulator(NewFlexFrame &phy)
virtual ~PacketModulator() = default
class liquid::PHY::PacketModulator : public PHY::PacketModulator, protected virtual liquid::Modulator

Subclassed by liquid::FlexFrame::PacketModulator, liquid::NewFlexFrame::PacketModulator, liquid::OFDM::PacketModulator

Public Functions

inline PacketModulator(PHY &phy, const MCS &header_mcs)
virtual ~PacketModulator() = default
PacketModulator(const PacketModulator&) = delete
PacketModulator(PacketModulator&&) = delete
PacketModulator &operator=(const PacketModulator&) = delete
PacketModulator &operator=(PacketModulator&&) = delete
virtual void modulate(std::shared_ptr<NetPacket> pkt, const float g, ModPacket &mpkt) final override

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gain – Soft (multiplicative) gain to apply to modulated signal.

  • mpkt – The ModPacket in which to place modulated samples.

struct PacketRecvEntry

Log entry for received packets.

Public Members

double slot_timestamp

Timestamp of the slot in which the packet occurred.

If the packet spans two slots, this is the timestamp of the first slot.

double timestamp

Timestamp of packet reception.

double mono_timestamp

Monotonic clock timestamp of packet reception.

int32_t start_samples

Offset (in samples) from timestamp slot to start of frame.

int32_t end_samples

Offset (in samples) from timestamp slot to end of frame.

uint8_t header_valid

Was header valid?

uint8_t payload_valid

Was payload valid?

uint8_t curhop

Packet current hop.

uint8_t nexthop

Packet next hop.

uint16_t seq

Packet sequence number.

uint8_t flags

Packet header flags.

uint8_t src

Packet source.

uint8_t dest

Packet destination.

uint16_t ack

ACK’ed sequence number.

uint16_t data_len

Size of data portion of packet (bytes).

uint32_t mgen_flow_uid

MGEN flow UID.

uint32_t mgen_seqno

MGEN sequence number.

uint8_t mcsidx

MCS Index.

float evm

EVM [dB].

float rssi

RSSI [dB].

float cfo

CFO [f/Fs].

float fc

Center frequency [Hz].

float bw

Bandwidth [Hz].

double demod_latency

Demodulation latency (sec)

double tuntap_latency

Latency between packet reception and write to tun/tap [sec].

uint32_t size

Size of packet (bytes).

hvl_t symbols

Raw IQ data.

struct PacketSendEntry

Log entry for sent packets.

Public Members

double timestamp

Timestamp of packet transmission.

double mono_timestamp

Monotonic clock timestamp of packet transmission.

double net_timestamp

Timestamp of packet reception from network.

uint8_t dropped

Was this packet dropped, and if so, why was it dropped?

uint16_t nretrans

Number of packet retransmissions.

uint8_t curhop

Packet current hop.

uint8_t nexthop

Packet next hop.

uint16_t seq

Packet sequence number.

uint8_t flags

Packet header flags.

uint8_t src

Packet source.

uint8_t dest

Packet destination.

uint16_t ack

ACK’ed sequence number.

uint16_t data_len

Size of data portion of packet (bytes).

uint32_t mgen_flow_uid

MGEN flow UID.

uint32_t mgen_seqno

MGEN sequence number.

uint8_t mcsidx

MCS Index.

float fc

Center frequency [Hz].

float bw

Bandwidth [Hz].

double tuntap_latency

Latency between packet creation and tun/tap read [sec].

double enqueue_latency

Enqueue latency [sec].

double dequeue_latency

Latency of just dequeue [sec].

double queue_latency

Queue latency [sec].

double llc_latency

LLC latency [sec].

double mod_latency

Latency of just modulation [sec].

double synth_latency

Latency from network read to modulation [sec].

uint32_t size

Size of packet (bytes).

int32_t nsamples

Number of IQ samples.

hvl_t iq_data

Raw IQ data.

template<class ChannelModulator>
class ParallelChannelSynthesizer : public ChannelSynthesizer
#include <ParallelChannelSynthesizer.hh>

A single-channel synthesizer.

Public Functions

ParallelChannelSynthesizer(std::shared_ptr<PHY> phy, double tx_rate, const Channels &channels, size_t nthreads)
virtual ~ParallelChannelSynthesizer()
virtual void stop(void) override

Stop modulating.

virtual void reconfigure(void) override

Reconfigure for new TX parameters.

Protected Functions

void modWorker(unsigned tid)

Thread modulating packets.

Protected Attributes

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.

std::vector<std::thread> mod_threads_

Threads running modWorker.

template<class T, class C>
class dragonradio::signal::Pfb
#include <Polyphase.hh>

A polyphase filter bank.

Subclassed by dragonradio::signal::Downsampler< T, C >, dragonradio::signal::RationalResampler< T, C >, dragonradio::signal::Upsampler< T, C >

Public Functions

inline Pfb(unsigned l, const std::vector<C> &taps)

Construct a polyphase filter bank.

Parameters
  • l – The number of channels

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

Pfb() = delete
virtual ~Pfb() = default
inline unsigned getNumChannels(void) const

Get the number of channels.

inline void setNumChannels(unsigned l)

Set the number of channels.

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

Get prototype filter taps.

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

Set prototype filter taps.

inline std::vector<std::vector<C>> getChannelTaps(void)

Get (reversed) per-channel taps.

Protected Types

using taps_t = std::vector<C, XSIMD_DEFAULT_ALLOCATOR(C)>

Protected Functions

inline virtual void reconfigure(void)

Reconfigure filter bank for current number of channels and taps.

Protected Attributes

unsigned l_

Number of channels.

std::vector<C>::size_type n_

Number of filter taps per channel.

std::vector<C> taps_

Filter taps.

std::vector<C> adjtaps_

Adjusted filter taps.

std::vector<taps_t> rtaps_

Per-channel filter taps, reversed.

Window<T> w_

Sample window.

class PHY
#include <PHY.hh>

A physical layer protocol that can provide a modulator and demodulator.

Subclassed by liquid::PHY, PyPHY

Public Functions

PHY() = default
virtual ~PHY() = default
virtual unsigned getMinRXRateOversample(void) const = 0

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

Returns

The minimum RX oversample rate

virtual unsigned getMinTXRateOversample(void) const = 0

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

Returns

The minimum TX oversample rate

virtual size_t getModulatedSize(mcsidx_t mcsidx, size_t n) = 0

Calculate size of modulated data.

virtual std::shared_ptr<PacketModulator> mkPacketModulator(void) = 0

Create a Modulator for this PHY.

virtual std::shared_ptr<PacketDemodulator> mkPacketDemodulator(void) = 0

Create a Demodulator for this PHY.

Public Members

std::vector<MCSEntry> mcs_table

MCS table.

Public Static Functions

static inline bool wantPacket(bool header_valid, const Header *h)

Return flag indicating whether or not we want the given packet.

We only demodulate packets destined for us unless we are collecting snapshots, in which case we demodulate everything so we can correctly record all known transmissions.

static inline std::shared_ptr<RadioPacket> mkRadioPacket(bool header_valid, bool payload_valid, const Header &h, size_t payload_len, unsigned char *payload_data)

Create a radio packet from a header and payload.

static inline NodeId getTeam()

Get this node’s ID.

static inline void setTeam(uint8_t team)

Set this node’s ID.

static inline NodeId getNodeId()

Get this node’s ID.

static inline void setNodeId(NodeId id)

Set this node’s ID.

static inline bool getLogInvalidHeaders()

Get whether or not invalid headers should be logged.

static inline void setLogInvalidHeaders(bool log)

Set whether or not invalid headers should be logged.

static inline void setSnapshotCollector(std::shared_ptr<SnapshotCollector> collector)

Set snapshot collector.

static inline void resetSnapshotCollector(void)

Reset snapshot collector.

Protected Static Attributes

static uint8_t team_ = 0

This node’s team.

static NodeId node_id_ = 0

This node’s ID.

static bool log_invalid_headers_ = false

Log invalid headers?

static std::shared_ptr<SnapshotCollector> snapshot_collector_

Snapshot collector.

class liquid::PHY : public PHY

Subclassed by liquid::FlexFrame, liquid::NewFlexFrame, liquid::OFDM

Public Functions

PHY(const MCS &header_mcs, const std::vector<std::pair<MCS, AutoGain>> &mcs_table, bool soft_header, bool soft_payload)
virtual ~PHY() = default
PHY() = delete
PHY(const PHY&) = delete
PHY(PHY&&) = delete
PHY &operator=(const PHY&) = delete
PHY &operator=(PHY&&) = delete
inline const MCS &getHeaderMCS() const

Return modulation and coding scheme used for headers.

inline bool getSoftHeader() const

Return flag indicating whether or not to use soft-decoding for headers.

inline bool getSoftPayload() const

Return flag indicating whether or not to use soft-decoding for payload.

virtual size_t getModulatedSize(mcsidx_t mcsidx, size_t n) override

Calculate size of modulated data.

Protected Functions

virtual std::unique_ptr<liquid::Modulator> mkLiquidModulator(void) = 0

Create underlying liquid modulator object.

Protected Attributes

MCS header_mcs_

Modulation and coding scheme for headers.

std::vector<liquid::MCS> mcs_table_

MCS table.

bool soft_header_

Flag indicating whether or not to use soft-decoding for headers.

bool soft_payload_

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

struct Ping
template<class D, class P, class T>
class Port
#include <Element.hh>

A port attached to an Element.

Public Functions

Port() = delete
virtual ~Port() = default
template<class T>
class Port<In, Pull, T> : public BasePort<In, Pull, T>
#include <Element.hh>

A pull input port.

Public Functions

Port() = delete
Port(const Port&) = delete
Port(Port&&) = delete
Port &operator=(const Port&) = delete
Port &operator=(Port&&) = delete
inline Port(Element &element, std::function<void(void)> connected, std::function<void(void)> disconnected)
inline virtual ~Port()
inline bool pull(T &pkt)

Pull a packet from the port.

inline void kick(void)

Kick the port.

inline void connect(std::shared_ptr<Element> element, Port<Out, Pull, T> *p)

Connect the port to an upstream pull port.

inline void disconnect(void)

Disconnect the port from its upstream pull port.

Protected Attributes

Port<Out, Pull, T> *upstream_

The upstream pull port.

std::shared_ptr<Element> upstream_element_

The upstream pull port’s Element.

template<class T>
class Port<In, Push, T> : public BasePort<In, Push, T>
#include <Element.hh>

A push input port.

Public Functions

Port() = delete
Port(const Port&) = delete
Port(Port&&) = delete
Port &operator=(const Port&) = delete
Port &operator=(Port&&) = delete
inline Port(Element &element, std::function<void(void)> connected, std::function<void(void)> disconnected, std::function<void(T&&)> send)
virtual ~Port() = default
inline void send(const T &pkt)

Send a packet to the port.

inline void send(T &&pkt)

Send a packet to the port.

Protected Attributes

std::function<void(T&&)> send_

Called to send a packet.

Friends

friend class Port< Out, Push, T >
template<class T>
class Port<Out, Pull, T> : public BasePort<Out, Pull, T>
#include <Element.hh>

A pull output port.

Public Functions

Port() = delete
Port(const Port&) = delete
Port(Port&&) = delete
Port &operator=(const Port&) = delete
Port &operator=(Port&&) = delete
inline Port(Element &element, std::function<void(void)> connected, std::function<void(void)> disconnected, std::function<bool(T&)> recv, std::function<void(void)> kick)
virtual ~Port() = default
inline bool recv(T &pkt)

Receive a packet from the port.

inline void kick(void)

Kick the port.

Protected Attributes

std::function<bool(T&)> recv_

Called to receive a packet.

std::function<void(void)> kick_

Called to kick.

Friends

friend class Port< In, Pull, T >
template<class T>
class Port<Out, Push, T> : public BasePort<Out, Push, T>
#include <Element.hh>

A push output port.

Public Functions

Port() = delete
Port(const Port&) = delete
Port(Port&&) = delete
Port &operator=(const Port&) = delete
Port &operator=(Port&&) = delete
inline Port(Element &element, std::function<void(void)> connected, std::function<void(void)> disconnected)
inline virtual ~Port()
inline void push(const T &pkt)

Push a packet out the port.

inline void push(T &&pkt)

Push a packet out the port.

inline void connect(std::shared_ptr<Element> element, Port<In, Push, T> *p)

Connect the port to a downstream push port.

inline void disconnect(void)

Disconnect the port from its downstream push port.

Protected Attributes

Port<In, Push, T> *downstream_

The downstream push port.

std::shared_ptr<Element> downstream_element_

The downstream push port’s Element.

template<class D, class P, class T>
struct PortWrapper

Public Functions

template<class U>
inline PortWrapper(std::shared_ptr<U> e, Port<D, P, T> *p)
~PortWrapper() = default
PortWrapper() = delete

Public Members

std::shared_ptr<Element> element
Port<D, P, T> *port
template<class T>
class Processor : public Element
#include <Processor.hh>

Packet-processor.

Subclassed by Firewall< T, Set >, Noop< T >

Public Functions

inline Processor()
virtual ~Processor() = default

Public Members

Port<In, Push, T> in

The processor’s packet input port.

Port<Out, Push, T> out

The processor’s packet output port.

Protected Functions

inline void push(T &&pkt)
virtual bool process(T &pkt) = 0
struct Pull
#include <Element.hh>

Type tag for pull ports.

struct Push
#include <Element.hh>

Type tag for push ports.

class PyArrayDecoder : public FLACMemoryDecoder

Public Functions

PyArrayDecoder() = default
virtual ~PyArrayDecoder() = default

Public Members

py::array_t<fc32_t> decoded

Protected Functions

inline virtual size_t size(void) override

Get size of buffer holding decoded data.

inline virtual fc32_t *data(void) override

Get pointer to buffer holding decoded data.

inline virtual void resize(size_t size) override

Resize buffer holding decoded data.

class PyArrayEncoder : public FLACMemoryEncoder

Public Functions

PyArrayEncoder() = default
virtual ~PyArrayEncoder() = default

Public Members

py::array_t<char> encoded

Protected Functions

inline virtual size_t size(void) override

Get size of buffer holding encoded.

inline virtual char *data(void) override

Get pointer to buffer holding encoded.

inline virtual void resize(size_t size) override

Resize buffer holding encoded data.

class PyPacketDemodulator : public PHY::PacketDemodulator

Public Functions

inline virtual bool isFrameOpen(void) override

Is a frame currently being demodulated?

Returns

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

inline virtual void reset(const Channel &channel) override

Reset the internal state of the demodulator.

Parameters

channel – The channel being demodulated.

inline virtual void timestamp(const MonoClock::time_point &timestamp, std::optional<ssize_t> snapshot_off, ssize_t offset, size_t delay, float rate, float rx_rate) override

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!

  • delayFilter delay

  • rate – The rate of the resampler applied before data is passed to the demodulator.

  • rx_rate – The RX rate (Hz).

inline virtual void demodulate(const std::complex<float> *data, size_t count) override

Demodulate IQ samples.

Parameters
  • data – The IQ data to demodulate

  • count – The number of samples to demodulate

inline PacketDemodulator(PHY &phy)
class PyPacketModulator : public PHY::PacketModulator

Public Functions

inline virtual void modulate(std::shared_ptr<NetPacket> pkt, const float gain, ModPacket &mpkt) override

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gain – Soft (multiplicative) gain to apply to modulated signal.

  • mpkt – The ModPacket in which to place modulated samples.

inline PacketModulator(PHY &phy)
class PyPHY : public PHY

Public Functions

inline virtual unsigned getMinRXRateOversample(void) const override

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

Returns

The minimum RX oversample rate

inline virtual unsigned getMinTXRateOversample(void) const override

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

Returns

The minimum TX oversample rate

inline virtual size_t getModulatedSize(mcsidx_t mcsidx, size_t n) override

Calculate size of modulated data.

inline virtual std::shared_ptr<PacketModulator> mkPacketModulator(void) override

Create a Modulator for this PHY.

inline virtual std::shared_ptr<PacketDemodulator> mkPacketDemodulator(void) override

Create a Demodulator for this PHY.

inline void updateAutoGain(const std::shared_ptr<NetPacket> &pkt, float g, const std::shared_ptr<IQBuf> &iqbuf)
inline std::vector<PHY::MCSEntry> &getMCSTable()
inline void setMCSTable(const std::vector<std::pair<std::shared_ptr<MCS>, AutoGain>> &table)
PHY() = default

Public Members

std::vector<std::shared_ptr<MCS>> mcs_table_

Actual MCS objects referred to by mcs_table.

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

A queue Element that has a separate high-priority queue that is always serviced first.

Subclassed by MandateQueue< T >, SimpleQueue< T >, SizedQueue< T >

Public Types

using const_iterator = typename std::list<T>::const_iterator

Public Functions

inline Queue()
virtual ~Queue() = default
virtual void reset(void) = 0

Reset queue to empty state.

virtual void push(T &&val) = 0

Push an element onto the queue.

virtual void push_hi(T &&item) = 0

Push an element onto the high-priority queue.

virtual void repush(T &&item) = 0

Re-queue an element.

virtual bool pop(T &val) = 0

Pop an element from the queue.

virtual void kick(void) = 0

Kick the queue.

virtual void stop(void) = 0

Stop processing queue elements.

virtual void updateMCS(NodeId id, const MCS *mcs) = 0

Notify queue of new MCS.

inline virtual void setTransmissionDelay(double t)

Set transmission delay.

inline virtual double getTransmissionDelay(void) const

Get transmission delay.

inline virtual void setSendWindowStatus(NodeId id, bool isOpen)

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

Public Members

Port<In, Push, T> in

The queue’s packet input port.

Port<Out, Pull, T> out

The queue’s packet output port.

Protected Functions

inline bool canPop(const T &pkt)

Return true if the packet can be popped.

Protected Attributes

std::mutex send_window_status_mutex_

Mutex protecting the send window status.

std::unordered_map<NodeId, bool> send_window_status_

Nodes’ send window statuses.

class RadioNet

Public Types

using NodeMap = std::map<NodeId, std::shared_ptr<Node>>
using new_node_callback_t = std::function<void(const std::shared_ptr<Node>&)>

Public Functions

RadioNet() = delete
inline RadioNet(std::shared_ptr<TunTap> tuntap, NodeId this_node_id)
~RadioNet() = default
RadioNet(const RadioNet&) = delete
RadioNet(RadioNet&&) = delete
RadioNet &operator=(const RadioNet&) = delete
RadioNet &operator=(RadioNet&&) = delete
inline NodeId getThisNodeId(void) const

Get this node’s ID.

inline Node &getThisNode(void)

Get the entry for this node.

inline bool contains(NodeId node_id)

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

inline NodeMap getNodes(void)

Get nodes.

Returns

A copy of the current node map.

inline std::shared_ptr<Node> getNode(NodeId node_id)

Get the entry for a particular node in the network.

inline Node &operator[](NodeId node_id)

Get the entry for a particular node in the network.

inline 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.

inline void setNewNodeCallback(const new_node_callback_t &cb)

Set new node callback.

Private Members

std::shared_ptr<TunTap> tuntap_

Our tun/tap interface.

const NodeId this_node_id_

This node’s ID.

std::shared_ptr<Node> this_node_

This node.

new_node_callback_t new_node_callback_

New node callback.

std::mutex nodes_mutex_

Mutex protecting nodes in the network.

NodeMap nodes_

The nodes in the network.

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

A packet received from the radio.

Public Functions

RadioPacket() = delete
inline RadioPacket(const Header &hdr)
inline RadioPacket(const Header &hdr, unsigned char *data, size_t n)

Public Members

float evm

Error vector magnitude [dB].

float rssi

Received signal strength indicator [dB].

float cfo

Carrier frequency offset (f/Fs)

Channel channel

Channel the packet was received on.

float bw

Bandwidth (Hz) of entire received signal.

mcsidx_t mcsidx

MCS index of packet.

MonoClock::time_point slot_timestamp

Timestamp of MAC slot containing this packet.

size_t start_samples

Offset of start of packet from MAC slot.

size_t end_samples

Offset of end of packet from MAC slot.

double demod_latency

Demodulation latency.

MonoClock::time_point tuntap_timestamp

Wall-clock time when packet was written to tun/tap.

size_t payload_len

Size of received payload, including controll information.

std::unique_ptr<std::vector<std::complex<float>>> symbols

Symbols.

class RadioPacketQueue
#include <RadioPacketQueue.hh>

A thread-safe queue of network packets. Handles barriers.

This is a specialized queue for RadioPackets that handles barrier packets. A barrier packet is a special packet that will not be removed from a queue seeing a barrier packet is like seeing the end of the queue. Barriers allow proper ordering: a producer can insert a barrier, insert packets before the barrier, then remove the barrier when it is done producing, thereby guaranteeing that packets inserted after the barrier will not be read from the queue until the barrier has been removed.

Public Types

using entry = std::variant<std::monostate, std::shared_ptr<RadioPacket>>

A queue entry.

using barrier = std::list<entry>::iterator

A barrier.

Public Functions

RadioPacketQueue()
~RadioPacketQueue()
RadioPacketQueue(const RadioPacketQueue&) = delete
RadioPacketQueue(RadioPacketQueue&&) = delete
RadioPacketQueue &operator=(const RadioPacketQueue&) = delete
RadioPacketQueue &operator=(RadioPacketQueue&&) = delete
void push(const std::shared_ptr<RadioPacket> &pkt)

Add a RadioPacket to the queue.

Parameters

pkt – The packet to push onto the queue.

void push(barrier b, const std::shared_ptr<RadioPacket> &pkt)

Add a RadioPacket to the queue before a barrier.

Parameters
  • b – The barrier.

  • pkt – The packet to push onto the queue.

barrier pushBarrier(void)

Push a barrier onto the queue.

Returns

A barrier.

void eraseBarrier(barrier b)

Erase a barrier from the queue.

Parameters

b – The barrier.

bool pop(std::shared_ptr<RadioPacket> &pkt)

Get a RadioPacket from the queue.

Parameters

pkt – The popped packet.

Returns

Return true if pop was successful, false otherwise.

void stop(void)

Stop processing this queue.

Private Members

bool done_

Flag that is true when we should finish processing.

std::mutex m_

Mutex protecting the queue of packets.

std::condition_variable cond_

Condition variable protecting the queue of packets.

std::list<entry> q_

The queue of packets.

class RaiseCaps

Public Functions

inline RaiseCaps(const std::vector<cap_value_t> &caps)
RaiseCaps() = delete
RaiseCaps(const RaiseCaps&) = delete
RaiseCaps(RaiseCaps&&) = delete
inline ~RaiseCaps()
RaiseCaps &operator=(const RaiseCaps&) = delete
RaiseCaps &operator=(RaiseCaps&&) = delete

Protected Attributes

Caps orig_caps_
template<class T, class C>
class dragonradio::signal::RationalResampler : public dragonradio::signal::Pfb<T, C>, public Resampler<T, T>
#include <Polyphase.hh>

A rational resampler that uses a polyphase filter bank.

Subclassed by dragonradio::signal::MixingRationalResampler< T, C >

Public Functions

inline RationalResampler(unsigned l, unsigned m, const std::vector<C> &taps)

Construct a polyphase rational resampler.

Parameters
  • l – The upsampling rate

  • m – The downsampling rate

  • taps – The taps for the prototype FIR filter

inline RationalResampler(double r, const std::vector<C> &taps = {1.0})

Construct a polyphase rational resampler.

Parameters
  • r – The resampler rate

  • taps – The taps for the prototype FIR filter

RationalResampler() = delete
virtual ~RationalResampler() = default
inline virtual double getRate(void) const override
inline unsigned getUpRate(void) const
inline unsigned getDownRate(void) const
inline void setRate(unsigned l, unsigned m)
inline void setRate(double rate)
inline virtual double getDelay(void) const override
inline virtual size_t neededOut(size_t count) const override
inline virtual void reset(void) override
inline virtual size_t resample(const T *in, size_t count, T *out) final override

Protected Functions

inline virtual void reconfigure(void) override

Reconfigure filter bank for current number of channels and taps.

Protected Attributes

unsigned m_

Downsampling rate.

unsigned idx_

Upsampled input sample index.

template<class U>
struct fftw::allocator::rebind

Public Types

using other = allocator<U>
struct ControlMsg::ReceiverStats

Public Members

float evm

EVM at receiver.

float rssi

RSSI at receiver.

class ReceiveWindowProxy
#include <proxies.hh>

A proxy object for a SmartController receive window.

Public Functions

inline ReceiveWindowProxy(std::shared_ptr<SmartController> controller, NodeId node_id)
inline std::optional<double> getShortEVM(void)
inline std::optional<double> getLongEVM(void)
inline std::optional<double> getShortRSSI(void)
inline std::optional<double> getLongRSSI(void)

Private Members

std::shared_ptr<SmartController> controller_

This send window’s SmartController.

const NodeId node_id_

This send window’s node ID.

class ReceiveWindowsProxy
#include <proxies.hh>

A proxy object for SmartController’s receive windows.

Public Functions

inline ReceiveWindowsProxy(std::shared_ptr<SmartController> controller)
ReceiveWindowsProxy() = delete
~ReceiveWindowsProxy() = default
inline ReceiveWindowProxy operator[](NodeId node)

Private Members

std::shared_ptr<SmartController> controller_

This object’s SmartController.

struct RecvWindow : public TimerQueue::Timer

Public Types

using vector_type = std::vector<Entry>

Public Functions

RecvWindow(Node &n, SmartController &controller, Seq::uint_type win, size_t nak_win)
inline bool contains(Seq seq)

Return true if sequence number is in the receive window.

void reset(Seq seq)

Reset the receive window.

inline Entry &operator[](Seq seq)

Return the packet with the given sequence number in the window.

virtual void operator()() override

Public Members

Node &node

Sender node.

SmartController &controller

Our controller.

std::mutex mutex

Mutex for the receive window.

TimeWindowMean<MonoClock, float> short_evm

Short-term packet EVM.

TimeWindowMean<MonoClock, float> long_evm

Long-term packet EVM.

TimeWindowMean<MonoClock, float> short_rssi

Short-term packet RSSI.

TimeWindowMean<MonoClock, float> long_rssi

Long-term packet RSSI.

bool active

True when this is an active window that has received a packet.

Seq ack

Next sequence number we should ACK.

We have received (or given up) on all packets with sequence numbers < this number. INVARIANT: The smallest sequence number in our receive window must be STRICTLY > ack because we have already received the packet with sequence number ack - 1, and if we received the packet with sequence number ack, we should have updated ack to ack + 1.

Seq max

Maximum sequence number we have received.

INVARIANT: ack <= max < ack + win. When max == ack, we have no holes in our receive window, which should therefore be empty.

MonoClock::time_point max_timestamp

Timestamp of packet with the maximum sequence number we have sent.

Seq::uint_type win

Receive window size.

bool need_selective_ack

Flag indicating whether or not we need a selective ACK.

bool timer_for_ack

Flag indicating whether or not the timer is for an ACK or a selective ACK.

std::vector<MonoClock::time_point> explicit_nak_win

Explicit NAK window.

size_t explicit_nak_idx

Explicit NAK window index.

Private Members

vector_type entries_

All packets with sequence numbers N such that ack <= N <= max < ack + win.

template<class T>
class REDQueue : public SizedQueue<T>
#include <REDQueue.hh>

An Adaptive RED queue.

See the paper Random Early Detection Gateways for Congestion Avoidance

Public Types

using const_iterator = typename std::list<T>::const_iterator

Public Functions

inline REDQueue(bool gentle, size_t min_thresh, size_t max_thresh, double max_p, double w_q)
REDQueue() = delete
inline virtual ~REDQueue()
inline bool getGentle(void) const

Get flag indicating whether or not to be gentle.

See: https://www.icir.org/floyd/notes/test-suite-red.txt

inline void setGentle(bool gentle)

Set flag indicating whether or not to be gentle.

inline size_t getMinThresh(void) const

Get minimum threshold.

inline void setMinThresh(size_t min_thresh)

Set minimum threshold.

inline size_t getMaxThresh(void) const

Get maximum threshold.

inline void setMaxThresh(size_t max_thresh)

Set maximum threshold.

inline double getMaxP(void) const

Get maximum drop probability.

inline void setMaxP(double max_p)

Set maximum drop probability.

inline double getQueueWeight(void) const

Get queue qeight.

inline void setQueueWeight(double w_q)

Set queue qeight.

inline virtual void reset(void) override

Reset queue to empty state.

inline virtual void push(T &&item) override

Push an element onto the queue.

Protected Attributes

bool gentle_

Gentle flag.

size_t min_thresh_

Minimum threshold.

size_t max_thresh_

Maximum threshold.

double max_p_

Maximum drop probability.

double w_q_

Queue weight.

int count_

Packets since last marked packet.

double avg_

Average size of queue (bytes).

std::mt19937 gen_

Random number generator.

std::uniform_real_distribution<double> dist_

Uniform 0-1 real distribution.

template<class I, class O>
class Resampler

Subclassed by liquid::MultiStageResampler< I, O, C >

Public Functions

Resampler() = default
virtual ~Resampler() = default
virtual double getRate(void) const = 0
virtual double getDelay(void) const = 0
virtual size_t neededOut(size_t count) const = 0
virtual void reset(void) = 0
virtual size_t resample(const I *in, size_t count, O *out) = 0
template<>
class Resampler<C, C>

Subclassed by liquid::MultiStageResampler< C, C, F >, dragonradio::signal::RationalResampler< C, C >

Public Functions

Resampler() = default
virtual ~Resampler() = default
virtual double getRate(void) const = 0
virtual double getDelay(void) const = 0
virtual size_t neededOut(size_t count) const = 0
virtual void reset(void) = 0
virtual size_t resample(const C *in, size_t count, C *out) = 0
inline virtual std::shared_ptr<IQBuf> resample(const IQBuf &in)
template<typename T, class Container = std::deque<T>>
class SafeQueue
#include <SafeQueue.hh>

A thread-safe queue.

A SafeQueue is a thread-safe FIFO queue. Any call to pop will block until an element is inserted until the queue is stopped by a call to stop. Once stop has been invoked, elements can still be inserted, but any call to pop will immediately return.

Public Types

using container_type = Container
using iterator = typename container_type::iterator
using const_iterator = typename container_type::const_iterator

Public Functions

inline SafeQueue()
inline ~SafeQueue()
SafeQueue(const SafeQueue&) = delete
SafeQueue(SafeQueue&&) = delete
SafeQueue &operator=(const SafeQueue&) = delete
SafeQueue &operator=(SafeQueue&&) = delete
inline size_t size(void)

Get queue size.

inline void clear(void)

Clear queue contents.

inline bool empty(void) const

Return true if the queue is empty.

inline void push(const T &val)

Push an element on the end of the queue.

inline void push(T &&val)

Push an element on the end of the queue.

template<class ...Args>
inline void emplace(Args&&... args)

Construct an element in-place on the end of the queue.

inline bool pop(T &val)

Access the first element of the queue and pop it.

Parameters

val – Reference to location where popped value should be copied.

Returns

true if a value was popped, false otherwise.

inline bool try_pop(T &val)

Access the first element of the queue and pop it without waiting.

Parameters

val – Reference to location where popped value should be copied.

Returns

true if a value was popped, false otherwise.

inline void stop(void)

Mark the queue as stopped.

Private Members

bool done_

Flag indicating that processing of the queue should stop.

mutable std::mutex m_

Mutex protecting the queue.

std::condition_variable cond_

Condition variable protecting the queue.

container_type q_

The queue itself.

class Schedule
#include <Schedule.hh>

A schedule specifying the channels on which a node may transmit in a given slot.

Public Types

using slot_type = std::vector<bool>
using sched_type = std::vector<slot_type>

Public Functions

Schedule() = default
Schedule(const Schedule&) = default
Schedule(Schedule&&) = default
Schedule &operator=(const Schedule&) = default
Schedule &operator=(Schedule&&) = default
inline Schedule &operator=(const sched_type &schedule)
inline sched_type::size_type size(void) const
inline sched_type::const_reference operator[](slot_type::size_type i) const
inline bool canTransmitInSlot(size_t slot) const

Return true if we can transmit in given slot.

inline bool canTransmitOnChannel(size_t chan) const

Return true if we can transmit on given channel (in any slot)

inline bool firstChannelIdx(size_t slot, size_t &chan_) const

Find the first channel index in which we can transmit in the given slot.

inline bool isFDMA(void) const

Is this an FDMA schedule?

Private Members

sched_type schedule_

The slot schedule.

struct Score
#include <Scorer.hh>

Scoring a single measurement period.

Public Functions

inline Score()

Public Members

size_t npackets_sent

Number of packets sent.

size_t nbytes_sent

Number of bytes sent.

double update_timestamp_sent

Timestamp of last update for sent statistics.

size_t npackets_recv

Number of packets received.

size_t nbytes_recv

Number of bytes received.

double update_timestamp_recv

Timestamp of last update for receive statistics.

bool goal

True if goal met in MP.

bool goal_stable

True if goal stable in MP.

unsigned achieved_duration

Number of consecutive MP’s in which goal has been met.

unsigned mp_score

Score for this MP.

class Scorer

Public Functions

Scorer()
virtual ~Scorer()
inline MandateMap getMandates(void)

Get mandates.

void setMandates(const MandateMap &mandates)

Set mandates.

inline ScoreMap getScores(void)

Get Scores.

void updateSentStatistics(FlowUID flow, double timestamp, unsigned first_mp, std::vector<size_t> npackets, std::vector<size_t> nbytes)
void updateReceivedStatistics(FlowUID flow, double timestamp, unsigned first_mp, std::vector<size_t> npackets, std::vector<size_t> nbytes)
void updateScore(unsigned final_mp)

Protected Attributes

MandateMap mandates_
ScoreMap scores_
struct Scores : public std::vector<Score>

Public Functions

inline Scores()

Public Members

unsigned invalid_mp

First invalid MP.

MP’s from this MP on have been invalidated and need to be scored

struct ControlMsg::SelectiveAck

Public Members

Seq begin
Seq end
struct SelfTX
#include <Snapshot.hh>

A self transmission event within a snapshot.

Public Members

bool is_local

Is this TX local, i.e., produced by this node?

ssize_t start
ssize_t end
float fc
float fs
struct SelfTXEntry

Log entry for self-transmission events.

Public Members

double timestamp

Timestamp of snapshot this self-transmission belongs to.

double mono_timestamp

Monotonic clock timestamp.

uint8_t is_local

Is this TX local, i.e., produced by this node?

int32_t start

Offset of start of packet.

int32_t end

Offset of end of packet.

float fc

Center frequency [Hz].

float fs

Sampling frequency [Hz].

struct SendWindow

Public Types

using vector_type = std::vector<Entry>

Public Functions

SendWindow(Node &n, SmartController &controller, Seq::uint_type maxwin, double retransmission_delay_)
inline Entry &operator[](Seq seq)

Return the packet with the given sequence number in the window.

void setSendWindowStatus(bool open)

Set send window status.

void ack(const MonoClock::time_point &tx_time)

Record a packet ACK.

void txSuccess(void)

Update PER as a result of successful packet transmission.

void txFailure(void)

Update PER as a result of unsuccessful packet transmission.

void updateMCS(bool fast_adjust)

Update MCS based on current PER.

bool mayMoveUpMCS(void) const

Return true if we may move up one MCS level.

inline void moveDownMCS(unsigned n)

Move down one MCS level.

inline void moveUpMCS(void)

Move up one MCS level.

void setMCS(size_t mcsidx)

Set MCS.

void resetPEREstimates(void)

Reconfigure a node’s PER estimates.

Public Members

Node &node

Destination node.

SmartController &controller

Our controller.

std::vector<PHY::MCSEntry> &mcs_table

PHY’s MCS table.

std::mutex mutex

Mutex for the send window.

size_t mcsidx

Modulation index.

std::optional<float> short_evm

Short-term EVM, as reported by receiver.

std::optional<float> long_evm

Long-term EVM, as reported by receiver.

std::optional<float> short_rssi

Short-term RSSI, as reported by receiver.

std::optional<float> long_rssi

Long-term RSSI, as reported by receiver.

bool new_window

Is this a new window?

bool window_open

Is the window open?

Seq seq

Current sequence number for this destination.

Seq unack

First un-ACKed sequence number.

Seq max

Maximum sequence number we have sent.

INVARIANT: max < unack + win

bool send_set_unack

Do we need to send a set unack control message?

Seq::uint_type win

Send window size.

Seq::uint_type maxwin

Maximum window size.

std::vector<double> mcsidx_prob

The probability of moving to a given MCS.

Seq per_cutoff

First sequence that can possibly be used to calculate PER.

The packet with this sequence number is the first that can possibly be used to calculate PER. We use this when the environment has changed and previously-sent packets should not be used to calculate PER in the new environment.

Seq per_end

End of the current PER window PER.

Every packet up to, but not including, this sequence number has already been used to calculate the current PER

double prev_short_per

Previous short-term packet error rate.

double prev_long_per

Previous long-term packet error rate.

WindowedMean<double> short_per

Short-term packet error rate.

WindowedMean<double> long_per

Long-term packet error rate.

double retransmission_delay

Duration of retransmission timer.

TimeWindowMax<MonoClock, double> ack_delay

ACK delay estimator.

Private Members

vector_type entries_

Unacknowledged packets in our send window.

INVARIANT: unack <= N <= max < unack + win

class SendWindowProxy
#include <proxies.hh>

A proxy object for a SmartController send window.

Public Functions

inline SendWindowProxy(std::shared_ptr<SmartController> controller, NodeId node_id)
inline std::optional<double> getShortPER(void)
inline std::optional<double> getLongPER(void)
inline std::optional<double> getShortEVM(void)
inline std::optional<double> getLongEVM(void)
inline std::optional<double> getShortRSSI(void)
inline std::optional<double> getLongRSSI(void)

Private Members

std::shared_ptr<SmartController> controller_

This send window’s SmartController.

const NodeId node_id_

This send window’s node ID.

class SendWindowsProxy
#include <proxies.hh>

A proxy object for SmartController’s send windows.

Public Functions

inline SendWindowsProxy(std::shared_ptr<SmartController> controller)
SendWindowsProxy() = delete
~SendWindowsProxy() = default
inline SendWindowProxy operator[](NodeId node)

Private Members

std::shared_ptr<SmartController> controller_

This object’s SmartController.

struct Seq

Public Types

using uint_type = uint16_t
using int_type = int16_t

Public Functions

Seq() = default
Seq(const Seq&) = default
Seq(Seq&&) = default
Seq &operator=(const Seq&) = default
Seq &operator=(Seq&&) = default
inline bool operator==(const Seq &other) const
inline bool operator!=(const Seq &other) const
inline bool operator<(const Seq &other) const
inline bool operator<=(const Seq &other) const
inline bool operator>(const Seq &other) const
inline bool operator>=(const Seq &other) const
inline Seq operator++()
inline Seq operator++(int)
inline Seq operator--()
inline Seq operator--(int)
inline Seq operator+(int i)
inline Seq operator-(int i)
inline operator uint_type() const

Public Members

uint_type seq_

Public Static Functions

static inline uint_type max(void)
struct ControlMsg::SetUnack

Public Members

Seq unack

Sender’s first un-ACK’ed packet.

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

A simple queue Element.

Public Types

enum QueueType

Values:

enumerator FIFO
enumerator LIFO
using const_iterator = typename std::list<T>::const_iterator

Public Functions

SimpleQueue() = delete
inline SimpleQueue(QueueType type)
inline virtual ~SimpleQueue()
inline QueueType getQueueType(void) const

Get queue type.

inline void setQueueType(QueueType type)

Set queue type.

inline virtual void reset(void) override

Reset queue to empty state.

inline virtual void push(T &&item) override

Push an element onto the queue.

inline virtual void push_hi(T &&item) override

Push an element onto the high-priority queue.

inline virtual void repush(T &&item) override

Re-queue an element.

inline virtual bool pop(T &val) override

Pop an element from the queue.

inline virtual void kick(void) override

Kick the queue.

inline virtual void stop(void) override

Stop processing queue elements.

inline virtual void updateMCS(NodeId, const MCS*) override

Notify queue of new MCS.

Public Members

const FlowUID INTERNAL_PORT = 4096

Protected Attributes

bool done_

Flag indicating that processing of the queue should stop.

std::atomic<bool> kicked_

Is the queue being kicked?

mutable std::mutex m_

Mutex protecting the queues.

std::condition_variable cond_

Condition variable protecting the queue.

QueueType type_

Queue type.

std::list<T> hiq_

The high-priority queue itself.

std::list<T> q_

The standard_priority queue itself.

template<int INTBITS>
class sintab

Public Types

using brad_t = uint32_t

A binary radian.

A binary radian (brad) is a fractional value, where 1 brad is 2 pi radians.

Public Functions

inline sintab()
inline ~sintab()
inline float operator[](brad_t pos)
inline float sin(brad_t theta)
inline float cos(brad_t theta)

Public Static Functions

static inline brad_t to_brad(double x)

Convert an angle in radians to binary radians.

static inline double from_brad(brad_t x)

Convert an angle in binary radians to radians.

Public Static Attributes

static constexpr int BRADBITS = 8 * sizeof(brad_t)

Number of bits used to represent a brad.

static constexpr int FRACBITS = BRADBITS - INTBITS

Number of bits used to represent fractional part of table index.

static constexpr int N = 1 << INTBITS

Size of table.

static constexpr brad_t ONE = static_cast<brad_t>(1) << sintab::FRACBITS

Number of brad’s per table entry.

static constexpr brad_t PIDIV2 = static_cast<brad_t>(1) << (BRADBITS - 2)

Binary radian representation of pi/2.

static constexpr float DTHETA = 1.0f / static_cast<float>(ONE)

Reciprocal of dx between two entries in the table.

Private Members

float sintab_[N]
template<class T>
class SizedQueue : public Queue<T>
#include <SizedQueue.hh>

A queue that tracks its size.

Subclassed by REDQueue< T >, TailDropQueue< T >

Public Types

using const_iterator = typename std::list<T>::const_iterator

Public Functions

inline SizedQueue()
inline virtual ~SizedQueue()
inline std::set<FlowUID> getHiPriorityFlows(void) const

Get flag indicating whether or not to be gentle.

inline void setHiPriorityFlows(const std::set<FlowUID> &flows)

Set flag indicating whether or not to be gentle.

inline virtual void reset(void) override

Reset queue to empty state.

inline virtual void push_hi(T &&item) override

Push an element onto the high-priority queue.

inline virtual void repush(T &&item) override

Re-queue an element.

inline virtual bool pop(T &val) override

Pop an element from the queue.

inline virtual void kick(void) override

Kick the queue.

inline virtual void stop(void) override

Stop processing queue elements.

inline virtual void updateMCS(NodeId, const MCS*) override

Notify queue of new MCS.

Protected Functions

inline bool pop_queue(std::list<T> &q, const MonoClock::time_point &now, T &val)

Attempt to pop packet from given queue.

inline void drop(const std::shared_ptr<NetPacket> &pkt) const

Indicate that a packet has been dropped.

Protected Attributes

bool done_

Flag indicating that processing of the queue should stop.

std::atomic<bool> kicked_

Is the queue being kicked?

std::set<FlowUID> hi_priority_flows_

High-priority flows.

size_t size_

Size of queue (bytes).

mutable std::mutex m_

Mutex protecting the queues.

std::condition_variable cond_

Condition variable protecting the queue.

std::list<T> hiq_

The high-priority queue.

std::list<T> q_

The standard_priority queue.

struct FDChannelizer::Slot

A demodulation slot.

Public Functions

Slot() = default
inline Slot(const std::shared_ptr<IQBuf> &iqbuf_, const std::shared_ptr<IQBuf> &fdbuf_, ssize_t fd_offset_) noexcept

Public Members

std::shared_ptr<IQBuf> iqbuf

The slot’s time-domain samples.

std::shared_ptr<IQBuf> fdbuf

The slot’s frequency-domain samples.

ssize_t fd_offset

Offset of frequency-domain samples from time-domain samples (in samples)

This is used to account for the fact that the frequency-domain buffer may hold some samples from the previous slot’s time-domain buffer that didn’t fit in a full size N FFT.

struct SlotSynthesizer::Slot
#include <SlotSynthesizer.hh>

A time slot that needs to be synthesized.

Public Functions

inline Slot(const WallClock::time_point &deadline_, size_t deadline_delay_, size_t max_samples_, size_t full_slot_samples_, size_t slotidx_, size_t nchannels)
Slot() = delete
~Slot() = default
inline size_t length(void)

The length of the slot, in samples.

Return the length of the slot, in samples. This does not include delayed samples.

inline bool push(std::unique_ptr<ModPacket> &mpkt, bool overfill)

Push a modulated packet onto the slot.

Parameters
  • mpkt – A reference to a modulated packet

  • overfill – true if the slot can be overfilled

Returns

true if the packet was pushed, false if it didn’t fit The slot’s mutex must be held by the caller. If pushed, the slot takes ownership of the ModPacket.

Public Members

const WallClock::time_point deadline

Synthesis deadline. Slot must be ready at this time!

const size_t deadline_delay

Number of samples to delay the deadline.

const size_t full_slot_samples

Number of samples in a full slot including any guard.

const size_t slotidx

The schedule slot this slot represents.

std::atomic<bool> closed

When true, indicates that the slot is closed for further samples.

std::mutex mutex

Mutex protecting slot info.

size_t max_samples

Maximum number of samples in this slot.

size_t delay

Number of samples to delay.

size_t nsamples

Number of samples in slot.

std::list<std::shared_ptr<IQBuf>> iqbufs

The list of IQ buffers.

std::list<std::unique_ptr<ModPacket>> mpkts

The list of modulated packets.

std::atomic<unsigned> nfinished

Number of threads who have finished with this slot.

std::unique_ptr<IQBuf> fdbuf

Frequency-domain IQ buffer.

size_t fdnsamples

Number of valid samples in the frequency-domain buffer.

size_t npartial

Number of samples represented by final FFT block that were part of the slot.

struct SlotEntry

Log entry for slots.

Public Members

double timestamp

Receive timestamp.

double mono_timestamp

Monotonic clock timestamp.

float fc

Sample center frequency [Hz].

float fs

Sample rate [Hz].

uint32_t iq_data_len

Size of uncompressed IQ data (bytes).

hvl_t iq_data

Compressed IQ data.

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

Base class for synthesizers.

Subclassed by MultichannelSynthesizer, UnichannelSynthesizer< ChannelModulator >

Public Functions

inline SlotSynthesizer(std::shared_ptr<PHY> phy, double tx_rate, const Channels &channels)
virtual ~SlotSynthesizer() = default
inline bool getSuperslots(void) const

Get superslots flag.

inline void setSuperslots(bool superslots)

Set superslots flag.

virtual void modulate(const std::shared_ptr<Slot> &slot) = 0

Modulate a slot.

inline virtual void finalize(Slot &slot)

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.

Protected Attributes

std::atomic<bool> superslots_

Use superslots.

class SlottedALOHA : public SlottedMAC
#include <SlottedALOHA.hh>

A Slotted ALOHA MAC.

Public Functions

SlottedALOHA(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<SlotSynthesizer> synthesizer, double slot_size, double guard_size, double slot_send_lead_time, double p)
virtual ~SlottedALOHA()
SlottedALOHA(const SlottedALOHA&) = delete
SlottedALOHA(SlottedALOHA&&) = delete
SlottedALOHA &operator=(const SlottedALOHA&) = delete
SlottedALOHA &operator=(SlottedALOHA&&) = delete
inline size_t getSlotIndex(void) const

Get slot index to transmit on.

inline void setSlotIndex(size_t slotidx)

Set slot to transmit on.

inline double getTXProb(void) const

Get probability of transmission.

inline void setTXProb(double p)

Set probability of transmission.

Parameters

p – The probability of transmitting in a given slot

virtual void stop(void) override

Stop processing packets.

virtual void reconfigure(void) override

Reconfigure the MAC when after parameters change.

Private Functions

void txSlotWorker(void)

Worker preparing slots for transmission.

Private Members

size_t slotidx_

Slot index to use.

double p_

Probability of transmission.

std::mt19937 gen_

Random number generator.

std::uniform_real_distribution<double> dist_

Uniform 0-1 real distribution.

std::exponential_distribution<double> arrival_dist_

Exponential distribution for inter-arrival times.

std::thread rx_thread_

Thread running rxWorker.

std::thread tx_thread_

Thread running txWorker.

std::thread tx_slot_thread_

Thread running txSlotWorker.

std::thread tx_notifier_thread_

Thread running txNotifier.

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

A slotted MAC.

Subclassed by SlottedALOHA, TDMA

Public Types

using Slot = SlotSynthesizer::Slot

Public Functions

SlottedMAC(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<SlotSynthesizer> synthesizer, double slot_size, double guard_size, double slot_send_lead_time)
virtual ~SlottedMAC()
SlottedMAC(const SlottedMAC&) = delete
SlottedMAC(SlottedMAC&&) = delete
SlottedMAC &operator=(const SlottedMAC&) = delete
SlottedMAC &operator=(SlottedMAC&&) = delete
inline virtual double getSlotSize(void)

Get slot size, including guard interval.

inline virtual void setSlotSize(double t)

Set slot size, including guard interval.

Parameters

t – Slot size in seconds

inline virtual double getGuardSize(void)

Get guard interval size.

inline virtual void setGuardSize(double t)

Set guard interval size.

Parameters

t – Guard interval size in seconds

inline virtual size_t getSlotSendLeadTime(void)
inline virtual void setSlotSendLeadTime(size_t t)
inline virtual bool isFDMA(void) const

Is this MAC FDMA?

virtual void reconfigure(void) override

Reconfigure the MAC when after parameters change.

virtual void stop(void) override

Stop processing packets.

Protected Types

using slot_queue = std::queue<std::shared_ptr<Slot>>

Protected Functions

void txWorker(void)

Worker transmitting slots.

void modulateSlot(slot_queue &q, WallClock::time_point when, size_t prev_overfill, size_t slotidx)

Schedule modulation of a slot.

Parameters
  • q – The slot queue

  • when – Start time of slot

  • prev_overfill – Number of overfill samples from previous slot.

  • slotidx – Index of the slot to modulated

std::shared_ptr<Slot> finalizeSlot(slot_queue &q, WallClock::time_point when)

Finalize the next TX slot.

Parameters
  • q – The slot queue

  • when – Start time of slot

Returns

The slot After finalizeSlot returns, the caller has exclusive access to the slot. That is, it does not need to acquire the slot’s lock to modify it, because it is guaranteed exclusive access.

inline void txSlot(std::shared_ptr<Slot> &&slot)

Transmit a slot.

Parameters

slot – The slot

void missedSlot(Slot &slot)

Mark a slot as missed.

Parameters

slot – The slot

void missedRemainingSlots(slot_queue &q)

Mark all remaining slots in qeueue as missed.

Parameters

q – The slot queue

Protected Attributes

std::shared_ptr<SlotSynthesizer> slot_synthesizer_

Our slot synthesizer.

double slot_size_

Length of a single TDMA slot, including guard (sec)

double guard_size_

Length of inter-slot guard (sec)

double slot_send_lead_time_

Lead time needed to send a slot’s worth of data.

size_t tx_slot_samps_

Number of TX samples in the non-guard portion of a slot.

size_t tx_full_slot_samps_

Number of TX samples in the entire slot, including the guard.

std::atomic<bool> stop_burst_

Do we need to stop the current burst?

SafeQueue<std::shared_ptr<Slot>> tx_slots_

Slots to transmit.

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

A MAC controller that implements ARQ.

Public Types

using evm_thresh_t = std::optional<double>

Public Functions

SmartController(std::shared_ptr<RadioNet> radionet_, size_t mtu, std::shared_ptr<PHY> phy, double slot_size, Seq::uint_type max_sendwin, Seq::uint_type recvwin, const std::vector<evm_thresh_t> &evm_thresholds)
virtual ~SmartController()
inline double getMCSFastAdjustmentPeriod(void) const

Get MCS fast adjustment period (sec)

inline void setMCSFastAdjustmentPeriod(double t)

Set MCS fast adjustment period (sec)

inline bool isMCSFastAdjustmentPeriod(void) const

Are we in MCS fast adjustment period?

inline double getShortPERWindow(void)

Get short time window over which to calculate PER (sec)

inline void setShortPERWindow(double window)

Set short time window over which to calculate PER (sec)

inline double getLongPERWindow(void)

Get long time window over which to calculate PER (sec)

inline void setLongPERWindow(double window)

Set long time window over which to calculate PER (sec)

inline double getShortStatsWindow(void)

Get time window for statistics collection (sec)

inline void setShortStatsWindow(double window)

Set time window for statistics collection (sec)

inline double getLongStatsWindow(void)

Get time window for statistics collection (sec)

inline void setLongStatsWindow(double window)

Set time window for statistics collection (sec)

inline mcsidx_t getBroadcastMCSIndex(void)

Get broadcast MCS index.

inline void setBroadcastMCSIndex(mcsidx_t mcsidx)

Set broadcast MCS index.

inline mcsidx_t getAckMCSIndex(void)

Get ACK MCS index.

inline void setAckMCSIndex(mcsidx_t mcsidx)

Set ACK MCS index.

inline mcsidx_t getMinMCSIndex(void)

Get minimum MCS index.

inline void setMinMCSIndex(mcsidx_t mcsidx)

Set minimum MCS index.

inline mcsidx_t getMaxMCSIndex(void)

Get maximum MCS index.

inline void setMaxMCSIndex(mcsidx_t mcsidx)

Set maximum MCS index.

inline mcsidx_t getInitialMCSIndex(void)

Get initial MCS index.

inline void setInitialMCSIndex(mcsidx_t mcsidx)

Set initial MCS index.

inline double getUpPERThreshold(void)

Get PER threshold for increasing modulation level.

inline void setUpPERThreshold(double thresh)

Set PER threshold for increasing modulation level.

inline double getDownPERThreshold(void)

Get PER threshold for decreasing modulation level.

inline void setDownPERThreshold(double thresh)

Set PER threshold for decreasing modulation level.

inline double getMCSLearningAlpha(void)

Get MCS index learning alpha.

inline void setMCSLearningAlpha(double alpha)

Set MCS index learning alpha.

inline double getMCSProbFloor(void)

Get MCS transition probability floor.

inline void setMCSProbFloor(double p)

Set MCS transition probability floor.

void environmentDiscontinuity(void)

Inform the controller that an environmental discontinuity has occurred.

inline double getACKDelay(void)

Get ACK delay.

inline void setACKDelay(double t)

Set ACK delay.

inline double getACKDelayEstimationWindow(void) const

Get ACK delay estimation window (sec).

inline void setACKDelayEstimationWindow(double t)

Set ACK delay estimation window (sec).

inline double getRetransmissionDelay(void)

Get retransmission delay.

inline void setRetransmissionDelay(double t)

Set retransmission delay.

inline double getMinRetransmissionDelay(void)

Get minimum retransmission delay.

inline void setMinRetransmissionDelay(double t)

Set minimum retransmission delay.

inline double getRetransmissionDelaySlop(void)

Get retransmission delay safety factor.

inline void setRetransmissionDelaySlop(double k)

Set retransmission delay safety factor.

inline double getSACKDelay(void)

Get SACK delay.

inline void setSACKDelay(double t)

Set SACK delay.

inline std::optional<size_t> getMaxSACKs(void) const

Get maximum number of SACKs in a packet.

inline void setMaxSACKs(std::optional<size_t> max_sacks)

Set maximum number of SACKs in a packet.

inline bool getExplicitNAKWindow(void)

Return explicit NAK window size.

inline void setExplicitNAKWindow(size_t n)

Set explicit NAK window size.

inline double getExplicitNAKWindowDuration(void)

Return explicit NAK window duration.

inline void setExplicitNAKWindowDuration(double t)

Set explicit NAK window duration.

inline bool getSelectiveACK(void)

Return whether or not we should send selective ACKs.

inline void setSelectiveACK(bool ack)

Set whether or not we should send selective ACKs.

inline double getSelectiveACKFeedbackDelay(void)

Return selective ACK feedback delay.

inline void setSelectiveACKFeedbackDelay(double delay)

Set selective ACK feedback delay.

inline std::optional<size_t> getMaxRetransmissions(void)

Return maximum number of retransmission attempts.

inline void setMaxRetransmissions(std::optional<size_t> max_retransmissions)

Set maximum number of retransmission attempts.

inline bool getDemodAlwaysOrdered(void)

Return flag indicating whether or not packets are always demodulated in order.

inline void setDemodAlwaysOrdered(bool always_ordered)

Set flag indicating whether or not packets are always demodulated in order.

inline bool getEnforceOrdering(void)

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

inline void setEnforceOrdering(bool enforce)

Set whether or not demodulation queue enforces packet order.

inline size_t getMCU(void)

Get maximum number of extra control bytes beyond MTU.

inline void setMCU(size_t mcu)

Set maximum number of extra control bytes beyond MTU.

inline bool getMoveAlong(void)

Get whether or not we always move the send windwo along.

inline void setMoveAlong(bool move_along)

Set whether or not to always move the send windwo along.

inline bool getDecreaseRetransMCSIdx(void)

Get whether or not we decrease the MCS index of retransmitted packets with a deadline.

inline void setDecreaseRetransMCSIdx(bool decrease_retrans_mcsidx)

Set whether or not we decrease the MCS index of retransmitted packets with a deadline.

virtual 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.

virtual 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.

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

Notify controller of transmitted packets.

void retransmitOnTimeout(SendWindow::Entry &entry)

Retransmit a send window entry on timeout.

void ack(RecvWindow &recvw)

Send an ACK to the given receiver.

The caller MUST hold the lock on recvw.

void nak(RecvWindow &recvw, Seq seq)

Send a NAK to the given receiver.

void broadcastHello(void)

Broadcast a HELLO packet.

void sendPing(NodeId dest)

Send a ping packet.

void sendPong(NodeId dest)

Send a pong packet.

Public Members

Gain broadcast_gain

Broadcast gain.

Gain ack_gain

ACK gain.

Protected Functions

void retransmitOrDrop(SendWindow::Entry &entry)

Re-transmit or drop a send window entry.

void retransmit(SendWindow::Entry &entry)

Re-transmit a send window entry.

NOTE: The lock on the send window to which entry belongs MUST be held before calling retransmit.

void drop(SendWindow::Entry &entry)

Drop a send window entry.

void advanceSendWindow(SendWindow &sendw)

Advance the send window.

Parameters

sendw – The send window to advance

void advanceRecvWindow(Seq seq, RecvWindow &recv)

Advance the receive window.

Parameters
  • seq – The sequence number received

  • recv – The receive window to advance

void startRetransmissionTimer(SendWindow::Entry &entry)

Start the re-transmission timer if it is not set.

void startSACKTimer(RecvWindow &recvw)

Start the selective ACK timer if it is not set.

void handleCtrlHelloAndPing(RadioPacket &pkt, Node &node)

Handle HELLO and ping control messages.

void handleCtrlTimestamp(RadioPacket &pkt, Node &node)

Handle timestamp control messages.

void appendFeedback(const std::shared_ptr<NetPacket> &pkt, RecvWindow &recvw)

Append control messages for feedback to sender.

This method appends feedback to the receiver in the form of both statistics and selective ACKs .

void handleReceiverStats(RadioPacket &pkt, SendWindow &sendw)

Handle receiver statistics.

void handleACK(SendWindow &sendw, const Seq &seq)

Handle an ACK.

std::optional<Seq> handleNAK(RadioPacket &pkt, SendWindow &sendw)

Handle a NAK.

Parameters
  • sendw – The sender’s window

  • pkt – The packet potentially containing NAK’s

Returns

The NAK with the highest sequence number, if there is a NAK

void handleSelectiveACK(const std::shared_ptr<RadioPacket> &pkt, SendWindow &sendw, MonoClock::time_point tfeedback)

Handle select ACK messages.

void handleSetUnack(RadioPacket &pkt, RecvWindow &recvw)

Handle sender setting unack.

bool getPacket(std::shared_ptr<NetPacket> &pkt)

Get a packet that is elligible to be sent.

SendWindow &getSendWindow(NodeId node_id)

Get a node’s send window.

RecvWindow &getReceiveWindow(NodeId node_id)

Get a node’s receive window.

Parameters

node_id – The node whose window to get

Returns

The receive window

Protected Attributes

std::shared_ptr<PHY> phy_

Our PHY.

std::mutex net_mutex_

Mutex to serialize access to the network.

double slot_size_

Slot size (sec)

std::optional<MonoClock::time_point> env_timestamp_

Latest environment discontinuity.

double mcs_fast_adjustment_period_

MCS fast-adjustment period (sec)

Seq::uint_type max_sendwin_

Maximum size of a send window.

Seq::uint_type recvwin_

Size of receive window.

std::mutex send_mutex_

Mutex for the send windows.

std::map<NodeId, SendWindow> send_

Send windows.

std::mutex recv_mutex_

Mutex for the receive windows.

std::map<NodeId, RecvWindow> recv_

Receive windows.

TimerQueue timer_queue_

Timer queue.

std::vector<size_t> max_packet_samples_

Samples in modulated packet of max size at each MCS.

std::vector<evm_thresh_t> evm_thresholds_

EVM thresholds.

double short_per_window_

Time window used to calculate short-term PER.

double long_per_window_

Time window used to calculate long-term PER.

double short_stats_window_

Time window used to calculate short-term statistics.

double long_stats_window_

Time window used to calculate long-term statistics.

mcsidx_t mcsidx_broadcast_

Broadcast MCS index.

mcsidx_t mcsidx_ack_

ACK MCS index.

mcsidx_t mcsidx_min_

Minimum MCS index.

mcsidx_t mcsidx_max_

Maximum MCS index.

mcsidx_t mcsidx_init_

Initial MCS index.

double mcsidx_up_per_threshold_

PER threshold for increasing modulation level.

double mcsidx_down_per_threshold_

PER threshold for decreasing modulation level.

double mcsidx_alpha_

Multiplicative factor used when learning MCS transition probabilities.

double mcsidx_prob_floor_

Minimum MCS transition probability.

double ack_delay_

ACK delay in seconds.

double ack_delay_estimation_window_

ACK delay estimation window (sec)

double retransmission_delay_

Packet re-transmission delay in seconds.

double min_retransmission_delay_

Minimum packet re-transmission delay in seconds.

double retransmission_delay_slop_

Safety factor for retransmission timer estimator.

double sack_delay_

SACK delay (sec)

Amount of time we wait for a regular packet to have a SACK attached.

std::optional<size_t> max_sacks_

Maximum number of SACKs in a packet.

size_t explicit_nak_win_

Explicit NAK window.

double explicit_nak_win_duration_

Explicit NAK window duration.

bool selective_ack_

Should we send selective ACK packets?

double selective_ack_feedback_delay_

Amount of time we wait to accept selective ACK feedback about a packet.

std::optional<size_t> max_retransmissions_

Maximum number of retransmission attempts.

bool demod_always_ordered_

Are packets always demodulated in order?

bool enforce_ordering_

Should packets always be output in the order they were actually received?

size_t mcu_

Maximum extra control bytes, in contrast to MTU.

bool move_along_

Always move the send window along, even if it’s full.

bool decrease_retrans_mcsidx_

Decrease MCS index of retransmitted packets with a deadline.

std::atomic<TimestampSeq> timestamp_seq_

Current timestamp sequence number.

std::mutex gen_mutex_

Mutex for random number generator.

std::mt19937 gen_

Random number generator.

std::uniform_real_distribution<double> dist_

Uniform 0-1 real distribution.

Friends

friend struct SendWindow
friend struct RecvWindow
friend class SendWindowsProxy
friend class SendWindowProxy
friend class ReceiveWindowsProxy
friend class ReceiveWindowProxy
struct Snapshot
#include <Snapshot.hh>

A snapshot of received spectrum.

Public Functions

std::optional<std::shared_ptr<IQBuf>> getCombinedSlots(void) const

Return an IQBuf containing IQ data from all slots.

Public Members

MonoClock::time_point timestamp

Timestamp of start of snapshot.

std::vector<std::shared_ptr<IQBuf>> slots

IQ buffers holding samples in snapshot.

std::vector<SelfTX> selftx

Demodulated packets.

class SnapshotCollector
#include <Snapshot.hh>

A snapshot collector.

Public Functions

SnapshotCollector()
virtual ~SnapshotCollector() = default
void start(void)

Start snapshot collection.

void stop(void)

Stop snapshot collection.

std::shared_ptr<Snapshot> finalize(void)

Finalize snapshot collection.

Snapshot collection should be stopped before finalize is called. Waiting for a small amount of time between stopping snapshot collection and finalizing a snapshot allows pending packets demodulation to finish, which provides more complete information about self-transmissions during the snapshot.

std::shared_ptr<Snapshot> next(void)

Get current snapshot and start a new snapshot immediately.

bool push(const std::shared_ptr<IQBuf> &buf)

Add IQ buffer to the snapshot.

Returns

true if snapshots are being collected The IQ buffer should not yet have been filled with received data. This will initialize the snapshot_off field of the IQ buffer.

void finalizePush(void)

Finalize a snapshotted IQ buffer.

Call this after the IQ buffer has been filled. This will update the snapshot offset counter.

void selfTX(ssize_t start, ssize_t end, float fc, float fs)

Add a self-transmission event based on a received packet.

Parameters
  • start – Sample offset of start of self-transmission

  • end – Sample offset of end of self-transmission

  • fc – Center frequency of self-transmission

  • fs – Bandwidth of self-transmission

void selfTX(MonoClock::time_point when, float fs_rx, float fs_tx, float fs_chan, unsigned nsamples, float fc)

Add a local self-transmission event (we transmitted something)

Parameters
  • when – Timestamp of start of self-transmission

  • fs_rx – RX sampling rate

  • fs_tx – TX sampling rate

  • fs_chan – TX channel sampling rate

  • nsamples – Number of samples of self-transmission

  • fc – Center frequency of self-transmission

inline bool active(void)

Return true if a snapshot is being collected.

Protected Functions

void newSnapshot(void)

Start a new snapshot.

void fixSnapshotTimestamps(void)

Fix timestamps in current snapshot.

Protected Attributes

std::mutex mutex_

Mutex protecting access to the snapshot.

std::unique_ptr<Snapshot> snapshot_

The current snapshot.

std::shared_ptr<IQBuf> curbuf_

The current IQ buffer.

bool snapshot_collect_

Should we collect new slots?

size_t snapshot_off_

Current offset from the beginning of the first collected slot.

MonoClock::time_point last_local_tx_start_

Timestamp of ast local TX.

float last_local_tx_fs_rx_

RX sampling frequency during last local TX

SelfTX last_local_tx_

Last local TX.

struct SnapshotEntry

Log entry for snapshots.

Public Members

double timestamp

Receive timestamp.

double mono_timestamp

Monotonic clock timestamp.

float fs

Sampling frequency [Hz].

uint32_t iq_data_len

Size of uncompressed IQ data (bytes).

hvl_t iq_data

Compressed IQ data.

class Socket

Public Functions

inline Socket()
inline explicit Socket(int fd)
inline Socket(int domain, int type, int protocol)
Socket(const Socket&) = delete
inline Socket(Socket &&other)
inline ~Socket()
inline Socket &operator=(Socket &other)
inline Socket &operator=(Socket &&other)
inline operator int()

Protected Attributes

int fd_
struct MandateQueue::SubQueue : public TimerQueue::Timer

Public Types

using container_type = std::deque<T>

Public Functions

SubQueue() = delete
inline SubQueue(MandateQueue<T> &mqueue_, const Priority &priority_, QueueType qtype_)
inline SubQueue(MandateQueue<T> &mqueue_, const Priority &priority_, QueueType qtype_, const Mandate &mandate_)
inline virtual ~SubQueue()
inline bool operator>(const SubQueue &other) const
inline virtual void operator()() override
inline void activate(void)

Activate the queue.

INVARIANT: The MandateQueue lock must be held before calling this method

inline void deactivate(void)

Deactivate the queue.

INVARIANT: The MandateQueue lock must be held before calling this method

inline bool isThroughput() const

Return true if this queue handles a throughput mandate flow.

inline bool isFileTransfer() const

Return true if this queue handles a file transfer mandate flow.

inline void setMandate(const Mandate &new_mandate)
inline void updateRate(double rate_)
inline void updatePriority(void)
inline void fillBucket(const MonoClock::time_point &now)
inline void setFillBucketTimer(void)
inline bool pop(T &pkt, MandateQueue<T> &mqueue, const MonoClock::time_point &now, bool bonus)
inline container_type::iterator begin(void)
inline container_type::iterator end(void)
inline container_type::reverse_iterator rbegin(void)
inline container_type::reverse_iterator rend(void)
inline container_type::iterator erase(typename container_type::const_iterator pos)
inline container_type::iterator erase(const T &pkt, typename container_type::const_iterator pos)
inline void emplace_front(T &&pkt)
inline void emplace_back(T &&pkt)
inline void append(SubQueue &other)
inline container_type::size_type size() const
inline void clear()

Public Members

Priority priority

Queue priority.

QueueType qtype

Queue type.

bool active

Is this queue active?

std::optional<Mandate> mandate

Associated mandate.

std::optional<NodeId> nexthop

Next hop.

std::optional<double> rate

Encoding rate.

std::optional<double> min_throughput

Minimum throughput (bytes per second)

std::optional<TokenBucket> bucket

Token bucket.

size_t nbytes

Bytes in queue.

Protected Functions

inline void preEmplace(const T &pkt)
inline void postEmplace()
inline bool shouldSend(const T &pkt, bool bonus)
inline void drop(const std::shared_ptr<NetPacket> &pkt) const

Indicate that a packet has been dropped.

inline void updateFileTransferThroughput(void)
inline void setFileTransferThroughput(double new_min_throughput)

Protected Attributes

container_type q_

The queue.

MandateQueue<T> &mq_

The mandate queue.

std::vector<MPStats> stats_

Measurement period statistics.

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

Base class for synthesizers.

Subclassed by ChannelSynthesizer, SlotSynthesizer

Public Functions

inline Synthesizer(std::shared_ptr<PHY> phy, double tx_rate, const Channels &channels)
virtual ~Synthesizer() = default
inline virtual double getTXRate(void)

Get the TX sample rate.

inline virtual void setTXRate(double rate)

Set the TX sample rate.

Parameters

rate – The rate.

inline virtual const Channels &getChannels(void) const

Get channels.

inline virtual void setChannels(const Channels &channels)

Set channels.

inline virtual const Schedule &getSchedule(void) const

Get schedule.

inline virtual void setSchedule(const Schedule &schedule)

Set schedule.

inline virtual void setSchedule(const Schedule::sched_type &schedule)

Set schedule.

virtual void stop(void) = 0

Stop modulating.

virtual void reconfigure(void) = 0

Reconfigure for new TX parameters.

Public Members

NetIn<Pull> sink

Input port for packets.

Protected Attributes

std::shared_ptr<PHY> phy_

Our PHY.

std::mutex mutex_

Mutex for synthesizer state.

double tx_rate_

TX sample rate.

Channels channels_

Radio channels.

Schedule schedule_

Radio schedule.

class TableNCO : public NCO

Public Functions

inline explicit TableNCO(double dtheta)
TableNCO() = default
TableNCO(const TableNCO&) = default
TableNCO(TableNCO&&) = default
virtual ~TableNCO() = default
TableNCO &operator=(const TableNCO&) = default
TableNCO &operator=(TableNCO&&) = default
inline virtual double getFrequency(void) final override

Get frequency in radians per sample.

inline virtual void setFrequency(double dtheta) final override

Set frequency in radians per sample.

inline virtual double getPhase(void) final override

Get phase in radians.

inline virtual void setPhase(double theta) final override

Set phase in radians.

inline virtual void reset(double dtheta) final override

Reset NCO state with given frequency in radians per sample.

inline virtual std::complex<float> mix_up(const std::complex<float> in) final override

Mix a single sample up.

inline virtual std::complex<float> mix_down(const std::complex<float> in) final override

Mix a single sample down.

inline virtual void mix_up(const std::complex<float> *in, std::complex<float> *out, size_t count) final override

Mix a signal up.

inline virtual void mix_down(const std::complex<float> *in, std::complex<float> *out, size_t count) final override

Mix a signal down.

Private Members

sintab<INTBITS>::brad_t theta_
sintab<INTBITS>::brad_t dtheta_

Private Static Attributes

static sintab<INTBITS> sintab_
template<class T>
class TailDropQueue : public SizedQueue<T>
#include <TailDropQueue.hh>

A tail dropD queue.

Public Types

using const_iterator = typename std::list<T>::const_iterator

Public Functions

inline TailDropQueue(size_t max_size)
TailDropQueue() = delete
inline virtual ~TailDropQueue()
inline size_t getMaxSize(void) const

Get maximum size.

inline void setMaxSize(size_t max_size)

Set maximum size.

inline virtual void push(T &&item) override

Push an element onto the queue.

Protected Attributes

size_t max_size_

Maximum size.

class TDChannelizer::TDChannelDemodulator : public ChannelDemodulator

Channel state for time-domain demodulation.

Public Functions

inline TDChannelDemodulator(PHY &phy, const Channel &channel, const std::vector<C> &taps, double rx_rate)
virtual ~TDChannelDemodulator() = 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.

size_t delay_

Filter delay.

IQBuf resamp_buf_

Resampling buffer.

dragonradio::signal::MixingRationalResampler<C, C> resamp_

Resampler.

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

A time-domain channelizer.

Public Functions

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

Add an IQ buffer to demodulate.

Parameters

buf – The IQ samples to demodulate

virtual void reconfigure(void) override

Reconfigure for new RX parameters.

void stop(void)

Stop demodulating.

Private Functions

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.

std::mutex demod_mutex_

Mutex for demodulation state.

std::vector<std::unique_ptr<TDChannelDemodulator>> demods_

Channel state for demodulation.

std::vector<std::unique_ptr<SafeQueue<std::shared_ptr<IQBuf>>>> iqbufs_

Packets to demodulate.

std::vector<std::thread> demod_threads_

Demodulation worker threads.

std::shared_ptr<Logger> logger_

A reference to the global logger.

Private Static Attributes

static const unsigned LOGN = 4
class TDChannelModulator : public ChannelModulator
#include <TDChannelModulator.hh>

Channel state for time-domain modulation.

Public Types

using C = std::complex<float>
using Upsampler = dragonradio::signal::MixingRationalResampler<C, C>

Public Functions

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

Modulate a packet to produce IQ samples.

Parameters
  • pkt – The NetPacket to modulate.

  • gGain to apply.

  • mpkt – The ModPacket in which to place modulated samples.

Protected Attributes

Upsampler upsampler_

Time domain upsampler.

class TDMA : public SlottedMAC
#include <TDMA.hh>

A TDMA MAC.

Public Types

using TDMASchedule = std::vector<bool>

Public Functions

TDMA(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<SlotSynthesizer> synthesizer, double slot_size, double guard_size, double slot_send_lead_time, size_t nslots)
virtual ~TDMA()
TDMA(const TDMA&) = delete
TDMA(TDMA&&) = delete
TDMA &operator=(const TDMA&) = delete
TDMA &operator=(TDMA&&) = delete
virtual void stop(void) override

Stop processing packets.

inline size_t getNSlots(void)

Get number of slots.

virtual void reconfigure(void) override

Reconfigure the MAC when after parameters change.

virtual bool isFDMA(void) const override

Is this MAC FDMA?

Private Functions

void txSlotWorker(void)

Worker preparing slots for transmission.

bool findNextSlot(WallClock::time_point t, WallClock::time_point &t_next, size_t &next_slotidx)

Find next TX slot.

Parameters
  • tTime at which to start looking for a TX slot

  • t_next – The beginning of the next TX slot

  • next_slotidx – Slot index of next slot

Returns

True if a slot was found, false otherwise

Private Members

double frame_size_

Length of TDMA frame (sec)

size_t nslots_

Number of TDMA slots.

TDMASchedule tdma_schedule_

The TDMA schedule.

std::thread rx_thread_

Thread running rxWorker.

std::thread tx_thread_

Thread running txWorker.

std::thread tx_slot_thread_

Thread running txSlotWorker.

std::thread tx_notifier_thread_

Thread running txNotifier.

struct Time
#include <Packet.hh>

A time.

Public Functions

inline void from_mono_time(MonoClock::time_point t)
inline MonoClock::time_point to_mono_time(void) const

Public Members

uint64_t secs
double frac_secs
template<class T>
struct time_point_t

Public Functions

inline explicit time_point_t(double secs = 0)
inline explicit time_point_t(int64_t full_secs, double frac_secs = 0)
inline explicit time_point_t(const uhd::time_spec_t &t0)
time_point_t(const time_point_t&) = default
time_point_t(time_point_t&&) = default
time_point_t &operator=(const time_point_t&) = default
time_point_t &operator=(time_point_t&&) = default
inline time_point_t operator+(const time_point_t &other) const
inline time_point_t operator+(double delta) const
inline time_point_t operator-(const time_point_t &other) const
inline time_point_t operator-(double delta) const
inline time_point_t &operator+=(double delta)
inline bool operator>(const time_point_t &other) const
inline bool operator<(const time_point_t &other) const
inline double get_real_secs(void) const
inline int64_t get_full_secs(void) const
inline double get_frac_secs(void) const

Public Members

uhd::time_spec_t t
struct TimerQueue::Timer : public heap<T, Container, Compare>::element

Subclassed by MandateQueue< T >::SubQueue, RecvWindow, SendWindow::Entry

Public Functions

virtual void operator()() = 0
inline bool operator<(const Timer &other) const

Public Members

time_type deadline
class TimerQueue

Public Types

using time_type = MonoClock::time_point

Public Functions

TimerQueue()
~TimerQueue()
TimerQueue(const TimerQueue&) = delete
TimerQueue(TimerQueue&&) = delete
TimerQueue &operator=(const TimerQueue&) = delete
TimerQueue &operator=(TimerQueue&&) = delete
void run_in(Timer &t, const double &delta)

Run a timer after a delta.

void run_at(Timer &t, const time_type &when)

Run a timer at a specific time.

bool running(const Timer &t)

Return true if a timer is running.

void cancel(Timer &t)

Cancel a timer.

void update(Timer &t)

Update a timer whose deadline has changed.

void run(void)

Execute timer events.

void start(void)

Start a thread to process timers.

void stop(void)

Stop the thread processing timers.

Private Functions

void timer_worker(void)

Timer worker.

Private Members

std::mutex mutex_

Mutex protecting event queue.

heap<Timer> timer_queue_

Event queue.

bool done_

Flag indicating we are done prcoessing timers.

std::thread timer_worker_thread_

Thread that runs the timer worker.

struct ControlMsg::Timestamp

Public Members

TimestampSeq tseq

Timestamp sequence of transmitted packet.

struct ControlMsg::TimestampRecv

Public Members

NodeId node

Node ID of original timestamp transmitter.

TimestampSeq tseq

Timestamp sequence of transmitted packet.

Time t_recv

Receiver’s timestamp of packet.

struct ControlMsg::TimestampSent

Public Members

TimestampSeq tseq

Timestamp sequence of transmitted packet.

Time t_sent

Sent packet’s timestamp.

template<class Clock, class T>
class TimeWindowEstimator : public Estimator<T>
#include <TimeWindowEstimator.hh>

A statistical estimator over a time window.

Subclassed by TimeWindowMax< Clock, T >, TimeWindowMean< Clock, T >, TimeWindowMin< Clock, T >

Public Types

using entry = std::pair<typename Clock::time_point, T>

Public Functions

inline explicit TimeWindowEstimator(double twindow = 1.0)
virtual ~TimeWindowEstimator() = default
inline virtual double getTimeWindow(void) const

Get the current time window.

inline virtual void setTimeWindow(double twindow)

Set the current time window.

inline virtual std::optional<typename Clock::time_point> getTimeWindowStart() const

Get start of window.

inline virtual std::optional<typename Clock::time_point> getTimeWindowEnd() const

Get end of window.

inline virtual operator bool() const override

Does the estimator have a value?

inline virtual std::optional<T> value(void) const override

Return the value of the estimator.

inline virtual T value_or(T &&default_value) const override

Return the value of the estimator or a default.

inline virtual size_t size(void) const override

Return the number of samples used in the estimate.

inline virtual void reset()
inline virtual void update(T x) override

Update the estimator with a new value.

virtual void update(typename Clock::time_point t, T x) = 0

Update the estimator with a new value.

Protected Functions

virtual void purge(typename Clock::time_point t) const = 0

Remove elements outside the time window.

Protected Attributes

double twindow_

Time window (sec)

mutable std::deque<entry> window_

Values in our window.

template<class Clock, class T>
class TimeWindowMax : public TimeWindowEstimator<Clock, T>
#include <TimeWindowEstimator.hh>

Compute maximum over a time window.

Public Functions

inline explicit TimeWindowMax(double twindow = 1.0)
virtual ~TimeWindowMax() = default
inline virtual T operator*() const override

Return the value of the estimator.

inline virtual void update(typename Clock::time_point t, T x) override

Update the estimator with a new value.

Protected Functions

inline virtual void purge(typename Clock::time_point t) const override

Remove elements outside the time window.

Protected Attributes

mutable T max_

Maximum value in our window.

template<class Clock, class T>
class TimeWindowMean : public TimeWindowEstimator<Clock, T>
#include <TimeWindowEstimator.hh>

Compute mean over a time window.

Subclassed by TimeWindowMeanRate< Clock, T >

Public Functions

inline explicit TimeWindowMean(double twindow = 1.0)
virtual ~TimeWindowMean() = default
inline virtual T operator*() const override

Return the value of the estimator.

inline virtual void reset(void) override
inline virtual void update(typename Clock::time_point t, T x) override

Update the estimator with a new value.

Protected Functions

inline virtual void purge(typename Clock::time_point t) const override

Remove elements outside the time window.

Protected Attributes

mutable T sum_

Sum of values in our window.

template<class Clock, class T>
class TimeWindowMeanRate : public TimeWindowMean<Clock, T>
#include <TimeWindowEstimator.hh>

Compute mean value per second over a time window.

Public Functions

inline explicit TimeWindowMeanRate(double twindow = 1.0)
virtual ~TimeWindowMeanRate() = default
inline virtual T operator*() const override

Return the value of the estimator.

template<class Clock, class T>
class TimeWindowMin : public TimeWindowEstimator<Clock, T>
#include <TimeWindowEstimator.hh>

Compute minimum over a time window.

Public Functions

inline explicit TimeWindowMin(double twindow = 1.0)
virtual ~TimeWindowMin() = default
inline virtual T operator*() const override

Return the value of the estimator.

inline virtual void update(typename Clock::time_point t, T x) override

Update the estimator with a new value.

Protected Functions

inline virtual void purge(typename Clock::time_point t) const override

Remove elements outside the time window.

Protected Attributes

mutable T min_

Minimum value in our window.

struct MandateQueue::TokenBucket

Public Members

MonoClock::time_point last_fill

Timestamp of last time bucket was filled.

double tokens

Number of tokens (bytes) in bucket.

double max_tokens

Maximum number of tokens (bytes) allowed in bucket.

class FDUpsampler::ToTimeDomain

Public Functions

inline ToTimeDomain(void)
inline size_t toTimeDomain(const T *in, size_t count, T *out)

Public Members

fftw::FFT<T> ifft

FFT.

class TunTap : public Element

Public Functions

TunTap(const std::string &tap_iface, const std::string &tap_ipaddr, const std::string &tap_ipnetmask, const std::string &tap_macaddr, bool persistent, size_t mtu, uint8_t node_id)

Create a tun/tap device.

Parameters
  • tap_iface – The name of the tun/tap device to create.

  • tap_ipaddr – IP address for tap interface.

  • tap_ipnetmask – Netmask for tap interface

  • tap_macaddrMAC address for tap interface.

  • persistent – Is this device persistent, or should we create it now and destroy it when we are destructed?

  • mtu – MTU size for interface.

  • node_idNode ID

virtual ~TunTap()
size_t getMTU(void)

Return the MTU of this interface.

void addARPEntry(uint8_t node_id)

Add a static ARP table entry to tap device for node.

void deleteARPEntry(uint8_t node_id)

Delete ARP table entryfrom tap device for node.

Public Members

RadioIn<Push> sink

Sink for radio packets. Packets written here are sent to the tun/tap device.

NetOut<Push> source

Source for network packets. Packets read here are received from the tun/tap device.

Private Functions

void openTap(std::string &dev, int flags)

Create and open a tun/tap device.

Parameters
  • dev – The name of the device to open; may be the empty string. This string will be assigned the actual device’s name once it is created.

  • flags – Flags to pass in the ifr_flags field of the ifreq given to ioctl.

void closeTap(void)

Close the tun/tap device.

std::string nodeMACAddress(uint8_t node_id)

Get MAC address for node.

std::string nodeIPAddress(uint8_t node_id)

Get IP address for node.

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

Send a packet to the tun/tap device.

void start(void)

Start the receive worker.

void stop(void)

Stop the receive worker.

void worker(void)

Receive worker.

Private Members

std::shared_ptr<Logger> logger_

A reference to the global logger.

bool persistent_

Flag indicating whether or not the interface is persistent.

std::string tap_iface_

The name of the tun/tap device.

std::string tap_ipaddr_

The name of the tun/tap device.

std::string tap_ipnetmask_

The name of the tun/tap device.

std::string tap_macaddr_

The name of the tun/tap device.

size_t mtu_

MTU of the interface.

int fd_

File descriptor for tun/tap device.

struct ifreq ifr_

ifreq for configuring tap interface

bool done_

Flag indicating whether or not we are done receiving.

std::thread worker_thread_

Receive worker thread.

struct MAC::TXRecord
#include <MAC.hh>

A transmission record.

Public Functions

TXRecord() = default
inline TXRecord(const std::optional<MonoClock::time_point> &timestamp_, size_t delay_, size_t nsamples_, std::list<std::shared_ptr<IQBuf>> &&iqbufs_, std::list<std::unique_ptr<ModPacket>> &&mpkts_) noexcept

Public Members

std::optional<MonoClock::time_point> timestamp

TX deadline.

size_t delay

Number of samples from timestamp transmission was delayed.

size_t nsamples

Number of samples transmitted.

std::list<std::shared_ptr<IQBuf>> iqbufs

Transmitted IQ buffers.

std::list<std::unique_ptr<ModPacket>> mpkts

Transmitted modulated packets.

struct TXRecordEntry

Log entry for TX records.

Public Members

double timestamp

TX timestamp.

double mono_timestamp

Monotonic TX timestamp.

int64_t nsamples

Number of samples.

float fs

Sampling frequency [Hz].

template<>
struct pybind11::detail::type_caster<std::shared_ptr<T>>

Public Types

using BaseCaster = copyable_holder_caster<T, std::shared_ptr<T>>

Public Functions

PYBIND11_TYPE_CASTER(std::shared_ptr<T>, _(TNAME))
inline bool load(pybind11::handle src, bool b)

Public Static Functions

static inline handle cast(std::shared_ptr<T> base, return_value_policy rvp, handle h)
union u_flags

Public Members

Header::Flags flags
uint8_t bits
template<class ChannelModulator>
class UnichannelSynthesizer : public SlotSynthesizer
#include <UnichannelSynthesizer.hh>

A single-channel synthesizer.

Public Functions

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

Modulate a slot.

virtual void reconfigure(void) override

Reconfigure for new TX parameters.

virtual void stop(void) override

Stop modulating.

Protected Functions

void modWorker(std::atomic<bool> &reconfig, unsigned tid)

Thread modulating packets.

Protected Attributes

std::atomic<bool> done_

Flag indicating if we should stop processing packets.

std::vector<std::atomic<bool>> mod_reconfigure_

Reconfiguration flags.

std::mutex curslot_mutex_

Lock for current slot.

std::condition_variable curslot_cond_

Condition variable for current slot.

std::shared_ptr<Slot> curslot_

Current slot that need to be synthesized.

std::vector<std::thread> mod_threads_

Threads running modWorker.

template<class T, class C>
class dragonradio::signal::Upsampler : public dragonradio::signal::Pfb<T, C>, public Resampler<T, T>
#include <Polyphase.hh>

An upsampler that uses a polyphase filter bank.

Public Functions

inline Upsampler(unsigned l, const std::vector<C> &taps)

Construct a polyphase upsampler.

Parameters
  • l – The upsampling rate

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

Upsampler() = delete
virtual ~Upsampler() = default
inline virtual double getRate(void) const override
inline virtual double getDelay(void) const override
inline virtual size_t neededOut(size_t count) const override
inline virtual void reset(void) override
inline virtual size_t resample(const T *in, size_t count, T *out) final override

Protected Functions

inline virtual void reconfigure(void) override

Reconfigure filter bank for current number of channels and taps.

class USRP
#include <USRP.hh>

A USRP.

Public Types

enum DeviceType

Values:

enumerator kUSRPN210
enumerator kUSRPX310
enumerator kUSRPUnknown

Public Functions

USRP(const std::string &addr, const std::optional<std::string> &tx_subdev, const std::optional<std::string> &rx_subdev, double freq, const std::string &tx_ant, const std::string &rx_ant, float tx_gain, float rx_gain)
~USRP()
USRP() = delete
USRP(const USRP&) = delete
USRP(USRP&&) = delete
USRP &operator=(const USRP&) = delete
USRP &operator=(USRP&&) = delete
inline DeviceType getDeviceType(void)

Get type of this device.

inline std::vector<std::string> getClockSources(const size_t mboard = 0)

Get clock sources.

inline std::string getClockSource(const size_t mboard = 0)

Get clock source.

inline void setClockSource(const std::string clock_source, const size_t mboard = uhd::usrp::multi_usrp::ALL_MBOARDS)

Set clock source.

inline std::vector<std::string> getTimeSources(const size_t mboard = 0)

Get time sources.

inline std::string getTimeSource(const size_t mboard = 0)

Get time source.

inline void setTimeSource(const std::string &time_source, const size_t mboard = uhd::usrp::multi_usrp::ALL_MBOARDS)

Set time source.

inline double getMasterClockRate(void)

Get master clock rate.

inline double getTXFrequency(void)

Get TX frequency.

void setTXFrequency(double freq)

Set TX frequency.

Parameters

freq – The center frequency

inline double getRXFrequency(void)

Get RX frequency.

void setRXFrequency(double freq)

Set RX frequency.

Parameters

freq – The center frequency

inline double getTXRate(void)

Get TX rate.

inline void setTXRate(double rate)

Set TX rate.

inline double getRXRate(void)

Get RX rate.

inline void setRXRate(double rate)

Set RX rate.

inline double getTXGain(void)

Get TX gain (dB).

inline void setTXGain(float db)

Set TX gain (dB).

inline double getRXGain(void)

Get RX gain (dB).

inline void setRXGain(float db)

Set RX gain (dB).

inline bool getAutoDCOffset(bool enable)

Get automatic DC offset correction.

inline std::optional<MonoClock::time_point> getNextTXTime()

Get time at which next transmission will occur.

inline void setAutoDCOffset(bool enable)

Set automatic DC offset correction.

void burstTX(std::optional<MonoClock::time_point> when, bool start_of_burst, bool end_of_burst, std::list<std::shared_ptr<IQBuf>> &bufs)

Transmit a burst of IQ buffers at the given time.

Parameters
  • whenTime at which to start the burst.

  • start_of_burst – Is this the start of a burst?

  • end_of_burst – Is this the end of a burst?

  • bufs – A list of IQBufs to transmit.

void stopTXBurst(void)

Stop TX burst.

void startRXStream(MonoClock::time_point when)

Start streaming read.

void stopRXStream(void)

Stop streaming read.

bool burstRX(MonoClock::time_point when, size_t nsamps, IQBuf &buf)

Receive specified number of samples at the given time.

Parameters
  • when – The time at which to start receiving.

  • nsamps – The number of samples to receive.

  • buf – The IQBuf to hold received IQ samples. The buffer should be at least getRecommendedBurstRXSize(nsamps) bytes.

Returns

Returns true if the burst was successfully received, false otherwise.

inline size_t getMaxRXSamps(void)

Return the maximum number of samples we will read at a time during burstRX.

inline void setMaxRXSamps(size_t count)

Set the maximum number of samples we will read at a time during burstRX.

inline void setMaxRXSampsFactor(unsigned n)

Set the multiplier for the maximum number of samples we will read at a time during burstRX.

inline size_t getMaxTXSamps(void)

Return the maximum number of samples we will write at a time during burstTX.

inline void setMaxTXSamps(size_t count)

Set the maximum number of samples we will write at a time during burstTX.

inline void setMaxTXSampsFactor(unsigned n)

Set the multiplier for the maximum number of samples we will read at a time during burstTX.

inline size_t getRecommendedBurstRXSize(size_t nsamps)

Return the recommended buffer size during burstRX.

Parameters

nsamps – Number of samples to read during burst

Returns

Recommended buffer size

inline uint64_t getTXUnderflowCount(void)

Get the TX underflow count.

Returns

The number of TX underflow errors Return the number of TX underflow errors and reset the counter

inline uint64_t getTXLateCount(void)

Get the TX late count.

Returns

The number of late TX packet errors Return the number of TX late packet errors and reset the counter

void stop(void)

Stop processing data.

Private Functions

void determineDeviceType(void)

Determine the type of the main device.

void txErrorWorker(void)

Worker that receives TX errors.

Private Members

uhd::usrp::multi_usrp::sptr usrp_

Our associated UHD USRP.

DeviceType device_type_

The DeviceType of the main device.

double tx_rate_

Current TX rate.

double rx_rate_

Current RX rate.

double tx_freq_

Current TX frequency.

double rx_freq_

Current RX frequency.

uhd::tx_streamer::sptr tx_stream_

The UHD TX stream for this USRP.

uhd::rx_streamer::sptr rx_stream_

The UHD RX stream for this USRP.

size_t tx_max_samps_

Maximum number of samples we will send at a time during burstTX.

size_t rx_max_samps_

Maximum number of samples we will read at a time during burstRX.

std::optional<MonoClock::time_point> t_next_tx_

Time at which next transmission will occur.

bool auto_dc_offset_

Flag indicating whether or not to enable automatic DC offset correction.

bool done_

Flag indicating the we should stop processing data.

std::atomic<uint64_t> tx_underflow_count_

TX underflow count.

std::atomic<uint64_t> tx_late_count_

TX late count.

std::thread tx_error_thread_

Thread that receives TX errors.

class liquid::VCO : public liquid::BaseNCO
#include <NCO.hh>

A “voltage”-controlled oscillator (precise)

Public Functions

inline VCO(double dtheta)
VCO() = delete
VCO(const VCO&) = delete
VCO(VCO&&) = default
inline virtual ~VCO()
VCO &operator=(const VCO&) = delete
VCO &operator=(VCO&&) = default
class WallClock : public Clock
#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

inline MonoClock::time_point getTimeZero(void)

Get time 0 for purposes of linear fit.

inline MonoClock::time_point getTimeOffset(void)

Get time offset.

inline void setTimeOffset(const MonoClock::time_point &offset)

Set time offset.

inline double getSkew(void)

Get skew.

inline void setSkew(double skew)

set skew.

Public Static Functions

static inline time_point now() noexcept

Get the current wall-clock time.

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

Return the monotonic time corresponding to wall-clock time.

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

Return the wall-clock time corresponding to monotonic time.

Public Static Attributes

static const bool is_steady = false

Private Static Attributes

static uhd::time_spec_t offset_

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

static double skew_

Clock skew.

template<class T>
class Window

Public Types

using size_type = typename std::vector<T>::size_type

Public Functions

inline explicit Window(size_type n)
Window() = delete
~Window() = default
inline size_type size(void)

Return window size.

inline void resize(size_type n)

Resize window.

Parameters

n – New window size

inline void reset(void)

Reset window elements to 0.

inline void add(T x)

Add one value to the window.

Parameters

x – The value to add to the window.

template<class C, class Tag>
inline T dotprod(const C *ys, Tag _tag)

Compute dot product of window.

Parameters
  • ys – The second argument to the dot product

  • _tag – An xsimd alignment tag indicating the alignment of ys. The array ys must have an integral multiple of xsimd::simd_type<C> elements. Any elements in ys beyond the first n, where n is the window size, must be zero. These invariants allow us to implement the dot product very efficiently with vector instructions.

inline std::vector<T> get(void) const

Protected Attributes

size_type n_

Window size.

size_type len_

Window size rounded up to next power of two.

size_type mask_

Mask for window read index.

size_type read_idx_

Read index.

std::vector<T, XSIMD_DEFAULT_ALLOCATOR(T)> w_

Samples in our window.

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

Estimate a value by calculating a mean over a window of values.

Public Types

using size_type = typename std::vector<T>::size_type

Public Functions

inline explicit WindowedMean(size_type n)
inline size_type getWindowSize(void) const
inline void setWindowSize(size_type n)
inline virtual operator bool() const override

Does the estimator have a value?

inline virtual T operator*() const override

Return the value of the estimator.

inline virtual std::optional<T> value(void) const override

Return the value of the estimator.

inline virtual T value_or(T &&default_value) const override

Return the value of the estimator or a default.

inline virtual size_t size(void) const override

Return the number of samples used in the estimate.

inline void reset(void)
inline virtual void update(T x) override

Update the estimator with a new value.

Private Members

std::vector<T> window_
size_type i_
T sum_
class WorkQueue
#include <WorkQueue.hh>

A work queue.

Public Functions

explicit WorkQueue(unsigned int nthreads = 0)
WorkQueue(const WorkQueue&) = delete
WorkQueue(WorkQueue&&) = delete
WorkQueue &operator=(const WorkQueue&) = delete
WorkQueue &operator=(WorkQueue&&) = delete
~WorkQueue()
void addThreads(unsigned int nthreads)
void stop(void)
template<typename F, typename ...Args>
inline void submit(F &&f, Args&&... args)
void submit(const std::function<void(void)> &item)
void submit(std::function<void(void)> &&item)

Private Functions

void run_worker(void)

Private Members

bool done_
std::vector<std::thread> threads_
SafeQueue<std::function<void(void)>> work_q_
namespace dragonradio
namespace dragonradio::signal

Functions

PMOutput firpm(std::size_t N, std::vector<double> const &f0, std::vector<double> const &a, std::vector<double> const &w, double fs, double epsT, int Nmax)
PMOutput firpmf(std::size_t N, std::vector<double> const &f0, std::vector<double> const &a, std::vector<double> const &w, std::function<double(double, double, double, double, double, double)> g, double fs, double eps, int Nmax)
PMOutput firpm1f(std::size_t N, std::vector<double> const &f, std::vector<double> const &a, std::vector<double> const &w, double fs, double eps, int Nmax)
PMOutput firpm1f2(std::size_t N, std::vector<double> const &f, std::vector<double> const &a, std::vector<double> const &w, double fs, double eps, int Nmax)
namespace fftw

Typedefs

template<typename T>
using vector = std::vector<T, allocator<T>>

Variables

std::mutex mutex

Creation of FFTW plans is not re-rentrant, so we need to protect access with a mutex.

namespace liquid

Typedefs

typedef std::complex<float> C
typedef float F

Functions

std::vector<float> parks_mcclellan(unsigned int n, float fc, float As)
std::vector<float> kaiser(unsigned int n, float fc, float As)
std::tuple<std::vector<float>, std::vector<float>> butter_lowpass(unsigned int N, float fc, float f0, float Ap, float As)
std::vector<float> parks_mcclellan(unsigned n, float fc, float As)

Construct a lowpass filter using Liquid’s Parks-McClellan implementation.

Parameters
  • nFilter length

  • fc – cutoff frequency

  • As – stop-band attenuation (dB)

Returns

A vector of FIR coefficients

std::vector<float> kaiser(unsigned n, float fc, float As)

Construct a lowpass filter using Liquid’s Kaiser window implementation.

Parameters
  • nFilter length

  • fc – cutoff frequency

  • As – stop-band attenuation (dB)

Returns

A vector of FIR coefficients

inline void mcs2genprops(const MCS &mcs, ofdmflexframegenprops_s &props)
inline void mcs2genprops(const MCS &mcs, origflexframegenprops_s &props)
inline void mcs2genprops(const MCS &mcs, flexframegenprops_s &props)
inline mcsidx_t getMCSIndex(const std::vector<PHY::MCSEntry> &mcs_table, const framesyncstats_s &stats_)

Get MCS index of MCS in frame stats.

Variables

std::mutex mutex

Creation of liquid objects is not re-rentrant, so we need to protect access with a mutex.

const size_t kInitialModbufSize = 16384
namespace pybind11
namespace detail
namespace literals
namespace complex_literals
namespace placeholders
file barrier.hh
#include <atomic>#include <thread>
file buffer.hh
#include <algorithm>#include <cstring>#include <cstdlib>#include <limits>#include <new>#include <stdexcept>#include <type_traits>

Functions

template<typename T>
bool operator==(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
bool operator<(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
bool operator!=(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
bool operator>(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
bool operator<=(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
bool operator>=(const buffer<T> &lhs, const buffer<T> &rhs)
template<typename T>
void swap(buffer<T> &lhs, buffer<T> &rhs)
file CIL.hh
#include <optional>#include <unordered_map>#include “RadioNet.hh”

Typedefs

using MandateMap = std::unordered_map<FlowUID, Mandate>
file Scorer.cc
#include “cil/CIL.hh”#include “cil/Scorer.hh”

Variables

const double kFTSuccessMandate = 0.9
file Scorer.hh

Typedefs

using ScoreMap = std::unordered_map<FlowUID, Scores>
file Clock.cc
#include <stdio.h>#include <string.h>#include <time.h>#include “Clock.hh”
file Clock.cc
#include <pybind11/pybind11.h>#include “Clock.hh”#include “python/PyModules.hh”

Functions

template<class T>
pybind11::class_<T, std::shared_ptr<T>> exportTimePoint(py::module &m, const char *name)
void exportClock(py::module &m)
file Clock.hh
#include <chrono>#include <memory>#include <uhd/usrp/multi_usrp.hpp>

Functions

template<class T>
double fmod(const time_point_t<T> &t, double x)
template<class T>
bool approx(const time_point_t<T> &t1, const time_point_t<T> &t2)
file FDResample.hh
#include <assert.h>#include <complex>#include <xsimd/xsimd.hpp>#include <xsimd/stl/algorithms.hpp>#include “dsp/FFTW.hh”
file FFTW.cc
#include “dsp/FFTW.hh”
file FFTW.hh
#include <complex>#include <memory>#include <mutex>#include <vector>#include <fftw3.h>
file Filter.hh
#include <vector>
file Filter.hh
#include <complex>#include <tuple>#include <vector>#include <liquid/liquid.h>#include “dsp/Filter.hh”

Defines

final
file FIR.hh
#include <vector>#include <xsimd/xsimd.hpp>#include “dsp/Filter.hh”#include “dsp/Window.hh”

Defines

final
file FIRDesign.cc
#include <firpm/pm.h>#include “FIRDesign.hh”
file FIRDesign.hh
#include <complex>#include <vector>
file NCO.hh
#include <sys/types.h>#include <complex>#include <memory>#include <liquid/liquid.h>
file NCO.hh
#include <complex>#include <liquid/liquid.h>#include “dsp/NCO.hh”

Defines

final
file Polyphase.hh
#include <assert.h>#include <vector>#include <xsimd/xsimd.hpp>#include “Math.hh”#include “dsp/Filter.hh”#include “dsp/Resample.hh”#include “dsp/TableNCO.hh”#include “dsp/Window.hh”

Defines

final
file Resample.hh
#include <complex>#include “IQBuffer.hh”

Typedefs

using C = std::complex<float>
file Resample.hh
#include <complex>#include <functional>#include <memory>#include <liquid/liquid.h>#include “IQBuffer.hh”#include “dsp/Resample.hh”

Defines

final
file sintab.hh
#include <complex>
file TableNCO.cc
#include <math.h>#include “dsp/TableNCO.hh”
file TableNCO.hh
#include “dsp/sintab.hh”#include “dsp/NCO.hh”

Defines

final

Variables

constexpr int INTBITS = 12
file Window.hh
#include <vector>#include <xsimd/xsimd.hpp>

Functions

inline uint32_t nextPowerOfTwo(uint32_t x)
file ExtensibleDataSet.cc
#include “ExtensibleDataSet.hh”

Variables

constexpr size_t kBlockSize = 4 * 1024

File block size(-ish)

constexpr size_t kAllocGranularity = 1024 * kBlockSize

We allocate capacity in multiples of this.

constexpr size_t kChunkGranularity = 32 * kBlockSize

We chunk in multiples of this.

file ExtensibleDataSet.hh
#include <string>#include <H5Cpp.h>

Typedefs

using Group = H5::CommonFG
file Header.hh
#include <sys/types.h>#include <stdint.h>#include <string.h>#include <netinet/in.h>#include <complex>#include <cstddef>#include <iterator>#include <vector>#include <liquid/liquid.h>#include “Seq.hh”

Defines

PACKED

Typedefs

typedef uint8_t NodeId

Variables

const NodeId kNodeBroadcast = 255
struct Header PACKED
file heap.hh
#include <functional>#include <limits>#include <utility>#include <vector>
file IQBuffer.hh
#include <atomic>#include <complex>#include <deque>#include <memory>#include <optional>#include <thread>#include <vector>#include <xsimd/xsimd.hpp>#include <xsimd/stl/algorithms.hpp>#include <uhd/types/time_spec.hpp>#include “buffer.hh”#include “Clock.hh”
file IQCompression.cc
#include “IQCompression.hh”#include “IQCompression/FLAC.hh”

Functions

void convert2sc16(const fc32_t *from, sc16_t *to, size_t n)

Convert fc32 format to sc16.

void convert2fc32(const sc16_t *from, fc32_t *to, size_t n)

Convert sc16 format to fc32.

buffer<char> compressIQData(const fc32_t *data, size_t n)

Compress fc32 IQ data.

buffer<fc32_t> decompressIQData(const char *data, size_t n)

Decompress fc32 IQ data.

file IQCompression.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <FLAC++/decoder.h>#include <FLAC++/encoder.h>#include “IQBuffer.hh”#include “IQCompression.hh”#include “IQCompression/FLAC.hh”#include “python/PyModules.hh”

Defines

HIDDEN

Functions

void exportIQCompression(py::module &m)
file IQCompression.hh
#include <atomic>#include <complex>#include <deque>#include <memory>#include <vector>#include <FLAC++/decoder.h>#include <FLAC++/encoder.h>#include “IQBuffer.hh”

Typedefs

typedef std::complex<int16_t> sc16_t
typedef std::complex<float> fc32_t
typedef std::complex<double> fc64_t

Functions

void convert2sc16(const fc32_t *from, sc16_t *to, size_t n)

Convert fc32 format to sc16.

void convert2fc32(const sc16_t *from, fc32_t *to, size_t n)

Convert sc16 format to fc32.

buffer<char> compressIQData(const fc32_t *data, size_t n)

Compress fc32 IQ data.

buffer<fc32_t> decompressIQData(const char *data, size_t n)

Decompress fc32 IQ data.

file FLAC.cc
#include <xsimd/xsimd.hpp>#include “IQCompression.hh”#include “IQCompression/FLAC.hh”

Functions

void convert2int32(const fc32_t *in_, const size_t n, int32_t *out)

Convert fc32_t IQ data to interleaved int32 format.

template<class T>
void interleave(const T &c, const T &y, T *res)
template<>
void interleave<float>(const float &x, const float &y, float *res)
template<>
void interleave<xsimd::simd_type<float>>(const xsimd::simd_type<float> &x, const xsimd::simd_type<float> &y, xsimd::simd_type<float> *res_)
void convert2fc32(const int32_t *const in[], const size_t size, fc32_t *out_)

Convert non-interleaved int32 format to fc32.

Variables

constexpr unsigned kBits = 14
file FLAC.hh
#include <atomic>#include <complex>#include <deque>#include <memory>#include <vector>#include <FLAC++/decoder.h>#include <FLAC++/encoder.h>
file Filter.cc
#include <assert.h>#include “liquid/Filter.hh”
file Filter.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include <firpm/pm.h>#include “dsp/FIR.hh”#include “dsp/FIRDesign.hh”#include “dsp/Filter.hh”#include “dsp/Window.hh”#include “liquid/Filter.hh”#include “python/PyModules.hh”

Functions

template<class I, class O>
void exportFilter(py::module &m, const char *name)
template<class I, class O, class C>
void exportLiquidFIR(py::module &m, const char *name)
template<class I, class O, class C>
void exportLiquidIIR(py::module &m, const char *name)
template<class T, class C>
void exportDragonFIR(py::module &m, const char *name)
template<class T>
void exportWindow(py::module &m, const char *name)
void exportFilters(py::module &m)
file FlexFrame.hh
#include <complex>#include <functional>#include <liquid/liquid.h>#include “dsp/FFTW.hh”#include “liquid/Modem.hh”
file FlexFrame.hh
#include “liquid/FlexFrame.hh”#include “liquid/PHY.hh”

Defines

final
file Modem.cc
#include “liquid/Modem.hh”
file Modem.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “phy/Modem.hh”#include “python/PyModules.hh”

Typedefs

using Demod = std::pair<std::optional<Header>, std::optional<py::bytes>>

Functions

py::array_t<std::complex<float>> modulate(Modulator &mod, const Header &hdr, py::buffer payload)
std::vector<Demod> demodulate(Demodulator &demod, py::array_t<std::complex<float>, py::array::c_style | py::array::forcecast> sig)
void exportModem(py::module &m)

Variables

const size_t kInitialModbufSize = 16384
file Modem.hh
#include <complex>#include <functional>#include <liquid/liquid.h>#include “Header.hh”#include “liquid/Mutex.hh”#include “phy/Modem.hh”
file Modem.hh
#include <functional>#include <Header.hh>#include <liquid/liquid.h>

Typedefs

typedef unsigned mcsidx_t

An index into the PHY’s MCS table.

file Mutex.cc
#include “liquid/Mutex.hh”
file Mutex.hh
#include <mutex>
file NewFlexFrame.hh
#include <complex>#include <functional>#include <liquid/liquid.h>#include “dsp/FFTW.hh”#include “liquid/Modem.hh”
file NewFlexFrame.hh
#include “liquid/NewFlexFrame.hh”#include “liquid/PHY.hh”

Defines

final
file OFDM.cc
#include “liquid/OFDM.hh”
file OFDM.hh
#include <complex>#include <functional>#include <optional>#include <liquid/liquid.h>#include “dsp/FFTW.hh”#include “liquid/Modem.hh”
file OFDM.hh
#include “liquid/OFDM.hh”#include “liquid/PHY.hh”

Defines

final
file PHY.cc
#include <xsimd/xsimd.hpp>#include <xsimd/stl/algorithms.hpp>#include “Logger.hh”#include “WorkQueue.hh”#include “dsp/NCO.hh”#include “liquid/PHY.hh”
file PHY.cc
#include “PHY.hh”
file PHY.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “WorkQueue.hh”#include “phy/FlexFrame.hh”#include “phy/Gain.hh”#include “phy/NewFlexFrame.hh”#include “phy/OFDM.hh”#include “phy/PHY.hh”#include “python/PyModules.hh”#include “python/py_shared_ptr.hh”

Defines

T
TNAME
T
TNAME

Typedefs

using fc32 = std::complex<float>
using PacketDemodulator = PHY::PacketDemodulator
using PacketModulator = PHY::PacketModulator

Functions

void exportPHYs(py::module &m)
void exportLiquidPHYs(py::module &m)
file PHY.hh
#include <complex>#include <functional>#include <type_traits>#include <liquid/liquid.h>#include “Clock.hh”#include “Logger.hh”#include “Packet.hh”#include “dsp/TableNCO.hh”#include “liquid/Modem.hh”#include “liquid/Resample.hh”#include “phy/PHY.hh”

Defines

final
file PHY.hh
#include <atomic>#include <functional>#include <list>#include “logging.hh”#include “IQBuffer.hh”#include “Packet.hh”#include “RadioNet.hh”#include “mac/Snapshot.hh”#include “phy/AutoGain.hh”
file Resample.cc
#include <assert.h>#include “liquid/Resample.hh”
file Resample.cc
#include <pybind11/pybind11.h>#include <pybind11/complex.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “dsp/Polyphase.hh”#include “dsp/Resample.hh”#include “liquid/Resample.hh”#include “python/PyModules.hh”

Functions

template<class I, class O>
void exportResampler(py::module &m, const char *name)
template<class I, class O, class C>
void exportLiquidMSResamp(py::module &m, const char *name)
template<class T, class C>
void exportDragonPfb(py::module &m, const char *name)
template<class T, class C>
void exportDragonUpsampler(py::module &m, const char *name)
template<class T, class C>
void exportDragonDownsampler(py::module &m, const char *name)
template<class T, class C>
void exportDragonRationalResampler(py::module &m, const char *name)
template<class T, class C>
void exportDragonMixingRationalResampler(py::module &m, const char *name)
void exportResamplers(py::module &m)
file Controller.hh
#include <functional>#include <list>#include “RadioNet.hh”#include “net/Element.hh”#include “net/Queue.hh”#include “phy/PHY.hh”#include “phy/Synthesizer.hh”
file DummyController.cc
#include “llc/DummyController.hh”
file DummyController.hh
#include <mutex>#include <unordered_map>#include “llc/Controller.hh”
file SmartController.cc
#include “Logger.hh”#include “llc/SmartController.hh”

Defines

DEBUG
dprintf(...)

Functions

inline void appendSelectiveACK(const std::shared_ptr<NetPacket> &pkt, RecvWindow &recvw, Seq begin, Seq end)
file SmartController.hh
#include <sys/types.h>#include <netinet/if_ether.h>#include <list>#include <map>#include <random>#include “heap.hh”#include “Clock.hh”#include “TimerQueue.hh”#include “llc/Controller.hh”#include “mac/MAC.hh”#include “phy/Gain.hh”#include “phy/PHY.hh”#include “stats/Estimator.hh”#include “stats/TimeWindowEstimator.hh”
file proxies.hh
#include “llc/SmartController.hh”
file Logger.cc
#include <stdint.h>#include <complex>#include <H5Cpp.h>#include “Clock.hh”#include “IQCompression.hh”#include “Logger.hh”

Variables

std::shared_ptr<Logger> logger

The global logger.

constexpr size_t kBlockSize = 4 * 1024

File block size(-ish)

constexpr int kMDCNumElements = 512

Number of elements in the meta data cache.

constexpr size_t kRDCCNumElements = 512

Number of elements in the raw data chunk cache.

constexpr size_t kRDCCNumBytes = 16 * 1024 * kBlockSize

Total size of the raw data chunk cache, in bytes.

constexpr double kRDCCW0 = 0.0

Preemption policy.

file Logger.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “logging.hh”#include “Clock.hh”#include “Logger.hh”#include “python/PyModules.hh”

Functions

std::shared_ptr<Logger> mkLogger(const std::string &path)
void addLoggerSource(py::class_<Logger, std::shared_ptr<Logger>> &cls, const std::string &name, Logger::Source src)
void exportLogger(py::module &m)
file Logger.hh
#include <time.h>#include <memory>#include <mutex>#include <string>#include <thread>#include <uhd/usrp/multi_usrp.hpp>#include <H5Cpp.h>#include “buffer.hh”#include “Clock.hh”#include “ExtensibleDataSet.hh”#include “IQBuffer.hh”#include “Packet.hh”#include “SafeQueue.hh”#include “mac/Snapshot.hh”

Variables

std::shared_ptr<Logger> logger

The global logger.

file logging.cc
#include <cassert>#include “logging.hh”#include “Logger.hh”

Functions

bool isLogLevelEnabled(EventCategory cat, loglevel lvl)

Return true if logging is enabled for level.

void setLogLevel(EventCategory cat, loglevel lvl)

Set log level.

bool isPrintLogLevelEnabled(EventCategory cat, loglevel lvl)

Return true if printing is enabled for level.

void setPrintLogLevel(EventCategory cat, loglevel lvl)

Set printing log level.

std::string eventCategory2string(EventCategory cat)

Return the string name of an event category.

EventCategory string2EventCategory(const std::string &s)

Return the named event category.

void vlogEvent(const MonoClock::time_point &t, EventCategory cat, loglevel lvl, const char *fmt, va_list ap)

Log an event.

Variables

loglevel loglevels[kNumEvents] = {0}

Event category log levels.

loglevel printlevels[kNumEvents] = {0}

Event category log print levels.

static const char *kEventCategoryString[] = {"SYSTEM", "SCHEDULER", "NET", "TUNTAP", "TIMESYNC", "AMC", "ARQ", "MAC", "PHY", "USRP"}
constexpr size_t MAXLEN = 1024
file logging.hh
#include <stdarg.h>#include “Clock.hh”#include “Logger.hh”

Defines

logSystem(lvl, ...)
logScheduler(lvl, ...)
logNet(lvl, ...)
logTunTap(lvl, ...)
logTimeSync(lvl, ...)
logAMC(lvl, ...)
logARQ(lvl, ...)
logMAC(lvl, ...)
logPHY(lvl, ...)
logUSRP(lvl, ...)
logUSRPAt(t, lvl, ...)

Typedefs

using loglevel = unsigned

Enums

enum EventCategory

Event categories.

Values:

enumerator kEventSystem
enumerator kEventScheduler
enumerator kEventNet
enumerator kEventTunTap
enumerator kEventTimeSync
enumerator kEventAMC
enumerator kEventARQ
enumerator kEventMAC
enumerator kEventPHY
enumerator kEventUSRP
enumerator kNumEvents

Functions

std::string eventCategory2string(EventCategory cat)

Return the string name of an event category.

EventCategory string2EventCategory(const std::string &s)

Return the named event category.

bool isLogLevelEnabled(EventCategory, loglevel)

Return true if logging is enabled for level.

void setLogLevel(EventCategory, loglevel)

Set log level.

bool isPrintLogLevelEnabled(EventCategory, loglevel)

Return true if printing is enabled for level.

void setPrintLogLevel(EventCategory, loglevel)

Set printing log level.

void vlogEvent(const MonoClock::time_point &t, EventCategory cat, loglevel lvl, const char *fmt, va_list ap)

Log an event.

inline void logEvent(EventCategory cat, loglevel lvl, const char *fmt, ...)

Log an event using current time.

inline void logEventAt(const MonoClock::time_point &t, EventCategory cat, loglevel lvl, const char *fmt, ...)

Log an event at specific time.

Variables

const loglevel LOGCRITICAL = 50
const loglevel LOGERROR = 40
const loglevel LOGWARNING = 30
const loglevel LOGINFO = 20
const loglevel LOGDEBUG = 10
const loglevel LOGNOTSET = 0
loglevel loglevels[kNumEvents]

Event category log levels.

loglevel printlevels[kNumEvents]

Event category log print levels.

file FDMA.cc
#include “Clock.hh”#include “USRP.hh”#include “mac/FDMA.hh”
file FDMA.hh
#include <vector>#include “USRP.hh”#include “phy/Channelizer.hh”#include “phy/PHY.hh”#include “phy/ChannelSynthesizer.hh”#include “mac/MAC.hh”
file MAC.cc
#include “mac/MAC.hh”#include “util/threads.hh”
file MAC.cc
#include <time.h>#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “mac/FDMA.hh”#include “mac/SlottedALOHA.hh”#include “mac/SlottedMAC.hh”#include “mac/TDMA.hh”#include “python/PyModules.hh”

Functions

void exportMACs(py::module &m)
file MAC.hh
#include <deque>#include <memory>#include “USRP.hh”#include “llc/Controller.hh”#include “mac/MAC.hh”#include “mac/Snapshot.hh”#include “phy/Channel.hh”#include “phy/Channelizer.hh”#include “phy/PHY.hh”#include “phy/Synthesizer.hh”
file Schedule.hh
#include <vector>
file SlottedALOHA.cc
#include “Clock.hh”#include “USRP.hh”#include “mac/SlottedALOHA.hh”#include “util/threads.hh”
file SlottedALOHA.hh
#include <random>#include <vector>#include “RadioNet.hh”#include “USRP.hh”#include “phy/Channelizer.hh”#include “phy/PHY.hh”#include “phy/Synthesizer.hh”#include “mac/MAC.hh”#include “mac/SlottedMAC.hh”
file SlottedMAC.cc
#include “Logger.hh”#include “SlottedMAC.hh”#include “liquid/Modem.hh”#include “util/threads.hh”

Typedefs

using Slot = SlotSynthesizer::Slot
file SlottedMAC.hh
#include <atomic>#include <mutex>#include <optional>#include <queue>#include “Clock.hh”#include “Logger.hh”#include “RadioNet.hh”#include “SafeQueue.hh”#include “USRP.hh”#include “phy/Channelizer.hh”#include “phy/PHY.hh”#include “phy/SlotSynthesizer.hh”#include “mac/MAC.hh”#include “mac/Schedule.hh”
file Snapshot.cc
#include <mutex>#include “mac/Snapshot.hh”
file Snapshot.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “mac/Snapshot.hh”#include “python/PyModules.hh”

Functions

void exportSnapshot(py::module &m)
file Snapshot.hh
#include <atomic>#include <memory>#include <mutex>#include “IQBuffer.hh”
file TDMA.cc
#include “Clock.hh”#include “USRP.hh”#include “mac/TDMA.hh”#include “util/threads.hh”
file TDMA.hh
#include <vector>#include “RadioNet.hh”#include “USRP.hh”#include “phy/Channelizer.hh”#include “phy/PHY.hh”#include “phy/Synthesizer.hh”#include “mac/MAC.hh”#include “mac/SlottedMAC.hh”
file main.cc
#include <stdio.h>#include <stdlib.h>#include <execinfo.h>#include <signal.h>#include <pybind11/embed.h>#include “Logger.hh”#include “util/capabilities.hh”#include “phy/PHY.hh”

Defines

MAXFRAMES

Functions

void backtraceHandler(int signum, siginfo_t *si, void *ptr)

A signal handler that prints a backtrace.

See: https://stackoverflow.com/questions/77005/how-to-automatically-generate-a-stacktrace-when-my-program-crashes

void activateVirtualenv(void)

Activate Python virtual environment.

If the environmement variable VIRTUAL_ENV is set, use the associated virtualenv. This allows us to use the virtualenv even through the dragonradio binary is not located in the virtual environment’s bin directory.

void setPythonArgv(int argc, char **argv)

Set Python sys.argv.

int main(int argc, char **argv)
file Math.cc
#include <math.h>#include “Math.hh”
file Math.hh
#include <limits>
file Element.hh
#include <functional>#include <memory>#include “Packet.hh”

This modules contains a Click-inspired, modern C++ implementation of push-pull elements.

Typedefs

template<typename D>
using NetIn = Port<In, D, std::shared_ptr<NetPacket>>
template<typename D>
using NetOut = Port<Out, D, std::shared_ptr<NetPacket>>
template<typename D>
using RadioIn = Port<In, D, std::shared_ptr<RadioPacket>>
template<typename D>
using RadioOut = Port<Out, D, std::shared_ptr<RadioPacket>>
file Firewall.hh
#include <sys/types.h>#include <sys/socket.h>#include <netinet/if_ether.h>#include <netinet/in.h>#include <netinet/ip.h>#include <netinet/udp.h>#include <netinet/tcp.h>#include <arpa/inet.h>#include <mutex>#include <unordered_set>#include “logging.hh”#include “Clock.hh”#include “Packet.hh”#include “cil/CIL.hh”#include “net/Processor.hh”#include “stats/TimeWindowEstimator.hh”

Typedefs

using NetFirewall = Firewall<std::shared_ptr<NetPacket>>
using RadioFirewall = Firewall<std::shared_ptr<RadioPacket>>
file FlowPerformance.cc
#include <sys/types.h>#include <sys/socket.h>#include <netinet/if_ether.h>#include <netinet/in.h>#include <netinet/ip.h>#include <netinet/udp.h>#include <netinet/tcp.h>#include <arpa/inet.h>#include <sys/time.h>#include “Logger.hh”#include “net/FlowPerformance.hh”

Defines

DEBUG
logMgen(...)
file FlowPerformance.hh
#include <mutex>#include <optional>#include <unordered_map>#include “Clock.hh”#include “Packet.hh”#include “cil/CIL.hh”#include “net/Processor.hh”#include “stats/TimeWindowEstimator.hh”

Typedefs

using FlowStatsMap = std::unordered_map<FlowUID, FlowStats>
file MandateQueue.hh
#include <condition_variable>#include <deque>#include <mutex>#include <optional>#include <set>#include <unordered_map>#include “Logger.hh”#include “TimerQueue.hh”#include “cil/CIL.hh”#include “net/Queue.hh”

Typedefs

using MandateNetQueue = MandateQueue<std::shared_ptr<NetPacket>>
file mgen.h
#include <sys/types.h>#include <arpa/inet.h>#include <byteswap.h>#include “Clock.hh”

Defines

PACKED

Typedefs

typedef uint32_t mgen_secs_t
typedef uint32_t mgen_usecs_t

Enums

enum [anonymous]

Values:

enumerator MGEN_VERSION

MGEN version number.

enumerator DARPA_MGEN_VERSION

DARPA MGEN version number.

enum [anonymous]

Values:

enumerator MGEN_INVALID_ADDRESS
enumerator MGEN_IPv4
enumerator MGEN_IPv6
enum [anonymous]

Values:

enumerator MGEN_INVALID_GPS
enumerator MGEN_STALE
enumerator MGEN_CURRENT
enum [anonymous]

Values:

enumerator MGEN_CLEAR
enumerator MGEN_CONTINUES
enumerator MGEN_END_OF_MSG
enumerator MGEN_CHECKSUM
enumerator MGEN_LAST_BUFFER
enumerator MGEN_CHECKSUM_ERROR
file NetFilter.cc
#include <sys/types.h>#include <sys/socket.h>#include <netinet/if_ether.h>#include <netinet/in.h>#include <netinet/ip.h>#include <arpa/inet.h>#include <cstddef>#include “logging.hh”#include “net/NetFilter.hh”#include “util/net.hh”
file NetFilter.hh
#include <functional>#include “RadioNet.hh”#include “net/Processor.hh”
file Noop.hh
#include “net/Processor.hh”

Typedefs

using NetNoop = Noop<std::shared_ptr<NetPacket>>
using RadioNoop = Noop<std::shared_ptr<RadioPacket>>
file PacketCompressor.cc
#include <sys/types.h>#include <sys/socket.h>#include <netinet/if_ether.h>#include <netinet/in.h>#include <netinet/ip.h>#include <netinet/udp.h>#include <netinet/tcp.h>#include <arpa/inet.h>#include <sys/time.h>#include <functional>#include “Logger.hh”#include “RadioNet.hh”#include “net/PacketCompressor.hh”

Defines

DEBUG
logCompress(...)

Functions

uint16_t ip_checksum_update(uint16_t cksum, const void *data_, size_t count)
uint16_t ip_checksum(const void *data, size_t count)
uint16_t udp_checksum(const struct ip *iph, const struct udphdr *udph, size_t udp_len)
uint32_t crc32(const void *data_, size_t count)

Variables

const uint32_t CRC32_TABLE[256]
const uint32_t CRC32_XINIT = 0xFFFFFFFFL

Initial value.

const uint32_t CRC32_XOROT = 0xFFFFFFFFL

Final xor value.

const u_int8_t kExpectedTTL = 254
const int32_t kExpectedLatitude = htonl((999 + 180) * 60000)
const int32_t kExpectedLongitude = htonl((999 + 180) * 60000)
const int32_t kExpectedAltitude = htonl(static_cast<int32_t>(-999))
file PacketCompressor.hh
#include <sys/types.h>#include <arpa/inet.h>#include “Packet.hh”#include “net/Element.hh”
file Processor.hh
#include <functional>#include “net/Element.hh”

Typedefs

using NetProcessor = Processor<std::shared_ptr<NetPacket>>
using RadioProcessor = Processor<std::shared_ptr<RadioPacket>>
file Queue.hh
#include <functional>#include <mutex>#include “Header.hh”#include “net/Element.hh”

Typedefs

using NetQueue = Queue<std::shared_ptr<NetPacket>>
file REDQueue.hh
#include <list>#include <random>#include “logging.hh”#include “Clock.hh”#include “net/Queue.hh”#include “net/SizedQueue.hh”

Typedefs

using REDNetQueue = REDQueue<std::shared_ptr<NetPacket>>
file SimpleQueue.hh
#include <condition_variable>#include <mutex>#include “net/Queue.hh”

Typedefs

using SimpleNetQueue = SimpleQueue<std::shared_ptr<NetPacket>>
file SizedQueue.hh
#include <list>#include <random>#include “logging.hh”#include “Clock.hh”#include “net/Queue.hh”

Typedefs

using SizedNetQueue = SizedQueue<std::shared_ptr<NetPacket>>
file TailDropQueue.hh
#include <list>#include “Clock.hh”#include “net/Queue.hh”#include “net/SizedQueue.hh”

Typedefs

using TailDropNetQueue = TailDropQueue<std::shared_ptr<NetPacket>>
file TunTap.cc
#include <sys/types.h>#include <sys/ioctl.h>#include <netinet/if_ether.h>#include <linux/if_tun.h>#include <fcntl.h>#include <string.h>#include <unistd.h>#include <functional>#include “logging.hh”#include “RadioNet.hh”#include “net/TunTap.hh”#include “util/capabilities.hh”#include “util/net.hh”#include “util/sprintf.hh”#include “util/threads.hh”

This code has been heavily modified from the version included in the reference SC2 radio. That code appears to have been taken from this Tun/Tap interface tutorial without attribution.

Variables

static const char *clonedev = "/dev/net/tun"
file TunTap.hh
#include <sys/ioctl.h>#include <net/if.h>#include <string>#include <thread>#include <vector>#include “Logger.hh”#include “net/Element.hh”
file Packet.cc
#include “Packet.hh”
file Packet.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “Header.hh”#include “Packet.hh”#include “python/PyModules.hh”

Typedefs

using fc32 = std::complex<float>

Functions

void exportPacket(py::module &m)
file Packet.hh
#include <sys/types.h>#include <netinet/if_ether.h>#include <netinet/ip.h>#include <netinet/udp.h>#include <netinet/tcp.h>#include <complex>#include <cstddef>#include <iterator>#include <optional>#include <vector>#include <liquid/liquid.h>#include “buffer.hh”#include “Clock.hh”#include “Header.hh”#include “IQBuffer.hh”#include “net/mgen.h”#include “phy/Channel.hh”#include “phy/Modem.hh”

Defines

PACKED

Typedefs

using TimestampSeq = uint16_t

Timestamp sequence number.

typedef uint16_t FlowUID

A flow UID.

Enums

enum CompressionType

Values:

enumerator kUncompressed

Uncompressed packet.

enumerator kEthernet

Compressed Ethernet packet.

enumerator kIP

Compressed IP packet.

enumerator kUDP

Compressed UDP packet.

enumerator kMGEN

Compressed (UDP) MGEN version 2 packet.

enumerator kDARPAMGEN

Compressed (UDP) DARPA MGEN version 4 packet.

enum CompressedIPAddress

Type of IP address compression used.

Values:

enumerator kIPUncompressed

Uncompressed IP address.

enumerator kIPInternal

Internal network IP address.

enumerator kIPExternal

External network IP address.

Functions

constexpr size_t ctrlsize(uint8_t ty)

Compute the size of the specified control message.

Variables

struct ControlMsg PACKED
file AutoGain.cc
#include “logging.hh”#include “phy/AutoGain.hh”
file AutoGain.hh
#include <complex>#include <mutex>#include <shared_mutex>#include <liquid/liquid.h>#include “IQBuffer.hh”#include “phy/Modem.hh”#include “stats/Estimator.hh”
file Channel.hh
#include <complex>#include <vector>#include <boost/functional/hash.hpp>

Typedefs

using C = std::complex<float>
using Taps = std::vector<C>

FIR taps.

using Channels = std::vector<std::pair<Channel, Taps>>

A vector of pairs of channels and taps.

file Channelizer.hh
#include “IQBuffer.hh”#include “RadioNet.hh”#include “phy/Channel.hh”#include “phy/PHY.hh”
file ChannelSynthesizer.hh
#include <atomic>#include <list>#include <memory>#include <mutex>#include “phy/Channel.hh”#include “phy/ModPacketQueue.hh”#include “phy/PHY.hh”#include “phy/Synthesizer.hh”
file FDChannelizer.cc
#include <math.h>#include <functional>#include <xsimd/xsimd.hpp>#include <xsimd/stl/algorithms.hpp>#include <pybind11/pybind11.h>#include “phy/FDChannelizer.hh”#include “phy/PHY.hh”
file FDChannelizer.hh
#include <condition_variable>#include <functional>#include <list>#include <mutex>#include “barrier.hh”#include “Logger.hh”#include “SafeQueue.hh”#include “dsp/FFTW.hh”#include “dsp/Polyphase.hh”#include “dsp/TableNCO.hh”#include “phy/Channel.hh”#include “phy/Channelizer.hh”
file FDChannelModulator.cc
#include “phy/FDChannelModulator.hh”
file FDChannelModulator.hh
#include “dsp/FDResample.hh”#include “phy/Synthesizer.hh”

Defines

final
file Gain.hh
#include <math.h>#include <atomic>
file ModPacketQueue.hh
#include <atomic>#include <list>#include <memory>#include <mutex>#include “phy/PHY.hh”
file MultichannelSynthesizer.cc
#include <xsimd/xsimd.hpp>#include <xsimd/stl/algorithms.hpp>#include <pybind11/pybind11.h>#include “phy/MultichannelSynthesizer.hh”#include “phy/PHY.hh”#include “stats/Estimator.hh”
file MultichannelSynthesizer.hh
#include <atomic>#include <mutex>#include “barrier.hh”#include “dsp/FDResample.hh”#include “dsp/FFTW.hh”#include “phy/PHY.hh”#include “phy/SlotSynthesizer.hh”
file OverlapTDChannelizer.cc
#include <functional>#include “phy/PHY.hh”#include “phy/OverlapTDChannelizer.hh”
file OverlapTDChannelizer.hh
#include <math.h>#include <condition_variable>#include <functional>#include <list>#include <mutex>#include “Logger.hh”#include “RadioPacketQueue.hh”#include “dsp/Polyphase.hh”#include “dsp/TableNCO.hh”#include “phy/Channel.hh”#include “phy/Channelizer.hh”
file ParallelChannelSynthesizer.hh
#include <atomic>#include <list>#include <memory>#include <mutex>#include “barrier.hh”#include “phy/Channel.hh”#include “phy/ChannelSynthesizer.hh”#include “phy/PHY.hh”
file ParallelChannelSynthesizer.inl
#include “ParallelChannelSynthesizer.hh”#include <pybind11/pybind11.h>
file RadioPacketQueue.cc
#include “phy/RadioPacketQueue.hh”
file RadioPacketQueue.hh
#include <condition_variable>#include <list>#include <memory>#include <mutex>#include <variant>#include “IQBuffer.hh”#include “Packet.hh”
file SlotSynthesizer.hh
#include “phy/Synthesizer.hh”
file Synthesizer.hh
#include <atomic>#include <mutex>#include “Logger.hh”#include “RadioNet.hh”#include “mac/Schedule.hh”#include “phy/PHY.hh”
file TDChannelizer.cc
#include <functional>#include <pybind11/pybind11.h>#include “Logger.hh”#include “phy/PHY.hh”#include “phy/TDChannelizer.hh”
file TDChannelizer.hh
#include <math.h>#include <condition_variable>#include <functional>#include <list>#include <mutex>#include “barrier.hh”#include “SafeQueue.hh”#include “dsp/Polyphase.hh”#include “dsp/TableNCO.hh”#include “phy/Channel.hh”#include “phy/Channelizer.hh”
file TDChannelModulator.cc
#include “phy/TDChannelModulator.hh”
file TDChannelModulator.hh
#include “dsp/Polyphase.hh”#include “phy/Synthesizer.hh”

Defines

final
file UnichannelSynthesizer.hh
#include <atomic>#include <mutex>#include “phy/Channel.hh”#include “phy/PHY.hh”#include “phy/SlotSynthesizer.hh”
file UnichannelSynthesizer.inl
#include “UnichannelSynthesizer.hh”#include <pybind11/pybind11.h>
file capsule.hh
#include <pybind11/pybind11.h>

Functions

template<class T>
py::capsule sharedptr_capsule(const std::shared_ptr<T> &ptr)

Save a shared_ptr in a capsule.

file Channelizer.cc
#include <pybind11/pybind11.h>#include <pybind11/complex.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “phy/Channel.hh”#include “phy/Channelizer.hh”#include “phy/FDChannelizer.hh”#include “phy/OverlapTDChannelizer.hh”#include “phy/TDChannelizer.hh”#include “python/PyModules.hh”

Functions

void exportChannelizers(py::module &m)
file Channels.cc
#include <pybind11/pybind11.h>#include <pybind11/complex.h>#include <pybind11/numpy.h>#include <pybind11/operators.h>#include <pybind11/stl.h>#include “python/PyModules.hh”

Functions

void exportChannels(py::module &m)
file CIL.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “cil/CIL.hh”#include “cil/Scorer.hh”#include “python/PyModules.hh”

Functions

void exportCIL(py::module &m)
file Controller.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “llc/Controller.hh”#include “llc/DummyController.hh”#include “llc/SmartController.hh”#include “llc/SmartController/proxies.hh”#include “python/PyModules.hh”

Functions

void exportControllers(py::module &m)
file Estimator.cc
#include “Clock.hh”#include “python/PyModules.hh”#include “stats/Estimator.hh”#include “stats/TimeWindowEstimator.hh”

Functions

template<class T>
void exportEstimator(py::module &m, const char *name)
template<class T>
void exportMeanEstimator(py::module &m, const char *name)
template<class T>
void exportWindowedMeanEstimator(py::module &m, const char *name)
template<class Clock, class T>
void exportTimeWindowEstimator(py::module &m, const char *name)
template<class Clock, class T>
void exportTimeWindowMeanEstimator(py::module &m, const char *name)
template<class Clock, class T>
void exportTimeWindowMeanRateEstimator(py::module &m, const char *name)
template<class Clock, class T>
void exportTimeWindowMinEstimator(py::module &m, const char *name)
template<class Clock, class T>
void exportTimeWindowMaxEstimator(py::module &m, const char *name)
void exportEstimators(py::module &m)
file Flow.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “net/Firewall.hh”#include “net/FlowPerformance.hh”#include “python/PyModules.hh”

Functions

void exportFlow(py::module &m)
file Header.cc
#include <pybind11/pybind11.h>#include “Header.hh”#include “python/PyModules.hh”

Functions

void exportHeader(py::module &m)
file IQBuffer.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include “IQBuffer.hh”#include “python/PyModules.hh”

Typedefs

using fc32 = std::complex<float>

Functions

void exportIQBuffer(py::module &m)
file Liquid.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “liquid/FlexFrame.hh”#include “liquid/NewFlexFrame.hh”#include “liquid/OFDM.hh”#include “python/PyModules.hh”

Typedefs

using FrameStats = framesyncstats_s
using Demod = std::tuple<std::optional<Header>, std::optional<py::bytes>, FrameStats>

Functions

std::vector<Demod> demodulate(liquid::Demodulator &demod, py::array_t<std::complex<float>, py::array::c_style | py::array::forcecast> sig)
void exportLiquid(py::module &m)
file NCO.cc
#include <pybind11/pybind11.h>#include <pybind11/numpy.h>#include “dsp/NCO.hh”#include “dsp/TableNCO.hh”#include “liquid/NCO.hh”#include “python/PyModules.hh”

Functions

void exportNCOs(py::module &m)
file Net.cc
#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include “RadioNet.hh”#include “net/MandateQueue.hh”#include “net/NetFilter.hh”#include “net/Noop.hh”#include “net/PacketCompressor.hh”#include “net/REDQueue.hh”#include “net/SimpleQueue.hh”#include “net/SizedQueue.hh”#include “net/TailDropQueue.hh”#include “net/Queue.hh”#include “python/PyModules.hh”#include “util/net.hh”

Functions

void exportNet(py::module &m)
void exportNetUtil(py::module &m)
file py_shared_ptr.hh
file PyModules.hh
#include <pybind11/pybind11.h>#include <pybind11/stl_bind.h>#include “phy/Channel.hh”#include “python/capsule.hh”#include “net/Element.hh”

Typedefs

template<typename D>
using NetInWrapper = PortWrapper<In, D, std::shared_ptr<NetPacket>>
template<typename D>
using NetOutWrapper = PortWrapper<Out, D, std::shared_ptr<NetPacket>>
using NetInPush = NetInWrapper<Push>
using NetInPull = NetInWrapper<Pull>
using NetOutPush = NetOutWrapper<Push>
using NetOutPull = NetOutWrapper<Pull>
template<typename D>
using RadioInWrapper = PortWrapper<In, D, std::shared_ptr<RadioPacket>>
template<typename D>
using RadioOutWrapper = PortWrapper<Out, D, std::shared_ptr<RadioPacket>>
using RadioInPush = RadioInWrapper<Push>
using RadioInPull = RadioInWrapper<Pull>
using RadioOutPush = RadioOutWrapper<Push>
using RadioOutPull = RadioOutWrapper<Pull>

Functions

template<class U, class D, class P, class T>
std::unique_ptr<PortWrapper<D, P, T>> exposePort(std::shared_ptr<U> e, Port<D, P, T> *p)
void exportClock(py::module &m)
void exportLogger(py::module &m)
void exportWorkQueue(py::module &m)
void exportUSRP(py::module &m)
void exportEstimators(py::module &m)
void exportNet(py::module &m)
void exportNetUtil(py::module &m)
void exportCIL(py::module &m)
void exportFlow(py::module &m)
void exportRadioNet(py::module &m)
void exportHeader(py::module &m)
void exportPacket(py::module &m)
void exportModem(py::module &m)
void exportLiquid(py::module &m)
void exportPHYs(py::module &m)
void exportLiquidPHYs(py::module &m)
void exportChannels(py::module &m)
void exportChannelizers(py::module &m)
void exportSynthesizers(py::module &m)
void exportControllers(py::module &m)
void exportMACs(py::module &m)
void exportResamplers(py::module &m)
void exportNCOs(py::module &m)
void exportFilters(py::module &m)
void exportIQBuffer(py::module &m)
void exportIQCompression(py::module &m)
void exportSnapshot(py::module &m)
file Python.cc
#include <pybind11/embed.h>#include “python/PyModules.hh”

Functions

PYBIND11_EMBEDDED_MODULE(_dragonradio, m)
file RadioNet.cc
#include <pybind11/pybind11.h>#include <pybind11/functional.h>#include <pybind11/stl.h>#include “RadioNet.hh”#include “python/PyModules.hh”

Functions

void exportRadioNet(py::module &m)
file RadioNet.cc
#include <sys/types.h>#include <netinet/if_ether.h>#include <netinet/in.h>#include <netinet/ip.h>#include <cstddef>#include <cstring>#include <functional>#include “RadioNet.hh”
file Synthesizer.cc
#include <pybind11/pybind11.h>#include <pybind11/complex.h>#include <pybind11/numpy.h>#include <pybind11/stl.h>#include “phy/Channel.hh”#include “phy/FDChannelModulator.hh”#include “phy/MultichannelSynthesizer.hh”#include “phy/ParallelChannelSynthesizer.inl”#include “phy/SlotSynthesizer.hh”#include “phy/Synthesizer.hh”#include “phy/TDChannelModulator.hh”#include “phy/UnichannelSynthesizer.inl”#include “python/PyModules.hh”

Functions

void exportSynthesizers(py::module &m)
file USRP.cc
#include <pybind11/stl.h>#include “USRP.hh”#include “python/PyModules.hh”

Functions

void exportUSRP(py::module &m)
file USRP.cc
#include <sys/types.h>#include <sys/time.h>#include <atomic>#include “logging.hh”#include “Clock.hh”#include “USRP.hh”#include “util/capabilities.hh”

Variables

const int kMaxLOLockCount = 100
file WorkQueue.cc
#include “WorkQueue.hh”#include “python/PyModules.hh”

Functions

void exportWorkQueue(py::module &m)
file WorkQueue.cc
#include “WorkQueue.hh”

Variables

WorkQueue work_queue

The global work queue.

file RadioNet.hh
#include <math.h>#include <functional>#include <map>#include <mutex>#include <unordered_map>#include <unordered_set>#include <optional>#include <queue>#include <thread>#include <vector>#include “Packet.hh”#include “net/TunTap.hh”

Typedefs

using timestamp_map = std::unordered_map<TimestampSeq, MonoClock::time_point>

Map from timestamp sequence number to timestamp.

using timestamps_map = std::unordered_map<TimestampSeq, std::pair<MonoClock::time_point, MonoClock::time_point>>

Map from timestamp sequence number to pair of sent, received timestamps.

using timestampseq_set = std::unordered_set<TimestampSeq>

Vector of pairs of timestamps.

file SafeQueue.hh
#include <condition_variable>#include <deque>#include <mutex>
file Seq.hh
#include <sys/types.h>#include <limits>
file Estimator.hh
#include <assert.h>#include <vector>
file TimeWindowEstimator.hh
#include <deque>#include <limits>#include “Estimator.hh”
file TimerQueue.cc
#include <algorithm>#include “TimerQueue.hh”#include “util/threads.hh”
file TimerQueue.hh
#include <chrono>#include <functional>#include <mutex>#include <queue>#include <thread>#include <unordered_map>#include “heap.hh”#include “Clock.hh”
file USRP.hh
#include <atomic>#include <deque>#include <string>#include <thread>#include <uhd/usrp/multi_usrp.hpp>#include “logging.hh”#include “Clock.hh”#include “IQBuffer.hh”
file capabilities.hh
#include <sys/capability.h>
file exec.cc
#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>#include “logging.hh”#include “util/exec.hh”

Functions

int exec(const std::vector<std::string> &args)

Exec a command.

file exec.hh
#include <string>#include <vector>

Functions

int exec(const std::vector<std::string>&)

Exec a command.

file net.cc
#include “logging.hh”#include “util/capabilities.hh”#include “util/net.hh”#include <sys/types.h>#include <sys/ioctl.h>#include <net/route.h>#include <netinet/if_ether.h>

Functions

struct sockaddr parseMAC(const std::string &s)

Parse a MAC address.

struct sockaddr parseIP(const std::string &s)

Parse an IP address.

void addStaticARPEntry(const std::optional<std::string> &dev, const std::string &ipaddr, const std::string &macaddr)

Add a static ARP table entry.

void deleteARPEntry(const std::optional<std::string> &dev, const std::string &ipaddr)

Delete a static ARP table entry.

void addRoute(const std::string &dst, const std::string &mask, const std::string &gateway)

Add an IP route.

void deleteRoute(const std::string &dst, const std::string &mask)

Delete an IP route.

file net.hh
#include <sys/types.h>#include <string.h>#include “Packet.hh”

Functions

inline uint32_t mkBroadcastAddress(uint32_t addr, uint32_t netmask)

Compute broadcast address from address and netmask

inline bool isEthernetBroadcast(const u_char *host)

Determine whether or not an Ethernet address is a broadcast address.

struct sockaddr parseMAC(const std::string &s)

Parse a MAC address.

struct sockaddr parseIP(const std::string &s)

Parse an IP address.

void addStaticARPEntry(const std::optional<std::string> &dev, const std::string &ipaddr, const std::string &macaddr)

Add a static ARP table entry.

void deleteARPEntry(const std::optional<std::string> &dev, const std::string &ipaddr)

Delete a static ARP table entry.

void addRoute(const std::string &dst, const std::string &mask, const std::string &gateway)

Add an IP route.

void deleteRoute(const std::string &dst, const std::string &mask)

Delete an IP route.

file sprintf.cc
#include <stdarg.h>#include <memory>#include “util/sprintf.hh”

Functions

std::string sprintf(const char *fmt, ...)

sprintf to a std::string.

file sprintf.hh
#include <string>

Functions

std::string sprintf(const char *fmt, ...)

sprintf to a std::string.

file threads.cc
#include <math.h>#include <atomic>#include <uhd/utils/thread_priority.hpp>#include “logging.hh”#include “util/capabilities.hh”#include “util/threads.hh”

Functions

void setRealtimePriority(pthread_t t)
void makeThisThreadHighPriority(void)

Make current thread high-priority.

void pinThreadToCPU(pthread_t t, int cpu_num)

Pin thread to given CPU.

void pinThisThread(void)

Pin this thread to a CPU.

int doze(double sec)

Sleep for the specified number of seconds. sleep, usleep, and nanosleep were already taken, so this function is named “doze.”.

Parameters

sec – The number of seconds to sleep.

Returns

-1 if interrupted.

static void dummySignalHandler(int)
void makeThreadWakeable(void)

Make the current thread wakeable.

This function installs a signal handler for SIGUSR1 so that the thread can be woken from a blocking sycall via wakeThread.

void wakeThread(std::thread &t)

Wake the given thread.

This function sends a SIGUSR1 signal to the given thread to wake it from any blocking syscalls.

file threads.hh
#include <signal.h>#include <unistd.h>#include <thread>

Functions

void setRealtimePriority(void)

Make thread have real-time priority.

void makeThisThreadHighPriority(void)

Make current thread high-priority.

void pinThreadToCPU(pthread_t t, int cpu_num)

Pin thread to given CPU.

void pinThisThread(void)

Pin this thread to a CPU.

int doze(double sec)

Sleep for the specified number of seconds. sleep, usleep, and nanosleep were already taken, so this function is named “doze.”.

Parameters

sec – The number of seconds to sleep.

Returns

-1 if interrupted.

void makeThreadWakeable(void)

Make the current thread wakeable.

This function installs a signal handler for SIGUSR1 so that the thread can be woken from a blocking sycall via wakeThread.

void wakeThread(std::thread &t)

Wake the given thread.

This function sends a SIGUSR1 signal to the given thread to wake it from any blocking syscalls.

Variables

const int SIGWAKE = SIGUSR1

The signal we use to wake a thread.

file WorkQueue.hh
#include <functional>#include <thread>#include <vector>#include “SafeQueue.hh”

Variables

WorkQueue work_queue

The global work queue.

dir /home/mainland/projects/dragonradio/dragonradio-local/src/cil
dir /home/mainland/projects/dragonradio/dragonradio-local/src/dsp
dir /home/mainland/projects/dragonradio/dragonradio-local/src/IQCompression
dir /home/mainland/projects/dragonradio/dragonradio-local/src/liquid
dir /home/mainland/projects/dragonradio/dragonradio-local/src/llc
dir /home/mainland/projects/dragonradio/dragonradio-local/src/mac
dir /home/mainland/projects/dragonradio/dragonradio-local/src/net
dir /home/mainland/projects/dragonradio/dragonradio-local/src/phy
dir /home/mainland/projects/dragonradio/dragonradio-local/src/python
dir /home/mainland/projects/dragonradio/dragonradio-local/src/llc/SmartController
dir /home/mainland/projects/dragonradio/dragonradio-local/src
dir /home/mainland/projects/dragonradio/dragonradio-local/src/stats
dir /home/mainland/projects/dragonradio/dragonradio-local/src/util