DESERT 4.0.0
UwTokenBus Class Reference

#include <uwtokenbus.h>

Inheritance diagram for UwTokenBus:
Inheritance graph
Collaboration diagram for UwTokenBus:
Collaboration graph

Classes

class  TimerBusIdle
 
class  TimerTokenPass
 

Public Types

enum  UWTokenBus_STATUS { IDLE , TRANSMITTING , RECEIVING }
 

Public Member Functions

 UwTokenBus ()
 
virtual ~UwTokenBus ()
 

Protected Member Functions

virtual void expireBusIdle ()
 
virtual void expireTokenPass ()
 
virtual void initRing ()
 
virtual bool validToken (Packet *p) const
 
virtual void sendToken (int next_id)
 
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 Phy2MacEndRx (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)
 
virtual int command (int argc, const char *const *argv) override
 
constexpr int NMOD (int n)
 

Protected Attributes

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
 

Static Protected Attributes

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

Member Enumeration Documentation

◆ UWTokenBus_STATUS

Enumerator
IDLE 
TRANSMITTING 
RECEIVING 

Constructor & Destructor Documentation

◆ UwTokenBus()

UwTokenBus::UwTokenBus ( )

Default constructor of the TokenBus class

References bus_idle_timeout, checkPriority, debug, drop_old_, initRing(), max_queue_size, max_token_hold_time, min_token_hold_time, n_nodes, slot_time, and token_pass_timeout.

Here is the call graph for this function:

◆ ~UwTokenBus()

UwTokenBus::~UwTokenBus ( )
virtual

Destructor of the TokenBus class

Member Function Documentation

◆ command()

int UwTokenBus::command ( int  argc,
const char *const *  argv 
)
overrideprotectedvirtual

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 in UwRangingTokenBus.

References buffer, bus_idle_timeout, count_bus_idle_exp, count_token_invalid, count_token_pass_exp, count_token_regen, count_token_resend, slot_time, and token_pass_timeout.

Referenced by UwRangingTokenBus::command().

◆ expireBusIdle()

void UwTokenBus::expireBusIdle ( )
protectedvirtual

called when bus_idle_timer expires

References count_bus_idle_exp, got_token, last_token_id_owned, min_token_hold_time, n_nodes, normId(), token_pass_timer, token_rx_time, and txData().

Here is the call graph for this function:

◆ expireTokenPass()

void UwTokenBus::expireTokenPass ( )
protectedvirtual

called when token_pass_timer expires

References count_token_pass_exp, got_token, last_token_id_owned, normId(), and sendToken().

Here is the call graph for this function:

◆ initPkt()

void UwTokenBus::initPkt ( Packet *  p)
protectedvirtual

Method called to add the MAC header size

Parameters
ppointer to a Packet object that rapresent the Packet in transmission

References hdr_tokenbus::getSize().

Referenced by recvFromUpperLayers().

Here is the call graph for this function:

◆ initRing()

void UwTokenBus::initRing ( )
protectedvirtual

Initialize the network and generates the first token

References bus_idle_timeout, bus_idle_timer, last_token_id_owned, n_nodes, and node_id.

Referenced by UwTokenBus().

◆ Mac2PhyStartTx()

void UwTokenBus::Mac2PhyStartTx ( Packet *  p)
protectedvirtual

Method called when the Mac Layer start to transmit a Packet

Parameters
ppointer to a packet object that rapresent the packet in transmission

References bus_idle_timer, last_token_id_heard, RECEIVING, rtx_status, hdr_tokenbus::tokenId(), and TRANSMITTING.

Referenced by sendToken(), UwRangingTokenBus::sendToken(), and txData().

Here is the call graph for this function:

◆ nextId()

int UwTokenBus::nextId ( int  id) const
protectedvirtual
Returns
token Id of next node

References n_nodes, and TOKENIDMAX.

◆ nextIdOwned()

int UwTokenBus::nextIdOwned ( int  id) const
protectedvirtual
Returns
next token id owned by this node

References n_nodes, node_id, and TOKENIDMAX.

◆ NMOD()

constexpr int UwTokenBus::NMOD ( int  n)
inlineconstexprprotected

given any int returns the corresponding node id via modulo operations

References n_nodes.

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

◆ normId()

int UwTokenBus::normId ( int  id) const
protectedvirtual

◆ Phy2MacEndRx()

void UwTokenBus::Phy2MacEndRx ( Packet *  p)
overrideprotectedvirtual

Method called when the Phy Layer finish to receive a Packet

Parameters
ppointer to a Packet object that rapresent the Packet in reception

Reimplemented in UwRangingTokenBus.

References bus_idle_timeout, bus_idle_timer, got_token, IDLE, last_token_id_heard, last_token_id_owned, min_token_hold_time, n_nodes, node_id, PT_UWTOKENBUS, rtx_status, token_pass_timer, token_rx_time, hdr_tokenbus::tokenId(), TRANSMITTING, txData(), and validToken().

Here is the call graph for this function:

◆ Phy2MacEndTx()

void UwTokenBus::Phy2MacEndTx ( const Packet *  p)
overrideprotectedvirtual

Method called when the Mac Layer finish to transmit a Packet

Parameters
ppointer to a Packet object that rapresent the Packet in transmission

References bus_idle_timeout, bus_idle_timer, got_token, IDLE, n_nodes, rtx_status, and txData().

Here is the call graph for this function:

◆ Phy2MacStartRx()

void UwTokenBus::Phy2MacStartRx ( const Packet *  p)
overrideprotectedvirtual

Method called when the Phy Layer start to receive a Packet

Parameters
ppointer to a packet object that rapresent the Packet in reception

References IDLE, RECEIVING, rtx_status, and TRANSMITTING.

◆ recvFromUpperLayers()

void UwTokenBus::recvFromUpperLayers ( Packet *  p)
overrideprotectedvirtual

Receive the packet from the upper layer (e.g. IP)

Parameters
ppointer to the packet received

References buffer, checkPriority, drop_old_, got_token, initPkt(), max_queue_size, hdr_uwcbr::priority(), PT_UWCBR, and txData().

Here is the call graph for this function:

◆ sendToken()

void UwTokenBus::sendToken ( int  next_id)
protectedvirtual

Passes the token to the next node

Parameters
next_idnode receiving the token

Reimplemented in UwRangingTokenBus.

References hdr_tokenbus::getSize(), got_token, Mac2PhyStartTx(), n_nodes, PT_UWTOKENBUS, and hdr_tokenbus::tokenId().

Referenced by expireTokenPass(), and txData().

Here is the call graph for this function:

◆ txData()

void UwTokenBus::txData ( )
protectedvirtual

◆ validToken()

bool UwTokenBus::validToken ( Packet *  p) const
protectedvirtual

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

Parameters
pPacket with token

Reimplemented in UwRangingTokenBus.

References last_token_id_heard, n_nodes, hdr_tokenbus::tokenId(), and TOKENIDMAX.

Referenced by Phy2MacEndRx(), and UwRangingTokenBus::validToken().

Here is the call graph for this function:

Member Data Documentation

◆ buffer

std::deque<Packet *> UwTokenBus::buffer
protected

outgoing packets dequeue

Referenced by command(), recvFromUpperLayers(), and txData().

◆ bus_idle_timeout

double UwTokenBus::bus_idle_timeout
protected

base timeout for the namesake timer should be (slot_time+max_token_hold_time)

Referenced by command(), initRing(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), Phy2MacEndTx(), and UwTokenBus().

◆ bus_idle_timer

TimerBusIdle UwTokenBus::bus_idle_timer
protected

token_pass_timer is scheduled when a node pass the token, it's cancelled when activity from the following node is heard and when it expires it resends the token.

Referenced by initRing(), Mac2PhyStartTx(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), and Phy2MacEndTx().

◆ checkPriority

int UwTokenBus::checkPriority
protected

flag to set to 1 if UWCBR module uses packets with priority, set to 0 otherwise. Priority can be used only with UWCBR module

Referenced by recvFromUpperLayers(), and UwTokenBus().

◆ count_bus_idle_exp

int UwTokenBus::count_bus_idle_exp
staticprotected
Initial value:
=
-1

count bus idle timer expirations

Referenced by command(), and expireBusIdle().

◆ count_nodes

int UwTokenBus::count_nodes = 0
staticprotected

counter of the instantiated nodes, used for assigning node ids in default contructor

◆ count_token_invalid

int UwTokenBus::count_token_invalid
protected

node count of invalid received token

Referenced by command().

◆ count_token_pass_exp

int UwTokenBus::count_token_pass_exp = 0
staticprotected

count token pass timer expirations

Referenced by command(), and expireTokenPass().

◆ count_token_regen

int UwTokenBus::count_token_regen
protected

node count of token regeneration

Referenced by command().

◆ count_token_resend

int UwTokenBus::count_token_resend
protected

bus_idle_timer is rescheduled everytime a new token_id is heard on the bus: the first time node n hears a token_id meant to node k, it sets the timeout to (3*(n-k+1)*bus_idle_timeout) in order to allow all the previous nodes to regenerate the token first When it expires, it regenerates the token and starts transmitting. node count of token retransmissions

Referenced by command().

◆ debug

int UwTokenBus::debug
protected

Debug variable: 0 for no info

Referenced by UwRangingTokenBus::Phy2MacEndRx(), and UwTokenBus().

◆ drop_old_

int UwTokenBus::drop_old_
protected

flag to set the drop packet policy in case of buffer overflow: if 0 (default) drops the new packet, if 1 the oldest

Referenced by recvFromUpperLayers(), and UwTokenBus().

◆ got_token

bool UwTokenBus::got_token
protected

◆ last_token_id_heard

int UwTokenBus::last_token_id_heard = 0
protected

◆ last_token_id_owned

int UwTokenBus::last_token_id_owned = 0
protected

◆ max_queue_size

int UwTokenBus::max_queue_size
protected

max packets in the queue

Referenced by recvFromUpperLayers(), and UwTokenBus().

◆ max_token_hold_time

double UwTokenBus::max_token_hold_time
protected

max token holding time

Referenced by txData(), and UwTokenBus().

◆ min_token_hold_time

double UwTokenBus::min_token_hold_time
protected

if the node has en empty queue when it receive the token, it waits this time before passing the token

Referenced by expireBusIdle(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), txData(), and UwTokenBus().

◆ n_nodes

◆ node_id

int UwTokenBus::node_id
protected

◆ rtx_status

◆ slot_time

double UwTokenBus::slot_time
protected

max travel time between any pair of nodes, used as time unit for some of the timers timeouts

Referenced by command(), and UwTokenBus().

◆ token_pass_timeout

double UwTokenBus::token_pass_timeout
protected

timeout for the namesake timer for token retransmission attempt, should be 2*slot_time+min_token_hold_time

Referenced by command(), txData(), and UwTokenBus().

◆ token_pass_timer

TimerTokenPass UwTokenBus::token_pass_timer
protected

◆ token_rx_time

double UwTokenBus::token_rx_time
protected

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