64#define UWSMARTOFDM_DROP_REASON_WRONG_STATE "WST"
65#define UWSMARTOFDM_DROP_REASON_WRONG_RECEIVER "WRCV"
66#define UWSMARTOFDM_DROP_REASON_UNKNOWN_TYPE "UPT"
67#define UWSMARTOFDM_DROP_REASON_BUFFER_FULL "DBF"
68#define UWSMARTOFDM_DROP_REASON_ERROR "ERR"
119 virtual int command(
int argc,
const char *
const *argv);
122 void init_macofdm_node(
int subCarNum,
double carSize,
int ctrl_subCar, std::string modulation);
445 virtual void expire(Event *e);
475 virtual void expire(Event *e);
505 virtual void expire(Event *e);
534 virtual void expire(Event *e);
565 virtual void expire(Event *e);
596 virtual void expire(Event *e);
626 virtual void expire(Event *e);
697 virtual void txAck(
int dest_addr);
703 virtual void txRTS();
711 virtual void txCTS(
int dest_addr,
int* rcv_car,
int bytesToSend);
949 hdr_cmn *ch = hdr_cmn::access(p);
972 map<pktSeqNum, Packet *>::iterator it_p;
975 Packet::free((*it_p).second);
980 std::cout <<
"ATTENTION PACKET NOT FOUND IN PKTQUEUE" << std::endl;
1000 map<pktSeqNum, AckTimer>::iterator it_a;
1013 return (up_data_pkts_rx -
mapPacket.size());
1028 return up_data_pkts_rx;
1069 int matchCarriers(
int* myFree,
int* otherFree,
int* matching);
1215 static map<UWSMARTOFDM_REASON_STATUS, string>
1218 static map<UWSMARTOFDM_PKT_TYPE, string>
1221 static map<criticalLevel, string>
1225 map<pktSeqNum, Packet *>
Base class of AckTimer, which is a derived class of UWSmartOFDMTimer.
virtual ~AckTimer()
Destructor of AckTimer Class.
AckTimer(UWSmartOFDM *m)
Constructor of AckTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of AssignmentTimer.
AssignmentTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~AssignmentTimer()
Destructor of BackOffTimer.
Base class of AssignmentValidTimer.
virtual ~AssignmentValidTimer()
Destructor of BackOffTimer.
AssignmentValidTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of BackoffTimer.
BackOffTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~BackOffTimer()
Destructor of BackOffTimer.
CTSTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual ~CTSTimer()
Destructor of BackOffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
DATATimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual ~DATATimer()
Destructor of BackOffTimer.
virtual ~RTSTimer()
Destructor of BackOffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
RTSTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
Base class of all the timer used in this protocol.
double left_duration
How long a timer is going to run more.
virtual void stop()
Stop the timer any way.
UWSmartOFDM *UWSMARTOFDM_TIMER_STATUS timer_status
< Pointer of UWSmartOFDM module.
void resetCounter()
Reset the timer counter.
double getDuration()
This methods provide the duration of a timer.
void incrCounter()
Increment the timer counter.
virtual double startTime()
int getCounter()
It provides, how many times a timer ran.
bool isActive()
It tells whether the timer is active or not.
virtual ~UWSmartOFDMTimer()
Destructor of UWSmartOFDMTimer Class.
double start_time
Start time of a timer.
int counter
How many times a timer ran.
bool isFrozen()
It tells whether the timer is in freeze mode or not.
bool isExpired()
Tells whether the timer is expired or not.
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.
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.
UWSmartOFDMTimer(UWSmartOFDM *m)
Constructor of UWSmartOFDMTimer Class.
virtual void unFreeze()
It starts the timer from where it was stopped.
This is the base class of UWSmartOFDM protocol, which is a derived class of MMac.
virtual double getCTSsent()
This method is used to get the total number of sent CTS messages.
virtual void stateWaitCTS()
Node is in waitCTS state.
void eraseItemFromPktQueue(int seq_num)
It erases the packet from the container.
virtual void stateTxData()
If a node has packet to transmits.
virtual ~UWSmartOFDM()
Destructor of UWSmartOFDM Class.
double wait_constant
This fixed time is used to componsate different time variations.
int recv_data_id
The sequence number of the packet which is received.
virtual void stateRxBackoff()
If a node start receiving a packet when it is in backoff state.
bool print_transitions
Whether to print the state of the nodes.
virtual void Phy2MacEndTx(const Packet *p)
It infroms that a packet transmission end.
void putAckTimerInMap(int seq_num)
Put acknowledgement timer in the container.
virtual double computeTxTime(UWSMARTOFDM_PKT_TYPE type)
Compute the transmission time of a packet.
virtual void recvFromUpperLayers(Packet *p)
This function receives the packet from upper layer and save it in the queue.
virtual void stateRxRTS(Packet *p)
int getHighPrioPktsSent()
std::vector< int > mac_carVec
virtual void incrCurrTxRounds()
Increments the current transmission round of a packet.
void init_macofdm_node(int subCarNum, double carSize, int ctrl_subCar, std::string modulation)
int txsn
Sequence number of the packet which is transmitted.
virtual void txAck(int dest_addr)
This methods transmits ACK packet from MAC layer to PHY layer.
bool has_buffer_queue
Whether the node has buffer to store data or not.
AssignmentValidTimer assignment_valid_timer
An object of the assignment valid timer class.
virtual void stateBackoffCTS()
Node is in BackoffCTS state.
int max_payload
Maximum number of payload in a packet.
void clearOccTable()
clears the carriers used in the past moves the index for the current time to the next slot
CTSTimer CTS_timer
An object of the CTS timer class.
int HDR_size
Size of the HDR if any.
int uwsmartofdm_debug
Debuging Flag.
void printOccTable()
prints on terminal the table
static map< criticalLevel, string > clevel_info
Container which stores all the packet type information of UWSmartOFDM.
void addInvalidCarriers(int c)
void carToBeUsed(criticalLevel c, int &top, int &bottom, int &avoid_top, int &avoid_bottom)
returns the current free carriers that can be given to a node top and bottom give the range avoid_top...
virtual double getBackoffTime()
This function calculates the backoff duration and return the backoff time.It employs the exponential ...
Packet * curr_data_pkt
Pointer of the latest selected data packet.
int RTS_size
Size of the ACK, if the node uses SMARTOFDM.
void updateOccupancy(int *busyCar, int ntslots)
updates occupancy table
UWSmartOFDM()
Constructor of UWSmartOFDM Class.
std::vector< std::vector< int > > occupancy_table
virtual void resetCurrTxRounds()
If a node is going to transmit a new packet, it resets the tx counter.
void putPktInQueue(Packet *p)
A node receives packet(s) from upper layer and store them 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...
AssignmentTimer assignment_timer
An object of the assignment timer class.
static map< UWSMARTOFDM_REASON_STATUS, string > reason_info
Container which stores all the reason information.
virtual void stateRxData(Packet *p)
It process the packet which is received.
virtual void incrUpperDataRx()
Increment the number of Data packet receive for the upper layer.
virtual void txCTS(int dest_addr, int *rcv_car, int bytesToSend)
This methods transmits CTS packet from MAC layer to PHY layer.
std::vector< std::vector< double > > interf_table
AckTimer ack_timer
An object of the AckTimer class.
DATATimer DATA_timer
An object of the DATA timer class.
int last_data_id_rx
The sequence number of last received packet.
UWSMARTOFDM_ACK_MODES
Enumeration class of UWSmartOFDM acknowledgement mode.
@ UWSMARTOFDM_NO_ACK_MODE
void removeInvalidCarrier(int c)
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
void updateInterfTable(Packet *p)
virtual void stateWaitData(double t)
UWSMARTOFDM_STATUS
Enumeration class of UWSmartOFDM status.
@ UWSMARTOFDM_STATE_ACK_RX
@ UWSMARTOFDM_STATE_RX_CTS
@ UWSMARTOFDM_STATE_BACKOFF
@ UWSMARTOFDM_STATE_NOT_SET
@ UWSMARTOFDM_STATE_TX_CTS
@ UWSMARTOFDM_STATE_TX_ACK
@ UWSMARTOFDM_STATE_RX_IDLE
@ UWSMARTOFDM_STATE_DATA_RX
@ UWSMARTOFDM_STATE_CHK_CTS_BACKOFF_TIMEOUT
@ UWSMARTOFDM_STATE_CHK_BACKOFF_TIMEOUT
@ UWSMARTOFDM_STATE_CHK_ACK_TIMEOUT
@ UWSMARTOFDM_STATE_WAIT_ACK
@ UWSMARTOFDM_STATE_RX_BACKOFF
@ UWSMARTOFDM_STATE_CTRL_BACKOFF
@ UWSMARTOFDM_STATE_TX_DATA
@ UWSMARTOFDM_STATE_TX_ACTIVE
@ UWSMARTOFDM_STATE_WRONG_PKT_RX
@ UWSMARTOFDM_STATE_WAIT_CTS
@ UWSMARTOFDM_STATE_RX_RTS
@ UWSMARTOFDM_STATE_TX_RTS
@ UWSMARTOFDM_STATE_RX_WAIT_ACK
@ UWSMARTOFDM_STATE_RX_ACTIVE
@ UWSMARTOFDM_STATE_WAIT_DATA
ofstream fout
An object of ofstream class.
int getPktSeqNum(Packet *p)
This method is used to get the sequence number from a packet.
virtual double getRTSsent()
This method is used to get the total number of sent RTS messages.
int rttsamples
Number of RTT samples.
virtual void updateAckTimeout(double rtt)
Like updateRTT() function.
double max_backoff_counter
Maximum number of backoff it will consider while it increases the backoff exponentially.
static map< UWSMARTOFDM_STATUS, string > status_info
Container which stores all the status information.
virtual void stateBackoff(double bt=0)
If ACK packet is not received within the acknowledgement expire time.
virtual void Phy2MacEndRx(Packet *p)
PHY layer informs the MAC layer that the reception of the packet is over.
double start_tx_time
Time when a packet start transmitting.
UWSMARTOFDM_STATUS curr_state
Enum variable.
virtual void Phy2MacStartRx(const Packet *p)
PHY layer informs the MAC layer that it is receiving a packet.
virtual void stateSendCTS(Packet *p)
Node is in sendRTS state.
virtual void initInfo()
This function is used to initialize the UWSmartOFDM protocol.
virtual void stateCheckCTSBackoffExpired()
It checks whether the CTS backoff timer is already expired while it was busy with other activities.
double sumrtt2
Sum of (RTT^2)
UWSMARTOFDM_STATUS prev_state
Enum variable.
virtual int getRemainingPkts()
Number of packets which MAC layer receives form upper layer(s) but were not transmitted.
std::vector< string > mac_carMod
int matchCarriers(int *myFree, int *otherFree, int *matching)
Returns free Carriers matching between itself and the sender to be used when an RTS is received to fi...
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
static bool initialized
It checks whether UWSmartOFDM protocol is initialized or not.
virtual void stateIdle()
Node is in Idle state.
BackOffTimer backoff_timer
An object of the backoff timer class.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual void Mac2PhyStartTx(Packet *p)
It informs that a packet transmission started.
void eraseItemFrommapAckTimer(int seq_num)
Erase an item from acknowledgement stored container.
virtual void refreshReason(UWSMARTOFDM_REASON_STATUS reason)
To know the reason why a node is in this current state.
static const double prop_speed
Speed of the sound signal.
map< pktSeqNum, Packet * > mapPacket
Container where Data packets are stored.
void resetAssignment()
resets value of car_assigned to FALSE
std::atomic< int > current_rcvs
double alpha_
This variable is used to tune the RTT.
int getHighPrioPktsRecv()
double ACK_timeout
ACK timeout for the initial packet.
double sumrtt
Sum of RTT samples.
int ACK_size
Size of the ACK, if the node uses ARQ technique.
virtual void updateLastDataIdRx(int id)
It updates the sequence number of the last data packet rx.
int buffer_pkts
Number of packets a node can store in the container.
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 initPkt(Packet *p, UWSMARTOFDM_PKT_TYPE pkt_type, int dest_addr=0)
This method, initialize the packet.
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 ...
UWSMARTOFDM_TIMER_STATUS
Enumeration class of UWSmartOFDM timer status.
UWSMARTOFDM_STATUS prev_prev_state
Enum variable.
int CTS_size
Size of the ACK, if the node uses SMARTOFDM.
virtual void stateRxCTS(Packet *p)
int DATA_size
Size of the DATA packet, if the node uses SMARTOFDM.
std::vector< char > mac_prioVec
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
UWSMARTOFDM_REASON_STATUS
Enumeration class which tells the nodes the reason why it is in this state.
@ UWSMARTOFDM_REASON_DATA_EMPTY
@ UWSMARTOFDM_REASON_ACK_RX
@ UWSMARTOFDM_REASON_ACK_TX
@ UWSMARTOFDM_REASON_START_RX
@ UWSMARTOFDM_REASON_RTS_RX
@ UWSMARTOFDM_REASON_ACK_TIMEOUT
@ UWSMARTOFDM_REASON_PKT_NOT_FOR_ME
@ UWSMARTOFDM_REASON_CTS_BACKOFF_TIMEOUT
@ UWSMARTOFDM_REASON_WAIT_DATA
@ UWSMARTOFDM_REASON_BACKOFF_TIMEOUT
@ UWSMARTOFDM_REASON_DATA_PENDING
@ UWSMARTOFDM_REASON_PHY_LAYER_SENDING
@ UWSMARTOFDM_REASON_MAX_RTS_TRIES
@ UWSMARTOFDM_REASON_DATAT_EXPIRED
@ UWSMARTOFDM_REASON_CTS_TX
@ UWSMARTOFDM_REASON_MAX_TX_TRIES
@ UWSMARTOFDM_REASON_BACKOFF_PENDING
@ UWSMARTOFDM_REASON_DATA_RX
@ UWSMARTOFDM_REASON_WAIT_CTS_PENDING
@ UWSMARTOFDM_REASON_PHY_LAYER_RECEIVING
@ UWSMARTOFDM_REASON_NOT_SET
@ UWSMARTOFDM_REASON_RTS_TX
@ UWSMARTOFDM_REASON_CTS_RX
@ UWSMARTOFDM_REASON_DATA_TX
@ UWSMARTOFDM_REASON_WAIT_ACK_PENDING
@ UWSMARTOFDM_REASON_PKT_ERROR
@ UWSMARTOFDM_REASON_PREVIOUS_RTS
@ UWSMARTOFDM_REASON_DATA_NOCAR
@ UWSMARTOFDM_REASON_DATA_CARASSIGNED
virtual void refreshState(UWSMARTOFDM_STATUS state)
Refreshes the states of the node.
map< pktSeqNum, AckTimer > mapAckTimer
Container where acknowledgement timer(s) is stored.
virtual void stateWaitAck()
After transmitting a Data packet, a node waits for the ACK packet.
std::vector< int > nouse_carriers
virtual void exitBackoff()
It stops the backoff timer.
int curr_tx_rounds
How many times a packet is transmitted.
virtual double getRTT()
This method is used to get the average RTT over all the receives RTT.
virtual void waitForUser()
virtual void stateCheckBackoffExpired()
It checks whether the backoff timer is already expired while it was busy with other activities.
double backoff_tuner
Tunes the backoff duration.
virtual void printStateInfo(double delay=0)
This methods print the state information of the nodes.
int pickFreeCarriers(int *freeC)
Returns max 5 carriers that are free in the next n time slots from occupancy table.
virtual void stateSendRTS()
Node is in sendRTS state.
virtual void stateRxIdle()
If a node start receiving a packet in Idle state.
static map< UWSMARTOFDM_PKT_TYPE, string > pkt_type_info
Container which stores all the packet type information of UWSmartOFDM.
UWSMARTOFDM_ACK_MODES ack_mode
Enum variable.
void Mac2PhySetTxBusy(int, int get=0)
RTSTimer RTS_timer
An object of the RTS timer class.
virtual void exitCTSBackoff()
It stops the CTS backoff timer.
UWSMARTOFDM_PKT_TYPE
Enumeration class of UWSmartOFDM packet type.
@ UWSMARTOFDM_DATAMAX_PKT
virtual void stateRxWaitAck()
If a node receives any packet while it was waiting for ACK packet, it moves to this state.
UWSMARTOFDM_REASON_STATUS last_reason
Enum variable which stores the last reason why a node changes its state.
int getUpLayersDataPktsRx()
int max_tx_tries
Maximum number of retransmissions attempt.
virtual void txRTS()
This methods transmits RTS packet from MAC layer to PHY layer.
Class that provide the implementation of an object to display messages.
std::pair< int, int > counter
counter of collisions
Common necessary fields for smart-ofdm.
Definition of UwOFDMPhy class. Your can find the brief description of this physical layer in the pape...
Common structures and variables in the protocol.