DESERT 3.5.1
|
#include <uwmodamodem.h>
Public Types | |
enum class | ModemState { AVAILABLE = 0 , TRANSMITTING , RECEIVING , CONFIGURING } |
enum class | ModemResponse { UNDEFINED = 0 , TX_END , RX_BEG , CFG_END } |
![]() | |
enum class | LogLevel { ERROR = 0 , INFO = 1 , DEBUG = 2 } |
Public Member Functions | |
UwMODAModem () | |
virtual | ~UwMODAModem () |
virtual void | recv (Packet *p) |
virtual int | command (int argc, const char *const *argv) |
virtual int | getModulationType (Packet *p) |
virtual double | getTxDuration (Packet *p) |
virtual int | recvSyncClMsg (ClMessage *m) |
![]() | |
UwModem () | |
virtual | ~UwModem () |
void | setModemID (int ID) |
int | getModemID () |
void | printOnLog (LogLevel log_level, string module, string message) |
LogLevel | getLogLevel () |
int | getDebug () |
std::string | getLogFile () |
void | realTxEnded (Packet *p) |
Protected Member Functions | |
virtual void | startTx (Packet *p) |
virtual void | startRx (Packet *p) |
virtual void | endRx (Packet *p) |
![]() | |
virtual void | endTx (Packet *p) |
void | checkEvent () |
Protected Attributes | |
ModemState | status |
![]() | |
int | modemID |
std::vector< char > | data_buffer |
std::queue< Packet * > | tx_queue |
std::queue< Packet * > | rx_queue |
unsigned int | DATA_BUFFER_LEN |
int | MAX_READ_BYTES |
std::string | modem_address |
int | debug_ |
std::ofstream | outLog |
std::string | logFile |
std::string | log_suffix |
LogLevel | loglevel_ |
bool | log_is_open |
CheckTimer * | checkTimer |
double | period |
std::queue< ModemEvent > | event_q |
Private Member Functions | |
void | start () |
void | stop () |
void | receivingSignaling () |
void | receivingData () |
void | createRxPacket (Packet *p) |
void | transmittingData () |
ModemResponse | parseSignaling (std::vector< char >::iterator &end_it) |
void | updateStatus (ModemResponse response) |
Private Attributes | |
std::mutex | status_m |
std::condition_variable | status_cv |
std::mutex | tx_queue_m |
std::condition_variable | tx_queue_cv |
std::atomic< bool > | receiving |
std::atomic< bool > | transmitting |
std::string | rx_payload |
int | rx_size |
std::thread | sig_thread |
std::thread | rx_thread |
std::thread | tx_thread |
std::unique_ptr< UwConnector > | signal_conn |
std::unique_ptr< UwConnector > | data_conn |
std::vector< char > | signal_buffer |
const std::string | sep = {"::"} |
const std::string | end_delim = {";"} |
std::string | signal_tag |
std::string | signal_address |
int | premodulation |
Static Private Attributes | |
static std::vector< std::pair< std::string, ModemResponse > > | signaling_dict |
static std::map< ModemState, std::string > | stateToString |
static const int | SIGNALING_ADDRESS = 55006 |
static const int | DATA_ADDRESS = 55555 |
static const std::chrono::milliseconds | MODEM_TIMEOUT |
Additional Inherited Members | |
![]() | |
static bool | string2log (const std::string &ll_string, LogLevel &ll) |
static bool | log2string (LogLevel ll, std::string &ll_string) |
Definition at line 51 of file uwmodamodem.h.
|
strong |
Enum type representing modem responses.
UNDEFINED: unrecognized signaling TX_END: modem signals that it has ended a transmission RX_BEG: modem signals that it has begun receiving data CFG_END: modem signals that it has ended an ongoing configuration
Enumerator | |
---|---|
UNDEFINED | |
TX_END | |
RX_BEG | |
CFG_END |
Definition at line 71 of file uwmodamodem.h.
|
strong |
Enum type for the modem general state.
AVAILABLE: immediately available to perform an operation TRANSMITTING: executing a tranmission command: must wait for it ot complete CONFIGURING: executing a configuration command: must wait for it to complete
Enumerator | |
---|---|
AVAILABLE | |
TRANSMITTING | |
RECEIVING | |
CONFIGURING |
Definition at line 62 of file uwmodamodem.h.
UwMODAModem::UwMODAModem | ( | ) |
Constructor of the UwMODAModem class.
Definition at line 87 of file uwmodamodem.cpp.
|
virtual |
Destructor of the UwMODAModem class.
Definition at line 113 of file uwmodamodem.cpp.
|
virtual |
Tcl command interpreter: Method that maps Tcl commands into C++ methods.
argc | number of arguments in argv |
argv | array of strings which are the command parameters (Note that argv[0] is the name of the object). |
Reimplemented from UwModem.
Definition at line 162 of file uwmodamodem.cpp.
|
private |
Method that creates a packet from the received stream of bytes.
p | allocated empty packet to fill in with the received bytes |
Definition at line 354 of file uwmodamodem.cpp.
|
protectedvirtual |
Method that ends a packet reception.
This method is also in charge of sending the received NS-MIRACLE packet to the upper layers
p | Packet pointer to the packet being sent |
Implements UwModem.
Definition at line 241 of file uwmodamodem.cpp.
|
virtual |
Method that returns the modulation type used for the packet being transmitted.
Inherited from MPhy, in NS-MIRACLE, could be left empty if no way exists to retrieve this information
p | Packet pointer to the given packet being transmitted |
modulation | type represented by an integer |
Reimplemented from UwModem.
Definition at line 176 of file uwmodamodem.cpp.
|
virtual |
Method that returns the duration of a given transmitted packet.
It uses a linear interpolation given the packet size. Inherited from MPhy, in NS-MIRACLE, could be empty if there is no way to retrieve this information.
p | Packet pointer to the given packet being transmitted |
Reimplemented from UwModem.
Definition at line 182 of file uwmodamodem.cpp.
|
private |
Method that parses the content of the signaling data buffer to retrieve signaling messages.
Definition at line 421 of file uwmodamodem.cpp.
|
private |
Method that dispatch a thread dedicated to receiving data from the data connector.
Definition at line 307 of file uwmodamodem.cpp.
|
private |
Method that dispacthes a thread dedicated to receiving signaling from the signaling connector Allows to be compliant with modem opeations: if channel fails, driver must stop operations until signaling resumes.
Definition at line 364 of file uwmodamodem.cpp.
|
virtual |
Method that handles the reception of packets arriving from upper layers of the network simulator.
p | pointer to the packet that has been received from the simulator upper layers |
Implements UwModem.
Definition at line 119 of file uwmodamodem.cpp.
|
virtual |
Cross-Layer messages synchronous interpreter.
ClMessage* | an instance of ClMessage that represent the message received |
Implements UwModem.
Definition at line 204 of file uwmodamodem.cpp.
|
privatevirtual |
Method that starts the driver operations.
It performs all the needed operations to correctly fire up the device's driver.
Implements UwModem.
Definition at line 248 of file uwmodamodem.cpp.
|
protectedvirtual |
Method that starts a packet reception.
This method is also in charge of sending a CrLayerMsg, Phy2MacStartRx(p), to notify the upper layers of the simulator about the start of the reception
p | Packet pointer to the packet to be received |
Implements UwModem.
Definition at line 233 of file uwmodamodem.cpp.
|
protectedvirtual |
Method that triggers the transmission of a packet through a specified modem.
p | Packet pointer to the packet to be sent |
Implements UwModem.
Definition at line 495 of file uwmodamodem.cpp.
|
privatevirtual |
Method that stops the driver operations.
It performs all the needed operations to correctly stop the device's driver before closing operations.
Implements UwModem.
Definition at line 280 of file uwmodamodem.cpp.
|
private |
Method that dispatches a thread dedicated to transmitting data through the data connector.
Definition at line 395 of file uwmodamodem.cpp.
|
private |
Method that, based on the received signaling, updates the state machine of the driver.
response | ModemRresponse response from the modem |
Definition at line 467 of file uwmodamodem.cpp.
|
staticprivate |
Port of the data channel.
Definition at line 256 of file uwmodamodem.h.
|
private |
Data connector: used ot retrieve data coming from the modem data socket.
Definition at line 255 of file uwmodamodem.h.
|
private |
String end delimiter used in reception signaling.
Definition at line 267 of file uwmodamodem.h.
|
staticprivate |
Maximum time to wait for modem to become ModemState::AVAILABLE.
Definition at line 262 of file uwmodamodem.h.
|
private |
True if premodulation is on, false otherwise.
Definition at line 278 of file uwmodamodem.h.
|
private |
Atomic boolean variable that controls the receiving looping thread.
Definition at line 225 of file uwmodamodem.h.
|
private |
String that is updated with each new received message.
Definition at line 230 of file uwmodamodem.h.
|
private |
Size of each new received message, coming from signaling.
Definition at line 232 of file uwmodamodem.h.
|
private |
Thread managing the data reception process.
Definition at line 235 of file uwmodamodem.h.
|
private |
String separator used in reception signaling.
Definition at line 265 of file uwmodamodem.h.
|
private |
Thread managing the signaling reception process.
Definition at line 234 of file uwmodamodem.h.
|
private |
Definition at line 276 of file uwmodamodem.h.
|
private |
Bytes buffer for the signaling channel (unparsed data)
Definition at line 259 of file uwmodamodem.h.
|
private |
Signaling connector: used ot retrieve signaling coming from the modem signaling's channel.
Definition at line 249 of file uwmodamodem.h.
|
private |
Signaling tag to recognize signaling from the modem.
It is not necessary but added in case of future additional features that want to use the signaling channel
Definition at line 274 of file uwmodamodem.h.
|
staticprivate |
Port of the signaling channel.
Definition at line 250 of file uwmodamodem.h.
|
staticprivate |
Dictionary of accepted signaling states.
Definition at line 52 of file uwmodamodem.h.
|
staticprivate |
Dictionary for converting a state to a printable string.
Definition at line 59 of file uwmodamodem.h.
|
protected |
Variable holding the current status of the modem.
Definition at line 160 of file uwmodamodem.h.
|
private |
Condition variable that is linked with the status variable.
Definition at line 219 of file uwmodamodem.h.
|
private |
Mutex associated with the state machine of the modem.
Definition at line 217 of file uwmodamodem.h.
|
private |
Atomic boolean variable that controls the transmitting looping thread.
Definition at line 227 of file uwmodamodem.h.
|
private |
Condition variable that is linked with the transmitting queue.
Definition at line 223 of file uwmodamodem.h.
|
private |
Mutex associated with the transmission queue.
Definition at line 221 of file uwmodamodem.h.
|
private |
Thread managing the data transmission process.
Definition at line 236 of file uwmodamodem.h.