#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
◆ CSMA_ACK_MODES
| Enumerator |
|---|
| CSMA_ACK_MODE | |
| CSMA_NO_ACK_MODE | |
◆ CSMA_PKT_TYPE
| Enumerator |
|---|
| CSMA_ACK_PKT | |
| CSMA_DATA_PKT | |
| CSMA_DATAMAX_PKT | |
◆ 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 | |
◆ 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 | |
◆ CSMA_TIMER_STATUS
| Enumerator |
|---|
| CSMA_IDLE | |
| CSMA_RUNNING | |
| CSMA_FROZEN | |
| CSMA_EXPIRED | |
◆ CsmaAloha()
◆ ~CsmaAloha()
| virtual CsmaAloha::~CsmaAloha |
( |
| ) |
|
|
virtualdefault |
◆ command()
| int CsmaAloha::command |
( |
int |
argc, |
|
|
const char *const * |
argv |
|
) |
| |
|
overridevirtual |
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.
◆ 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 |
◆ exitBackoff()
| void CsmaAloha::exitBackoff |
( |
| ) |
|
|
protectedvirtual |
Method called when the Backoff timer is expired
◆ 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
◆ getRemainingPkts()
| virtual int CsmaAloha::getRemainingPkts |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
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
References Q.
◆ getRTT()
| virtual double CsmaAloha::getRTT |
( |
| ) |
const |
|
inlineprotectedvirtual |
get the value of RTT as mean of all the rttsamples
- Returns
- RTT value
References rttsamples, and sumrtt.
◆ getUpLayersDataPktsRx()
| virtual int CsmaAloha::getUpLayersDataPktsRx |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ incrCurrTxRounds()
| virtual void CsmaAloha::incrCurrTxRounds |
( |
| ) |
|
|
inlineprotectedvirtual |
Increases the number of times a packet is re-transmitted
References curr_tx_rounds.
◆ incrUpperDataRx()
| virtual void CsmaAloha::incrUpperDataRx |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
Increase the number of Data packet Received from the Upper layers
◆ initInfo()
| void CsmaAloha::initInfo |
( |
| ) |
|
|
protectedvirtual |
Initializes the protocol at the beginning of the simulation. This method is called by a command in tcl.
◆ 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
-
| Packet* | Pointer to a Packet to initialize |
| CSMA_PKT_TYPE | Type of the packet |
| int | destination address |
◆ 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
◆ 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 |
◆ Phy2MacEndRx()
| void CsmaAloha::Phy2MacEndRx |
( |
Packet * |
p | ) |
|
|
overrideprotectedvirtual |
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 |
◆ Phy2MacEndTx()
| void CsmaAloha::Phy2MacEndTx |
( |
const Packet * |
p | ) |
|
|
overrideprotectedvirtual |
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 |
◆ Phy2MacStartRx()
| void CsmaAloha::Phy2MacStartRx |
( |
const Packet * |
p | ) |
|
|
overrideprotectedvirtual |
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 |
◆ 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) |
◆ queuePop()
| virtual void CsmaAloha::queuePop |
( |
bool |
flag = true | ) |
|
|
inlineprotectedvirtual |
Pop the first element of the data packet queue
References data_sn_queue, and Q.
◆ recvFromUpperLayers()
| void CsmaAloha::recvFromUpperLayers |
( |
Packet * |
p | ) |
|
|
overrideprotectedvirtual |
Receives the packet from the upper layer (e.g. IP)
- Parameters
-
| Packet* | pointer to the packet received |
◆ refreshReason()
Refresh the reason for the change of state
References last_reason.
◆ 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
References curr_tx_rounds.
◆ resetSession()
| void CsmaAloha::resetSession |
( |
| ) |
|
|
protectedvirtual |
Resets the current session (e.g. the session distance)
◆ 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 |
References session_distance.
◆ 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
◆ stateCheckAckExpired()
| void CsmaAloha::stateCheckAckExpired |
( |
| ) |
|
|
protectedvirtual |
Checks if the ACK reception timer is expired
◆ stateCheckBackoffExpired()
| void CsmaAloha::stateCheckBackoffExpired |
( |
| ) |
|
|
protectedvirtual |
Checks if the Backoff period is expired
◆ stateCheckListenExpired()
| void CsmaAloha::stateCheckListenExpired |
( |
| ) |
|
|
protectedvirtual |
Checks if the Listen period is expired
◆ stateIdle()
| void CsmaAloha::stateIdle |
( |
| ) |
|
|
protectedvirtual |
IDLE state. Each variable is resetted
◆ stateListen()
| void CsmaAloha::stateListen |
( |
| ) |
|
|
protectedvirtual |
State in which the node is listening the channel
◆ stateRxAck()
| void CsmaAloha::stateRxAck |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
state in which an ACK packet is received
◆ stateRxBackoff()
| void CsmaAloha::stateRxBackoff |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occurring while the protocol is in the backoff state
◆ stateRxData()
| void CsmaAloha::stateRxData |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
State in which a DATA packet is received
◆ stateRxIdle()
| void CsmaAloha::stateRxIdle |
( |
| ) |
|
|
protectedvirtual |
A reception is occuring while the protocol is in IDLE state
◆ stateRxListen()
| void CsmaAloha::stateRxListen |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occuring while the node is listening the channel
◆ stateRxPacketNotForMe()
| void CsmaAloha::stateRxPacketNotForMe |
( |
Packet * |
p | ) |
|
|
protectedvirtual |
state in which a wrong Packet is received
◆ stateRxWaitAck()
| void CsmaAloha::stateRxWaitAck |
( |
| ) |
|
|
protectedvirtual |
State in which a reception is occuring while the node is waiting an ACK
◆ 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 |
◆ stateTxData()
| void CsmaAloha::stateTxData |
( |
| ) |
|
|
protectedvirtual |
State in which the protocol allows the node to transmit a data packet
◆ stateWaitAck()
| void CsmaAloha::stateWaitAck |
( |
| ) |
|
|
protectedvirtual |
State in which a DATA packet is sent. The time-out for receiving a ACK is set-up
◆ 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 |
◆ txData()
| void CsmaAloha::txData |
( |
| ) |
|
|
protectedvirtual |
Transmits the DATA packet (calling Mac2PhyStartTx) and increment the counter of transmitted data packets
◆ 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
-
◆ updateLastDataIdRx()
| virtual void CsmaAloha::updateLastDataIdRx |
( |
int |
id | ) |
|
|
inlineprotectedvirtual |
Updates the ID of the last DATA packet received
References last_data_id_rx.
◆ 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 |
◆ ack_mode
Variable that indicates if the protocol is in ACK or NO_ACK mode
◆ ACK_size
◆ ACK_timeout
| double CsmaAloha::ACK_timeout |
|
protected |
Duration of the ACK waiting time
◆ ack_timer
Object that represents the ack timer
◆ alpha_
smooth factor in the calculation of the RTT
◆ backoff_timer
Object that represents the backoff timer
◆ backoff_tuner
| double CsmaAloha::backoff_tuner |
|
protected |
Multiplier factor in the calculation of the backoff
◆ buffer_pkts
| int CsmaAloha::buffer_pkts |
|
protected |
Length of the data buffer in number of packets
◆ curr_data_pkt
| Packet* CsmaAloha::curr_data_pkt |
|
protected |
Pointer to the current data packet
◆ curr_state
◆ curr_tx_rounds
| int CsmaAloha::curr_tx_rounds |
|
protected |
◆ data_sn_queue
| std::queue<int> CsmaAloha::data_sn_queue |
|
protected |
Queue of the sequence number of the packets
Referenced by queuePop().
◆ fout
Object that handles the output file where the protocol writes the state transistions
◆ has_buffer_queue
| bool CsmaAloha::has_buffer_queue |
|
protected |
flag that indicates if a node has a buffer where store DATA packets
◆ HDR_size
Size (in bytes) of the header added by the protocol
◆ initialized
| bool CsmaAloha::initialized = false |
|
staticprotected |
true if the protocol is initialized
◆ last_data_id_rx
| int CsmaAloha::last_data_id_rx |
|
protected |
◆ last_reason
◆ last_sent_data_id
| int CsmaAloha::last_sent_data_id |
|
protected |
ID of the last sent packet
◆ listen_time
| double CsmaAloha::listen_time |
|
protected |
Time in which the node sense the channel
◆ listen_timer
Object that represents the listen timer
◆ max_backoff_counter
| int CsmaAloha::max_backoff_counter |
|
protected |
Number of times a backoff is calculated
◆ max_payload
| int CsmaAloha::max_payload |
|
protected |
Maximum dimension of the data payload in bytes
◆ max_tx_tries
| int CsmaAloha::max_tx_tries |
|
protected |
Maximum number of transmissions for one packet
◆ pkt_type_info
Textual description of the packet type
◆ 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
◆ 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
| std::queue<Packet *> CsmaAloha::Q |
|
protected |
◆ reason_info
Textual description of the protocol reason for the change of the state
◆ rttsamples
| int CsmaAloha::rttsamples |
|
protected |
num of RTT samples
Referenced by getRTT().
◆ RxActive
flag that indicates if a reception is occuring
◆ session_active
| bool CsmaAloha::session_active |
|
protected |
flag that indicates if a session (i.e. a transmission/reception activity is occuring) between two nodes
◆ session_distance
| double CsmaAloha::session_distance |
|
protected |
Distance between sender and the receiver involved in the current session
Referenced by setSessionDistance().
◆ srtt
Smoothed Round Trip Time, calculated as for TCP
◆ start_tx_time
| double CsmaAloha::start_tx_time |
|
protected |
timestamp in which the node stars to transmit a packet
◆ status_info
Textual description of the protocol states
◆ sumrtt
sum of RTT samples
Referenced by getRTT().
◆ sumrtt2
| double CsmaAloha::sumrtt2 |
|
protected |
◆ TxActive
flag that indicates if a transmission is occuring
◆ u_data_id
◆ u_pkt_id
simulation-unique packet ID
◆ wait_costant
| double CsmaAloha::wait_costant |
|
protected |
Adding factor in the calculation of the listen time
The documentation for this class was generated from the following files: