INET Framework for OMNeT++/OMNEST
inet::Ieee802154Mac Class Reference

Generic CSMA Mac-Layer. More...

#include <Ieee802154Mac.h>

Inheritance diagram for inet::Ieee802154Mac:
inet::MacProtocolBase inet::IMacProtocol inet::queueing::IActivePacketSink inet::LayeredProtocolBase inet::OperationalBase inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 Ieee802154Mac ()
 
virtual ~Ieee802154Mac ()
 
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 (Packet *packet) override
 Handle messages from lower layer. More...
 
virtual void handleUpperPacket (Packet *packet) 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, intval_t value, cObject *details) override
 Handle control messages from lower layer. More...
 
virtual queueing::IPassivePacketSourcegetProvider (cGate *gate) override
 Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface. More...
 
virtual void handleCanPullPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate. More...
 
virtual void handlePullPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pulled earlier independently whether the packet is passed or streamed. More...
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::IMacProtocol
virtual ~IMacProtocol ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSink
virtual ~IActivePacketSink ()
 

Different tracked statistics.

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
 

Pointer for timer messages.

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::IRadioradio
 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...
 
PacketackMessage
 
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...
 
Ieee802154Macoperator= (const Ieee802154Mac &)
 Assignment operator is not allowed. More...
 

Additional Inherited Members

- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 
- Protected Member Functions inherited from inet::MacProtocolBase
 MacProtocolBase ()
 
virtual ~MacProtocolBase ()
 
virtual void registerInterface ()
 
virtual MacAddress parseMacAddressParameter (const char *addrstr)
 
virtual void deleteCurrentTxFrame ()
 
virtual void dropCurrentTxFrame (PacketDropDetails &details)
 
virtual void handleMessageWhenDown (cMessage *msg) override
 
virtual void sendUp (cMessage *message)
 
virtual void sendDown (cMessage *message)
 
virtual bool isUpperMessage (cMessage *message) const override
 
virtual bool isLowerMessage (cMessage *message) const override
 
virtual bool isInitializeStage (int stage) const override
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
virtual void flushQueue (PacketDropDetails &details)
 should clear queue and emit signal "packetDropped" with entire packets More...
 
virtual void clearQueue ()
 should clear queue silently More...
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
queueing::IPacketQueuegetQueue (cGate *gate) const
 
virtual bool canDequeuePacket () const
 
virtual PacketdequeuePacket ()
 
- Protected Member Functions inherited from inet::LayeredProtocolBase
virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleUpperMessage (cMessage *message)
 
virtual void handleLowerMessage (cMessage *message)
 
virtual void handleUpperCommand (cMessage *message)
 
virtual void handleLowerCommand (cMessage *message)
 
- Protected Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual State getInitialOperationalState () const
 Returns initial operational state: OPERATING or NOT_OPERATING. More...
 
virtual void handleActiveOperationTimeout (cMessage *message)
 
virtual bool isUp () const
 utility functions More...
 
virtual bool isDown () const
 
virtual void setOperationalState (State newState)
 
virtual void scheduleOperationTimeout (simtime_t timeout)
 
virtual void setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State)
 
virtual void delayActiveOperationFinish (simtime_t timeout)
 
virtual void startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO)
 
virtual void startActiveOperationExtraTimeOrFinish (simtime_t extraTime)
 
virtual void finishActiveOperation ()
 
- Protected Attributes inherited from inet::MacProtocolBase
int upperLayerInGateId = -1
 Gate ids. More...
 
int upperLayerOutGateId = -1
 
int lowerLayerInGateId = -1
 
int lowerLayerOutGateId = -1
 
opp_component_ptr< NetworkInterfacenetworkInterface
 
opp_component_ptr< cModule > hostModule
 
PacketcurrentTxFrame = nullptr
 Currently transmitted frame if any. More...
 
opp_component_ptr< queueing::IPacketQueuetxQueue
 Messages received from upper layer and to be transmitted later. More...
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 

Detailed Description

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

Member Enumeration Documentation

◆ 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.

197  {
199  CONSTANT = 0,
201  LINEAR,
203  EXPONENTIAL,
204  };

◆ t_csma_frame_types

Types for frames sent by the CSMA.

Enumerator
DATA 
ACK 
176  {
177  DATA,
178  ACK
179  };

◆ t_mac_carrier_sensed

Enumerator
CHANNEL_BUSY 
CHANNEL_FREE 
181  {
182  CHANNEL_BUSY = 1,
184  };

◆ 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 
162  {
163  EV_SEND_REQUEST = 1, // 1, 11, 20, 21, 22
164  EV_TIMER_BACKOFF, // 2, 7, 14, 15
165  EV_FRAME_TRANSMITTED, // 4, 19
166  EV_ACK_RECEIVED, // 5
167  EV_ACK_TIMEOUT, // 12
168  EV_FRAME_RECEIVED, // 15, 26
170  EV_TIMER_SIFS, // 17
171  EV_BROADCAST_RECEIVED, // 23, 24
173  };

◆ t_mac_states

MAC states see states diagram.

Enumerator
IDLE_1 
BACKOFF_2 
CCA_3 
TRANSMITFRAME_4 
WAITACK_5 
WAITSIFS_6 
TRANSMITACK_7 
132  {
133  IDLE_1 = 1,
134  BACKOFF_2,
135  CCA_3,
137  WAITACK_5,
138  WAITSIFS_6,
140  };

◆ 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 
147  {
148  TIMER_NULL = 0,
150  TIMER_CCA,
151  TIMER_SIFS,
152  TIMER_RX_ACK,
153  };

Constructor & Destructor Documentation

◆ Ieee802154Mac() [1/2]

inet::Ieee802154Mac::Ieee802154Mac ( )
inline
51  : MacProtocolBase()
52  , nbTxFrames(0)
53  , nbRxFrames(0)
54  , nbMissedAcks(0)
55  , nbRecvdAcks(0)
56  , nbDroppedFrames(0)
57  , nbTxAcks(0)
58  , nbDuplicates(0)
59  , nbBackoffs(0)
60  , backoffValues(0)
61  , backoffTimer(nullptr), ccaTimer(nullptr), sifsTimer(nullptr), rxAckTimer(nullptr)
62  , macState(IDLE_1)
63  , status(STATUS_OK)
65  , sifs()
67  , headerLength(0)
70  , rxSetupTime()
71  , aTurnaroundTime()
75  , useMACAcks(false)
77  , macMinBE(0)
78  , macMaxBE(0)
79  , initialCW(0)
80  , txPower(0)
81  , NB(0)
82  , txAttempts(0)
83  , bitrate(0)
84  , ackLength(0)
85  , ackMessage(nullptr)
86  , SeqNrParent()
87  , SeqNrChild()
88  {}

◆ ~Ieee802154Mac()

inet::Ieee802154Mac::~Ieee802154Mac ( )
virtual
149 {
150  cancelAndDelete(backoffTimer);
151  cancelAndDelete(ccaTimer);
152  cancelAndDelete(sifsTimer);
153  cancelAndDelete(rxAckTimer);
154  if (ackMessage)
155  delete ackMessage;
156 }

◆ Ieee802154Mac() [2/2]

inet::Ieee802154Mac::Ieee802154Mac ( const Ieee802154Mac )
private

Copy constructor is not allowed.

Member Function Documentation

◆ attachSignal()

void inet::Ieee802154Mac::attachSignal ( Packet mac,
simtime_t_cref  startTime 
)
protected
336 {
337  simtime_t duration = mac->getBitLength() / bitrate;
338  mac->setDuration(duration);
339 }

