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

#include <uwahoimodem.h>

Inheritance diagram for UwAhoiModem:
Collaboration diagram for UwAhoiModem:

Public Types

enum class  ModemState { AVAILABLE = 0 , TRANSMITTING , CONFIGURING }
 
enum class  TransmissionState { TX_IDLE = 0 , TX_WAITING }
 
- Public Types inherited from UwModem
enum class  LogLevel { ERROR = 0 , INFO = 1 , DEBUG = 2 }
 

Public Member Functions

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

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 ()
 
void updateStatus (std::shared_ptr< ahoi::packet_t > packet)
 
ahoi::packet_t fillAhoiPkt (Packet *p)
 
void createRxPacket (Packet *p)
 
bool parseFooter (std::shared_ptr< ahoi::footer_t > footer)
 
bool storePacketInfo (std::shared_ptr< ahoi::packet_t > header, Packet *p)
 
void updateSN ()
 

Private Attributes

std::unique_ptr< UwConnectorp_connector
 
std::unique_ptr< UwInterpreterAhoip_interpreter
 
ModemState status
 
TransmissionState tx_status
 
std::mutex status_m
 
std::mutex tx_status_m
 
std::mutex tx_queue_m
 
std::condition_variable status_cv
 
std::condition_variable tx_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
 
double virtual_time_ref
 
std::chrono::milliseconds WAIT_DELIVERY
 
ahoi::packet_t tmpPacket
 
uint id
 
int parity_bit
 
int stop_bit
 
int flow_control
 
int baud_rate
 
uint power
 
uint rssi
 
uint bit_errors
 
uint agc_mean
 
uint agc_min
 
uint agc_max
 

Static Private Attributes

static const std::chrono::milliseconds MODEM_TIMEOUT
 
static uint MAX_RETX = 0
 
static uint8_t sn = 0
 
static const double EPSILON_S
 
static uint WAIT_DELIVERY_INT = 3000
 

Additional Inherited Members

- 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

The ahoi! modems are an underwater acoustic modems developed by TUUH University, Hamburg by the SmartPORT Group.

The reference website can be found here: https://www.tuhh.de/smartport/research/acoustic-modem.html

Definition at line 56 of file uwahoimodem.h.

Member Enumeration Documentation

◆ ModemState

enum class UwAhoiModem::ModemState
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 
CONFIGURING 

Definition at line 65 of file uwahoimodem.h.

◆ TransmissionState

enum class UwAhoiModem::TransmissionState
strong

Enum type for the trasnmission state.

TX_IDLE: the modem is available for transmission of a new packet TX_WAITING: a packet was tranmitted but the command was not acknowledged

Enumerator
TX_IDLE 
TX_WAITING 

Definition at line 72 of file uwahoimodem.h.

Constructor & Destructor Documentation

◆ UwAhoiModem()

UwAhoiModem::UwAhoiModem ( )

Constructor of the UwAhoiModem 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 73 of file uwahoimodem.cpp.

◆ ~UwAhoiModem()

UwAhoiModem::~UwAhoiModem ( )
virtual

Destructor of the UwAhoiModem class.

Definition at line 116 of file uwahoimodem.cpp.

Member Function Documentation

◆ command()

int UwAhoiModem::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 164 of file uwahoimodem.cpp.

◆ createRxPacket()

void UwAhoiModem::createRxPacket ( Packet *  p)
private

Method that fills up a packet with the needed header and payload and makes it ready to be sent to the layer above.

Parameters
pinstance of an empty packet to be filled

Definition at line 450 of file uwahoimodem.cpp.

◆ endRx()

void UwAhoiModem::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 262 of file uwahoimodem.cpp.

◆ fillAhoiPkt()

ahoi::packet_t UwAhoiModem::fillAhoiPkt ( Packet *  p)
private

Method that fills the fields of an ahoi! packet with the needed values, so that later it can be serialized.

param p Packet pointer of the DESERT packet

Definition at line 229 of file uwahoimodem.cpp.

◆ parseFooter()

bool UwAhoiModem::parseFooter ( std::shared_ptr< ahoi::footer_t >  footer)
private

