39#ifndef UW_CSMA_UW_CS_ALOHA_TRIG_SINK_TRIGGER_SINK_H
40#define UW_CSMA_UW_CS_ALOHA_TRIG_SINK_TRIGGER_SINK_H
48#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_WRONG_RECEIVER \
50#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_UNKNOWN_TYPE \
52#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_ERROR "ERR"
53#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_RECEIVING_NOT_ENABLED \
82 virtual int command(
int argc,
const char *
const *argv);
330 virtual void expire(Event *e);
363 virtual void initPkt(Packet *p,
int dest_addr = 0);
Class that describes the timers in the node.
UwCsmaAloha_Trigger_SINK *UW_CS_ALOHA_TRIG_SINK_TIMER_STATUS timer_status
< Pointer to an object of type CsmaAloha
virtual void freeze()
Freezes the timer.
virtual void stop()
stops the timer
bool isRunning()
checks if the timer is RUNNING
double getDuration()
Returns the left duration of the timer.
bool isExpired()
Checks if the timer is EXPIRED.
virtual ~GenericTimer()
Destructor of the GenericTimer class.
void incrCounter()
Increments the counter of the timer.
double left_duration
Left duration of the timer.
int counter
counter of the timer
virtual void schedule(double val)
schedule a timer
bool isIdle()
checks if the timer is IDLE
double start_time
Start Time of the timer.
bool isActive()
Checks if the timer is ACTIVE.
void resetCounter()
Resets the counter of the timer.
bool isFrozen()
Checks if the timer is FROZEN.
GenericTimer(UwCsmaAloha_Trigger_SINK *m)
Constructor of the GenericTimer class.
int getCounter()
Returns the counter of the timer.
virtual void unFreeze()
unFreezes is used to resume the timer starting from the point where it was freezed
Class used to handle the timer of the reception period.
virtual void expire(Event *e)
Method called when the timer expire.
ReceiveTimer(UwCsmaAloha_Trigger_SINK *m)
Conscructor of ReceiveTimer class.
virtual ~ReceiveTimer()
Descructor of ReceiveTimer class.
Class that describes a UwCsmaAloha_Trigger_SINK module.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layers finishes to transmit packet.
UW_CS_ALOHA_TRIG_SINK_STATUS curr_state
Current state of the protocol.
void refreshReason(UW_CS_ALOHA_TRIG_SINK_REASON_STATUS reason)
Refresh the reason for the change of state.
virtual void recvFromUpperLayers(Packet *p)
Receives the packet from the upper layer (e.g.
int TRIGGER_size
Size of the TRIGGER packet.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the PHY layer begins to receive a packet.
bool receiving_state_active
True if the sink is allowed to receive data packet.
UW_CS_ALOHA_TRIG_SINK_REASON_STATUS
@ UW_CS_ALOHA_TRIG_SINK_REASON_PKT_NOT_FOR_ME
@ UW_CS_ALOHA_TRIG_SINK_REASON_TX_TRIGGER
@ UW_CS_ALOHA_TRIG_SINK_REASON_DATA_RX
@ UW_CS_ALOHA_TRIG_SINK_REASON_START_RX
@ UW_CS_ALOHA_TRIG_SINK_REASON_PKT_ERROR
@ UW_CS_ALOHA_TRIG_SINK_REASON_NOT_SET
int buffer_pkts
Length of data packet queue.
void incrTRIGGERPacketTx()
Increment the number of TRIGGER packets transmitted.
int getTriggerMsgSent()
Return the number of TRIGGER packets sent over the simulation.
ReceiveTimer receive_timer
timer of receive state
double tx_timer_duration
Duration of the timer in which one node is allowed to transmit.
UW_CS_ALOHA_TRIG_SINK_STATUS
< Variable that rapresent the status of the protocol machine state
@ UW_CS_ALOHA_TRIG_SINK_STATE_DISABLE_RX
@ UW_CS_ALOHA_TRIG_SINK_STATE_ENABLE_RX
@ UW_CS_ALOHA_TRIG_SINK_STATE_TX_TRIGGER
@ UW_CS_ALOHA_TRIG_SINK_STATE_IDLE
@ UW_CS_ALOHA_TRIG_SINK_STATE_NOT_SET
@ UW_CS_ALOHA_TRIG_SINK_STATE_DATA_RX
virtual void stateRxData(Packet *p)
The sink receives a DATA packet from a node.
virtual void initPkt(Packet *p, int dest_addr=0)
Init the headers of the packet in transmission.
virtual void stateRxPacketNotForMe(Packet *p)
The destination address of the packet is not equal to the sink's address.
virtual void txTRIGGER(Packet *p)
Transmit the TRIGGER packet.
UW_CS_ALOHA_TRIG_SINK_TIMER_STATUS
@ UW_CS_ALOHA_TRIG_SINK_RUNNING
@ UW_CS_ALOHA_TRIG_SINK_IDLE
@ UW_CS_ALOHA_TRIG_SINK_FROZEN
@ UW_CS_ALOHA_TRIG_SINK_EXPIRED
virtual void waitForUser()
Used for debug purposes.
virtual void stateTxTRIGGER()
The sink transmit the TRIGGER packet to begin the neighbour discovery phase.
virtual void stateIdle()
State IDLE of the protocol.
int trigger_pkts_tx
Number of TRIGGER packet received.
UW_CS_ALOHA_TRIG_SINK_REASON_STATUS last_reason
Last reason of the state change of the protocol.
virtual ~UwCsmaAloha_Trigger_SINK()
Destructor of the UwCsmaAloha_Trigger_SINK class.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
void refreshState(UW_CS_ALOHA_TRIG_SINK_STATUS state)
Refresh the state of the protocol.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void stateDisableRx()
The sink is not allowed to receive the packet from a certain node anymore.
virtual void Phy2MacEndRx(Packet *p)
Method called when the PHY layer finishes to receive a packet.
virtual void incrUpperDataRx()
Increment the number of Data received from upper layers.
virtual void stateEnableRx()
State in which the sink is enabled to receive packets.
UwCsmaAloha_Trigger_SINK()
Constructor of the UwCsmaAloha_Trigger_SINK class.
UW_CS_ALOHA_TRIG_SINK_STATUS prev_state
Previous state of the protocol.
std::pair< int, int > counter
counter of collisions