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

#include <uw-csma-ca.h>

Inheritance diagram for CsmaCa:
Collaboration diagram for CsmaCa:

Classes

class  CsmaCaTimer
 

Public Member Functions

 CsmaCa ()
 
virtual ~CsmaCa ()
 
virtual int command (int argc, const char *const *argv)
 

Protected Member Functions

virtual void recvFromUpperLayers (Packet *p)
 
virtual void Mac2PhyStartTx (Packet *p)
 
virtual void Phy2MacEndTx (const Packet *p)
 
virtual void Phy2MacStartRx (const Packet *p)
 
virtual void Phy2MacEndRx (Packet *p)
 
virtual void dropPacket (Packet *p, csma_ca_pkt_type_t type, char *reason)
 
csma_ca_states_t getState ()
 
void updateState (csma_ca_states_t s)
 
csma_ca_log_level_t getLogLevel ()
 
int getQueueSize ()
 
time_t getEpoch ()
 
string getLogFile ()
 
virtual void state_Wait_CTS ()
 
virtual void state_Wait_Data ()
 
virtual void state_Idle ()
 
virtual void state_Backoff (int tx_time)
 
virtual int stateRxData (Packet *p)
 
virtual int stateRxRTS (hdr_ca_RTS *rts, int mac_src, int mac_dst)
 
virtual int stateRxCTS (hdr_ca_CTS *cts, int mac_src, int mac_dst)
 
virtual int stateRxACK (Packet *ack)
 
virtual void stateTxCTS ()
 
virtual int stateTxData ()
 
virtual void state_Wait_ACK ()
 
virtual void stateTxAck (int mac_dst)
 
virtual void initializeLog ()
 

Protected Attributes

CsmaCaTimer backoff_timer
 
CsmaCaTimer cts_timer
 
CsmaCaTimer data_timer
 
CsmaCaTimer ack_timer
 

Private Member Functions

void printonLog (csma_ca_log_level_t level, string log)
 
void extractDataPacket ()
 
int txData ()
 
int txRTS (int mac_dest)
 
int txCTS (int mac_dest)
 
int txAck ()
 
void data_timer_fired ()
 
void backoff_timer_fired ()
 
void cts_timer_fired ()
 
void ack_timer_fired ()
 
int computeTxTime ()
 
void buildRTShdr (hdr_ca_RTS **rts, uint8_t tx_time)
 
void buildCTShdr (hdr_ca_CTS **cts, uint8_t tx_time)
 
Packet * buildPacket (int mac_dest, csma_ca_pkt_type_t type, uint8_t tx_time)
 

Private Attributes

int max_queue_size
 
int data_size
 
int bitrate
 
int backoff_delta
 
int backoff_max
 
int cts_wait_val
 
int data_wait_val
 
int ack_wait_val
 
int actual_mac_data_src
 
int actual_expected_tx_time
 
Packet * actual_data_packet
 
std::queue< Packet * > data_q
 
ack_modes_t ack_mode
 
csma_ca_states_t state
 
csma_ca_states_t previous_state
 
std::ofstream outLog
 
csma_ca_log_level_t log_level
 
string logfile
 
int n_rts_rx
 
int n_cts_rx
 
int data_pkt_dropped
 
int cts_pkt_dropped
 
int rts_pkt_dropped
 
int ack_pkt_dropped
 

Detailed Description

Class that describes a CsmaAloha module.

Definition at line 96 of file uw-csma-ca.h.

Constructor & Destructor Documentation

◆ CsmaCa()

CsmaCa::CsmaCa ( )

Definition at line 130 of file uw-csma-ca.cpp.

◆ ~CsmaCa()

CsmaCa::~CsmaCa ( )
virtual

Definition at line 161 of file uw-csma-ca.cpp.

Member Function Documentation

◆ ack_timer_fired()

void CsmaCa::ack_timer_fired ( )
private

ACK timer is expired.

Definition at line 185 of file uw-csma-ca.cpp.

◆ backoff_timer_fired()

void CsmaCa::backoff_timer_fired ( )
private

backoff timer is expired

Definition at line 194 of file uw-csma-ca.cpp.

◆ buildCTShdr()

void CsmaCa::buildCTShdr ( hdr_ca_CTS **  cts,
uint8_t  tx_time 
)
private

Build an CTS header.

Parameters
hdr_ca_CTS**pointer to CTS header to be built
uint8_texpected tx time of DATA packet

Definition at line 621 of file uw-csma-ca.cpp.

◆ buildPacket()

Packet * CsmaCa::buildPacket ( int  mac_dest,
csma_ca_pkt_type_t  type,
uint8_t  tx_time 
)
private

Build a generic packet.

Parameters
intMAC destination
csma_ca_pkt_type_ttype of packet to build
uint8_texpected tx time of DATA packet

Definition at line 627 of file uw-csma-ca.cpp.

◆ buildRTShdr()

void CsmaCa::buildRTShdr ( hdr_ca_RTS **  rts,
uint8_t  tx_time 
)
private

Build an RTS header.

Parameters
hdr_ca_RTS**pointer to RTS header to be built
uint8_texpected tx time of DATA packet

Definition at line 615 of file uw-csma-ca.cpp.

◆ command()

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

TCL command interpreter.

It implements the following OTcl 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.

Definition at line 74 of file uw-csma-ca.cpp.

◆ computeTxTime()

int CsmaCa::computeTxTime ( )
inlineprivate

Compute transmission time of a packet using known bitrate.

Returns
int tranmission time

Definition at line 351 of file uw-csma-ca.h.

◆ cts_timer_fired()

void CsmaCa::cts_timer_fired ( )
private

CTS timer is expired.

Definition at line 205 of file uw-csma-ca.cpp.

◆ data_timer_fired()

void CsmaCa::data_timer_fired ( )
private

data timer is expired

Definition at line 217 of file uw-csma-ca.cpp.

◆ dropPacket()

void CsmaCa::dropPacket ( Packet *  p,
csma_ca_pkt_type_t  type,
char *  reason 
)
protectedvirtual

Drop the packet logging the reason and incrementing the counters.

Parameters
Packet*Pointer to packet to be ack_pkt_dropped
csma_ca_pkt_type_ttype of the packet dropped
char*Reason for drop

Definition at line 537 of file uw-csma-ca.cpp.

◆ extractDataPacket()

void CsmaCa::extractDataPacket ( )
private

Extract data packet from queue.

Definition at line 523 of file uw-csma-ca.cpp.

◆ getEpoch()

time_t CsmaCa::getEpoch ( )
inlineprotected

Return the system epoch.

Returns
time_t epoch

Definition at line 209 of file uw-csma-ca.h.

◆ getLogFile()

string CsmaCa::getLogFile ( )
inlineprotected

Return name of the log file.

Returns
string file name

Definition at line 218 of file uw-csma-ca.h.

◆ getLogLevel()

csma_ca_log_level_t CsmaCa::getLogLevel ( )
inlineprotected

Return the current log level of the protocol.

Returns
csma_ca_log_t log level

Definition at line 191 of file uw-csma-ca.h.

◆ getQueueSize()

int CsmaCa::getQueueSize ( )
inlineprotected

Return the size of the data packet queue.

Returns
int queue size

Definition at line 200 of file uw-csma-ca.h.

◆ getState()

csma_ca_states_t CsmaCa::getState ( )
inlineprotected

Get the state of the protocol.

Returns
csma_ca_state_t Current state

Definition at line 172 of file uw-csma-ca.h.

◆ initializeLog()

void CsmaCa::initializeLog ( )
protectedvirtual

Initializes the protocol at the beginning of the simulation.

This method is called by a command in tcl.

Definition at line 228 of file uw-csma-ca.cpp.

◆ Mac2PhyStartTx()

void CsmaCa::Mac2PhyStartTx ( Packet *  p)
protectedvirtual

Pass the packet to the PHY layer.

Parameters
Packet*Pointer to an object of type Packet that represent the Packet to transmit

Definition at line 241 of file uw-csma-ca.cpp.

◆ Phy2MacEndRx()

void CsmaCa::Phy2MacEndRx ( Packet *  p)
protectedvirtual

Method called when the Phy Layer finish to receive a Packet.

Parameters
Packet*Pointer to an object of type Packet that represent the Packet received

Definition at line 247 of file uw-csma-ca.cpp.

◆ Phy2MacEndTx()

void CsmaCa::Phy2MacEndTx ( const Packet *  p)
protectedvirtual

Method called when the PHY layer finish to transmit the packet.

Parameters
Packet*Pointer to an object of type Packet that represent the Packet transmitted

Definition at line 487 of file uw-csma-ca.cpp.

◆ Phy2MacStartRx()

void CsmaCa::Phy2MacStartRx ( const Packet *  p)
protectedvirtual

Method called when the Phy Layer start to receive a Packet.

Parameters
constPacket* Pointer to an object of type Packet that represent the Packet that is in reception

