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

Implementation of X-MAC. More...

#include <XMac.h>

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

Public Member Functions

 XMac ()
 
virtual ~XMac ()
 
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 *) override
 Handle messages from lower layer. More...
 
virtual void handleUpperPacket (Packet *) override
 Handle messages from upper layer. More...
 
virtual void handleSelfMessage (cMessage *) override
 Handle self messages such as timers. More...
 
void receiveSignal (cComponent *source, simsignal_t signalID, intval_t value, cObject *details) override
 Handle transmission over messages: either send another preambles or the data packet itself. 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 ()
 

Protected Member Functions

virtual void configureNetworkInterface () override
 implements MacBase functions More...
 
- 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
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) 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 ()
 

Private Member Functions

 XMac (const XMac &)
 Copy constructor is not allowed. More...
 
XMacoperator= (const XMac &)
 Assignment operator is not allowed. More...
 

Different tracked statistics.

enum  States {
  INIT, SLEEP, CCA, SEND_PREAMBLE,
  WAIT_DATA, SEND_DATA, WAIT_TX_DATA_OVER, WAIT_ACK,
  SEND_ACK, WAIT_ACK_TX
}
 MAC states. More...
 
long nbTxDataPackets
 
long nbTxPreambles
 
long nbRxDataPackets
 
long nbRxPreambles
 
long nbMissedAcks
 
long nbRecvdAcks
 
long nbDroppedDataPackets
 
long nbTxAcks
 
long nbRxBrokenDataPackets
 
States macState
 The current state of the protocol. More...
 
cMessage * resend_data
 
cMessage * ack_timeout
 
cMessage * start_xmac
 
cMessage * wakeup
 
cMessage * send_ack
 
cMessage * cca_timeout
 
cMessage * ack_tx_over
 
cMessage * send_preamble
 
cMessage * switch_preamble_phase
 
cMessage * delay_for_ack_within_remote_rx
 
cMessage * stop_preambles
 
cMessage * data_tx_over
 
cMessage * data_timeout
 
cMessage * switching_done
 

Help variables for the acknowledgment process.

enum  XMAC_COLORS {
  GREEN = 1, BLUE = 2, RED = 3, BLACK = 4,
  YELLOW = 5
}
 Possible colors of the node for animation. More...
 
MacAddress lastDataPktSrcAddr
 
MacAddress lastDataPktDestAddr
 
MacAddress lastPreamblePktSrcAddr
 
b headerLength = b(0)
 
b ctrlFrameLength = b(0)
 
ModuleRefByPar< physicallayer::IRadioradio
 The radio. More...
 
physicallayer::IRadio::TransmissionState transmissionState = physicallayer::IRadio::TRANSMISSION_STATE_UNDEFINED
 
int txAttempts
 
bool animation
 Animate (colorize) the nodes. More...
 
double slotDuration
 The duration of the slot in secs. More...
 
double bitrate
 The bitrate of transmission. More...
 
double checkInterval
 The duration of CCA. More...
 
double txPower
 Transmission power of the node. More...
 
bool useMacAcks
 Use MAC level acks or not. More...
 
int maxTxAttempts
 Maximum transmission attempts per data packet, when ACKs are used. More...
 
bool stats
 Gather stats at the end of the simulation. More...
 
void changeDisplayColor (XMAC_COLORS color)
 Internal function to change the color of the node. More...
 
void sendDataPacket ()
 Internal function to send the first packet in the queue. More...
 
void sendMacAck ()
 Internal function to send an ACK. More...
 
void sendPreamble (MacAddress destination)
 Internal function to send one preamble. More...
 
void attachSignal (Packet *packet, simtime_t_cref startTime)
 Internal function to attach a signal to the packet. More...
 
void decapsulate (Packet *packet)
 
void encapsulate (Packet *packet)
 

Additional Inherited Members

- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 
- 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

Implementation of X-MAC.

This implementation was created for the MiXiM framework by Joaquim Oller. It was ported to the INET framework by Jan Peter Drees.

A paper describing the X-MAC protocol can be found at: http://www.cs.cmu.edu/~andersoe/papers/xmac-sensys.pdf

A paper analyzing this MiXiM implementation can be found at: http://ieeexplore.ieee.org/document/7024195/

Author
Joaquim Oller and Jan Peter Drees

Member Enumeration Documentation

◆ States

enum inet::XMac::States
protected

MAC states.

The MAC states help to keep track what the MAC is actually trying to do. INIT – node has just started and its status is unclear SLEEP – node sleeps, but accepts packets from the network layer CCA – Clear Channel Assessment - MAC checks whether medium is busy SEND_PREAMBLE – node sends preambles to wake up all nodes WAIT_DATA – node has received at least one preamble from another node and wiats for the actual data packet SEND_DATA – node has sent enough preambles and sends the actual data packet WAIT_TX_DATA_OVER – node waits until the data packet sending is ready WAIT_ACK – node has sent the data packet and waits for ack from the receiving node SEND_ACK – node send an ACK back to the sender WAIT_ACK_TX – node waits until the transmission of the ack packet is over

Enumerator
INIT 
SLEEP 
CCA 
SEND_PREAMBLE 
WAIT_DATA 
SEND_DATA 
WAIT_TX_DATA_OVER 
WAIT_ACK 
SEND_ACK 
WAIT_ACK_TX 
137  {
138  INIT, // 0
139  SLEEP, // 1
140  CCA, // 2
141  SEND_PREAMBLE, // 3
142  WAIT_DATA, // 4
143  SEND_DATA, // 5
144  WAIT_TX_DATA_OVER, // 6
145  WAIT_ACK, // ~7: think this is not used
146  SEND_ACK, // 8
147  WAIT_ACK_TX // 9
148  };

◆ XMAC_COLORS

enum inet::XMac::XMAC_COLORS
protected

Possible colors of the node for animation.

Enumerator
GREEN 
BLUE 
RED 
BLACK 
YELLOW 
208  {
209  GREEN = 1,
210  BLUE = 2,
211  RED = 3,
212  BLACK = 4,
213  YELLOW = 5
214  };

Constructor & Destructor Documentation

◆ XMac() [1/2]

inet::XMac::XMac ( const XMac )
private

Copy constructor is not allowed.

◆ XMac() [2/2]

inet::XMac::XMac ( )
inline
58  : MacProtocolBase()
61  , macState(INIT)
62  , resend_data(nullptr), ack_timeout(nullptr), start_xmac(nullptr), wakeup(nullptr)
63  , send_ack(nullptr), cca_timeout(nullptr), ack_tx_over(nullptr), send_preamble(nullptr), stop_preambles(nullptr)
64  , data_tx_over(nullptr), data_timeout(nullptr)
67  , txAttempts(0)
68  , animation(false)
69  , slotDuration(0), bitrate(0), checkInterval(0), txPower(0)
70  , useMacAcks(0)
71  , maxTxAttempts(0)
72  , stats(false)
73  {}

◆ ~XMac()

inet::XMac::~XMac ( )
virtual
93 {
94  cancelAndDelete(wakeup);
95  cancelAndDelete(data_timeout);
96  cancelAndDelete(data_tx_over);
97  cancelAndDelete(stop_preambles);
98  cancelAndDelete(send_preamble);
99  cancelAndDelete(ack_tx_over);
100  cancelAndDelete(cca_timeout);
101  cancelAndDelete(send_ack);
102  cancelAndDelete(start_xmac);
103  cancelAndDelete(ack_timeout);
104  cancelAndDelete(resend_data);
105  cancelAndDelete(switch_preamble_phase);
106  cancelAndDelete(delay_for_ack_within_remote_rx);
107  cancelAndDelete(switching_done);
108 }

Member Function Documentation

◆ attachSignal()

void inet::XMac::attachSignal ( Packet packet,
simtime_t_cref  startTime 
)
protected

Internal function to attach a signal to the packet.

563 {
564  simtime_t duration = packet->getBitLength() / bitrate;
565  packet->setDuration(duration);
566 }

◆ changeDisplayColor()

void inet::XMac::changeDisplayColor ( XMAC_COLORS  color)
protected

Internal function to change the color of the node.

Change the color of the node for animation purposes.

572 {
573  if (!animation)
574  return;
575  cDisplayString& dispStr = getContainingNode(this)->getDisplayString();
576  switch (macState) {
577  case INIT:
578  dispStr.setTagArg("t", 0, "INIT");
579  break;
580 
581  case SLEEP:
582  dispStr.setTagArg("t", 0, "SLEEP");
583  break;
584 
585  case CCA:
586  dispStr.setTagArg("t", 0, "CCA");
587  break;
588 
589  case SEND_ACK:
590  case SEND_PREAMBLE:
591  case SEND_DATA:
592  dispStr.setTagArg("t", 0, "SEND");
593  break;
594 
595  case WAIT_ACK:
596  case WAIT_DATA:
597  case WAIT_TX_DATA_OVER:
598  case WAIT_ACK_TX:
599  dispStr.setTagArg("t", 0, "WAIT");
600  break;
601 
602  default:
603  dispStr.setTagArg("t", 0, "");
604  break;
605  }
606 }

◆ configureNetworkInterface()

void inet::XMac::configureNetworkInterface ( )
overrideprotectedvirtual

implements MacBase functions

Implements inet::MacProtocolBase.

130 {
131  MacAddress address = parseMacAddressParameter(par("address"));
132 
133  // data rate
134  networkInterface->setDatarate(bitrate);
135 
136  // generate a link-layer address to be used as interface token for IPv6
137  networkInterface->setMacAddress(address);
138  networkInterface->setInterfaceToken(address.formInterfaceIdentifier());
139 
140  // capabilities
141  networkInterface->setMtu(par("mtu"));
142  networkInterface->setMulticast(false);
143  networkInterface->setBroadcast(true);
144 }

◆ decapsulate()

void inet::XMac::decapsulate ( Packet packet)
protected
609 {
610  const auto& xmacHeader = packet->popAtFront<XMacDataFrameHeader>();
611  packet->addTagIfAbsent<MacAddressInd>()->setSrcAddress(xmacHeader->getSrcAddr());
612  packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(networkInterface->getInterfaceId());
613  auto payloadProtocol = ProtocolGroup::ethertype.getProtocol(xmacHeader->getNetworkProtocol());
614  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(payloadProtocol);
615  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(payloadProtocol);
616  packet->setKind(0);
617  EV_DETAIL << " message decapsulated " << endl;
618 }

◆ encapsulate()

void inet::XMac::encapsulate ( Packet packet)
protected
621 {
622  auto pkt = makeShared<XMacDataFrameHeader>();
623  pkt->setChunkLength(headerLength);
624 
625  // copy dest address from the Control Info attached to the network
626  // message by the network layer
627  auto dest = packet->getTag<MacAddressReq>()->getDestAddress();
628  EV_DETAIL << "CInfo removed, mac addr=" << dest << endl;
629  pkt->setNetworkProtocol(ProtocolGroup::ethertype.getProtocolNumber(packet->getTag<PacketProtocolTag>()->getProtocol()));
630  pkt->setDestAddr(dest);
631 
632  // delete the control info
633  delete packet->removeControlInfo();
634 
635  // set the src address to own mac address (nic module getId())
636  pkt->setSrcAddr(networkInterface->getMacAddress());
637 
638  pkt->setType(XMAC_DATA);
639  packet->setKind(XMAC_DATA);
640 
641  // encapsulate the network packet
642  packet->insertAtFront(pkt);
643  packet->getTagForUpdate<PacketProtocolTag>()->setProtocol(&Protocol::xmac);
644  EV_DETAIL << "pkt encapsulated\n";
645 }

◆ finish()

void inet::XMac::finish ( )
overridevirtual

Delete all dynamically allocated objects of the module.

111 {
112  // record stats
113  if (stats) {
114  recordScalar("nbTxDataPackets", nbTxDataPackets);
115  recordScalar("nbTxPreambles", nbTxPreambles);
116  recordScalar("nbRxDataPackets", nbRxDataPackets);
117  recordScalar("nbRxPreambles", nbRxPreambles);
118  recordScalar("nbMissedAcks", nbMissedAcks);
119  recordScalar("nbRecvdAcks", nbRecvdAcks);
120  recordScalar("nbTxAcks", nbTxAcks);
121  recordScalar("nbDroppedDataPackets", nbDroppedDataPackets);
122  recordScalar("nbRxBrokenDataPackets", nbRxBrokenDataPackets);
123 // recordScalar("timeSleep", timeSleep);
124 // recordScalar("timeRX", timeRX);
125 // recordScalar("timeTX", timeTX);
126  }
127 }

◆ getProvider()

queueing::IPassivePacketSource * inet::XMac::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.

648 {
649  return (gate->getId() == upperLayerInGateId) ? txQueue.get() : nullptr;
650 }

◆ handleCanPullPacketChanged()

void inet::XMac::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.

653 {
654  Enter_Method("handleCanPullPacketChanged");
655  // force wakeup now
656  if (gate->getId() == upperLayerInGateId && (macState == SLEEP) && wakeup->isScheduled()
657  && canDequeuePacket())
658  {
659  rescheduleAfter(dblrand() * 0.01f, wakeup);
660  }
661 }

◆ handleLowerPacket()

void inet::XMac::handleLowerPacket ( Packet msg)
overridevirtual

Handle messages from lower layer.

Handle XMAC preambles and received data packets.

Reimplemented from inet::LayeredProtocolBase.

499 {
500  if (msg->hasBitError()) {
501  EV << "Received " << msg << " contains bit errors or collision, dropping it\n";
503  delete msg;
504  return;
505  }
506  // simply pass the massage as self message, to be processed by the FSM.
507  const auto& hdr = msg->peekAtFront<XMacHeaderBase>();
508  msg->setKind(hdr->getType());
509  handleSelfMessage(msg);
510 }

◆ handlePullPacketProcessed()

void inet::XMac::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.

664 {
665  Enter_Method("handlePullPacketProcessed");
666  throw cRuntimeError("Not supported callback");
667 }

◆ handleSelfMessage()

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

Handle self messages such as timers.

Handle own messages:

Reimplemented from inet::LayeredProtocolBase.

196 {
197  MacAddress address = networkInterface->getMacAddress();
198 
199  switch (macState) {
200  case INIT:
201  if (msg->getKind() == XMAC_START_XMAC) {
202  EV_DEBUG << "State INIT, message XMAC_START, new state SLEEP" << endl;
204  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
205  macState = SLEEP;
206  scheduleAfter(dblrand() * slotDuration, wakeup);
207  return;
208  }
209  break;
210  case SLEEP:
211  if (msg->getKind() == XMAC_WAKE_UP) {
212  EV_DEBUG << "node " << address << " : State SLEEP, message XMAC_WAKEUP, new state CCA, simTime "
213  << simTime() << " to " << simTime() + 1.7f * checkInterval << endl;
214  // this CCA is useful when in RX to detect preamble and has to make room for
215  // 0.2f = Tx switch, 0.5f = Tx send_preamble, 1f = time_for_ack_back
216  scheduleAfter(1.7f * checkInterval, cca_timeout);
217  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
219  macState = CCA;
220  return;
221  }
222  // we receive an ACK back but it is too late
223  else if (msg->getKind() == XMAC_ACK) {
224  nbMissedAcks++;
225  delete msg;
226  return;
227  }
228  // received messages prior real-switching to SLEEP? I'm sorry, out
229  else {
230  return;
231  }
232  break;
233  case CCA:
234  if (msg->getKind() == XMAC_CCA_TIMEOUT) {
235  // channel is clear and we wanna SEND
236  if (!txQueue->isEmpty()) {
237  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
240  // We send the preamble for a whole SLOT duration :)
241  scheduleAfter(slotDuration, stop_preambles);
242  // if 0.2f * CI = 2ms to switch to TX -> has to be accounted for RX_preamble_detection
243  scheduleAfter(0.2f * checkInterval, switch_preamble_phase);
244  return;
245  }
246  // if anything to send, go back to sleep and wake up after a full period
247  else {
248  scheduleAfter(slotDuration, wakeup);
249  macState = SLEEP;
250  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
252  return;
253  }
254  }
255  // during CCA, we received a preamble. Go to state WAIT_DATA and
256  // schedule the timeout.
257  if (msg->getKind() == XMAC_PREAMBLE) {
258  auto incoming_preamble = check_and_cast<Packet *>(msg)->peekAtFront<XMacControlFrame>();
259 
260  // preamble is for me
261  if (incoming_preamble->getDestAddr() == address || incoming_preamble->getDestAddr().isBroadcast() || incoming_preamble->getDestAddr().isMulticast()) {
262  cancelEvent(cca_timeout);
263  nbRxPreambles++;
264  EV << "node " << address << " : State CCA, message XMAC_PREAMBLE received, new state SEND_ACK" << endl;
265  macState = SEND_ACK;
266  lastPreamblePktSrcAddr = incoming_preamble->getSrcAddr();
268  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
269  }
270  // the preamble is not for us
271  else {
272  EV << "node " << address << " : State CCA, message XMAC_PREAMBLE not for me." << endl;
273  // ~ better overhearing management? :)
274  cancelEvent(cca_timeout);
275  scheduleAfter(slotDuration, wakeup);
276  macState = SLEEP;
277  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
279  }
280 
281  delete msg;
282  return;
283  }
284  // in case we get an ACK, we simply dicard it, because it means the end
285  // of another communication
286  if (msg->getKind() == XMAC_ACK) {
287  EV_DEBUG << "State CCA, message XMAC_ACK, new state CCA" << endl;
288  delete msg;
289  return;
290  }
291  // this case is very, very, very improbable, but let's do it.
292  // if in CCA the node receives directly the data packet, accept it
293  // even if we increased nbMissedAcks in state SLEEP
294  if (msg->getKind() == XMAC_DATA) {
295  auto incoming_data = check_and_cast<Packet *>(msg)->peekAtFront<XMacDataFrameHeader>();
296 
297  // packet is for me
298  if (incoming_data->getDestAddr() == address) {
299  EV << "node " << address << " : State CCA, received XMAC_DATA, accepting it." << endl;
300  cancelEvent(cca_timeout);
301  cancelEvent(switch_preamble_phase);
302  cancelEvent(stop_preambles);
304  scheduleAfter(SIMTIME_ZERO, msg);
305  }
306  return;
307  }
308  break;
309 
310  case SEND_PREAMBLE:
311  if (msg->getKind() == SWITCH_PREAMBLE_PHASE) {
312  // ~ make room for preamble + time_for_ack_back, check_interval is 10ms by default (from NetworkXMAC.ini)
313  // 0.5f* = 5ms
314  if (radio->getRadioMode() == IRadio::RADIO_MODE_RECEIVER) {
315  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
317  EV_DEBUG << "node " << address << " : preamble_phase tx, simTime = " << simTime() << endl;
318  scheduleAfter(0.5f * checkInterval, switch_preamble_phase);
319  }
320  // 1.0f* = 10ms
321  else if (radio->getRadioMode() == IRadio::RADIO_MODE_TRANSMITTER) {
322  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
324  EV_DEBUG << "node " << address << " : preamble_phase rx, simTime = " << simTime() << endl;
325  scheduleAfter(1.0f * checkInterval, switch_preamble_phase);
326  }
327  return;
328  }
329  // radio switch from above
330  if (msg->getKind() == XMAC_SWITCHING_FINISHED) {
331  if (radio->getRadioMode() == IRadio::RADIO_MODE_TRANSMITTER) {
332  if (currentTxFrame == nullptr) {
335  }
336  auto pkt_preamble = currentTxFrame->peekAtFront<XMacHeaderBase>();
337  sendPreamble(pkt_preamble->getDestAddr());
338  }
339  return;
340  }
341  // ack_rx within sending_preamble or preamble_timeout without an ACK
342  if ((msg->getKind() == XMAC_ACK) || (msg->getKind() == XMAC_STOP_PREAMBLES)) {
343  // ~ ADDED THE SECOND CONDITION! :) if not, below
344  if (msg->getKind() == XMAC_ACK) {
345  delete msg;
346  EV << "node " << address << " : State SEND_PREAMBLE, message XMAC_ACK, new state SEND_DATA" << endl;
347  }
348  else if (msg->getKind() == XMAC_STOP_PREAMBLES) {
349  EV << "node " << address << " : State SEND_PREAMBLE, message XMAC_STOP_PREAMBLES" << endl;
350  }
352  cancelEvent(stop_preambles);
353  cancelEvent(switch_preamble_phase);
355  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
356  txAttempts = 1;
357  return;
358  }
359 
360  // next is the case of a node receiving 1 preamble or data while in his preamble gaps, ignore, we are sending!
361  if ((msg->getKind() == XMAC_PREAMBLE) || (msg->getKind() == XMAC_DATA)) {
362  if (msg->getKind() == XMAC_DATA) {
364  }
365  delete msg;
366  return;
367  }
368  else {
369  EV << "**node " << address << " : State SEND_PREAMBLE, received message " << msg->getKind() << endl;
370  return;
371  }
372  break;
373 
374  case SEND_DATA:
375  if (msg->getKind() == XMAC_STOP_PREAMBLES) {
376  EV << "node " << address << " : State SEND_DATA, message XMAC_STOP_PREAMBLES" << endl;
377  // send the data packet
378  sendDataPacket();
380  return;
381  }
382  else if (msg->getKind() == XMAC_SWITCHING_FINISHED) {
383  EV << "node " << address << " : State SEND_DATA, message RADIO_SWITCHING OVER, sending packet..." << endl;
384  // send the data packet
385  sendDataPacket();
387  return;
388  }
389  else {
390  return;
391  }
392  break;
393 
394  case WAIT_TX_DATA_OVER:
395  if (msg->getKind() == XMAC_DATA_TX_OVER) {
396  EV_DEBUG << "node " << address << " : State WAIT_TX_DATA_OVER, message XMAC_DATA_TX_OVER, new state SLEEP" << endl;
397  // remove the packet just served from the queue
399  // if something in the queue, wakeup soon.
400  if (!txQueue->isEmpty())
401  scheduleAfter(dblrand() * checkInterval, wakeup);
402  else
403  scheduleAfter(slotDuration, wakeup);
404  macState = SLEEP;
405  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
407  return;
408  }
409  break;
410  case WAIT_ACK:
411  // not used
412  break;
413  case WAIT_DATA:
414  if (msg->getKind() == XMAC_PREAMBLE) {
415  // nothing happens
416  nbRxPreambles++;
417  delete msg;
418  return;
419  }
420  if (msg->getKind() == XMAC_ACK) {
421  // nothing happens
422  delete msg;
423  return;
424  }
425  if (msg->getKind() == XMAC_DATA) {
426  auto packet = check_and_cast<Packet *>(msg);
427  auto mac = packet->peekAtFront<XMacDataFrameHeader>();
428  const MacAddress& dest = mac->getDestAddr();
429 
430  if ((dest == address) || dest.isBroadcast() || dest.isMulticast()) {
431  decapsulate(packet);
432  sendUp(packet);
433  nbRxDataPackets++;
434  cancelEvent(data_timeout);
435 
436  // if something in the queue, wakeup soon.
437  if (!txQueue->isEmpty())
438  scheduleAfter(dblrand() * checkInterval, wakeup);
439  else
440  scheduleAfter(slotDuration, wakeup);
441  macState = SLEEP;
442  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
444 
445  }
446  else {
447  delete msg;
448  msg = nullptr;
449  mac = nullptr;
450  }
451 
452  EV << "node " << address << " : State WAIT_DATA, message XMAC_DATA, new state SLEEP" << endl;
453  return;
454  }
455  // data does not arrives in time
456  if (msg->getKind() == XMAC_DATA_TIMEOUT) {
457  EV << "node " << address << " : State WAIT_DATA, message XMAC_DATA_TIMEOUT, new state SLEEP" << endl;
458  // if something in the queue, wakeup soon.
459  if (!txQueue->isEmpty())
460  scheduleAfter(dblrand() * checkInterval, wakeup);
461  else
462  scheduleAfter(slotDuration, wakeup);
463  macState = SLEEP;
464  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
466  return;
467  }
468  break;
469  case SEND_ACK:
470  // send now the ack packet
471  if (msg->getKind() == DELAY_FOR_ACK_WITHIN_REMOTE_RX) {
472  EV_DEBUG << "node " << address << " : State SEND_ACK, message XMAC_SEND_ACK, new state WAIT_ACK_TX" << endl;
473  sendMacAck();
475  return;
476  }
477  break;
478  case WAIT_ACK_TX:
479  // wait for the ACK to be sent back to the Transmitter
480  if (msg->getKind() == XMAC_ACK_TX_OVER) {
481  EV_DEBUG << "node " << address << " : State WAIT_ACK_TX, message XMAC_ACK_TX_OVER, new state WAIT_DATA" << endl;
484  cancelEvent(cca_timeout);
485  scheduleAfter((slotDuration / 2), data_timeout);
486  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
487  return;
488  }
489  break;
490  }
491  throw cRuntimeError("Undefined event of type %d in state %d (Radio state %d)!",
492  msg->getKind(), macState, radio->getRadioMode());
493 }

◆ handleUpperPacket()

void inet::XMac::handleUpperPacket ( Packet packet)
overridevirtual

Handle messages from upper layer.

Check whether the queue is not full: if yes, print a warning and drop the packet.

Then initiate sending of the packet, if the node is sleeping. Do nothing, if node is working.

Reimplemented from inet::LayeredProtocolBase.

152 {
153  throw cRuntimeError("Model error: this module should pull packet from upper queue, direct incoming packet not accepted");
154 }

◆ initialize()

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

Initialization of the module and some variables.

Initialize method of XMac.

Init all parameters, schedule timers.

Reimplemented from inet::MacProtocolBase.

29 {
31  if (stage == INITSTAGE_LOCAL) {
32  animation = par("animation");
33  slotDuration = par("slotDuration");
34  bitrate = par("bitrate");
35  headerLength = b(par("headerLength"));
36  ctrlFrameLength = b(par("ctrlFrameLength"));
37  checkInterval = par("checkInterval");
38  txPower = par("txPower");
39  useMacAcks = par("useMACAcks");
40  maxTxAttempts = par("maxTxAttempts");
41  EV_DEBUG << "headerLength: " << headerLength << "ctrlFrameLength: " << ctrlFrameLength << ", bitrate: " << bitrate << endl;
42 
43  stats = par("stats");
44  nbTxDataPackets = 0;
45  nbTxPreambles = 0;
46  nbRxDataPackets = 0;
47  nbRxPreambles = 0;
48  nbMissedAcks = 0;
49  nbRecvdAcks = 0;
52  nbTxAcks = 0;
53 
54  txAttempts = 0;
57 
58  macState = INIT;
60  WATCH(macState);
61  }
62  else if (stage == INITSTAGE_LINK_LAYER) {
63  radio.reference(this, "radioModule", true);
64  cModule *radioModule = check_and_cast<cModule *>(radio.get());
65  radioModule->subscribe(IRadio::radioModeChangedSignal, this);
66  radioModule->subscribe(IRadio::transmissionStateChangedSignal, this);
67 
68  wakeup = new cMessage("wakeup", XMAC_WAKE_UP);
69 
70  data_timeout = new cMessage("data_timeout", XMAC_DATA_TIMEOUT);
71  data_timeout->setSchedulingPriority(100);
72 
73  data_tx_over = new cMessage("data_tx_over", XMAC_DATA_TX_OVER);
74  stop_preambles = new cMessage("stop_preambles", XMAC_STOP_PREAMBLES);
75  send_preamble = new cMessage("send_preamble", XMAC_SEND_PREAMBLE);
76  ack_tx_over = new cMessage("ack_tx_over", XMAC_ACK_TX_OVER);
77  cca_timeout = new cMessage("cca_timeout", XMAC_CCA_TIMEOUT);
78  cca_timeout->setSchedulingPriority(100);
79  send_ack = new cMessage("send_ack", XMAC_SEND_ACK);
80  start_xmac = new cMessage("start_xmac", XMAC_START_XMAC);
81  ack_timeout = new cMessage("ack_timeout", XMAC_ACK_TIMEOUT);
82  resend_data = new cMessage("resend_data", XMAC_RESEND_DATA);
83  resend_data->setSchedulingPriority(100);
84  switch_preamble_phase = new cMessage("switch_preamble_phase", SWITCH_PREAMBLE_PHASE);
85  delay_for_ack_within_remote_rx = new cMessage("delay_for_ack_within_remote_rx", DELAY_FOR_ACK_WITHIN_REMOTE_RX);
86  switching_done = new cMessage("switching_done", XMAC_SWITCHING_FINISHED);
87 
88  scheduleAfter(SIMTIME_ZERO, start_xmac);
89  }
90 }

◆ operator=()

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

Assignment operator is not allowed.

◆ receiveSignal()

void inet::XMac::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
intval_t  value,
cObject *  details 
)
override

Handle transmission over messages: either send another preambles or the data packet itself.

532 {
533  Enter_Method("%s", cComponent::getSignalName(signalID));
534 
535  if (signalID == IRadio::transmissionStateChangedSignal) {
536  IRadio::TransmissionState newRadioTransmissionState = (IRadio::TransmissionState)value;
538  // Transmission of one packet is over
539  if (macState == WAIT_TX_DATA_OVER) {
540  scheduleAfter(SIMTIME_ZERO, data_tx_over);
541  }
542  if (macState == WAIT_ACK_TX) {
543  scheduleAfter(SIMTIME_ZERO, ack_tx_over);
544  }
545  }
546  transmissionState = newRadioTransmissionState;
547  }
548  else if (signalID == IRadio::radioModeChangedSignal) {
549  // Radio switching (to RX or TX) is over, ignore switching to SLEEP.
550  if (macState == SEND_PREAMBLE) {
551  scheduleAfter(SIMTIME_ZERO, switching_done);
552  }
553  else if (macState == SEND_ACK) {
554  scheduleAfter(0.5f * checkInterval, delay_for_ack_within_remote_rx);
555  }
556  else if (macState == SEND_DATA) {
557  scheduleAfter(SIMTIME_ZERO, switching_done);
558  }
559  }
560 }

◆ sendDataPacket()

void inet::XMac::sendDataPacket ( )
protected

Internal function to send the first packet in the queue.

513 {
514  nbTxDataPackets++;
515  if (currentTxFrame == nullptr) {
518  }
519  auto packet = currentTxFrame->dup();
520  const auto& hdr = packet->peekAtFront<XMacHeaderBase>();
521  lastDataPktDestAddr = hdr->getDestAddr();
522  ASSERT(hdr->getType() == XMAC_DATA);
523  attachSignal(packet, simTime());
524  sendDown(packet);
525 }

◆ sendMacAck()

void inet::XMac::sendMacAck ( )
protected

Internal function to send an ACK.

Send one short preamble packet immediately.

178 {
179  auto ack = makeShared<XMacControlFrame>();
180  ack->setSrcAddr(networkInterface->getMacAddress());
181  // ~ diff with XMAC, ack_preamble_based
182  ack->setDestAddr(lastPreamblePktSrcAddr);
183  ack->setChunkLength(ctrlFrameLength);
184  ack->setType(XMAC_ACK);
185  auto packet = new Packet("XMacAck", ack);
186  packet->addTag<PacketProtocolTag>()->setProtocol(&Protocol::xmac);
187  attachSignal(packet, simTime());
188  sendDown(packet);
189  nbTxAcks++;
190 }

◆ sendPreamble()

void inet::XMac::sendPreamble ( MacAddress  destination)
protected

Internal function to send one preamble.

Send one short preamble packet immediately.

160 {
161  // ~ diff with XMAC, @ in preamble!
162  auto preamble = makeShared<XMacControlFrame>();
163  preamble->setSrcAddr(networkInterface->getMacAddress());
164  preamble->setDestAddr(preamble_address);
165  preamble->setChunkLength(ctrlFrameLength);
166  preamble->setType(XMAC_PREAMBLE);
167  auto packet = new Packet("Preamble", preamble);
168  packet->addTag<PacketProtocolTag>()->setProtocol(&Protocol::xmac);
169  attachSignal(packet, simTime());
170  sendDown(packet);
171  nbTxPreambles++;
172 }

Member Data Documentation

◆ ack_timeout

cMessage* inet::XMac::ack_timeout
protected

◆ ack_tx_over

cMessage* inet::XMac::ack_tx_over
protected

◆ animation

bool inet::XMac::animation
protected

Animate (colorize) the nodes.

The color of the node reflects its basic status (not the exact state!) BLACK - node is sleeping GREEN - node is receiving YELLOW - node is sending

◆ bitrate

double inet::XMac::bitrate
protected

The bitrate of transmission.

◆ cca_timeout

cMessage* inet::XMac::cca_timeout
protected

◆ checkInterval

double inet::XMac::checkInterval
protected

The duration of CCA.

◆ ctrlFrameLength

b inet::XMac::ctrlFrameLength = b(0)
protected

◆ data_timeout

cMessage* inet::XMac::data_timeout
protected

◆ data_tx_over

cMessage* inet::XMac::data_tx_over
protected

◆ delay_for_ack_within_remote_rx

cMessage* inet::XMac::delay_for_ack_within_remote_rx
protected

◆ headerLength

b inet::XMac::headerLength = b(0)
protected

◆ lastDataPktDestAddr

MacAddress inet::XMac::lastDataPktDestAddr
protected

◆ lastDataPktSrcAddr

MacAddress inet::XMac::lastDataPktSrcAddr
protected

◆ lastPreamblePktSrcAddr

MacAddress inet::XMac::lastPreamblePktSrcAddr
protected

◆ macState

States inet::XMac::macState
protected

The current state of the protocol.

◆ maxTxAttempts

int inet::XMac::maxTxAttempts
protected

Maximum transmission attempts per data packet, when ACKs are used.

◆ nbDroppedDataPackets

long inet::XMac::nbDroppedDataPackets
protected

◆ nbMissedAcks

long inet::XMac::nbMissedAcks
protected

◆ nbRecvdAcks

long inet::XMac::nbRecvdAcks
protected

◆ nbRxBrokenDataPackets

long inet::XMac::nbRxBrokenDataPackets
protected

◆ nbRxDataPackets

long inet::XMac::nbRxDataPackets
protected

◆ nbRxPreambles

long inet::XMac::nbRxPreambles
protected

◆ nbTxAcks

long inet::XMac::nbTxAcks
protected

◆ nbTxDataPackets

long inet::XMac::nbTxDataPackets
protected

◆ nbTxPreambles

long inet::XMac::nbTxPreambles
protected

◆ radio

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

The radio.

◆ resend_data

cMessage* inet::XMac::resend_data
protected

◆ send_ack

cMessage* inet::XMac::send_ack
protected

◆ send_preamble

cMessage* inet::XMac::send_preamble
protected

◆ slotDuration

double inet::XMac::slotDuration
protected

The duration of the slot in secs.

◆ start_xmac

cMessage* inet::XMac::start_xmac
protected

◆ stats

bool inet::XMac::stats
protected

Gather stats at the end of the simulation.

◆ stop_preambles

cMessage* inet::XMac::stop_preambles
protected

◆ switch_preamble_phase

cMessage* inet::XMac::switch_preamble_phase
protected

◆ switching_done

cMessage* inet::XMac::switching_done
protected

◆ transmissionState

◆ txAttempts

int inet::XMac::txAttempts
protected

◆ txPower

double inet::XMac::txPower
protected

Transmission power of the node.

◆ useMacAcks

bool inet::XMac::useMacAcks
protected

Use MAC level acks or not.

◆ wakeup

cMessage* inet::XMac::wakeup
protected

The documentation for this class was generated from the following files:
inet::MacProtocolBase::networkInterface
opp_component_ptr< NetworkInterface > networkInterface
Definition: MacProtocolBase.h:30
inet::XMac::SEND_DATA
@ SEND_DATA
Definition: XMac.h:143
inet::XMac::data_tx_over
cMessage * data_tx_over
Definition: XMac.h:164
inet::XMac::slotDuration
double slotDuration
The duration of the slot in secs.
Definition: XMac.h:192
inet::XMac::BLACK
@ BLACK
Definition: XMac.h:212
inet::XMac::headerLength
b headerLength
Definition: XMac.h:173
inet::XMac::useMacAcks
bool useMacAcks
Use MAC level acks or not.
Definition: XMac.h:200
inet::XMAC_START_XMAC
@ XMAC_START_XMAC
Definition: XMacHeader_m.h:82
inet::XMac::wakeup
cMessage * wakeup
Definition: XMac.h:156
inet::XMac::nbRxDataPackets
long nbRxDataPackets
Definition: XMac.h:108
inet::XMAC_RESEND_DATA
@ XMAC_RESEND_DATA
Definition: XMacHeader_m.h:80
inet::MacProtocolBase::sendUp
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
inet::XMac::stop_preambles
cMessage * stop_preambles
Definition: XMac.h:163
inet::XMac::lastDataPktDestAddr
MacAddress lastDataPktDestAddr
Definition: XMac.h:171
inet::XMac::lastDataPktSrcAddr
MacAddress lastDataPktSrcAddr
Definition: XMac.h:170
inet::XMac::BLUE
@ BLUE
Definition: XMac.h:210
inet::XMac::SEND_PREAMBLE
@ SEND_PREAMBLE
Definition: XMac.h:141
inet::XMAC_SWITCHING_FINISHED
@ XMAC_SWITCHING_FINISHED
Definition: XMacHeader_m.h:93
inet::XMac::switching_done
cMessage * switching_done
Definition: XMac.h:166
inet::XMac::ack_tx_over
cMessage * ack_tx_over
Definition: XMac.h:159
inet::XMAC_PREAMBLE
@ XMAC_PREAMBLE
Definition: XMacHeader_m.h:77
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::DELAY_FOR_ACK_WITHIN_REMOTE_RX
@ DELAY_FOR_ACK_WITHIN_REMOTE_RX
Definition: XMacHeader_m.h:92
inet::getContainingNode
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
inet::physicallayer::IRadio::RADIO_MODE_SLEEP
@ RADIO_MODE_SLEEP
The radio is sleeping, frame reception or transmission is not possible, power consumption is minimal,...
Definition: IRadio.h:90
inet::XMac::nbRecvdAcks
long nbRecvdAcks
Definition: XMac.h:111
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::SWITCH_PREAMBLE_PHASE
@ SWITCH_PREAMBLE_PHASE
Definition: XMacHeader_m.h:91
inet::XMac::nbTxDataPackets
long nbTxDataPackets
Definition: XMac.h:106
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::XMac::SLEEP
@ SLEEP
Definition: XMac.h:139
inet::XMac::sendMacAck
void sendMacAck()
Internal function to send an ACK.
Definition: XMac.cc:177
inet::XMAC_DATA_TIMEOUT
@ XMAC_DATA_TIMEOUT
Definition: XMacHeader_m.h:90
inet::XMac::sendDataPacket
void sendDataPacket()
Internal function to send the first packet in the queue.
Definition: XMac.cc:512
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::XMAC_SEND_PREAMBLE
@ XMAC_SEND_PREAMBLE
Definition: XMacHeader_m.h:87
inet::XMac::changeDisplayColor
void changeDisplayColor(XMAC_COLORS color)
Internal function to change the color of the node.
Definition: XMac.cc:571
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::XMac::nbRxPreambles
long nbRxPreambles
Definition: XMac.h:109
inet::XMAC_ACK_TX_OVER
@ XMAC_ACK_TX_OVER
Definition: XMacHeader_m.h:86
inet::XMac::checkInterval
double checkInterval
The duration of CCA.
Definition: XMac.h:196
inet::MacProtocolBase::MacProtocolBase
MacProtocolBase()
Definition: MacProtocolBase.cc:15
inet::XMac::send_ack
cMessage * send_ack
Definition: XMac.h:157
inet::XMac::macState
States macState
The current state of the protocol.
Definition: XMac.h:150
inet::XMac::nbTxPreambles
long nbTxPreambles
Definition: XMac.h:107
inet::XMac::maxTxAttempts
int maxTxAttempts
Maximum transmission attempts per data packet, when ACKs are used.
Definition: XMac.h:203
inet::XMac::bitrate
double bitrate
The bitrate of transmission.
Definition: XMac.h:194
inet::XMac::transmissionState
physicallayer::IRadio::TransmissionState transmissionState
Definition: XMac.h:178
inet::Packet::dup
virtual Packet * dup() const override
Definition: Packet.h:171
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::XMac::ack_timeout
cMessage * ack_timeout
Definition: XMac.h:154
inet::XMac::handleSelfMessage
virtual void handleSelfMessage(cMessage *) override
Handle self messages such as timers.
Definition: XMac.cc:195
inet::XMac::SEND_ACK
@ SEND_ACK
Definition: XMac.h:146
inet::MacProtocolBase::currentTxFrame
Packet * currentTxFrame
Currently transmitted frame if any.
Definition: MacProtocolBase.h:35
inet::XMac::resend_data
cMessage * resend_data
Definition: XMac.h:153
inet::XMac::delay_for_ack_within_remote_rx
cMessage * delay_for_ack_within_remote_rx
Definition: XMac.h:162
inet::XMac::data_timeout
cMessage * data_timeout
Definition: XMac.h:165
inet::MacProtocolBase::sendDown
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
inet::XMac::ctrlFrameLength
b ctrlFrameLength
Definition: XMac.h:174
inet::XMAC_CCA_TIMEOUT
@ XMAC_CCA_TIMEOUT
Definition: XMacHeader_m.h:85
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::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::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::XMac::stats
bool stats
Gather stats at the end of the simulation.
Definition: XMac.h:205
inet::XMac::switch_preamble_phase
cMessage * switch_preamble_phase
Definition: XMac.h:161
inet::Protocol::xmac
static const Protocol xmac
Definition: Protocol.h:118
inet::XMac::decapsulate
void decapsulate(Packet *packet)
Definition: XMac.cc:608
inet::XMac::animation
bool animation
Animate (colorize) the nodes.
Definition: XMac.h:190
inet::XMac::nbRxBrokenDataPackets
long nbRxBrokenDataPackets
Definition: XMac.h:114
inet::MacProtocolBase::deleteCurrentTxFrame
virtual void deleteCurrentTxFrame()
Definition: MacProtocolBase.cc:93
inet::XMAC_ACK
@ XMAC_ACK
Definition: XMacHeader_m.h:79
inet::MacProtocolBase::initialize
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
inet::XMac::encapsulate
void encapsulate(Packet *packet)
Definition: XMac.cc:620
inet::XMac::WAIT_ACK
@ WAIT_ACK
Definition: XMac.h:145
inet::XMac::RED
@ RED
Definition: XMac.h:211
inet::XMAC_STOP_PREAMBLES
@ XMAC_STOP_PREAMBLES
Definition: XMacHeader_m.h:88
inet::XMac::YELLOW
@ YELLOW
Definition: XMac.h:213
inet::XMac::sendPreamble
void sendPreamble(MacAddress destination)
Internal function to send one preamble.
Definition: XMac.cc:159
inet::XMac::start_xmac
cMessage * start_xmac
Definition: XMac.h:155
inet::MacProtocolBase::getQueue
queueing::IPacketQueue * getQueue(cGate *gate) const
Definition: MacProtocolBase.cc:157
inet::XMac::lastPreamblePktSrcAddr
MacAddress lastPreamblePktSrcAddr
Definition: XMac.h:172
inet::XMac::GREEN
@ GREEN
Definition: XMac.h:209
inet::XMAC_WAKE_UP
@ XMAC_WAKE_UP
Definition: XMacHeader_m.h:83
inet::XMac::WAIT_ACK_TX
@ WAIT_ACK_TX
Definition: XMac.h:147
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::XMac::attachSignal
void attachSignal(Packet *packet, simtime_t_cref startTime)
Internal function to attach a signal to the packet.
Definition: XMac.cc:562
inet::XMac::radio
ModuleRefByPar< physicallayer::IRadio > radio
The radio.
Definition: XMac.h:177
inet::MacProtocolBase::dequeuePacket
virtual Packet * dequeuePacket()
Definition: MacProtocolBase.cc:175
inet::XMAC_DATA_TX_OVER
@ XMAC_DATA_TX_OVER
Definition: XMacHeader_m.h:89
inet::MacAddress::BROADCAST_ADDRESS
static const MacAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MacAddress.h:34
inet::XMac::nbDroppedDataPackets
long nbDroppedDataPackets
Definition: XMac.h:112
inet::XMac::INIT
@ INIT
Definition: XMac.h:138
inet::MacProtocolBase::parseMacAddressParameter
virtual MacAddress parseMacAddressParameter(const char *addrstr)
Definition: MacProtocolBase.cc:24
inet::XMac::send_preamble
cMessage * send_preamble
Definition: XMac.h:160
inet::XMAC_SEND_ACK
@ XMAC_SEND_ACK
Definition: XMacHeader_m.h:84
inet::XMAC_ACK_TIMEOUT
@ XMAC_ACK_TIMEOUT
Definition: XMacHeader_m.h:81
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_IDLE
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
inet::XMac::txPower
double txPower
Transmission power of the node.
Definition: XMac.h:198
inet::XMac::WAIT_TX_DATA_OVER
@ WAIT_TX_DATA_OVER
Definition: XMac.h:144
inet::XMAC_DATA
@ XMAC_DATA
Definition: XMacHeader_m.h:78
inet::XMac::nbMissedAcks
long nbMissedAcks
Definition: XMac.h:110
inet::XMac::CCA
@ CCA
Definition: XMac.h:140
inet::MacProtocolBase::canDequeuePacket
virtual bool canDequeuePacket() const
Definition: MacProtocolBase.cc:170
inet::XMac::WAIT_DATA
@ WAIT_DATA
Definition: XMac.h:142
inet::XMac::nbTxAcks
long nbTxAcks
Definition: XMac.h:113
inet::XMac::txAttempts
int txAttempts
Definition: XMac.h:180
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::ProtocolGroup::ethertype
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40
inet::physicallayer::IRadio::radioModeChangedSignal
static simsignal_t radioModeChangedSignal
This signal is emitted when the radio mode of the radio is changed.
Definition: IRadio.h:42
inet::XMac::cca_timeout
cMessage * cca_timeout
Definition: XMac.h:158