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