Definition at line 472 of file uw-csma-ca.cpp.

◆ printonLog()

void CsmaCa::printonLog ( csma_ca_log_level_t  level,
string  log 
)
private

Print a message on log file.

Parameters
csma_ca_log_level_tlog level of the message
stringActual message

Definition at line 668 of file uw-csma-ca.cpp.

◆ recvFromUpperLayers()

void CsmaCa::recvFromUpperLayers ( Packet *  p)
protectedvirtual

Receives the packet from the upper layer (e.g.

IP)

Parameters
Packet*pointer to the packet received

Definition at line 509 of file uw-csma-ca.cpp.

◆ state_Backoff()

void CsmaCa::state_Backoff ( int  tx_time)
protectedvirtual

Backoff state.

Parameters
intTransmission time sent on over-heared RTS

Definition at line 463 of file uw-csma-ca.cpp.

◆ state_Idle()

void CsmaCa::state_Idle ( )
protectedvirtual

Protocol in IDLE state.

Definition at line 427 of file uw-csma-ca.cpp.

◆ state_Wait_ACK()

void CsmaCa::state_Wait_ACK ( )
protectedvirtual

Wait for an ACK after a data transmission.

Definition at line 479 of file uw-csma-ca.cpp.

◆ state_Wait_CTS()

void CsmaCa::state_Wait_CTS ( )
protectedvirtual

Waiting for CTS packet.

Definition at line 599 of file uw-csma-ca.cpp.

◆ state_Wait_Data()

void CsmaCa::state_Wait_Data ( )
protectedvirtual

Waiting for DATA packet.

Definition at line 607 of file uw-csma-ca.cpp.

◆ stateRxACK()

int CsmaCa::stateRxACK ( Packet *  ack)
protectedvirtual

Reception of an ACK packet.

Parameters
hdr_ca_ACK*pointer to RTS header in packet
intsource MAC of packet
intdestination MAC of the packet

Definition at line 321 of file uw-csma-ca.cpp.

◆ stateRxCTS()

int CsmaCa::stateRxCTS ( hdr_ca_CTS cts,
int  mac_src,
int  mac_dst 
)
protectedvirtual

Reception of an CTS packet.

Parameters
hdr_ca_CTS*pointer to RTS header in packet
intsource MAC of packet
intdestination MAC of the packet

Definition at line 437 of file uw-csma-ca.cpp.

◆ stateRxData()

int CsmaCa::stateRxData ( Packet *  p)
protectedvirtual

Transmit a data packet.

Parameters
Packet*Pointer to data packet to be transmitted

Definition at line 352 of file uw-csma-ca.cpp.

◆ stateRxRTS()

int CsmaCa::stateRxRTS ( hdr_ca_RTS rts,
int  mac_src,
int  mac_dst 
)
protectedvirtual

Reception of an RTS packet.

Parameters
hdr_ca_RTS*pointer to RTS header in packet
intsource MAC of packet
intdestination MAC of the packet

Definition at line 380 of file uw-csma-ca.cpp.

◆ stateTxAck()

void CsmaCa::stateTxAck ( int  mac_dst)
protectedvirtual

Tranmission of an ACK.

Parameters
intdestination MAC address

Definition at line 344 of file uw-csma-ca.cpp.

◆ stateTxCTS()

void CsmaCa::stateTxCTS ( )
protectedvirtual

Transmission of a CTS packet.

Definition at line 416 of file uw-csma-ca.cpp.

◆ stateTxData()

int CsmaCa::stateTxData ( )
protectedvirtual

Transmission of a DATA packet.

Definition at line 456 of file uw-csma-ca.cpp.

◆ txAck()

int CsmaCa::txAck ( )
private

Actually transmit an ACK.

◆ txCTS()

int CsmaCa::txCTS ( int  mac_dest)
private

Actually transmit a CTS packet.

Parameters
intdestination MAC

Definition at line 572 of file uw-csma-ca.cpp.

◆ txData()

int CsmaCa::txData ( )
private

Actually transmit a DATA packet.

Definition at line 586 of file uw-csma-ca.cpp.

◆ txRTS()

int CsmaCa::txRTS ( int  mac_dest)
private

Actually transmit a RTS packet.

Parameters
intdestination MAC

Definition at line 559 of file uw-csma-ca.cpp.

◆ updateState()

void CsmaCa::updateState ( csma_ca_states_t  s)
inlineprotected

Update the state of the protocol.

Parameters
csma_ca_state_tnew state

Definition at line 181 of file uw-csma-ca.h.

Member Data Documentation

◆ ack_mode

ack_modes_t CsmaCa::ack_mode
private

ACK mode (configurable.

Definition at line 392 of file uw-csma-ca.h.

◆ ack_pkt_dropped

int CsmaCa::ack_pkt_dropped
private

ACK packet dropped.

Definition at line 407 of file uw-csma-ca.h.

◆ ack_timer

CsmaCaTimer CsmaCa::ack_timer
protected

ACK timer.

Definition at line 292 of file uw-csma-ca.h.

◆ ack_wait_val

int CsmaCa::ack_wait_val
private

Timer duration of ACK.

Definition at line 385 of file uw-csma-ca.h.

◆ actual_data_packet

Packet* CsmaCa::actual_data_packet
private

Pointer to DATA packet we are handling.

Definition at line 390 of file uw-csma-ca.h.

◆ actual_expected_tx_time

int CsmaCa::actual_expected_tx_time
private

Tx time of DATA packet we are handling.

Definition at line 389 of file uw-csma-ca.h.

◆ actual_mac_data_src

int CsmaCa::actual_mac_data_src
private

Source MAC of DATA packet we are handling.

Definition at line 388 of file uw-csma-ca.h.

◆ backoff_delta

int CsmaCa::backoff_delta
private

Delta value (configurable) to be added to backoff.

Definition at line 381 of file uw-csma-ca.h.

◆ backoff_max

int CsmaCa::backoff_max
private

Maximum value in range of backoff.

Definition at line 382 of file uw-csma-ca.h.

◆ backoff_timer

CsmaCaTimer CsmaCa::backoff_timer
protected

Backoff timer.

Definition at line 289 of file uw-csma-ca.h.

◆ bitrate

int CsmaCa::bitrate
private

Bit rate adopted.

Definition at line 380 of file uw-csma-ca.h.

◆ cts_pkt_dropped

int CsmaCa::cts_pkt_dropped
private

CTS packet dropped.

Definition at line 405 of file uw-csma-ca.h.

◆ cts_timer

CsmaCaTimer CsmaCa::cts_timer
protected

CTS timer.

Definition at line 290 of file uw-csma-ca.h.

◆ cts_wait_val

int CsmaCa::cts_wait_val
private

Timer duration of CTS.

Definition at line 383 of file uw-csma-ca.h.

◆ data_pkt_dropped

int CsmaCa::data_pkt_dropped
private

DATA packet dropped.

Definition at line 404 of file uw-csma-ca.h.

◆ data_q

std::queue<Packet *> CsmaCa::data_q
private

Size of DATA packet.

Definition at line 391 of file uw-csma-ca.h.

◆ data_size

int CsmaCa::data_size
private

Size of DATA packet.

Definition at line 379 of file uw-csma-ca.h.

◆ data_timer

CsmaCaTimer CsmaCa::data_timer
protected

Data timer.

Definition at line 291 of file uw-csma-ca.h.

◆ data_wait_val

int CsmaCa::data_wait_val
private

Timer duration of DATA.

Definition at line 384 of file uw-csma-ca.h.

◆ log_level

csma_ca_log_level_t CsmaCa::log_level
private

Current log level chosen for protocol.

Definition at line 398 of file uw-csma-ca.h.

◆ logfile

string CsmaCa::logfile
private

File name of log.

Definition at line 399 of file uw-csma-ca.h.

◆ max_queue_size

int CsmaCa::max_queue_size
private

Maximum dimension of Queue.

Definition at line 378 of file uw-csma-ca.h.

◆ n_cts_rx

int CsmaCa::n_cts_rx
private

CTS received.

Definition at line 403 of file uw-csma-ca.h.

◆ n_rts_rx

int CsmaCa::n_rts_rx
private

RTS received.

Definition at line 402 of file uw-csma-ca.h.

◆ outLog

std::ofstream CsmaCa::outLog
private

Stdout stream of log.

Definition at line 397 of file uw-csma-ca.h.

◆ previous_state

csma_ca_states_t CsmaCa::previous_state
private

Previous state of the protocol.

Definition at line 394 of file uw-csma-ca.h.

◆ rts_pkt_dropped

int CsmaCa::rts_pkt_dropped
private

RTS packet dropped.

Definition at line 406 of file uw-csma-ca.h.

◆ state

csma_ca_states_t CsmaCa::state
private

Current state of the protocol.

Definition at line 393 of file uw-csma-ca.h.


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