40#ifndef Uwpolling_HDR_SINK_H
41#define Uwpolling_HDR_SINK_H
55#define UWPOLLING_SINK_DROP_REASON_BUFFER_FULL \
57#define UWPOLLING_SINK_DROP_REASON_ERROR "DERR"
58#define UWPOLLING_SINK_DROP_REASON_UNKNOWN_TYPE \
60#define UWPOLLING_SINK_DROP_REASON_WRONG_RECEIVER \
62#define UWPOLLING_SINK_DROP_REASON_WRONG_STATE \
64#define UWPOLLING_SINK_DROP_REASON_PACKET_NOT_FOR_ME \
66#define UWPOLLING_SINK_DROP_REASON_IMINLIST_NOT_POLLED \
69#define UWPOLLING_SINK_DROP_REASON_NOT_POLLED \
96 virtual int command(
int argc,
const char *
const *argv);
359 virtual void expire(Event *e);
390 virtual void expire(Event *e);
597 virtual void txAck();
630 inline unsigned long int
633 unsigned long int timestamp =
634 (
unsigned long int) (std::chrono::duration_cast<std::chrono::milliseconds>(
635 std::chrono::system_clock::now().time_since_epoch()).count() );
701 static map<Uwpolling_SINK::UWPOLLING_SINK_STATUS, string>
703 static map<Uwpolling_SINK::UWPOLLING_SINK_REASON, string>
705 static map<Uwpolling_SINK::UWPOLLING_PKT_TYPE, string>
Class (inherited from Uwpolling_SINK_Timer) used to handle the time of backoff of the node before tra...
virtual ~BackOffTimer()
Destructor of DataTimer class.
BackOffTimer(Uwpolling_SINK *m)
Conscructor of ProbeTimer class.
virtual void expire(Event *e)
Method call when the timer expire.
Class (inherited from Uwpolling_SINK_Timer) used to handle the time in which the NODE wait for the DA...
virtual ~Rx_Data_Timer()
Destructor of ProbeTimer class.
virtual void expire(Event *e)
Method call when the timer expire.
Rx_Data_Timer(Uwpolling_SINK *m)
Conscructor of Rx_Data_Timer class.
Class that describes the timer in the SINK.
virtual ~Uwpolling_SINK_Timer()
Destructor of the Uwpolling_SINK_Timer class.
Uwpolling_SINK_Timer(Uwpolling_SINK *m)
Constructor of the Uwpolling_SINK_Timer class.
bool isFrozen()
Checks if the timer is FROZEN.
double start_time
Start Time of the timer.
bool isActive()
Checks if the timer is ACTIVE.
virtual void unFreeze()
unFreeze is used to resume the timer starting from the point where it was freezed
bool isRunning()
Checks if the timer is RUNNING.
double getDuration()
Returns the counter of the timer.
int getCounter()
Returns the counter of the timer.
void incrCounter()
Increments the counter of the timer.
int counter
counter of the timer
bool isExpired()
Checks if the timer is EXPIRED.
virtual void freeze()
Freeze the timer.
virtual void schedule(double val)
Schedules a timer.
void resetCounter()
Resets the counter of the timer.
double left_duration
Left duration of the timer.
Uwpolling_SINK *UWPOLLING_TIMER_STATUS timer_status
< Pointer to an object of type Uwpolling_SINK
bool isIdle()
Checks if the timer is IDLE.
virtual void stop()
stops the timer
Class used to represents the UWPOLLING MAC layer of a node.
int max_payload
Dimension of the DATA payload.
double BOffTime
Backoff time chosen.
static map< Uwpolling_SINK::UWPOLLING_PKT_TYPE, string > pkt_type_info
Textual info of the type of the packet.
Packet * curr_data_pkt
Pointer to the current DATA packet.
virtual void refreshReason(UWPOLLING_SINK_REASON reason)
Refresh the reason for the changing of the state.
uint n_curr_rx_pkts
Number of current received packets after the probe transmission.
virtual void stateWaitData()
State in which the protocol set up the timer to wait the reception of the DATA packet.
virtual void BackOffTimerExpired()
Method called by the Expire event of the timer.
virtual void stateRxData()
State in which the DATA packet is received.
UWPOLLING_SINK_STATUS prev_state
Previous state of the protocol.
unsigned long int getEpoch()
Calculate the epoch of the event.
virtual void refreshState(UWPOLLING_SINK_STATUS state)
Refresh the state of the protocol.
void incrTriggerReceived()
Increments the number of TRIGGER packets received.
void incrTriggerDropped()
Increments the number of TRIGGER packets dropped because of erroneous CRC.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
Packet * curr_trigger_pkt
Pointer to the current TRIGGER packet.
uint16_t expected_last_id
uint sink_id
Unique Node ID.
virtual void incrAckSent()
Increment the number of sent PROBE packets.
static bool initialized
true if the protocol is initialized, false otherwise
virtual double getBackOffTime()
The backoff timer is calculated choosing randomly using a Uniform random variable and multiplying it ...
bool first_rx_pkt
Number ot duplicated packets received.
int print_stats
Print protocol's statistics of the protocol.
int AUV_mac_addr
MAC address of the AUV from which it receives data.
int ack_enabled
True if ack is enabled, false if disabled, default true.
double T_guard
Guard time added to the calculation of the data TO.
virtual void initInfo()
Initializes the protocol at the beginning of the simulation.
double T_data_gurad
Guard time for RxDataTimer.
std::ofstream fout
Output stream for the textual file of debug.
virtual void stateIdle()
IDLE state.
virtual void txAck()
The ACK Packet is sent down to the PHY layer.
UWPOLLING_SINK_STATUS
< Variable that rapresents the status of the protocol machine state
@ UWPOLLING_SINK_STATUS_WAIT_DATA
@ UWPOLLING_SINK_STATUS_RX_DATA
@ UWPOLLING_SINK_STATUS_TX_ACK
@ UWPOLLING_SINK_STATUS_TX_PROBE
@ UWPOLLING_SINK_STATUS_RX_TRIGGER
@ UWPOLLING_SINK_STATUS_IDLE
virtual void incrProbeSent()
Increment the number of sent PROBE packets.
Packet * curr_ack_pkt
Pointer to the current ACK packet.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
Rx_Data_Timer rx_data_timer
Receiving DATA Timer.
virtual void stateTxAck()
State in which the ACK is sent.
static map< Uwpolling_SINK::UWPOLLING_SINK_STATUS, string > status_info
Textual info of the state.
virtual void stateRxTrigger()
State of the protocol in which a TRIGGER packet is received.
std::list< uint16_t > missing_id_list
List with missing packet ID.
uint max_n_ack
Max number of ACK that can be sent in a single round.
double T_in
True if rx trigger is enabled.
@ UWPOLLING_SINK_REASON_RX_TRIGGER
@ UWPOLLING_SINK_REASON_BACKOFF_TIMER_EXPIRED
@ UWPOLLING_SINK_REASON_TX_PROBE
@ UWPOLLING_SINK_REASON_WRONG_TYPE
@ UWPOLLING_SINK_REASON_PKT_ERROR
@ UWPOLLING_SINK_REASON_NOT_SET
@ UWPOLLING_SINK_REASON_TX_ACK
@ UWPOLLING_SINK_REASON_WRONG_STATE
@ UWPOLLING_SINK_REASON_WRONG_RECEIVER
@ UWPOLLING_SINK_REASON_RX_DATA_TIMER_EXPIRED
@ UWPOLLING_SINK_REASON_MAX_DATA_RECEIVED
@ UWPOLLING_SINK_REASON_RX_DATA
int getProbeSent()
Returns the number of PROBE packets sent during the simulation.
Packet * curr_probe_pkt
Pointer to the current PROBE packet.
int getTriggerReceived()
Return the number of TRIGGER packets received by the NODE.
std::ofstream out_file_stats
virtual void waitForUser()
Used for debug purposes.
bool RxDataEnabled
true if the node is enabled to receive the DATA, false otherwise
uint PROBE_uid
True if the packet received is the first packet in the round.
UWPOLLING_SINK_REASON last_reason
Last reason to the change of state.
int useAdaptiveTdata
True if an adaptive T_poll is used.
virtual void addMissPkt2List(uint16_t n_pkts)
Add packet uids in the missing packet list.
UWPOLLING_SINK_STATUS curr_state
Current state of the protocol.
uint16_t prev_expect_last_id
Expected Unique ID of the last packet in the round.
int n_trigger_received
Number of TRIGGER packets received.
virtual void RxDataTimerExpired()
Methods called by the Expire event of the timer.
double backoff_tuner
Multiplying value to the backoff value.
uint16_t last_rx
ID of the last received packet.
uint16_t expected_id
Expected ID of the next data packet received.
static map< Uwpolling_SINK::UWPOLLING_SINK_REASON, string > reason_info
Textual info of the reason.
virtual void TxProbe()
The PROBE Packet is sended down to the PHY layer.
int modem_data_bit_rate
Bit rate of the modem used.
virtual void stateTxProbe()
State of the protocol in which a PROBE packet is sent.
int getAckSent()
Returns the number of ACK packets sent during the simulation.
double T_data
Duration of RxDataTimer.
virtual ~Uwpolling_SINK()
Destructor of the Uwpolling_SINK class.
BackOffTimer backoff_timer
Backoff timer.
int n_trigger_dropped
Number of TRIGGER packet dropped.
Uwpolling_SINK()
Constructor of the Uwpolling_SINK class.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
int sea_trial
Sea Trial flag: To activate if the protocol is going to be tested at the sea.
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 ...
int n_probe_sent
Number of PROBE packets sent to the AUV.
double T_fin
Upper bound of the range in which choose randomly the backoff time (sent by the AUV in the TRIGGER me...
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
int getTriggerDropped()
Return the number of TRIGGER dropped by the node because of erroneous CRC.
bool send_ACK
True if an ACK has to be sent, false otherwise.
bool Triggered
true if the node has correctly received a TRIGGER, false otherwise
std::pair< int, int > counter
counter of collisions
Common structures and variables in the protocol.