INET Framework for OMNeT++/OMNEST
inet::ieee80211::Tx Class Reference

The default implementation of ITx. More...

#include <Tx.h>

Inheritance diagram for inet::ieee80211::Tx:
inet::ieee80211::ITx

Public Member Functions

 Tx ()
 
 ~Tx ()
 
virtual void transmitFrame (Ieee80211Frame *frame, ITx::ICallback *txCallback) override
 
virtual void transmitFrame (Ieee80211Frame *frame, simtime_t ifs, ITx::ICallback *txCallback) override
 
virtual void radioTransmissionFinished () override
 
- Public Member Functions inherited from inet::ieee80211::ITx
virtual ~ITx ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void refreshDisplay () const override
 

Protected Attributes

MACAddress address = MACAddress::UNSPECIFIED_ADDRESS
 
ITx::ICallbacktxCallback = nullptr
 
Ieee80211Macmac = nullptr
 
IRxrx = nullptr
 
IStatisticsstatistics = nullptr
 
Ieee80211Frameframe = nullptr
 
cMessage * endIfsTimer = nullptr
 
simtime_t durationField = -1
 
bool transmitting = false
 

Detailed Description

The default implementation of ITx.

Constructor & Destructor Documentation

inet::ieee80211::Tx::Tx ( )
inline
53 {}
inet::ieee80211::Tx::~Tx ( )
32 {
33  cancelAndDelete(endIfsTimer);
34  if (frame && !transmitting)
35  delete frame;
36 }
bool transmitting
Definition: Tx.h:44
Ieee80211Frame * frame
Definition: Tx.h:41
cMessage * endIfsTimer
Definition: Tx.h:42

Member Function Documentation

void inet::ieee80211::Tx::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
93 {
94  if (msg == endIfsTimer) {
95  EV_DETAIL << "Tx: endIfsTimer expired\n";
96  transmitting = true;
99  if (hasGUI())
100  refreshDisplay();
101  }
102  else
103  ASSERT(false);
104 }
Ieee80211Mac * mac
Definition: Tx.h:38
simtime_t durationField
Definition: Tx.h:43
virtual ::omnetpp::simtime_t getDuration() const
bool transmitting
Definition: Tx.h:44
virtual void refreshDisplay() const override
Definition: Tx.cc:106
Ieee80211Frame * frame
Definition: Tx.h:41
cMessage * endIfsTimer
Definition: Tx.h:42
virtual void sendFrame(Ieee80211Frame *frameToSend)
Definition: Ieee80211Mac.cc:215
void inet::ieee80211::Tx::initialize ( int  stage)
overrideprotectedvirtual
39 {
40  if (stage == INITSTAGE_LOCAL) {
41  mac = check_and_cast<Ieee80211Mac *>(getContainingNicModule(this)->getSubmodule("mac"));
42  endIfsTimer = new cMessage("endIFS");
43  rx = dynamic_cast<IRx *>(getModuleByPath(par("rxModule")));
44  // statistics = check_and_cast<IStatistics*>(getModuleByPath(par("statisticsModule")));
45  WATCH(transmitting);
46  }
47  if (stage == INITSTAGE_LINK_LAYER) {
48  address = mac->getAddress();
50  }
51 }
virtual const MACAddress & getAddress() const
Definition: Ieee80211Mac.h:102
Ieee80211Mac * mac
Definition: Tx.h:38
Abstract interface for Rx processes.
Definition: IRx.h:45
MACAddress address
Definition: Tx.h:36
Implements the IEEE 802.11 MAC.
Definition: Ieee80211Mac.h:47
Local initializations.
Definition: InitStages.h:35
Initialization of link-layer protocols.
Definition: InitStages.h:59
cModule * getContainingNicModule(cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: ModuleAccess.cc:96
bool transmitting
Definition: Tx.h:44
virtual void refreshDisplay() const override
Definition: Tx.cc:106
cMessage * endIfsTimer
Definition: Tx.h:42
IRx * rx
Definition: Tx.h:39
virtual int inet::ieee80211::Tx::numInitStages ( ) const
inlineoverrideprotectedvirtual
47 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::ieee80211::Tx::radioTransmissionFinished ( )
overridevirtual

Implements inet::ieee80211::ITx.

75 {
76  Enter_Method_Silent();
77  if (transmitting) {
78  EV_DETAIL << "Tx: radioTransmissionFinished()\n";
79  transmitting = false;
80  auto transmittedFrame = inet::utils::dupPacketAndControlInfo(frame);
81  frame = nullptr;
82  ASSERT(txCallback != nullptr);
83  ITx::ICallback *tmpTxCallback = txCallback;
84  txCallback = nullptr;
85  tmpTxCallback->transmissionComplete(transmittedFrame);
87  if (hasGUI())
89  }
90 }
ITx::ICallback * txCallback
Definition: Tx.h:37
simtime_t durationField
Definition: Tx.h:43
bool transmitting
Definition: Tx.h:44
virtual void refreshDisplay() const override
Definition: Tx.cc:106
Ieee80211Frame * frame
Definition: Tx.h:41
virtual void transmissionComplete(Ieee80211Frame *frame)=0
IRx * rx
Definition: Tx.h:39
virtual void frameTransmitted(simtime_t durationField)=0
T * dupPacketAndControlInfo(T *packet)
Duplicate a packet together with its control info.
Definition: INETUtils.h:86
void inet::ieee80211::Tx::refreshDisplay ( ) const
overrideprotectedvirtual

Referenced by handleMessage(), initialize(), radioTransmissionFinished(), and transmitFrame().

107 {
108  const char *stateName = endIfsTimer->isScheduled() ? "WAIT_IFS" : transmitting ? "TRANSMIT" : "IDLE";
109  // faster version is just to display the state: getDisplayString().setTagArg("t", 0, stateName);
110  std::stringstream os;
111  if (frame)
112  os << frame->getName() << "\n";
113  os << stateName;
114  getDisplayString().setTagArg("t", 0, os.str().c_str());
115 }
bool transmitting
Definition: Tx.h:44
Ieee80211Frame * frame
Definition: Tx.h:41
cMessage * endIfsTimer
Definition: Tx.h:42
void inet::ieee80211::Tx::transmitFrame ( Ieee80211Frame frame,
ITx::ICallback txCallback 
)
overridevirtual

Implements inet::ieee80211::ITx.

54 {
55  transmitFrame(frame, SIMTIME_ZERO, txCallback);
56 }
virtual void transmitFrame(Ieee80211Frame *frame, ITx::ICallback *txCallback) override
Definition: Tx.cc:53
void inet::ieee80211::Tx::transmitFrame ( Ieee80211Frame frame,
simtime_t  ifs,
ITx::ICallback txCallback 
)
overridevirtual

Implements inet::ieee80211::ITx.

59 {
60  ASSERT(this->txCallback == nullptr);
61  this->txCallback = txCallback;
62  Enter_Method("transmitFrame(\"%s\")", frame->getName());
63  take(frame);
64  auto frameToTransmit = inet::utils::dupPacketAndControlInfo(frame);
65  this->frame = frameToTransmit;
66  if (auto twoAddrFrame = dynamic_cast<Ieee80211TwoAddressFrame*>(frameToTransmit))
67  twoAddrFrame->setTransmitterAddress(address);
68  ASSERT(!endIfsTimer->isScheduled() && !transmitting); // we are idle
69  scheduleAt(simTime() + ifs, endIfsTimer);
70  if (hasGUI())
72 }
ITx::ICallback * txCallback
Definition: Tx.h:37
MACAddress address
Definition: Tx.h:36
bool transmitting
Definition: Tx.h:44
virtual void refreshDisplay() const override
Definition: Tx.cc:106
cMessage * endIfsTimer
Definition: Tx.h:42
T * dupPacketAndControlInfo(T *packet)
Duplicate a packet together with its control info.
Definition: INETUtils.h:86

Member Data Documentation

MACAddress inet::ieee80211::Tx::address = MACAddress::UNSPECIFIED_ADDRESS
protected

Referenced by initialize(), and transmitFrame().

simtime_t inet::ieee80211::Tx::durationField = -1
protected
cMessage* inet::ieee80211::Tx::endIfsTimer = nullptr
protected
Ieee80211Frame* inet::ieee80211::Tx::frame = nullptr
protected
Ieee80211Mac* inet::ieee80211::Tx::mac = nullptr
protected

Referenced by handleMessage(), and initialize().

IRx* inet::ieee80211::Tx::rx = nullptr
protected
IStatistics* inet::ieee80211::Tx::statistics = nullptr
protected
bool inet::ieee80211::Tx::transmitting = false
protected
ITx::ICallback* inet::ieee80211::Tx::txCallback = nullptr
protected

The documentation for this class was generated from the following files: