DESERT 4.0.0
UwModem Class Referenceabstract

#include <uwmodem.h>

Inheritance diagram for UwModem:
Inheritance graph
Collaboration diagram for UwModem:
Collaboration graph

Public Types

enum class  LogLevel { ERROR = 0 , INFO = 1 , DEBUG = 2 }
 

Public Member Functions

 UwModem ()
 
virtual ~UwModem ()
 
virtual void recv (Packet *p)=0
 
virtual int command (int argc, const char *const *argv)
 
virtual int recvSyncClMsg (ClMessage *m)=0
 
virtual double getTxDuration (Packet *p)
 
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)
 

Static Public Member Functions

static bool string2log (const std::string &ll_string, LogLevel &ll)
 
static bool log2string (LogLevel ll, std::string &ll_string)
 

Protected Member Functions

virtual void startTx (Packet *p)=0
 
virtual void endTx (Packet *p)
 
virtual void startRx (Packet *p)=0
 
virtual void endRx (Packet *p)=0
 
virtual void start ()=0
 
virtual void stop ()=0
 
void checkEvent ()
 

Protected Attributes

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
 

Friends

class CheckTimer
 

Detailed Description

Class that implements the interface to DESERT, as used through Tcl scripts. This class provides common functions to operate as a physical layer; its derivate classes will implement its virtual methods as specific to each device.

Member Enumeration Documentation

◆ LogLevel

enum class UwModem::LogLevel
strong

Enum representing the amount of logs being generated ERROR: only errors will be generated INFO : general info about the algorithms running DEBUG: details that allow to understand the execution flow

Enumerator
ERROR 
INFO 
DEBUG 

Constructor & Destructor Documentation

◆ UwModem()

UwModem::UwModem ( )

UwModem constructor

Parameters
addressstring representing the address to connect to

References DATA_BUFFER_LEN, debug_, MAX_READ_BYTES, modemID, and period.

◆ ~UwModem()

UwModem::~UwModem ( )
virtual

UwModem destructor

References outLog.

Member Function Documentation

◆ checkEvent()

void UwModem::checkEvent ( )
protected

Method to check if any event from real world has to go to ns

References checkTimer, event_q, ModemEvent::f, ModemEvent::p, and period.

Referenced by CheckTimer::expire().

◆ command()

int UwModem::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 in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

References log_suffix, loglevel_, modem_address, start(), stop(), and string2log().

Referenced by UwAhoiModem::command(), UwEvoLogicsS2CModem::command(), UwMODAModem::command(), and UwModemCSA::command().

Here is the call graph for this function:

◆ endRx()

virtual void UwModem::endRx ( Packet *  p)
protectedpure virtual

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

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

◆ endTx()

void UwModem::endTx ( Packet *  p)
protectedvirtual

Method that ends a packet transmission. This method is also in charge of sending a CrLayerMsg, Phy2MacEndTx(p), to notify the above layers of the simulator about the end of a transmission

Parameters
pPacket pointer to the packet being received

Referenced by realTxEnded().

◆ getDebug()

int UwModem::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UwEvoLogicsS2CModem::debug_

References debug_.

Referenced by CheckTimer::CheckTimer(), and CheckTimer::CheckTimer().

◆ getLogFile()

std::string UwModem::getLogFile ( )
inline

Method to return the name of the file where to log messages.

Returns
UwEvoLogicsS2CModem::logFile

References log_suffix, logFile, and modemID.

Referenced by printOnLog().

◆ getLogLevel()

LogLevel UwModem::getLogLevel ( )
inline

Method to return the flag used to enable the printing of log messages in UwEvoLogicsS2CModem::logFile.

Returns
UwEvologicsS2CModem::log_

References loglevel_.

Referenced by printOnLog().

◆ getModemID()

int UwModem::getModemID ( )
inline

Method that returns the current ID of the modem.

Returns
integer current ID of the modem

References modemID.

◆ getModulationType()

virtual int UwModem::getModulationType ( Packet *  P)
inlinevirtual

Method that should return 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

Parameters
pPacket pointer to the given packet being transmitted
modulationtype represented by an integer

Reimplemented in UwMODAModem.

Referenced by UwAhoiModem::recv(), UwEvoLogicsS2CModem::recv(), and UwModemCSA::recv().

◆ getTxDuration()

virtual double UwModem::getTxDuration ( Packet *  p)
inlinevirtual

Method that returnd 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 in UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

◆ log2string()

bool UwModem::log2string ( LogLevel  ll,
std::string &  ll_string 
)
static

Method that converts an enum type of the loglevel into the string representing it

Parameters
llreturn loglevel to be converted
ll_stringreturn param string representing the loglevel
Returns
boolean true if conversion was correctly performed

References DEBUG, ERROR, and INFO.

Referenced by printOnLog().

◆ printOnLog()

