63#define UWSR_DROP_REASON_WRONG_STATE "WST"
64#define UWSR_DROP_REASON_WRONG_RECEIVER "WRCV"
65#define UWSR_DROP_REASON_UNKNOWN_TYPE "UPT"
66#define UWSR_DROP_REASON_BUFFER_FULL "DBF"
67#define UWSR_DROP_REASON_ERROR "ERR"
75typedef pair<macAddress, pktSeqNum>
usrPair;
106 virtual int command(
int argc,
const char *
const *argv);
411 virtual void expire(Event *e);
441 virtual void expire(Event *e);
471 virtual void expire(Event *e);
501 virtual void expire(Event *e);
592 virtual void txAck(
int dest_addr);
774 return (up_data_pkts_rx -
mapPacket.size());
794 hdr_cmn *ch = hdr_cmn::access(p);
807 hdr_mac *mach = HDR_MAC(p);
808 return mach->macDA();
842 map<usrPair, txRounds>::iterator it_t;
843 it_t =
mapTxRounds.find(make_pair(mac_addr, seq_num));
856 map<usrPair, txRounds>::iterator it_t;
857 it_t =
mapTxRounds.find(make_pair(mac_addr, seq_num));
858 return ((*it_t).second);
870 map<usrPair, txRounds>::iterator it_t;
871 it_t =
mapTxRounds.find(make_pair(mac_addr, seq_num));
894 map<usrPair, Packet *>::iterator it_p;
895 it_p =
mapPacket.find(make_pair(mac_addr, seq_num));
896 Packet::free((*it_p).second);
922 map<usrPair, AckTimer>::iterator it_a;
923 it_a =
mapAckTimer.find(make_pair(mac_addr, seq_num));
948 map<usrPair, txStartTime>::iterator it_ca;
949 it_ca =
mapCalcAck.find(make_pair(mac_addr, seq_num));
992 virtual void putRTTInMap(
int mac_addr,
double rtt);
1002 map<macAddress, rttPair>::iterator it_d;
1003 it_d =
mapRTT.find(mac_addr);
1004 return (it_d->second).first;
1241 static map<UWSR_STATUS, string>
1244 static map<UWSR_REASON_STATUS, string>
1247 static map<UWSR_PKT_TYPE, string>
1251 map<usrPair, Packet *>
Base class of AckTimer, which is a derived class of UWSRTimer.
AckTimer(MMacUWSR *m)
Constructor of AckTimer Class.
virtual ~AckTimer()
Destructor of AckTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of BackoffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~BackOffTimer()
Destructor of BackOffTimer.
BackOffTimer(MMacUWSR *m)
Constructor of BackOffTimer Class.
Base class of ListenTimer, which is a derived class of UWSRTimer.
ListenTimer(MMacUWSR *m)
Constructor of ListenTimer class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~ListenTimer()
Destructor of ListenTimer class.
Base class of all the timer used in this protocol.
int counter
How many times a timer ran.
UWSRTimer(MMacUWSR *m)
Constructor of UWSRTimer Class.
virtual void stop()
Stop the timer any way.
MMacUWSR *UWSR_TIMER_STATUS timer_status
< Pointer of MMacUWSR module.
void resetCounter()
Reset the timer counter.
bool isIdle()
It tells whether the timer is in Idle state or not.
bool isRunning()
This method tells whether the timer is in Running state or not.
double leftDuration()
This methods provide the remaining duration of a timer.
virtual ~UWSRTimer()
Destructor of UWSRTimer Class.
virtual void unFreeze()
It starts the timer from where it was stopped.
bool isFrozen()
It tells whether the timer is in freeze mode or not.
double start_time
Start time of a timer.
void incrCounter()
Increment the timer counter.
virtual void schedule(double val)
Schedule the time, i.e., how long a timer is going to run.
virtual void freeze()
It freezes or in another word, it stops the timer for some time.
double left_duration
How long a timer is going to run more.
double getDuration()
This methods provide the duration of a timer.
int getCounter()
It provides, how many times a timer ran.
bool isActive()
It tells whether the timer is active or not.
bool isExpired()
Tells whether the timer is expired or not.
Base class of WaitTxTimer, which is a derived class of UWSRTimer.
virtual ~WaitTxTimer()
Destructor of WaitTxTimer class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
WaitTxTimer(MMacUWSR *m)
Constructor of WaitTxTimer class.
This is the base class of MMacUWSR protocol, which is a derived class of MMac.
static bool initialized
It checks whether MMacUWSR protocol is initialized or not.
virtual void refreshState(UWSR_STATUS state)
Refreshes the states of the node.
void eraseItemFromPktQueue(int mac_addr, int seq_num)
Erase the packet which is delivered to the destination correctly or other reasons.
int rttsamples
Number of RTT samples.
double wait_constant
This fixed time is employed to componsate different time variations.
double ACK_timeout
ACK timeout for the initial packet.
virtual void printStateInfo(double delay=0)
This methods print the state information of the nodes.
virtual void stateCheckWaitTxExpired()
It checks whether the wait transmit timer is already expired while it was busy with other activities.
void setBackoffCount()
It sets the number of times backoff cpounter is run.
AckTimer ack_timer
An object of the AckTimer class.
double var_k
It is employed to decrease the window size.
int ACK_size
Size of the ACK.
void putPktInQueue(Packet *p)
handling packets
UWSR_TIMER_STATUS
Enumeration class of MMacUWSR timer status.
int getBackoffCount()
It returns the number of time backoff counter is run in the whole communication period.
double sumwtt
Summation of total waiting time.
virtual void updateLastDataIdRx(int id)
It updates the sequence number of the last data packet rx.
void updateTxStatus(macAddress mac_addr, int rcv_acks)
How many acknowledgements receive for the transmitting packets in a single RTT.
virtual bool checkMultipleTx(int rcv_mac_addr)
This method checks whether the node is capable of sending multiple packets in a single RTT.
bool print_transitions
Whether to print the state of the nodes.
map< macAddress, txStatusPair > mapTxStatus
Container which stores the number of packets transmitted in a single RTT to a receiving node and numb...
virtual void stateTxData()
If a node has packet to transmits.
void putAckTimerInMap(int mac_addr, int seq_num)
managing ack
virtual void stateListen()
A short time which is used to sense the channel condision.
int total_pkts_tx
Total number of packets transmit.
void putStartTxTimeInMap(int mac_addr, int seq_num, double start_tx_time)
It stores the initial transmission start time in a container.
virtual void waitForUser()
int pkts_sent_1RTT
Packets already sent in single RTT.
UWSR_STATUS prev_prev_state
Enum variable.
int hit_count
This is a counter which is employed to calculate average number of packets transmit in a sigle RTT.
UWSR_STATUS curr_state
Enum variable.
ListenTimer listen_timer
An object of the ListenTimer class.
void incrPktsLostCount()
Increments the number of packets lost in a single RTT.
virtual int checkAckTimer(CHECK_ACK_TIMER type)
It checks whether any acknowledgement timer expire.
void incrPktsSentIn1RTT()
Increments the number of Data packets sent in single RTT.
map< macAddress, rttPair > mapRTT
Container where RTT between various sender-receiver pairs are stored.
int txsn
Sequence number of the transmitted packet.
virtual void eraseExpiredItemsFrommapAckandCalc()
Erases those items whose acknowledgement timer expire from AckTimer containter and also from start tr...
virtual void initPkt(Packet *p, UWSR_PKT_TYPE pkt_type, int dest_addr=0)
This method, initialize the packet.
WaitTxTimer wait_tx_timer
An object of the WaitTxTimer class.
int backoff_count
This variable counts how many times a node move to the backoff state.
int getCurrTxRounds(int mac_addr, int seq_num)
Returns the current transmission round of a Data packet.
virtual double calcWaitTxTime(int mac_addr)
Calcultes the time a node has to wait before transmitting another packet in a single RTT.
MMacUWSR()
Constructor of MMacUWSR Class.
virtual void incrUpperDataRx()
Increment the number of Data packet receive for the upper layer.
map< usrPair, txRounds > mapTxRounds
Container where retransmission information of various packets are stored.
CHECK_ACK_TIMER
This enumeration class is employed to know the current acknowledgement timer status.
int uwsr_debug
Debuging flag.
virtual void Mac2PhyStartTx(Packet *p)
It informs that a packet transmission started.
double node_speed
Speed of the mobile node [m/s].
virtual int getPktSeqNum(Packet *p)
This method is used to get the sequence number from a packet.
bool chkItemInmapTxRounds(int mac_addr, int seq_num)
handling transmission round
int prv_mac_addr
Previous mac address.
void incrAcksRcvIn1RTT()
Increments the number of ACK packets receive by a node in single RTT.
virtual void stateRxPacketNotForMe(Packet *p)
The receive packet is not intended for this node.
virtual int getPktsCanSendIn1RTT(int mac_addr)
Number of packets a node can transmits to a receiving node in a single RTT.
virtual void stateTxAck(int dest_addr)
After receiving a Data packet the node sends an ACK packet.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual int getRemainingPkts()
Number of packets which MAC layer receives form upper layer(s) but were not transmitted.
virtual bool prepBeforeTx(int mac_addr, int seq_num)
It checks how many times a packet is transmitted.
double guard_time
A time which is used to componsate variating in timing.
virtual void recvFromUpperLayers(Packet *p)
This function receives the packet from upper layer and save it in the queue.
void calTotalPktsTx()
Total number of packets transmitted by a node.
double max_backoff_counter
Maximum number of backoff it will consider while it increases the backoff exponentially.
int last_data_id_rx
The sequence number of last received packet.
map< usrPair, txStartTime > mapCalcAck
Container where starting transmission time of various packets are stored.
virtual void stateIdle()
Node is in Idle state.
double latest_ack_timeout
Latest timeout of an acknowledgement packet.
double getAvgPktsTxIn1RTT()
Average number of packets transmitted in a single RTT.
virtual void initInfo()
This function is used to initialize the UWAloha protocol.
void rstPktsSentIn1RTT()
Resets the number of Data packets sent in single RTT.
int curr_tx_rounds
How many times the same packet is (re)transmitted.
virtual double getRTT()
This method is used to get the average RTT over all the receives RTT.
UWSR_PKT_TYPE
Enumeration class of packet type.
ofstream fout
An object of ofstream class.
virtual void stateRxIdle()
If a node starts receiving a packet in Idle state.
virtual int calWindowSize(macAddress mac_addr)
Number of packets a node can transmits to a receving node in a single RTT.
virtual double computeTxTime(UWSR_PKT_TYPE type)
Compute the transmission time of a packet.
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
static const double prop_speed
Speed of the sound signal.
virtual void Phy2MacStartRx(const Packet *p)
PHY layer informs the MAC layer that it is receiving a packet.
void eraseItemFrommapAckTimer(int mac_addr, int seq_num)
If a node receives an ACK for its transmitted packet, it erases the related AckTimer object of that p...
UWSR_REASON_STATUS
Enumeration class which tells the nodes the reason why it is in this state.
@ UWSR_REASON_DATA_PENDING
@ UWSR_REASON_LISTEN_TIMEOUT
@ UWSR_REASON_ACK_TIMEOUT
@ UWSR_REASON_BACKOFF_PENDING
@ UWSR_REASON_WAIT_ACK_PENDING
@ UWSR_REASON_LISTEN_PENDING
@ UWSR_REASON_BACKOFF_TIMEOUT
@ UWSR_REASON_MAX_TX_TRIES
@ UWSR_REASON_WAIT_TX_TIMEOUT
@ UWSR_REASON_PKT_NOT_FOR_ME
@ UWSR_REASON_WAIT_TX_PENDING
void rstPktsLostCount()
Resets the number of packets lost in single RTT.
double backoff_tuner
Tunes the backoff duration.
virtual ~MMacUWSR()
Destructor of MMacUWSR Class.
int max_tx_tries
Maximum number of retransmissions attempt.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void stateRxinPreTxData()
If a node starts receiving a packet when it was waiting for transmitting another packet in a singlet ...
UWSR_STATUS
Enumeration class of MMacUWSR status.
@ UWSR_STATE_CHK_LISTEN_TIMEOUT
@ UWSR_STATE_CHK_WAIT_TX_TIMEOUT
@ UWSR_STATE_RX_IN_PRE_TX_DATA
@ UWSR_STATE_CHK_ACK_TIMEOUT
@ UWSR_STATE_RX_DATA_TX_DATA
@ UWSR_STATE_CHK_BACKOFF_TIMEOUT
@ UWSR_STATE_WRONG_PKT_RX
@ UWSR_STATE_WAIT_ACK_WAIT_TX
int max_payload
Maximum number of payload in a packet.
virtual void stateRxListen()
If a node starts receiving a packet when it was listening the channel.
double wait_tx_time
Waiting time before transmitting a packet in a single RTT.
virtual void stateBackoff()
If ACK packet is not received within the acknowledgement expire time.
int getAcksRcvIn1RTT()
Returns number of ACK packets receive by a node in single RTT.
virtual void stateRxData(Packet *p)
It process the packet which is received.
void eraseItemFrommapCalcAck(int mac_addr, int seq_num)
Erases the transmission start time of a packet when an ACK is received correctly.
int pkt_tx_count
Number of packets transmitted.
int getPktsSentIn1RTT()
Returns number of Data packets transmit in single RTT.
static map< UWSR_STATUS, string > status_info
Container which stores all the status information.
UWSR_REASON_STATUS last_reason
Enum variable which stores the last reason why a node changes its state.
virtual double getBackoffTime()
This function calculates the backoff duration and return the backoff time.It employs the exponential ...
double start_tx_time
Time when a packet start transmitting.
void eraseItemFromTxRounds(int mac_addr, int seq_num)
Erase an Item form the container where transmission round of various transmit packet are stored.
static map< UWSR_PKT_TYPE, string > pkt_type_info
Container which stores all the packet type information of MMacUWSR.
double getRTTInMap(int mac_addr)
Returns the RTT between a sender-receiver pair.
double round_trip_time
RTT time.
virtual void Phy2MacEndTx(const Packet *p)
It infroms that a packet transmission end.
virtual void stateRxBackoff()
If a node starts receiving a packet when it is in backoff state.
int recv_data_id
The sequence number of the packet which is received.
int last_sent_data_id
sequence number of the latest sent packet
int getPktsLostCount()
Returns number of packets lost in single RTT.
UWSR_STATUS prev_state
Enum variable.
Packet * curr_data_pkt
Pointer of the latest selected data packet.
double listen_time
A short channel sensing time.
virtual void txAck(int dest_addr)
This methods transmits ACK packet from MAC layer to PHY layer.
int pkts_lost_counter
Number of packets lost in a single RTT.
virtual int getMacAddress(Packet *p)
This method returns the destination mac address of the node which transmits the packet.
void rstAcksRcvIn1RTT()
Resets the number of ACK packets receive by a node in single RTT.
virtual void statePreTxData()
This method finds out whether there is any packet to be transmitted to the destination.
void incrCurrTxRounds(int mac_addr, int seq_num)
Increment the number of times a packet is transmitted.
int HDR_size
Size of the HDR if any.
int buffer_pkts
Number of packets a node can store in the container.
int wttsamples
Number of waiting time samples.
double alpha_
This variable is used to tune the RTT.
static map< UWSR_REASON_STATUS, string > reason_info
Container which stores all the reason information.
map< usrPair, Packet * > mapPacket
Container where Data packets are stored.
int window_size
Maximum number of packets a node can transmit in a single RTT.
virtual void Phy2MacEndRx(Packet *p)
PHY layer informs the MAC layer that the reception of the packet is over.
int acks_rcv_1RTT
Number of ACK packets receive in single RTT.
virtual void exitBackoff()
It stops the backoff timer.
BackOffTimer backoff_timer
An object of the BackOffTimer class.
virtual void stateCheckListenExpired()
It checks whether the listen timer is already expired while it was busy with other activities.
bool has_buffer_queue
Whether the node has buffer to store data or not.
virtual void stateCheckBackoffExpired()
It checks whether the backoff timer is already expired while it was busy with other activities.
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
void setCurrTxRounds(int mac_addr, int seq_num)
It sets the current tranmission round of a packet.
double sumrtt2
Sum of (RTT^2)
double sumrtt
Sum of RTT samples.
virtual void putRTTInMap(int mac_addr, double rtt)
Put RTT of all the nodes which are whithin the transmission range of a node.
virtual void stateRxWaitAck()
If a node receives any packet while it was waiting for ACK packet, it moves to this state.
virtual void stateWaitAck()
After transmitting a Data packet, a node waits for the ACK packet.
map< usrPair, AckTimer > mapAckTimer
Container where AckTimer objects for variuous packets are stored.
virtual void refreshReason(UWSR_REASON_STATUS reason)
To know the reason why a node in this current state.
std::pair< int, int > counter
counter of collisions
pair< double, double > rttPair
pair< int, int > txStatusPair
pair< macAddress, pktSeqNum > usrPair