◆ configureNetworkInterface()

void inet::Ieee802154Mac::configureNetworkInterface ( )
overrideprotectedvirtual

Generate new interface address.

Implements inet::MacProtocolBase.

159 {
160  MacAddress address = parseMacAddressParameter(par("address"));
161 
162  // data rate
163  networkInterface->setDatarate(bitrate);
164 
165  // generate a link-layer address to be used as interface token for IPv6
166  networkInterface->setMacAddress(address);
167  networkInterface->setInterfaceToken(address.formInterfaceIdentifier());
168 
169  // capabilities
170  networkInterface->setMtu(par("mtu"));
171  networkInterface->setMulticast(true);
172  networkInterface->setBroadcast(true);
173 }

◆ decapsulate()

void inet::Ieee802154Mac::decapsulate ( Packet packet)
protectedvirtual
903 {
904  const auto& csmaHeader = packet->popAtFront<Ieee802154MacHeader>();
905  packet->addTagIfAbsent<MacAddressInd>()->setSrcAddress(csmaHeader->getSrcAddr());
906  packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(networkInterface->getInterfaceId());
907  auto payloadProtocol = ProtocolGroup::ethertype.getProtocol(csmaHeader->getNetworkProtocol());
908  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(payloadProtocol);
909  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(payloadProtocol);
910 }

◆ encapsulate()

void inet::Ieee802154Mac::encapsulate ( Packet packet)
protectedvirtual

Encapsulates the message.

179 {
180  auto macPkt = makeShared<Ieee802154MacHeader>();
181  assert(headerLength % 8 == 0);
182  macPkt->setChunkLength(b(headerLength));
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;
185  macPkt->setNetworkProtocol(ProtocolGroup::ethertype.getProtocolNumber(packet->getTag<PacketProtocolTag>()->getProtocol()));
186  macPkt->setDestAddr(dest);
187  delete packet->removeControlInfo();
188  macPkt->setSrcAddr(networkInterface->getMacAddress());
189 
190  if (useMACAcks) {
191  if (!containsKey(SeqNrParent, dest)) {
192  // no record of current parent -> add next sequence number to map
193  SeqNrParent[dest] = 1;
194  macPkt->setSequenceId(0);
195  EV_DETAIL << "Adding a new parent to the map of Sequence numbers:" << dest << endl;
196  }
197  else {
198  macPkt->setSequenceId(SeqNrParent[dest]);
199  EV_DETAIL << "Packet send with sequence number = " << SeqNrParent[dest] << endl;
200  SeqNrParent[dest]++;
201  }
202  }
203 
204  packet->insertAtFront(macPkt);
205  packet->getTagForUpdate<PacketProtocolTag>()->setProtocol(&Protocol::ieee802154);
206  EV_DETAIL << "pkt encapsulated, length: " << macPkt->getChunkLength() << "\n";
207 }

◆ executeMac()

void inet::Ieee802154Mac::executeMac ( t_mac_event  event,
cMessage *  msg 
)
protected

Updates state machine.

610 {
611  EV_DETAIL << "In executeMac" << endl;
612  if (macState != IDLE_1 && event == EV_SEND_REQUEST) {
613  updateStatusNotIdle(msg);
614  }
615  else {
616  switch (macState) {
617  case IDLE_1:
618  updateStatusIdle(event, msg);
619  break;
620 
621  case BACKOFF_2:
622  updateStatusBackoff(event, msg);
623  break;
624 
625  case CCA_3:
626  updateStatusCCA(event, msg);
627  break;
628 
629  case TRANSMITFRAME_4:
630  updateStatusTransmitFrame(event, msg);
631  break;
632 
633  case WAITACK_5:
634  updateStatusWaitAck(event, msg);
635  break;
636 
637  case WAITSIFS_6:
638  updateStatusSIFS(event, msg);
639  break;
640 
641  case TRANSMITACK_7:
642  updateStatusTransmitAck(event, msg);
643  break;
644 
645  default:
646  EV << "Error in CSMA FSM: an unknown state has been reached. macState=" << macState << endl;
647  break;
648  }
649  }
650 }

◆ finish()

void inet::Ieee802154Mac::finish ( )
overridevirtual

Delete all dynamically allocated objects of the module.

130 {
131  recordScalar("nbTxFrames", nbTxFrames);
132  recordScalar("nbRxFrames", nbRxFrames);
133  recordScalar("nbDroppedFrames", nbDroppedFrames);
134  recordScalar("nbMissedAcks", nbMissedAcks);
135  recordScalar("nbRecvdAcks", nbRecvdAcks);
136  recordScalar("nbTxAcks", nbTxAcks);
137  recordScalar("nbDuplicates", nbDuplicates);
138  if (nbBackoffs > 0) {
139  recordScalar("meanBackoff", backoffValues / nbBackoffs);
140  }
141  else {
142  recordScalar("meanBackoff", 0);
143  }
144  recordScalar("nbBackoffs", nbBackoffs);
145  recordScalar("backoffDurations", backoffValues);
146 }

◆ fsmError()

void inet::Ieee802154Mac::fsmError ( t_mac_event  event,
cMessage *  msg 
)
protected
687 {
688  EV << "FSM Error ! In state " << macState << ", received unknown event:" << event << "." << endl;
689  if (msg != nullptr)
690  delete msg;
691 }

◆ getProvider()

queueing::IPassivePacketSource * inet::Ieee802154Mac::getProvider ( cGate *  gate)
overridevirtual

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.

990 {
991  return (gate->getId() == upperLayerInGateId) ? txQueue.get() : nullptr;
992 }

◆ 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.

995 {
996  Enter_Method("handleCanPullPacketChanged");
997  if (gate->getId() == upperLayerInGateId)
998  executeMac(EV_SEND_REQUEST, nullptr);
999 }

◆ handleCommand()

virtual void inet::Ieee802154Mac::handleCommand ( cMessage *  msg)
inlineprotectedvirtual
282 {}

◆ handleCrashOperation()

void inet::Ieee802154Mac::handleCrashOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

938 {
939  cancelEvent(backoffTimer);
940  cancelEvent(ccaTimer);
941  cancelEvent(sifsTimer);
942  cancelEvent(rxAckTimer);
943 
944  cModule *radioModule = check_and_cast<cModule *>(radio.get());
945  radioModule->unsubscribe(IRadio::transmissionStateChangedSignal, this);
946 
948 }

◆ 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.

787 {
788  if (packet->hasBitError()) {
789  EV << "Received " << packet << " contains bit errors or collision, dropping it\n";
790  PacketDropDetails details;
791  details.setReason(INCORRECTLY_RECEIVED);
792  emit(packetDroppedSignal, packet, &details);
793  delete packet;
794  return;
795  }
796  const auto& csmaHeader = packet->peekAtFront<Ieee802154MacHeader>();
797  const MacAddress& src = csmaHeader->getSrcAddr();
798  const MacAddress& dest = csmaHeader->getDestAddr();
799  long ExpectedNr = 0;
800  MacAddress address = networkInterface->getMacAddress();
801 
802  EV_DETAIL << "Received frame name= " << csmaHeader->getName()
803  << ", myState=" << macState << " src=" << src
804  << " dst=" << dest << " myAddr="
805  << address << endl;
806 
807  if (dest == address) {
808  if (!useMACAcks) {
809  EV_DETAIL << "Received a data packet addressed to me." << endl;
810 // nbRxFrames++;
811  executeMac(EV_FRAME_RECEIVED, packet);
812  }
813  else {
814  long SeqNr = csmaHeader->getSequenceId();
815 
816  if (strcmp(packet->getName(), "CSMA-Ack") != 0) {
817  // This is a data message addressed to us
818  // and we should send an ack.
819  // we build the ack packet here because we need to
820  // copy data from macPkt (src).
821  EV_DETAIL << "Received a data packet addressed to me,"
822  << " preparing an ack..." << endl;
823 
824 // nbRxFrames++;
825 
826  if (ackMessage != nullptr)
827  delete ackMessage;
828  auto csmaHeader = makeShared<Ieee802154MacHeader>();
829  csmaHeader->setSrcAddr(address);
830  csmaHeader->setDestAddr(src);
831  csmaHeader->setChunkLength(b(ackLength));
832  ackMessage = new Packet("CSMA-Ack");
833  ackMessage->insertAtFront(csmaHeader);
835  // Check for duplicates by checking expected seqNr of sender
836  if (!containsKey(SeqNrChild, src)) {
837  // no record of current child -> add expected next number to map
838  SeqNrChild[src] = SeqNr + 1;
839  EV_DETAIL << "Adding a new child to the map of Sequence numbers:" << src << endl;
840  executeMac(EV_FRAME_RECEIVED, packet);
841  }
842  else {
843  ExpectedNr = SeqNrChild[src];
844  EV_DETAIL << "Expected Sequence number is " << ExpectedNr
845  << " and number of packet is " << SeqNr << endl;
846  if (SeqNr < ExpectedNr) {
847  // Duplicate Packet, count and do not send to upper layer
848  nbDuplicates++;
850  }
851  else {
852  SeqNrChild[src] = SeqNr + 1;
853  executeMac(EV_FRAME_RECEIVED, packet);
854  }
855  }
856  }
857  else if (currentTxFrame != nullptr) {
858  // message is an ack, and it is for us.
859  // Is it from the right node ?
860  const auto& csmaHeader = currentTxFrame->peekAtFront<Ieee802154MacHeader>();
861  if (src == csmaHeader->getDestAddr()) {
862  nbRecvdAcks++;
863  executeMac(EV_ACK_RECEIVED, packet);
864  }
865  else {
866  EV << "Error! Received an ack from an unexpected source: src=" << src << ", I was expecting from node addr=" << csmaHeader->getDestAddr() << endl;
867  delete packet;
868  }
869  }
870  else {
871  EV << "Error! Received an Ack while my send queue was empty. src=" << src << "." << endl;
872  delete packet;
873  }
874  }
875  }
876  else if (dest.isBroadcast() || dest.isMulticast()) {
878  }
879  else {
880  EV_DETAIL << "packet not for me, deleting...\n";
881  PacketDropDetails details;
882  details.setReason(NOT_ADDRESSED_TO_US);
883  emit(packetDroppedSignal, packet, &details);
884  delete packet;
885  }
886 }

◆ 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.

1002 {
1003  Enter_Method("handlePullPacketProcessed");
1004  throw cRuntimeError("Not supported callback");
1005 }

◆ handleSelfMessage()

void inet::Ieee802154Mac::handleSelfMessage ( cMessage *  msg)
overridevirtual

Handle self messages such as timers.

Reimplemented from inet::LayeredProtocolBase.

766 {
767  EV_DETAIL << "timer routine." << endl;
768  if (msg == backoffTimer)
770  else if (msg == ccaTimer)
771  executeMac(EV_TIMER_CCA, msg);
772  else if (msg == sifsTimer)
774  else if (msg == rxAckTimer) {
775  nbMissedAcks++;
777  }
778  else
779  EV << "CSMA Error: unknown timer fired:" << msg << endl;
780 }

◆ handleStartOperation()

void inet::Ieee802154Mac::handleStartOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

913 {
915  // manageQueue() to see waiting packets or set to idle if none
917 
918  cModule *radioModule = check_and_cast<cModule *>(radio.get());
919  radioModule->subscribe(IRadio::transmissionStateChangedSignal, this);
920 }

◆ handleStopOperation()

void inet::Ieee802154Mac::handleStopOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

923 {
924  // TODO More gracefully allow current Tx to end (delay operation)
925  // Cancel all self message timers
926  cancelEvent(backoffTimer);
927  cancelEvent(ccaTimer);
928  cancelEvent(sifsTimer);
929  cancelEvent(rxAckTimer);
930 
931  cModule *radioModule = check_and_cast<cModule *>(radio.get());
932  radioModule->unsubscribe(IRadio::transmissionStateChangedSignal, this);
933 
935 }

◆ 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.

214 {
215  throw cRuntimeError("not supported");
216 }

◆ initialize()

void inet::Ieee802154Mac::initialize ( int  stage)
overridevirtual

Initialization of the module and some variables.

Reimplemented from inet::MacProtocolBase.

47 {
49  if (stage == INITSTAGE_LOCAL) {
50  useMACAcks = par("useMACAcks");
51  sifs = par("sifs");
52  headerLength = par("headerLength");
54  nbTxFrames = 0;
55  nbRxFrames = 0;
56  nbMissedAcks = 0;
57  nbTxAcks = 0;
58  nbRecvdAcks = 0;
59  nbDroppedFrames = 0;
60  nbDuplicates = 0;
61  nbBackoffs = 0;
62  backoffValues = 0;
63  macMaxCSMABackoffs = par("macMaxCSMABackoffs");
64  macMaxFrameRetries = par("macMaxFrameRetries");
65  macAckWaitDuration = par("macAckWaitDuration");
66  aUnitBackoffPeriod = par("aUnitBackoffPeriod");
67  ccaDetectionTime = par("ccaDetectionTime");
68  rxSetupTime = par("rxSetupTime");
69  aTurnaroundTime = par("aTurnaroundTime");
70  bitrate = par("bitrate");
71  ackLength = par("ackLength");
72  ackMessage = nullptr;
73 
74  // init parameters for backoff method
75  std::string backoffMethodStr = par("backoffMethod").stdstringValue();
76  if (backoffMethodStr == "exponential") {
78  macMinBE = par("macMinBE");
79  macMaxBE = par("macMaxBE");
80  }
81  else {
82  if (backoffMethodStr == "linear") {
84  }
85  else if (backoffMethodStr == "constant") {
87  }
88  else {
89  throw cRuntimeError("Unknown backoff method \"%s\".\
90  Use \"constant\", \"linear\" or \"\
91  \"exponential\".", backoffMethodStr.c_str());
92  }
93  initialCW = par("contentionWindow");
94  }
95  NB = 0;
96 
97  // initialize the timers
98  backoffTimer = new cMessage("timer-backoff");
99  ccaTimer = new cMessage("timer-cca");
100  sifsTimer = new cMessage("timer-sifs");
101  rxAckTimer = new cMessage("timer-rxAck");
102  macState = IDLE_1;
103  txAttempts = 0;
105  radio.reference(this, "radioModule", true);
106  WATCH(macState);
107  }
108  else if (stage == INITSTAGE_LINK_LAYER) {
109  cModule *radioModule = check_and_cast<cModule *>(radio.get());
110  // check parameters for consistency
111  // aTurnaroundTime should match (be equal or bigger) the RX to TX
112  // switching time of the radio
113  if (radioModule->hasPar("timeRXToTX")) {
114  simtime_t rxToTx = radioModule->par("timeRXToTX");
115  if (rxToTx > aTurnaroundTime) {
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",
119  SIMTIME_DBL(aTurnaroundTime), SIMTIME_DBL(rxToTx));
120  }
121  }
122  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
123 
124  EV_DETAIL << " bitrate = " << bitrate
125  << " backoff method = " << par("backoffMethod").stringValue() << endl;
126  }
127 }

