53#define UWALOHA_DROP_REASON_WRONG_STATE "WST"
54#define UWALOHA_DROP_REASON_WRONG_RECEIVER "WRCV"
55#define UWALOHA_DROP_REASON_UNKNOWN_TYPE "UPT"
56#define UWALOHA_DROP_REASON_BUFFER_FULL "DBF"
57#define UWALOHA_DROP_REASON_ERROR "ERR"
90 virtual int command(
int argc,
const char *
const *argv);
376 virtual void expire(Event *e);
406 virtual void expire(Event *e);
477 virtual void txAck(
int dest_addr);
656 hdr_cmn *ch = hdr_cmn::access(p);
679 map<pktSeqNum, Packet *>::iterator it_p;
683 Packet::free((*it_p).second);
705 map<pktSeqNum, AckTimer>::iterator it_a;
721 return (up_data_pkts_rx -
mapPacket.size());
736 return up_data_pkts_rx;
805 static map<UWALOHA_REASON_STATUS, string>
808 static map<UWALOHA_PKT_TYPE, string>
812 map<pktSeqNum, Packet *>
Base class of AckTimer, which is a derived class of UWAlohaTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~AckTimer()
Destructor of AckTimer Class.
AckTimer(UWAloha *m)
Constructor of AckTimer Class.
Base class of BackoffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
BackOffTimer(UWAloha *m)
Constructor of BackOffTimer Class.
virtual ~BackOffTimer()
Destructor of BackOffTimer.
Base class of all the timer used in this protocol.
int counter
How many times a timer ran.
virtual void unFreeze()
It starts the timer from where it was stopped.
double getDuration()
This methods provide the duration of a timer.
virtual void stop()
Stop the timer any way.
int getCounter()
It provides, how many times a timer ran.
double start_time
Start time of a timer.
virtual void freeze()
It freezes or in another word, it stops the timer for some time.
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.
void resetCounter()
Reset the timer counter.
virtual ~UWAlohaTimer()
Destructor of UWAlohaTimer Class.
double left_duration
How long a timer is going to run more.
UWAloha *UWALOHA_TIMER_STATUS timer_status
< Pointer of UWAloha module.
virtual void schedule(double val)
Schedule the time, i.e., how long a timer is going to run.
UWAlohaTimer(UWAloha *m)
Constructor of UWAlohaTimer Class.
void incrCounter()
Increment the timer counter.
bool isActive()
It tells whether the timer is active or not.
bool isExpired()
Tells whether the timer is expired or not.
bool isFrozen()
It tells whether the timer is in freeze mode or not.
This is the base class of UWAloha protocol, which is a derived class of MMac.
void putAckTimerInMap(int seq_num)
Put acknowledgement timer in the container.
int rttsamples
Number of RTT samples.
int txsn
Sequence number of the packet which is transmitted.
static map< UWALOHA_STATUS, string > status_info
Container which stores all the status information.
double start_tx_time
Time when a packet start transmitting.
virtual void waitForUser()
static map< UWALOHA_REASON_STATUS, string > reason_info
Container which stores all the reason information.
UWALOHA_STATUS prev_prev_state
Enum variable.
BackOffTimer backoff_timer
An object of the backoff timer class.
void eraseItemFromPktQueue(int seq_num)
It erases the packet from the container.
virtual ~UWAloha()
Destructor of UWAloha Class.
UWAloha()
Constructor of UWAloha Class.
static bool initialized
It checks whether UWAloha protocol is initialized or not.
virtual void stateTxData()
If a node has packet to transmits.
int max_payload
Maximum number of payload in a packet.
UWALOHA_TIMER_STATUS
Enumeration class of UWAloha timer status.
UWALOHA_ACK_MODES
Enumeration class of UWAloha acknowledgement mode.
int last_sent_data_id
sequence number of the last sent packet
virtual void txData()
This method transmits Data packets from MAC layer to PHY layer.
virtual void Phy2MacStartRx(const Packet *p)
PHY layer informs the MAC layer that it is receiving a packet.
virtual void stateRxData(Packet *p)
It process the packet which is received.
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
UWALOHA_PKT_TYPE
Enumeration class of UWAloha packet type.
bool print_transitions
Whether to print the state of the nodes.
int buffer_pkts
Number of packets a node can store in the container.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual void stateWaitAck()
After transmitting a Data packet, a node waits for the ACK packet.
UWALOHA_STATUS prev_state
Enum variable.
virtual void updateLastDataIdRx(int id)
It updates the sequence number of the last data packet rx.
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
double ACK_timeout
ACK timeout for the initial packet.
double backoff_tuner
Tunes the backoff duration.
virtual void stateIdle()
Node is in Idle state.
int getUpLayersDataPktsRx()
virtual void resetCurrTxRounds()
If a node is going to transmit a new packet, it resets the tx counter.
virtual void updateRTT(double rtt)
Update the Round Trip Time (RTT) which is necessary to compute the acknowledgement duration as well a...
UWALOHA_REASON_STATUS
Enumeration class which tells the nodes the reason why it is in this state.
@ UWALOHA_REASON_BACKOFF_PENDING
@ UWALOHA_REASON_DATA_PENDING
@ UWALOHA_REASON_DATA_EMPTY
@ UWALOHA_REASON_WAIT_ACK_PENDING
@ UWALOHA_REASON_START_RX
@ UWALOHA_REASON_BACKOFF_TIMEOUT
@ UWALOHA_REASON_MAX_TX_TRIES
@ UWALOHA_REASON_ACK_TIMEOUT
@ UWALOHA_REASON_PKT_ERROR
@ UWALOHA_REASON_PKT_NOT_FOR_ME
virtual void initInfo()
This function is used to initialize the UWAloha protocol.
virtual double computeTxTime(UWALOHA_PKT_TYPE type)
Compute the transmission time of a packet.
int curr_tx_rounds
How many times a packet is transmitted.
virtual void stateCheckBackoffExpired()
It checks whether the backoff timer is already expired while it was busy with other activities.
virtual void stateRxIdle()
If a node start receiving a packet in Idle state.
UWALOHA_STATUS curr_state
Enum variable.
UWALOHA_STATUS
Enumeration class of UWAloha status.
@ UWALOHA_STATE_CHK_ACK_TIMEOUT
@ UWALOHA_STATE_RX_BACKOFF
@ UWALOHA_STATE_RX_WAIT_ACK
@ UWALOHA_STATE_CHK_BACKOFF_TIMEOUT
@ UWALOHA_STATE_WRONG_PKT_RX
double sumrtt
Sum of RTT samples.
virtual void Phy2MacEndTx(const Packet *p)
It infroms that a packet transmission end.
virtual double getRTT()
This method is used to get the average RTT over all the receives RTT.
int getPktSeqNum(Packet *p)
This method is used to get the sequence number from a packet.
virtual void stateRxBackoff()
If a node start receiving a packet when it is in backoff state.
virtual void exitBackoff()
It stops the backoff timer.
virtual int getRemainingPkts()
Number of packets which MAC layer receives form upper layer(s) but were not transmitted.
int last_data_id_rx
The sequence number of last received packet.
int max_backoff_counter
Maximum number of backoff it will consider while it increases the backoff exponentially.
virtual void Phy2MacEndRx(Packet *p)
PHY layer informs the MAC layer that the reception of the packet is over.
static const double prop_speed
Speed of the sound signal.
bool has_buffer_queue
Whether the node has buffer to store data or not.
virtual double getBackoffTime()
This function calculates the backoff duration and return the backoff time.It employs the exponential ...
virtual void incrCurrTxRounds()
Increments the current transmission round of a packet.
void putPktInQueue(Packet *p)
A node receives packet(s) from upper layer and store them in the container.
AckTimer ack_timer
An object of the AckTimer class.
virtual void Mac2PhyStartTx(Packet *p)
It informs that a packet transmission started.
map< pktSeqNum, AckTimer > mapAckTimer
Container where acknowledgement timer(s) is stored.
UWALOHA_ACK_MODES ack_mode
Enum variable.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
int max_tx_tries
Maximum number of transmissions for one packet.
static map< UWALOHA_PKT_TYPE, string > pkt_type_info
Container which stores all the packet type information of UWAloha.
UWALOHA_REASON_STATUS last_reason
Enum variable which stores the last reason why a node changes its state.
virtual void stateBackoff()
If ACK packet is not received within the acknowledgement expire time.
virtual void initPkt(Packet *p, UWALOHA_PKT_TYPE pkt_type, int dest_addr=0)
This method, initialize the packet.
void eraseItemFrommapAckTimer(int seq_num)
Erase an item from acknowledgement stored container.
int ACK_size
Size of the ACK, if the node uses ARQ technique.
double sumrtt2
Sum of (RTT^2)
virtual void stateRxWaitAck()
If a node receives any packet while it was waiting for ACK packet, it moves to this state.
int recv_data_id
The sequence number of the packet which is received.
double wait_constant
This fixed time is used to componsate different time variations.
map< pktSeqNum, Packet * > mapPacket
Container where Data packets are stored.
virtual void incrUpperDataRx()
Increment the number of Data packet receive for the upper layer.
virtual void refreshState(UWALOHA_STATUS state)
Refreshes the states of the node.
int uwaloha_debug
Debuging Flag.
virtual void recvFromUpperLayers(Packet *p)
This function receives the packet from upper layer and save it in the queue.
ofstream fout
An object of ofstream class.
virtual void stateTxAck(int dest_addr)
If the protocl uses ARQ technique, in that case, after receiving a Data packet the node sends an ACK ...
virtual void updateAckTimeout(double rtt)
Like updateRTT() function.
virtual void printStateInfo(double delay=0)
This methods print the state information of the nodes.
virtual void refreshReason(UWALOHA_REASON_STATUS reason)
To know the reason why a node is in this current state.
double alpha_
This variable is used to tune the RTT.
Packet * curr_data_pkt
Pointer of the latest selected data packet.
int HDR_size
Size of the HDR if any.
virtual void txAck(int dest_addr)
This methods transmits ACK packet from MAC layer to PHY layer.
std::pair< int, int > counter
counter of collisions