A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
frame-exchange-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef FRAME_EXCHANGE_MANAGER_H
10#define FRAME_EXCHANGE_MANAGER_H
11
12#include "mac-rx-middle.h"
13#include "mac-tx-middle.h"
14#include "qos-txop.h"
15#include "wifi-mac.h"
16#include "wifi-phy.h"
17#include "wifi-psdu.h"
18#include "wifi-tx-parameters.h"
19#include "wifi-tx-timer.h"
20#include "wifi-tx-vector.h"
21
22// Needed to compile wave bindings
24#include "wifi-ack-manager.h"
26
27#include "ns3/object.h"
28
29#include <functional>
30#include <optional>
31
32#define WIFI_FEM_NS_LOG_APPEND_CONTEXT \
33 std::clog << "[link=" << +m_linkId << "][mac=" << m_self << "] "
34
35namespace ns3
36{
37
38struct RxSignalInfo;
39struct WifiProtection;
40struct WifiAcknowledgment;
41
42/**
43 * \ingroup wifi
44 *
45 * FrameExchangeManager is a base class handling the basic frame exchange
46 * sequences for non-QoS stations.
47 *
48 * The fragmentation policy implemented uses a simple fragmentation
49 * threshold: any packet bigger than this threshold is fragmented
50 * in fragments whose size is smaller than the threshold.
51 *
52 * The retransmission policy is also very simple: every packet is
53 * retransmitted until it is either successfully transmitted or
54 * it has been retransmitted up until the SSRC or SLRC thresholds.
55 */
57{
58 public:
59 /**
60 * \brief Get the type ID.
61 * \return the object TypeId
62 */
63 static TypeId GetTypeId();
65 ~FrameExchangeManager() override;
66
67 /**
68 * typedef for a callback to invoke when an MPDU is dropped.
69 */
71 /**
72 * typedef for a callback to invoke when an MPDU is successfully acknowledged.
73 */
75
76 /**
77 * Request the FrameExchangeManager to start a frame exchange sequence.
78 *
79 * \param dcf the channel access function that gained channel access. It is
80 * the DCF on non-QoS stations and an EDCA on QoS stations.
81 * \param allowedWidth the allowed width for the frame exchange sequence
82 * \return true if a frame exchange sequence was started, false otherwise
83 */
84 virtual bool StartTransmission(Ptr<Txop> dcf, MHz_u allowedWidth);
85
86 /**
87 * This method is intended to be called by the PHY layer every time an MPDU
88 * is received and also when the reception of an A-MPDU is completed. In case
89 * the PSDU contains multiple MPDUs, the <i>perMpduStatus</i> vector is empty
90 * when receiving the individual MPDUs.
91 *
92 * \param psdu the received PSDU
93 * \param rxSignalInfo the info on the received signal (\see RxSignalInfo)
94 * \param txVector TxVector of the received PSDU
95 * \param perMpduStatus per MPDU reception status
96 */
98 RxSignalInfo rxSignalInfo,
99 WifiTxVector txVector,
100 std::vector<bool> perMpduStatus);
101
102 /**
103 * Information about the MPDU being received. The TXVECTOR is populated upon
104 * PHY-RXSTART indication; the MAC header is populated when notified by the PHY.
105 */
107 {
108 std::optional<WifiMacHeader> macHdr; //!< MAC header of the MPDU being received
109 WifiTxVector txVector; //!< TXVECTOR of the MPDU being received
110 Time endOfPsduRx; //!< time when reception of PSDU ends
111 };
112
113 /**
114 * \return the information about the MPDU being received by the PHY, if any. This information
115 * is available from the time the PHY-RXSTART.indication is received until the end
116 * of PSDU reception
117 */
118 std::optional<std::reference_wrapper<const OngoingRxInfo>> GetOngoingRxInfo() const;
119
120 /**
121 * \return the information about the MAC header of the MPDU being received by the PHY, if any.
122 * The MAC header is available from the time its reception is completed until the end
123 * of PSDU reception
124 */
125 std::optional<std::reference_wrapper<const WifiMacHeader>> GetReceivedMacHdr() const;
126
127 /**
128 * Set the ID of the link this Frame Exchange Manager is associated with.
129 *
130 * \param linkId the ID of the link this Frame Exchange Manager is associated with
131 */
132 virtual void SetLinkId(uint8_t linkId);
133 /**
134 * Set the MAC layer to use.
135 *
136 * \param mac the MAC layer to use
137 */
138 virtual void SetWifiMac(const Ptr<WifiMac> mac);
139 /**
140 * Set the MAC TX Middle to use.
141 *
142 * \param txMiddle the MAC TX Middle to use
143 */
144 virtual void SetMacTxMiddle(const Ptr<MacTxMiddle> txMiddle);
145 /**
146 * Set the MAC RX Middle to use.
147 *
148 * \param rxMiddle the MAC RX Middle to use
149 */
150 virtual void SetMacRxMiddle(const Ptr<MacRxMiddle> rxMiddle);
151 /**
152 * Set the channel access manager to use
153 *
154 * \param channelAccessManager the channel access manager to use
155 */
156 virtual void SetChannelAccessManager(const Ptr<ChannelAccessManager> channelAccessManager);
157 /**
158 * Set the PHY layer to use.
159 *
160 * \param phy the PHY layer to use
161 */
162 virtual void SetWifiPhy(const Ptr<WifiPhy> phy);
163 /**
164 * Remove WifiPhy associated with this FrameExchangeManager.
165 */
166 virtual void ResetPhy();
167 /**
168 * Set the Protection Manager to use
169 *
170 * \param protectionManager the Protection Manager to use
171 */
172 virtual void SetProtectionManager(Ptr<WifiProtectionManager> protectionManager);
173 /**
174 * Set the Acknowledgment Manager to use
175 *
176 * \param ackManager the Acknowledgment Manager to use
177 */
178 virtual void SetAckManager(Ptr<WifiAckManager> ackManager);
179 /**
180 * Set the MAC address.
181 *
182 * \param address the MAC address
183 */
184 virtual void SetAddress(Mac48Address address);
185 /**
186 * Get the MAC address.
187 *
188 * \return the MAC address
189 */
190 Mac48Address GetAddress() const;
191 /**
192 * Set the Basic Service Set Identification.
193 *
194 * \param bssid the BSSID
195 */
196 virtual void SetBssid(Mac48Address bssid);
197 /**
198 * Get the Basic Service Set Identification.
199 *
200 * \return the BSSID
201 */
202 Mac48Address GetBssid() const;
203 /**
204 * \return the width of the channel that the FEM is allowed to use for the current transmission
205 */
206 MHz_u GetAllowedWidth() const;
207 /**
208 * Set the callback to invoke when an MPDU is dropped.
209 *
210 * \param callback the callback to invoke when an MPDU is dropped
211 */
212 virtual void SetDroppedMpduCallback(DroppedMpdu callback);
213 /**
214 * Set the callback to invoke when an MPDU is successfully acked.
215 *
216 * \param callback the callback to invoke when an MPDU is successfully acked
217 */
218 void SetAckedMpduCallback(AckedMpdu callback);
219 /**
220 * Enable promiscuous mode.
221 */
222 void SetPromisc();
223 /**
224 * Check if the device is operating in promiscuous mode.
225 *
226 * \return true if the device is operating in promiscuous mode,
227 * false otherwise
228 */
229 bool IsPromisc() const;
230
231 /**
232 * Get a const reference to the WifiTxTimer object.
233 *
234 * \return a const reference to the WifiTxTimer object
235 */
236 const WifiTxTimer& GetWifiTxTimer() const;
237
238 /**
239 * Get the Protection Manager used by this node.
240 *
241 * \return the Protection Manager used by this node
242 */
244
245 /**
246 * Calculate the time required to protect a frame according to the given
247 * protection method. The protection time is stored in the protection
248 * object itself.
249 *
250 * \param protection the protection method
251 */
252 virtual void CalculateProtectionTime(WifiProtection* protection) const;
253
254 /**
255 * Get the Acknowledgment Manager used by this node.
256 *
257 * \return the Acknowledgment Manager used by this node
258 */
260
261 /**
262 * Calculate the time required to acknowledge a frame according to the given
263 * acknowledgment method. The acknowledgment time is stored in the acknowledgment
264 * object itself.
265 *
266 * \param acknowledgment the acknowledgment method
267 */
268 virtual void CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledgment) const;
269
270 /**
271 * \return true if the virtual CS indication is that the medium is idle
272 */
273 virtual bool VirtualCsMediumIdle() const;
274
275 /**
276 * \return the set of stations that have successfully received an RTS in this TXOP.
277 */
278 const std::set<Mac48Address>& GetProtectedStas() const;
279
280 /**
281 * Notify that an internal collision has occurred for the given Txop
282 *
283 * \param txop the Txop for which an internal collision has occurred
284 */
285 virtual void NotifyInternalCollision(Ptr<Txop> txop);
286
287 /**
288 * \param duration switching delay duration.
289 *
290 * This method is typically invoked by the PhyListener to notify
291 * the MAC layer that a channel switching occurred. When a channel switching
292 * occurs, pending MAC transmissions (RTS, CTS, Data and Ack) are cancelled.
293 */
294 virtual void NotifySwitchingStartNow(Time duration);
295
296 /**
297 * This method is typically invoked by the PhyListener to notify
298 * the MAC layer that the device has been put into sleep mode. When the device is put
299 * into sleep mode, pending MAC transmissions (RTS, CTS, Data and Ack) are cancelled.
300 */
301 void NotifySleepNow();
302
303 /**
304 * This method is typically invoked by the PhyListener to notify
305 * the MAC layer that the device has been put into off mode. When the device is put
306 * into off mode, pending MAC transmissions (RTS, CTS, Data and Ack) are cancelled.
307 */
308 void NotifyOffNow();
309
310 protected:
311 void DoDispose() override;
312
313 /**
314 * \return the remote station manager operating on our link
315 */
317
318 /**
319 * Fragment the given MPDU if needed. If fragmentation is needed, return the
320 * first fragment; otherwise, return the given MPDU. Note that, if fragmentation
321 * is applied, the given MPDU is dequeued from the MAC queue and the first
322 * fragment is enqueued in its place.
323 *
324 * \param mpdu the given MPDU
325 * \return the first fragment if fragmentation is needed, the given MPDU otherwise
326 */
328
329 /**
330 * Send an MPDU with the given TX parameters (with the specified protection).
331 * Note that <i>txParams</i> is moved to m_txParams and hence is left in an
332 * undefined state.
333 *
334 * \param mpdu the MPDU to send
335 * \param txParams the TX parameters to use to transmit the MPDU
336 */
338
339 /**
340 * Start the protection mechanism indicated by the given TX parameters
341 *
342 * \param txParams the TX parameters
343 */
344 virtual void StartProtection(const WifiTxParameters& txParams);
345
346 /**
347 * Transmit prepared frame upon successful protection mechanism.
348 */
349 virtual void ProtectionCompleted();
350
351 /**
352 * Update the NAV, if needed, based on the Duration/ID of the given <i>psdu</i>.
353 *
354 * \param psdu the received PSDU
355 * \param txVector TxVector of the received PSDU
356 */
357 virtual void UpdateNav(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
358
359 /**
360 * Reset the NAV upon expiration of the NAV reset timer.
361 */
362 virtual void NavResetTimeout();
363
364 /**
365 * This method is called when the reception of a PSDU fails.
366 *
367 * \param psdu the PSDU whose reception failed
368 */
369 virtual void PsduRxError(Ptr<const WifiPsdu> psdu);
370
371 /**
372 * This method handles the reception of an MPDU (possibly included in an A-MPDU)
373 *
374 * \param mpdu the received MPDU
375 * \param rxSignalInfo the info on the received signal (\see RxSignalInfo)
376 * \param txVector TxVector of the received PSDU
377 * \param inAmpdu true if the MPDU is part of an A-MPDU
378 */
379 virtual void ReceiveMpdu(Ptr<const WifiMpdu> mpdu,
380 RxSignalInfo rxSignalInfo,
381 const WifiTxVector& txVector,
382 bool inAmpdu);
383
384 /**
385 * This method is called when the reception of an A-MPDU including multiple
386 * MPDUs is completed.
387 *
388 * \param psdu the received PSDU
389 * \param rxSignalInfo the info on the received signal (\see RxSignalInfo)
390 * \param txVector TxVector of the received PSDU
391 * \param perMpduStatus per MPDU reception status
392 */
393 virtual void EndReceiveAmpdu(Ptr<const WifiPsdu> psdu,
394 const RxSignalInfo& rxSignalInfo,
395 const WifiTxVector& txVector,
396 const std::vector<bool>& perMpduStatus);
397
398 /**
399 * Perform the actions needed when a Normal Ack is received.
400 *
401 * \param mpdu the MPDU that was acknowledged
402 * \param txVector the TXVECTOR used to transmit the MPDU that was acknowledged
403 * \param ackTxVector the TXVECTOR used to transmit the Normal Ack frame
404 * \param rxInfo the info on the received signal (\see RxSignalInfo)
405 * \param snr the SNR at the receiver for the MPDU that was acknowledged
406 */
407 virtual void ReceivedNormalAck(Ptr<WifiMpdu> mpdu,
408 const WifiTxVector& txVector,
409 const WifiTxVector& ackTxVector,
410 const RxSignalInfo& rxInfo,
411 double snr);
412
413 /**
414 * Notify other components that an MPDU was acknowledged.
415 *
416 * \param mpdu the MPDU that was acknowledged
417 */
418 virtual void NotifyReceivedNormalAck(Ptr<WifiMpdu> mpdu);
419
420 /**
421 * Retransmit an MPDU that was not acknowledged.
422 *
423 * \param mpdu the MPDU to retransmit
424 */
425 virtual void RetransmitMpduAfterMissedAck(Ptr<WifiMpdu> mpdu) const;
426
427 /**
428 * Make the sequence numbers of MPDUs included in the given PSDU available again
429 * if the MPDUs have never been transmitted.
430 *
431 * \param psdu the given PSDU
432 */
433 virtual void ReleaseSequenceNumbers(Ptr<const WifiPsdu> psdu) const;
434
435 /**
436 * Pass the given MPDU, discarded because of the max retry limit was reached,
437 * to the MPDU dropped callback.
438 *
439 * \param mpdu the discarded MPDU
440 */
442
443 /**
444 * Perform actions that are possibly needed when receiving any frame,
445 * independently of whether the frame is addressed to this station
446 * (e.g., storing buffer status reports).
447 *
448 * \param psdu the received PSDU
449 * \param txVector TX vector of the received PSDU
450 */
451 virtual void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
452
453 /**
454 * Perform actions that are possibly needed after receiving any frame,
455 * independently of whether the frame is addressed to this station
456 * (e.g., setting the NAV or the TXOP holder).
457 *
458 * \param psdu the received PSDU
459 * \param txVector TX vector of the received PSDU
460 */
461 virtual void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
462
463 /**
464 * Get the updated TX duration of the frame associated with the given TX
465 * parameters if the size of the PSDU addressed to the given receiver
466 * becomes <i>ppduPayloadSize</i>.
467 *
468 * \param ppduPayloadSize the new PSDU size
469 * \param receiver the MAC address of the receiver of the PSDU
470 * \param txParams the TX parameters
471 * \return the updated TX duration
472 */
473 virtual Time GetTxDuration(uint32_t ppduPayloadSize,
474 Mac48Address receiver,
475 const WifiTxParameters& txParams) const;
476
477 /**
478 * Update the TX duration field of the given TX parameters after that the PSDU
479 * addressed to the given receiver has changed.
480 *
481 * \param receiver the MAC address of the receiver of the PSDU
482 * \param txParams the TX parameters
483 */
484 void UpdateTxDuration(Mac48Address receiver, WifiTxParameters& txParams) const;
485
486 /**
487 * Get the size in bytes of the given MPDU, which is to be transmitted with the
488 * given TXVECTOR. The purpose of this method is that it can be overridden to
489 * compute the size of an S-MPDU.
490 *
491 * \param mpdu the given MPDU
492 * \param txVector the given TXVECTOR
493 * \return the size of the MPDU
494 */
495 virtual uint32_t GetPsduSize(Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector) const;
496
497 /**
498 * Notify the given Txop that channel has been released.
499 *
500 * \param txop the given Txop
501 */
502 virtual void NotifyChannelReleased(Ptr<Txop> txop);
503
504 Ptr<Txop> m_dcf; //!< the DCF/EDCAF that gained channel access
505 WifiTxTimer m_txTimer; //!< the timer set upon frame transmission
506 EventId m_navResetEvent; //!< the event to reset the NAV after an RTS
507 Ptr<WifiMac> m_mac; //!< the MAC layer on this station
508 Ptr<MacTxMiddle> m_txMiddle; //!< the MAC TX Middle on this station
509 Ptr<MacRxMiddle> m_rxMiddle; //!< the MAC RX Middle on this station
510 Ptr<ChannelAccessManager> m_channelAccessManager; //!< the channel access manager
511 Ptr<WifiPhy> m_phy; //!< the PHY layer on this station
512 Mac48Address m_self; //!< the MAC address of this device
513 Mac48Address m_bssid; //!< BSSID address (Mac48Address)
514 Time m_navEnd; //!< NAV expiration time
515 std::set<Mac48Address> m_sentRtsTo; //!< the STA(s) which we sent an RTS to (waiting for CTS)
516 std::set<Mac48Address> m_protectedStas; //!< STAs that have replied to an RTS in this TXOP
517 uint8_t m_linkId; //!< the ID of the link this object is associated with
518 MHz_u m_allowedWidth; //!< the allowed width for the current transmission
519 bool m_promisc; //!< Flag if the device is operating in promiscuous mode
520 DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback
521 AckedMpdu m_ackedMpduCallback; //!< the acknowledged MPDU callback
522
523 /**
524 * Finalize the MAC header of the MPDUs in the given PSDU before transmission. Tasks
525 * performed by this method include setting the Power Management flag in the MAC header.
526 *
527 * \param psdu the given PSDU
528 */
529 virtual void FinalizeMacHeader(Ptr<const WifiPsdu> psdu);
530
531 /**
532 * Forward an MPDU down to the PHY layer.
533 *
534 * \param mpdu the MPDU to forward down
535 * \param txVector the TXVECTOR used to transmit the MPDU
536 */
537 virtual void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector);
538
539 /**
540 * Dequeue the given MPDU from the queue in which it is stored.
541 *
542 * \param mpdu the given MPDU
543 */
544 virtual void DequeueMpdu(Ptr<const WifiMpdu> mpdu);
545
546 /**
547 * Compute how to set the Duration/ID field of a frame being transmitted with
548 * the given TX parameters
549 *
550 * \param header the MAC header of the frame
551 * \param size the size of the frame in bytes
552 * \param txParams the TX parameters used to send the frame
553 * \param fragmentedPacket the packet that originated the frame to transmit, in case
554 * the latter is a fragment
555 * \return the computed Duration/ID value
556 */
557 virtual Time GetFrameDurationId(const WifiMacHeader& header,
558 uint32_t size,
559 const WifiTxParameters& txParams,
560 Ptr<Packet> fragmentedPacket) const;
561
562 /**
563 * Compute how to set the Duration/ID field of an RTS frame to send to protect
564 * a frame transmitted with the given TX vector.
565 *
566 * \param rtsTxVector the TX vector used to send the RTS frame
567 * \param txDuration the TX duration of the data frame
568 * \param response the time taken by the response (acknowledgment) to the data frame
569 * \return the computed Duration/ID value for the RTS frame
570 */
571 virtual Time GetRtsDurationId(const WifiTxVector& rtsTxVector,
572 Time txDuration,
573 Time response) const;
574
575 /**
576 * Send RTS to begin RTS-CTS-Data-Ack transaction.
577 *
578 * \param txParams the TX parameters for the data frame
579 */
580 void SendRts(const WifiTxParameters& txParams);
581
582 /**
583 * Send CTS after receiving RTS.
584 *
585 * \param rtsHdr the header of the received RTS
586 * \param rtsTxMode the TX mode used to transmit the RTS
587 * \param rtsSnr the SNR of the RTS in linear scale
588 */
589 virtual void SendCtsAfterRts(const WifiMacHeader& rtsHdr, WifiMode rtsTxMode, double rtsSnr);
590
591 /**
592 * Send CTS after receiving RTS.
593 *
594 * \param rtsHdr the header of the received RTS
595 * \param ctsTxVector the TXVECTOR to use to transmit the CTS
596 * \param rtsSnr the SNR of the RTS in linear scale
597 */
598 void DoSendCtsAfterRts(const WifiMacHeader& rtsHdr, WifiTxVector& ctsTxVector, double rtsSnr);
599
600 /**
601 * Compute how to set the Duration/ID field of a CTS-to-self frame to send to
602 * protect a frame transmitted with the given TX vector.
603 *
604 * \param ctsTxVector the TX vector used to send the CTS-to-self frame
605 * \param txDuration the TX duration of the data frame
606 * \param response the time taken by the response (acknowledgment) to the data frame
607 * \return the computed Duration/ID value for the CTS-to-self frame
608 */
609 virtual Time GetCtsToSelfDurationId(const WifiTxVector& ctsTxVector,
610 Time txDuration,
611 Time response) const;
612
613 /**
614 * Send CTS for a CTS-to-self mechanism.
615 *
616 * \param txParams the TX parameters for the data frame
617 */
618 void SendCtsToSelf(const WifiTxParameters& txParams);
619
620 /**
621 * Send Normal Ack.
622 *
623 * \param hdr the header of the frame soliciting the Normal Ack
624 * \param dataTxVector the TXVECTOR used to transmit the frame soliciting the Normal Ack
625 * \param dataSnr the SNR of the frame soliciting the Normal Ack in linear scale
626 */
627 void SendNormalAck(const WifiMacHeader& hdr, const WifiTxVector& dataTxVector, double dataSnr);
628
629 /**
630 * Get the next fragment of the current MSDU.
631 * Only called for fragmented MSDUs.
632 *
633 * \return the next fragment of the current MSDU.
634 */
636
637 /**
638 * Take necessary actions upon a transmission success. A non-QoS station
639 * transmits the next fragment, if any, or releases the channel, otherwise.
640 */
641 virtual void TransmissionSucceeded();
642
643 /**
644 * Take necessary actions upon a transmission failure. A non-QoS station
645 * releases the channel when this method is called.
646 */
647 virtual void TransmissionFailed();
648
649 /**
650 * Called when the Ack timeout expires.
651 *
652 * \param mpdu the MPDU that solicited a Normal Ack response
653 * \param txVector the TXVECTOR used to transmit the frame soliciting the Normal Ack
654 */
655 virtual void NormalAckTimeout(Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector);
656
657 /**
658 * Called when the CTS timeout expires.
659 *
660 * \param rts the RTS that solicited a CTS response
661 * \param txVector the TXVECTOR used to transmit the RTS frame
662 */
663 virtual void CtsTimeout(Ptr<WifiMpdu> rts, const WifiTxVector& txVector);
664 /**
665 * Take required actions when the CTS timer fired after sending an RTS to
666 * protect the given PSDU expires.
667 *
668 * \param psdu the PSDU protected by the failed RTS
669 */
670 void DoCtsTimeout(Ptr<WifiPsdu> psdu);
671
672 /**
673 * Reset this frame exchange manager.
674 */
675 virtual void Reset();
676
677 /**
678 * \param txVector the TXVECTOR decoded from PHY header.
679 * \param psduDuration the duration of the PSDU that is about to be received.
680 *
681 * This method is typically invoked by the lower PHY layer to notify
682 * the MAC layer that the reception of a PSDU is starting.
683 * This is equivalent to the PHY-RXSTART primitive.
684 * If the reception is correct for at least one MPDU of the PSDU
685 * the Receive method will be called after \p psduDuration.
686 */
687 virtual void RxStartIndication(WifiTxVector txVector, Time psduDuration);
688
689 /**
690 * Store information about the MAC header of the MPDU being received.
691 *
692 * \param macHdr the MAC header of the MPDU being received
693 * \param txVector the TXVECTOR used to transmit the PSDU
694 * \param psduDuration the remaining duration of the PSDU
695 */
696 virtual void ReceivedMacHdr(const WifiMacHeader& macHdr,
697 const WifiTxVector& txVector,
698 Time psduDuration);
699
700 private:
701 /**
702 * Send the current MPDU, which can be acknowledged by a Normal Ack.
703 */
704 void SendMpdu();
705
706 Ptr<WifiMpdu> m_mpdu; //!< the MPDU being transmitted
707 WifiTxParameters m_txParams; //!< the TX parameters for the current frame
708 Ptr<Packet> m_fragmentedPacket; //!< the MSDU being fragmented
709 bool m_moreFragments; //!< true if a fragment has to be sent after a SIFS
711 Ptr<WifiAckManager> m_ackManager; //!< Acknowledgment manager
712
714 m_ongoingRxInfo{}; //!< information about the MAC header of the MPDU being received
715};
716
717} // namespace ns3
718
719#endif /* FRAME_EXCHANGE_MANAGER_H */
Callback template class.
Definition callback.h:422
An identifier for simulation events.
Definition event-id.h:45
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
std::set< Mac48Address > m_sentRtsTo
the STA(s) which we sent an RTS to (waiting for CTS)
void DoCtsTimeout(Ptr< WifiPsdu > psdu)
Take required actions when the CTS timer fired after sending an RTS to protect the given PSDU expires...
Ptr< WifiMpdu > m_mpdu
the MPDU being transmitted
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
void NotifyOffNow()
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
virtual void NotifyInternalCollision(Ptr< Txop > txop)
Notify that an internal collision has occurred for the given Txop.
static TypeId GetTypeId()
Get the type ID.
uint8_t m_linkId
the ID of the link this object is associated with
Ptr< WifiMac > m_mac
the MAC layer on this station
Callback< void, WifiMacDropReason, Ptr< const WifiMpdu > > DroppedMpdu
typedef for a callback to invoke when an MPDU is dropped.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the MAC layer to use.
virtual void ResetPhy()
Remove WifiPhy associated with this FrameExchangeManager.
virtual void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Update the NAV, if needed, based on the Duration/ID of the given psdu.
void SendMpduWithProtection(Ptr< WifiMpdu > mpdu, WifiTxParameters &txParams)
Send an MPDU with the given TX parameters (with the specified protection).
Ptr< WifiAckManager > m_ackManager
Acknowledgment manager.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
void UpdateTxDuration(Mac48Address receiver, WifiTxParameters &txParams) const
Update the TX duration field of the given TX parameters after that the PSDU addressed to the given re...
virtual void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
Ptr< MacTxMiddle > m_txMiddle
the MAC TX Middle on this station
void SendNormalAck(const WifiMacHeader &hdr, const WifiTxVector &dataTxVector, double dataSnr)
Send Normal Ack.
Ptr< Packet > m_fragmentedPacket
the MSDU being fragmented
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Set the callback to invoke when an MPDU is dropped.
virtual void Reset()
Reset this frame exchange manager.
Callback< void, Ptr< const WifiMpdu > > AckedMpdu
typedef for a callback to invoke when an MPDU is successfully acknowledged.
Mac48Address m_self
the MAC address of this device
virtual void StartProtection(const WifiTxParameters &txParams)
Start the protection mechanism indicated by the given TX parameters.
virtual void TransmissionFailed()
Take necessary actions upon a transmission failure.
virtual void NotifyPacketDiscarded(Ptr< const WifiMpdu > mpdu)
Pass the given MPDU, discarded because of the max retry limit was reached, to the MPDU dropped callba...
std::optional< std::reference_wrapper< const WifiMacHeader > > GetReceivedMacHdr() const
WifiTxTimer m_txTimer
the timer set upon frame transmission
virtual void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
std::set< Mac48Address > m_protectedStas
STAs that have replied to an RTS in this TXOP.
virtual Time GetRtsDurationId(const WifiTxVector &rtsTxVector, Time txDuration, Time response) const
Compute how to set the Duration/ID field of an RTS frame to send to protect a frame transmitted with ...
virtual void RetransmitMpduAfterMissedAck(Ptr< WifiMpdu > mpdu) const
Retransmit an MPDU that was not acknowledged.
Mac48Address GetAddress() const
Get the MAC address.
Ptr< WifiProtectionManager > m_protectionManager
Protection manager.
OngoingRxInfo m_ongoingRxInfo
information about the MAC header of the MPDU being received
virtual void ProtectionCompleted()
Transmit prepared frame upon successful protection mechanism.
virtual void ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector)
Forward an MPDU down to the PHY layer.
virtual void SetLinkId(uint8_t linkId)
Set the ID of the link this Frame Exchange Manager is associated with.
virtual bool VirtualCsMediumIdle() const
void SendRts(const WifiTxParameters &txParams)
Send RTS to begin RTS-CTS-Data-Ack transaction.
virtual void NotifyReceivedNormalAck(Ptr< WifiMpdu > mpdu)
Notify other components that an MPDU was acknowledged.
virtual void NotifyChannelReleased(Ptr< Txop > txop)
Notify the given Txop that channel has been released.
virtual void NormalAckTimeout(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
virtual void NotifySwitchingStartNow(Time duration)
virtual void SetBssid(Mac48Address bssid)
Set the Basic Service Set Identification.
void SendCtsToSelf(const WifiTxParameters &txParams)
Send CTS for a CTS-to-self mechanism.
virtual void CtsTimeout(Ptr< WifiMpdu > rts, const WifiTxVector &txVector)
Called when the CTS timeout expires.
virtual void ReceivedMacHdr(const WifiMacHeader &macHdr, const WifiTxVector &txVector, Time psduDuration)
Store information about the MAC header of the MPDU being received.
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
std::optional< std::reference_wrapper< const OngoingRxInfo > > GetOngoingRxInfo() const
virtual void SetAddress(Mac48Address address)
Set the MAC address.
Ptr< WifiAckManager > GetAckManager() const
Get the Acknowledgment Manager used by this node.
virtual void DequeueMpdu(Ptr< const WifiMpdu > mpdu)
Dequeue the given MPDU from the queue in which it is stored.
virtual void NavResetTimeout()
Reset the NAV upon expiration of the NAV reset timer.
const std::set< Mac48Address > & GetProtectedStas() const
Ptr< WifiProtectionManager > GetProtectionManager() const
Get the Protection Manager used by this node.
bool IsPromisc() const
Check if the device is operating in promiscuous mode.
void SendMpdu()
Send the current MPDU, which can be acknowledged by a Normal Ack.
virtual void EndReceiveAmpdu(Ptr< const WifiPsdu > psdu, const RxSignalInfo &rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &perMpduStatus)
This method is called when the reception of an A-MPDU including multiple MPDUs is completed.
Ptr< MacRxMiddle > m_rxMiddle
the MAC RX Middle on this station
virtual void TransmissionSucceeded()
Take necessary actions upon a transmission success.
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
Ptr< WifiPhy > m_phy
the PHY layer on this station
Ptr< WifiMpdu > GetFirstFragmentIfNeeded(Ptr< WifiMpdu > mpdu)
Fragment the given MPDU if needed.
Ptr< WifiMpdu > GetNextFragment()
Get the next fragment of the current MSDU.
virtual void ReleaseSequenceNumbers(Ptr< const WifiPsdu > psdu) const
Make the sequence numbers of MPDUs included in the given PSDU available again if the MPDUs have never...
void SetAckedMpduCallback(AckedMpdu callback)
Set the callback to invoke when an MPDU is successfully acked.
virtual void PreProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Perform actions that are possibly needed when receiving any frame, independently of whether the frame...
virtual Time GetFrameDurationId(const WifiMacHeader &header, uint32_t size, const WifiTxParameters &txParams, Ptr< Packet > fragmentedPacket) const
Compute how to set the Duration/ID field of a frame being transmitted with the given TX parameters.
virtual Time GetCtsToSelfDurationId(const WifiTxVector &ctsTxVector, Time txDuration, Time response) const
Compute how to set the Duration/ID field of a CTS-to-self frame to send to protect a frame transmitte...
void DoSendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiTxVector &ctsTxVector, double rtsSnr)
Send CTS after receiving RTS.
void Receive(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > perMpduStatus)
This method is intended to be called by the PHY layer every time an MPDU is received and also when th...
Mac48Address m_bssid
BSSID address (Mac48Address)
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
Set the PHY layer to use.
AckedMpdu m_ackedMpduCallback
the acknowledged MPDU callback
virtual void FinalizeMacHeader(Ptr< const WifiPsdu > psdu)
Finalize the MAC header of the MPDUs in the given PSDU before transmission.
virtual void PostProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Perform actions that are possibly needed after receiving any frame, independently of whether the fram...
virtual uint32_t GetPsduSize(Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector) const
Get the size in bytes of the given MPDU, which is to be transmitted with the given TXVECTOR.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual void ReceivedNormalAck(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector, const WifiTxVector &ackTxVector, const RxSignalInfo &rxInfo, double snr)
Perform the actions needed when a Normal Ack is received.
bool m_promisc
Flag if the device is operating in promiscuous mode.
void NotifySleepNow()
This method is typically invoked by the PhyListener to notify the MAC layer that the device has been ...
virtual void ReceiveMpdu(Ptr< const WifiMpdu > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu)
This method handles the reception of an MPDU (possibly included in an A-MPDU)
virtual void SetChannelAccessManager(const Ptr< ChannelAccessManager > channelAccessManager)
Set the channel access manager to use.
virtual bool StartTransmission(Ptr< Txop > dcf, MHz_u allowedWidth)
Request the FrameExchangeManager to start a frame exchange sequence.
bool m_moreFragments
true if a fragment has to be sent after a SIFS
void SetPromisc()
Enable promiscuous mode.
MHz_u m_allowedWidth
the allowed width for the current transmission
virtual void PsduRxError(Ptr< const WifiPsdu > psdu)
This method is called when the reception of a PSDU fails.
Time m_navEnd
NAV expiration time.
virtual void SetMacTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set the MAC TX Middle to use.
virtual void SetMacRxMiddle(const Ptr< MacRxMiddle > rxMiddle)
Set the MAC RX Middle to use.
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
Mac48Address GetBssid() const
Get the Basic Service Set Identification.
void DoDispose() override
Destructor implementation.
WifiTxParameters m_txParams
the TX parameters for the current frame
virtual void RxStartIndication(WifiTxVector txVector, Time psduDuration)
EventId m_navResetEvent
the event to reset the NAV after an RTS
const WifiTxTimer & GetWifiTxTimer() const
Get a const reference to the WifiTxTimer object.
virtual Time GetTxDuration(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams) const
Get the updated TX duration of the frame associated with the given TX parameters if the size of the P...
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Implements the IEEE 802.11 MAC header.
represent a single transmission mode
Definition wifi-mode.h:40
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
This class is used to handle the timer that a station starts when transmitting a frame that solicits ...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Information about the MPDU being received.
Time endOfPsduRx
time when reception of PSDU ends
std::optional< WifiMacHeader > macHdr
MAC header of the MPDU being received.
WifiTxVector txVector
TXVECTOR of the MPDU being received.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:72
WifiAcknowledgment is an abstract base struct.
WifiProtection is an abstract base struct.