◆ manageMissingAck()

void inet::Ieee802154Mac::manageMissingAck ( t_mac_event  event,
cMessage *  msg 
)
protected
528 {
530  // increment counter
531  txAttempts++;
532  EV_DETAIL << "I will retransmit this packet (I already tried "
533  << txAttempts << " times)." << endl;
534  }
535  else {
536  // drop packet
537  EV_DETAIL << "Packet was transmitted " << txAttempts
538  << " times and I never got an Ack. I drop the packet." << endl;
539  txAttempts = 0;
540  PacketDropDetails details;
541  details.setReason(RETRY_LIMIT_REACHED);
542  details.setLimit(macMaxFrameRetries);
543  dropCurrentTxFrame(details);
544  }
545  manageQueue();
546 }

◆ manageQueue()

void inet::Ieee802154Mac::manageQueue ( )
protected
653 {
654  if (currentTxFrame != nullptr || !txQueue->isEmpty()) {
655  EV_DETAIL << "(manageQueue) there are " << txQueue->getNumPackets() + (currentTxFrame == nullptr ? 0 : 1) << " packets to send, entering backoff wait state." << endl;
657  // resume a transmission cycle which was interrupted by
658  // a frame reception during CCA check
660  }
661  else {
662  // initialize counters if we start a new transmission
663  // cycle from zero
664  NB = 0;
665 // BE = macMinBE;
666  }
667  if (!backoffTimer->isScheduled()) {
669  }
671  }
672  else {
673  EV_DETAIL << "(manageQueue) no packets to send, entering IDLE state." << endl;
675  }
676 }

◆ operator=()

Ieee802154Mac& inet::Ieee802154Mac::operator= ( const Ieee802154Mac )
private

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.

889 {
890  Enter_Method("%s", cComponent::getSignalName(signalID));
891 
892  if (signalID == IRadio::transmissionStateChangedSignal) {
893  IRadio::TransmissionState newRadioTransmissionState = static_cast<IRadio::TransmissionState>(value);
895  // KLUDGE we used to get a cMessage from the radio (the identity was not important)
896  executeMac(EV_FRAME_TRANSMITTED, new cMessage("Transmission over"));
897  }
898  transmissionState = newRadioTransmissionState;
899  }
900 }

◆ refreshDisplay()