Method that extarcts fields from a provided ahoi! packet and save the info values to class field for later access.

Info parameters include values such as received power, RSSI, number of corrupted packets, ecc...

Parameters
packetthe packet from which to extract the values

Definition at line 490 of file uwahoimodem.cpp.

◆ receivingData()

void UwAhoiModem::receivingData ( )
privatevirtual

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

Definition at line 393 of file uwahoimodem.cpp.

◆ recv()

void UwAhoiModem::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 122 of file uwahoimodem.cpp.

◆ recvSyncClMsg()

int UwAhoiModem::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 170 of file uwahoimodem.cpp.

◆ start()

void UwAhoiModem::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 269 of file uwahoimodem.cpp.

◆ startRx()

void UwAhoiModem::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 255 of file uwahoimodem.cpp.

◆ startTx()

void UwAhoiModem::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 176 of file uwahoimodem.cpp.

◆ stop()

void UwAhoiModem::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 322 of file uwahoimodem.cpp.

◆ storePacketInfo()

bool UwAhoiModem::storePacketInfo ( std::shared_ptr< ahoi::packet_t >  header,
Packet *  p 
)
private

Method that extarcts fields from a provided ahoi! packet and save the info values to class field for later access.

Info parameters include values such as received power, RSSI, number of corrupted packets, ecc...

Parameters
headerahoi header the packet from which to extract the values
pns2 packet in which to save the destination address, ecc...

Definition at line 461 of file uwahoimodem.cpp.

◆ transmittingData()

void UwAhoiModem::transmittingData ( )
privatevirtual

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

Definition at line 342 of file uwahoimodem.cpp.

◆ updateSN()

void UwAhoiModem::updateSN ( )
private

Method for Sequence Number (SN) update.

Definition at line 577 of file uwahoimodem.cpp.

◆ updateStatus()

void UwAhoiModem::updateStatus ( std::shared_ptr< ahoi::packet_t >  packet)
private

Method that updates the status of the modem State Machine: state change is triggered by recepting the response packet from the ahoi! modem on the connector interface.

Parameters
packetpacket received on the connector interface

Definition at line 503 of file uwahoimodem.cpp.

Member Data Documentation

◆ agc_max

uint UwAhoiModem::agc_max
private

Maximum gain set by the AGC (if used) in reception of the last packet.

Definition at line 286 of file uwahoimodem.h.

◆ agc_mean

uint UwAhoiModem::agc_mean
private

Mean gain set by the AGC (if used) in reception of the last packet.

Definition at line 282 of file uwahoimodem.h.

◆ agc_min

uint UwAhoiModem::agc_min
private

Minimum gain set by the AGC (if used) in reception of the last packet.

Definition at line 284 of file uwahoimodem.h.

◆ baud_rate

int UwAhoiModem::baud_rate
private

Integer for port baud rate.

Definition at line 272 of file uwahoimodem.h.

◆ bit_errors

uint UwAhoiModem::bit_errors
private

Number of repaired bit errors during reception in the last packet.

Definition at line 280 of file uwahoimodem.h.

◆ EPSILON_S

const double UwAhoiModem::EPSILON_S
staticprivate

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

Definition at line 248 of file uwahoimodem.h.

◆ flow_control

int UwAhoiModem::flow_control
private

flag for flow control

Definition at line 270 of file uwahoimodem.h.

◆ id

uint UwAhoiModem::id
private

Modem ID, to be set in simulation.

Definition at line 263 of file uwahoimodem.h.

◆ MAX_RETX

uint UwAhoiModem::MAX_RETX = 0
staticprivate

Maximum number of retransmissions for the same packet.

Definition at line 239 of file uwahoimodem.h.

◆ MODEM_TIMEOUT

const std::chrono::milliseconds UwAhoiModem::MODEM_TIMEOUT
staticprivate
Initial value:
=
std::chrono::milliseconds(3600)

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

Definition at line 237 of file uwahoimodem.h.

◆ p_connector

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

Pointer to Connector object that interfaces with the device.

Definition at line 204 of file uwahoimodem.h.

◆ p_interpreter

std::unique_ptr<UwInterpreterAhoi> UwAhoiModem::p_interpreter
private

Pointer to Interpreter object to parse device syntax.

Definition at line 207 of file uwahoimodem.h.

◆ parity_bit

int UwAhoiModem::parity_bit
private

flag for parity bit

Definition at line 266 of file uwahoimodem.h.

◆ power

uint UwAhoiModem::power
private

Received power (RMSE) ratio and "ideal packet".

Above 100 = clipping

Definition at line 276 of file uwahoimodem.h.

◆ receiving

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

Atomic boolean variable that controls the receiving looping thread.

Definition at line 227 of file uwahoimodem.h.

◆ rssi

uint UwAhoiModem::rssi
private

RSSI vs an "ideal packet".

Above 100 = clipping

Definition at line 278 of file uwahoimodem.h.

◆ rx_payload

std::string UwAhoiModem::rx_payload
private

String that is updated witn each new received messsage.

Definition at line 235 of file uwahoimodem.h.

◆ rx_thread

std::thread UwAhoiModem::rx_thread
private

Object with the rx thread.

Definition at line 231 of file uwahoimodem.h.

◆ sn

uint8_t UwAhoiModem::sn = 0
staticprivate

Sequence number, which follows all the packets transmitted to the modem.

Definition at line 242 of file uwahoimodem.h.

◆ status

ModemState UwAhoiModem::status
private

Variable holding the current status of the modem.

Definition at line 209 of file uwahoimodem.h.

◆ status_cv

std::condition_variable UwAhoiModem::status_cv
private

Condition variable to wait for ModemState::AVAILABLE.

Definition at line 221 of file uwahoimodem.h.

◆ status_m

std::mutex UwAhoiModem::status_m
private

Mutex associated with the state machine of the modem.

Definition at line 215 of file uwahoimodem.h.

◆ stop_bit

int UwAhoiModem::stop_bit
private

flag for stop bit

Definition at line 268 of file uwahoimodem.h.

◆ tmpPacket

ahoi::packet_t UwAhoiModem::tmpPacket
private

Packet to be checked to unlock state machine.

Definition at line 260 of file uwahoimodem.h.

◆ transmitting

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

Atomic boolean variable that controls the transmitting looping thread.

Definition at line 229 of file uwahoimodem.h.

◆ tx_queue_cv

std::condition_variable UwAhoiModem::tx_queue_cv
private

Condition variable that is linked with the transmitting queue.

Definition at line 225 of file uwahoimodem.h.

◆ tx_queue_m

std::mutex UwAhoiModem::tx_queue_m
private

Mutex associated with the transmission queue.

Definition at line 219 of file uwahoimodem.h.

◆ tx_status

TransmissionState UwAhoiModem::tx_status
private

Variable holding the current transmission status of the modem.

Definition at line 211 of file uwahoimodem.h.

◆ tx_status_cv

std::condition_variable UwAhoiModem::tx_status_cv
private

Condition variable to wait for TransmissionState::TX_IDLE.

Definition at line 223 of file uwahoimodem.h.

◆ tx_status_m

std::mutex UwAhoiModem::tx_status_m
private

Mutex associated with the state machine of the transmission process.

Definition at line 217 of file uwahoimodem.h.

◆ tx_thread

std::thread UwAhoiModem::tx_thread
private

Object with the tx thread.

Definition at line 233 of file uwahoimodem.h.

◆ virtual_time_ref

double UwAhoiModem::virtual_time_ref
private

virtual time reference

Definition at line 245 of file uwahoimodem.h.

◆ WAIT_DELIVERY

std::chrono::milliseconds UwAhoiModem::WAIT_DELIVERY
private

Time interval to wait for the modem notifying the response of a given packet.

Definition at line 252 of file uwahoimodem.h.

◆ WAIT_DELIVERY_INT

uint UwAhoiModem::WAIT_DELIVERY_INT = 3000
staticprivate

Time interval matching the WAIT_DELIVERY variable: version of type int to match the chrono one, needed because TclObject::bind does not support binding std::chrono variable [milliseconds]

Definition at line 257 of file uwahoimodem.h.


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