38#ifndef UWPOLLING_HDR_AUV_H
39#define UWPOLLING_HDR_AUV_H
56#define UWPOLLING_AUV_DROP_REASON_ERROR "DERR"
57#define UWPOLLING_AUV_DROP_REASON_UNKNOWN_TYPE \
59#define UWPOLLING_AUV_DROP_REASON_WRONG_RECEIVER \
61#define UWPOLLING_AUV_DROP_REASON_WRONG_STATE \
63#define UWPOLLING_AUV_DROP_REASON_BUFFER_FULL "ADBF"
65#define ENTRY_MAX_SIZE 256
203 virtual int command(
int argc,
const char *
const *argv);
473 virtual void expire(Event *e);
506 virtual void expire(Event *e);
533 virtual void expire(Event *e);
560 virtual void expire(Event *e);
580 double x,
double x1,
double x2,
double y1,
double y2);
914 inline unsigned long int
917 unsigned long int timestamp =
918 (
unsigned long int) (std::chrono::duration_cast<std::chrono::milliseconds>(
919 std::chrono::system_clock::now().time_since_epoch()).count() );
1060 map<UWPOLLING_PKT_TYPE, std::string>
1064 map<UWPOLLING_AUV_STATUS, std::string>
1068 map<UWPOLLING_AUV_REASON, std::string>
virtual void expire(Event *e)
Method call when the timer expire.
AckTimer(Uwpolling_AUV *m)
Conscructor of AckTimer class.
virtual ~AckTimer()
Destructor of AckTimer class.
Class (inherited from Uwpolling_AUV_Timer) used to handle the timer of data packets When the AUV give...
virtual void expire(Event *e)
Method called when the timer expire.
DataTimer(Uwpolling_AUV *m)
Conscructor of DataTimer class.
virtual ~DataTimer()
Destructor of DataTimer class.
PollTimer(Uwpolling_AUV *m)
Conscructor of ProbeTimer class.
virtual ~PollTimer()
Destructor of ProbeTimer class.
virtual void expire(Event *e)
Method call when the timer expire.
Class (inherited from Uwpolling_AUV_Timer) used to handle the Probe Timer.
ProbeTimer(Uwpolling_AUV *m)
Conscructor of ProbeTimer class.
virtual void expire(Event *e)
Method call when the timer expire.
virtual ~ProbeTimer()
Destructor of ProbeTimer class.
Class that describes the timer in the AUV.
virtual ~Uwpolling_AUV_Timer()
Destructor of the Uwpolling_AUV_Timer class.
Uwpolling_AUV_Timer(Uwpolling_AUV *m)
Constructor of the Uwpolling_AUV_Timer class.
virtual void freeze()
Freeze the timer.
Uwpolling_AUV *UWPOLLING_TIMER_STATUS timer_status
< Pointer to an object of type Uwpolling_AUV
bool isExpired()
Checks if the timer is EXPIRED.
int counter
counter of the timer
bool isActive()
Checks if the timer is ACTIVE.
void resetCounter()
Resets the counter of the timer.
virtual void schedule(double val)
Schedules a timer.
int getCounter()
Returns the counter of the timer.
double getDuration()
Returns the left duration of the timer.
virtual void stop()
stops the timer
bool isRunning()
Checks if the timer is RUNNING.
double start_time
Start Time of the timer.
bool isIdle()
Checks if the timer is IDLE.
bool isFrozen()
Checks if the timer is FROZEN.
double left_duration
Left duration of the timer.
virtual void unFreeze()
unFreeze is used to resume the timer starting from the point where it was freezed
void incrCounter()
Increments the counter of the timer.
Class used to represent the UWPOLLING MAC layer of the AUV.
std::deque< Packet * > tx_buffer
Queue of DATA in number of packets.
virtual void initInfo()
Prints a file with every state change for debug purposes.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
PollTimer poll_timer
POLL Timer.
virtual void refreshState(UWPOLLING_AUV_STATUS state)
Refresh the state of the protocol.
Packet * curr_data_packet
Pointer to the current DATA packet.
int n_dropped_ack_pkts
Number of ACK dropped pkts.
virtual void ChangeNodePolled()
The first element of the list of nodes is trimmed and the next node is polled.
Packet * curr_tx_data_packet
Pointer to the current DATA packet.
Packet * curr_probe_packet
Pointer to the current PROBE packet.
probbed_node probbed_sink
Element with sink probe data.
void incrPollTx()
Incrase the number of POLL transmitted.
virtual uint16_t getPollTime()
Estimate the time needed by the AUV to POLL all the remaining node in the probbed node list.
int N_dropped_probe_pkts
Number of PROBE dropped because of CRC error.
int full_knowledge
Set to a number != 0 means we have full_knowledge about the estimate of neighbors.
void incrTriggerTx()
Increases the number of TRIGGER packets sent.
std::vector< probbed_node > list_probbed_node
list of nodes that have sent correctly the PROBE
virtual void handleNoAck()
Handle case with no ack received.
double Ttrigger
Time needed to transmit a TRIGGER packet.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
int modem_data_bit_rate
Bit rate of the modem used.
UWPOLLING_AUV_STATUS prev_state
Current and previous state variable.
virtual void TxTrigger()
Transmission of the TRIGGER packet.
uint n_tx_pkts
Number of packets transmitted by the AUV during a TxData session.
virtual void stop_count_time()
Informs the protocol to stop counting the time in which the AUV receive DATA packets from the nodes I...
std::string backoff_LUT_file
File name of the backoff LUT.
virtual void stateIdle()
IDLE state.
virtual void waitForUser()
Used for debug purposes.
uint POLL_uid
POLL Unique ID.
uint TRIGGER_uid
TRIGGER Unique ID.
double Tdata
Time needed to transmit a DATA packet.
static std::map< UWPOLLING_AUV_REASON, std::string > reason_info
Map the UWPOLLING_AUV_STATUS to the description of each state.
@ UWPOLLING_AUV_REASON_PACKET_ERROR
@ UWPOLLING_AUV_REASON_RX_DATA_TO
@ UWPOLLING_AUV_REASON_PROBE_TO_EXPIRED
@ UWPOLLING_AUV_REASON_PROBE_RECEIVED
@ UWPOLLING_AUV_REASON_TX_POLL
@ UWPOLLING_AUV_REASON_MAX_PROBE_RECEIVED
@ UWPOLLING_AUV_REASON_LAST_POLLED_NODE
@ UWPOLLING_AUV_REASON_LAST_PACKET_RECEIVED
@ UWPOLLING_AUV_REASON_DATA_RX
@ UWPOLLING_AUV_REASON_TX_TRIGGER
virtual void SortNode2Poll()
Method in which the node that has sent correctly the PROBE packet is sorted in order to give the prio...
uint n_probe_rx
Number of PROBE packets received.
virtual void stateRxProbe()
State of the protocol in which there's a reception of a PROBE packet.
double curr_Tmeasured
Time elapsed between the transmission of the TRIGGER and the reception of the PROBE packet by the pol...
AckTimer ack_timer
ACK Timer.
int sea_trial_
Sea Trial flag: To activate if the protocol is going to be tested at the sea.
virtual void DataTOExpired()
DATA TIMER is Expired.
static bool initialized
Map the UWPOLLING_AUV_REASON to the description of each reason.
double T_probe
Duration of PROBE TIMER.
virtual double linearInterpolator(double x, double x1, double x2, double y1, double y2)
Calculate the linear interpolation between two 2-D points.
double total_time
Total time in which the AUV has received data packets.
Packet * curr_ack_packet
Pointer to the current ACK packet.
UWPOLLING_AUV_REASON reason
int getDroppedProbeWrongState()
Return the number of PROBE packets discarded because sent after the maximum time allowed.
void incrDroppedAckPkts()
Increases the number of wrong ACK packet received.
virtual void UpdateRTT()
Update the RTT between a node and the AUV based on the time elapsed between the transmisison of the T...
int getProbeRx()
Returns the number of PROBE received during the simulation.
int getWrongNodeDataSent()
Returns the number of Data Packet sent by Nodes not polled (used for debug purposes)
int DATA_POLL_guard_time_
Guard time between the reception of the last data and the transmission of the following POLL.
uint max_buffer_size
Temp buffer where packets are insert waiting for an ACK.
double T_guard
Guard time added to the calculation of the RTT.
int getPollSent()
Return the number of POLL packets sent during the simulation.
uint16_t uid_tx_pkt
Unique ID of the transmitted packets.
uint curr_node_id
ID of the node polled.
uint n_pkts_to_tx
Number of packets to transmit during a TxData session.
virtual void computeTxTime(UWPOLLING_PKT_TYPE pkt)
Compute the Transmission Time for various type of packet using a CrossLayer Message to ask the PHY to...
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void stateTxData()
Handle the data transmission after poll reception.
int max_polled_node
Maximum number of node that the AUV can poll each time.
int ack_enabled
True if ack is enabled, false if disabled, default true.
bool curr_is_sink
True if the current node of the list is a sink.
virtual void ackTOExpired()
ACK TIMER is Expired.
void incrDroppedProbePkts()
Increases the number of wrong PROBE packet received.
bool RxProbeEnabled
true if the AUV is enabled to receive PROBE packets, false otherwise
double probe_rtt
RTT calculation between AUV and NODE based on the time of PROBE transmission and reception.
double Tpoll
Time needed to transmit a POLL packet.
double T_max
Maximum value in which the node can choose his backoff time.
bool enableAckRx
True if the ack reception is enabled.
int getTriggerTx()
Returns the number of TRIGGER sent during the simulation.
static std::map< UWPOLLING_PKT_TYPE, std::string > pkt_type_info
Map the UWPOLLING_PKT_TYPE to the description of each type of packet.
double T_min
Minimum value in which the node can choose his backoff time.
ProbeTimer probe_timer
PROBE Timer.
virtual void refreshReason(UWPOLLING_AUV_REASON reason)
Refresh the reason for the changing of the state.
std::map< int, uint > rx_pkts_map
Map (mac_addr,rx_pkts) with the received packets for each node.
int print_stats_
Print protocol's statistics of the protocol.
void incrWrongNodeDataSent()
Increases the number of DATA packets received from node that are not POLLED anymore (i....
std::ofstream fout
Variable that handle the file in which the protocol write the state transition for debug purposes.
static std::map< UWPOLLING_AUV_STATUS, std::string > status_info
probe_cicle_counters probe_counters
Number of probe detected in a round (i.e., prehamble received)
virtual void handleAck()
Handle a received ack, reinserting in the buffer the packet not received by the sink.
virtual void addNode2List()
Add a node to the list of probbed nodes.
virtual void stateWaitData()
State of the protocol in which the DATA timer is set up.
virtual void stateTxPoll()
State of the protocol in which a POLL packet is initialized.
virtual void stateWaitAck()
State of the protcol in which the ACK timer is set up.
void incrAckRx()
Increases the number of Ack packets received.
UWPOLLING_AUV_REASON last_reason
Current and previous reason for the change of the state.
void incrDroppedProbeWrongState()
Increase the number of PROBEs packets dropped because the AUV was not in the RX_PROBE state.
int n_trigger_tx
Number of TRIGGER packets sent.
virtual void stateTxTrigger()
State of the protocol in which a TRIGGER packet is initialized.
virtual void handleProbeAck()
Handle the ack received in the probe packet tx by the sink.
int N_dropped_probe_wrong_state
Number of PROBE dropped because the AUV was not in RX_PROBE mode.
int getDroppedProbePkts()
Return the number of PROBE packets discarded because of wrong CRC.
virtual uint getRxPkts(int mac_addr)
Get the packets received from the node with the given mac address.
double pkt_time
Time needed to transmit a data packet.
Packet * curr_trigger_packet
true if the sink has been inserted in the list
bool RxDataEnabled
true if the AUV is enabled to receive DATA packets, false otherwise
virtual void stateAckRx()
Handle the recption of an ACK from the sink.
void incrProbeRx()
Increases the number of PROBE packets received.
uint16_t last_pkt_uid
ID of the last packet transmitted in the round.
DataTimer data_timer
Data timer.
virtual void recvFromUpperLayers(Packet *p)
Handle a packet coming from upper layers.
double stop_time
Time stamp in which the AUV finish to receive data packets.
uint max_tx_pkts
Max number of packets can be transmitted by the AUV during a TxData session.
double distance
Distance between the AUV and the current node.
double T_probe_guard
Guard time for PROBE packet: T_probe=T_max+T_probe_guard.
int getAckRx()
Returns the number of ACK received during the simulation.
std::ofstream out_file_stats
Variable that handle the file in which the protocol write the statistics.
virtual void addSink2List()
Add a sink node to the list of probbed nodes.
UWPOLLING_AUV_STATUS curr_state
int max_payload
Duration of ACK_TIMER.
std::deque< Packet * > temp_buffer
double Tprobe
Time needed to transmit a PROBE packet.
int N_expected_pkt
Number of packets that the node polled wish to transmit to the AUV.
double initial_time
Timestamp in which the AUV receive the first data packet.
virtual void TxPoll()
Transmisssion of the POLL packet.
virtual void stateWaitProbe()
State of the protocol in which the PROBE timer is set up.
std::map< double, double > backoff_LUT
Map with the backoff LUT.
int packet_index
Variable that indicate the number of the packet that has been just received by the AUV.
virtual ~Uwpolling_AUV()
Destructor of the Uwpolling_AUV class.
virtual void ProbeTOExpired()
PROBE TIMER is Expired.
double GetTotalReceivingTime()
Permits to retrieve the total time in which the AUV has received DATA packets.
virtual double GetDataTimerValue()
Calculation of DATA TIMER value based on the number of packet that a node need to transmit,...
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
bool initBackoffLUT()
Initialize the backoff LUT.
bool acked
True if an ack has been received.
virtual void txData()
Transmit data transmission after poll reception.
int n_poll_tx
Number of POLL packets sent.
int curr_polled_node_address
MAC address of the node polled.
UWPOLLING_AUV_STATUS
< Variable that rapresent the status of the protocol machine state
@ UWPOLLING_AUV_STATUS_RX_DATA
@ UWPOLLING_AUV_STATUS_TX_DATA
@ UWPOLLING_AUV_STATUS_IDLE
@ UWPOLLING_AUV_STATUS_WAIT_ACK
@ UWPOLLING_AUV_STATUS_TX_TRIGGER
@ UWPOLLING_AUV_STATUS_RX_PROBES
@ UWPOLLING_AUV_STATUS_TX_POLL
@ UWPOLLING_AUV_STATUS_WAIT_DATA
@ UWPOLLING_AUV_STATUS_RX_ACK
@ UWPOLLING_AUV_STATUS_WAIT_PROBE
Uwpolling_AUV()
Constructor of the Uwpolling_AUV class.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
int wrong_node_data_sent
Number of data sent by a node that isn't polled anymore.
unsigned long int getEpoch()
Calculate the epoch of the event.
int polling_index
Index of the node that the AUV is polling.
bool TxEnabled
true if the AUV is enabled to receive POLL packets, false otherwise
int getDroppedAckPkts()
Return the number of PROBE packets discarded because of wrong CRC.
int n_ack_rx
Number of ack packets received.
virtual void stateTx()
Handle the transmission after poll reception.
bool enable_adaptive_backoff
Set to true if backoff is chosen adaptively.
char lut_token_separator
LUT token separator.
bool begin
indicate the first PROBE received
virtual void stateRxData()
State of the protocol in which there's a reception of a DATA packet.
Packet * curr_poll_packet
Pointer to the current POLL packet.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
double curr_RTT
Round Trip time of the node polled.
double getMaxBackoffTime()
Reference to the backoff_time variable.
Internal structure where the AUV store the informations about the node to POLL.
uint16_t & get_id_ack()
Reference to the id_ack variable.
bool & is_sink()
Reference to the is_sink variable.
int n_pkts
Number of packets that the node transmit when he's polled.
double time_stamp
Timestamp of the most recent data packet generated by the node.
double & get_time_stamp()
Reference to the time_stamp variable.
uint id_node
Id of the node.
int & get_n_pkts()
Reference to the n_pkts variable.
double Tmeasured
Time elapsed between the transmisssion of the TRIGGER and the reception of the PROBE.
uint & get_id_node()
Reference to the id_node variable.
double & get_weight()
Reference to the policy_weight variable.
bool is_sink_
Ture if the probe comes from a sink.
uint16_t id_ack
Id used for ack purpose is the proebbed node is a sink.
int & get_mac_address()
Reference to the mac_address variable.
double policy_weight
Weigth used to choose the order to poll the nodes.
int mac_address
Mac Address of the node.
Struct used for handling the number of probes detected and received to estimate the number of neighbo...
uint n_probe_received
Number of probe received in a round (i.e., prehamble received)
uint n_probe_detected
Number of probe (prehamble) detected in a round by the MAC.
void incrementCounters()
Increment both counters.
void resetCounters()
Reset both counters.
uint getNumberOfNeighbors()
Get estimate number of neighbors.
std::pair< int, int > counter
counter of collisions
struct probbed_node probbed_node
Internal structure where the AUV store the informations about the node to POLL.
Common structures and variables in the protocol.
Provides the definition of the class UWSMPosition.