DESERT 4.0.0
UWMPhy_modem Class Referenceabstract

#include <uwmphy_modem.h>

Inheritance diagram for UWMPhy_modem:
Inheritance graph
Collaboration diagram for UWMPhy_modem:
Collaboration graph

Public Member Functions

 UWMPhy_modem (std::string)
 
 ~UWMPhy_modem ()
 
virtual void recv (Packet *)
 
virtual int command (int, const char *const *)
 
virtual int recvSyncClMsg (ClMessage *m)=0
 
int getID ()
 
double getPeriod ()
 
std::string getPathToDevice ()
 
uint getQueueLength ()
 
int getDebug ()
 
std::string getLogFile ()
 
log_level_t getLogLevel ()
 
unsigned long int getEpoch ()
 
void updatePktRx (Packet *)
 
 UWMPhy_modem (std::string)
 
 ~UWMPhy_modem ()
 
virtual void recv (Packet *)
 
virtual int command (int, const char *const *)
 
virtual int recvSyncClMsg (ClMessage *m)=0
 
int getID ()
 
double getPeriod ()
 
std::string getPathToDevice ()
 
uint getQueueLength ()
 
int getDebug ()
 
std::string getLogFile ()
 
log_level_t getLogLevel ()
 
unsigned long int getEpoch ()
 
void updatePktRx (Packet *)
 

Protected Member Functions

void setConnections (CheckTimer *, UWMdriver *, DropTimer *)
 
virtual void start ()
 
virtual void stop ()
 
virtual modem_state_t check_modem ()=0
 
virtual void startTx (Packet *)
 
virtual void endTx (Packet *)
 
virtual void startRx (Packet *)
 
virtual void endRx (Packet *)
 
Packet * popTxBuff ()
 
virtual double getTxDuration (Packet *p)
 
virtual int getModulationType (Packet *p)
 
void setConnections (CheckTimer *, UWMdriver *, DropTimer *)
 
virtual void start ()
 
virtual void stop ()
 
virtual modem_state_t check_modem ()=0
 
virtual void startTx (Packet *)
 
virtual void endTx (Packet *)
 
virtual void startRx (Packet *)
 
virtual void endRx (Packet *)
 
Packet * popTxBuff ()
 
virtual double getTxDuration (Packet *p)
 
virtual int getModulationType (Packet *p)
 

Protected Attributes

CheckTimerpcheckTmr
 
UWMdriverpmDriver
 
DropTimerpDropTimer
 
int ID
 
double period
 
Packet * modemTxBuff [_MTBL]
 
int t
 
Packet * PktRx
 
std::string pToDevice
 
int debug_
 
std::ofstream outLog
 
std::string logFile
 
char * log_suffix
 
int loglevel_
 
int SetModemID
 
uint queue_length
 

Friends

class CheckTimer
 
class DropTimer
 

Detailed Description

