DESERT 4.0.0
MMacUWSR Class Reference

This is the base class of MMacUWSR protocol, which is a derived class of MMac. More...

#include <uwsr.h>

Inheritance diagram for MMacUWSR:
Inheritance graph
Collaboration diagram for MMacUWSR:
Collaboration graph

Classes

class  AckTimer
 
class  BackOffTimer
 
class  ListenTimer
 
class  UWSRTimer
 
class  WaitTxTimer
 

Public Member Functions

 MMacUWSR ()
 
virtual ~MMacUWSR ()
 
virtual int command (int argc, const char *const *argv)
 

Protected Types

enum  UWSR_STATUS {
  UWSR_STATE_IDLE = 1 , UWSR_STATE_BACKOFF , UWSR_STATE_TX_DATA , UWSR_STATE_TX_ACK ,
  UWSR_STATE_WAIT_ACK , UWSR_STATE_DATA_RX , UWSR_STATE_ACK_RX , UWSR_STATE_NOT_SET ,
  UWSR_STATE_LISTEN , UWSR_STATE_CHK_ACK_TIMEOUT , UWSR_STATE_CHK_LISTEN_TIMEOUT , UWSR_STATE_CHK_BACKOFF_TIMEOUT ,
  UWSR_STATE_RX_IDLE , UWSR_STATE_RX_LISTEN , UWSR_STATE_RX_BACKOFF , UWSR_STATE_RX_WAIT_ACK ,
  UWSR_STATE_WRONG_PKT_RX , UWSR_STATE_WAIT_TX , UWSR_STATE_CHK_WAIT_TX_TIMEOUT , UWSR_STATE_WAIT_ACK_WAIT_TX ,
  UWSR_STATE_RX_DATA_TX_DATA , UWSR_STATE_PRE_TX_DATA , UWSR_STATE_RX_IN_PRE_TX_DATA
}
 
enum  UWSR_REASON_STATUS {
  UWSR_REASON_DATA_PENDING , UWSR_REASON_DATA_RX , UWSR_REASON_DATA_TX , UWSR_REASON_ACK_TX ,
  UWSR_REASON_ACK_RX , UWSR_REASON_BACKOFF_TIMEOUT , UWSR_REASON_ACK_TIMEOUT , UWSR_REASON_DATA_EMPTY ,
  UWSR_REASON_NOT_SET , UWSR_REASON_MAX_TX_TRIES , UWSR_REASON_BACKOFF_PENDING , UWSR_REASON_LISTEN ,
  UWSR_REASON_LISTEN_TIMEOUT , UWSR_REASON_LISTEN_PENDING , UWSR_REASON_START_RX , UWSR_REASON_PKT_NOT_FOR_ME ,
  UWSR_REASON_WAIT_ACK_PENDING , UWSR_REASON_PKT_ERROR , UWSR_REASON_WAIT_TX , UWSR_REASON_WAIT_TX_PENDING ,
  UWSR_REASON_WAIT_TX_TIMEOUT
}
 
enum  UWSR_PKT_TYPE { UWSR_ACK_PKT = 1 , UWSR_DATA_PKT , UWSR_DATAMAX_PKT }
 
enum  UWSR_TIMER_STATUS { UWSR_IDLE = 1 , UWSR_RUNNING , UWSR_FROZEN , UWSR_EXPIRED }
 
enum  CHECK_ACK_TIMER { CHECK_ACTIVE = 1 , CHECK_EXPIRED , CHECK_IDLE }
 

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 double computeTxTime (UWSR_PKT_TYPE type)
 
virtual void initPkt (Packet *p, UWSR_PKT_TYPE pkt_type, int dest_addr=0)
 
virtual double getBackoffTime ()
 
void setBackoffCount ()
 
int getBackoffCount ()
 
virtual void statePreTxData ()
 
virtual void txAck (int dest_addr)
 
virtual void stateIdle ()
 
virtual void stateRxIdle ()
 
virtual void stateTxData ()
 
virtual void stateTxAck (int dest_addr)
 
virtual void stateBackoff ()
 
virtual void stateRxBackoff ()
 
virtual void stateWaitAck ()
 
virtual void stateRxinPreTxData ()
 
virtual void stateRxWaitAck ()
 
virtual void stateListen ()
 
virtual void stateRxListen ()
 
virtual void stateCheckListenExpired ()
 
virtual void stateCheckAckExpired ()
 
virtual void stateCheckBackoffExpired ()
 
virtual void stateCheckWaitTxExpired ()
 
virtual void stateRxData (Packet *p)
 
virtual void stateRxAck (Packet *p)
 
virtual void stateRxPacketNotForMe (Packet *p)
 
virtual void printStateInfo (double delay=0)
 
virtual void initInfo ()
 
virtual void refreshState (UWSR_STATUS state)
 
virtual void refreshReason (UWSR_REASON_STATUS reason)
 
virtual void exitBackoff ()
 
virtual double getRTT ()
 
virtual void updateLastDataIdRx (int id)
 
virtual void waitForUser ()
 
virtual int getRemainingPkts ()
 
virtual void incrUpperDataRx ()
 
virtual int getPktSeqNum (Packet *p)
 
virtual int getMacAddress (Packet *p)
 
bool chkItemInmapTxRounds (int mac_addr, int seq_num)
 handling transmission round
 
void setCurrTxRounds (int mac_addr, int seq_num)
 
void incrCurrTxRounds (int mac_addr, int seq_num)
 
int getCurrTxRounds (int mac_addr, int seq_num)
 
void eraseItemFromTxRounds (int mac_addr, int seq_num)
 
void putPktInQueue (Packet *p)
 handling packets
 
void eraseItemFromPktQueue (int mac_addr, int seq_num)
 
void putAckTimerInMap (int mac_addr, int seq_num)
 managing ack
 
void eraseItemFrommapAckTimer (int mac_addr, int seq_num)
 
void putStartTxTimeInMap (int mac_addr, int seq_num, double start_tx_time)
 
void eraseItemFrommapCalcAck (int mac_addr, int seq_num)
 
virtual int checkAckTimer (CHECK_ACK_TIMER type)
 
virtual void eraseExpiredItemsFrommapAckandCalc ()
 
virtual bool checkMultipleTx (int rcv_mac_addr)
 
virtual int getPktsCanSendIn1RTT (int mac_addr)
 
virtual void putRTTInMap (int mac_addr, double rtt)
 
double getRTTInMap (int mac_addr)
 
void incrPktsSentIn1RTT ()
 
void rstPktsSentIn1RTT ()
 
int getPktsSentIn1RTT ()
 
void incrAcksRcvIn1RTT ()
 
void rstAcksRcvIn1RTT ()
 
int getAcksRcvIn1RTT ()
 
void incrPktsLostCount ()
 
void rstPktsLostCount ()
 
int getPktsLostCount ()
 
virtual bool prepBeforeTx (int mac_addr, int seq_num)
 
virtual double calcWaitTxTime (int mac_addr)
 
void updateTxStatus (macAddress mac_addr, int rcv_acks)
 
virtual int calWindowSize (macAddress mac_addr)
 
void calTotalPktsTx ()
 
double getAvgPktsTxIn1RTT ()
 

Protected Attributes

int max_tx_tries
 
double backoff_tuner
 
double wait_constant
 
int max_payload
 
int HDR_size
 
int ACK_size
 
double ACK_timeout
 
int buffer_pkts
 
double alpha_
 
double max_backoff_counter
 
double listen_time
 
double guard_time
 
double node_speed
 
double var_k
 
int uwsr_debug
 
int last_sent_data_id
 
bool print_transitions
 
bool has_buffer_queue
 
double start_tx_time
 
double srtt
 
double sumrtt
 
double sumrtt2
 
int rttsamples
 
int curr_tx_rounds
 
int last_data_id_rx
 
int recv_data_id
 
int backoff_count
 
int pkt_tx_count
 
Packet * curr_data_pkt
 
double round_trip_time
 
double wait_tx_time
 
double sumwtt
 
int wttsamples
 
int pkts_sent_1RTT
 
int acks_rcv_1RTT
 
int pkts_lost_counter
 
int window_size
 
int txsn
 
double latest_ack_timeout
 
int prv_mac_addr
 
int hit_count
 
int total_pkts_tx
 
AckTimer ack_timer
 
BackOffTimer backoff_timer
 
ListenTimer listen_timer
 
WaitTxTimer wait_tx_timer
 
UWSR_REASON_STATUS last_reason
 
UWSR_STATUS curr_state
 
UWSR_STATUS prev_state
 
UWSR_STATUS prev_prev_state
 
map< usrPair, Packet * > mapPacket
 
map< usrPair, txRoundsmapTxRounds
 
map< usrPair, AckTimermapAckTimer
 
map< usrPair, txStartTimemapCalcAck
 
map< macAddress, rttPairmapRTT
 
map< macAddress, txStatusPairmapTxStatus
 
ofstream fout
 

Static Protected Attributes

static bool initialized = false
 
static const double prop_speed = 1500.0
 
static map< UWSR_STATUS, string > status_info
 
static map< UWSR_REASON_STATUS, string > reason_info
 
static map< UWSR_PKT_TYPE, string > pkt_type_info
 

Detailed Description

This is the base class of MMacUWSR protocol, which is a derived class of MMac.

Member Enumeration Documentation

◆ CHECK_ACK_TIMER

enum MMacUWSR::CHECK_ACK_TIMER
protected

This enumeration class is employed to know the current acknowledgement timer status. First enumerator is given value 1.

Enumerator
CHECK_ACTIVE 
CHECK_EXPIRED 
CHECK_IDLE 

◆ UWSR_PKT_TYPE

enum MMacUWSR::UWSR_PKT_TYPE
protected

Enumeration class of packet type. First enumerator is given value 1. Three kinds of packets are supported by MMacUWSR protocol.

Enumerator
UWSR_ACK_PKT 
UWSR_DATA_PKT 
UWSR_DATAMAX_PKT 

◆ UWSR_REASON_STATUS

Enumeration class which tells the nodes the reason why it is in this state. First enumerator is given value 1.

Enumerator
UWSR_REASON_DATA_PENDING 
UWSR_REASON_DATA_RX 
UWSR_REASON_DATA_TX 
UWSR_REASON_ACK_TX 
UWSR_REASON_ACK_RX 
UWSR_REASON_BACKOFF_TIMEOUT 
UWSR_REASON_ACK_TIMEOUT 
UWSR_REASON_DATA_EMPTY 
UWSR_REASON_NOT_SET 
UWSR_REASON_MAX_TX_TRIES 
UWSR_REASON_BACKOFF_PENDING 
UWSR_REASON_LISTEN 
UWSR_REASON_LISTEN_TIMEOUT 
UWSR_REASON_LISTEN_PENDING 
UWSR_REASON_START_RX 
UWSR_REASON_PKT_NOT_FOR_ME 
UWSR_REASON_WAIT_ACK_PENDING 
UWSR_REASON_PKT_ERROR 
UWSR_REASON_WAIT_TX 
UWSR_REASON_WAIT_TX_PENDING 
UWSR_REASON_WAIT_TX_TIMEOUT 

◆ UWSR_STATUS

enum MMacUWSR::UWSR_STATUS
protected

Enumeration class of MMacUWSR status. First enumerator is given value 1.

Enumerator
UWSR_STATE_IDLE 
UWSR_STATE_BACKOFF 
UWSR_STATE_TX_DATA 
UWSR_STATE_TX_ACK 
UWSR_STATE_WAIT_ACK 
UWSR_STATE_DATA_RX 
UWSR_STATE_ACK_RX 
UWSR_STATE_NOT_SET 
UWSR_STATE_LISTEN 
UWSR_STATE_CHK_ACK_TIMEOUT 
UWSR_STATE_CHK_LISTEN_TIMEOUT 
UWSR_STATE_CHK_BACKOFF_TIMEOUT 
UWSR_STATE_RX_IDLE 
UWSR_STATE_RX_LISTEN 
UWSR_STATE_RX_BACKOFF 
UWSR_STATE_RX_WAIT_ACK 
UWSR_STATE_WRONG_PKT_RX 
UWSR_STATE_WAIT_TX 
UWSR_STATE_CHK_WAIT_TX_TIMEOUT 
UWSR_STATE_WAIT_ACK_WAIT_TX 
UWSR_STATE_RX_DATA_TX_DATA 
UWSR_STATE_PRE_TX_DATA 
UWSR_STATE_RX_IN_PRE_TX_DATA 

◆ UWSR_TIMER_STATUS

Enumeration class of MMacUWSR timer status. First enumerator is given value

  1. It is employed to know the current status of a timer.
Enumerator
UWSR_IDLE 
UWSR_RUNNING 
UWSR_FROZEN 
UWSR_EXPIRED 

Constructor & Destructor Documentation

◆ MMacUWSR()

MMacUWSR::MMacUWSR ( )

Constructor of MMacUWSR Class

Referenced by MMacUWSR::AckTimer::expire(), and MMacUWSR::ListenTimer::expire().

◆ ~MMacUWSR()

MMacUWSR::~MMacUWSR ( )
virtual

Destructor of MMacUWSR Class

Member Function Documentation

◆ calcWaitTxTime()

double MMacUWSR::calcWaitTxTime ( int  mac_addr)
protectedvirtual

Calcultes the time a node has to wait before transmitting another packet in a single RTT.

Parameters
macaddress of the receiving node.
Returns
waiting time (double)

◆ calTotalPktsTx()

void MMacUWSR::calTotalPktsTx ( )
inlineprotected

Total number of packets transmitted by a node.

References getPktsSentIn1RTT(), hit_count, and total_pkts_tx.

Here is the call graph for this function:

◆ calWindowSize()

int MMacUWSR::calWindowSize ( macAddress  mac_addr)
protectedvirtual

Number of packets a node can transmits to a receving node in a single RTT.

Returns
maximum number of packets a node can transmits to a receiving node (integer).

◆ checkAckTimer()

int MMacUWSR::checkAckTimer ( CHECK_ACK_TIMER  type)
protectedvirtual

It checks whether any acknowledgement timer expire. Since, in UWSR, we are transmitting multiple packet in a single RTT, we have to check AckTimer container whether any acknowledgement timer expire or not.

Parameters
typewhich is a CHECK_ACK_TIMER data type.
Returns
number of acknowledgements expire in the container.

◆ checkMultipleTx()

bool MMacUWSR::checkMultipleTx ( int  rcv_mac_addr)
protectedvirtual

This method checks whether the node is capable of sending multiple packets in a single RTT.

Parameters
macaddress of the receiving node.
Returns
Returns TRUE if multiple packet transmission is possible, FALSE otherwise.

◆ chkItemInmapTxRounds()

bool MMacUWSR::chkItemInmapTxRounds ( int  mac_addr,
int  seq_num 
)
inlineprotected

handling transmission round

It checks whether the same packet is transmitted before.

Parameters
macaddress of the node
sequencenumber of the packet.
Returns
boolean data type. Returns TRUE when this packet was not transmitted before and FALSE when it was transmitted.

◆ command()

int MMacUWSR::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 succesfully or not

◆ computeTxTime()

double MMacUWSR::computeTxTime ( UWSR_PKT_TYPE  type)
protectedvirtual

Compute the transmission time of a packet. It uses a cross-layer message to calculate the duration of that packet.

Parameters
typeis a UWSR_PKT_TYPE
Returns
tranmission time of a packet which is a double data type.

◆ eraseExpiredItemsFrommapAckandCalc()

void MMacUWSR::eraseExpiredItemsFrommapAckandCalc ( )
protectedvirtual

Erases those items whose acknowledgement timer expire from AckTimer containter and also from start trasmit time contaioner.

◆ eraseItemFrommapAckTimer()

void MMacUWSR::eraseItemFrommapAckTimer ( int  mac_addr,
int  seq_num 
)
inlineprotected

If a node receives an ACK for its transmitted packet, it erases the related AckTimer object of that packet.

Parameters
macaddress of the node
sequencenumber of the packet.

References mapAckTimer.

◆ eraseItemFrommapCalcAck()

void MMacUWSR::eraseItemFrommapCalcAck ( int  mac_addr,
int  seq_num 
)
inlineprotected

Erases the transmission start time of a packet when an ACK is received correctly.

Parameters
macaddress of the node
sequencenumber of the packet.

References mapCalcAck.

◆ eraseItemFromPktQueue()

void MMacUWSR::eraseItemFromPktQueue ( int  mac_addr,
int  seq_num 
)
inlineprotected

Erase the packet which is delivered to the destination correctly or other reasons

References mapPacket.

◆ eraseItemFromTxRounds()

void MMacUWSR::eraseItemFromTxRounds ( int  mac_addr,
int  seq_num 
)
inlineprotected

Erase an Item form the container where transmission round of various transmit packet are stored.

Parameters
macaddress of the node
sequencenumber of the packet.

References mapTxRounds.

◆ exitBackoff()

void MMacUWSR::exitBackoff ( )
protectedvirtual

It stops the backoff timer.

◆ getAcksRcvIn1RTT()

int MMacUWSR::getAcksRcvIn1RTT ( )
inlineprotected

Returns number of ACK packets receive by a node in single RTT.

Returns
number of ACK receive in single RTT.

References acks_rcv_1RTT.

◆ getAvgPktsTxIn1RTT()

double MMacUWSR::getAvgPktsTxIn1RTT ( )
inlineprotected

Average number of packets transmitted in a single RTT.

References hit_count, and total_pkts_tx.

◆ getBackoffCount()

int MMacUWSR::getBackoffCount ( )
inlineprotected

It returns the number of time backoff counter is run in the whole communication period.

Returns
backoff_count which is an integer data type.

References backoff_count.

◆ getBackoffTime()

double MMacUWSR::getBackoffTime ( )
protectedvirtual

This function calculates the backoff duration and return the backoff time.It employs the exponential backoff algorithm.

Returns
backoff duration which is a double data type.

◆ getCurrTxRounds()

int MMacUWSR::getCurrTxRounds ( int  mac_addr,
int  seq_num 
)
inlineprotected

Returns the current transmission round of a Data packet.

Parameters
macaddress of the node
sequencenumber of the packet.
Returns
an integer data type.

References mapTxRounds.

◆ getMacAddress()

virtual int MMacUWSR::getMacAddress ( Packet *  p)
inlineprotectedvirtual

This method returns the destination mac address of the node which transmits the packet.

Parameters
packetpointer
Returns
it returns the mac address of the node

Referenced by putPktInQueue().

◆ getPktsCanSendIn1RTT()

int MMacUWSR::getPktsCanSendIn1RTT ( int  mac_addr)
protectedvirtual

Number of packets a node can transmits to a receiving node in a single RTT.

Parameters
macaddress of the receiving node.
Returns
number of packets can transmit in a single RTT (integer).

◆ getPktSeqNum()

virtual int MMacUWSR::getPktSeqNum ( Packet *  p)
inlineprotectedvirtual

This method is used to get the sequence number from a packet.

Parameters
packetpointer
Returns
it returns sequence number which is an integer data type.

Referenced by putPktInQueue().

◆ getPktsLostCount()

int MMacUWSR::getPktsLostCount ( )
inlineprotected

Returns number of packets lost in single RTT.

Returns
number of packets lost in single RTT (integer).

References pkts_lost_counter.

◆ getPktsSentIn1RTT()

int MMacUWSR::getPktsSentIn1RTT ( )
inlineprotected

Returns number of Data packets transmit in single RTT.

Returns
packets sent in single RTT (integer).

References pkts_sent_1RTT.

Referenced by calTotalPktsTx().

◆ getRemainingPkts()

virtual int MMacUWSR::getRemainingPkts ( )
inlineprotectedvirtual

Number of packets which MAC layer receives form upper layer(s) but were not transmitted.

Returns
an integer value.

References mapPacket.

◆ getRTT()

virtual double MMacUWSR::getRTT ( )
inlineprotectedvirtual

This method is used to get the average RTT over all the receives RTT.

Returns
average RTT time which is a double data type.

References rttsamples, and sumrtt.

◆ getRTTInMap()

double MMacUWSR::getRTTInMap ( int  mac_addr)
inlineprotected

Returns the RTT between a sender-receiver pair.

Parameters
macaddress of the receiving node.
Returns
RTT which is a double data type.

References mapRTT.

◆ incrAcksRcvIn1RTT()

void MMacUWSR::incrAcksRcvIn1RTT ( )
inlineprotected

Increments the number of ACK packets receive by a node in single RTT.

References acks_rcv_1RTT.

◆ incrCurrTxRounds()

void MMacUWSR::incrCurrTxRounds ( int  mac_addr,
int  seq_num 
)
inlineprotected

Increment the number of times a packet is transmitted.

Parameters
macaddress of the node
sequencenumber of the packet.

References mapTxRounds.

◆ incrPktsLostCount()

void MMacUWSR::incrPktsLostCount ( )
inlineprotected

Increments the number of packets lost in a single RTT.

References pkts_lost_counter.

◆ incrPktsSentIn1RTT()

void MMacUWSR::incrPktsSentIn1RTT ( )
inlineprotected

Increments the number of Data packets sent in single RTT.

References pkts_sent_1RTT.

◆ incrUpperDataRx()

virtual void MMacUWSR::incrUpperDataRx ( )
inlineprotectedvirtual

Increment the number of Data packet receive for the upper layer.

◆ initInfo()

void MMacUWSR::initInfo ( )
protectedvirtual

This function is used to initialize the UWAloha protocol.

◆ initPkt()

void MMacUWSR::initPkt ( Packet *  p,
UWSR_PKT_TYPE  pkt_type,
int  dest_addr = 0 
)
protectedvirtual

This method, initialize the packet. If the packet is received from the upper layer, it adds the header (if any). It also sets the fields of ACK packet.

Parameters
Packetpointer P. The packet can be Data packet or ACK packet.
pkt_typeis an UWSR_PKT_TYPE. Packet can be either Data packet or ACK packet.
dest_addris a integer data type. It is initialized as 0.

◆ Mac2PhyStartTx()

void MMacUWSR::Mac2PhyStartTx ( Packet *  p)
protectedvirtual

It informs that a packet transmission started.

Parameters
Packetpointer

◆ Phy2MacEndRx()

void MMacUWSR::Phy2MacEndRx ( Packet *  p)
protectedvirtual

PHY layer informs the MAC layer that the reception of the packet is over.

Parameters
Packetpointer.

◆ Phy2MacEndTx()

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

It infroms that a packet transmission end.

Parameters
Packetpointer (constant)

◆ Phy2MacStartRx()

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

PHY layer informs the MAC layer that it is receiving a packet. @Param Packet pointer (constant)

◆ prepBeforeTx()

bool MMacUWSR::prepBeforeTx ( int  mac_addr,
int  seq_num 
)
protectedvirtual

It checks how many times a packet is transmitted. If it reaches the threshold of retransmission, the packet is deleted from the all containers.

Parameters
macaddress of the node
sequencenumber of the packet.
Returns
whether this packet can be transmitted or not. TRUE means its retransmission does not exit the threshold and FALSE otherwise.

◆ printStateInfo()

void MMacUWSR::printStateInfo ( double  delay = 0)
protectedvirtual

This methods print the state information of the nodes.

Parameters
delayis a double data type.

◆ putAckTimerInMap()

void MMacUWSR::putAckTimerInMap ( int  mac_addr,
int  seq_num 
)
inlineprotected

managing ack

Put AckTimer Object in the container. For every transmitted packet an AckTimer object is created.

Parameters
macaddress of the node
sequencenumber of the packet.

References ack_timer, and mapAckTimer.

◆ putPktInQueue()

void MMacUWSR::putPktInQueue ( Packet *  p)
inlineprotected

handling packets

Store the packet in a container.

Parameters
packetpointer

References getMacAddress(), getPktSeqNum(), and mapPacket.

Here is the call graph for this function:

◆ putRTTInMap()

void MMacUWSR::putRTTInMap ( int  mac_addr,
double  rtt 
)
protectedvirtual

Put RTT of all the nodes which are whithin the transmission range of a node. Whever a node receives a packet from another node, it put the RTT information of that node in a container.

Parameters
macaddress of the node which transmits the packet
RTTof the sender and receiver.

◆ putStartTxTimeInMap()

void MMacUWSR::putStartTxTimeInMap ( int  mac_addr,
int  seq_num,
double  start_tx_time 
)
inlineprotected

It stores the initial transmission start time in a container.

Parameters
macaddress of the node
sequencenumber of the packet.

References mapCalcAck, and start_tx_time.

◆ recvFromUpperLayers()

void MMacUWSR::recvFromUpperLayers ( Packet *  p)
protectedvirtual

This function receives the packet from upper layer and save it in the queue.

Parameters
Packetpointer

◆ refreshReason()

virtual void MMacUWSR::refreshReason ( UWSR_REASON_STATUS  reason)
inlineprotectedvirtual

To know the reason why a node in this current state.

Parameters
reasonis an UWSR_REASON_STATUS type.

References last_reason.

◆ refreshState()

virtual void MMacUWSR::refreshState ( UWSR_STATUS  state)
inlineprotectedvirtual

Refreshes the states of the node. The node save the information of three states, they are: previous to previous state, previous state and current state of the node.

Parameters
statewhich is an UWSR_STATUS type.

References curr_state, prev_prev_state, and prev_state.

◆ rstAcksRcvIn1RTT()

void MMacUWSR::rstAcksRcvIn1RTT ( )
inlineprotected

Resets the number of ACK packets receive by a node in single RTT.

References acks_rcv_1RTT.

◆ rstPktsLostCount()

void MMacUWSR::rstPktsLostCount ( )
inlineprotected

Resets the number of packets lost in single RTT

References pkts_lost_counter.

◆ rstPktsSentIn1RTT()

void MMacUWSR::rstPktsSentIn1RTT ( )
inlineprotected

Resets the number of Data packets sent in single RTT.

References pkts_sent_1RTT.

◆ setBackoffCount()

void MMacUWSR::setBackoffCount ( )
inlineprotected

It sets the number of times backoff cpounter is run.

References backoff_count.

◆ setCurrTxRounds()

void MMacUWSR::setCurrTxRounds ( int  mac_addr,
int  seq_num 
)
inlineprotected

It sets the current tranmission round of a packet.

Parameters
macaddress of the node
sequencenumber of the packet.

References curr_tx_rounds, and mapTxRounds.

◆ stateBackoff()

void MMacUWSR::stateBackoff ( )
protectedvirtual

If ACK packet is not received within the acknowledgement expire time.

◆ stateCheckAckExpired()

void MMacUWSR::stateCheckAckExpired ( )
protectedvirtual

It checks whether the ack timer is already expired while it was busy with other activities.

◆ stateCheckBackoffExpired()

void MMacUWSR::stateCheckBackoffExpired ( )
protectedvirtual

It checks whether the backoff timer is already expired while it was busy with other activities.

◆ stateCheckListenExpired()

void MMacUWSR::stateCheckListenExpired ( )
protectedvirtual

It checks whether the listen timer is already expired while it was busy with other activities.

◆ stateCheckWaitTxExpired()

void MMacUWSR::stateCheckWaitTxExpired ( )
protectedvirtual

It checks whether the wait transmit timer is already expired while it was busy with other activities.

◆ stateIdle()

void MMacUWSR::stateIdle ( )
protectedvirtual

Node is in Idle state. It only changes its state if it has packet(s) to transmit or it receives a packet.

◆ stateListen()

void MMacUWSR::stateListen ( )
protectedvirtual

A short time which is used to sense the channel condision.

◆ statePreTxData()

void MMacUWSR::statePreTxData ( )
protectedvirtual

This method finds out whether there is any packet to be transmitted to the destination.

◆ stateRxAck()

void MMacUWSR::stateRxAck ( Packet *  p)
protectedvirtual

The node comes to this state if it receives an ACK packet. After receiving an ACK packet it changes it states according to the previously stored status information.

◆ stateRxBackoff()

void MMacUWSR::stateRxBackoff ( )
protectedvirtual

If a node starts receiving a packet when it is in backoff state. The node first freeze (or another word, hold) the backoff timer and start receiving the packet.

◆ stateRxData()

void MMacUWSR::stateRxData ( Packet *  p)
protectedvirtual

It process the packet which is received. After receiving a packet it changes it states according to the previously stored status information.

Parameters
<i>Data</i>packet pointer

◆ stateRxIdle()

void MMacUWSR::stateRxIdle ( )
protectedvirtual

If a node starts receiving a packet in Idle state.

◆ stateRxinPreTxData()

void MMacUWSR::stateRxinPreTxData ( )
protectedvirtual

If a node starts receiving a packet when it was waiting for transmitting another packet in a singlet RTT.

◆ stateRxListen()

void MMacUWSR::stateRxListen ( )
protectedvirtual

If a node starts receiving a packet when it was listening the channel.

◆ stateRxPacketNotForMe()

void MMacUWSR::stateRxPacketNotForMe ( Packet *  p)
protectedvirtual

The receive packet is not intended for this node. The node returns back to its own state.

Parameters
packetpointer

◆ stateRxWaitAck()

void MMacUWSR::stateRxWaitAck ( )
protectedvirtual

If a node receives any packet while it was waiting for ACK packet, it moves to this state. The packet it is receiving can be a Data packet from another node or ACK packet.

◆ stateTxAck()

void MMacUWSR::stateTxAck ( int  dest_addr)
protectedvirtual

After receiving a Data packet the node sends an ACK packet.

◆ stateTxData()

void MMacUWSR::stateTxData ( )
protectedvirtual

If a node has packet to transmits. In such case, it moves from Idle state to data transmits state.

◆ stateWaitAck()

void MMacUWSR::stateWaitAck ( )
protectedvirtual

After transmitting a Data packet, a node waits for the ACK packet.

◆ txAck()

void MMacUWSR::txAck ( int  dest_addr)
protectedvirtual

This methods transmits ACK packet from MAC layer to PHY layer.

Parameters
dest_addrwhich is an integer data type.

◆ updateLastDataIdRx()

virtual void MMacUWSR::updateLastDataIdRx ( int  id)
inlineprotectedvirtual

It updates the sequence number of the last data packet rx.

Parameters
idis an integer data type.

References last_data_id_rx.

◆ updateTxStatus()

void MMacUWSR::updateTxStatus ( macAddress  mac_addr,
int  rcv_acks 
)
inlineprotected

How many acknowledgements receive for the transmitting packets in a single RTT. It stores this information to calculte the next window size (i.e. number of packets can be exchanged between a sender-receiver pair.

Parameters
macaddress of the receiving node.
numberof receive acknowledgement packets in a single RTT

◆ waitForUser()

void MMacUWSR::waitForUser ( )
protectedvirtual

Member Data Documentation

◆ ACK_size

int MMacUWSR::ACK_size
protected

Size of the ACK.

◆ ACK_timeout

double MMacUWSR::ACK_timeout
protected

ACK timeout for the initial packet

◆ ack_timer

AckTimer MMacUWSR::ack_timer
protected

An object of the AckTimer class

Referenced by putAckTimerInMap().

◆ acks_rcv_1RTT

int MMacUWSR::acks_rcv_1RTT
protected

Number of ACK packets receive in single RTT.

Referenced by getAcksRcvIn1RTT(), incrAcksRcvIn1RTT(), and rstAcksRcvIn1RTT().

◆ alpha_

double MMacUWSR::alpha_
protected

This variable is used to tune the RTT

◆ backoff_count

int MMacUWSR::backoff_count
protected

This variable counts how many times a node move to the backoff state

Referenced by getBackoffCount(), and setBackoffCount().

◆ backoff_timer

BackOffTimer MMacUWSR::backoff_timer
protected

An object of the BackOffTimer class

◆ backoff_tuner

double MMacUWSR::backoff_tuner
protected

Tunes the backoff duration.

◆ buffer_pkts

int MMacUWSR::buffer_pkts
protected

Number of packets a node can store in the container

◆ curr_data_pkt

Packet* MMacUWSR::curr_data_pkt
protected

Pointer of the latest selected data packet.

◆ curr_state

UWSR_STATUS MMacUWSR::curr_state
protected

Enum variable. It stores the current state of a node

Referenced by refreshState().

◆ curr_tx_rounds

int MMacUWSR::curr_tx_rounds
protected

How many times the same packet is (re)transmitted

Referenced by setCurrTxRounds().

◆ fout

ofstream MMacUWSR::fout
protected

An object of ofstream class

◆ guard_time

double MMacUWSR::guard_time
protected

A time which is used to componsate variating in timing

◆ has_buffer_queue

bool MMacUWSR::has_buffer_queue
protected

Whether the node has buffer to store data or not

◆ HDR_size

int MMacUWSR::HDR_size
protected

Size of the HDR if any

◆ hit_count

int MMacUWSR::hit_count
protected

This is a counter which is employed to calculate average number of packets transmit in a sigle RTT

Referenced by calTotalPktsTx(), and getAvgPktsTxIn1RTT().

◆ initialized

bool MMacUWSR::initialized = false
staticprotected

It checks whether MMacUWSR protocol is initialized or not. If FALSE means, not initialized and if TRUE means it is initialized

◆ last_data_id_rx

int MMacUWSR::last_data_id_rx
protected

The sequence number of last received packet

Referenced by updateLastDataIdRx().

◆ last_reason

UWSR_REASON_STATUS MMacUWSR::last_reason
protected

Enum variable which stores the last reason why a node changes its state

Referenced by refreshReason().

◆ last_sent_data_id

int MMacUWSR::last_sent_data_id
protected

sequence number of the latest sent packet

◆ latest_ack_timeout

double MMacUWSR::latest_ack_timeout
protected

Latest timeout of an acknowledgement packet.

◆ listen_time

double MMacUWSR::listen_time
protected

A short channel sensing time

◆ listen_timer

ListenTimer MMacUWSR::listen_timer
protected

An object of the ListenTimer class

◆ mapAckTimer

map<usrPair, AckTimer> MMacUWSR::mapAckTimer
protected

Container where AckTimer objects for variuous packets are stored

Referenced by eraseItemFrommapAckTimer(), and putAckTimerInMap().

◆ mapCalcAck

map<usrPair, txStartTime> MMacUWSR::mapCalcAck
protected

Container where starting transmission time of various packets are stored

Referenced by eraseItemFrommapCalcAck(), and putStartTxTimeInMap().

◆ mapPacket

map<usrPair, Packet *> MMacUWSR::mapPacket
protected

Container where Data packets are stored

Referenced by eraseItemFromPktQueue(), getRemainingPkts(), and putPktInQueue().

◆ mapRTT

map<macAddress, rttPair> MMacUWSR::mapRTT
protected

Container where RTT between various sender-receiver pairs are stored

Referenced by getRTTInMap().

◆ mapTxRounds

map<usrPair, txRounds> MMacUWSR::mapTxRounds
protected

Container where retransmission information of various packets are stored

Referenced by eraseItemFromTxRounds(), getCurrTxRounds(), incrCurrTxRounds(), and setCurrTxRounds().

◆ mapTxStatus

map<macAddress, txStatusPair> MMacUWSR::mapTxStatus
protected

Container which stores the number of packets transmitted in a single RTT to a receiving node and number of acknowledgement receive among them.

◆ max_backoff_counter

double MMacUWSR::max_backoff_counter
protected

Maximum number of backoff it will consider while it increases the backoff exponentially

◆ max_payload

int MMacUWSR::max_payload
protected

Maximum number of payload in a packet.

◆ max_tx_tries

int MMacUWSR::max_tx_tries
protected

Maximum number of retransmissions attempt.

◆ node_speed

double MMacUWSR::node_speed
protected

Speed of the mobile node [m/s]

◆ pkt_tx_count

int MMacUWSR::pkt_tx_count
protected

Number of packets transmitted

◆ pkt_type_info

map< MMacUWSR::UWSR_PKT_TYPE, string > MMacUWSR::pkt_type_info
staticprotected

Container which stores all the packet type information of MMacUWSR

◆ pkts_lost_counter

int MMacUWSR::pkts_lost_counter
protected

Number of packets lost in a single RTT.

Referenced by getPktsLostCount(), incrPktsLostCount(), and rstPktsLostCount().

◆ pkts_sent_1RTT

int MMacUWSR::pkts_sent_1RTT
protected

Packets already sent in single RTT

Referenced by getPktsSentIn1RTT(), incrPktsSentIn1RTT(), and rstPktsSentIn1RTT().

◆ prev_prev_state

UWSR_STATUS MMacUWSR::prev_prev_state
protected

Enum variable. It stores the previous to previous state of a node

Referenced by refreshState().

◆ prev_state

UWSR_STATUS MMacUWSR::prev_state
protected

Enum variable. It stores the previous state of a node

Referenced by refreshState().

◆ print_transitions

bool MMacUWSR::print_transitions
protected

Whether to print the state of the nodes

◆ prop_speed

const double MMacUWSR::prop_speed = 1500.0
staticprotected

Speed of the sound signal

◆ prv_mac_addr

int MMacUWSR::prv_mac_addr
protected

Previous mac address

◆ reason_info

map< MMacUWSR::UWSR_REASON_STATUS, string > MMacUWSR::reason_info
staticprotected

Container which stores all the reason information

◆ recv_data_id

int MMacUWSR::recv_data_id
protected

The sequence number of the packet which is received

◆ round_trip_time

double MMacUWSR::round_trip_time
protected

RTT time

◆ rttsamples

int MMacUWSR::rttsamples
protected

Number of RTT samples

Referenced by getRTT().

◆ srtt

double MMacUWSR::srtt
protected

Smoothed Round Trip Time, calculated as for TCP

◆ start_tx_time

double MMacUWSR::start_tx_time
protected

Time when a packet start transmitting

Referenced by putStartTxTimeInMap().

◆ status_info

map< MMacUWSR::UWSR_STATUS, string > MMacUWSR::status_info
staticprotected

Container which stores all the status information

◆ sumrtt

double MMacUWSR::sumrtt
protected

Sum of RTT samples

Referenced by getRTT().

◆ sumrtt2

double MMacUWSR::sumrtt2
protected

Sum of (RTT^2)

◆ sumwtt

double MMacUWSR::sumwtt
protected

Summation of total waiting time

◆ total_pkts_tx

int MMacUWSR::total_pkts_tx
protected

Total number of packets transmit.

Referenced by calTotalPktsTx(), and getAvgPktsTxIn1RTT().

◆ txsn

int MMacUWSR::txsn
protected

Sequence number of the transmitted packet.

◆ uwsr_debug

int MMacUWSR::uwsr_debug
protected

Debuging flag.

◆ var_k

double MMacUWSR::var_k
protected

It is employed to decrease the window size.

◆ wait_constant

double MMacUWSR::wait_constant
protected

This fixed time is employed to componsate different time variations.

◆ wait_tx_time

double MMacUWSR::wait_tx_time
protected

Waiting time before transmitting a packet in a single RTT.

◆ wait_tx_timer

WaitTxTimer MMacUWSR::wait_tx_timer
protected

An object of the WaitTxTimer class

◆ window_size

int MMacUWSR::window_size
protected

Maximum number of packets a node can transmit in a single RTT.

◆ wttsamples

int MMacUWSR::wttsamples
protected

Number of waiting time samples


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