void inet::Ieee802154Mac::refreshDisplay ( ) const
overrideprotectedvirtual
951 {
952  std::stringstream os;
953  os<<"";
954  switch (macState) {
955  case IDLE_1:
956  os<< "IDLE";
957  break;
958 
959  case BACKOFF_2:
960  os<< "BACKOFF ("<<(backoffTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<"us)";
961  break;
962 
963  case CCA_3:
964  os<< "CCA ("<<(ccaTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<"us)";
965  break;
966 
967  case TRANSMITFRAME_4:
968  os<< "TRANSMITING FRAME";
969  break;
970 
971  case WAITACK_5:
972  os<< "WAITING ACK (" <<(rxAckTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<"us)";
973  break;
974 
975  case WAITSIFS_6:
976  os<< "WAITING SIFS (" <<(sifsTimer->getArrivalTime()- simTime()).inUnit(SIMTIME_US) <<"us)";
977  break;
978 
979  case TRANSMITACK_7:
980  os<< "TRANSMITING ACK";
981  break;
982  default:
983  os<< "defined state";
984  break;
985  }
986  getDisplayString().setTagArg("t", 0, os.str().c_str());
987 }

◆ scheduleBackoff()

simtime_t inet::Ieee802154Mac::scheduleBackoff ( )
protectedvirtual
721 {
722  simtime_t backoffTime;
723 
724  switch (backoffMethod) {
725  case EXPONENTIAL: {
726  int BE = std::min(macMinBE + NB, macMaxBE);
727  int v = (1 << BE) - 1;
728  int r = intuniform(0, v, 0);
729  backoffTime = r * aUnitBackoffPeriod;
730 
731  EV_DETAIL << "(startTimer) backoffTimer value=" << backoffTime
732  << " (BE=" << BE << ", 2^BE-1= " << v << "r="
733  << r << ")" << endl;
734  break;
735  }
736 
737  case LINEAR: {
738  int slots = intuniform(1, initialCW + NB, 0);
739  backoffTime = slots * aUnitBackoffPeriod;
740  EV_DETAIL << "(startTimer) backoffTimer value=" << backoffTime << endl;
741  break;
742  }
743 
744  case CONSTANT: {
745  int slots = intuniform(1, initialCW, 0);
746  backoffTime = slots * aUnitBackoffPeriod;
747  EV_DETAIL << "(startTimer) backoffTimer value=" << backoffTime << endl;
748  break;
749  }
750 
751  default:
752  throw cRuntimeError("Unknown backoff method!");
753  break;
754  }
755 
756  nbBackoffs = nbBackoffs + 1;
757  backoffValues = backoffValues + SIMTIME_DBL(backoffTime);
758 
759  return backoffTime;
760 }

◆ startTimer()

void inet::Ieee802154Mac::startTimer ( t_mac_timer  timer)
protected
694 {
695  if (timer == TIMER_BACKOFF) {
696  scheduleAfter(scheduleBackoff(), backoffTimer);
697  }
698  else if (timer == TIMER_CCA) {
699  simtime_t ccaTime = rxSetupTime + ccaDetectionTime;
700  EV_DETAIL << "(startTimer) ccaTimer value=" << ccaTime
701  << "(rxSetupTime,ccaDetectionTime:" << rxSetupTime
702  << "," << ccaDetectionTime << ")." << endl;
703  scheduleAfter(rxSetupTime + ccaDetectionTime, ccaTimer);
704  }
705  else if (timer == TIMER_SIFS) {
706  assert(useMACAcks);
707  EV_DETAIL << "(startTimer) sifsTimer value=" << sifs << endl;
708  scheduleAfter(sifs, sifsTimer);
709  }
710  else if (timer == TIMER_RX_ACK) {
711  assert(useMACAcks);
712  EV_DETAIL << "(startTimer) rxAckTimer value=" << macAckWaitDuration << endl;
713  scheduleAfter(macAckWaitDuration, rxAckTimer);
714  }
715  else {
716  EV << "Unknown timer requested to start:" << timer << endl;
717  }
718 }

◆ updateMacState()

void inet::Ieee802154Mac::updateMacState ( t_mac_states  newMacState)
protected
679 {
680  macState = newMacState;
681 }

◆ updateStatusBackoff()

void inet::Ieee802154Mac::updateStatusBackoff ( t_mac_event  event,
cMessage *  msg 
)
protected
270 {
271  switch (event) {
272  case EV_TIMER_BACKOFF:
273  EV_DETAIL << "(2) FSM State BACKOFF, EV_TIMER_BACKOFF:"
274  << " starting CCA timer." << endl;
277  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
278  break;
279 
281  // suspend current transmission attempt,
282  // transmit ack,
283  // and resume transmission when entering manageQueue()
284  EV_DETAIL << "(28) FSM State BACKOFF, EV_DUPLICATE_RECEIVED:";
285  if (useMACAcks) {
286  EV_DETAIL << "suspending current transmit tentative and transmitting ack";
288  cancelEvent(backoffTimer);
289  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
292  }
293  else {
294  EV_DETAIL << "Nothing to do.";
295  }
296 // sendUp(decapsMsg(static_cast<MacSeqPkt *>(msg)));
297  delete msg;
298 
299  break;
300 
301  case EV_FRAME_RECEIVED:
302  // suspend current transmission attempt,
303  // transmit ack,
304  // and resume transmission when entering manageQueue()
305  EV_DETAIL << "(28) FSM State BACKOFF, EV_FRAME_RECEIVED:";
306  if (useMACAcks) {
307  EV_DETAIL << "suspending current transmit tentative and transmitting ack";
309  cancelEvent(backoffTimer);
310 
311  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
314  }
315  else {
316  EV_DETAIL << "sending frame up and resuming normal operation.";
317  }
318  decapsulate(check_and_cast<Packet *>(msg));
319  sendUp(msg);
320  break;
321 
323  EV_DETAIL << "(29) FSM State BACKOFF, EV_BROADCAST_RECEIVED:"
324  << "sending frame up and resuming normal operation." << endl;
325  decapsulate(check_and_cast<Packet *>(msg));
326  sendUp(msg);
327  break;
328 
329  default:
330  fsmError(event, msg);
331  break;
332  }
333 }

◆ updateStatusCCA()

void inet::Ieee802154Mac::updateStatusCCA ( t_mac_event  event,
cMessage *  msg 
)
protected
342 {
343  switch (event) {
344  case EV_TIMER_CCA: {
345  EV_DETAIL << "(25) FSM State CCA_3, EV_TIMER_CCA" << endl;
346  bool isIdle = radio->getReceptionState() == IRadio::RECEPTION_STATE_IDLE;
347  if (isIdle) {
348  EV_DETAIL << "(3) FSM State CCA_3, EV_TIMER_CCA, [Channel Idle]: -> TRANSMITFRAME_4." << endl;
350  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
351  if (currentTxFrame == nullptr) {
354  }
355  Packet *mac = currentTxFrame->dup();
356  attachSignal(mac, simTime() + aTurnaroundTime);
357 // sendDown(msg);
358  // give time for the radio to be in Tx state before transmitting
359  sendDelayed(mac, aTurnaroundTime, lowerLayerOutGateId);
360  nbTxFrames++;
361  }
362  else {
363  // Channel was busy, increment 802.15.4 backoff timers as specified.
364  EV_DETAIL << "(7) FSM State CCA_3, EV_TIMER_CCA, [Channel Busy]: "
365  << " increment counters." << endl;
366  NB = NB + 1;
367 // BE = std::min(BE+1, macMaxBE);
368 
369  // decide if we go for another backoff or if we drop the frame.
370  if (NB > macMaxCSMABackoffs) {
371  // drop the frame
372  EV_DETAIL << "Tried " << NB << " backoffs, all reported a busy "
373  << "channel. Dropping the packet." << endl;
374  txAttempts = 0;
375  if (currentTxFrame) {
376  nbDroppedFrames++;
377  PacketDropDetails details;
378  details.setReason(CONGESTION);
379  details.setLimit(macMaxCSMABackoffs);
380  dropCurrentTxFrame(details);
381  }
382  else {
383  EV_ERROR << "too many Backoffs, but currentTxFrame is empty\n"; // TODO is it good, or model error?
384  }
385  manageQueue();
386  }
387  else {
388  // redo backoff
391  }
392  }
393  break;
394  }
395 
397  EV_DETAIL << "(26) FSM State CCA_3, EV_DUPLICATE_RECEIVED:";
398  if (useMACAcks) {
399  EV_DETAIL << " setting up radio tx -> WAITSIFS." << endl;
400  // suspend current transmission attempt,
401  // transmit ack,
402  // and resume transmission when entering manageQueue()
404  cancelEvent(ccaTimer);
405 
406  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
409  }
410  else {
411  EV_DETAIL << " Nothing to do." << endl;
412  }
413 // sendUp(decapsMsg(static_cast<MacPkt*>(msg)));
414  delete msg;
415  break;
416 
417  case EV_FRAME_RECEIVED:
418  EV_DETAIL << "(26) FSM State CCA_3, EV_FRAME_RECEIVED:";
419  if (useMACAcks) {
420  EV_DETAIL << " setting up radio tx -> WAITSIFS." << endl;
421  // suspend current transmission attempt,
422  // transmit ack,
423  // and resume transmission when entering manageQueue()
425  cancelEvent(ccaTimer);
426  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
429  }
430  else {
431  EV_DETAIL << " Nothing to do." << endl;
432  }
433  decapsulate(check_and_cast<Packet *>(msg));
434  sendUp(msg);
435  break;
436 
438  EV_DETAIL << "(24) FSM State BACKOFF, EV_BROADCAST_RECEIVED:"
439  << " Nothing to do." << endl;
440  decapsulate(check_and_cast<Packet *>(msg));
441  sendUp(msg);
442  break;
443 
444  default:
445  fsmError(event, msg);
446  break;
447  }
448 }

◆ updateStatusIdle()

void inet::Ieee802154Mac::updateStatusIdle ( t_mac_event  event,
cMessage *  msg 
)
protected
219 {
220  switch (event) {
221  case EV_SEND_REQUEST:
222  if (!txQueue->isEmpty()) {
223  EV_DETAIL << "(1) FSM State IDLE_1, EV_SEND_REQUEST and [TxBuff avail]: startTimerBackOff -> BACKOFF." << endl;
225  NB = 0;
226 // BE = macMinBE;
228  }
229  break;
230 
232  EV_DETAIL << "(15) FSM State IDLE_1, EV_DUPLICATE_RECEIVED: setting up radio tx -> WAITSIFS." << endl;
233 // sendUp(decapsMsg(static_cast<MacSeqPkt *>(msg)));
234  delete msg;
235 
236  if (useMACAcks) {
237  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
240  }
241  break;
242 
243  case EV_FRAME_RECEIVED:
244  EV_DETAIL << "(15) FSM State IDLE_1, EV_FRAME_RECEIVED: setting up radio tx -> WAITSIFS." << endl;
245  decapsulate(check_and_cast<Packet *>(msg));
246  sendUp(msg);
247  nbRxFrames++;
248 
249  if (useMACAcks) {
250  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
253  }
254  break;
255 
257  EV_DETAIL << "(23) FSM State IDLE_1, EV_BROADCAST_RECEIVED: Nothing to do." << endl;
258  nbRxFrames++;
259  decapsulate(check_and_cast<Packet *>(msg));
260  sendUp(msg);
261  break;
262 
263  default:
264  fsmError(event, msg);
265  break;
266  }
267 }

◆ updateStatusNotIdle()

void inet::Ieee802154Mac::updateStatusNotIdle ( cMessage *  msg)
protected
602 {
603  EV_DETAIL << "(20) FSM State NOT IDLE, EV_SEND_REQUEST. Is a TxBuffer available ?" << endl;
604 }

◆ updateStatusSIFS()

void inet::Ieee802154Mac::updateStatusSIFS ( t_mac_event  event,
cMessage *  msg 
)
protected
549 {
550  assert(useMACAcks);
551 
552  switch (event) {
553  case EV_TIMER_SIFS:
554  EV_DETAIL << "(17) FSM State WAITSIFS_6, EV_TIMER_SIFS:"
555  << " sendAck -> TRANSMITACK." << endl;
557  attachSignal(ackMessage, simTime());
559  nbTxAcks++;
560 // sendDelayed(ackMessage, aTurnaroundTime, lowerLayerOut);
561  ackMessage = nullptr;
562  break;
563 
564  case EV_TIMER_BACKOFF:
565  // Backoff timer has expired while receiving a frame. Restart it
566  // and stay here.
567  EV_DETAIL << "(16) FSM State WAITSIFS_6, EV_TIMER_BACKOFF. "
568  << "Restart backoff timer and don't move." << endl;
570  break;
571 
573  case EV_FRAME_RECEIVED:
574  EV << "Error ! Received a frame during SIFS !" << endl;
575  decapsulate(check_and_cast<Packet *>(msg));
576  sendUp(msg);
577  break;
578 
579  default:
580  fsmError(event, msg);
581  break;
582  }
583 }

◆ updateStatusTransmitAck()

void inet::Ieee802154Mac::updateStatusTransmitAck ( t_mac_event  event,
cMessage *  msg 
)
protected
586 {
587  assert(useMACAcks);
588 
589  if (event == EV_FRAME_TRANSMITTED) {
590  EV_DETAIL << "(19) FSM State TRANSMITACK_7, EV_FRAME_TRANSMITTED:"
591  << " ->manageQueue." << endl;
592  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
593  delete msg;
594  manageQueue();
595  }
596  else {
597  fsmError(event, msg);
598  }
599 }

◆ updateStatusTransmitFrame()

void inet::Ieee802154Mac::updateStatusTransmitFrame ( t_mac_event  event,
cMessage *  msg 
)
protected
451 {
452  if (event == EV_FRAME_TRANSMITTED && currentTxFrame != nullptr) {
453 // delete msg;
454  Packet *packet = currentTxFrame;
455  const auto& csmaHeader = packet->peekAtFront<Ieee802154MacHeader>();
456  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
457 
458  bool expectAck = useMACAcks;
459  if (!csmaHeader->getDestAddr().isBroadcast() && !csmaHeader->getDestAddr().isMulticast()) {
460  // unicast
461  EV_DETAIL << "(4) FSM State TRANSMITFRAME_4, "
462  << "EV_FRAME_TRANSMITTED [Unicast]: ";
463  }
464  else {
465  // broadcast
466  EV_DETAIL << "(27) FSM State TRANSMITFRAME_4, EV_FRAME_TRANSMITTED "
467  << " [Broadcast]";
468  expectAck = false;
469  }
470 
471  if (expectAck) {
472  EV_DETAIL << "RadioSetupRx -> WAITACK." << endl;
475  }
476  else {
477  EV_DETAIL << ": RadioSetupRx, manageQueue..." << endl;
479  manageQueue();
480  }
481  delete msg;
482  }
483  else {
484  fsmError(event, msg);
485  }
486 }

◆ updateStatusWaitAck()

void inet::Ieee802154Mac::updateStatusWaitAck ( t_mac_event  event,
cMessage *  msg 
)
protected
489 {
490  assert(useMACAcks);
491 
492  switch (event) {
493  case EV_ACK_RECEIVED: {
494  EV_DETAIL << "(5) FSM State WAITACK_5, EV_ACK_RECEIVED: "
495  << " ProcessAck, manageQueue..." << endl;
496  if (rxAckTimer->isScheduled())
497  cancelEvent(rxAckTimer);
499  txAttempts = 0;
500  delete msg;
501  manageQueue();
502  break;
503  }
504  case EV_ACK_TIMEOUT:
505  EV_DETAIL << "(12) FSM State WAITACK_5, EV_ACK_TIMEOUT:"
506  << " incrementCounter/dropPacket, manageQueue..." << endl;
507  manageMissingAck(event, msg);
508  break;
509 
511  case EV_FRAME_RECEIVED:
512  decapsulate(check_and_cast<Packet *>(msg));
513  sendUp(msg);
514  break;
515 
517  EV_DETAIL << "Error ! Received a frame during SIFS !" << endl;
518  delete msg;
519  break;
520 
521  default:
522  fsmError(event, msg);
523  break;
524  }
525 }

Member Data Documentation

◆ 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

backoff_methods inet::Ieee802154Mac::backoffMethod
protected

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

CCA detection time.

◆ ccaTimer

cMessage * inet::Ieee802154Mac::ccaTimer
protected

◆ headerLength

int inet::Ieee802154Mac::headerLength
protected

Length of the header.

◆ 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

t_mac_states inet::Ieee802154Mac::macState
protected

keep track of MAC state

◆ 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

ModuleRefByPar<physicallayer::IRadio> inet::Ieee802154Mac::radio
protected

The 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

t_mac_status inet::Ieee802154Mac::status
protected

◆ transmissionAttemptInterruptedByRx

bool inet::Ieee802154Mac::transmissionAttemptInterruptedByRx
protected

◆ transmissionState

physicallayer::IRadio::TransmissionState inet::Ieee802154Mac::transmissionState
protected

◆ 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:
inet::Ieee802154Mac::fsmError
void fsmError(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:686
inet::MacProtocolBase::networkInterface
opp_component_ptr< NetworkInterface > networkInterface
Definition: MacProtocolBase.h:30
inet::Ieee802154Mac::backoffMethod
backoff_methods backoffMethod
Defines the backoff method to be used.
Definition: Ieee802154Mac.h:244
inet::Ieee802154Mac::CONSTANT
@ CONSTANT
Constant back-off time.
Definition: Ieee802154Mac.h:199
inet::MacProtocolBase::handleCrashOperation
virtual void handleCrashOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:142
inet::Ieee802154Mac::ackLength
int ackLength
The bit length of the ACK packet.
Definition: Ieee802154Mac.h:277
inet::Packet::addTag
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
inet::Ieee802154Mac::updateStatusTransmitFrame
void updateStatusTransmitFrame(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:450
inet::Ieee802154Mac::nbTxAcks
long nbTxAcks
Definition: Ieee802154Mac.h:123
inet::physicallayer::IRadio::RECEPTION_STATE_IDLE
@ RECEPTION_STATE_IDLE
The radio medium is free, no signal is detected.
Definition: IRadio.h:136
inet::Ieee802154Mac::nbRxFrames
long nbRxFrames
Definition: Ieee802154Mac.h:119
inet::MacProtocolBase::sendUp
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
inet::Ieee802154Mac::EV_TIMER_BACKOFF
@ EV_TIMER_BACKOFF
Definition: Ieee802154Mac.h:164
inet::Ieee802154Mac::sifsTimer
cMessage * sifsTimer
Definition: Ieee802154Mac.h:157
inet::Ieee802154Mac::aUnitBackoffPeriod
simtime_t aUnitBackoffPeriod
base time unit for calculating backoff durations
Definition: Ieee802154Mac.h:239
inet::Ieee802154Mac::updateStatusNotIdle
void updateStatusNotIdle(cMessage *msg)
Definition: Ieee802154Mac.cc:601
inet::MacProtocolBase::handleStartOperation
virtual void handleStartOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:124
inet::Ieee802154Mac::updateMacState
void updateMacState(t_mac_states newMacState)
Definition: Ieee802154Mac.cc:678
inet::Ieee802154Mac::txPower
double txPower
The power (in mW) to transmit with.
Definition: Ieee802154Mac.h:262
inet::INCORRECTLY_RECEIVED
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
inet::Ieee802154Mac::STATUS_FRAME_TRANSMITTED
@ STATUS_FRAME_TRANSMITTED
Definition: Ieee802154Mac.h:193
inet::Packet::peekAtFront
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
inet::Ieee802154Mac::nbRecvdAcks
long nbRecvdAcks
Definition: Ieee802154Mac.h:121
inet::RETRY_LIMIT_REACHED
@ RETRY_LIMIT_REACHED
Definition: Simsignals_m.h:78
inet::sctp::min
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
inet::Ieee802154Mac::NB
int NB
number of backoff performed until now for current frame
Definition: Ieee802154Mac.h:265
inet::Ieee802154Mac::initialCW
int initialCW
initial contention window size Only used for linear and constant backoff method.
Definition: Ieee802154Mac.h:259
inet::Ieee802154Mac::STATUS_FRAME_TO_PROCESS
@ STATUS_FRAME_TO_PROCESS
Definition: Ieee802154Mac.h:191
inet::Ieee802154Mac::EV_BROADCAST_RECEIVED
@ EV_BROADCAST_RECEIVED
Definition: Ieee802154Mac.h:171
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::Ieee802154Mac::radio
ModuleRefByPar< physicallayer::IRadio > radio
The radio.
Definition: Ieee802154Mac.h:211
inet::Ieee802154Mac::bitrate
double bitrate
the bit rate at which we transmit
Definition: Ieee802154Mac.h:274
inet::Ieee802154Mac::manageMissingAck
void manageMissingAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:527
inet::Ieee802154Mac::STATUS_ERROR
@ STATUS_ERROR
Definition: Ieee802154Mac.h:188
inet::Ieee802154Mac::SeqNrChild
std::map< MacAddress, unsigned long > SeqNrChild
Definition: Ieee802154Mac.h:320
inet::MacProtocolBase::dropCurrentTxFrame
virtual void dropCurrentTxFrame(PacketDropDetails &details)
Definition: MacProtocolBase.cc:99
inet::Ieee802154Mac::txAttempts
unsigned int txAttempts
count the number of tx attempts
Definition: Ieee802154Mac.h:271
inet::Ieee802154Mac::sifs
simtime_t sifs
Maximum time between a packet and its ACK.
Definition: Ieee802154Mac.h:219
inet::Ieee802154Mac::backoffValues
double backoffValues
Definition: Ieee802154Mac.h:126
inet::Ieee802154Mac::STATUS_RX_ERROR
@ STATUS_RX_ERROR
Definition: Ieee802154Mac.h:189
inet::Ieee802154Mac::ackMessage
Packet * ackMessage
Definition: Ieee802154Mac.h:313
inet::Ieee802154Mac::nbMissedAcks
long nbMissedAcks
Definition: Ieee802154Mac.h:120
inet::Ieee802154Mac::TIMER_CCA
@ TIMER_CCA
Definition: Ieee802154Mac.h:150
inet::physicallayer::IRadio::transmissionStateChangedSignal
static simsignal_t transmissionStateChangedSignal
This signal is emitted when the radio transmission state of the radio is changed.
Definition: IRadio.h:60
inet::Ieee802154Mac::macMaxCSMABackoffs
int macMaxCSMABackoffs
maximum number of extra backoffs (excluding the first unconditional one) before frame drop
Definition: Ieee802154Mac.h:235
inet::Ieee802154Mac::nbTxFrames
long nbTxFrames
Definition: Ieee802154Mac.h:118
inet::Ieee802154Mac::headerLength
int headerLength
Length of the header.
Definition: Ieee802154Mac.h:225
inet::MacProtocolBase::handleStopOperation
virtual void handleStopOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:130
inet::Ieee802154Mac::EV_FRAME_RECEIVED
@ EV_FRAME_RECEIVED
Definition: Ieee802154Mac.h:168
inet::physicallayer::IRadio::RADIO_MODE_TRANSMITTER
@ RADIO_MODE_TRANSMITTER
The radio is prepared for frame transmission, frame reception is not possible, power consumption is l...
Definition: IRadio.h:104
inet::Ieee802154Mac::updateStatusSIFS
void updateStatusSIFS(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:548
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::Ieee802154Mac::updateStatusWaitAck
void updateStatusWaitAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:488
inet::Ieee802154Mac::macMaxFrameRetries
unsigned int macMaxFrameRetries
maximum number of frame retransmissions without ack
Definition: Ieee802154Mac.h:237
inet::Ieee802154Mac::EV_TIMER_CCA
@ EV_TIMER_CCA
Definition: Ieee802154Mac.h:172
inet::Ieee802154Mac::WAITACK_5
@ WAITACK_5
Definition: Ieee802154Mac.h:137
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::MacProtocolBase::MacProtocolBase
MacProtocolBase()
Definition: MacProtocolBase.cc:15
inet::Ieee802154Mac::executeMac
void executeMac(t_mac_event event, cMessage *msg)
Updates state machine.
Definition: Ieee802154Mac.cc:609
inet::Ieee802154Mac::scheduleBackoff
virtual simtime_t scheduleBackoff()
Definition: Ieee802154Mac.cc:720
inet::Protocol::ieee802154
static const Protocol ieee802154
Definition: Protocol.h:83
inet::Ieee802154Mac::TIMER_NULL
@ TIMER_NULL
Definition: Ieee802154Mac.h:148
inet::Ieee802154Mac::EV_TIMER_SIFS
@ EV_TIMER_SIFS
Definition: Ieee802154Mac.h:170
inet::Ieee802154Mac::EV_SEND_REQUEST
@ EV_SEND_REQUEST
Definition: Ieee802154Mac.h:163
inet::Ieee802154Mac::TRANSMITACK_7
@ TRANSMITACK_7
Definition: Ieee802154Mac.h:139
inet::Packet::dup
virtual Packet * dup() const override
Definition: Packet.h:171
inet::Ieee802154Mac::EV_DUPLICATE_RECEIVED
@ EV_DUPLICATE_RECEIVED
Definition: Ieee802154Mac.h:169
inet::Packet::insertAtFront
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
inet::physicallayer::IRadio::RADIO_MODE_RECEIVER
@ RADIO_MODE_RECEIVER
The radio is prepared for frame reception, frame transmission is not possible, power consumption is l...
Definition: IRadio.h:97
inet::Ieee802154Mac::ccaDetectionTime
simtime_t ccaDetectionTime
CCA detection time.
Definition: Ieee802154Mac.h:229
inet::Ieee802154Mac::decapsulate
virtual void decapsulate(Packet *packet)
Definition: Ieee802154Mac.cc:902
inet::Ieee802154Mac::rxAckTimer
cMessage * rxAckTimer
Definition: Ieee802154Mac.h:157
inet::Ieee802154Mac::updateStatusCCA
void updateStatusCCA(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:341
inet::Ieee802154Mac::TIMER_RX_ACK
@ TIMER_RX_ACK
Definition: Ieee802154Mac.h:152
inet::Ieee802154Mac::useMACAcks
bool useMACAcks
Stores if the MAC expects Acks for Unicast packets.
Definition: Ieee802154Mac.h:241
inet::Ieee802154Mac::rxSetupTime
simtime_t rxSetupTime
Time to setup radio from sleep to Rx state.
Definition: Ieee802154Mac.h:231
inet::MacProtocolBase::currentTxFrame
Packet * currentTxFrame
Currently transmitted frame if any.
Definition: MacProtocolBase.h:35
inet::Ieee802154Mac::CHANNEL_BUSY
@ CHANNEL_BUSY
Definition: Ieee802154Mac.h:182
inet::Ieee802154Mac::IDLE_1
@ IDLE_1
Definition: Ieee802154Mac.h:133
inet::Ieee802154Mac::startTimer
void startTimer(t_mac_timer timer)
Definition: Ieee802154Mac.cc:693
inet::Ieee802154Mac::attachSignal
void attachSignal(Packet *mac, simtime_t_cref startTime)
Definition: Ieee802154Mac.cc:335
inet::Ieee802154Mac::DATA
@ DATA
Definition: Ieee802154Mac.h:177
inet::MacProtocolBase::sendDown
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
inet::Ieee802154Mac::EV_ACK_RECEIVED
@ EV_ACK_RECEIVED
Definition: Ieee802154Mac.h:166
inet::MacProtocolBase::upperLayerInGateId
int upperLayerInGateId
Gate ids.
Definition: MacProtocolBase.h:24
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::Ieee802154Mac::SeqNrParent
std::map< MacAddress, unsigned long > SeqNrParent
Definition: Ieee802154Mac.h:317
inet::Ieee802154Mac::nbDuplicates
long nbDuplicates
Definition: Ieee802154Mac.h:124
inet::physicallayer::IRadio::TRANSMISSION_STATE_TRANSMITTING
@ TRANSMISSION_STATE_TRANSMITTING
The radio medium is busy, the radio is currently transmitting a signal.
Definition: IRadio.h:171
inet::Ieee802154Mac::macState
t_mac_states macState
keep track of MAC state
Definition: Ieee802154Mac.h:207
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::Ieee802154Mac::CCA_3
@ CCA_3
Definition: Ieee802154Mac.h:135
inet::Ieee802154Mac::STATUS_RX_TIMEOUT
@ STATUS_RX_TIMEOUT
Definition: Ieee802154Mac.h:190
inet::MacProtocolBase::deleteCurrentTxFrame
virtual void deleteCurrentTxFrame()
Definition: MacProtocolBase.cc:93
inet::Ieee802154Mac::manageQueue
void manageQueue()
Definition: Ieee802154Mac.cc:652
inet::MacProtocolBase::initialize
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
inet::Ieee802154Mac::EXPONENTIAL
@ EXPONENTIAL
Exponentially increasing back-off time.
Definition: Ieee802154Mac.h:203
inet::Ieee802154Mac::TIMER_BACKOFF
@ TIMER_BACKOFF
Definition: Ieee802154Mac.h:149
inet::Ieee802154Mac::TRANSMITFRAME_4
@ TRANSMITFRAME_4
Definition: Ieee802154Mac.h:136
inet::MacProtocolBase::getQueue
queueing::IPacketQueue * getQueue(cGate *gate) const
Definition: MacProtocolBase.cc:157
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::physicallayer::IRadio::TransmissionState
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
inet::Ieee802154Mac::ccaTimer
cMessage * ccaTimer
Definition: Ieee802154Mac.h:157
inet::Ieee802154Mac::STATUS_NO_FRAME_TO_PROCESS
@ STATUS_NO_FRAME_TO_PROCESS
Definition: Ieee802154Mac.h:192
inet::Ieee802154Mac::backoffTimer
cMessage * backoffTimer
Definition: Ieee802154Mac.h:157
inet::CONGESTION
@ CONGESTION
Definition: Simsignals_m.h:80
inet::Ieee802154Mac::nbDroppedFrames
long nbDroppedFrames
Definition: Ieee802154Mac.h:122
inet::MacProtocolBase::lowerLayerOutGateId
int lowerLayerOutGateId
Definition: MacProtocolBase.h:27
inet::MacProtocolBase::dequeuePacket
virtual Packet * dequeuePacket()
Definition: MacProtocolBase.cc:175
inet::MacProtocolBase::parseMacAddressParameter
virtual MacAddress parseMacAddressParameter(const char *addrstr)
Definition: MacProtocolBase.cc:24
inet::Ieee802154Mac::updateStatusIdle
void updateStatusIdle(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:218
inet::Ieee802154Mac::updateStatusBackoff
void updateStatusBackoff(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:269
inet::Ieee802154Mac::macAckWaitDuration
simtime_t macAckWaitDuration
The amount of time the MAC waits for the ACK of a packet.
Definition: Ieee802154Mac.h:222
inet::Ieee802154Mac::TIMER_SIFS
@ TIMER_SIFS
Definition: Ieee802154Mac.h:151
inet::Ieee802154Mac::ACK
@ ACK
Definition: Ieee802154Mac.h:178
inet::ProtocolGroup::getProtocol
const Protocol * getProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:31
inet::MacProtocolBase::txQueue
opp_component_ptr< queueing::IPacketQueue > txQueue
Messages received from upper layer and to be transmitted later.
Definition: MacProtocolBase.h:38
inet::physicallayer::IRadio::TRANSMISSION_STATE_UNDEFINED
@ TRANSMISSION_STATE_UNDEFINED
The transmission state is undefined or meaningless.
Definition: IRadio.h:160
inet::Ieee802154Mac::macMinBE
int macMinBE
Minimum backoff exponent.
Definition: Ieee802154Mac.h:250
inet::Ieee802154Mac::BACKOFF_2
@ BACKOFF_2
Definition: Ieee802154Mac.h:134
inet::physicallayer::IRadio::TRANSMISSION_STATE_IDLE
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
inet::Ieee802154Mac::EV_ACK_TIMEOUT
@ EV_ACK_TIMEOUT
Definition: Ieee802154Mac.h:167
inet::Ieee802154Mac::WAITSIFS_6
@ WAITSIFS_6
Definition: Ieee802154Mac.h:138
inet::Ieee802154Mac::LINEAR
@ LINEAR
Linear increasing back-off time.
Definition: Ieee802154Mac.h:201
inet::Ieee802154Mac::transmissionState
physicallayer::IRadio::TransmissionState transmissionState
Definition: Ieee802154Mac.h:212
inet::Ieee802154Mac::STATUS_OK
@ STATUS_OK
Definition: Ieee802154Mac.h:187
inet::Ieee802154Mac::aTurnaroundTime
simtime_t aTurnaroundTime
Time to switch radio from Rx to Tx state.
Definition: Ieee802154Mac.h:233
inet::Ieee802154Mac::status
t_mac_status status
Definition: Ieee802154Mac.h:208
inet::NOT_ADDRESSED_TO_US
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
inet::Ieee802154Mac::transmissionAttemptInterruptedByRx
bool transmissionAttemptInterruptedByRx
Definition: Ieee802154Mac.h:227
inet::Ieee802154Mac::updateStatusTransmitAck
void updateStatusTransmitAck(t_mac_event event, cMessage *msg)
Definition: Ieee802154Mac.cc:585
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::containsKey
bool containsKey(const std::map< K, V, _C > &m, const Tk &a)
Definition: stlutils.h:80
inet::Ieee802154Mac::macMaxBE
int macMaxBE
Maximum backoff exponent.
Definition: Ieee802154Mac.h:255
inet::Ieee802154Mac::EV_FRAME_TRANSMITTED
@ EV_FRAME_TRANSMITTED
Definition: Ieee802154Mac.h:165
inet::ProtocolGroup::ethertype
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40
inet::Ieee802154Mac::nbBackoffs
long nbBackoffs
Definition: Ieee802154Mac.h:125
inet::Ieee802154Mac::CHANNEL_FREE
@ CHANNEL_FREE
Definition: Ieee802154Mac.h:183
inet::Ieee802154Mac::encapsulate
virtual void encapsulate(Packet *packet)
Encapsulates the message.
Definition: Ieee802154Mac.cc:178