The main class implementing the module used to implement the interface between ns2/NS-Miracle and real acoustic modems. UWMPhy_modem (as well as its possible derived classes) handles all the messages needed by NS-Miracle (e.g., cross-layer messages between MAC and PHY) and contains all the variables set by the tcl-user; furthermore, this module coordinates the interactions between UWMcodec and UWMdriver. This class replaces the physical layer of NS-Miracle and inherits from MPhy (see NS-Miracle documentation at http://telecom.dei.unipd.it/ns/miracle/doxygen/classMPhy.html).

Constructor & Destructor Documentation

◆ UWMPhy_modem() [1/2]

UWMPhy_modem::UWMPhy_modem ( std::string  pToDevice_)

Class constructor.

Parameters
pToDevice_the path to the device that must be connected with NS-Miracle (e.g., /dev/ttyUSB0 for a serial connection)

References debug_, ID, loglevel_, modemTxBuff, pcheckTmr, pDropTimer, period, PktRx, pmDriver, pToDevice, queue_length, SetModemID, and t.

◆ ~UWMPhy_modem() [1/2]

UWMPhy_modem::~UWMPhy_modem ( )

Class destructor.

◆ UWMPhy_modem() [2/2]

UWMPhy_modem::UWMPhy_modem ( std::string  )

Class constructor.

Parameters
pToDevice_the path to the device that must be connected with NS-Miracle (e.g., /dev/ttyUSB0 for a serial connection)

◆ ~UWMPhy_modem() [2/2]

UWMPhy_modem::~UWMPhy_modem ( )

Class destructor.

Member Function Documentation

◆ check_modem() [1/2]

virtual modem_state_t UWMPhy_modem::check_modem ( )
protectedpure virtual

Modem checker. This method is at the core of the "check-modem" process. It is called periodically by the timer object linked to this UWMPhy_modem object (see UWMPhy_modem::checkTmr_); its due is to verify if something has been received or is going to be received from the channel.

Returns
modemStatus, a flag on the status of the modem, see UWMdriver for a description of the driver state machine.

Implemented in MS2C_Evo_lowlev.

◆ check_modem() [2/2]

virtual modem_state_t UWMPhy_modem::check_modem ( )
protectedpure virtual

Modem checker. This method is at the core of the "check-modem" process. It is called periodically by the timer object linked to this UWMPhy_modem object (see UWMPhy_modem::checkTmr_); its due is to verify if something has been received or is going to be received from the channel.

Returns
modemStatus, a flag on the status of the modem, see UWMdriver for a description of the driver state machine.

Implemented in MS2C_Evo_lowlev.

Referenced by recv().

◆ command() [1/2]

virtual int UWMPhy_modem::command ( int  ,
const char *const *   
)
virtual

Method to map tcl commands into c++ methods.

Parameters
argcnumber of arguments in argv
argvarray of arguments where argv[3] is the tcl command name and argv[4, 5, ...] are the parameters for the corresponding c++ method.

◆ command() [2/2]

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

Method to map tcl commands into c++ methods.

Parameters
argcnumber of arguments in argv
argvarray of arguments where argv[3] is the tcl command name and argv[4, 5, ...] are the parameters for the corresponding c++ method.

References log_suffix, start(), and stop().

Here is the call graph for this function:

◆ endRx() [1/2]

virtual void UWMPhy_modem::endRx ( Packet *  )
protectedvirtual

Method to end a packet reception. This method is also in charge to send the received NS-Miracle packet (as recovered from the received acoustic packet) to the above layers of the simulator.

Parameters
ppointer to the last received packet.

◆ endRx() [2/2]

void UWMPhy_modem::endRx ( Packet *  p)
protectedvirtual

Method to end a packet reception. This method is also in charge to send the received NS-Miracle packet (as recovered from the received acoustic packet) to the above layers of the simulator.

Parameters
ppointer to the last received packet.

References hdr_uwal::binPkt(), hdr_uwal::binPktLength(), UWMdriver::getRxPayload(), LOG_LEVEL_DEBUG, PktRx, pmDriver, UWMdriver::printOnLog(), UWMdriver::resetModemStatus(), and updatePktRx().

Referenced by MS2C_Evo_lowlev::check_modem().

Here is the call graph for this function:

◆ endTx() [1/2]

virtual void UWMPhy_modem::endTx ( Packet *  )
protectedvirtual

Method to end a packet transmission. This method is also in charge to send a cross layer message Phy2MacEndTx(p) to notify the above layers of the simulator about the end of a transmission, see http://telecom.dei.unipd.it/ns/miracle/doxygen/classMPhy.html#c8c2f52d3833fed8ac736aca0ee52c98.

Parameters
ppointer to the last transmitted packet.

◆ endTx() [2/2]

void UWMPhy_modem::endTx ( Packet *  p)
protectedvirtual

Method to end a packet transmission. This method is also in charge to send a cross layer message Phy2MacEndTx(p) to notify the above layers of the simulator about the end of a transmission, see http://telecom.dei.unipd.it/ns/miracle/doxygen/classMPhy.html#c8c2f52d3833fed8ac736aca0ee52c98.

Parameters
ppointer to the last transmitted packet.

References LOG_LEVEL_DEBUG, pmDriver, and UWMdriver::printOnLog().

Referenced by MS2C_Evo_lowlev::check_modem(), and recv().

Here is the call graph for this function:

◆ getDebug() [1/2]

int UWMPhy_modem::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UWMPhy_modem::debug_

References debug_.

◆ getDebug() [2/2]

int UWMPhy_modem::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UWMPhy_modem::debug_

References debug_.

Referenced by UWMdriver::UWMdriver().

◆ getEpoch() [1/2]

unsigned long int UWMPhy_modem::getEpoch ( )
inline

Calculate the epoch of the event. Used in sea-trial mode

Returns
the epoch of the system

◆ getEpoch() [2/2]

unsigned long int UWMPhy_modem::getEpoch ( )
inline

Calculate the epoch of the event. Used in sea-trial mode

Returns
the epoch of the system

Referenced by start().

◆ getID() [1/2]

int UWMPhy_modem::getID ( )
inline

Method to return the node ID.

Returns
UWMPhy_modem::ID

References ID.

◆ getID() [2/2]

int UWMPhy_modem::getID ( )
inline

Method to return the node ID.

Returns
UWMPhy_modem::ID

References ID.

Referenced by UWMdriver::UWMdriver().

◆ getLogFile() [1/2]

std::string UWMPhy_modem::getLogFile ( )
inline

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

Returns
UWMPhy_modem::logFile

References logFile.

◆ getLogFile() [2/2]

std::string UWMPhy_modem::getLogFile ( )
inline

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

Returns
UWMPhy_modem::logFile

References logFile.

Referenced by UWMdriver::getLogFile().

◆ getLogLevel() [1/2]

log_level_t UWMPhy_modem::getLogLevel ( )
inline

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

Returns
UWMPhy_modem::log_

References loglevel_.

◆ getLogLevel() [2/2]

log_level_t UWMPhy_modem::getLogLevel ( )
inline

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

Returns
UWMPhy_modem::log_

References loglevel_.

Referenced by UWMdriver::getLogLevel().

◆ getModulationType() [1/2]

virtual int UWMPhy_modem::getModulationType ( Packet *  p)
inlineprotectedvirtual

Method to get the modulation type used to transmit/receive a given packet. NOTE: not implemented or used at the moment.

Parameters
pa pointer to the packet for which to return the modulation used.
Returns
the modulation type.

◆ getModulationType() [2/2]

virtual int UWMPhy_modem::getModulationType ( Packet *  p)
inlineprotectedvirtual

Method to get the modulation type used to transmit/receive a given packet. NOTE: not implemented or used at the moment.

Parameters
pa pointer to the packet for which to return the modulation used.
Returns
the modulation type.

◆ getPathToDevice() [1/2]

std::string UWMPhy_modem::getPathToDevice ( )
inline

Method to return the path to the device to be connect with the network simulator.

Returns
UWMPhy_modem::pToDevice

References pToDevice.

◆ getPathToDevice() [2/2]

std::string UWMPhy_modem::getPathToDevice ( )
inline

Method to return the path to the device to be connect with the network simulator.

Returns
UWMPhy_modem::pToDevice

References pToDevice.

◆ getPeriod() [1/2]

double UWMPhy_modem::getPeriod ( )
inline

Method to return the checking period of the modem (i.e., the time interval between two succesive checks on the modem buffer).

Returns
UWMPhy_modem::period

References period.

◆ getPeriod() [2/2]

double UWMPhy_modem::getPeriod ( )
inline

Method to return the checking period of the modem (i.e., the time interval between two succesive checks on the modem buffer).

Returns
UWMPhy_modem::period

References period.

◆ getQueueLength() [1/2]

uint UWMPhy_modem::getQueueLength ( )
inline

References queue_length.

◆ getQueueLength() [2/2]

uint UWMPhy_modem::getQueueLength ( )
inline

References queue_length.

Referenced by UWMdriver::setConnections().

◆ getTxDuration() [1/2]

virtual double UWMPhy_modem::getTxDuration ( Packet *  p)
inlineprotectedvirtual

Method to get the transmission duration for a given packet. NOTE: not implemented or used at the moment.

Parameters
pa pointer to the packet for which to return the duration.
Returns
the transmission duration.

◆ getTxDuration() [2/2]

virtual double UWMPhy_modem::getTxDuration ( Packet *  p)
inlineprotectedvirtual

Method to get the transmission duration for a given packet. NOTE: not implemented or used at the moment.

Parameters
pa pointer to the packet for which to return the duration.
Returns
the transmission duration.

◆ popTxBuff() [1/2]

Packet * UWMPhy_modem::popTxBuff ( )
protected

Method to pop the oldest packet in the TX buffer or to delete after a tx or to drop it.

Parameters
temppointer to the popped packet.

◆ popTxBuff() [2/2]

Packet * UWMPhy_modem::popTxBuff ( )
protected

Method to pop the oldest packet in the TX buffer or to delete after a tx or to drop it.

Parameters
temppointer to the popped packet.

References modemTxBuff, and t.

Referenced by MS2C_Evo_lowlev::check_modem(), and recv().

◆ recv() [1/2]

virtual void UWMPhy_modem::recv ( Packet *  )
virtual

Method to handle 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's upper layers.

◆ recv() [2/2]

void UWMPhy_modem::recv ( Packet *  p)
virtual

Method to handle 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's upper layers.

References hdr_uwal::binPkt(), hdr_uwal::binPktLength(), check_modem(), endTx(), UWMdriver::getStatus(), LOG_LEVEL_ERROR, LOG_LEVEL_INFO, MODEM_CFG, MODEM_IDLE, MODEM_IDLE_RX, MODEM_RESET, MODEM_RX, MODEM_TX, modemTxBuff, PktRx, pmDriver, popTxBuff(), UWMdriver::printOnLog(), UWMdriver::resetModemStatus(), startTx(), t, and UWMdriver::updateTx().

Here is the call graph for this function:

◆ recvSyncClMsg() [1/2]

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

Implemented in MS2C_Evo_lowlev.

◆ recvSyncClMsg() [2/2]

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

Implemented in MS2C_Evo_lowlev.

◆ setConnections() [1/2]

void UWMPhy_modem::setConnections ( CheckTimer ,
UWMdriver ,
DropTimer  
)
protected

Link connector. This method must be used by any derived class D of UWMPhy_modem to link the members pcheckTmr, pmDriver and pmCodec to the corresponding derived objects contained in D;

See also
e.g., MFSK_WHOI_MM or MS2C_EvoLogics
Parameters
[in]pcheckTmr_pointer to a CheckTimer object
[in]pmDriver_pointer to an UWMdriver object
[in]pmCodec_pointer to an UWMcodec object
[out]pcheckTmr(i.e., the member UWMPhy_modem::pcheckTmr)
[out]pmDriver(i.e., the member UWMPhy_modem::pmDriver)
[out]pmCodec(i.e., the member UWMPhy_modem::pmCodec)

◆ setConnections() [2/2]

void UWMPhy_modem::setConnections ( CheckTimer pcheckTmr_,
UWMdriver pmDriver_,
DropTimer pDropTimer_ 
)
protected

Link connector. This method must be used by any derived class D of UWMPhy_modem to link the members pcheckTmr, pmDriver and pmCodec to the corresponding derived objects contained in D;

See also
e.g., MFSK_WHOI_MM or MS2C_EvoLogics
Parameters
[in]pcheckTmr_pointer to a CheckTimer object
[in]pmDriver_pointer to an UWMdriver object
[in]pmCodec_pointer to an UWMcodec object
[out]pcheckTmr(i.e., the member UWMPhy_modem::pcheckTmr)
[out]pmDriver(i.e., the member UWMPhy_modem::pmDriver)
[out]pmCodec(i.e., the member UWMPhy_modem::pmCodec)

References pcheckTmr, pDropTimer, and pmDriver.

Referenced by MS2C_Evo_lowlev::MS2C_Evo_lowlev().

◆ start() [1/2]

virtual void UWMPhy_modem::start ( )
protectedvirtual

Connection starter. This method starts the connection with the modem. It performs all the needed operations to open an host-modem connection (e.g., set up of the connection port's parameters, start of the "check-modem" process).

◆ start() [2/2]

void UWMPhy_modem::start ( )
protectedvirtual

Connection starter. This method starts the connection with the modem. It performs all the needed operations to open an host-modem connection (e.g., set up of the connection port's parameters, start of the "check-modem" process).

References getEpoch(), ID, log_suffix, logFile, outLog, pcheckTmr, period, pmDriver, UWMdriver::setID(), UWMdriver::setModemID(), SetModemID, and UWMdriver::start().

Referenced by command().

Here is the call graph for this function:

◆ startRx() [1/2]

virtual void UWMPhy_modem::startRx ( Packet *  )
protectedvirtual

Method to start a packet reception. This method is also in charge to send a cross layer message Phy2MacStartRx(p) to notify the above layers of the simulator about the start of a reception, see http://telecom.dei.unipd.it/ns/miracle/doxygen/classMPhy.html#a15cc91b98013e1c631ad85072867ab6.

Parameters
ppointer to the last received packet.

◆ startRx() [2/2]

void UWMPhy_modem::startRx ( Packet *  p)
protectedvirtual

Method to start a packet reception. This method is also in charge to send a cross layer message Phy2MacStartRx(p) to notify the above layers of the simulator about the start of a reception, see http://telecom.dei.unipd.it/ns/miracle/doxygen/classMPhy.html#a15cc91b98013e1c631ad85072867ab6.

Parameters
ppointer to the last received packet.

References LOG_LEVEL_DEBUG, pmDriver, and UWMdriver::printOnLog().

Referenced by MS2C_Evo_lowlev::check_modem().

Here is the call graph for this function:

◆ startTx() [1/2]

virtual void UWMPhy_modem::startTx ( Packet *  )
protectedvirtual

Method to send to an UWMdriver object the packet to be transmitted, see UWMdriver::modemTx().

Parameters
ppointer to the packet to be transmitted.

◆ startTx() [2/2]

void UWMPhy_modem::startTx ( Packet *  p)
protectedvirtual

Method to send to an UWMdriver object the packet to be transmitted, see UWMdriver::modemTx().

Parameters
ppointer to the packet to be transmitted.

References LOG_LEVEL_DEBUG, UWMdriver::modemTx(), pmDriver, and UWMdriver::printOnLog().

Referenced by recv().

Here is the call graph for this function:

◆ stop() [1/2]

virtual void UWMPhy_modem::stop ( )
protectedvirtual

Connection stopper. This method should be used before stopping the simulation. It closes and, if needed, resets all the opened files and ports.

◆ stop() [2/2]

void UWMPhy_modem::stop ( )
protectedvirtual

Connection stopper. This method should be used before stopping the simulation. It closes and, if needed, resets all the opened files and ports.

References pcheckTmr, pmDriver, and UWMdriver::stop().

Referenced by command().

Here is the call graph for this function:

◆ updatePktRx() [1/2]

void UWMPhy_modem::updatePktRx ( Packet *  )

Method to update the value of the pointer to the last received packet. This method should be used by an object of the class UWMcodec.

See also
UWMcodec
Parameters
[in]ppointer to the last received packet (recovered from the last received acoustic message)
[out]PktRx(i.e., the member UWMPhy_modem::PktRx)

◆ updatePktRx() [2/2]

void UWMPhy_modem::updatePktRx ( Packet *  p)

Method to update the value of the pointer to the last received packet. This method should be used by an object of the class UWMcodec.

See also
UWMcodec
Parameters
[in]ppointer to the last received packet (recovered from the last received acoustic message)
[out]PktRx(i.e., the member UWMPhy_modem::PktRx)

References PktRx.

Referenced by endRx().

Friends And Related Symbol Documentation

◆ CheckTimer

CheckTimer
friend

Friend class used to implement the timer handler.

See also
CheckTimer

◆ DropTimer

DropTimer
friend

Member Data Documentation

◆ debug_

int UWMPhy_modem::debug_
protected

Flag to enable debug mode (i.e., printing of debug messages) if set to 1.

Referenced by getDebug(), and UWMPhy_modem().

◆ ID

int UWMPhy_modem::ID
protected

ID of the node. NOTE: when the node transmits, this value must coincide with the source ID.

Referenced by getID(), start(), and UWMPhy_modem().

◆ log_suffix

char * UWMPhy_modem::log_suffix
protected

Possibility to insert a log suffix

Referenced by command(), and start().

◆ logFile

std::string UWMPhy_modem::logFile
protected

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

Referenced by getLogFile(), and start().

◆ loglevel_

int UWMPhy_modem::loglevel_
protected

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

Referenced by getLogLevel(), and UWMPhy_modem().

◆ modemTxBuff

Packet * UWMPhy_modem::modemTxBuff
protected

Transmission buffer to store packets that cannot be sent immediately because the real acoustic modem is busy (receiving or transmitting).

Referenced by popTxBuff(), recv(), and UWMPhy_modem().

◆ outLog

std::ofstream UWMPhy_modem::outLog
protected

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

Referenced by start().

◆ pcheckTmr

CheckTimer * UWMPhy_modem::pcheckTmr
protected

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

Referenced by setConnections(), start(), stop(), and UWMPhy_modem().

◆ pDropTimer

DropTimer * UWMPhy_modem::pDropTimer
protected

Referenced by setConnections(), and UWMPhy_modem().

◆ period

double UWMPhy_modem::period
protected

Checking period of the modem's buffer.

Referenced by getPeriod(), start(), and UWMPhy_modem().

◆ PktRx

Packet * UWMPhy_modem::PktRx
protected

Transmission buffer's index; it must be in {-1, 0, 1, ..., _MTBL-1}. Address of the last received packet.

Referenced by MS2C_Evo_lowlev::check_modem(), endRx(), recv(), updatePktRx(), and UWMPhy_modem().

◆ pmDriver

UWMdriver * UWMPhy_modem::pmDriver
protected

Pointer to an object to drive the modem operations.

Referenced by MS2C_Evo_lowlev::check_modem(), endRx(), endTx(), DropTimer::expire(), recv(), setConnections(), start(), startRx(), startTx(), stop(), and UWMPhy_modem().

◆ pToDevice

std::string UWMPhy_modem::pToDevice
protected

A string containing the path to the device to be connected with the network simulator.

Referenced by getPathToDevice(), and UWMPhy_modem().

◆ queue_length

uint UWMPhy_modem::queue_length
protected

Referenced by getQueueLength(), and UWMPhy_modem().

◆ SetModemID

int UWMPhy_modem::SetModemID
protected

Flag to indicate if the interface has to force the modem to have the ID indicated in the tcl script

Referenced by start(), and UWMPhy_modem().

◆ t

int UWMPhy_modem::t
protected

Referenced by popTxBuff(), recv(), and UWMPhy_modem().


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