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

Implementation of B-MAC (called also Berkeley MAC, Low Power Listening or LPL). More...

#include <BMac.h>

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

Public Member Functions

 BMac ()
 
virtual ~BMac ()
 
virtual int numInitStages () const override
 Initialization of the module and some variables. More...
 
virtual void initialize (int) override
 
virtual void refreshDisplay () const override
 Change the color of the node for animation purposes. 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 ()
 

Protected Member Functions

void scheduleWakeUp ()
 
- 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 ()
 

Protected Attributes

ModuleRefByPar< physicallayer::IRadioradio
 The radio. More...
 
physicallayer::IRadio::TransmissionState transmissionState = physicallayer::IRadio::TRANSMISSION_STATE_UNDEFINED
 
- 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
 

Private Member Functions

 BMac (const BMac &)
 Copy constructor is not allowed. More...
 
BMacoperator= (const BMac &)
 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 = 0
 
long nbTxPreambles = 0
 
long nbRxDataPackets = 0
 
long nbRxPreambles = 0
 
long nbMissedAcks = 0
 
long nbRecvdAcks = 0
 
long nbDroppedDataPackets = 0
 
long nbTxAcks = 0
 
States macState = static_cast<States>(-1)
 The current state of the protocol. More...
 
cMessage * resend_data = nullptr
 
cMessage * ack_timeout = nullptr
 
cMessage * start_bmac = nullptr
 
cMessage * wakeup = nullptr
 
cMessage * send_ack = nullptr
 
cMessage * cca_timeout = nullptr
 
cMessage * ack_tx_over = nullptr
 
cMessage * send_preamble = nullptr
 
cMessage * stop_preambles = nullptr
 
cMessage * data_tx_over = nullptr
 
cMessage * data_timeout = nullptr
 

Help variables for the acknowledgment process.

MacAddress lastDataPktSrcAddr
 
MacAddress lastDataPktDestAddr
 
int txAttempts = 0
 
bool animation = false
 Animate (colorize) the nodes. More...
 
double slotDuration = 0
 The duration of the slot in secs. More...
 
b headerLength = b(0)
 Length of the header. More...
 
b ctrlFrameLength = b(0)
 
double bitrate = 0
 The bitrate of transmission. More...
 
double checkInterval = 0
 The duration of CCA. More...
 
bool useMacAcks = false
 Use MAC level acks or not. More...
 
int maxTxAttempts = 0
 Maximum transmission attempts per data packet, when ACKs are used. More...
 
bool stats = false
 Gather stats at the end of the simulation. More...
 
virtual void configureNetworkInterface () override
 Generate new interface address. More...
 
virtual void handleCommand (cMessage *msg)
 
void sendDataPacket ()
 Internal function to send the first packet in the queue. More...
 
void sendMacAck ()
 Internal function to send an ACK. More...
 
void sendPreamble ()
 Internal function to send one preamble. More...
 
void attachSignal (Packet *macPkt)
 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
 

Detailed Description

Implementation of B-MAC (called also Berkeley MAC, Low Power Listening or LPL).

The protocol works as follows: each node is allowed to sleep for slotDuration. After waking up, it first checks the channel for ongoing transmissions. If a transmission is catched (a preamble is received), the node stays awake for at most slotDuration and waits for the actual data packet. If a node wants to send a packet, it first sends preambles for at least slotDuration, thus waking up all nodes in its transmission radius and then sends out the data packet. If a mac-level ack is required, then the receiver sends the ack immediately after receiving the packet (no preambles) and the sender waits for some time more before going back to sleep.

B-MAC is designed for low traffic, low power communication in WSN and is one of the most widely used protocols (e.g. it is part of TinyOS). The finite state machine of the protocol is given in the below figure:

B-MAC Layer - finite state machine

A paper describing this implementation can be found at: http://www.omnet-workshop.org/2011/uploads/slides/OMNeT_WS2011_S5_C1_Foerster.pdf

Author
Anna Foerster

Member Enumeration Documentation

◆ States

enum inet::BMac::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 
128  {
129  INIT, // 0
130  SLEEP, // 1
131  CCA, // 2
132  SEND_PREAMBLE, // 3
133  WAIT_DATA, // 4
134  SEND_DATA, // 5
135  WAIT_TX_DATA_OVER, // 6
136  WAIT_ACK, // 7
137  SEND_ACK, // 8
138  WAIT_ACK_TX // 9
139  };

Constructor & Destructor Documentation

◆ BMac() [1/2]

inet::BMac::BMac ( const BMac )
private

Copy constructor is not allowed.

◆ BMac() [2/2]

inet::BMac::BMac ( )
inline
61 {}

◆ ~BMac()

inet::BMac::~BMac ( )
virtual
98 {
99  cancelAndDelete(wakeup);
100  cancelAndDelete(data_timeout);
101  cancelAndDelete(data_tx_over);
102  cancelAndDelete(stop_preambles);
103  cancelAndDelete(send_preamble);
104  cancelAndDelete(ack_tx_over);
105  cancelAndDelete(cca_timeout);
106  cancelAndDelete(send_ack);
107  cancelAndDelete(start_bmac);
108  cancelAndDelete(ack_timeout);
109  cancelAndDelete(resend_data);
110 }

Member Function Documentation

◆ attachSignal()

void inet::BMac::attachSignal ( Packet macPkt)
protected

Internal function to attach a signal to the packet.

561 {
562  // calc signal duration
563  simtime_t duration = macPkt->getBitLength() / bitrate;
564  // create and initialize control info with new signal
565  macPkt->setDuration(duration);
566 }

◆ configureNetworkInterface()

void inet::BMac::configureNetworkInterface ( )
overrideprotectedvirtual

Generate new interface address.

Implements inet::MacProtocolBase.

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

◆ decapsulate()

void inet::BMac::decapsulate ( Packet packet)
protected
647 {
648  const auto& bmacHeader = packet->popAtFront<BMacDataFrameHeader>();
649  packet->addTagIfAbsent<MacAddressInd>()->setSrcAddress(bmacHeader->getSrcAddr());
650  packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(networkInterface->getInterfaceId());
651  auto payloadProtocol = ProtocolGroup::ethertype.getProtocol(bmacHeader->getNetworkProtocol());
652  packet->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(payloadProtocol);
653  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(payloadProtocol);
654  packet->setKind(0);
655  EV_DETAIL << " message decapsulated " << endl;
656 }

◆ encapsulate()

void inet::BMac::encapsulate ( Packet packet)
protected
659 {
660  auto pkt = makeShared<BMacDataFrameHeader>();
661  pkt->setChunkLength(headerLength);
662 
663  pkt->setType(BMAC_DATA);
664  // copy dest address from the Control Info attached to the network
665  // message by the network layer
666  auto dest = packet->getTag<MacAddressReq>()->getDestAddress();
667  EV_DETAIL << "CInfo removed, mac addr=" << dest << endl;
668  pkt->setNetworkProtocol(ProtocolGroup::ethertype.getProtocolNumber(packet->getTag<PacketProtocolTag>()->getProtocol()));
669  pkt->setDestAddr(dest);
670 
671  // delete the control info
672  delete packet->removeControlInfo();
673 
674  // set the src address to own mac address (nic module getId())
675  pkt->setSrcAddr(networkInterface->getMacAddress());
676 
677  // encapsulate the network packet
678  packet->insertAtFront(pkt);
679  EV_DETAIL << "pkt encapsulated\n";
680  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::bmac);
681 }

◆ finish()

void inet::BMac::finish ( )
overridevirtual

Delete all dynamically allocated objects of the module.

113 {
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("timeSleep", timeSleep);
123 // recordScalar("timeRX", timeRX);
124 // recordScalar("timeTX", timeTX);
125 }

◆ getProvider()

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

693 {
694  return (gate->getId() == upperLayerInGateId) ? txQueue.get() : nullptr;
695 }

◆ handleCanPullPacketChanged()

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

698 {
699  Enter_Method("handleCanPullPacketChanged");
700  // force wakeup now
701  if (gate->getId() == upperLayerInGateId && (macState == SLEEP) && wakeup->isScheduled()
702  && canDequeuePacket())
703  {
704  rescheduleAfter(dblrand() * 0.1f, wakeup);
705  }
706 }

◆ handleCommand()

virtual void inet::BMac::handleCommand ( cMessage *  msg)
inlineprotectedvirtual
190 {}

◆ handleLowerPacket()

void inet::BMac::handleLowerPacket ( Packet packet)
overridevirtual

Handle messages from lower layer.

Handle BMAC preambles and received data packets.

Reimplemented from inet::LayeredProtocolBase.

499 {
500  if (packet->hasBitError()) {
501  EV << "Received " << packet << " contains bit errors or collision, dropping it\n";
502  PacketDropDetails details;
503  details.setReason(INCORRECTLY_RECEIVED);
504  emit(packetDroppedSignal, packet, &details);
505  delete packet;
506  return;
507  }
508  else {
509  const auto& hdr = packet->peekAtFront<BMacHeaderBase>();
510  packet->setKind(hdr->getType());
511  // simply pass the message as self message, to be processed by the FSM.
512  handleSelfMessage(packet);
513  }
514 }

◆ handlePullPacketProcessed()

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

709 {
710  Enter_Method("handlePullPacketProcessed");
711  throw cRuntimeError("Not supported callback");
712 }

◆ handleSelfMessage()

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

Handle self messages such as timers.

Handle own messages: BMAC_WAKEUP: wake up the node, check the channel for some time.

BMAC_CHECK_CHANNEL: if the channel is free, check whether there is something in the queue and switch the radio to TX. When switched to TX, the node will start sending preambles for a full slot duration. If the channel is busy, stay awake to receive message. Schedule a timeout to handle false alarms. BMAC_SEND_PREAMBLES: sending of preambles over. Next time the data packet will be send out (single one). BMAC_TIMEOUT_DATA: timeout the node after a false busy channel alarm. Go back to sleep.

Reimplemented from inet::LayeredProtocolBase.

208 {
209  switch (macState) {
210  case INIT:
211  if (msg->getKind() == BMAC_START_BMAC) {
212  EV_DETAIL << "State INIT, message BMAC_START, new state SLEEP" << endl;
213  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
214  macState = SLEEP;
215  scheduleAfter(dblrand() * slotDuration, wakeup);
216  return;
217  }
218  break;
219 
220  case SLEEP:
221  if (msg->getKind() == BMAC_WAKE_UP) {
222  EV_DETAIL << "State SLEEP, message BMAC_WAKEUP, new state CCA" << endl;
223  scheduleAfter(checkInterval, cca_timeout);
224  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
225  macState = CCA;
226  return;
227  }
228  break;
229 
230  case CCA:
231  if (msg->getKind() == BMAC_CCA_TIMEOUT) {
232  // channel is clear
233  // something waiting in eth queue?
234  if (!txQueue->isEmpty()) {
235  EV_DETAIL << "State CCA, message CCA_TIMEOUT, new state"
236  " SEND_PREAMBLE" << endl;
238  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
239  scheduleAfter(slotDuration, stop_preambles);
240  return;
241  }
242  // if not, go back to sleep and wake up after a full period
243  else {
244  EV_DETAIL << "State CCA, message CCA_TIMEOUT, new state SLEEP"
245  << endl;
246  scheduleAfter(slotDuration, wakeup);
247  macState = SLEEP;
248  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
249  return;
250  }
251  }
252  // during CCA, we received a preamble. Go to state WAIT_DATA and
253  // schedule the timeout.
254  if (msg->getKind() == BMAC_PREAMBLE) {
255  nbRxPreambles++;
256  EV_DETAIL << "State CCA, message BMAC_PREAMBLE received, new state"
257  " WAIT_DATA" << endl;
259  cancelEvent(cca_timeout);
260  scheduleAfter(slotDuration + checkInterval, data_timeout);
261  delete msg;
262  return;
263  }
264  // this case is very, very, very improbable, but let's do it.
265  // if in CCA and the node receives directly the data packet, switch to
266  // state WAIT_DATA and re-send the message
267  if (msg->getKind() == BMAC_DATA) {
268  nbRxDataPackets++;
269  EV_DETAIL << "State CCA, message BMAC_DATA, new state WAIT_DATA"
270  << endl;
272  cancelEvent(cca_timeout);
273  scheduleAfter(slotDuration + checkInterval, data_timeout);
274  scheduleAfter(SIMTIME_ZERO, msg);
275  return;
276  }
277  // in case we get an ACK, we simply dicard it, because it means the end
278  // of another communication
279  if (msg->getKind() == BMAC_ACK) {
280  EV_DETAIL << "State CCA, message BMAC_ACK, new state CCA" << endl;
281  delete msg;
282  return;
283  }
284  break;
285 
286  case SEND_PREAMBLE:
287  if (msg->getKind() == BMAC_SEND_PREAMBLE) {
288  EV_DETAIL << "State SEND_PREAMBLE, message BMAC_SEND_PREAMBLE, new"
289  " state SEND_PREAMBLE" << endl;
290  sendPreamble();
291  scheduleAfter(0.5f * checkInterval, send_preamble);
293  return;
294  }
295  // simply change the state to SEND_DATA
296  if (msg->getKind() == BMAC_STOP_PREAMBLES) {
297  EV_DETAIL << "State SEND_PREAMBLE, message BMAC_STOP_PREAMBLES, new"
298  " state SEND_DATA" << endl;
300  txAttempts = 1;
301  return;
302  }
303  break;
304 
305  case SEND_DATA:
306  if ((msg->getKind() == BMAC_SEND_PREAMBLE)
307  || (msg->getKind() == BMAC_RESEND_DATA))
308  {
309  EV_DETAIL << "State SEND_DATA, message BMAC_SEND_PREAMBLE or"
310  " BMAC_RESEND_DATA, new state WAIT_TX_DATA_OVER" << endl;
311  // send the data packet
312  if (msg->getKind() == BMAC_SEND_PREAMBLE) {
313  if (currentTxFrame != nullptr)
314  throw cRuntimeError("Model error: incomplete transmission exists");
317  }
318  ASSERT(currentTxFrame != nullptr);
319  sendDataPacket();
321  return;
322  }
323  break;
324 
325  case WAIT_TX_DATA_OVER:
326  if (msg->getKind() == BMAC_DATA_TX_OVER) {
328  EV_DETAIL << "State WAIT_TX_DATA_OVER, message BMAC_DATA_TX_OVER,"
329  " new state WAIT_ACK" << endl;
330  macState = WAIT_ACK;
331  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
332  scheduleAfter(checkInterval, ack_timeout);
333  }
334  else {
335  EV_DETAIL << "State WAIT_TX_DATA_OVER, message BMAC_DATA_TX_OVER,"
336  " new state SLEEP" << endl;
338  scheduleWakeUp();
339  macState = SLEEP;
340  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
341  }
342  return;
343  }
344  break;
345 
346  case WAIT_ACK:
347  if (msg->getKind() == BMAC_ACK_TIMEOUT) {
348  // No ACK received. try again or drop.
349  if (txAttempts < maxTxAttempts) {
350  EV_DETAIL << "State WAIT_ACK, message BMAC_ACK_TIMEOUT, new state"
351  " SEND_DATA" << endl;
352  txAttempts++;
354  scheduleAfter(slotDuration, stop_preambles);
355  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
356  }
357  else {
358  EV_DETAIL << "State WAIT_ACK, message BMAC_ACK_TIMEOUT, new state"
359  " SLEEP" << endl;
360  // drop the packet
362  PacketDropDetails details;
363  details.setReason(OTHER_PACKET_DROP);
364  dropCurrentTxFrame(details);
365  scheduleWakeUp();
366  macState = SLEEP;
367  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
368  nbMissedAcks++;
369  }
370  return;
371  }
372  // ignore and other packets
373  if ((msg->getKind() == BMAC_DATA) || (msg->getKind() == BMAC_PREAMBLE)) {
374  EV_DETAIL << "State WAIT_ACK, message BMAC_DATA or BMAC_PREMABLE, new"
375  " state WAIT_ACK" << endl;
376  delete msg;
377  return;
378  }
379  if (msg->getKind() == BMAC_ACK) {
380  EV_DETAIL << "State WAIT_ACK, message BMAC_ACK" << endl;
381  auto packet = check_and_cast<Packet *>(msg);
382  const MacAddress src = packet->peekAtFront<BMacControlFrame>()->getSrcAddr();
383  // the right ACK is received..
384  EV_DETAIL << "We are waiting for ACK from : " << lastDataPktDestAddr
385  << ", and ACK came from : " << src << endl;
386  if (src == lastDataPktDestAddr) {
387  EV_DETAIL << "New state SLEEP" << endl;
388  nbRecvdAcks++;
390  cancelEvent(ack_timeout);
392  scheduleWakeUp();
393  macState = SLEEP;
394  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
396  }
397  delete msg;
398  return;
399  }
400  break;
401 
402  case WAIT_DATA:
403  if (msg->getKind() == BMAC_PREAMBLE) {
404  // nothing happens
405  EV_DETAIL << "State WAIT_DATA, message BMAC_PREAMBLE, new state"
406  " WAIT_DATA" << endl;
407  nbRxPreambles++;
408  delete msg;
409  return;
410  }
411  if (msg->getKind() == BMAC_ACK) {
412  // nothing happens
413  EV_DETAIL << "State WAIT_DATA, message BMAC_ACK, new state WAIT_DATA"
414  << endl;
415  delete msg;
416  return;
417  }
418  if (msg->getKind() == BMAC_DATA) {
419  MacAddress address = networkInterface->getMacAddress();
420  nbRxDataPackets++;
421  auto packet = check_and_cast<Packet *>(msg);
422  const auto bmacHeader = packet->peekAtFront<BMacDataFrameHeader>();
423  const MacAddress& dest = bmacHeader->getDestAddr();
424  const MacAddress& src = bmacHeader->getSrcAddr();
425  if ((dest == address) || dest.isBroadcast()) {
426  EV_DETAIL << "Local delivery " << packet << endl;
427  decapsulate(packet);
428  sendUp(packet);
429  }
430  else {
431  EV_DETAIL << "Received " << packet << " is not for us, dropping frame." << endl;
432  PacketDropDetails details;
433  details.setReason(NOT_ADDRESSED_TO_US);
434  emit(packetDroppedSignal, msg, &details);
435  delete msg;
436  msg = nullptr;
437  packet = nullptr;
438  }
439 
440  cancelEvent(data_timeout);
441  if ((useMacAcks) && (dest == address)) {
442  EV_DETAIL << "State WAIT_DATA, message BMAC_DATA, new state"
443  " SEND_ACK" << endl;
444  macState = SEND_ACK;
445  lastDataPktSrcAddr = src;
446  radio->setRadioMode(IRadio::RADIO_MODE_TRANSMITTER);
447  }
448  else {
449  EV_DETAIL << "State WAIT_DATA, message BMAC_DATA, new state SLEEP"
450  << endl;
451  scheduleWakeUp();
452  macState = SLEEP;
453  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
454  }
455  return;
456  }
457  if (msg->getKind() == BMAC_DATA_TIMEOUT) {
458  EV_DETAIL << "State WAIT_DATA, message BMAC_DATA_TIMEOUT, new state"
459  " SLEEP" << endl;
460  scheduleWakeUp();
461  macState = SLEEP;
462  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
463  return;
464  }
465  break;
466 
467  case SEND_ACK:
468  if (msg->getKind() == BMAC_SEND_ACK) {
469  EV_DETAIL << "State SEND_ACK, message BMAC_SEND_ACK, new state"
470  " WAIT_ACK_TX" << endl;
471  // send now the ack packet
472  sendMacAck();
474  return;
475  }
476  break;
477 
478  case WAIT_ACK_TX:
479  if (msg->getKind() == BMAC_ACK_TX_OVER) {
480  EV_DETAIL << "State WAIT_ACK_TX, message BMAC_ACK_TX_OVER, new state"
481  " SLEEP" << endl;
482  // ack sent, go to sleep now.
483  scheduleWakeUp();
484  macState = SLEEP;
485  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
487  return;
488  }
489  break;
490  }
491  throw cRuntimeError("Undefined event of type %d in state %d (radio mode %d, radio reception state %d, radio transmission state %d)!",
492  msg->getKind(), macState, radio->getRadioMode(), radio->getReceptionState(), radio->getTransmissionState());
493 }

◆ handleUpperPacket()

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

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

◆ initialize()

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

Reimplemented from inet::MacProtocolBase.

28 {
30 
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  useMacAcks = par("useMACAcks");
39  maxTxAttempts = par("maxTxAttempts");
40  EV_DETAIL << "headerLength: " << headerLength << ", bitrate: " << bitrate << endl;
41 
42  nbTxDataPackets = 0;
43  nbTxPreambles = 0;
44  nbRxDataPackets = 0;
45  nbRxPreambles = 0;
46  nbMissedAcks = 0;
47  nbRecvdAcks = 0;
49  nbTxAcks = 0;
50 
51  txAttempts = 0;
54 
55  macState = INIT;
57  WATCH(macState);
58  }
59  else if (stage == INITSTAGE_LINK_LAYER) {
60  radio.reference(this, "radioModule", true);
61  cModule *radioModule = check_and_cast<cModule *>(radio.get());
62  radioModule->subscribe(IRadio::radioModeChangedSignal, this);
63  radioModule->subscribe(IRadio::transmissionStateChangedSignal, this);
64 
65  // init the dropped packet info
66  WATCH(macState);
67 
68  wakeup = new cMessage("wakeup", BMAC_WAKE_UP);
69 
70  data_timeout = new cMessage("data_timeout", BMAC_DATA_TIMEOUT);
71  data_timeout->setSchedulingPriority(100);
72 
73  data_tx_over = new cMessage("data_tx_over", BMAC_DATA_TX_OVER);
74 
75  stop_preambles = new cMessage("stop_preambles", BMAC_STOP_PREAMBLES);
76 
77  send_preamble = new cMessage("send_preamble", BMAC_SEND_PREAMBLE);
78 
79  ack_tx_over = new cMessage("ack_tx_over", BMAC_ACK_TX_OVER);
80 
81  cca_timeout = new cMessage("cca_timeout", BMAC_CCA_TIMEOUT);
82  cca_timeout->setSchedulingPriority(100);
83 
84  send_ack = new cMessage("send_ack", BMAC_SEND_ACK);
85 
86  start_bmac = new cMessage("start_bmac", BMAC_START_BMAC);
87 
88  ack_timeout = new cMessage("ack_timeout", BMAC_ACK_TIMEOUT);
89 
90  resend_data = new cMessage("resend_data", BMAC_RESEND_DATA);
91  resend_data->setSchedulingPriority(100);
92 
93  scheduleAfter(SIMTIME_ZERO, start_bmac);
94  }
95 }

◆ numInitStages()

virtual int inet::BMac::numInitStages ( ) const
inlineoverridevirtual

Initialization of the module and some variables.

65 { return NUM_INIT_STAGES; }

◆ operator=()

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

Assignment operator is not allowed.

◆ receiveSignal()

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

Handle control messages from lower layer.

529 {
530  Enter_Method("%s", cComponent::getSignalName(signalID));
531 
532  if (signalID == IRadio::radioModeChangedSignal) {
533  IRadio::RadioMode radioMode = static_cast<IRadio::RadioMode>(value);
534  if (radioMode == IRadio::RADIO_MODE_TRANSMITTER) {
535  // we just switched to TX after CCA, so simply send the first
536  // sendPremable self message
537  if (macState == SEND_PREAMBLE)
538  scheduleAfter(SIMTIME_ZERO, send_preamble);
539  else if (macState == SEND_ACK)
540  scheduleAfter(SIMTIME_ZERO, send_ack);
541  // we were waiting for acks, but none came. we switched to TX and now
542  // need to resend data
543  else if (macState == SEND_DATA)
544  scheduleAfter(SIMTIME_ZERO, resend_data);
545  }
546  }
547  // Transmission of one packet is over
548  else if (signalID == IRadio::transmissionStateChangedSignal) {
549  IRadio::TransmissionState newRadioTransmissionState = static_cast<IRadio::TransmissionState>(value);
552  scheduleAfter(SIMTIME_ZERO, data_tx_over);
553  else if (macState == WAIT_ACK_TX)
554  scheduleAfter(SIMTIME_ZERO, ack_tx_over);
555  }
556  transmissionState = newRadioTransmissionState;
557  }
558 }

◆ refreshDisplay()

void inet::BMac::refreshDisplay ( ) const
overridevirtual

Change the color of the node for animation purposes.

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

◆ scheduleWakeUp()

void inet::BMac::scheduleWakeUp ( )
protected
684 {
685  // if something in the queue, wakeup soon.
686  if (!txQueue->isEmpty())
687  scheduleAfter(dblrand() * checkInterval, wakeup);
688  else
689  scheduleAfter(slotDuration, wakeup);
690 }

◆ sendDataPacket()

void inet::BMac::sendDataPacket ( )
protected

Internal function to send the first packet in the queue.

517 {
518  nbTxDataPackets++;
519 
520  Packet *pkt = currentTxFrame->dup();
521  attachSignal(pkt);
522  const auto& hdr = pkt->peekAtFront<BMacDataFrameHeader>();
523  lastDataPktDestAddr = hdr->getDestAddr();
524  ASSERT(hdr->getType() == BMAC_DATA);
525  sendDown(pkt);
526 }

◆ sendMacAck()

void inet::BMac::sendMacAck ( )
protected

Internal function to send an ACK.

Send one short preamble packet immediately.

178 {
179  auto ack = makeShared<BMacControlFrame>();
180  ack->setSrcAddr(networkInterface->getMacAddress());
181  ack->setDestAddr(lastDataPktSrcAddr);
182  ack->setChunkLength(ctrlFrameLength);
183 
184  // attach signal and send down
185  auto packet = new Packet("BMacAck");
186  ack->setType(BMAC_ACK);
187  packet->insertAtFront(ack);
188  packet->addTag<PacketProtocolTag>()->setProtocol(&Protocol::bmac);
189  attachSignal(packet);
190  sendDown(packet);
191  nbTxAcks++;
192 // endSimulation();
193 }

◆ sendPreamble()

void inet::BMac::sendPreamble ( )
protected

Internal function to send one preamble.

Send one short preamble packet immediately.

158 {
159  auto preamble = makeShared<BMacControlFrame>();
160  preamble->setSrcAddr(networkInterface->getMacAddress());
161  preamble->setDestAddr(MacAddress::BROADCAST_ADDRESS);
162  preamble->setChunkLength(ctrlFrameLength);
163 
164  // attach signal and send down
165  auto packet = new Packet("Preamble");
166  preamble->setType(BMAC_PREAMBLE);
167  packet->insertAtFront(preamble);
168  packet->addTag<PacketProtocolTag>()->setProtocol(&Protocol::bmac);
169  attachSignal(packet);
170  sendDown(packet);
171  nbTxPreambles++;
172 }

Member Data Documentation

◆ ack_timeout

cMessage* inet::BMac::ack_timeout = nullptr
protected

◆ ack_tx_over

cMessage* inet::BMac::ack_tx_over = nullptr
protected

◆ animation

bool inet::BMac::animation = false
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::BMac::bitrate = 0
protected

The bitrate of transmission.

◆ cca_timeout

cMessage* inet::BMac::cca_timeout = nullptr
protected

◆ checkInterval

double inet::BMac::checkInterval = 0
protected

The duration of CCA.

◆ ctrlFrameLength

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

◆ data_timeout

cMessage* inet::BMac::data_timeout = nullptr
protected

◆ data_tx_over

cMessage* inet::BMac::data_tx_over = nullptr
protected

◆ headerLength

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

Length of the header.

◆ lastDataPktDestAddr

MacAddress inet::BMac::lastDataPktDestAddr
protected

◆ lastDataPktSrcAddr

MacAddress inet::BMac::lastDataPktSrcAddr
protected

◆ macState

States inet::BMac::macState = static_cast<States>(-1)
protected

The current state of the protocol.

◆ maxTxAttempts

int inet::BMac::maxTxAttempts = 0
protected

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

◆ nbDroppedDataPackets

long inet::BMac::nbDroppedDataPackets = 0
protected

◆ nbMissedAcks

long inet::BMac::nbMissedAcks = 0
protected

◆ nbRecvdAcks

long inet::BMac::nbRecvdAcks = 0
protected

◆ nbRxDataPackets

long inet::BMac::nbRxDataPackets = 0
protected

◆ nbRxPreambles

long inet::BMac::nbRxPreambles = 0
protected

◆ nbTxAcks

long inet::BMac::nbTxAcks = 0
protected

◆ nbTxDataPackets

long inet::BMac::nbTxDataPackets = 0
protected

◆ nbTxPreambles

long inet::BMac::nbTxPreambles = 0
protected

◆ radio

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

The radio.

◆ resend_data

cMessage* inet::BMac::resend_data = nullptr
protected

◆ send_ack

cMessage* inet::BMac::send_ack = nullptr
protected

◆ send_preamble

