45#include <condition_variable>
94 virtual void recv(Packet *p);
105 virtual int command(
int argc,
const char *
const *argv);
143 virtual void startTx(Packet *p);
151 virtual void startRx(Packet *p);
158 virtual void endRx(Packet *p);
239 static std::vector<std::pair<std::string, ModemResponse> >
signaling_dict;
265 const std::string
sep = {
"::"};
std::thread rx_thread
Thread managing the data reception process.
virtual int getModulationType(Packet *p)
Method that returns the modulation type used for the packet being transmitted.
int premodulation
True if premodulation is on, false otherwise.
void createRxPacket(Packet *p)
Method that creates a packet from the received stream of bytes.
const std::string sep
String separator used in reception signaling.
virtual void endRx(Packet *p)
Method that ends a packet reception.
ModemState status
Variable holding the current status of the modem.
void receivingSignaling()
Method that dispacthes a thread dedicated to receiving signaling from the signaling connector Allows ...
ModemResponse parseSignaling(std::vector< char >::iterator &end_it)
Method that parses the content of the signaling data buffer to retrieve signaling messages.
void receivingData()
Method that dispatch a thread dedicated to receiving data from the data connector.
std::mutex status_m
Mutex associated with the state machine of the modem.
static const int SIGNALING_ADDRESS
Port of the signaling channel.
virtual void recv(Packet *p)
Method that handles the reception of packets arriving from upper layers of the network simulator.
std::thread tx_thread
Thread managing the data transmission process.
virtual double getTxDuration(Packet *p)
Method that returns the duration of a given transmitted packet.
void updateStatus(ModemResponse response)
Method that, based on the received signaling, updates the state machine of the driver.
std::string rx_payload
String that is updated with each new received message.
void start()
Method that starts the driver operations.
std::thread sig_thread
Thread managing the signaling reception process.
std::atomic< bool > receiving
Atomic boolean variable that controls the receiving looping thread.
virtual void startTx(Packet *p)
Method that triggers the transmission of a packet through a specified modem.
std::condition_variable status_cv
Condition variable that is linked with the status variable.
std::mutex tx_queue_m
Mutex associated with the transmission queue.
ModemResponse
Enum type representing modem responses.
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.
static std::vector< std::pair< std::string, ModemResponse > > signaling_dict
Dictionary of accepted signaling states.
void stop()
Method that stops the driver operations.
void transmittingData()
Method that dispatches a thread dedicated to transmitting data through the data connector.
virtual int command(int argc, const char *const *argv)
Tcl command interpreter: Method that maps Tcl commands into C++ methods.
static std::map< ModemState, std::string > stateToString
Dictionary for converting a state to a printable string.
std::string signal_tag
Signaling tag to recognize signaling from the modem.
UwMODAModem()
Constructor of the UwMODAModem class.
const std::string end_delim
String end delimiter used in reception signaling.
std::vector< char > signal_buffer
Bytes buffer for the signaling channel (unparsed data)
ModemState
Enum type for the modem general state.
virtual void startRx(Packet *p)
Method that starts a packet reception.
virtual ~UwMODAModem()
Destructor of the UwMODAModem class.
int rx_size
Size of each new received message, coming from signaling.
std::unique_ptr< UwConnector > signal_conn
Signaling connector: used ot retrieve signaling coming from the modem signaling's channel.
virtual int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
static const int DATA_ADDRESS
Port of the data channel.
std::atomic< bool > transmitting
Atomic boolean variable that controls the transmitting looping thread.
std::string signal_address
std::unique_ptr< UwConnector > data_conn
Data connector: used ot retrieve data coming from the modem data socket.
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,...
Header of the main class that implements the general interface between DESERT and real acoustic modem...
Class that implements a connector and, specifically, the socket connector. BSD sockets are used,...