#include <uw-csma-aloha.h>
|
enum | CSMA_STATUS {
CSMA_STATE_IDLE = 1
, CSMA_STATE_BACKOFF
, CSMA_STATE_TX_DATA
, CSMA_STATE_TX_ACK
,
CSMA_STATE_WAIT_ACK
, CSMA_STATE_DATA_RX
, CSMA_STATE_ACK_RX
, CSMA_STATE_NOT_SET
,
CSMA_STATE_LISTEN
, CSMA_STATE_CHK_ACK_TIMEOUT
, CSMA_STATE_CHK_LISTEN_TIMEOUT
, CSMA_STATE_CHK_BACKOFF_TIMEOUT
,
CSMA_STATE_RX_IDLE
, CSMA_STATE_RX_LISTEN
, CSMA_STATE_RX_BACKOFF
, CSMA_STATE_RX_WAIT_ACK
,
CSMA_STATE_WRONG_PKT_RX
} |
|
enum | CSMA_REASON_STATUS {
CSMA_REASON_DATA_PENDING
, CSMA_REASON_DATA_RX
, CSMA_REASON_DATA_TX
, CSMA_REASON_ACK_TX
,
CSMA_REASON_ACK_RX
, CSMA_REASON_BACKOFF_TIMEOUT
, CSMA_REASON_ACK_TIMEOUT
, CSMA_REASON_DATA_EMPTY
,
CSMA_REASON_NOT_SET
, CSMA_REASON_MAX_TX_TRIES
, CSMA_REASON_BACKOFF_PENDING
, CSMA_REASON_LISTEN
,
CSMA_REASON_LISTEN_TIMEOUT
, CSMA_REASON_LISTEN_PENDING
, CSMA_REASON_START_RX
, CSMA_REASON_PKT_NOT_FOR_ME
,
CSMA_REASON_WAIT_ACK_PENDING
, CSMA_REASON_PKT_ERROR
} |
|
enum | CSMA_PKT_TYPE { CSMA_ACK_PKT = 1
, CSMA_DATA_PKT
, CSMA_DATAMAX_PKT
} |
|
enum | CSMA_ACK_MODES { CSMA_ACK_MODE = 1
, CSMA_NO_ACK_MODE
} |
|
enum | CSMA_TIMER_STATUS { CSMA_IDLE = 1
, CSMA_RUNNING
, CSMA_FROZEN
, CSMA_EXPIRED
} |
|
Class that describes a CsmaAloha module.
Definition at line 68 of file uw-csma-aloha.h.
◆ CSMA_ACK_MODES
◆ CSMA_PKT_TYPE
Enumerator |
---|
CSMA_ACK_PKT | |
CSMA_DATA_PKT | |
CSMA_DATAMAX_PKT | |
Definition at line 147 of file uw-csma-aloha.h.
◆ CSMA_REASON_STATUS
Enumerator |
---|
CSMA_REASON_DATA_PENDING | |
CSMA_REASON_DATA_RX | |
CSMA_REASON_DATA_TX | |
CSMA_REASON_ACK_TX | |
CSMA_REASON_ACK_RX | |
CSMA_REASON_BACKOFF_TIMEOUT | |
CSMA_REASON_ACK_TIMEOUT | |
CSMA_REASON_DATA_EMPTY | |
CSMA_REASON_NOT_SET | |
CSMA_REASON_MAX_TX_TRIES | |
CSMA_REASON_BACKOFF_PENDING | |
CSMA_REASON_LISTEN | |
CSMA_REASON_LISTEN_TIMEOUT | |
CSMA_REASON_LISTEN_PENDING | |
CSMA_REASON_START_RX | |
CSMA_REASON_PKT_NOT_FOR_ME | |
CSMA_REASON_WAIT_ACK_PENDING | |
CSMA_REASON_PKT_ERROR | |
Definition at line 125 of file uw-csma-aloha.h.
◆ CSMA_STATUS
Enumerator |
---|
CSMA_STATE_IDLE | |
CSMA_STATE_BACKOFF | |
CSMA_STATE_TX_DATA | |
CSMA_STATE_TX_ACK | |
CSMA_STATE_WAIT_ACK | |
CSMA_STATE_DATA_RX | |
CSMA_STATE_ACK_RX | |
CSMA_STATE_NOT_SET | |
CSMA_STATE_LISTEN | |
CSMA_STATE_CHK_ACK_TIMEOUT | |
CSMA_STATE_CHK_LISTEN_TIMEOUT | |
CSMA_STATE_CHK_BACKOFF_TIMEOUT | |
CSMA_STATE_RX_IDLE | |
CSMA_STATE_RX_LISTEN | |
CSMA_STATE_RX_BACKOFF | |
CSMA_STATE_RX_WAIT_ACK | |
CSMA_STATE_WRONG_PKT_RX | |
Definition at line 104 of file uw-csma-aloha.h.
◆ CSMA_TIMER_STATUS
Enumerator |
---|
CSMA_IDLE | |
CSMA_RUNNING | |
CSMA_FROZEN | |
CSMA_EXPIRED | |
Definition at line 153 of file uw-csma-aloha.h.
◆ CsmaAloha()
◆ ~CsmaAloha()
CsmaAloha::~CsmaAloha |
( |
| ) |
|
|
virtual |
◆ command()
int CsmaAloha::command |
( |
int |
argc, |
|
|
const char *const * |
argv |
|
) |
| |
|
virtual |
TCL command interpreter.
It implements the following OTcl methods:
- Parameters
-
argc | Number of arguments in argv. |
argv | Array 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 205 of file uw-csma-aloha.cpp.
◆ computeTxTime()
Compute the time needed to transmit the packet (using a CrLayerMessage to ask the PHY to perform the computation)
- Parameters
-
CMSA_PKT_TYPE | Type of the packet |
Definition at line 345 of file uw-csma-aloha.cpp.
◆ crLayCommand()
int CsmaAloha::crLayCommand |
( |
ClMessage * |
m | ) |
|
|
virtual |
Cross-Layer messages interpreter.
- Parameters
-
ClMessage* | an instance of ClMessage that represent the message received |
- Returns
- 0 if successful.
Definition at line 244 of file uw-csma-aloha.cpp.
◆ exitBackoff()
void CsmaAloha::exitBackoff |
( |
| ) |
|
|
protectedvirtual |
◆ getBackoffTime()
double CsmaAloha::getBackoffTime |
( |
| ) |
|
|
protectedvirtual |
compute the BackOff time as backoff = backoff_tuner*random*2*ACK_timeout*2^(counter) where counter is a value incremented each time this method is called and backoff_tuner is a multiplier factor chosen by the user
Definition at line 377 of file uw-csma-aloha.cpp.
◆ getRemainingPkts()
virtual int CsmaAloha::getRemainingPkts |
( |
| ) |
|
|
inlineprotectedvirtual |
Return the number of packets not transmitted (remained in the protocol queue) at the end of the simulation.
- Returns
- the size of the queue at the end of the simulation
Definition at line 709 of file uw-csma-aloha.h.
◆ getRTT()
virtual double CsmaAloha::getRTT |
( |
| ) |
|
|
inlineprotectedvirtual |
get the value of RTT as mean of all the rttsamples
- Returns
- RTT value
Definition at line 658 of file uw-csma-aloha.h.
◆ getUpLayersDataPktsRx()
virtual int CsmaAloha::getUpLayersDataPktsRx |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ incrCurrTxRounds()
virtual void CsmaAloha::incrCurrTxRounds |
( |
| ) |
|
|
inlineprotectedvirtual |
Increases the number of times a packet is re-transmitted.
Definition at line 631 of file uw-csma-aloha.h.
◆ incrUpperDataRx()
virtual void CsmaAloha::incrUpperDataRx |
( |
| ) |
|
|
inlineprotectedvirtual |
Increase the number of Data packet Received from the Upper layers.
Definition at line 718 of file uw-csma-aloha.h.
◆ initInfo()
void CsmaAloha::initInfo |
( |
| ) |
|
|
protectedvirtual |
Initializes the protocol at the beginning of the simulation.
This method is called by a command in tcl.
- Parameters
-
- See also
- command method
Definition at line 254 of file uw-csma-aloha.cpp.
◆ initPkt()
void CsmaAloha::initPkt |
( |
Packet * |
p, |
|
|
CSMA_PKT_TYPE |
pkt_type, |
|
|
int |
dest_addr = 0 |
|
) |
| |
|
protectedvirtual |
Init the packet with the MAC address of the receiver and the sender, the size of the packet and the type.
- Parameters
-
UWPOLLING_PKT_TYPE | the type of the packet |
Definition at line 420 of file uw-csma-aloha.cpp.
◆ keepDataPkt()
bool CsmaAloha::keepDataPkt |
( |
int |
serial_number | ) |
|
|
protectedvirtual |
Checks if the data packet received is a double packet (using the serial number of the packet)
- Parameters
-
int | serial number of the received packet |
- Returns
- true if the serial number of the last data pacekt received is greater than the serial number of the last data packet received. false otherwise
Definition at line 333 of file uw-csma-aloha.cpp.
◆ Mac2PhyStartTx()
void CsmaAloha::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 447 of file uw-csma-aloha.cpp.
◆ Phy2MacEndRx()
void CsmaAloha::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 580 of file uw-csma-aloha.cpp.
◆ Phy2MacEndTx()
void CsmaAloha::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 457 of file uw-csma-aloha.cpp.
◆ Phy2MacStartRx()
void CsmaAloha::Phy2MacStartRx |
( |
const Packet * |
p | ) |
|
|
protectedvirtual |
Method called when the Phy Layer start to receive a Packet.
- Parameters
-
const | Packet* Pointer to an object of type Packet that represent the Packet that is in reception |
Definition at line 544 of file uw-csma-aloha.cpp.
◆ printStateInfo()
void CsmaAloha::printStateInfo |
( |
double |
delay = 0 | ) |
|
|
protectedvirtual |
Prints in a file the textual information of the current state and the transitions reasons.
- Parameters
-
double | time lapse from the call of the method and the effective write process in the file (setted to zero by default) |
Definition at line 1057 of file uw-csma-aloha.cpp.
◆ queuePop()
virtual void CsmaAloha::queuePop |
( |
bool |
flag = true | ) |
|
|
inlineprotectedvirtual |
Pop the first element of the data packet queue.
Definition at line 683 of file uw-csma-aloha.h.
◆ recvFromUpperLayers()
void CsmaAloha::recvFromUpperLayers |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
Receives the packet from the upper layer (e.g.
IP)
- Parameters
-
Packet* | pointer to the packet received |
Definition at line 400 of file uw-csma-aloha.cpp.
◆ refreshReason()
Refresh the reason for the change of state.
Definition at line 599 of file uw-csma-aloha.h.
◆ refreshState()
virtual void CsmaAloha::refreshState |
( |
CSMA_STATUS |
state | ) |
|
|
inlineprotectedvirtual |
◆ resetCurrTxRounds()
virtual void CsmaAloha::resetCurrTxRounds |
( |
| ) |
|
|
inlineprotectedvirtual |
Reset the number of times a data pacekt is re-transmitted.
Definition at line 640 of file uw-csma-aloha.h.
◆ resetSession()
void CsmaAloha::resetSession |
( |
| ) |
|
|
protectedvirtual |
Resets the current session (e.g.
the session distance)
Definition at line 306 of file uw-csma-aloha.cpp.
◆ setSessionDistance()
virtual void CsmaAloha::setSessionDistance |
( |
double |
distance | ) |
|
|
inlineprotectedvirtual |
Set the distance between the sender and the receiver.
- Parameters
-
double | Distance between the sender and the receiver |
Definition at line 613 of file uw-csma-aloha.h.
◆ stateBackoff()
void CsmaAloha::stateBackoff |
( |
| ) |
|
|
protectedvirtual |
BackOff STATE.
An ACK packet is lost. A backoff timer is set up. When the timer expire the protocol will re-send the data packet
Definition at line 843 of file uw-csma-aloha.cpp.
◆ stateCheckAckExpired()
void CsmaAloha::stateCheckAckExpired |
( |
| ) |
|
|
protectedvirtual |
◆ stateCheckBackoffExpired()
void CsmaAloha::stateCheckBackoffExpired |
( |
| ) |
|
|
protectedvirtual |
◆ stateCheckListenExpired()
void CsmaAloha::stateCheckListenExpired |
( |
| ) |
|
|
protectedvirtual |
◆ stateIdle()
void CsmaAloha::stateIdle |
( |
| ) |
|
|
protectedvirtual |
◆ stateListen()
void CsmaAloha::stateListen |
( |
| ) |
|
|
protectedvirtual |
◆ stateRxAck()
void CsmaAloha::stateRxAck |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
◆ stateRxBackoff()
void CsmaAloha::stateRxBackoff |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occurring while the protocol is in the backoff state.
Definition at line 859 of file uw-csma-aloha.cpp.
◆ stateRxData()
void CsmaAloha::stateRxData |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
◆ stateRxIdle()
void CsmaAloha::stateRxIdle |
( |
| ) |
|
|
protectedvirtual |
A reception is occuring while the protocol is in IDLE state.
Definition at line 804 of file uw-csma-aloha.cpp.
◆ stateRxListen()
void CsmaAloha::stateRxListen |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occuring while the node is listening the channel.
Definition at line 834 of file uw-csma-aloha.cpp.
◆ stateRxPacketNotForMe()
void CsmaAloha::stateRxPacketNotForMe |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
◆ stateRxWaitAck()
void CsmaAloha::stateRxWaitAck |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occuring while the node is waiting an ACK.
Definition at line 924 of file uw-csma-aloha.cpp.
◆ stateTxAck()
void CsmaAloha::stateTxAck |
( |
int |
dest_addr | ) |
|
|
protectedvirtual |
State in which the protocol set-up the ACK packet to transmit.
- Parameters
-
int | MAC address of the destination of the ACK packet |
Definition at line 933 of file uw-csma-aloha.cpp.
◆ stateTxData()
void CsmaAloha::stateTxData |
( |
| ) |
|
|
protectedvirtual |
State in which the protocol allows the node to transmit a data packet.
Definition at line 869 of file uw-csma-aloha.cpp.
◆ stateWaitAck()
void CsmaAloha::stateWaitAck |
( |
| ) |
|
|
protectedvirtual |
State in which a DATA packet is sent.
The time-out for receiving a ACK is set-up
Definition at line 909 of file uw-csma-aloha.cpp.
◆ txAck()
void CsmaAloha::txAck |
( |
int |
dest_addr | ) |
|
|
protectedvirtual |
Transmits the ACK packet (calling Mac2PhyStartTx) and increment the counter of transmitted ACK packets.
- Parameters
-
in | MAC address of the destination of ACK packet |
Definition at line 650 of file uw-csma-aloha.cpp.
◆ txData()
void CsmaAloha::txData |
( |
| ) |
|
|
protectedvirtual |
Transmits the DATA packet (calling Mac2PhyStartTx) and increment the counter of transmitted data packets.
Definition at line 636 of file uw-csma-aloha.cpp.
◆ updateAckTimeout()
void CsmaAloha::updateAckTimeout |
( |
double |
rtt | ) |
|
|
protectedvirtual |
Updates the AckTimeout calling getRTT, where the ACK timeout is computed as srtt/rttsamples using the smooth RTT.
- See also
- updateRTT
- Parameters
-
Definition at line 322 of file uw-csma-aloha.cpp.
◆ updateLastDataIdRx()
virtual void CsmaAloha::updateLastDataIdRx |
( |
int |
id | ) |
|
|
inlineprotectedvirtual |
Updates the ID of the last DATA packet received.
Definition at line 674 of file uw-csma-aloha.h.
◆ updateRTT()
void CsmaAloha::updateRTT |
( |
double |
rtt | ) |
|
|
protectedvirtual |
Update the RTT increasing the number of RTT samples and calculating the smoothed RTT using the formula srtt = alpha*srtt + (1-alpha) * curr_rtt where alpha is a value chosen by the user.
- Parameters
-
double | current value of RTT |
Definition at line 312 of file uw-csma-aloha.cpp.
◆ waitForUser()
void CsmaAloha::waitForUser |
( |
| ) |
|
|
protectedvirtual |
Used for debug purposes.
(Permit to have a "step by step" behavior of the protocol)
Definition at line 1082 of file uw-csma-aloha.cpp.
◆ ack_mode
Variable that indicates if the protocol is in ACK or NO_ACK mode.
Definition at line 794 of file uw-csma-aloha.h.
◆ ACK_size
◆ ACK_timeout
double CsmaAloha::ACK_timeout |
|
protected |
◆ ack_timer
◆ alpha_
smooth factor in the calculation of the RTT
Definition at line 740 of file uw-csma-aloha.h.
◆ backoff_timer
◆ backoff_tuner
double CsmaAloha::backoff_tuner |
|
protected |
Multiplier factor in the calculation of the backoff.
Definition at line 731 of file uw-csma-aloha.h.
◆ buffer_pkts
int CsmaAloha::buffer_pkts |
|
protected |
Length of the data buffer in number of packets.
Definition at line 739 of file uw-csma-aloha.h.
◆ curr_data_pkt
Packet* CsmaAloha::curr_data_pkt |
|
protected |
◆ curr_state
◆ curr_tx_rounds
int CsmaAloha::curr_tx_rounds |
|
protected |
Number of current transmission of the same packet.
Definition at line 776 of file uw-csma-aloha.h.
◆ data_sn_queue
std::queue<int> CsmaAloha::data_sn_queue |
|
protected |
Queue of the sequence number of the packets.
Definition at line 747 of file uw-csma-aloha.h.
◆ fout
Object that handles the output file where the protocol writes the state transistions.
Definition at line 805 of file uw-csma-aloha.h.
◆ has_buffer_queue
bool CsmaAloha::has_buffer_queue |
|
protected |
flag that indicates if a node has a buffer where store DATA packets
Definition at line 766 of file uw-csma-aloha.h.
◆ HDR_size
Size (in bytes) of the header added by the protocol.
Definition at line 736 of file uw-csma-aloha.h.
◆ initialized
bool CsmaAloha::initialized = false |
|
staticprotected |
◆ last_data_id_rx
int CsmaAloha::last_data_id_rx |
|
protected |
◆ last_reason
◆ last_sent_data_id
int CsmaAloha::last_sent_data_id |
|
protected |
◆ listen_time
double CsmaAloha::listen_time |
|
protected |
◆ listen_timer
◆ max_backoff_counter
int CsmaAloha::max_backoff_counter |
|
protected |
◆ max_payload
int CsmaAloha::max_payload |
|
protected |
Maximum dimension of the data payload in bytes.
Definition at line 735 of file uw-csma-aloha.h.
◆ max_tx_tries
int CsmaAloha::max_tx_tries |
|
protected |
Maximum number of transmissions for one packet.
Definition at line 730 of file uw-csma-aloha.h.
◆ pkt_type_info
◆ prev_prev_state
◆ prev_state
◆ print_transitions
bool CsmaAloha::print_transitions |
|
protected |
flag that indicates if the protocol is enabled to print its state transitions on a file
Definition at line 762 of file uw-csma-aloha.h.
◆ prop_speed
const double CsmaAloha::prop_speed = 1500.0 |
|
staticprotected |
Typical sound propagation speed in underwater enviroment.
Variable that represent the status of the protocol machine state
Definition at line 100 of file uw-csma-aloha.h.
std::queue<Packet *> CsmaAloha::Q |
|
protected |
◆ reason_info
Textual description of the protocol reason for the change of the state.
Definition at line 800 of file uw-csma-aloha.h.
◆ rttsamples
int CsmaAloha::rttsamples |
|
protected |
◆ RxActive
flag that indicates if a reception is occuring
Definition at line 756 of file uw-csma-aloha.h.
◆ session_active
bool CsmaAloha::session_active |
|
protected |
flag that indicates if a session (i.e.
a transmission/reception activity is occuring) between two nodes
Definition at line 758 of file uw-csma-aloha.h.
◆ session_distance
double CsmaAloha::session_distance |
|
protected |
Distance between sender and the receiver involved in the current session.
Definition at line 782 of file uw-csma-aloha.h.
◆ srtt
Smoothed Round Trip Time, calculated as for TCP.
Definition at line 771 of file uw-csma-aloha.h.
◆ start_tx_time
double CsmaAloha::start_tx_time |
|
protected |
timestamp in which the node stars to transmit a packet
Definition at line 769 of file uw-csma-aloha.h.
◆ status_info
Textual description of the protocol states.
Definition at line 798 of file uw-csma-aloha.h.
◆ sumrtt
◆ sumrtt2
double CsmaAloha::sumrtt2 |
|
protected |
◆ TxActive
flag that indicates if a transmission is occuring
Definition at line 755 of file uw-csma-aloha.h.
◆ u_data_id
◆ u_pkt_id
◆ wait_costant
double CsmaAloha::wait_costant |
|
protected |
Adding factor in the calculation of the listen time.
Definition at line 733 of file uw-csma-aloha.h.
The documentation for this class was generated from the following files: