DESERT 3.5.1
Loading...
Searching...
No Matches
UwModem Class Referenceabstract

#include <uwmodem.h>

Inheritance diagram for UwModem:
Collaboration diagram for UwModem:

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.

Definition at line 61 of file uwmodem.h.

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 

Definition at line 72 of file uwmodem.h.

Constructor & Destructor Documentation

◆ UwModem()

UwModem::UwModem ( )

UwModem constructor.

Parameters
addressstring representing the address to connect to

Definition at line 69 of file uwmodem.cpp.

◆ ~UwModem()

UwModem::~UwModem ( )
virtual

UwModem destructor.

Definition at line 95 of file uwmodem.cpp.

Member Function Documentation

◆ checkEvent()

void UwModem::checkEvent ( )
protected

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

Definition at line 170 of file uwmodem.cpp.

◆ 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.

Definition at line 127 of file uwmodem.cpp.

◆ 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

Definition at line 163 of file uwmodem.cpp.

◆ getDebug()

int UwModem::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UwEvoLogicsS2CModem::debug_

Definition at line 199 of file uwmodem.h.

◆ getLogFile()

std::string UwModem::getLogFile ( )
inline

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

Returns
UwEvoLogicsS2CModem::logFile

Definition at line 209 of file uwmodem.h.

◆ getLogLevel()

LogLevel UwModem::getLogLevel ( )
inline

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

Returns
UwEvologicsS2CModem::log_

Definition at line 189 of file uwmodem.h.

◆ getModemID()

int UwModem::getModemID ( )
inline

Method that returns the current ID of the modem.

Returns
integer current ID of the modem

Definition at line 172 of file uwmodem.h.

◆ 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.

Definition at line 152 of file uwmodem.h.

◆ 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.

Definition at line 139 of file uwmodem.h.

◆ 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

Definition at line 52 of file uwmodem.cpp.

◆ printOnLog()

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

Function that, given the appropriate level of log, prints to the set log file the provided log message.

Definition at line 102 of file uwmodem.cpp.

◆ 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

Definition at line 219 of file uwmodem.h.

◆ 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.

◆ 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

Definition at line 162 of file uwmodem.h.

◆ 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.

◆ 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.

◆ 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

Definition at line 34 of file uwmodem.cpp.

Friends And Related Symbol Documentation

◆ CheckTimer

friend class CheckTimer
friend

Definition at line 63 of file uwmodem.h.

Member Data Documentation

◆ checkTimer

CheckTimer* UwModem::checkTimer
protected

Pointer to an object to schedule the "check-modem" events.

Definition at line 265 of file uwmodem.h.

◆ 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.

Definition at line 231 of file uwmodem.h.

◆ DATA_BUFFER_LEN

unsigned int UwModem::DATA_BUFFER_LEN
protected

Size of the buffer that holds data.

Definition at line 242 of file uwmodem.h.

◆ debug_

int UwModem::debug_
protected

Usual debug value that chooses the debug level through Tcl interface.

Definition at line 255 of file uwmodem.h.

◆ event_q

std::queue<ModemEvent> UwModem::event_q
protected

Queue of events that are scheduled for NS2 to execute (callbacks)

Definition at line 269 of file uwmodem.h.

◆ log_is_open

bool UwModem::log_is_open
protected

Flag to check if log file has already be opened.

Definition at line 264 of file uwmodem.h.

◆ log_suffix

std::string UwModem::log_suffix
protected

Possibility to insert a log suffix.

Definition at line 261 of file uwmodem.h.

◆ logFile

std::string UwModem::logFile
protected

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

Definition at line 259 of file uwmodem.h.

◆ loglevel_

LogLevel UwModem::loglevel_
protected

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

Definition at line 262 of file uwmodem.h.

◆ MAX_READ_BYTES

int UwModem::MAX_READ_BYTES
protected

Maximum number of bytes to be read by a single dump of data.

Definition at line 245 of file uwmodem.h.

◆ 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.

Definition at line 252 of file uwmodem.h.

◆ modemID

int UwModem::modemID
protected

Number used for identification purposes: not specified.

Definition at line 225 of file uwmodem.h.

◆ outLog

std::ofstream UwModem::outLog
protected

output strem to print into a disk-file log messages.

See UwEvoLogicsS2CModem::logFile.

Definition at line 257 of file uwmodem.h.

◆ period

double UwModem::period
protected

Checking period of the modem's buffer.

Definition at line 267 of file uwmodem.h.

◆ 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.

Definition at line 239 of file uwmodem.h.

◆ tx_queue

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

Modem's transmission queue: holds packets that are to be transmitted.

Definition at line 234 of file uwmodem.h.


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