39#ifndef UW_CS_ALOHA_TRIG_NODE_H
40#define UW_CS_ALOHA_TRIG_NODE_H
56#define UW_CS_ALOHA_TRIG_NODE_DROP_REASON_BUFFER_FULL \
58#define UW_CS_ALOHA_TRIG_NODE_DROP_REASON_ERROR "ERR"
86 virtual int command(
int argc,
const char *
const *argv);
350 virtual void expire(Event *e);
381 virtual void expire(Event *e);
419 virtual void initPkt(Packet *p);
515 Packet::free(
Q.front());
537 return (up_data_pkts_rx -
Q.size());
564 std::queue<Packet *>
Q;
584 static map<UW_CS_ALOHA_TRIG_NODE_STATUS, string>
586 static map<UW_CS_ALOHA_TRIG_NODE_REASON_STATUS, string>
Class that describes the timers in the node.
Csma_Aloha_Triggered_Timer(UwCsmaAloha_Trigger_NODE *m)
Constructor of the AlohaTimer class.
double start_time
Start time of the timer.
int counter
counter of the timer
virtual void schedule(double val)
schedule a timer
bool isActive()
Checks if the timer is ACTIVE.
virtual ~Csma_Aloha_Triggered_Timer()
Destructor of the AlohaTimer class.
UwCsmaAloha_Trigger_NODE *UW_CS_ALOHA_TRIG_NODE_TIMER_STATUS timer_status
< Pointer of an object of type UwCsmaAloha_Triggered
void incrCounter()
Increments the counter of the timer.
void resetCounter()
Resets the counter of the timer.
bool isExpired()
Checks if the timer is EXPIRED.
bool isIdle()
checks if the timer is IDLE
virtual void unFreeze()
unFreezes is used to resume the timer starting from the point where it was freezed
int getCounter()
Returns the counter of the timer.
virtual void freeze()
Freezes the timer.
double left_duration
Left duration of the timer.
bool isFrozen()
Checks if the timer is FROZEN.
bool isRunning()
checks if the timer is RUNNING
double getDuration()
Returns the left duration of the timer.
virtual void stop()
stops the timer
Class used to handle the timer to handle the listen time.
ListenTimer(UwCsmaAloha_Trigger_NODE *m)
Constructor of ListenTimer class.
virtual void expire(Event *e)
Method called when the timer expire.
virtual ~ListenTimer()
Destructor of the class ListenTimer.
Class used to handle the time in which the node is allowed to transmit to the sink.
virtual void expire(Event *e)
Method called when the timer expire.
virtual ~TransmissionTimer()
Destructor of the class TransmissionTimer.
TransmissionTimer(UwCsmaAloha_Trigger_NODE *m)
Constructor of the TransmissionTimer class.
Class that describes a CsmaAloha_TRIGGERED module of the node.
UW_CS_ALOHA_TRIG_NODE_TIMER_STATUS
@ UW_CS_ALOHA_TRIG_NODE_RUNNING
@ UW_CS_ALOHA_TRIG_NODE_IDLE
@ UW_CS_ALOHA_TRIG_NODE_FROZEN
@ UW_CS_ALOHA_TRIG_NODE_EXPIRED
static bool initialized
true if the protocol is initialized
virtual void updateLastDataIdRx(int id)
Updates the ID of the last DATA packet received.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
double wait_costant
Adding factor in the calculation of the listen time.
static const double prop_speed
Typical sound propagation speed in underwater enviroment.
UW_CS_ALOHA_TRIG_NODE_STATUS prev_state
Previous state of the protocol.
virtual void stateRxData(Packet *p)
State in which a DATA packet is received.
virtual void refreshState(UW_CS_ALOHA_TRIG_NODE_STATUS state)
Refresh the State of the protocol.
UW_CS_ALOHA_TRIG_NODE_REASON_STATUS last_reason
Reason for the state transitions.
double listen_time
Time in which the node sense the channel.
virtual void waitForUser()
Used for debug purposes.
bool has_buffer_queue
flag that indicates if a node has a buffer where store DATA packets
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
UW_CS_ALOHA_TRIG_NODE_STATUS prev_prev_state
Previous previous state of the protocol.
UwCsmaAloha_Trigger_NODE()
Constructor of the UwCsmaAloha_Trigger_NODE class.
virtual void stateRxIdle()
A reception is occuring while the protocol is in IDLE state.
int buffer_pkts
Length of the data buffer in number of packets.
std::queue< int > data_sn_queue
Queue of the sequence number of the packets.
static map< UW_CS_ALOHA_TRIG_NODE_STATUS, string > status_info
Textual description of the protocol states.
int tx_timer_duration
Duration of the time in which the node is allowed to transmit.
virtual void stateRxListen()
State in which a reception is occuring while the node is listening the channel.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
virtual void stateTxData()
State in which the protocol allows the node to transmit a data packet.
int u_data_id
DATA packete ID.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
int HDR_size
Size (in bytes) of the header added by the protocol.
ofstream fout
Object that handles the output file where the protocol writes the state transistions.
virtual int getRemainingPkts()
Return the number of packets not transmitted (remained in the protocol queue) at the end of the simul...
virtual ~UwCsmaAloha_Trigger_NODE()
Destructor of the UwCsmaAloha_Trigger_NODE class.
virtual void txData()
Transmits the DATA packet (calling Mac2PhyStartTx) and increment the counter of transmitted data pack...
virtual void stateIdle()
IDLE state.
static map< UW_CS_ALOHA_TRIG_NODE_REASON_STATUS, string > reason_info
Textual description of the protocol reason for the change of the state.
TransmissionTimer tx_timer
int max_payload
Maximum dimension of the data payload in bytes.
static int u_pkt_id
simulation-unique packet ID
std::queue< Packet * > Q
Packet queue.
UW_CS_ALOHA_TRIG_NODE_REASON_STATUS
@ UW_CS_ALOHA_TRIG_NODE_REASON_DATA_RX
@ UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_AFTER_TRIGGER
@ UW_CS_ALOHA_TRIG_NODE_REASON_DATA_TX
@ UW_CS_ALOHA_TRIG_NODE_REASON_PKT_ERROR
@ UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_TIMEOUT
@ UW_CS_ALOHA_TRIG_NODE_REASON_NOT_SET
@ UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN_PENDING
@ UW_CS_ALOHA_TRIG_NODE_REASON_LISTEN
@ UW_CS_ALOHA_TRIG_NODE_REASON_PKT_NOT_FOR_ME
@ UW_CS_ALOHA_TRIG_NODE_REASON_DATA_EMPTY
@ UW_CS_ALOHA_TRIG_NODE_REASON_START_RX
@ UW_CS_ALOHA_TRIG_NODE_REASON_TRIGGER_RX
@ UW_CS_ALOHA_TRIG_NODE_REASON_DATA_PENDING
int last_sent_data_id
ID of the last sent packet.
Packet * curr_data_pkt
Pointer to the current data packet.
virtual void stateRxTrigger(Packet *p)
State of the protocol in which a TRIGGER packet is received.
virtual void recvFromUpperLayers(Packet *p)
Receives the packet from the upper layer (e.g.
UW_CS_ALOHA_TRIG_NODE_STATUS curr_state
Current state of the protocol.
virtual void incrUpperDataRx()
Increase the number of Data packet Received from the Upper layers.
virtual void initInfo()
Initializes the protocol at the beginning of the simulation.
virtual void stateCheckListenExpired()
Checks if the Listen period is expired.
bool can_transmit
Flag that indicates if the node can transmit data packets to the sink.
virtual void stateCheckTxTimerExpired()
Checks if the Time period is expired.
virtual void stateListen()
State in which the node is listening the channel.
virtual void initPkt(Packet *p)
Init the packet with the MAC address of the receiver and the sender, the size of the packet and the t...
UW_CS_ALOHA_TRIG_NODE_STATUS
@ UW_CS_ALOHA_TRIG_NODE_STATE_RX_IDLE
@ UW_CS_ALOHA_TRIG_NODE_STATE_RX_TRIGGER
@ UW_CS_ALOHA_TRIG_NODE_STATE_IDLE
@ UW_CS_ALOHA_TRIG_NODE_STATE_CHK_LISTEN_TIMEOUT
@ UW_CS_ALOHA_TRIG_NODE_STATE_TX_DATA
@ UW_CS_ALOHA_TRIG_NODE_STATE_NOT_SET
@ UW_CS_ALOHA_TRIG_NODE_STATE_DATA_RX
@ UW_CS_ALOHA_TRIG_NODE_STATE_RX_LISTEN
@ UW_CS_ALOHA_TRIG_NODE_STATE_WRONG_PKT_RX
@ UW_CS_ALOHA_TRIG_NODE_STATE_LISTEN
virtual void stateRxPacketNotForMe(Packet *p)
state in which a wrong Packet is received
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void queuePop(bool flag=true)
Pop the first element of the data packet queue.
int last_data_id_rx
ID of the last DATA packet received.
virtual void refreshReason(UW_CS_ALOHA_TRIG_NODE_REASON_STATUS reason)
Refresh the reason for the change of state.
std::pair< int, int > counter
counter of collisions