cMessage* inet::BMac::send_preamble = nullptr
protected

◆ slotDuration

double inet::BMac::slotDuration = 0
protected

The duration of the slot in secs.

◆ start_bmac

cMessage* inet::BMac::start_bmac = nullptr
protected

◆ stats

bool inet::BMac::stats = false
protected

Gather stats at the end of the simulation.

◆ stop_preambles

cMessage* inet::BMac::stop_preambles = nullptr
protected

◆ transmissionState

◆ txAttempts

int inet::BMac::txAttempts = 0
protected

◆ useMacAcks

bool inet::BMac::useMacAcks = false
protected

Use MAC level acks or not.

◆ wakeup

cMessage* inet::BMac::wakeup = nullptr
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::BMac::WAIT_ACK_TX
@ WAIT_ACK_TX
Definition: BMac.h:138
inet::BMAC_CCA_TIMEOUT
@ BMAC_CCA_TIMEOUT
Definition: BMacHeader_m.h:83
inet::BMac::SLEEP
@ SLEEP
Definition: BMac.h:130
inet::BMac::nbTxAcks
long nbTxAcks
Definition: BMac.h:105
inet::MacProtocolBase::sendUp
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
inet::BMAC_WAKE_UP
@ BMAC_WAKE_UP
Definition: BMacHeader_m.h:81
inet::MacAddress::isBroadcast
bool isBroadcast() const
Returns true if this is the broadcast address (hex ff:ff:ff:ff:ff:ff).
Definition: MacAddress.h:121
inet::linkBrokenSignal
simsignal_t linkBrokenSignal
Definition: Simsignals.cc:22
inet::BMac::stop_preambles
cMessage * stop_preambles
Definition: BMac.h:152
inet::BMac::nbRxDataPackets
long nbRxDataPackets
Definition: BMac.h:100
inet::BMAC_DATA
@ BMAC_DATA
Definition: BMacHeader_m.h:76
inet::INCORRECTLY_RECEIVED
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
inet::BMac::ack_timeout
cMessage * ack_timeout
Definition: BMac.h:145
inet::BMac::animation
bool animation
Animate (colorize) the nodes.
Definition: BMac.h:170
inet::BMac::sendDataPacket
void sendDataPacket()
Internal function to send the first packet in the queue.
Definition: BMac.cc:516
inet::Protocol::bmac
static const Protocol bmac
Definition: Protocol.h:56
inet::BMac::data_timeout
cMessage * data_timeout
Definition: BMac.h:154
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::BMac::SEND_PREAMBLE
@ SEND_PREAMBLE
Definition: BMac.h:132
inet::BMac::INIT
@ INIT
Definition: BMac.h:129
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::MacProtocolBase::dropCurrentTxFrame
virtual void dropCurrentTxFrame(PacketDropDetails &details)
Definition: MacProtocolBase.cc:99
inet::BMac::lastDataPktSrcAddr
MacAddress lastDataPktSrcAddr
Definition: BMac.h:158
inet::BMAC_PREAMBLE
@ BMAC_PREAMBLE
Definition: BMacHeader_m.h:75
inet::BMac::ack_tx_over
cMessage * ack_tx_over
Definition: BMac.h:150
inet::BMac::sendPreamble
void sendPreamble()
Internal function to send one preamble.
Definition: BMac.cc:157
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::BMac::txAttempts
int txAttempts
Definition: BMac.h:160
inet::BMac::SEND_DATA
@ SEND_DATA
Definition: BMac.h:134
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::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::BMac::checkInterval
double checkInterval
The duration of CCA.
Definition: BMac.h:179
inet::BMac::handleSelfMessage
virtual void handleSelfMessage(cMessage *) override
Handle self messages such as timers.
Definition: BMac.cc:207
inet::BMac::WAIT_DATA
@ WAIT_DATA
Definition: BMac.h:133
inet::BMac::wakeup
cMessage * wakeup
Definition: BMac.h:147
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::BMac::radio
ModuleRefByPar< physicallayer::IRadio > radio
The radio.
Definition: BMac.h:93
inet::BMac::headerLength
b headerLength
Length of the header.
Definition: BMac.h:174
inet::BMac::lastDataPktDestAddr
MacAddress lastDataPktDestAddr
Definition: BMac.h:159
inet::BMAC_START_BMAC
@ BMAC_START_BMAC
Definition: BMacHeader_m.h:80
inet::MacProtocolBase::currentTxFrame
Packet * currentTxFrame
Currently transmitted frame if any.
Definition: MacProtocolBase.h:35
inet::BMac::nbRxPreambles
long nbRxPreambles
Definition: BMac.h:101
inet::BMac::bitrate
double bitrate
The bitrate of transmission.
Definition: BMac.h:177
inet::MacProtocolBase::sendDown
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
inet::BMac::transmissionState
physicallayer::IRadio::TransmissionState transmissionState
Definition: BMac.h:94
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::BMAC_STOP_PREAMBLES
@ BMAC_STOP_PREAMBLES
Definition: BMacHeader_m.h:86
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::BMac::send_ack
cMessage * send_ack
Definition: BMac.h:148
inet::BMac::start_bmac
cMessage * start_bmac
Definition: BMac.h:146
inet::BMAC_ACK_TIMEOUT
@ BMAC_ACK_TIMEOUT
Definition: BMacHeader_m.h:79
inet::OTHER_PACKET_DROP
@ OTHER_PACKET_DROP
Definition: Simsignals_m.h:84
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::BMac::nbMissedAcks
long nbMissedAcks
Definition: BMac.h:102
inet::BMac::nbTxDataPackets
long nbTxDataPackets
Definition: BMac.h:98
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::BMac::slotDuration
double slotDuration
The duration of the slot in secs.
Definition: BMac.h:172
inet::BMAC_ACK_TX_OVER
@ BMAC_ACK_TX_OVER
Definition: BMacHeader_m.h:84
inet::BMac::cca_timeout
cMessage * cca_timeout
Definition: BMac.h:149
inet::BMac::WAIT_ACK
@ WAIT_ACK
Definition: BMac.h:136
inet::BMac::SEND_ACK
@ SEND_ACK
Definition: BMac.h:137
inet::MacProtocolBase::deleteCurrentTxFrame
virtual void deleteCurrentTxFrame()
Definition: MacProtocolBase.cc:93
inet::MacProtocolBase::initialize
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
inet::BMac::resend_data
cMessage * resend_data
Definition: BMac.h:144
inet::BMac::macState
States macState
The current state of the protocol.
Definition: BMac.h:141
inet::BMac::WAIT_TX_DATA_OVER
@ WAIT_TX_DATA_OVER
Definition: BMac.h:135
inet::BMAC_DATA_TX_OVER
@ BMAC_DATA_TX_OVER
Definition: BMacHeader_m.h:87
inet::BMAC_SEND_ACK
@ BMAC_SEND_ACK
Definition: BMacHeader_m.h:82
inet::BMac::sendMacAck
void sendMacAck()
Internal function to send an ACK.
Definition: BMac.cc:177
inet::MacProtocolBase::getQueue
queueing::IPacketQueue * getQueue(cGate *gate) const
Definition: MacProtocolBase.cc:157
inet::BMac::ctrlFrameLength
b ctrlFrameLength
Definition: BMac.h:175
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::BMac::attachSignal
void attachSignal(Packet *macPkt)
Internal function to attach a signal to the packet.
Definition: BMac.cc:560
inet::physicallayer::IRadio::TransmissionState
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
inet::BMac::send_preamble
cMessage * send_preamble
Definition: BMac.h:151
inet::MacProtocolBase::dequeuePacket
virtual Packet * dequeuePacket()
Definition: MacProtocolBase.cc:175
inet::BMac::scheduleWakeUp
void scheduleWakeUp()
Definition: BMac.cc:683
inet::BMac::nbTxPreambles
long nbTxPreambles
Definition: BMac.h:99
inet::MacAddress::BROADCAST_ADDRESS
static const MacAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MacAddress.h:34
inet::physicallayer::IRadio::RadioMode
RadioMode
This enumeration specifies the requested operational mode of the radio.
Definition: IRadio.h:79
inet::BMAC_ACK
@ BMAC_ACK
Definition: BMacHeader_m.h:77
inet::MacProtocolBase::parseMacAddressParameter
virtual MacAddress parseMacAddressParameter(const char *addrstr)
Definition: MacProtocolBase.cc:24
inet::BMAC_DATA_TIMEOUT
@ BMAC_DATA_TIMEOUT
Definition: BMacHeader_m.h:88
inet::BMAC_SEND_PREAMBLE
@ BMAC_SEND_PREAMBLE
Definition: BMacHeader_m.h:85
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::BMac::decapsulate
void decapsulate(Packet *packet)
Definition: BMac.cc:646
inet::BMac::maxTxAttempts
int maxTxAttempts
Maximum transmission attempts per data packet, when ACKs are used.
Definition: BMac.h:184
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::BMac::useMacAcks
bool useMacAcks
Use MAC level acks or not.
Definition: BMac.h:181
inet::BMac::encapsulate
void encapsulate(Packet *packet)
Definition: BMac.cc:658
inet::MacProtocolBase::canDequeuePacket
virtual bool canDequeuePacket() const
Definition: MacProtocolBase.cc:170
inet::NOT_ADDRESSED_TO_US
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
inet::BMac::data_tx_over
cMessage * data_tx_over
Definition: BMac.h:153
inet::BMac::nbDroppedDataPackets
long nbDroppedDataPackets
Definition: BMac.h:104
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::BMac::CCA
@ CCA
Definition: BMac.h:131
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::BMAC_RESEND_DATA
@ BMAC_RESEND_DATA
Definition: BMacHeader_m.h:78
inet::BMac::nbRecvdAcks
long nbRecvdAcks
Definition: BMac.h:103