DESERT 3.5.1
Loading...
Searching...
No Matches
UwTokenBus Class Reference

#include <uwtokenbus.h>

Inheritance diagram for UwTokenBus:
Collaboration diagram for UwTokenBus:

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 = -1
 

Detailed Description

Class that represents a TokenBus Node.

Definition at line 51 of file uwtokenbus.h.

Member Enumeration Documentation

◆ UWTokenBus_STATUS

Enumerator
IDLE 
TRANSMITTING 
RECEIVING 

Definition at line 120 of file uwtokenbus.h.

Constructor & Destructor Documentation

◆ UwTokenBus()

UwTokenBus::UwTokenBus ( )

Default constructor of the TokenBus class.

Definition at line 93 of file uwtokenbus.cpp.

◆ ~UwTokenBus()

UwTokenBus::~UwTokenBus ( )
virtual

Destructor of the TokenBus class.

Definition at line 170 of file uwtokenbus.cpp.

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.

Definition at line 469 of file uwtokenbus.cpp.

◆ expireBusIdle()

void UwTokenBus::expireBusIdle ( )
protectedvirtual

called when bus_idle_timer expires

Definition at line 181 of file uwtokenbus.cpp.

◆ expireTokenPass()

void UwTokenBus::expireTokenPass ( )
protectedvirtual

called when token_pass_timer expires

Definition at line 174 of file uwtokenbus.cpp.

◆ 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

Definition at line 439 of file uwtokenbus.cpp.

◆ initRing()

void UwTokenBus::initRing ( )
protectedvirtual

Initialize the network and generates the first token.

Definition at line 192 of file uwtokenbus.cpp.

◆ 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

Definition at line 316 of file uwtokenbus.cpp.

◆ nextId()

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

Definition at line 256 of file uwtokenbus.cpp.

◆ nextIdOwned()

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

Definition at line 263 of file uwtokenbus.cpp.

◆ NMOD()

constexpr int UwTokenBus::NMOD ( int  n)
inlineconstexprprotected

given any int returns the corresponding node id via modulo operations

Definition at line 265 of file uwtokenbus.h.

◆ normId()

int UwTokenBus::normId ( int  id) const
protectedvirtual
Returns
the token id modulo TOKENIDMAX

Definition at line 248 of file uwtokenbus.cpp.

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

Definition at line 365 of file uwtokenbus.cpp.

◆ 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

Definition at line 333 of file uwtokenbus.cpp.

◆ 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

Definition at line 342 of file uwtokenbus.cpp.

◆ recvFromUpperLayers()

void UwTokenBus::recvFromUpperLayers ( Packet *  p)
overrideprotectedvirtual

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

IP)

Parameters
ppointer to the packet received

Definition at line 197 of file uwtokenbus.cpp.

◆ sendToken()

void UwTokenBus::sendToken ( int  next_id)
protectedvirtual

Passes the token to the next node.

Parameters
next_idnode receiving the token

Reimplemented in UwRangingTokenBus.

Definition at line 446 of file uwtokenbus.cpp.

◆ txData()

void UwTokenBus::txData ( )
protectedvirtual

Starts transmitting the packets from the queue.

Definition at line 271 of file uwtokenbus.cpp.

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

Definition at line 353 of file uwtokenbus.cpp.

Member Data Documentation

◆ buffer

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

outgoing packets dequeue

Definition at line 238 of file uwtokenbus.h.

◆ bus_idle_timeout

double UwTokenBus::bus_idle_timeout
protected

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

Definition at line 243 of file uwtokenbus.h.

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

Definition at line 247 of file uwtokenbus.h.

◆ 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

Definition at line 259 of file uwtokenbus.h.

◆ count_bus_idle_exp

int UwTokenBus::count_bus_idle_exp = -1
staticprotected

count bus idle timer expirations

Definition at line 264 of file uwtokenbus.h.

◆ count_nodes

int UwTokenBus::count_nodes = 0
staticprotected

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

Definition at line 262 of file uwtokenbus.h.

◆ count_token_invalid

int UwTokenBus::count_token_invalid
protected

node count of invalid received token

Definition at line 254 of file uwtokenbus.h.

◆ count_token_pass_exp

int UwTokenBus::count_token_pass_exp = 0
staticprotected

count token pass timer expirations

Definition at line 263 of file uwtokenbus.h.

◆ count_token_regen

int UwTokenBus::count_token_regen
protected

node count of token regeneration

Definition at line 253 of file uwtokenbus.h.

◆ 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

Definition at line 252 of file uwtokenbus.h.

◆ debug

int UwTokenBus::debug
protected

Debug variable: 0 for no info.

Definition at line 256 of file uwtokenbus.h.

◆ 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

Definition at line 257 of file uwtokenbus.h.

◆ got_token

bool UwTokenBus::got_token
protected

set if node is currently holding the token

Definition at line 240 of file uwtokenbus.h.

◆ last_token_id_heard

int UwTokenBus::last_token_id_heard = 0
protected

last token id heard on the bus

Definition at line 231 of file uwtokenbus.h.

◆ last_token_id_owned

int UwTokenBus::last_token_id_owned = 0
protected

last token id owned

Definition at line 232 of file uwtokenbus.h.

◆ max_queue_size

int UwTokenBus::max_queue_size
protected

max packets in the queue

Definition at line 237 of file uwtokenbus.h.

◆ max_token_hold_time

double UwTokenBus::max_token_hold_time
protected

max token holding time

Definition at line 234 of file uwtokenbus.h.

◆ 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

Definition at line 235 of file uwtokenbus.h.

◆ n_nodes

int UwTokenBus::n_nodes
protected

number of nodes in the ring

Definition at line 230 of file uwtokenbus.h.

◆ node_id

int UwTokenBus::node_id
protected

id of the node (0 to n_nodes-1)

Definition at line 229 of file uwtokenbus.h.

◆ rtx_status

UWTokenBus_STATUS UwTokenBus::rtx_status
protected

Definition at line 239 of file uwtokenbus.h.

◆ 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

Definition at line 241 of file uwtokenbus.h.

◆ 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

Definition at line 242 of file uwtokenbus.h.

◆ token_pass_timer

TimerTokenPass UwTokenBus::token_pass_timer
protected

Definition at line 244 of file uwtokenbus.h.

◆ token_rx_time

double UwTokenBus::token_rx_time
protected

time of token reception

Definition at line 236 of file uwtokenbus.h.


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