DESERT 4.0.0
UwCsmaAloha_Trigger_NODE Class Reference

#include <uw-csma-aloha-trigger-node.h>

Inheritance diagram for UwCsmaAloha_Trigger_NODE:
Inheritance graph
Collaboration diagram for UwCsmaAloha_Trigger_NODE:
Collaboration graph

Classes

class  Csma_Aloha_Triggered_Timer
 
class  ListenTimer
 
class  TransmissionTimer
 

Public Member Functions

 UwCsmaAloha_Trigger_NODE ()
 
virtual ~UwCsmaAloha_Trigger_NODE ()
 
virtual int command (int argc, const char *const *argv)
 
virtual int crLayCommand (ClMessage *m)
 

Protected Types

enum  UW_CS_ALOHA_TRIG_NODE_STATUS {
  UW_CS_ALOHA_TRIG_NODE_STATE_IDLE = 1 , UW_CS_ALOHA_TRIG_NODE_STATE_TX_DATA , UW_CS_ALOHA_TRIG_NODE_STATE_DATA_RX , UW_CS_ALOHA_TRIG_NODE_STATE_NOT_SET ,
  UW_CS_ALOHA_TRIG_NODE_STATE_LISTEN , UW_CS_ALOHA_TRIG_NODE_STATE_CHK_LISTEN_TIMEOUT , UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE , UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN ,
  UW_CS_ALOHA_TRIG_NODE_STATE_WRONG_PKT_RX , UW_CS_ALOHA_TRIG_NODE_STATE_RX_TRIGGER
}
 
enum  UW_CS_ALOHA_TRIG_NODE_REASON_STATUS {
  UW_CS_ALOHA_TRIG_NODE_REASON_DATA_PENDING , UW_CS_ALOHA_TRIG_NODE_REASON_DATA_RX , UW_CS_ALOHA_TRIG_NODE_REASON_DATA_TX , UW_CS_ALOHA_TRIG_NODE_REASON_DATA_EMPTY ,
  UW_CS_ALOHA_TRIG_NODE_REASON_NOT_SET , UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN , UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_TIMEOUT , UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_PENDING ,
  UW_CS_ALOHA_TRIG_NODE_REASON_START_RX , UW_CS_ALOHA_TRIG_NODE_REASON_PKT_NOT_FOR_ME , UW_CS_ALOHA_TRIG_NODE_REASON_PKT_ERROR , UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_AFTER_TRIGGER ,
  UW_CS_ALOHA_TRIG_NODE_REASON_TRIGGER_RX
}
 
enum  UW_CS_ALOHA_TRIG_NODE_TIMER_STATUS { UW_CS_ALOHA_TRIG_NODE_IDLE = 1 , UW_CS_ALOHA_TRIG_NODE_RUNNING , UW_CS_ALOHA_TRIG_NODE_FROZEN , UW_CS_ALOHA_TRIG_NODE_EXPIRED }
 

Protected Member Functions

virtual void recvFromUpperLayers (Packet *p)
 
virtual void Mac2PhyStartTx (Packet *p)
 
virtual void Phy2MacEndTx (const Packet *p)
 
virtual void Phy2MacStartRx (const Packet *p)
 
virtual void Phy2MacEndRx (Packet *p)
 
virtual void initPkt (Packet *p)
 
virtual void txData ()
 
virtual void stateIdle ()
 
virtual void stateRxIdle ()
 
virtual void stateTxData ()
 
virtual void stateListen ()
 
virtual void stateRxListen ()
 
virtual void stateRxTrigger (Packet *p)
 
virtual void stateCheckListenExpired ()
 
virtual void stateCheckTxTimerExpired ()
 
virtual void stateRxData (Packet *p)
 
virtual void stateRxPacketNotForMe (Packet *p)
 
virtual void initInfo ()
 
virtual void refreshState (UW_CS_ALOHA_TRIG_NODE_STATUS state)
 
virtual void refreshReason (UW_CS_ALOHA_TRIG_NODE_REASON_STATUS reason)
 
virtual void updateLastDataIdRx (int id)
 
virtual void queuePop (bool flag=true)
 
virtual void waitForUser ()
 
virtual int getRemainingPkts ()
 
virtual void incrUpperDataRx ()
 

Protected Attributes

ListenTimer listen_timer
 
TransmissionTimer tx_timer
 
double wait_costant
 
int max_payload
 
int HDR_size
 
int buffer_pkts
 
double listen_time
 
int tx_timer_duration
 
std::queue< Packet * > Q
 
std::queue< int > data_sn_queue
 
int u_data_id
 
int last_sent_data_id
 
Packet * curr_data_pkt
 
int last_data_id_rx
 
bool has_buffer_queue
 
bool can_transmit
 
UW_CS_ALOHA_TRIG_NODE_STATUS curr_state
 
UW_CS_ALOHA_TRIG_NODE_STATUS prev_state
 
UW_CS_ALOHA_TRIG_NODE_STATUS prev_prev_state
 
UW_CS_ALOHA_TRIG_NODE_REASON_STATUS last_reason
 
ofstream fout
 

Static Protected Attributes

static const double prop_speed = 1500.0
 
static bool initialized = false
 
static int u_pkt_id
 
static map< UW_CS_ALOHA_TRIG_NODE_STATUS, string > status_info
 
static map< UW_CS_ALOHA_TRIG_NODE_REASON_STATUS, string > reason_info
 

Detailed Description

Class that describes a CsmaAloha_TRIGGERED module of the node

Member Enumeration Documentation

◆ UW_CS_ALOHA_TRIG_NODE_REASON_STATUS

Enumerator
UW_CS_ALOHA_TRIG_NODE_REASON_DATA_PENDING 
UW_CS_ALOHA_TRIG_NODE_REASON_DATA_RX 
UW_CS_ALOHA_TRIG_NODE_REASON_DATA_TX 
UW_CS_ALOHA_TRIG_NODE_REASON_DATA_EMPTY 
UW_CS_ALOHA_TRIG_NODE_REASON_NOT_SET 
UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN 
UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_TIMEOUT 
UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_PENDING 
UW_CS_ALOHA_TRIG_NODE_REASON_START_RX 
UW_CS_ALOHA_TRIG_NODE_REASON_PKT_NOT_FOR_ME 
UW_CS_ALOHA_TRIG_NODE_REASON_PKT_ERROR 
UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_AFTER_TRIGGER 
UW_CS_ALOHA_TRIG_NODE_REASON_TRIGGER_RX 

◆ UW_CS_ALOHA_TRIG_NODE_STATUS

Enumerator
UW_CS_ALOHA_TRIG_NODE_STATE_IDLE 
UW_CS_ALOHA_TRIG_NODE_STATE_TX_DATA 
UW_CS_ALOHA_TRIG_NODE_STATE_DATA_RX 
UW_CS_ALOHA_TRIG_NODE_STATE_NOT_SET 
UW_CS_ALOHA_TRIG_NODE_STATE_LISTEN 
UW_CS_ALOHA_TRIG_NODE_STATE_CHK_LISTEN_TIMEOUT 
UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE 
UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN 
UW_CS_ALOHA_TRIG_NODE_STATE_WRONG_PKT_RX 
UW_CS_ALOHA_TRIG_NODE_STATE_RX_TRIGGER 

◆ UW_CS_ALOHA_TRIG_NODE_TIMER_STATUS

Enumerator
UW_CS_ALOHA_TRIG_NODE_IDLE 
UW_CS_ALOHA_TRIG_NODE_RUNNING 
UW_CS_ALOHA_TRIG_NODE_FROZEN 
UW_CS_ALOHA_TRIG_NODE_EXPIRED 

Constructor & Destructor Documentation

◆ UwCsmaAloha_Trigger_NODE()

UwCsmaAloha_Trigger_NODE::UwCsmaAloha_Trigger_NODE ( )

◆ ~UwCsmaAloha_Trigger_NODE()

UwCsmaAloha_Trigger_NODE::~UwCsmaAloha_Trigger_NODE ( )
virtual

Destructor of the UwCsmaAloha_Trigger_NODE class

Member Function Documentation

◆ command()

int UwCsmaAloha_Trigger_NODE::command ( int  argc,
const char *const *  argv 
)
virtual

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.

References initInfo(), and Q.

Here is the call graph for this function:

◆ crLayCommand()

int UwCsmaAloha_Trigger_NODE::crLayCommand ( ClMessage *  m)
virtual

Cross-Layer messages interpreter

Parameters
ClMessage*an instance of ClMessage that represent the message received
Returns
0 if successful.

◆ getRemainingPkts()

virtual int UwCsmaAloha_Trigger_NODE::getRemainingPkts ( )
inlineprotectedvirtual

Return the number of packets not transmitted (remained in the protocol queue) at the end of the simulation

Returns
the size of the queue at the end of the simulation

References Q.

◆ incrUpperDataRx()

virtual void UwCsmaAloha_Trigger_NODE::incrUpperDataRx ( )
inlineprotectedvirtual

Increase the number of Data packet Received from the Upper layers

Referenced by recvFromUpperLayers().

◆ initInfo()

◆ initPkt()

void UwCsmaAloha_Trigger_NODE::initPkt ( Packet *  p)
protectedvirtual

Init the packet with the MAC address of the receiver and the sender, the size of the packet and the type

Parameters
UWPOLLING_PKT_TYPEthe type of the packet

References data_sn_queue, HDR_size, and u_data_id.

Referenced by recvFromUpperLayers().

◆ Mac2PhyStartTx()

void UwCsmaAloha_Trigger_NODE::Mac2PhyStartTx ( Packet *  p)
protectedvirtual

Pass the packet to the PHY layer

Parameters
Packet*Pointer to an object of type Packet that rapresent the Packet to transmit

Referenced by txData().

◆ Phy2MacEndRx()

void UwCsmaAloha_Trigger_NODE::Phy2MacEndRx ( Packet *  p)
protectedvirtual

Method called when the Phy Layer finish to receive a Packet

Parameters
Packet*Pointer to an object of type Packet that rapresent the Packet received

References curr_state, prop_speed, PT_MMAC_TRIGGER, refreshReason(), stateRxPacketNotForMe(), stateRxTrigger(), status_info, UW_CS_ALOHA_TRIG_NODE_REASON_PKT_ERROR, UW_CS_ALOHA_TRIG_NODE_REASON_PKT_NOT_FOR_ME, and UW_CS_ALOHA_TRIG_NODE_REASON_TRIGGER_RX.

Here is the call graph for this function:

◆ Phy2MacEndTx()

void UwCsmaAloha_Trigger_NODE::Phy2MacEndTx ( const Packet *  p)
protectedvirtual

Method called when the PHY layer finish to transmit the packet.

Parameters
Packet*Pointer to an object of type Packet that rapresent the Packet transmitted

References curr_state, refreshReason(), stateIdle(), status_info, UW_CS_ALOHA_TRIG_NODE_REASON_DATA_TX, UW_CS_ALOHA_TRIG_NODE_STATE_IDLE, and UW_CS_ALOHA_TRIG_NODE_STATE_TX_DATA.

Here is the call graph for this function:

◆ Phy2MacStartRx()

void UwCsmaAloha_Trigger_NODE::Phy2MacStartRx ( const Packet *  p)
protectedvirtual

Method called when the Phy Layer start to receive a Packet

Parameters
constPacket* Pointer to an object of type Packet that rapresent the Packet that is in reception

References curr_state, refreshReason(), stateRxIdle(), stateRxListen(), status_info, UW_CS_ALOHA_TRIG_NODE_REASON_START_RX, UW_CS_ALOHA_TRIG_NODE_STATE_IDLE, and UW_CS_ALOHA_TRIG_NODE_STATE_LISTEN.

Here is the call graph for this function:

◆ queuePop()

virtual void UwCsmaAloha_Trigger_NODE::queuePop ( bool  flag = true)
inlineprotectedvirtual

Pop the first element of the data packet queue

References data_sn_queue, and Q.

Referenced by txData().

◆ recvFromUpperLayers()

void UwCsmaAloha_Trigger_NODE::recvFromUpperLayers ( Packet *  p)
protectedvirtual

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

Parameters
Packet*pointer to the packet received

References buffer_pkts, curr_state, has_buffer_queue, incrUpperDataRx(), initPkt(), Q, refreshReason(), stateListen(), UW_CS_ALOHA_TRIG_NODE_REASON_DATA_PENDING, and UW_CS_ALOHA_TRIG_NODE_STATE_IDLE.

Here is the call graph for this function:

◆ refreshReason()

virtual void UwCsmaAloha_Trigger_NODE::refreshReason ( UW_CS_ALOHA_TRIG_NODE_REASON_STATUS  reason)
inlineprotectedvirtual

◆ refreshState()

virtual void UwCsmaAloha_Trigger_NODE::refreshState ( UW_CS_ALOHA_TRIG_NODE_STATUS  state)
inlineprotectedvirtual

◆ stateCheckListenExpired()

◆ stateCheckTxTimerExpired()

void UwCsmaAloha_Trigger_NODE::stateCheckTxTimerExpired ( )
protectedvirtual

Checks if the Time period is expired

◆ stateIdle()

void UwCsmaAloha_Trigger_NODE::stateIdle ( )
protectedvirtual

◆ stateListen()

◆ stateRxData()

void UwCsmaAloha_Trigger_NODE::stateRxData ( Packet *  p)
protectedvirtual

State in which a DATA packet is received

Parameters
ppointer to the Packet received

References HDR_size, prev_state, refreshReason(), refreshState(), stateCheckListenExpired(), stateIdle(), status_info, UW_CS_ALOHA_TRIG_NODE_REASON_DATA_RX, UW_CS_ALOHA_TRIG_NODE_STATE_DATA_RX, UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE, and UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN.

Here is the call graph for this function:

◆ stateRxIdle()

void UwCsmaAloha_Trigger_NODE::stateRxIdle ( )
protectedvirtual

A reception is occuring while the protocol is in IDLE state

References refreshState(), and UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE.

Referenced by Phy2MacStartRx().

Here is the call graph for this function:

◆ stateRxListen()

void UwCsmaAloha_Trigger_NODE::stateRxListen ( )
protectedvirtual

State in which a reception is occuring while the node is listening the channel

References refreshState(), and UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN.

Referenced by Phy2MacStartRx().

Here is the call graph for this function:

◆ stateRxPacketNotForMe()

void UwCsmaAloha_Trigger_NODE::stateRxPacketNotForMe ( Packet *  p)
protectedvirtual

state in which a wrong Packet is received

References prev_state, refreshState(), stateCheckListenExpired(), stateIdle(), status_info, UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE, UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN, and UW_CS_ALOHA_TRIG_NODE_STATE_WRONG_PKT_RX.

Referenced by Phy2MacEndRx().

Here is the call graph for this function:

◆ stateRxTrigger()

void UwCsmaAloha_Trigger_NODE::stateRxTrigger ( Packet *  p)
protectedvirtual

State of the protocol in which a TRIGGER packet is received

Parameters
pPointer to the Packet received

References can_transmit, Q, refreshReason(), refreshState(), UwCsmaAloha_Trigger_NODE::Csma_Aloha_Triggered_Timer::schedule(), stateListen(), tx_timer, tx_timer_duration, UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_AFTER_TRIGGER, and UW_CS_ALOHA_TRIG_NODE_STATE_RX_TRIGGER.

Referenced by Phy2MacEndRx().

Here is the call graph for this function:

◆ stateTxData()

void UwCsmaAloha_Trigger_NODE::stateTxData ( )
protectedvirtual

State in which the protocol allows the node to transmit a data packet

References can_transmit, curr_data_pkt, data_sn_queue, last_sent_data_id, listen_timer, Q, refreshState(), UwCsmaAloha_Trigger_NODE::Csma_Aloha_Triggered_Timer::resetCounter(), txData(), and UW_CS_ALOHA_TRIG_NODE_STATE_TX_DATA.

Referenced by stateCheckListenExpired().

Here is the call graph for this function:

◆ txData()

void UwCsmaAloha_Trigger_NODE::txData ( )
protectedvirtual

Transmits the DATA packet (calling Mac2PhyStartTx) and increment the counter of transmitted data packets

References curr_data_pkt, Mac2PhyStartTx(), and queuePop().

Referenced by stateTxData().

Here is the call graph for this function:

◆ updateLastDataIdRx()

virtual void UwCsmaAloha_Trigger_NODE::updateLastDataIdRx ( int  id)
inlineprotectedvirtual

Updates the ID of the last DATA packet received

Parameters
idID of the packet

References last_data_id_rx.

◆ waitForUser()

void UwCsmaAloha_Trigger_NODE::waitForUser ( )
protectedvirtual

Used for debug purposes. (Permit to have a "step by step" behavior of the protocol)

Member Data Documentation

◆ buffer_pkts

int UwCsmaAloha_Trigger_NODE::buffer_pkts
protected

Length of the data buffer in number of packets

Referenced by recvFromUpperLayers(), and UwCsmaAloha_Trigger_NODE().

◆ can_transmit

bool UwCsmaAloha_Trigger_NODE::can_transmit
protected

Flag that indicates if the node can transmit data packets to the sink

Referenced by stateIdle(), stateRxTrigger(), and stateTxData().

◆ curr_data_pkt

Packet* UwCsmaAloha_Trigger_NODE::curr_data_pkt
protected

Pointer to the current data packet

Referenced by stateTxData(), and txData().

◆ curr_state

UW_CS_ALOHA_TRIG_NODE_STATUS UwCsmaAloha_Trigger_NODE::curr_state
protected

◆ data_sn_queue

std::queue<int> UwCsmaAloha_Trigger_NODE::data_sn_queue
protected

Queue of the sequence number of the packets

Referenced by initPkt(), queuePop(), and stateTxData().

◆ fout

ofstream UwCsmaAloha_Trigger_NODE::fout
protected

Object that handles the output file where the protocol writes the state transistions

◆ has_buffer_queue

bool UwCsmaAloha_Trigger_NODE::has_buffer_queue
protected

flag that indicates if a node has a buffer where store DATA packets

Referenced by recvFromUpperLayers(), and UwCsmaAloha_Trigger_NODE().

◆ HDR_size

int UwCsmaAloha_Trigger_NODE::HDR_size
protected

Size (in bytes) of the header added by the protocol

Referenced by initPkt(), stateRxData(), and UwCsmaAloha_Trigger_NODE().

◆ initialized

bool UwCsmaAloha_Trigger_NODE::initialized = false
staticprotected

true if the protocol is initialized

Referenced by initInfo().

◆ last_data_id_rx

int UwCsmaAloha_Trigger_NODE::last_data_id_rx
protected

ID of the last DATA packet received

Referenced by updateLastDataIdRx().

◆ last_reason

UW_CS_ALOHA_TRIG_NODE_REASON_STATUS UwCsmaAloha_Trigger_NODE::last_reason
protected

Reason for the state transitions

Referenced by refreshReason().

◆ last_sent_data_id

int UwCsmaAloha_Trigger_NODE::last_sent_data_id
protected

ID of the last sent packet

Referenced by stateTxData().

◆ listen_time

double UwCsmaAloha_Trigger_NODE::listen_time
protected

Time in which the node sense the channel

Referenced by stateListen(), and UwCsmaAloha_Trigger_NODE().

◆ listen_timer

ListenTimer UwCsmaAloha_Trigger_NODE::listen_timer
protected

◆ max_payload

int UwCsmaAloha_Trigger_NODE::max_payload
protected

Maximum dimension of the data payload in bytes

Referenced by UwCsmaAloha_Trigger_NODE().

◆ prev_prev_state

UW_CS_ALOHA_TRIG_NODE_STATUS UwCsmaAloha_Trigger_NODE::prev_prev_state
protected

Previous previous state of the protocol

Referenced by refreshState().

◆ prev_state

UW_CS_ALOHA_TRIG_NODE_STATUS UwCsmaAloha_Trigger_NODE::prev_state
protected

Previous state of the protocol

Referenced by refreshState(), stateCheckListenExpired(), stateRxData(), and stateRxPacketNotForMe().

◆ prop_speed

const double UwCsmaAloha_Trigger_NODE::prop_speed = 1500.0
staticprotected

Typical sound propagation speed in underwater enviroment Variable that rapresent the status of the protocol machine state

Referenced by Phy2MacEndRx().

◆ Q

std::queue<Packet *> UwCsmaAloha_Trigger_NODE::Q
protected

◆ reason_info

map< UwCsmaAloha_Trigger_NODE::UW_CS_ALOHA_TRIG_NODE_REASON_STATUS, string > UwCsmaAloha_Trigger_NODE::reason_info
staticprotected

Textual description of the protocol reason for the change of the state

Referenced by initInfo().

◆ status_info

map< UwCsmaAloha_Trigger_NODE::UW_CS_ALOHA_TRIG_NODE_STATUS, string > UwCsmaAloha_Trigger_NODE::status_info
staticprotected

◆ tx_timer

TransmissionTimer UwCsmaAloha_Trigger_NODE::tx_timer
protected

Referenced by stateRxTrigger().

◆ tx_timer_duration

int UwCsmaAloha_Trigger_NODE::tx_timer_duration
protected

Duration of the time in which the node is allowed to transmit

Referenced by stateRxTrigger(), and UwCsmaAloha_Trigger_NODE().

◆ u_data_id

int UwCsmaAloha_Trigger_NODE::u_data_id
protected

DATA packete ID

Referenced by initPkt().

◆ u_pkt_id

int UwCsmaAloha_Trigger_NODE::u_pkt_id
staticprotected

simulation-unique packet ID

Referenced by UwCsmaAloha_Trigger_NODE().

◆ wait_costant

double UwCsmaAloha_Trigger_NODE::wait_costant
protected

Adding factor in the calculation of the listen time

Referenced by stateListen().


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