|
INET Framework for OMNeT++/OMNEST
|
Generic CSMA Mac-Layer.
More...
#include <Ieee802154Mac.h>
|
| 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...
|
| |
| long | nbTxFrames |
| |
| long | nbRxFrames |
| |
| long | nbMissedAcks |
| |
| long | nbRecvdAcks |
| |
| long | nbDroppedFrames |
| |
| long | nbTxAcks |
| |
| long | nbDuplicates |
| |
| long | nbBackoffs |
| |
| double | backoffValues |
| |
|
| 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...
|
| |
| cMessage * | backoffTimer |
| |
| cMessage * | ccaTimer |
| |
| cMessage * | sifsTimer |
| |
| cMessage * | rxAckTimer |
| |
| t_mac_states | macState |
| | keep track of MAC state More...
|
| |
| t_mac_status | status |
| |
| ModuleRefByPar< physicallayer::IRadio > | radio |
| | The radio. More...
|
| |
| physicallayer::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...
|
| |
| int | 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...
|
| |
| 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...
|
| |
| Packet * | ackMessage |
| |
| std::map< MacAddress, unsigned long > | SeqNrParent |
| |
| std::map< MacAddress, unsigned long > | SeqNrChild |
| |
| virtual void | configureNetworkInterface () override |
| | Generate new interface address. More...
|
| |
| virtual void | handleCommand (cMessage *msg) |
| |
| 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 (Packet *mac, simtime_t_cref startTime) |
| |
| void | manageMissingAck (t_mac_event event, cMessage *msg) |
| |
| void | startTimer (t_mac_timer timer) |
| |
| virtual simtime_t | scheduleBackoff () |
| |
| virtual void | encapsulate (Packet *packet) |
| | Encapsulates the message. More...
|
| |
| virtual void | decapsulate (Packet *packet) |
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | refreshDisplay () const override |
| |
| | Ieee802154Mac (const Ieee802154Mac &) |
| | Copy constructor is not allowed. More...
|
| |
| Ieee802154Mac & | operator= (const Ieee802154Mac &) |
| | Assignment operator is not allowed. More...
|
| |
Generic CSMA Mac-Layer.
Supports constant, linear and exponential backoffs as well as MAC ACKs.
- Author
- Jerome Rousselot, Amre El-Hoiydi, Marc Loebbers, Yosia Hadisusanto, Andreas Koepke
-
Karl Wessel (port for MiXiM)
CSMA Mac-Layer - finite state machine
◆ backoff_methods
The different back-off methods.
| Enumerator |
|---|
| CONSTANT | Constant back-off time.
|
| LINEAR | Linear increasing back-off time.
|
| EXPONENTIAL | Exponentially increasing back-off time.
|
◆ t_csma_frame_types
Types for frames sent by the CSMA.
◆ t_mac_carrier_sensed
| Enumerator |
|---|
| CHANNEL_BUSY | |
| CHANNEL_FREE | |
◆ t_mac_event
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 | |
◆ t_mac_states
MAC states see states diagram.
| Enumerator |
|---|
| IDLE_1 | |
| BACKOFF_2 | |
| CCA_3 | |
| TRANSMITFRAME_4 | |
| WAITACK_5 | |
| WAITSIFS_6 | |
| TRANSMITACK_7 | |
◆ t_mac_status
| Enumerator |
|---|
| STATUS_OK | |
| STATUS_ERROR | |
| STATUS_RX_ERROR | |
| STATUS_RX_TIMEOUT | |
| STATUS_FRAME_TO_PROCESS | |
| STATUS_NO_FRAME_TO_PROCESS | |
| STATUS_FRAME_TRANSMITTED | |
◆ t_mac_timer
Kinds for timer messages.
| Enumerator |
|---|
| TIMER_NULL | |
| TIMER_BACKOFF | |
| TIMER_CCA | |
| TIMER_SIFS | |
| TIMER_RX_ACK | |
◆ Ieee802154Mac() [1/2]
| inet::Ieee802154Mac::Ieee802154Mac |
( |
| ) |
|
|
inline |
◆ ~Ieee802154Mac()
| inet::Ieee802154Mac::~Ieee802154Mac |
( |
| ) |
|
|
virtual |
◆ Ieee802154Mac() [2/2]
Copy constructor is not allowed.
◆ attachSignal()
| void inet::Ieee802154Mac::attachSignal |
( |
Packet * |
mac, |
|
|
simtime_t_cref |
startTime |
|
) |
| |
|
protected |
337 simtime_t duration = mac->getBitLength() /
bitrate;
338 mac->setDuration(duration);
◆ configureNetworkInterface()
| void inet::Ieee802154Mac::configureNetworkInterface |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ decapsulate()
| void inet::Ieee802154Mac::decapsulate |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
904 const auto& csmaHeader = packet->popAtFront<Ieee802154MacHeader>();
905 packet->addTagIfAbsent<MacAddressInd>()->setSrcAddress(csmaHeader->getSrcAddr());
906 packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(
networkInterface->getInterfaceId());
◆ encapsulate()
| void inet::Ieee802154Mac::encapsulate |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
Encapsulates the message.
180 auto macPkt = makeShared<Ieee802154MacHeader>();
183 MacAddress dest = packet->getTag<MacAddressReq>()->getDestAddress();
184 EV_DETAIL <<
"CSMA received a message from upper layer, name is " << packet->getName() <<
", CInfo removed, mac addr=" << dest << endl;
186 macPkt->setDestAddr(dest);
187 delete packet->removeControlInfo();
194 macPkt->setSequenceId(0);
195 EV_DETAIL <<
"Adding a new parent to the map of Sequence numbers:" << dest << endl;
199 EV_DETAIL <<
"Packet send with sequence number = " <<
SeqNrParent[dest] << endl;
204 packet->insertAtFront(macPkt);
206 EV_DETAIL <<
"pkt encapsulated, length: " << macPkt->getChunkLength() <<
"\n";
◆ executeMac()
| void inet::Ieee802154Mac::executeMac |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
Updates state machine.
611 EV_DETAIL <<
"In executeMac" << endl;
646 EV <<
"Error in CSMA FSM: an unknown state has been reached. macState=" <<
macState << endl;
◆ finish()
| void inet::Ieee802154Mac::finish |
( |
| ) |
|
|
overridevirtual |
Delete all dynamically allocated objects of the module.
142 recordScalar(
"meanBackoff", 0);
◆ fsmError()
| void inet::Ieee802154Mac::fsmError |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
688 EV <<
"FSM Error ! In state " <<
macState <<
", received unknown event:" <<
event <<
"." << endl;
◆ getProvider()
Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface.
The gate parameter must be a valid gate of this module.
Implements inet::queueing::IActivePacketSink.
◆ handleCanPullPacketChanged()
| void inet::Ieee802154Mac::handleCanPullPacketChanged |
( |
cGate * |
gate | ) |
|
|
overridevirtual |
Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate.
This method is called, for example, when a new packet is inserted into a queue. It allows the sink to pull a new packet from the queue.
The gate parameter must be a valid gate of this module.
Implements inet::queueing::IActivePacketSink.
◆ handleCommand()
| virtual void inet::Ieee802154Mac::handleCommand |
( |
cMessage * |
msg | ) |
|
|
inlineprotectedvirtual |
◆ handleCrashOperation()
◆ handleLowerPacket()
| void inet::Ieee802154Mac::handleLowerPacket |
( |
Packet * |
packet | ) |
|
|
overridevirtual |
Handle messages from lower layer.
Compares the address of this Host with the destination address in frame.
Generates the corresponding event.
Reimplemented from inet::LayeredProtocolBase.
788 if (packet->hasBitError()) {
789 EV <<
"Received " << packet <<
" contains bit errors or collision, dropping it\n";
790 PacketDropDetails details;
796 const auto& csmaHeader = packet->peekAtFront<Ieee802154MacHeader>();
797 const MacAddress& src = csmaHeader->getSrcAddr();
798 const MacAddress& dest = csmaHeader->getDestAddr();
802 EV_DETAIL <<
"Received frame name= " << csmaHeader->getName()
803 <<
", myState=" <<
macState <<
" src=" << src
804 <<
" dst=" << dest <<
" myAddr="
807 if (dest == address) {
809 EV_DETAIL <<
"Received a data packet addressed to me." << endl;
814 long SeqNr = csmaHeader->getSequenceId();
816 if (strcmp(packet->getName(),
"CSMA-Ack") != 0) {
821 EV_DETAIL <<
"Received a data packet addressed to me,"
822 <<
" preparing an ack..." << endl;
828 auto csmaHeader = makeShared<Ieee802154MacHeader>();
829 csmaHeader->setSrcAddr(address);
830 csmaHeader->setDestAddr(src);
839 EV_DETAIL <<
"Adding a new child to the map of Sequence numbers:" << src << endl;
844 EV_DETAIL <<
"Expected Sequence number is " << ExpectedNr
845 <<
" and number of packet is " << SeqNr << endl;
846 if (SeqNr < ExpectedNr) {
861 if (src == csmaHeader->getDestAddr()) {
866 EV <<
"Error! Received an ack from an unexpected source: src=" << src <<
", I was expecting from node addr=" << csmaHeader->getDestAddr() << endl;
871 EV <<
"Error! Received an Ack while my send queue was empty. src=" << src <<
"." << endl;
876 else if (dest.isBroadcast() || dest.isMulticast()) {
880 EV_DETAIL <<
"packet not for me, deleting...\n";
881 PacketDropDetails details;
◆ handlePullPacketProcessed()
| void inet::Ieee802154Mac::handlePullPacketProcessed |
( |
Packet * |
packet, |
|
|
cGate * |
gate, |
|
|
bool |
successful |
|
) |
| |
|
overridevirtual |
Notifies about the completion of the packet processing for a packet that was pulled earlier independently whether the packet is passed or streamed.
This method is called, for example, when a previously pulled packet is failed to be processed successfully. It allows the sink to retry the operation.
The gate parameter must be a valid gate of this module. The packet must not be nullptr.
Implements inet::queueing::IActivePacketSink.
1004 throw cRuntimeError(
"Not supported callback");
◆ handleSelfMessage()
| void inet::Ieee802154Mac::handleSelfMessage |
( |
cMessage * |
msg | ) |
|
|
overridevirtual |
Handle self messages such as timers.
Reimplemented from inet::LayeredProtocolBase.
767 EV_DETAIL <<
"timer routine." << endl;
779 EV <<
"CSMA Error: unknown timer fired:" << msg << endl;
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleUpperPacket()
| void inet::Ieee802154Mac::handleUpperPacket |
( |
Packet * |
packet | ) |
|
|
overridevirtual |
Handle messages from upper layer.
Encapsulates the message to be transmitted and pass it on to the FSM main method for further processing.
Reimplemented from inet::LayeredProtocolBase.
215 throw cRuntimeError(
"not supported");
◆ initialize()
| void inet::Ieee802154Mac::initialize |
( |
int |
stage | ) |
|
|
overridevirtual |
Initialization of the module and some variables.
Reimplemented from inet::MacProtocolBase.
75 std::string backoffMethodStr = par(
"backoffMethod").stdstringValue();
76 if (backoffMethodStr ==
"exponential") {
82 if (backoffMethodStr ==
"linear") {
85 else if (backoffMethodStr ==
"constant") {
89 throw cRuntimeError(
"Unknown backoff method \"%s\".\
90 Use \"constant\", \"linear\" or \"\
91 \"exponential\".", backoffMethodStr.c_str());
99 ccaTimer =
new cMessage(
"timer-cca");
105 radio.reference(
this,
"radioModule",
true);
109 cModule *radioModule = check_and_cast<cModule *>(
radio.get());
113 if (radioModule->hasPar(
"timeRXToTX")) {
114 simtime_t rxToTx = radioModule->par(
"timeRXToTX");
116 throw cRuntimeError(
"Parameter \"aTurnaroundTime\" (%f) does not match"
117 " the radios RX to TX switching time (%f)! It"
118 " should be equal or bigger",
124 EV_DETAIL <<
" bitrate = " <<
bitrate
125 <<
" backoff method = " << par(
"backoffMethod").stringValue() << endl;
◆ manageMissingAck()
| void inet::Ieee802154Mac::manageMissingAck |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
532 EV_DETAIL <<
"I will retransmit this packet (I already tried "
537 EV_DETAIL <<
"Packet was transmitted " <<
txAttempts
538 <<
" times and I never got an Ack. I drop the packet." << endl;
540 PacketDropDetails details;
◆ manageQueue()
| void inet::Ieee802154Mac::manageQueue |
( |
| ) |
|
|
protected |
655 EV_DETAIL <<
"(manageQueue) there are " <<
txQueue->getNumPackets() + (
currentTxFrame ==
nullptr ? 0 : 1) <<
" packets to send, entering backoff wait state." << endl;
673 EV_DETAIL <<
"(manageQueue) no packets to send, entering IDLE state." << endl;
◆ operator=()
Assignment operator is not allowed.
◆ receiveSignal()
| void inet::Ieee802154Mac::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
intval_t |
value, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
Handle control messages from lower layer.
890 Enter_Method(
"%s", cComponent::getSignalName(signalID));
◆ refreshDisplay()
| void inet::Ieee802154Mac::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
952 std::stringstream os;
960 os<<
"BACKOFF ("<<(
backoffTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<
"us)";
964 os<<
"CCA ("<<(
ccaTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<
"us)";
968 os<<
"TRANSMITING FRAME";
972 os<<
"WAITING ACK (" <<(
rxAckTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<
"us)";
976 os<<
"WAITING SIFS (" <<(
sifsTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<
"us)";
980 os<<
"TRANSMITING ACK";
983 os<<
"defined state";
986 getDisplayString().setTagArg(
"t", 0, os.str().c_str());
◆ scheduleBackoff()
| simtime_t inet::Ieee802154Mac::scheduleBackoff |
( |
| ) |
|
|
protectedvirtual |
722 simtime_t backoffTime;
727 int v = (1 << BE) - 1;
728 int r = intuniform(0, v, 0);
731 EV_DETAIL <<
"(startTimer) backoffTimer value=" << backoffTime
732 <<
" (BE=" << BE <<
", 2^BE-1= " << v <<
"r="
740 EV_DETAIL <<
"(startTimer) backoffTimer value=" << backoffTime << endl;
747 EV_DETAIL <<
"(startTimer) backoffTimer value=" << backoffTime << endl;
752 throw cRuntimeError(
"Unknown backoff method!");
◆ startTimer()
| void inet::Ieee802154Mac::startTimer |
( |
t_mac_timer |
timer | ) |
|
|
protected |
700 EV_DETAIL <<
"(startTimer) ccaTimer value=" << ccaTime
707 EV_DETAIL <<
"(startTimer) sifsTimer value=" <<
sifs << endl;
716 EV <<
"Unknown timer requested to start:" << timer << endl;
◆ updateMacState()
| void inet::Ieee802154Mac::updateMacState |
( |
t_mac_states |
newMacState | ) |
|
|
protected |
◆ updateStatusBackoff()
| void inet::Ieee802154Mac::updateStatusBackoff |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
273 EV_DETAIL <<
"(2) FSM State BACKOFF, EV_TIMER_BACKOFF:"
274 <<
" starting CCA timer." << endl;
284 EV_DETAIL <<
"(28) FSM State BACKOFF, EV_DUPLICATE_RECEIVED:";
286 EV_DETAIL <<
"suspending current transmit tentative and transmitting ack";
294 EV_DETAIL <<
"Nothing to do.";
305 EV_DETAIL <<
"(28) FSM State BACKOFF, EV_FRAME_RECEIVED:";
307 EV_DETAIL <<
"suspending current transmit tentative and transmitting ack";
316 EV_DETAIL <<
"sending frame up and resuming normal operation.";
323 EV_DETAIL <<
"(29) FSM State BACKOFF, EV_BROADCAST_RECEIVED:"
324 <<
"sending frame up and resuming normal operation." << endl;
◆ updateStatusCCA()
| void inet::Ieee802154Mac::updateStatusCCA |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
345 EV_DETAIL <<
"(25) FSM State CCA_3, EV_TIMER_CCA" << endl;
348 EV_DETAIL <<
"(3) FSM State CCA_3, EV_TIMER_CCA, [Channel Idle]: -> TRANSMITFRAME_4." << endl;
364 EV_DETAIL <<
"(7) FSM State CCA_3, EV_TIMER_CCA, [Channel Busy]: "
365 <<
" increment counters." << endl;
372 EV_DETAIL <<
"Tried " <<
NB <<
" backoffs, all reported a busy "
373 <<
"channel. Dropping the packet." << endl;
377 PacketDropDetails details;
383 EV_ERROR <<
"too many Backoffs, but currentTxFrame is empty\n";
397 EV_DETAIL <<
"(26) FSM State CCA_3, EV_DUPLICATE_RECEIVED:";
399 EV_DETAIL <<
" setting up radio tx -> WAITSIFS." << endl;
411 EV_DETAIL <<
" Nothing to do." << endl;
418 EV_DETAIL <<
"(26) FSM State CCA_3, EV_FRAME_RECEIVED:";
420 EV_DETAIL <<
" setting up radio tx -> WAITSIFS." << endl;
431 EV_DETAIL <<
" Nothing to do." << endl;
438 EV_DETAIL <<
"(24) FSM State BACKOFF, EV_BROADCAST_RECEIVED:"
439 <<
" Nothing to do." << endl;
◆ updateStatusIdle()
| void inet::Ieee802154Mac::updateStatusIdle |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
223 EV_DETAIL <<
"(1) FSM State IDLE_1, EV_SEND_REQUEST and [TxBuff avail]: startTimerBackOff -> BACKOFF." << endl;
232 EV_DETAIL <<
"(15) FSM State IDLE_1, EV_DUPLICATE_RECEIVED: setting up radio tx -> WAITSIFS." << endl;
244 EV_DETAIL <<
"(15) FSM State IDLE_1, EV_FRAME_RECEIVED: setting up radio tx -> WAITSIFS." << endl;
257 EV_DETAIL <<
"(23) FSM State IDLE_1, EV_BROADCAST_RECEIVED: Nothing to do." << endl;
◆ updateStatusNotIdle()
| void inet::Ieee802154Mac::updateStatusNotIdle |
( |
cMessage * |
msg | ) |
|
|
protected |
603 EV_DETAIL <<
"(20) FSM State NOT IDLE, EV_SEND_REQUEST. Is a TxBuffer available ?" << endl;
◆ updateStatusSIFS()
| void inet::Ieee802154Mac::updateStatusSIFS |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
554 EV_DETAIL <<
"(17) FSM State WAITSIFS_6, EV_TIMER_SIFS:"
555 <<
" sendAck -> TRANSMITACK." << endl;
567 EV_DETAIL <<
"(16) FSM State WAITSIFS_6, EV_TIMER_BACKOFF. "
568 <<
"Restart backoff timer and don't move." << endl;
574 EV <<
"Error ! Received a frame during SIFS !" << endl;
◆ updateStatusTransmitAck()
| void inet::Ieee802154Mac::updateStatusTransmitAck |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
590 EV_DETAIL <<
"(19) FSM State TRANSMITACK_7, EV_FRAME_TRANSMITTED:"
591 <<
" ->manageQueue." << endl;
◆ updateStatusTransmitFrame()
| void inet::Ieee802154Mac::updateStatusTransmitFrame |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
455 const auto& csmaHeader = packet->
peekAtFront<Ieee802154MacHeader>();
459 if (!csmaHeader->getDestAddr().isBroadcast() && !csmaHeader->getDestAddr().isMulticast()) {
461 EV_DETAIL <<
"(4) FSM State TRANSMITFRAME_4, "
462 <<
"EV_FRAME_TRANSMITTED [Unicast]: ";
466 EV_DETAIL <<
"(27) FSM State TRANSMITFRAME_4, EV_FRAME_TRANSMITTED "
472 EV_DETAIL <<
"RadioSetupRx -> WAITACK." << endl;
477 EV_DETAIL <<
": RadioSetupRx, manageQueue..." << endl;
◆ updateStatusWaitAck()
| void inet::Ieee802154Mac::updateStatusWaitAck |
( |
t_mac_event |
event, |
|
|
cMessage * |
msg |
|
) |
| |
|
protected |
494 EV_DETAIL <<
"(5) FSM State WAITACK_5, EV_ACK_RECEIVED: "
495 <<
" ProcessAck, manageQueue..." << endl;
505 EV_DETAIL <<
"(12) FSM State WAITACK_5, EV_ACK_TIMEOUT:"
506 <<
" incrementCounter/dropPacket, manageQueue..." << endl;
517 EV_DETAIL <<
"Error ! Received a frame during SIFS !" << endl;
◆ ackLength
| int inet::Ieee802154Mac::ackLength |
|
protected |
The bit length of the ACK packet.
◆ ackMessage
| Packet* inet::Ieee802154Mac::ackMessage |
|
protected |
◆ aTurnaroundTime
| simtime_t inet::Ieee802154Mac::aTurnaroundTime |
|
protected |
Time to switch radio from Rx to Tx state.
◆ aUnitBackoffPeriod
| simtime_t inet::Ieee802154Mac::aUnitBackoffPeriod |
|
protected |
base time unit for calculating backoff durations
◆ backoffMethod
Defines the backoff method to be used.
◆ backoffTimer
| cMessage* inet::Ieee802154Mac::backoffTimer |
|
protected |
◆ backoffValues
| double inet::Ieee802154Mac::backoffValues |
|
protected |
◆ bitrate
| double inet::Ieee802154Mac::bitrate |
|
protected |
the bit rate at which we transmit
◆ ccaDetectionTime
| simtime_t inet::Ieee802154Mac::ccaDetectionTime |
|
protected |
◆ ccaTimer
| cMessage * inet::Ieee802154Mac::ccaTimer |
|
protected |
◆ headerLength
| int inet::Ieee802154Mac::headerLength |
|
protected |
◆ initialCW
| int inet::Ieee802154Mac::initialCW |
|
protected |
initial contention window size Only used for linear and constant backoff method.
◆ macAckWaitDuration
| simtime_t inet::Ieee802154Mac::macAckWaitDuration |
|
protected |
The amount of time the MAC waits for the ACK of a packet.
◆ macMaxBE
| int inet::Ieee802154Mac::macMaxBE |
|
protected |
Maximum backoff exponent.
Only used for exponential backoff method.
◆ macMaxCSMABackoffs
| int inet::Ieee802154Mac::macMaxCSMABackoffs |
|
protected |
maximum number of extra backoffs (excluding the first unconditional one) before frame drop
◆ macMaxFrameRetries
| unsigned int inet::Ieee802154Mac::macMaxFrameRetries |
|
protected |
maximum number of frame retransmissions without ack
◆ macMinBE
| int inet::Ieee802154Mac::macMinBE |
|
protected |
Minimum backoff exponent.
Only used for exponential backoff method.
◆ macState
◆ NB
| int inet::Ieee802154Mac::NB |
|
protected |
number of backoff performed until now for current frame
◆ nbBackoffs
| long inet::Ieee802154Mac::nbBackoffs |
|
protected |
◆ nbDroppedFrames
| long inet::Ieee802154Mac::nbDroppedFrames |
|
protected |
◆ nbDuplicates
| long inet::Ieee802154Mac::nbDuplicates |
|
protected |
◆ nbMissedAcks
| long inet::Ieee802154Mac::nbMissedAcks |
|
protected |
◆ nbRecvdAcks
| long inet::Ieee802154Mac::nbRecvdAcks |
|
protected |
◆ nbRxFrames
| long inet::Ieee802154Mac::nbRxFrames |
|
protected |
◆ nbTxAcks
| long inet::Ieee802154Mac::nbTxAcks |
|
protected |
◆ nbTxFrames
| long inet::Ieee802154Mac::nbTxFrames |
|
protected |
◆ radio
◆ rxAckTimer
| cMessage * inet::Ieee802154Mac::rxAckTimer |
|
protected |
◆ rxSetupTime
| simtime_t inet::Ieee802154Mac::rxSetupTime |
|
protected |
Time to setup radio from sleep to Rx state.
◆ SeqNrChild
| std::map<MacAddress, unsigned long> inet::Ieee802154Mac::SeqNrChild |
|
protected |
◆ SeqNrParent
| std::map<MacAddress, unsigned long> inet::Ieee802154Mac::SeqNrParent |
|
protected |
◆ sifs
| simtime_t inet::Ieee802154Mac::sifs |
|
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.
◆ sifsTimer
| cMessage * inet::Ieee802154Mac::sifsTimer |
|
protected |
◆ status
◆ transmissionAttemptInterruptedByRx
| bool inet::Ieee802154Mac::transmissionAttemptInterruptedByRx |
|
protected |
◆ transmissionState
◆ txAttempts
| unsigned int inet::Ieee802154Mac::txAttempts |
|
protected |
count the number of tx attempts
This holds the number of transmission attempts for the current frame.
◆ txPower
| double inet::Ieee802154Mac::txPower |
|
protected |
The power (in mW) to transmit with.
◆ useMACAcks
| bool inet::Ieee802154Mac::useMACAcks |
|
protected |
Stores if the MAC expects Acks for Unicast packets.
The documentation for this class was generated from the following files:
void fsmError(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:686
opp_component_ptr< NetworkInterface > networkInterface
Definition: MacProtocolBase.h:30
backoff_methods backoffMethod
Defines the backoff method to be used.
Definition: Ieee802154Mac.h:244
@ CONSTANT
Constant back-off time.
Definition: Ieee802154Mac.h:199
virtual void handleCrashOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:142
int ackLength
The bit length of the ACK packet.
Definition: Ieee802154Mac.h:277
const Ptr< T > addTag()
Returns a newly added packet tag for the provided type, or throws an exception if such a packet tag i...
Definition: Packet.h:1310
void updateStatusTransmitFrame(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:450
long nbTxAcks
Definition: Ieee802154Mac.h:123
@ RECEPTION_STATE_IDLE
The radio medium is free, no signal is detected.
Definition: IRadio.h:136
long nbRxFrames
Definition: Ieee802154Mac.h:119
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
@ EV_TIMER_BACKOFF
Definition: Ieee802154Mac.h:164
cMessage * sifsTimer
Definition: Ieee802154Mac.h:157
simtime_t aUnitBackoffPeriod
base time unit for calculating backoff durations
Definition: Ieee802154Mac.h:239
void updateStatusNotIdle(cMessage *msg)
Definition: Ieee802154Mac.cc:601
virtual void handleStartOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:124
void updateMacState(t_mac_states newMacState)
Definition: Ieee802154Mac.cc:678
double txPower
The power (in mW) to transmit with.
Definition: Ieee802154Mac.h:262
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
@ STATUS_FRAME_TRANSMITTED
Definition: Ieee802154Mac.h:193
const Ptr< const Chunk > peekAtFront(b length=b(-1), int flags=0) const
Returns the designated part from the beginning of the data part of the packet as an immutable chunk i...
Definition: Packet.h:245
long nbRecvdAcks
Definition: Ieee802154Mac.h:121
@ RETRY_LIMIT_REACHED
Definition: Simsignals_m.h:78
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
int NB
number of backoff performed until now for current frame
Definition: Ieee802154Mac.h:265
int initialCW
initial contention window size Only used for linear and constant backoff method.
Definition: Ieee802154Mac.h:259
@ STATUS_FRAME_TO_PROCESS
Definition: Ieee802154Mac.h:191
@ EV_BROADCAST_RECEIVED
Definition: Ieee802154Mac.h:171
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
ModuleRefByPar< physicallayer::IRadio > radio
The radio.
Definition: Ieee802154Mac.h:211
double bitrate
the bit rate at which we transmit
Definition: Ieee802154Mac.h:274
void manageMissingAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:527
@ STATUS_ERROR
Definition: Ieee802154Mac.h:188
std::map< MacAddress, unsigned long > SeqNrChild
Definition: Ieee802154Mac.h:320
virtual void dropCurrentTxFrame(PacketDropDetails &details)
Definition: MacProtocolBase.cc:99
unsigned int txAttempts
count the number of tx attempts
Definition: Ieee802154Mac.h:271
simtime_t sifs
Maximum time between a packet and its ACK.
Definition: Ieee802154Mac.h:219
double backoffValues
Definition: Ieee802154Mac.h:126
@ STATUS_RX_ERROR
Definition: Ieee802154Mac.h:189
Packet * ackMessage
Definition: Ieee802154Mac.h:313
long nbMissedAcks
Definition: Ieee802154Mac.h:120
@ TIMER_CCA
Definition: Ieee802154Mac.h:150
static simsignal_t transmissionStateChangedSignal
This signal is emitted when the radio transmission state of the radio is changed.
Definition: IRadio.h:60
int macMaxCSMABackoffs
maximum number of extra backoffs (excluding the first unconditional one) before frame drop
Definition: Ieee802154Mac.h:235
long nbTxFrames
Definition: Ieee802154Mac.h:118
int headerLength
Length of the header.
Definition: Ieee802154Mac.h:225
virtual void handleStopOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:130
@ EV_FRAME_RECEIVED
Definition: Ieee802154Mac.h:168
@ RADIO_MODE_TRANSMITTER
The radio is prepared for frame transmission, frame reception is not possible, power consumption is l...
Definition: IRadio.h:104
void updateStatusSIFS(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:548
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
void updateStatusWaitAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:488
unsigned int macMaxFrameRetries
maximum number of frame retransmissions without ack
Definition: Ieee802154Mac.h:237
@ EV_TIMER_CCA
Definition: Ieee802154Mac.h:172
@ WAITACK_5
Definition: Ieee802154Mac.h:137
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
MacProtocolBase()
Definition: MacProtocolBase.cc:15
void executeMac(t_mac_event event, cMessage *msg)
Updates state machine.
Definition: Ieee802154Mac.cc:609
virtual simtime_t scheduleBackoff()
Definition: Ieee802154Mac.cc:720
static const Protocol ieee802154
Definition: Protocol.h:83
@ TIMER_NULL
Definition: Ieee802154Mac.h:148
@ EV_TIMER_SIFS
Definition: Ieee802154Mac.h:170
@ EV_SEND_REQUEST
Definition: Ieee802154Mac.h:163
@ TRANSMITACK_7
Definition: Ieee802154Mac.h:139
virtual Packet * dup() const override
Definition: Packet.h:171
@ EV_DUPLICATE_RECEIVED
Definition: Ieee802154Mac.h:169
void insertAtFront(const Ptr< const Chunk > &chunk)
Inserts the provided chunk at the beginning of the data part of the packet.
Definition: Packet.h:583
@ RADIO_MODE_RECEIVER
The radio is prepared for frame reception, frame transmission is not possible, power consumption is l...
Definition: IRadio.h:97
simtime_t ccaDetectionTime
CCA detection time.
Definition: Ieee802154Mac.h:229
virtual void decapsulate(Packet *packet)
Definition: Ieee802154Mac.cc:902
cMessage * rxAckTimer
Definition: Ieee802154Mac.h:157
void updateStatusCCA(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:341
@ TIMER_RX_ACK
Definition: Ieee802154Mac.h:152
bool useMACAcks
Stores if the MAC expects Acks for Unicast packets.
Definition: Ieee802154Mac.h:241
simtime_t rxSetupTime
Time to setup radio from sleep to Rx state.
Definition: Ieee802154Mac.h:231
Packet * currentTxFrame
Currently transmitted frame if any.
Definition: MacProtocolBase.h:35
@ CHANNEL_BUSY
Definition: Ieee802154Mac.h:182
@ IDLE_1
Definition: Ieee802154Mac.h:133
void startTimer(t_mac_timer timer)
Definition: Ieee802154Mac.cc:693
void attachSignal(Packet *mac, simtime_t_cref startTime)
Definition: Ieee802154Mac.cc:335
@ DATA
Definition: Ieee802154Mac.h:177
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
@ EV_ACK_RECEIVED
Definition: Ieee802154Mac.h:166
int upperLayerInGateId
Gate ids.
Definition: MacProtocolBase.h:24
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
std::map< MacAddress, unsigned long > SeqNrParent
Definition: Ieee802154Mac.h:317
long nbDuplicates
Definition: Ieee802154Mac.h:124
@ TRANSMISSION_STATE_TRANSMITTING
The radio medium is busy, the radio is currently transmitting a signal.
Definition: IRadio.h:171
t_mac_states macState
keep track of MAC state
Definition: Ieee802154Mac.h:207
value< int64_t, units::b > b
Definition: Units.h:1241
@ CCA_3
Definition: Ieee802154Mac.h:135
@ STATUS_RX_TIMEOUT
Definition: Ieee802154Mac.h:190
virtual void deleteCurrentTxFrame()
Definition: MacProtocolBase.cc:93
void manageQueue()
Definition: Ieee802154Mac.cc:652
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
@ EXPONENTIAL
Exponentially increasing back-off time.
Definition: Ieee802154Mac.h:203
@ TIMER_BACKOFF
Definition: Ieee802154Mac.h:149
@ TRANSMITFRAME_4
Definition: Ieee802154Mac.h:136
queueing::IPacketQueue * getQueue(cGate *gate) const
Definition: MacProtocolBase.cc:157
#define Enter_Method(...)
Definition: SelfDoc.h:71
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
cMessage * ccaTimer
Definition: Ieee802154Mac.h:157
@ STATUS_NO_FRAME_TO_PROCESS
Definition: Ieee802154Mac.h:192
cMessage * backoffTimer
Definition: Ieee802154Mac.h:157
@ CONGESTION
Definition: Simsignals_m.h:80
long nbDroppedFrames
Definition: Ieee802154Mac.h:122
int lowerLayerOutGateId
Definition: MacProtocolBase.h:27
virtual Packet * dequeuePacket()
Definition: MacProtocolBase.cc:175
virtual MacAddress parseMacAddressParameter(const char *addrstr)
Definition: MacProtocolBase.cc:24
void updateStatusIdle(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:218
void updateStatusBackoff(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:269
simtime_t macAckWaitDuration
The amount of time the MAC waits for the ACK of a packet.
Definition: Ieee802154Mac.h:222
@ TIMER_SIFS
Definition: Ieee802154Mac.h:151
@ ACK
Definition: Ieee802154Mac.h:178
const Protocol * getProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:31
opp_component_ptr< queueing::IPacketQueue > txQueue
Messages received from upper layer and to be transmitted later.
Definition: MacProtocolBase.h:38
@ TRANSMISSION_STATE_UNDEFINED
The transmission state is undefined or meaningless.
Definition: IRadio.h:160
int macMinBE
Minimum backoff exponent.
Definition: Ieee802154Mac.h:250
@ BACKOFF_2
Definition: Ieee802154Mac.h:134
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
@ EV_ACK_TIMEOUT
Definition: Ieee802154Mac.h:167
@ WAITSIFS_6
Definition: Ieee802154Mac.h:138
@ LINEAR
Linear increasing back-off time.
Definition: Ieee802154Mac.h:201
physicallayer::IRadio::TransmissionState transmissionState
Definition: Ieee802154Mac.h:212
@ STATUS_OK
Definition: Ieee802154Mac.h:187
simtime_t aTurnaroundTime
Time to switch radio from Rx to Tx state.
Definition: Ieee802154Mac.h:233
t_mac_status status
Definition: Ieee802154Mac.h:208
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
bool transmissionAttemptInterruptedByRx
Definition: Ieee802154Mac.h:227
void updateStatusTransmitAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:585
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80
int macMaxBE
Maximum backoff exponent.
Definition: Ieee802154Mac.h:255
@ EV_FRAME_TRANSMITTED
Definition: Ieee802154Mac.h:165
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40
long nbBackoffs
Definition: Ieee802154Mac.h:125
@ CHANNEL_FREE
Definition: Ieee802154Mac.h:183
virtual void encapsulate(Packet *packet)
Encapsulates the message.
Definition: Ieee802154Mac.cc:178