void UwModem::printOnLog ( LogLevel  log_level,
string  module,
string  message 
)

◆ realTxEnded()

void UwModem::realTxEnded ( Packet *  p)
inline

Method to call endTx from end of real packet transmission

Parameters
pPacket pointer to the packet being received

References endTx().

Referenced by UwEvoLogicsS2CModem::startTx(), UwMODAModem::startTx(), UwModemCSA::startTx(), and UwAhoiModem::transmittingData().

Here is the call graph for this function:

◆ recv()

virtual void UwModem::recv ( Packet *  p)
pure virtual

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

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

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

Referenced by UwMODAModem::receivingData(), UwModemCSA::startRealRx(), UwAhoiModem::updateStatus(), and UwEvoLogicsS2CModem::updateStatus().

◆ recvSyncClMsg()

virtual int UwModem::recvSyncClMsg ( ClMessage *  m)
pure virtual

Cross-Layer messages synchronous interpreter.

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

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

◆ setModemID()

void UwModem::setModemID ( int  ID)
inline

Set the modem's ID number. Used for identification purposes

Parameters
IDinteger number used as modem ID

References modemID.

◆ start()

virtual void UwModem::start ( )
protectedpure virtual

Method that starts the driver operations. It performs all the needed operations to correctly fire up the device's driver.

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

Referenced by command().

◆ startRx()

virtual void UwModem::startRx ( Packet *  p)
protectedpure virtual

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

Parameters
pPacket pointer to the packet to be received

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

◆ startTx()

virtual void UwModem::startTx ( Packet *  p)
protectedpure virtual

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

Parameters
pPacket pointer to the packet to be sent

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

◆ stop()

virtual void UwModem::stop ( )
protectedpure virtual

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

Implemented in UwAhoiModem, UwEvoLogicsS2CModem, UwMODAModem, and UwModemCSA.

Referenced by command().

◆ string2log()

bool UwModem::string2log ( const std::string &  ll_string,
LogLevel ll 
)
static

Method that converts a string representing the loglevel into the enum type of loglevel

Parameters
ll_stringstring to be converted
llreturn parameter containing the converted loglevel
Returns
boolean true if conversion was correctly performed

References DEBUG, ERROR, and INFO.

Referenced by command().

Friends And Related Symbol Documentation

◆ CheckTimer

Member Data Documentation

◆ checkTimer

CheckTimer* UwModem::checkTimer
protected

◆ data_buffer

std::vector<char> UwModem::data_buffer
protected

Char buffer (vector) that holds data read from the modem (unparsed data) Main container for data received by the connector.

Referenced by UwAhoiModem::receivingData(), UwEvoLogicsS2CModem::receivingData(), UwMODAModem::receivingData(), UwModemCSA::receivingData(), and UwMODAModem::UwMODAModem().

◆ DATA_BUFFER_LEN

◆ debug_

int UwModem::debug_
protected

Usual debug value that chooses the debug level through Tcl interface

Referenced by getDebug(), and UwModem().

◆ event_q

◆ log_is_open

bool UwModem::log_is_open
protected

Flag to check if log file has already be opened

Referenced by printOnLog().

◆ log_suffix

std::string UwModem::log_suffix
protected

Possibility to insert a log suffix

Referenced by command(), and getLogFile().

◆ logFile

std::string UwModem::logFile
protected

Name of the disk-file where to write the interface's log messages.

Referenced by getLogFile().

◆ loglevel_

LogLevel UwModem::loglevel_
protected

Log level on file, from ERROR (0) to DEBUG (2) in UwEvoLogicsS2CModem::logFile.

Referenced by command(), and getLogLevel().

◆ MAX_READ_BYTES

◆ modem_address

std::string UwModem::modem_address
protected

String containing the address needed to connect to the device In case of socket, it may be expressed as: 192.168.XXX.XXX:PORTNUM In case of serial, it will be expressed in some other way

Referenced by command(), UwAhoiModem::start(), UwEvoLogicsS2CModem::start(), UwMODAModem::start(), and UwModemCSA::start().

◆ modemID

int UwModem::modemID
protected

Number used for identification purposes: not specified

Referenced by UwEvoLogicsS2CModem::configure(), UwAhoiModem::fillAhoiPkt(), getLogFile(), getModemID(), setModemID(), UwAhoiModem::updateStatus(), and UwModem().

◆ outLog

std::ofstream UwModem::outLog
protected

output strem to print into a disk-file log messages. See UwEvoLogicsS2CModem::logFile.

Referenced by printOnLog(), and ~UwModem().

◆ period

double UwModem::period
protected

◆ rx_queue

std::queue<Packet *> UwModem::rx_queue
protected

Modem's reception queue: holds packets eceived from the channel awaiting to be pushed up the stack

◆ tx_queue

std::queue<Packet *> UwModem::tx_queue
protected

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