40#ifndef Uwpolling_HDR_NODE_H
41#define Uwpolling_HDR_NODE_H
54#define UWPOLLING_NODE_DROP_REASON_BUFFER_FULL \
56#define UWPOLLING_NODE_DROP_REASON_ERROR "DERR"
57#define UWPOLLING_NODE_DROP_REASON_UNKNOWN_TYPE \
59#define UWPOLLING_NODE_DROP_REASON_WRONG_RECEIVER \
61#define UWPOLLING_NODE_DROP_REASON_WRONG_STATE \
63#define UWPOLLING_NODE_DROP_REASON_PACKET_NOT_FOR_ME \
65#define UWPOLLING_NODE_DROP_REASON_IMINLIST_NOT_POLLED \
68#define UWPOLLING_NODE_DROP_REASON_NOT_POLLED \
95 virtual int command(
int argc,
const char *
const *argv);
359 virtual void expire(Event *e);
390 virtual void expire(Event *e);
424 virtual void expire(Event *e);
543 std::cout <<
getEpoch() <<
"::" << NOW
544 <<
"::Uwpolling_NODE(" << addr
545 <<
")::DATA_QUEUE_SIZE--> " <<
Q_data.size()
674 inline unsigned long int
677 unsigned long int timestamp =
678 (
unsigned long int) (std::chrono::duration_cast<std::chrono::milliseconds>(
679 std::chrono::system_clock::now().time_since_epoch()).count() );
748 static map<Uwpolling_NODE::UWPOLLING_NODE_STATUS, string>
750 static map<Uwpolling_NODE::UWPOLLING_NODE_REASON, string>
752 static map<Uwpolling_NODE::UWPOLLING_PKT_TYPE, string>
Class (inherited from Uwpolling_NODE_Timer) used to handle the time of backoff of the node before tra...
BackOffTimer(Uwpolling_NODE *m)
Conscructor of ProbeTimer class.
virtual void expire(Event *e)
Method call when the timer expire.
virtual ~BackOffTimer()
Destructor of DataTimer class.
Class (inherited from Uwpolling_NODE_Timer) used to handle the time in which the NODE wait for the PO...
virtual void expire(Event *e)
Method call when the timer expire.
Rx_Poll_Timer(Uwpolling_NODE *m)
Conscructor of Rx_Poll_Timer class.
virtual ~Rx_Poll_Timer()
Destructor of ProbeTimer class.
Class (inherited from Uwpolling_NODE_Timer) used to handle the time between the transmission of the D...
virtual void expire(Event *e)
Method call when the timer expire.
Tx_Data_Timer(Uwpolling_NODE *m)
Conscructor of Tx_Data_Timer class.
virtual ~Tx_Data_Timer()
Destructor of Tx_Data_Timer class.
Class that describes the timer in the AUV.
bool isRunning()
Checks if the timer is RUNNING.
Uwpolling_NODE *UWPOLLING_TIMER_STATUS timer_status
< Pointer to an object of type Uwpolling_AUV
virtual void freeze()
Freeze the timer.
int getCounter()
Returns the counter of the timer.
Uwpolling_NODE_Timer(Uwpolling_NODE *m)
Constructor of the Uwpolling_NODE_Timer class.
virtual void stop()
stops the timer
double start_time
Start Time of the timer.
virtual void schedule(double val)
Schedules a timer.
virtual void unFreeze()
unFreeze is used to resume the timer starting from the point where it was freezed
bool isExpired()
Checks if the timer is EXPIRED.
int counter
counter of the timer
bool isFrozen()
Checks if the timer is FROZEN.
bool isActive()
Checks if the timer is ACTIVE.
void resetCounter()
Resets the counter of the timer.
double left_duration
Left duration of the timer.
double getDuration()
Returns the counter of the timer.
bool isIdle()
Checks if the timer is IDLE.
virtual ~Uwpolling_NODE_Timer()
Destructor of the Uwpolling_NODE_Timer class.
void incrCounter()
Increments the counter of the timer.
Class used to represents the UWPOLLING MAC layer of a node.
virtual void stateTxData()
State of the protocol in which a DATA packet is sent.
virtual void incrProbeSent()
Increment the number of sent PROBE packets.
double T_fin
Upper bound of the range in which choose randomly the backoff time (sent by the AUV in the TRIGGER me...
Tx_Data_Timer tx_data_timer
Timer between two consequent DATA packet transmission.
int max_data_pkt_tx
Max number of DATA packets to transmit each cycle.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
Packet * curr_poll_pkt
Pointer ot the current POLL packet.
UWPOLLING_NODE_REASON last_reason
Last reason to the change of state.
int getTimesPolled()
Return the number of times the node are polled by the AUV.
uint N_polled_node
Number of node polled in this POLL message.
bool LastPacket
true if the node has just sent the last packet of the queue and has to exit from the TxData state,...
uint node_id
Unique Node ID.
int n_times_polled
Number of times that the node has been polled by the AUV.
virtual void stateRxTrigger()
State of the protocol in which a TRIGGER packet is received.
virtual void stateRxPoll()
State of the protocol in which a POLL packet is received.
double BOffTime
Backoff time chosen.
bool polled
true if the node is polled, false otherwise
static map< Uwpolling_NODE::UWPOLLING_NODE_REASON, string > reason_info
Textual info of the reason.
double T_poll_guard
Guard time for initial POLL timer.
BackOffTimer backoff_timer
Backoff timer.
UWPOLLING_NODE_STATUS curr_state
Current state of the protocol.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
virtual void stateTxProbe()
State of the protocol in which a PROBE packet is sent.
virtual void initInfo()
Initializes the protocol at the beginning of the simulation.
bool Triggered
true if the node has correctly received a TRIGGER, false otherwise
std::ofstream fout
Output stream for the textual file of debug.
int max_payload
Payload of Application Layer in bytes.
int getProbeSent()
Returns the number of PROBE packets sent during the simulation.
void incrTriggerReceived()
Increments the number of TRIGGER packets received.
int buffer_data_pkts
Length of buffer of DATA pkts in number of pkts.
unsigned long int getEpoch()
Calculate the epoch of the event.
virtual void incrTimesPolled()
Increments the number of times that the node has been polled by the AUV.
virtual void refreshReason(UWPOLLING_NODE_REASON reason)
Refresh the reason for the changing of the state.
Packet * curr_probe_pkt
Pointer to the current PROBE packet.
static map< Uwpolling_NODE::UWPOLLING_NODE_STATUS, string > status_info
Textual info of the state.
int getPollDropped()
Return the number of POLL dropped by the node because of erroneous CRC.
Rx_Poll_Timer rx_poll_timer
Receiving POLL Timer.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
double T_poll
Duration of RxPOLLTimer.
double backoff_tuner
Multiplying value to the backoff value.
virtual void refreshState(UWPOLLING_NODE_STATUS state)
Refresh the state of the protocol.
Uwpolling_NODE()
Constructor of the Uwpolling_NODE class.
virtual void waitForUser()
Used for debug purposes.
uint PROBE_uid
PROBE Unique ID.
int getTriggerReceived()
Return the number of TRIGGER packets received by the NODE.
std::queue< Packet * > Q_data
Queue of DATA in number of packets.
int n_trigger_received
Number of TRIGGER packets received.
virtual void recvFromUpperLayers(Packet *p)
Receives the packet from the upper layer (e.g.
virtual void RxPollTimerExpired()
Methods called by the Expire event of the timer.
int packet_index
Index of the packet just sent to the AUV.
static bool initialized
true if the protocol is initialized, false otherwise
UWPOLLING_NODE_STATUS
< Variable that rapresents the status of the protocol machine state
@ UWPOLLING_NODE_STATUS_IDLE
@ UWPOLLING_NODE_STATUS_RX_POLL
@ UWPOLLING_NODE_STATUS_WAIT_POLL
@ UWPOLLING_NODE_STATUS_RX_TRIGGER
@ UWPOLLING_NODE_STATUS_TX_DATA
@ UWPOLLING_NODE_STATUS_TX_PROBE
int n_trigger_dropped
Number of TRIGGER packet dropped.
virtual void BackOffTimerExpired()
Method called by the Expire event of the timer.
virtual void TxPRobe()
The PROBE Packet is sended down to the PHY layer.
int AUV_mac_addr
MAC address of the AUV.
Packet * curr_data_pkt
Pointer to the current DATA packet.
virtual void initPkt(UWPOLLING_PKT_TYPE pkt_type)
Inits the packet with the MAC address of the receiver and the sender, the size of the packet and the ...
virtual void TxData()
The DATA Packet is sended down to the PHY layer.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
double T_in
Lower bound of the range in which choose randomly the backoff time (sent by the AUV in the TRIGGER me...
UWPOLLING_NODE_STATUS prev_state
Previous state of the protocol.
int getTriggerDropped()
Return the number of TRIGGER dropped by the node because of erroneous CRC.
int sea_trial
Sea Trial flag: To activate if the protocol is going to be tested at the sea.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
double MaxTimeStamp
Timestamp of the most recent data packet generated.
@ UWPOLLING_NODE_REASON_TX_DATA
@ UWPOLLING_NODE_REASON_NOT_IN_LIST
@ UWPOLLING_NODE_REASON_WRONG_TYPE
@ UWPOLLING_NODE_REASON_LIST_NOT_POLLED
@ UWPOLLING_NODE_REASON_BACKOFF_TIMER_EXPIRED
@ UWPOLLING_NODE_REASON_RX_TRIGGER
@ UWPOLLING_NODE_REASON_NOT_SET
@ UWPOLLING_NODE_REASON_RX_POLL
@ UWPOLLING_NODE_REASON_RX_POLL_TIMER_EXPIRED
@ UWPOLLING_NODE_REASON_PKT_ERROR
@ UWPOLLING_NODE_REASON_WRONG_RECEIVER
@ UWPOLLING_NODE_REASON_TX_PROBE
@ UWPOLLING_NODE_REASON_WRONG_STATE
@ UWPOLLING_NODE_REASON_EMPTY_DATA_QUEUE
virtual void stateWaitPoll()
State in which the protocol set up the timer to wait the reception of the POLL packet.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
int n_poll_dropped
Number of POLL packet dropped.
int useAdaptiveTpoll
True if an adaptive T_poll is used.
void incrPollDropped()
Increments the number of POLL packets dropped because of erroneous CRC.
int N_data_pkt_2_TX
Number of DATA packets to transmit to the AUV.
int print_stats
Print protocol's statistics of the protocol.
virtual void stateIdle()
IDLE state.
Packet * curr_trigger_pkt
Pointer to the current TRIGGER packet.
void incrTriggerDropped()
Increments the number of TRIGGER packets dropped because of erroneous CRC.
bool RxPollEnabled
true if the node is enabled to receive the POLL, false otherwise
virtual double getBackOffTime()
The backoff timer is calculated choosing randomly using a Uniform random variable and multiplying it ...
uint n_probe_sent
Number of PROBE packets sent to the AUV.
static map< Uwpolling_NODE::UWPOLLING_PKT_TYPE, string > pkt_type_info
Textual info of the type of the packet.
double Intra_data_Guard_Time
Guard Time between one data packet and the following.
std::ofstream out_file_stats
virtual ~Uwpolling_NODE()
Destructor of the Uwpolling_NODE class.
std::pair< int, int > counter
counter of collisions
Common structures and variables in the protocol.