DESERT 3.5.1
Loading...
Searching...
No Matches
UwModemCSA Class Reference

#include <uwmodemcsa.h>

Inheritance diagram for UwModemCSA:
Collaboration diagram for UwModemCSA:

Public Member Functions

 UwModemCSA ()
 
virtual ~UwModemCSA ()
 
virtual void recv (Packet *p)
 
virtual int recvSyncClMsg (ClMessage *m)
 
virtual double getTxDuration (Packet *p)
 
virtual int command (int argc, const char *const *argv)
 
- Public Member Functions inherited from UwModem
 UwModem ()
 
virtual ~UwModem ()
 
virtual int getModulationType (Packet *P)
 
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)
 

Private Member Functions

virtual void startTx (Packet *p)
 
virtual void startRx (Packet *p)
 
virtual void endRx (Packet *p)
 
virtual void start ()
 
virtual void stop ()
 
virtual void transmittingData ()
 
virtual void receivingData ()
 
virtual std::string findCommand (std::vector< char >::iterator beg_it, std::vector< char >::iterator end_it, std::vector< char >::iterator &cmd_b, std::vector< char >::iterator &cmd_e)
 
virtual bool parseCommand (std::vector< char >::iterator cmd_b, std::vector< char >::iterator cmd_e, std::string &rx_payload)
 
virtual std::string buildSend (const std::string &payload, int dest)
 
void startRealRx (const std::string &cmd)
 
void createRxPacket (Packet *p)
 

Private Attributes

std::unique_ptr< UwConnectorp_connector
 
ModemState status
 
std::mutex status_m
 
std::mutex tx_queue_m
 
std::condition_variable status_cv
 
std::condition_variable tx_queue_cv
 
std::atomic< bool > receiving
 
std::atomic< bool > transmitting
 
std::thread rx_thread
 
std::thread tx_thread
 
std::string rx_payload
 
std::string del_b
 
std::string del_e
 

Static Private Attributes

static const std::chrono::milliseconds MODEM_TIMEOUT
 
static const double EPSILON_S = 0.01
 
static const size_t MAX_TX_STATUS_POLL = 20
 

Additional Inherited Members

- Public Types inherited from UwModem
enum class  LogLevel { ERROR = 0 , INFO = 1 , DEBUG = 2 }
 
- Static Public Member Functions inherited from UwModem
static bool string2log (const std::string &ll_string, LogLevel &ll)
 
static bool log2string (LogLevel ll, std::string &ll_string)
 
- Protected Member Functions inherited from UwModem
virtual void endTx (Packet *p)
 
void checkEvent ()
 
- Protected Attributes inherited from UwModem
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
 
CheckTimercheckTimer
 
double period
 
std::queue< ModemEventevent_q
 

Detailed Description

Definition at line 52 of file uwmodemcsa.h.

Constructor & Destructor Documentation

◆ UwModemCSA()

UwModemCSA::UwModemCSA ( )

Constructor of the UwModemCSA class.

Parameters
addressstring containing the address to connect to
buflenlenght in char of the data buffer
readlen length in char of a signle read from the connector

Definition at line 70 of file uwmodemcsa.cpp.

◆ ~UwModemCSA()

UwModemCSA::~UwModemCSA ( )
virtual

Destructor of the UwModemCSA class.

Definition at line 91 of file uwmodemcsa.cpp.

Member Function Documentation

◆ buildSend()

std::string UwModemCSA::buildSend ( const std::string &  payload,
int  dest 
)
privatevirtual

Definition at line 248 of file uwmodemcsa.cpp.

◆ command()

int UwModemCSA::command ( int  argc,
const char *const *  argv 
)
virtual

Tcl command interpreter: Method that maps Tcl commands into C++ methods.

Parameters
argcnumber of arguments in argv
argvarray of strings which are the command parameters (Note that argv[0] is the name of the object).
Returns
TCL_OK or TCL_ERROR whether the command has been dispatched successfully or not

Reimplemented from UwModem.

Definition at line 146 of file uwmodemcsa.cpp.

◆ createRxPacket()

void UwModemCSA::createRxPacket ( Packet *  p)
private

Definition at line 466 of file uwmodemcsa.cpp.

◆ endRx()

void UwModemCSA::endRx ( Packet *  p)
privatevirtual

Method that ends a packet reception.

This method is also in charge of sending the received NS-MIRACLE packet to the upper layers

Parameters
pPacket pointer to the packet being sent

Implements UwModem.

Definition at line 269 of file uwmodemcsa.cpp.

◆ findCommand()

std::string UwModemCSA::findCommand ( std::vector< char >::iterator  beg_it,
std::vector< char >::iterator  end_it,
std::vector< char >::iterator &  cmd_b,
std::vector< char >::iterator &  cmd_e 
)
privatevirtual

Method that finds the position of a command in a buffer.

Definition at line 394 of file uwmodemcsa.cpp.

◆ getTxDuration()

double UwModemCSA::getTxDuration ( Packet *  p)
virtual

Method that returns the duration of a given transmitted packet.

Inherited from MPhy, in NS-MIRACLE, could be empty if there is no way to retrieve this information.

Parameters
pPacket pointer to the given packet being transmitted
Returns
duration in seconds

Reimplemented from UwModem.

Definition at line 196 of file uwmodemcsa.cpp.

◆ parseCommand()

bool UwModemCSA::parseCommand ( std::vector< char >::iterator  cmd_b,
std::vector< char >::iterator  cmd_e,
std::string &  rx_payload 
)
privatevirtual

Method that parses the command to obtain the recquired informations.

Definition at line 417 of file uwmodemcsa.cpp.

◆ receivingData()

void UwModemCSA::receivingData ( )
privatevirtual

Method that detach a thread devoted to receiving data from the connector.

Definition at line 353 of file uwmodemcsa.cpp.

◆ recv()

void UwModemCSA::recv ( Packet *  p)
virtual

Method that handles the reception of packets arriving from upper layers of the network simulator.

Parameters
ppointer to the packet that has been received from the simulator upper layers

Implements UwModem.

Definition at line 97 of file uwmodemcsa.cpp.

◆ recvSyncClMsg()

int UwModemCSA::recvSyncClMsg ( ClMessage *  m)
virtual

Cross-Layer messages synchronous interpreter.

Parameters
ClMessage*an instance of ClMessage that represent the message received
Returns
0 if successful.

Implements UwModem.

Definition at line 168 of file uwmodemcsa.cpp.

◆ start()

void UwModemCSA::start ( )
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 277 of file uwmodemcsa.cpp.

◆ startRealRx()

void UwModemCSA::startRealRx ( const std::string &  cmd)
private

Method that updates the status of the modem State Machine: state change is triggered by reception of commands on the connector interface, or by commands to be sent to the device, e.g., SEND or SENDIM.

Parameters
cmdcommand received on the connector interface

Definition at line 449 of file uwmodemcsa.cpp.

◆ startRx()

void UwModemCSA::startRx ( Packet *  p)
privatevirtual

Method that starts a packet reception.

This method is also in charge of sending a ClMsg, Phy2MacStartRx(p), to notify the upper layers of the simulator about the start of the reception

Parameters
pPacket pointer to the packet to be received

Implements UwModem.

Definition at line 261 of file uwmodemcsa.cpp.

◆ startTx()

void UwModemCSA::startTx ( Packet *  p)
privatevirtual

Method that triggers the transmission of a packet through a specified modem.

Parameters
pPacket pointer to the packet to be sent

Implements UwModem.

Definition at line 205 of file uwmodemcsa.cpp.

◆ stop()

void UwModemCSA::stop ( )
privatevirtual

Method that stops the driver operations.

It performs all the needed operations to correctly stop the device's driver before closing the simulation.

Implements UwModem.

Definition at line 307 of file uwmodemcsa.cpp.

◆ transmittingData()

void UwModemCSA::transmittingData ( )
privatevirtual

Method that detach a thread devoted to sending packets found in tx_queue.

Definition at line 328 of file uwmodemcsa.cpp.

Member Data Documentation

◆ del_b

std::string UwModemCSA::del_b
private

Definition at line 203 of file uwmodemcsa.h.

◆ del_e

std::string UwModemCSA::del_e
private

Definition at line 205 of file uwmodemcsa.h.

◆ EPSILON_S

const double UwModemCSA::EPSILON_S = 0.01
staticprivate

minimum time to wait before to schedule a new event in seconds

Definition at line 210 of file uwmodemcsa.h.

◆ MAX_TX_STATUS_POLL

const size_t UwModemCSA::MAX_TX_STATUS_POLL = 20
staticprivate

maximum number of time to poll the modem transmission status before to discard the transmitted packet

Definition at line 213 of file uwmodemcsa.h.

◆ MODEM_TIMEOUT

const std::chrono::milliseconds UwModemCSA::MODEM_TIMEOUT
staticprivate
Initial value:
=
std::chrono::milliseconds(210)

Maximum time to wait for modem to become ModemState::AVAILABLE.

Definition at line 207 of file uwmodemcsa.h.

◆ p_connector

std::unique_ptr<UwConnector> UwModemCSA::p_connector
private

Pointer to Connector object that interfaces with the device.

Definition at line 180 of file uwmodemcsa.h.

◆ receiving

std::atomic<bool> UwModemCSA::receiving
private

Atomic boolean variable that controls the receiving looping thread.

Definition at line 193 of file uwmodemcsa.h.

◆ rx_payload

std::string UwModemCSA::rx_payload
private

String that is updated witn each new received messsage.

Definition at line 201 of file uwmodemcsa.h.

◆ rx_thread

std::thread UwModemCSA::rx_thread
private

Object with the rx thread.

Definition at line 197 of file uwmodemcsa.h.

◆ status

ModemState UwModemCSA::status
private

Variable holding the current status of the modem.

Definition at line 182 of file uwmodemcsa.h.

◆ status_cv

std::condition_variable UwModemCSA::status_cv
private

Condition variable to wait for ModemState::AVAILABLE.

Definition at line 189 of file uwmodemcsa.h.

◆ status_m

std::mutex UwModemCSA::status_m
private

Mutex associated with the state machine of the modem.

Definition at line 185 of file uwmodemcsa.h.

◆ transmitting

std::atomic<bool> UwModemCSA::transmitting
private

Atomic boolean variable that controls the transmitting looping thread.

Definition at line 195 of file uwmodemcsa.h.

◆ tx_queue_cv

std::condition_variable UwModemCSA::tx_queue_cv
private

Condition variable that is linked with the transmitting queue.

Definition at line 191 of file uwmodemcsa.h.

◆ tx_queue_m

std::mutex UwModemCSA::tx_queue_m
private

Mutex associated with the transmission queue.

Definition at line 187 of file uwmodemcsa.h.

◆ tx_thread

std::thread UwModemCSA::tx_thread
private

Object with the tx thread.

Definition at line 199 of file uwmodemcsa.h.


The documentation for this class was generated from the following files: