45#include <condition_variable>
93 virtual void recv(Packet *p);
112 virtual int command(
int argc,
const char *
const *argv);
120 virtual void startTx(Packet *p);
128 virtual void startRx(Packet *p);
135 virtual void endRx(Packet *p);
141 virtual void start();
166 void updateStatus(std::shared_ptr<ahoi::packet_t> packet);
187 bool parseFooter(std::shared_ptr<ahoi::footer_t> footer);
196 bool storePacketInfo(std::shared_ptr<ahoi::packet_t> header, Packet *p);
The ahoi! modems are an underwater acoustic modems developed by TUUH University, Hamburg by the Smart...
void updateSN()
Method for Sequence Number (SN) update.
int stop_bit
flag for stop bit
virtual void endRx(Packet *p)
Method that ends a packet reception.
UwAhoiModem()
Constructor of the UwAhoiModem class.
TransmissionState
Enum type for the trasnmission state.
uint id
Modem ID, to be set in simulation.
ModemState
Enum type for the modem general state.
std::condition_variable tx_status_cv
Condition variable to wait for TransmissionState::TX_IDLE.
virtual void startTx(Packet *p)
Method that triggers the transmission of a packet through a specified modem.
std::mutex tx_queue_m
Mutex associated with the transmission queue.
ahoi::packet_t fillAhoiPkt(Packet *p)
Method that fills the fields of an ahoi! packet with the needed values, so that later it can be seria...
std::unique_ptr< UwConnector > p_connector
Pointer to Connector object that interfaces with the device.
virtual int command(int argc, const char *const *argv)
Tcl command interpreter: Method that maps Tcl commands into C++ methods.
uint rssi
RSSI vs an "ideal packet".
virtual void stop()
Method that stops the driver operations.
double virtual_time_ref
virtual time reference
virtual int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
uint power
Received power (RMSE) ratio and "ideal packet".
virtual void start()
Method that starts the driver operations.
uint agc_max
Maximum gain set by the AGC (if used) in reception of the last packet.
std::mutex tx_status_m
Mutex associated with the state machine of the transmission process.
uint bit_errors
Number of repaired bit errors during reception in the last packet.
void createRxPacket(Packet *p)
Method that fills up a packet with the needed header and payload and makes it ready to be sent to the...
bool storePacketInfo(std::shared_ptr< ahoi::packet_t > header, Packet *p)
Method that extarcts fields from a provided ahoi! packet and save the info values to class field for ...
std::mutex status_m
Mutex associated with the state machine of the modem.
uint agc_mean
Mean gain set by the AGC (if used) in reception of the last packet.
std::atomic< bool > receiving
Atomic boolean variable that controls the receiving looping thread.
static uint MAX_RETX
Maximum number of retransmissions for the same packet.
std::chrono::milliseconds WAIT_DELIVERY
Time interval to wait for the modem notifying the response of a given packet.
ModemState status
Variable holding the current status of the modem.
static uint WAIT_DELIVERY_INT
Time interval matching the WAIT_DELIVERY variable: version of type int to match the chrono one,...
int flow_control
flag for flow control
virtual void transmittingData()
Method that detach a thread devoted to sending packets found in tx_queue.
static const std::chrono::milliseconds MODEM_TIMEOUT
Maximum time to wait for modem to become ModemState::AVAILABLE.
std::condition_variable tx_queue_cv
Condition variable that is linked with the transmitting queue.
virtual ~UwAhoiModem()
Destructor of the UwAhoiModem class.
uint agc_min
Minimum gain set by the AGC (if used) in reception of the last packet.
std::unique_ptr< UwInterpreterAhoi > p_interpreter
Pointer to Interpreter object to parse device syntax.
virtual void startRx(Packet *p)
Method that starts a packet reception.
std::atomic< bool > transmitting
Atomic boolean variable that controls the transmitting looping thread.
std::thread rx_thread
Object with the rx thread.
std::thread tx_thread
Object with the tx thread.
static const double EPSILON_S
minimum time to wait before to schedule a new event in seconds
int parity_bit
flag for parity bit
std::condition_variable status_cv
Condition variable to wait for ModemState::AVAILABLE.
void updateStatus(std::shared_ptr< ahoi::packet_t > packet)
Method that updates the status of the modem State Machine: state change is triggered by recepting the...
std::string rx_payload
String that is updated witn each new received messsage.
virtual void receivingData()
Mehod that detach a thread devoted to receiving data from the connector.
TransmissionState tx_status
Variable holding the current transmission status of the modem.
int baud_rate
Integer for port baud rate.
ahoi::packet_t tmpPacket
Packet to be checked to unlock state machine.
static uint8_t sn
Sequence number, which follows all the packets transmitted to the modem.
bool parseFooter(std::shared_ptr< ahoi::footer_t > footer)
Method that extarcts fields from a provided ahoi! packet and save the info values to class field for ...
virtual void recv(Packet *p)
Method that handles the reception of packets arriving from upper layers of the network simulator.
Class that implements the interface to DESERT, as used through Tcl scripts.
Generic class that provides a method to interface with the devices. Will be specialized for,...
Interpreter for commands and responses for ahoi! modems, TUHH, Hamburg.
Header of the main class that implements the general interface between DESERT and real acoustic modem...