INET Framework for OMNeT++/OMNEST
|
Generic CSMA Mac-Layer. More...
#include <CSMA.h>
Public Member Functions | |
CSMA () | |
virtual | ~CSMA () |
virtual void | initialize (int) override |
Initialization of the module and some variables. More... | |
virtual void | finish () override |
Delete all dynamically allocated objects of the module. More... | |
virtual void | handleLowerPacket (cPacket *) override |
Handle messages from lower layer. More... | |
virtual void | handleUpperPacket (cPacket *) override |
Handle messages from upper layer. More... | |
virtual void | handleSelfMessage (cMessage *) override |
Handle self messages such as timers. More... | |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, long value, cObject *details) override |
Handle control messages from lower layer. More... | |
Public Member Functions inherited from inet::OperationalBase | |
OperationalBase () | |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Public Member Functions inherited from inet::IMACProtocol | |
virtual | ~IMACProtocol () |
Protected Types | |
enum | t_mac_states { IDLE_1 = 1, BACKOFF_2, CCA_3, TRANSMITFRAME_4, WAITACK_5, WAITSIFS_6, TRANSMITACK_7 } |
MAC states see states diagram. More... | |
enum | t_mac_timer { TIMER_NULL = 0, TIMER_BACKOFF, TIMER_CCA, TIMER_SIFS, TIMER_RX_ACK } |
Kinds for timer messages. More... | |
enum | t_mac_event { EV_SEND_REQUEST = 1, EV_TIMER_BACKOFF, EV_FRAME_TRANSMITTED, EV_ACK_RECEIVED, EV_ACK_TIMEOUT, EV_FRAME_RECEIVED, EV_DUPLICATE_RECEIVED, EV_TIMER_SIFS, EV_BROADCAST_RECEIVED, EV_TIMER_CCA } |
MAC state machine events. More... | |
enum | t_csma_frame_types { DATA, ACK } |
Types for frames sent by the CSMA. More... | |
enum | t_mac_carrier_sensed { CHANNEL_BUSY = 1, CHANNEL_FREE } |
enum | t_mac_status { STATUS_OK = 1, STATUS_ERROR, STATUS_RX_ERROR, STATUS_RX_TIMEOUT, STATUS_FRAME_TO_PROCESS, STATUS_NO_FRAME_TO_PROCESS, STATUS_FRAME_TRANSMITTED } |
enum | backoff_methods { CONSTANT = 0, LINEAR, EXPONENTIAL } |
The different back-off methods. More... | |
typedef std::list< CSMAFrame * > | MacQueue |
Protected Member Functions | |
virtual void | initializeMACAddress () |
Generate new interface address. More... | |
virtual InterfaceEntry * | createInterfaceEntry () override |
virtual void | handleCommand (cMessage *msg) |
virtual void | flushQueue () |
virtual void | clearQueue () |
void | fsmError (t_mac_event event, cMessage *msg) |
void | executeMac (t_mac_event event, cMessage *msg) |
Updates state machine. More... | |
void | updateStatusIdle (t_mac_event event, cMessage *msg) |
void | updateStatusBackoff (t_mac_event event, cMessage *msg) |
void | updateStatusCCA (t_mac_event event, cMessage *msg) |
void | updateStatusTransmitFrame (t_mac_event event, cMessage *msg) |
void | updateStatusWaitAck (t_mac_event event, cMessage *msg) |
void | updateStatusSIFS (t_mac_event event, cMessage *msg) |
void | updateStatusTransmitAck (t_mac_event event, cMessage *msg) |
void | updateStatusNotIdle (cMessage *msg) |
void | manageQueue () |
void | updateMacState (t_mac_states newMacState) |
void | attachSignal (CSMAFrame *mac, simtime_t_cref startTime) |
void | manageMissingAck (t_mac_event event, cMessage *msg) |
void | startTimer (t_mac_timer timer) |
virtual simtime_t | scheduleBackoff () |
virtual cPacket * | decapsMsg (CSMAFrame *macPkt) |
cObject * | setUpControlInfo (cMessage *const pMsg, const MACAddress &pSrcAddr) |
Attaches a "control info" (MacToNetw) structure (object) to the message pMsg. More... | |
Protected Member Functions inherited from inet::MACProtocolBase | |
MACProtocolBase () | |
virtual void | registerInterface () |
virtual void | sendUp (cMessage *message) |
virtual void | sendDown (cMessage *message) |
virtual bool | isUpperMessage (cMessage *message) override |
virtual bool | isLowerMessage (cMessage *message) override |
virtual bool | isInitializeStage (int stage) override |
virtual bool | isNodeStartStage (int stage) override |
virtual bool | isNodeShutdownStage (int stage) override |
Protected Member Functions inherited from inet::LayeredProtocolBase | |
virtual void | handleMessageWhenUp (cMessage *message) override |
virtual void | handleUpperCommand (cMessage *message) |
virtual void | handleLowerCommand (cMessage *message) |
Protected Member Functions inherited from inet::OperationalBase | |
virtual int | numInitStages () const override |
virtual void | handleMessage (cMessage *msg) override |
virtual void | handleMessageWhenDown (cMessage *msg) |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
Perform one stage of a lifecycle operation. More... | |
virtual bool | handleNodeStart (IDoneCallback *doneCallback) |
virtual bool | handleNodeShutdown (IDoneCallback *doneCallback) |
virtual void | handleNodeCrash () |
virtual void | setOperational (bool isOperational) |
Protected Attributes | |
t_mac_states | macState |
keep track of MAC state More... | |
t_mac_status | status |
MACAddress | address |
The MAC address of the interface. More... | |
IRadio * | radio |
The radio. More... | |
IRadio::TransmissionState | transmissionState |
simtime_t | sifs |
Maximum time between a packet and its ACK. More... | |
simtime_t | macAckWaitDuration |
The amount of time the MAC waits for the ACK of a packet. More... | |
int | headerLength |
Length of the header. More... | |
bool | transmissionAttemptInterruptedByRx |
simtime_t | ccaDetectionTime |
CCA detection time. More... | |
simtime_t | rxSetupTime |
Time to setup radio from sleep to Rx state. More... | |
simtime_t | aTurnaroundTime |
Time to switch radio from Rx to Tx state. More... | |
int | macMaxCSMABackoffs |
maximum number of extra backoffs (excluding the first unconditional one) before frame drop More... | |
unsigned int | macMaxFrameRetries |
maximum number of frame retransmissions without ack More... | |
simtime_t | aUnitBackoffPeriod |
base time unit for calculating backoff durations More... | |
bool | useMACAcks |
Stores if the MAC expects Acks for Unicast packets. More... | |
backoff_methods | backoffMethod |
Defines the backoff method to be used. More... | |
int | macMinBE |
Minimum backoff exponent. More... | |
int | macMaxBE |
Maximum backoff exponent. More... | |
double | initialCW |
initial contention window size Only used for linear and constant backoff method. More... | |
double | txPower |
The power (in mW) to transmit with. More... | |
int | NB |
number of backoff performed until now for current frame More... | |
MacQueue | macQueue |
A queue to store packets from upper layer in case another packet is still waiting for transmission. More... | |
unsigned int | queueLength |
length of the queue More... | |
unsigned int | txAttempts |
count the number of tx attempts More... | |
double | bitrate |
the bit rate at which we transmit More... | |
int | ackLength |
The bit length of the ACK packet. More... | |
CSMAFrame * | ackMessage |
std::map< MACAddress, unsigned long > | SeqNrParent |
std::map< MACAddress, unsigned long > | SeqNrChild |
Different tracked statistics. | |
long | nbTxFrames |
long | nbRxFrames |
long | nbMissedAcks |
long | nbRecvdAcks |
long | nbDroppedFrames |
long | nbTxAcks |
long | nbDuplicates |
long | nbBackoffs |
double | backoffValues |
Pointer for timer messages. | |
cMessage * | backoffTimer |
cMessage * | ccaTimer |
cMessage * | sifsTimer |
cMessage * | rxAckTimer |
Protected Attributes inherited from inet::OperationalBase | |
bool | isOperational |
simtime_t | lastChange |
Private Member Functions | |
CSMA (const CSMA &) | |
Copy constructor is not allowed. More... | |
CSMA & | operator= (const CSMA &) |
Assignment operator is not allowed. More... | |
Additional Inherited Members | |
Public Attributes inherited from inet::MACProtocolBase | |
InterfaceEntry * | interfaceEntry |
int | upperLayerInGateId |
Gate ids. More... | |
int | upperLayerOutGateId |
int | lowerLayerInGateId |
int | lowerLayerOutGateId |
Static Public Attributes inherited from inet::LayeredProtocolBase | |
static simsignal_t | packetSentToUpperSignal = registerSignal("packetSentToUpper") |
static simsignal_t | packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper") |
static simsignal_t | packetFromUpperDroppedSignal = registerSignal("packetFromUpperDropped") |
static simsignal_t | packetSentToLowerSignal = registerSignal("packetSentToLower") |
static simsignal_t | packetReceivedFromLowerSignal = registerSignal("packetReceivedFromLower") |
static simsignal_t | packetFromLowerDroppedSignal = registerSignal("packetFromLowerDropped") |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
MAC state machine events.
See state diagram.
Enumerator | |
---|---|
EV_SEND_REQUEST | |
EV_TIMER_BACKOFF | |
EV_FRAME_TRANSMITTED | |
EV_ACK_RECEIVED | |
EV_ACK_TIMEOUT | |
EV_FRAME_RECEIVED | |
EV_DUPLICATE_RECEIVED | |
EV_TIMER_SIFS | |
EV_BROADCAST_RECEIVED | |
EV_TIMER_CCA |
|
protected |
|
protected |
Enumerator | |
---|---|
STATUS_OK | |
STATUS_ERROR | |
STATUS_RX_ERROR | |
STATUS_RX_TIMEOUT | |
STATUS_FRAME_TO_PROCESS | |
STATUS_NO_FRAME_TO_PROCESS | |
STATUS_FRAME_TRANSMITTED |
|
protected |
|
inline |
|
virtual |
|
private |
Copy constructor is not allowed.
|
protected |
Referenced by updateStatusCCA(), and updateStatusSIFS().
|
protectedvirtual |
|
overrideprotectedvirtual |
Implements inet::MACProtocolBase.
|
protectedvirtual |
Referenced by updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusSIFS(), and updateStatusWaitAck().
|
protected |
Updates state machine.
Referenced by handleLowerPacket(), handleSelfMessage(), handleUpperPacket(), and receiveSignal().
|
overridevirtual |
Delete all dynamically allocated objects of the module.
|
protectedvirtual |
|
protected |
Referenced by updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusSIFS(), updateStatusTransmitAck(), updateStatusTransmitFrame(), and updateStatusWaitAck().
|
overridevirtual |
Handle messages from lower layer.
Compares the address of this Host with the destination address in frame.
Generates the corresponding event.
Implements inet::LayeredProtocolBase.
|
overridevirtual |
Handle self messages such as timers.
Reimplemented from inet::LayeredProtocolBase.
|
overridevirtual |
Handle messages from upper layer.
Encapsulates the message to be transmitted and pass it on to the FSM main method for further processing.
Implements inet::LayeredProtocolBase.
|
overridevirtual |
Initialization of the module and some variables.
Reimplemented from inet::MACProtocolBase.
|
protectedvirtual |
Generate new interface address.
Referenced by initialize().
|
protected |
Referenced by updateStatusWaitAck().
|
protected |
Referenced by manageMissingAck(), updateStatusCCA(), updateStatusTransmitAck(), updateStatusTransmitFrame(), and updateStatusWaitAck().
|
overridevirtual |
Handle control messages from lower layer.
|
protectedvirtual |
Referenced by startTimer().
|
protected |
Attaches a "control info" (MacToNetw) structure (object) to the message pMsg.
Referenced by decapsMsg().
|
protected |
Referenced by manageQueue(), updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusSIFS(), and updateStatusTransmitFrame().
|
protected |
Referenced by manageQueue(), updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusSIFS(), and updateStatusTransmitFrame().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
Referenced by executeMac().
|
protected |
The bit length of the ACK packet.
Referenced by handleLowerPacket(), and initialize().
|
protected |
Referenced by handleLowerPacket(), initialize(), updateStatusSIFS(), and ~CSMA().
|
protected |
The MAC address of the interface.
Referenced by createInterfaceEntry(), handleLowerPacket(), handleUpperPacket(), and initializeMACAddress().
|
protected |
Time to switch radio from Rx to Tx state.
Referenced by initialize(), and updateStatusCCA().
|
protected |
base time unit for calculating backoff durations
Referenced by initialize(), and scheduleBackoff().
|
protected |
Defines the backoff method to be used.
Referenced by initialize(), and scheduleBackoff().
|
protected |
Referenced by handleSelfMessage(), initialize(), manageQueue(), startTimer(), updateStatusBackoff(), and ~CSMA().
|
protected |
Referenced by finish(), initialize(), and scheduleBackoff().
|
protected |
the bit rate at which we transmit
Referenced by attachSignal(), createInterfaceEntry(), and initialize().
|
protected |
CCA detection time.
Referenced by initialize(), and startTimer().
|
protected |
Referenced by handleSelfMessage(), initialize(), startTimer(), updateStatusCCA(), and ~CSMA().
|
protected |
Length of the header.
Referenced by handleUpperPacket().
|
protected |
initial contention window size Only used for linear and constant backoff method.
Referenced by initialize(), and scheduleBackoff().
|
protected |
The amount of time the MAC waits for the ACK of a packet.
Referenced by initialize(), and startTimer().
|
protected |
Maximum backoff exponent.
Only used for exponential backoff method.
Referenced by initialize(), and scheduleBackoff().
|
protected |
maximum number of extra backoffs (excluding the first unconditional one) before frame drop
Referenced by initialize(), and updateStatusCCA().
|
protected |
maximum number of frame retransmissions without ack
Referenced by initialize(), and manageMissingAck().
|
protected |
Minimum backoff exponent.
Only used for exponential backoff method.
Referenced by initialize(), and scheduleBackoff().
|
protected |
A queue to store packets from upper layer in case another packet is still waiting for transmission.
Referenced by clearQueue(), flushQueue(), handleLowerPacket(), manageMissingAck(), manageQueue(), updateStatusCCA(), updateStatusIdle(), updateStatusNotIdle(), updateStatusTransmitFrame(), updateStatusWaitAck(), and ~CSMA().
|
protected |
keep track of MAC state
Referenced by executeMac(), fsmError(), handleLowerPacket(), initialize(), and updateMacState().
|
protected |
number of backoff performed until now for current frame
Referenced by initialize(), manageQueue(), scheduleBackoff(), updateStatusCCA(), and updateStatusIdle().
|
protected |
Referenced by finish(), initialize(), and scheduleBackoff().
|
protected |
Referenced by finish(), initialize(), and updateStatusCCA().
|
protected |
Referenced by finish(), handleLowerPacket(), and initialize().
|
protected |
Referenced by finish(), handleSelfMessage(), and initialize().
|
protected |
Referenced by finish(), handleLowerPacket(), and initialize().
|
protected |
Referenced by finish(), initialize(), and updateStatusIdle().
|
protected |
Referenced by finish(), initialize(), and updateStatusSIFS().
|
protected |
Referenced by finish(), initialize(), and updateStatusCCA().
|
protected |
length of the queue
Referenced by initialize(), updateStatusIdle(), and updateStatusNotIdle().
|
protected |
The radio.
Referenced by initialize(), updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusTransmitAck(), and updateStatusTransmitFrame().
|
protected |
Referenced by handleSelfMessage(), initialize(), startTimer(), updateStatusWaitAck(), and ~CSMA().
|
protected |
Time to setup radio from sleep to Rx state.
Referenced by initialize(), and startTimer().
|
protected |
Referenced by handleLowerPacket().
|
protected |
Referenced by handleUpperPacket().
|
protected |
Maximum time between a packet and its ACK.
Usually this is slightly more then the tx-rx turnaround time The channel should stay clear within this period of time.
Referenced by initialize(), and startTimer().
|
protected |
Referenced by handleSelfMessage(), initialize(), startTimer(), and ~CSMA().
|
protected |
|
protected |
Referenced by initialize(), manageQueue(), updateStatusBackoff(), and updateStatusCCA().
|
protected |
Referenced by receiveSignal().
|
protected |
count the number of tx attempts
This holds the number of transmission attempts for the current frame.
Referenced by initialize(), manageMissingAck(), updateStatusCCA(), and updateStatusWaitAck().
|
protected |
The power (in mW) to transmit with.
|
protected |
Stores if the MAC expects Acks for Unicast packets.
Referenced by handleLowerPacket(), handleUpperPacket(), initialize(), startTimer(), updateStatusBackoff(), updateStatusCCA(), updateStatusIdle(), updateStatusSIFS(), updateStatusTransmitAck(), updateStatusTransmitFrame(), and updateStatusWaitAck().