|
INET Framework for OMNeT++/OMNEST
|
Implements a simplified ideal MAC.
More...
#include <AckingMac.h>
Implements a simplified ideal MAC.
See the NED file for details.
◆ AckingMac()
| inet::AckingMac::AckingMac |
( |
| ) |
|
◆ ~AckingMac()
| inet::AckingMac::~AckingMac |
( |
| ) |
|
|
virtual |
◆ acked()
| void inet::AckingMac::acked |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
183 throw cRuntimeError(
"Unexpected ACK received");
185 EV_DEBUG <<
"AckingMac::acked(" << frame->getFullName() <<
") is accepted\n";
Referenced by handleLowerPacket().
◆ configureNetworkInterface()
| void inet::AckingMac::configureNetworkInterface |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ decapsulate()
| void inet::AckingMac::decapsulate |
( |
Packet * |
frame | ) |
|
|
protectedvirtual |
241 const auto& macHeader = packet->popAtFront<AckingMacHeader>();
242 auto macAddressInd = packet->addTagIfAbsent<MacAddressInd>();
243 macAddressInd->setSrcAddress(macHeader->getSrc());
244 macAddressInd->setDestAddress(macHeader->getDest());
245 packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(
networkInterface->getInterfaceId());
◆ dropFrameNotForUs()
| bool inet::AckingMac::dropFrameNotForUs |
( |
Packet * |
frame | ) |
|
|
protectedvirtual |
214 auto macHeader = packet->peekAtFront<AckingMacHeader>();
225 if (macHeader->getDest().isBroadcast())
228 if (
promiscuous || macHeader->getDest().isMulticast())
231 EV <<
"Frame '" << packet->getName() <<
"' not destined to us, discarding\n";
232 PacketDropDetails details;
◆ encapsulate()
| void inet::AckingMac::encapsulate |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
194 auto macHeader = makeShared<AckingMacHeader>();
196 auto macAddressReq = packet->getTag<MacAddressReq>();
197 macHeader->setSrc(macAddressReq->getSrcAddress());
198 macHeader->setDest(macAddressReq->getDestAddress());
199 MacAddress dest = macAddressReq->getDestAddress();
200 if (dest.isBroadcast() || dest.isMulticast() || dest.isUnspecified())
201 macHeader->setSrcModuleId(-1);
203 macHeader->setSrcModuleId(getId());
205 packet->insertAtFront(macHeader);
206 auto macAddressInd = packet->addTagIfAbsent<MacAddressInd>();
207 macAddressInd->setSrcAddress(macHeader->getSrc());
208 macAddressInd->setDestAddress(macHeader->getDest());
◆ getProvider()
Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface.
The gate parameter must be a valid gate of this module.
Implements inet::queueing::IActivePacketSink.
◆ handleCanPullPacketChanged()
| void inet::AckingMac::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.
◆ handleCrashOperation()
◆ handleLowerPacket()
| void inet::AckingMac::handleLowerPacket |
( |
Packet * |
packet | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::LayeredProtocolBase.
132 auto macHeader = packet->peekAtFront<AckingMacHeader>();
133 if (packet->hasBitError()) {
134 EV <<
"Received frame '" << packet->getName() <<
"' contains bit errors or collision, dropping it\n";
135 PacketDropDetails details;
144 auto dest = macHeader->getDest();
145 bool needsAck = !(dest.isBroadcast() || dest.isMulticast() || dest.isUnspecified());
147 int senderModuleId = macHeader->getSrcModuleId();
148 AckingMac *senderMac = check_and_cast<AckingMac *>(getSimulation()->getModule(senderModuleId));
149 if (senderMac->useAck)
150 senderMac->acked(packet);
155 EV <<
"Passing up contained packet '" << packet->getName() <<
"' to higher layer\n";
◆ handlePullPacketProcessed()
| void inet::AckingMac::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.
269 throw cRuntimeError(
"Not supported callback");
◆ handleSelfMessage()
| void inet::AckingMac::handleSelfMessage |
( |
cMessage * |
message | ) |
|
|
overrideprotectedvirtual |
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleUpperPacket()
| void inet::AckingMac::handleUpperPacket |
( |
Packet * |
packet | ) |
|
|
overrideprotectedvirtual |
implements MacProtocolBase functions
Reimplemented from inet::LayeredProtocolBase.
123 EV <<
"Received " << packet <<
" for transmission\n";
125 throw cRuntimeError(
"AckingMac already in transmit state when packet arrived from upper layer");
◆ initialize()
| void inet::AckingMac::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::MacProtocolBase.
49 cModule *radioModule = gate(
"lowerLayerOut")->getPathEndGate()->getOwnerModule();
51 radio = check_and_cast<IRadio *>(radioModule);
◆ numInitStages()
| virtual int inet::AckingMac::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ processUpperPacket()
| void inet::AckingMac::processUpperPacket |
( |
| ) |
|
|
protectedvirtual |
◆ receiveSignal()
| void inet::AckingMac::receiveSignal |
( |
cComponent * |
src, |
|
|
simsignal_t |
id, |
|
|
intval_t |
value, |
|
|
cObject * |
details |
|
) |
| |
|
overrideprotectedvirtual |
◆ startTransmitting()
| void inet::AckingMac::startTransmitting |
( |
| ) |
|
|
protectedvirtual |
106 if (
useAck && !dest.isBroadcast() && !dest.isMulticast() && !dest.isUnspecified()) {
116 EV <<
"Starting transmission of " << msg << endl;
◆ ackTimeout
| simtime_t inet::AckingMac::ackTimeout |
|
protected |
◆ ackTimeoutMsg
| cMessage* inet::AckingMac::ackTimeoutMsg = nullptr |
|
protected |
◆ bitrate
| double inet::AckingMac::bitrate = 0 |
|
protected |
◆ fullDuplex
| bool inet::AckingMac::fullDuplex = false |
|
protected |
◆ headerLength
| int inet::AckingMac::headerLength = 0 |
|
protected |
◆ promiscuous
| bool inet::AckingMac::promiscuous = false |
|
protected |
◆ radio
◆ transmissionState
◆ useAck
| bool inet::AckingMac::useAck = true |
|
protected |
The documentation for this class was generated from the following files:
opp_component_ptr< NetworkInterface > networkInterface
Definition: MacProtocolBase.h:30
simtime_t ackTimeout
Definition: AckingMac.h:38
virtual void setRadioMode(RadioMode radioMode)=0
Changes the current radio mode.
virtual void handleCrashOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:142
double bitrate
Definition: AckingMac.h:30
@ RADIO_MODE_TRANSCEIVER
The radio is prepared for simultaneous frame reception and transmission, power consumption is low whe...
Definition: IRadio.h:111
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
int headerLength
Definition: AckingMac.h:29
simsignal_t linkBrokenSignal
Definition: Simsignals.cc:22
virtual void startTransmitting()
Definition: AckingMac.cc:101
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
virtual void handleUpperPacket(Packet *packet) override
implements MacProtocolBase functions
Definition: AckingMac.cc:121
virtual void encapsulate(Packet *msg)
Definition: AckingMac.cc:192
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
virtual void dropCurrentTxFrame(PacketDropDetails &details)
Definition: MacProtocolBase.cc:99
virtual void decapsulate(Packet *frame)
Definition: AckingMac.cc:239
static simsignal_t transmissionStateChangedSignal
This signal is emitted when the radio transmission state of the radio is changed.
Definition: IRadio.h:60
virtual void handleStopOperation(LifecycleOperation *operation) override
Definition: MacProtocolBase.cc:130
@ RADIO_MODE_TRANSMITTER
The radio is prepared for frame transmission, frame reception is not possible, power consumption is l...
Definition: IRadio.h:104
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
virtual TransmissionState getTransmissionState() const =0
Returns the current radio transmission state.
virtual bool dropFrameNotForUs(Packet *frame)
Definition: AckingMac.cc:212
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
intscale< b, 1, 8 > B
Definition: Units.h:1168
virtual Packet * dup() const override
Definition: Packet.h:171
@ RADIO_MODE_RECEIVER
The radio is prepared for frame reception, frame transmission is not possible, power consumption is l...
Definition: IRadio.h:97
virtual void handleSelfMessage(cMessage *message)
Definition: LayeredProtocolBase.cc:46
Packet * currentTxFrame
Currently transmitted frame if any.
Definition: MacProtocolBase.h:35
bool fullDuplex
Definition: AckingMac.h:32
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
int upperLayerInGateId
Gate ids.
Definition: MacProtocolBase.h:24
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
@ TRANSMISSION_STATE_TRANSMITTING
The radio medium is busy, the radio is currently transmitting a signal.
Definition: IRadio.h:171
@ OTHER_PACKET_DROP
Definition: Simsignals_m.h:84
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
physicallayer::IRadio::TransmissionState transmissionState
Definition: AckingMac.h:36
virtual void deleteCurrentTxFrame()
Definition: MacProtocolBase.cc:93
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
static const Protocol ackingMac
Definition: Protocol.h:122
queueing::IPacketQueue * getQueue(cGate *gate) const
Definition: MacProtocolBase.cc:157
#define Enter_Method(...)
Definition: SelfDoc.h:71
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
bool promiscuous
Definition: AckingMac.h:31
virtual Packet * dequeuePacket()
Definition: MacProtocolBase.cc:175
const Ptr< const TagBase > getTag(int index) const
Returns the packet tag at the given index.
Definition: Packet.h:1261
virtual const char * getFullName() const override
Returns the full name of the packet.
Definition: Packet.cc:290
virtual MacAddress parseMacAddressParameter(const char *addrstr)
Definition: MacProtocolBase.cc:24
AckingMac()
Definition: AckingMac.cc:29
const Protocol * getProtocol(int protocolNumber) const
Definition: ProtocolGroup.cc:31
opp_component_ptr< queueing::IPacketQueue > txQueue
Messages received from upper layer and to be transmitted later.
Definition: MacProtocolBase.h:38
@ TRANSMISSION_STATE_UNDEFINED
The transmission state is undefined or meaningless.
Definition: IRadio.h:160
virtual void processUpperPacket()
Definition: AckingMac.cc:272
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
virtual bool canDequeuePacket() const
Definition: MacProtocolBase.cc:170
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
cMessage * ackTimeoutMsg
Definition: AckingMac.h:39
physicallayer::IRadio * radio
Definition: AckingMac.h:35
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
bool useAck
Definition: AckingMac.h:33
static ProtocolGroup ethertype
Definition: ProtocolGroup.h:40