DESERT 4.0.0
UwRangingTokenBus Class Reference

#include <uwranging_tokenbus.h>

Inheritance diagram for UwRangingTokenBus:
Inheritance graph
Collaboration diagram for UwRangingTokenBus:
Collaboration graph

Public Member Functions

 UwRangingTokenBus ()
 
virtual ~UwRangingTokenBus ()
 
- Public Member Functions inherited from UwTokenBus
 UwTokenBus ()
 
virtual ~UwTokenBus ()
 

Protected Member Functions

virtual bool validToken (Packet *p) const override
 
virtual void sendToken (int next_id) override
 
virtual void Phy2MacEndRx (Packet *p) override
 
virtual void computeDist ()
 compute the linear regression and updates the distances vector
 
virtual int command (int argc, const char *const *argv)
 
- Protected Member Functions inherited from UwTokenBus
virtual void expireBusIdle ()
 
virtual void expireTokenPass ()
 
virtual void initRing ()
 
virtual void txData ()
 
virtual int normId (int id) const
 
virtual int nextId (int id) const
 
virtual int nextIdOwned (int id) const
 
virtual void recvFromUpperLayers (Packet *p) override
 
virtual void Phy2MacStartRx (const Packet *p) override
 
virtual void Mac2PhyStartTx (Packet *p)
 
virtual void Phy2MacEndTx (const Packet *p) override
 
virtual void initPkt (Packet *p)
 
constexpr int NMOD (int n)
 

Protected Attributes

const int dist_num
 
double epsilon
 
double max_tt
 
std::vector< std::vector< int > > dist_map
 
std::vector< std::vector< double > > times_mat
 
std::vector< std::vector< int > > times_age
 
std::vector< std::vector< double > > x_mat
 
std::vector< double > distances
 
double time_last_range
 
int id_last_range
 
- Protected Attributes inherited from UwTokenBus
int node_id
 
int n_nodes
 
int last_token_id_heard = 0
 
int last_token_id_owned = 0
 
double max_token_hold_time
 
double min_token_hold_time
 
double token_rx_time
 
int max_queue_size
 
std::deque< Packet * > buffer
 
UWTokenBus_STATUS rtx_status
 
bool got_token
 
double slot_time
 
double token_pass_timeout
 
double bus_idle_timeout
 
TimerTokenPass token_pass_timer
 
TimerBusIdle bus_idle_timer
 
int count_token_resend
 
int count_token_regen
 
int count_token_invalid
 
int debug
 
int drop_old_
 
int checkPriority
 

Additional Inherited Members

- Public Types inherited from UwTokenBus
enum  UWTokenBus_STATUS { IDLE , TRANSMITTING , RECEIVING }
 
- Static Protected Attributes inherited from UwTokenBus
static int count_nodes = 0
 
static int count_token_pass_exp = 0
 
static int count_bus_idle_exp
 

Detailed Description

Class that represents a TokenBus Node

Constructor & Destructor Documentation

◆ UwRangingTokenBus()

UwRangingTokenBus::UwRangingTokenBus ( )

Default constructor of the TokenBus class

References dist_map, dist_num, distances, epsilon, max_tt, UwTokenBus::n_nodes, UwTokenBus::NMOD(), times_age, times_mat, and x_mat.

Here is the call graph for this function:

◆ ~UwRangingTokenBus()

UwRangingTokenBus::~UwRangingTokenBus ( )
virtual

Destructor of the TokenBus class

Member Function Documentation

◆ command()

int UwRangingTokenBus::command ( int  argc,
const char *const *  argv 
)
protectedvirtual

TCL command interpreter. It implements the following OTcl methods:

Parameters
argcNumber of arguments in argv.
argvArray of strings which are the command parameters (Note that argv[0] is the name of the object).
Returns
TCL_OK or TCL_ERROR whether the command has been dispatched successfully or not.

Reimplemented from UwTokenBus.

References UwTokenBus::command(), computeDist(), dist_map, distances, UwTokenBus::n_nodes, and UwTokenBus::NMOD().

Here is the call graph for this function:

◆ computeDist()

void UwRangingTokenBus::computeDist ( )
protectedvirtual

compute the linear regression and updates the distances vector

References dist_num, distances, epsilon, id_last_range, max_tt, UwTokenBus::n_nodes, UwTokenBus::NMOD(), LSSQ::nnLeastSquares(), UwTokenBus::normId(), LSSQ::OK, LSSQ::TIMEOUT, times_age, times_mat, and x_mat.

Referenced by command().

Here is the call graph for this function:

◆ Phy2MacEndRx()

◆ sendToken()

◆ validToken()

bool UwRangingTokenBus::validToken ( Packet *  p) const
overrideprotectedvirtual

Assert if the received token id is valid, i.e it follows the monotonic progression taking in account overflow.

Parameters
pPacket with token

Reimplemented from UwTokenBus.

References UwTokenBus::last_token_id_owned, UwTokenBus::n_nodes, UwTokenBus::normId(), and UwTokenBus::validToken().

Referenced by Phy2MacEndRx().

Here is the call graph for this function:

Member Data Documentation

◆ dist_map

std::vector<std::vector<int> > UwRangingTokenBus::dist_map
protected

of size [n_nodes][n_nodes] maps(nodeX,nodeY) -> distance

Referenced by command(), and UwRangingTokenBus().

◆ dist_num

const int UwRangingTokenBus::dist_num
protected

num of distances: will be initialized to n_nodes*(n_nodes-1)/2

Referenced by computeDist(), and UwRangingTokenBus().

◆ distances

std::vector<double> UwRangingTokenBus::distances
protected

vector of shape [D], contains the one way travel times between nodes to be transformed to distances by the user according to the chosen speed of sound model

Referenced by command(), computeDist(), and UwRangingTokenBus().

◆ epsilon

double UwRangingTokenBus::epsilon
protected

difference between virtually equal distances can result in small negative numbers due to floating point precision so values within epsilon will not be discarded by NNLS algo

Referenced by computeDist(), and UwRangingTokenBus().

◆ id_last_range

int UwRangingTokenBus::id_last_range
protected

node id from which I received the last ranging pkt

Referenced by computeDist(), Phy2MacEndRx(), and sendToken().

◆ max_tt

double UwRangingTokenBus::max_tt
protected

max travel time between nodes in seconds, used to discard bad nnleast_squares() results

Referenced by computeDist(), and UwRangingTokenBus().

◆ time_last_range

double UwRangingTokenBus::time_last_range
protected

time of last ping reception (or transmission)

Referenced by Phy2MacEndRx(), and sendToken().

◆ times_age

std::vector<std::vector<int> > UwRangingTokenBus::times_age
protected

vector of shape [n_nodes][n_nodes-1] holds the age of a time (slot number in which the time was calculate or received)

Referenced by computeDist(), Phy2MacEndRx(), sendToken(), and UwRangingTokenBus().

◆ times_mat

std::vector<std::vector<double> > UwRangingTokenBus::times_mat
protected

vector of shape [n_nodes][n_nodes-1] holds the travel times: the first index is the node_id which has calculated them

Referenced by computeDist(), Phy2MacEndRx(), sendToken(), and UwRangingTokenBus().

◆ x_mat

std::vector<std::vector<double> > UwRangingTokenBus::x_mat
protected

of size [2D][D] it's the sparse matrix with the equations coefficients (-1,0,1)

Referenced by computeDist(), and UwRangingTokenBus().


The documentation for this class was generated from the following files: