55#define UWOFDMALOHA_DROP_REASON_WRONG_STATE "WST"
56#define UWOFDMALOHA_DROP_REASON_WRONG_RECEIVER "WRCV"
57#define UWOFDMALOHA_DROP_REASON_UNKNOWN_TYPE "UPT"
58#define UWOFDMALOHA_DROP_REASON_BUFFER_FULL "DBF"
59#define UWOFDMALOHA_DROP_REASON_ERROR "ERR"
88 virtual int command(
int argc,
const char *
const *argv);
96 void init_macofdm_node(
int subCarNum,
double subCarSize,
int ctrl_subCar,
string modulation);
386 virtual void expire(Event *e);
416 virtual void expire(Event *e);
487 virtual void txAck(
int dest_addr);
665 hdr_cmn *ch = hdr_cmn::access(p);
680 std::cout <<
"MAC " << addr <<
"putPktInQueue packet "<<
getPktSeqNum(p) << std::endl;
690 map<pktSeqNum, Packet *>::iterator it_p;
693 std::cout <<
"MAC " << addr <<
"eraseItemFromPktQueue packet "<< seq_num << std::endl;
694 Packet::free((*it_p).second);
696 std::cout <<
"eraseItemFromPktQueue freed second " << std::endl;
699 std::cout <<
"eraseItemFromPktQueue erased first " << std::endl;
719 map<pktSeqNum, AckTimer>::iterator it_a;
732 return (up_data_pkts_rx -
mapPacket.size());
747 return up_data_pkts_rx;
758 std::cout << NOW <<
"UwOFDMAloha ("<< addr <<
")::displayCarriers";
761 std::cout <<
" car["<< i <<
"] = " << ofdmph->
carriers[i];
763 std::cout <<
" "<< std::endl;
857 static map<UWOFDMALOHA_REASON_STATUS, string>
860 static map<UWOFDMALOHA_PKT_TYPE, string>
864 map<pktSeqNum, Packet *>
Base class of AckTimer, which is a derived class of UWOFDMAlohaTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~AckTimer()
Destructor of AckTimer Class.
AckTimer(UWOFDMAloha *m)
Constructor of AckTimer Class.
Base class of BackoffTimer.
BackOffTimer(UWOFDMAloha *m)
Constructor of BackOffTimer Class.
virtual ~BackOffTimer()
Destructor of BackOffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of all the timer used in this protocol.
virtual void freeze()
It freezes or in another word, it stops the timer for some time.
void incrCounter()
Increment the timer counter.
bool isRunning()
This method tells whether the timer is in Running state or not.
bool isIdle()
It tells whether the timer is in Idle state or not.
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.
virtual void schedule(double val)
Schedule the time, i.e., how long a timer is going to run.
int counter
How many times a timer ran.
UWOFDMAlohaTimer(UWOFDMAloha *m)
Constructor of UWOFDMAlohaTimer Class.
double start_time
Start time of a timer.
double left_duration
How long a timer is going to run more.
double getDuration()
This methods provide the duration of a timer.
virtual void stop()
Stop the timer any way.
virtual ~UWOFDMAlohaTimer()
Destructor of UWOFDMAlohaTimer Class.
virtual void unFreeze()
It starts the timer from where it was stopped.
void resetCounter()
Reset the timer counter.
int getCounter()
It provides, how many times a timer ran.
UWOFDMAloha *UWOFDMALOHA_TIMER_STATUS timer_status
< Pointer of UWOFDMAloha module.
virtual ~UWOFDMAloha()
Destructor of UWOFDMAloha Class.
UWOFDMALOHA_REASON_STATUS last_reason
Enum variable which stores the last reason why a node changes its state.
static map< UWOFDMALOHA_PKT_TYPE, string > pkt_type_info
Container which stores all the packet type information of UWOFDMAloha.
void eraseItemFromPktQueue(int seq_num)
It erases the packet from the container.
virtual void resetCurrTxRounds()
If a node is going to transmit a new packet, it resets the tx counter.
Packet * curr_data_pkt
Pointer of the latest selected data packet.
int getPktSeqNum(Packet *p)
This method is used to get the sequence number from a packet.
UWOFDMALOHA_REASON_STATUS
Enumeration class which tells the nodes the reason why it is in this state.
@ UWOFDMALOHA_REASON_ACK_TX
@ UWOFDMALOHA_REASON_BACKOFF_TIMEOUT
@ UWOFDMALOHA_REASON_DATA_RX
@ UWOFDMALOHA_REASON_PKT_RECEIVING
@ UWOFDMALOHA_REASON_DATA_EMPTY
@ UWOFDMALOHA_REASON_ACK_TIMEOUT
@ UWOFDMALOHA_REASON_ACK_RX
@ UWOFDMALOHA_REASON_DATA_PENDING
@ UWOFDMALOHA_REASON_PKT_ERROR
@ UWOFDMALOHA_REASON_MAX_TX_TRIES
@ UWOFDMALOHA_REASON_WAIT_ACK_PENDING
@ UWOFDMALOHA_REASON_BACKOFF_PENDING
@ UWOFDMALOHA_REASON_DATA_TX
@ UWOFDMALOHA_REASON_NOT_SET
@ UWOFDMALOHA_REASON_PKT_NOT_FOR_ME
@ UWOFDMALOHA_REASON_START_RX
virtual void txAck(int dest_addr)
This methods transmits ACK packet from MAC layer to PHY layer.
UWOFDMALOHA_ACK_MODES ack_mode
Enum variable.
UWOFDMALOHA_STATUS prev_state
Enum variable.
virtual void incrCurrTxRounds()
Increments the current transmission round of a packet.
UWOFDMAloha()
Constructor of UWOFDMAloha Class.
virtual void stateRxIdle()
If a node start receiving a packet in Idle state.
void init_macofdm_node(int subCarNum, double subCarSize, int ctrl_subCar, string modulation)
Initialize subCarriers parameters inside a node, default all carriers are used.
virtual void stateRxData(Packet *p)
It process the packet which is received.
double wait_constant
This fixed time is used to componsate different time variations.
virtual void stateCheckBackoffExpired()
It checks whether the backoff timer is already expired while it was busy with other activities.
int ACK_size
Size of the ACK, if the node uses ARQ technique.
map< pktSeqNum, Packet * > mapPacket
Container where Data packets are stored.
virtual void Phy2MacEndRx(Packet *p)
PHY layer informs the MAC layer that the reception of the packet is over.
int uwofdmaloha_debug
Debuging Flag.
virtual void refreshReason(UWOFDMALOHA_REASON_STATUS reason)
To know the reason why a node is in this current state.
double max_backoff_counter
Maximum number of backoff it will consider while it increases the backoff exponentially.
int rttsamples
Number of RTT samples.
std::vector< int > nouse_carriers
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
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 ...
double srtt
Smoothed Round Trip Time, calculated as for TCP.
std::vector< Packet * > pkt_rcv_queue
UWOFDMALOHA_ACK_MODES
Enumeration class of UWOFDMAloha acknowledgement mode.
@ UWOFDMALOHA_NO_ACK_MODE
virtual void exitBackoff()
It stops the backoff timer.
int last_sent_data_id
sequence number of the last sent packet
static const double prop_speed
Speed of the sound signal.
int last_data_id_rx
The sequence number of last received packet.
virtual double getBackoffTime()
This function calculates the backoff duration and return the backoff time.It employs the exponential ...
ofstream fout
An object of ofstream class.
virtual void updateLastDataIdRx(int id)
It updates the sequence number of the last data packet rx.
int curr_tx_rounds
How many times a packet is transmitted.
virtual void refreshState(UWOFDMALOHA_STATUS state)
Refreshes the states of the node.
virtual void initPkt(Packet *p, UWOFDMALOHA_PKT_TYPE pkt_type, int dest_addr=0)
This method, initialize the packet.
virtual void stateBackoff()
If ACK packet is not received within the acknowledgement expire time.
void addInvalidCarriers(int c)
Adds carriers that should not be used.
virtual double computeTxTime(UWOFDMALOHA_PKT_TYPE type)
Compute the transmission time of a packet.
UWOFDMALOHA_STATUS curr_state
Enum variable.
double start_tx_time
Time when a packet start transmitting.
double alpha_
This variable is used to tune the RTT.
virtual void Phy2MacEndTx(const Packet *p)
It infroms that a packet transmission end.
virtual void recvFromUpperLayers(Packet *p)
This function receives the packet from upper layer and save it in the queue.
double ACK_timeout
ACK timeout for the initial packet.
static map< UWOFDMALOHA_REASON_STATUS, string > reason_info
Container which stores all the reason information.
virtual void Mac2PhyStartTx(Packet *p)
It informs that a packet transmission started.
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
static map< UWOFDMALOHA_STATUS, string > status_info
Container which stores all the status information.
virtual void txData()
This method transmits Data packets from MAC layer to PHY layer.
int buffer_pkts
Number of packets a node can store in the container.
virtual void updateRTT(double rtt)
Update the Round Trip Time (RTT) which is necessary to compute the acknowledgement duration as well a...
virtual double getRTT()
This method is used to get the average RTT over all the receives RTT.
map< pktSeqNum, AckTimer > mapAckTimer
Container where acknowledgement timer(s) is stored.
virtual void stateRxBackoff()
If a node start receiving a packet when it is in backoff state.
virtual void stateTxData()
If a node has packet to transmits.
std::vector< string > mac_carMod
--— OFDM PARAMS
UWOFDMALOHA_PKT_TYPE
Enumeration class of UWOFDMAloha packet type.
@ UWOFDMALOHA_DATAMAX_PKT
virtual int getRemainingPkts()
Number of packets which MAC layer receives form upper layer(s) but were not transmitted.
virtual void Phy2MacStartRx(const Packet *p)
PHY layer informs the MAC layer that it is receiving a packet.
void putPktInQueue(Packet *p)
A node receives packet(s) from upper layer and store them in the container.
int getUpLayersDataPktsRx()
bool print_transitions
Whether to print the state of the nodes.
AckTimer ack_timer
An object of the AckTimer class.
int recv_data_id
The sequence number of the packet which is received.
int max_tx_tries
Maximum number of retransmissions attempt.
UWOFDMALOHA_STATUS
Enumeration class of UWOFDMAloha status.
@ UWOFDMALOHA_STATE_NOT_SET
@ UWOFDMALOHA_STATE_BACKOFF
@ UWOFDMALOHA_STATE_TX_ACK
@ UWOFDMALOHA_STATE_CHK_BACKOFF_TIMEOUT
@ UWOFDMALOHA_STATE_WRONG_PKT_RX
@ UWOFDMALOHA_STATE_WAIT_ACK
@ UWOFDMALOHA_STATE_DATA_RX
@ UWOFDMALOHA_STATE_RX_IDLE
@ UWOFDMALOHA_STATE_RX_IN_PROGRESS
@ UWOFDMALOHA_STATE_TX_DATA
@ UWOFDMALOHA_STATE_CHK_ACK_TIMEOUT
@ UWOFDMALOHA_STATE_MULTIPLE_RX_IN_PROGRESS
@ UWOFDMALOHA_STATE_RX_BACKOFF
@ UWOFDMALOHA_STATE_RX_WAIT_ACK
@ UWOFDMALOHA_STATE_ACK_RX
int txsn
Sequence number of the packet which is transmitted.
virtual void stateRxWaitAck()
If a node receives any packet while it was waiting for ACK packet, it moves to this state.
double sumrtt
Sum of RTT samples.
bool has_buffer_queue
Whether the node has buffer to store data or not.
BackOffTimer backoff_timer
An object of the backoff timer class.
virtual void printStateInfo(double delay=0)
This methods print the state information of the nodes.
double backoff_tuner
Tunes the backoff duration.
double sumrtt2
Sum of (RTT^2)
virtual void updateAckTimeout(double rtt)
Like updateRTT() function.
int max_payload
Maximum number of payload in a packet.
static bool initialized
It checks whether UWOFDMAloha protocol is initialized or not.
virtual void incrUpperDataRx()
Increment the number of Data packet receive for the upper layer.
int HDR_size
Size of the HDR if any.
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
void displayCarriers(Packet *p)
Prints the carriers as a sequence of 0s and 1s.
virtual void stateWaitAck()
After transmitting a Data packet, a node waits for the ACK packet.
std::vector< int > mac_carVec
UWOFDMALOHA_STATUS prev_prev_state
Enum variable.
UWOFDMALOHA_TIMER_STATUS
Enumeration class of UWOFDMAloha timer status.
virtual void initInfo()
This function is used to initialize the UWOFDMAloha protocol.
virtual void stateIdle()
Node is in Idle state.
void putAckTimerInMap(int seq_num)
Put acknowledgement timer in the container.
void eraseItemFrommapAckTimer(int seq_num)
Erase an item from acknowledgement stored container.
Header of the OFDM message with fields to implement a multi carrier system.
int carriers[MAX_CARRIERS]
std::pair< int, int > counter
counter of collisions
Common structures and variables in the protocol.
#define HDR_OFDM(p)
alias defined to access the PROBE HEADER