|
DESERT 4.0.0
|
#include <uwtokenbus.h>


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 |
Class that represents a TokenBus Node
| 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.

|
virtual |
Destructor of the TokenBus class
|
overrideprotectedvirtual |
TCL command interpreter. It implements the following OTcl methods:
| argc | Number of arguments in argv. |
| argv | Array of strings which are the command parameters (Note that argv[0] is the name of the object). |
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().
|
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().

|
protectedvirtual |
called when token_pass_timer expires
References count_token_pass_exp, got_token, last_token_id_owned, normId(), and sendToken().

|
protectedvirtual |
Method called to add the MAC header size
| p | pointer to a Packet object that rapresent the Packet in transmission |
References hdr_tokenbus::getSize().
Referenced by recvFromUpperLayers().

|
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().
|
protectedvirtual |
Method called when the Mac Layer start to transmit a Packet
| p | pointer 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().

|
protectedvirtual |
References n_nodes, and TOKENIDMAX.
|
protectedvirtual |
References n_nodes, node_id, and TOKENIDMAX.
|
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().
|
protectedvirtual |
References n_nodes, and TOKENIDMAX.
Referenced by UwRangingTokenBus::computeDist(), expireBusIdle(), expireTokenPass(), UwRangingTokenBus::Phy2MacEndRx(), UwRangingTokenBus::sendToken(), txData(), and UwRangingTokenBus::validToken().
|
overrideprotectedvirtual |
Method called when the Phy Layer finish to receive a Packet
| p | pointer 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().

|
overrideprotectedvirtual |
Method called when the Mac Layer finish to transmit a Packet
| p | pointer 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().

|
overrideprotectedvirtual |
Method called when the Phy Layer start to receive a Packet
| p | pointer to a packet object that rapresent the Packet in reception |
References IDLE, RECEIVING, rtx_status, and TRANSMITTING.
|
overrideprotectedvirtual |
Receive the packet from the upper layer (e.g. IP)
| p | pointer to the packet received |
References buffer, checkPriority, drop_old_, got_token, initPkt(), max_queue_size, hdr_uwcbr::priority(), PT_UWCBR, and txData().

|
protectedvirtual |
Passes the token to the next node
| next_id | node 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().

|
protectedvirtual |
Starts transmitting the packets from the queue
References buffer, got_token, IDLE, last_token_id_owned, Mac2PhyStartTx(), max_token_hold_time, min_token_hold_time, node_id, normId(), RECEIVING, rtx_status, sendToken(), token_pass_timeout, token_pass_timer, token_rx_time, and TRANSMITTING.
Referenced by expireBusIdle(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), Phy2MacEndTx(), and recvFromUpperLayers().

|
protectedvirtual |
Assert if the received token id is valid, i.e it follows the monotonic progression taking in account uint16 overflow.
| p | Packet with token |
Reimplemented in UwRangingTokenBus.
References last_token_id_heard, n_nodes, hdr_tokenbus::tokenId(), and TOKENIDMAX.
Referenced by Phy2MacEndRx(), and UwRangingTokenBus::validToken().

|
protected |
outgoing packets dequeue
Referenced by command(), recvFromUpperLayers(), and txData().
|
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().
|
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().
|
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().
|
staticprotected |
|
staticprotected |
counter of the instantiated nodes, used for assigning node ids in default contructor
|
protected |
node count of invalid received token
Referenced by command().
|
staticprotected |
count token pass timer expirations
Referenced by command(), and expireTokenPass().
|
protected |
node count of token regeneration
Referenced by command().
|
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().
|
protected |
Debug variable: 0 for no info
Referenced by UwRangingTokenBus::Phy2MacEndRx(), and UwTokenBus().
|
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().
|
protected |
set if node is currently holding the token
Referenced by expireBusIdle(), expireTokenPass(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), Phy2MacEndTx(), recvFromUpperLayers(), sendToken(), UwRangingTokenBus::sendToken(), and txData().
|
protected |
last token id heard on the bus
Referenced by Mac2PhyStartTx(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), UwRangingTokenBus::sendToken(), and validToken().
|
protected |
last token id owned
Referenced by expireBusIdle(), expireTokenPass(), initRing(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), txData(), and UwRangingTokenBus::validToken().
|
protected |
max packets in the queue
Referenced by recvFromUpperLayers(), and UwTokenBus().
|
protected |
max token holding time
Referenced by txData(), and UwTokenBus().
|
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().
|
protected |
number of nodes in the ring
Referenced by UwRangingTokenBus::command(), UwRangingTokenBus::computeDist(), expireBusIdle(), initRing(), nextId(), nextIdOwned(), NMOD(), normId(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), Phy2MacEndTx(), sendToken(), UwRangingTokenBus::sendToken(), UwRangingTokenBus::UwRangingTokenBus(), UwTokenBus(), validToken(), and UwRangingTokenBus::validToken().
|
protected |
id of the node (0 to n_nodes-1)
Referenced by initRing(), nextIdOwned(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), UwRangingTokenBus::sendToken(), and txData().
|
protected |
Referenced by Mac2PhyStartTx(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), Phy2MacEndTx(), Phy2MacStartRx(), and txData().
|
protected |
max travel time between any pair of nodes, used as time unit for some of the timers timeouts
Referenced by command(), and UwTokenBus().
|
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().
|
protected |
Referenced by expireBusIdle(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), and txData().
|
protected |
time of token reception
Referenced by expireBusIdle(), Phy2MacEndRx(), UwRangingTokenBus::Phy2MacEndRx(), UwRangingTokenBus::sendToken(), and txData().