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 */
320
321 /**
322 * Fragment the given MPDU if needed. If fragmentation is needed, return the
323 * first fragment; otherwise, return the given MPDU. Note that, if fragmentation
324 * is applied, the given MPDU is dequeued from the MAC queue and the first
325 * fragment is enqueued in its place.
326 *
327 * @param mpdu the given MPDU
328 * @return the first fragment if fragmentation is needed, the given MPDU otherwise
329 */
331
332 /**
333 * Send an MPDU with the given TX parameters (with the specified protection).
334 * Note that <i>txParams</i> is moved to m_txParams and hence is left in an
335 * undefined state.
336 *
337 * @param mpdu the MPDU to send
338 * @param txParams the TX parameters to use to transmit the MPDU
339 */
341
342 /**
343 * Start the protection mechanism indicated by the given TX parameters
344 *
345 * @param txParams the TX parameters
346 */
347 virtual void StartProtection(const WifiTxParameters& txParams);
348
349 /**
350 * Transmit prepared frame immediately, if no protection was used, or in a SIFS, if protection
351 * was completed successfully.
352 */
353 virtual void ProtectionCompleted();
354
355 /**
356 * Update the NAV, if needed, based on the Duration/ID of the given MAC header and the given
357 * surplus.
358 *
359 * @param hdr the given MAC header
360 * @param txVector TxVector of the PSDU containing the MAC header
361 * @param surplus the surplus to add to the Duration/ID value. This is needed, e.g., when
362 * setting the NAV at the end of the reception of the MAC header
363 */
364 virtual void UpdateNav(const WifiMacHeader& hdr,
365 const WifiTxVector& txVector,
366 const Time& surplus = Time{0});
367
368 /**
369 * Reset the NAV upon expiration of the NAV reset timer.
370 */
371 virtual void NavResetTimeout();
372
373 /**
374 * Set the TXNAV upon sending an MPDU.
375 *
376 * @param mpdu the MPDU being sent
377 * @param txDuration the TX duration of the MPDU
378 */
379 void SetTxNav(Ptr<const WifiMpdu> mpdu, const Time& txDuration);
380
381 /// Reset the TXNAV
382 void ResetTxNav();
383
384 /**
385 * This method is called when the reception of a PSDU fails.
386 *
387 * @param psdu the PSDU whose reception failed
388 */
389 virtual void PsduRxError(Ptr<const WifiPsdu> psdu);
390
391 /**
392 * This method handles the reception of an MPDU (possibly included in an A-MPDU)
393 *
394 * @param mpdu the received MPDU
395 * @param rxSignalInfo the info on the received signal (\see RxSignalInfo)
396 * @param txVector TxVector of the received PSDU
397 * @param inAmpdu true if the MPDU is part of an A-MPDU
398 */
399 virtual void ReceiveMpdu(Ptr<const WifiMpdu> mpdu,
400 RxSignalInfo rxSignalInfo,
401 const WifiTxVector& txVector,
402 bool inAmpdu);
403
404 /**
405 * This method is called when the reception of an A-MPDU including multiple
406 * MPDUs is completed.
407 *
408 * @param psdu the received PSDU
409 * @param rxSignalInfo the info on the received signal (\see RxSignalInfo)
410 * @param txVector TxVector of the received PSDU
411 * @param perMpduStatus per MPDU reception status
412 */
413 virtual void EndReceiveAmpdu(Ptr<const WifiPsdu> psdu,
414 const RxSignalInfo& rxSignalInfo,
415 const WifiTxVector& txVector,
416 const std::vector<bool>& perMpduStatus);
417
418 /**
419 * Perform the actions needed when a Normal Ack is received.
420 *
421 * @param mpdu the MPDU that was acknowledged
422 * @param txVector the TXVECTOR used to transmit the MPDU that was acknowledged
423 * @param ackTxVector the TXVECTOR used to transmit the Normal Ack frame
424 * @param rxInfo the info on the received signal (\see RxSignalInfo)
425 * @param snr the SNR at the receiver for the MPDU that was acknowledged
426 */
427 virtual void ReceivedNormalAck(Ptr<WifiMpdu> mpdu,
428 const WifiTxVector& txVector,
429 const WifiTxVector& ackTxVector,
430 const RxSignalInfo& rxInfo,
431 double snr);
432
433 /**
434 * Notify other components that an MPDU was acknowledged.
435 *
436 * @param mpdu the MPDU that was acknowledged
437 */
438 virtual void NotifyReceivedNormalAck(Ptr<WifiMpdu> mpdu);
439
440 /**
441 * Retransmit an MPDU that was not acknowledged.
442 *
443 * @param mpdu the MPDU to retransmit
444 */
445 virtual void RetransmitMpduAfterMissedAck(Ptr<WifiMpdu> mpdu) const;
446
447 /**
448 * Make the sequence numbers of MPDUs included in the given PSDU available again
449 * if the MPDUs have never been transmitted.
450 *
451 * @param psdu the given PSDU
452 */
453 virtual void ReleaseSequenceNumbers(Ptr<const WifiPsdu> psdu) const;
454
455 /**
456 * Pass the given MPDU, discarded because of the max retry limit was reached,
457 * to the MPDU dropped callback.
458 *
459 * @param mpdu the discarded MPDU
460 */
462
463 /**
464 * Perform actions that are possibly needed when receiving any frame,
465 * independently of whether the frame is addressed to this station
466 * (e.g., storing buffer status reports).
467 *
468 * @param psdu the received PSDU
469 * @param txVector TX vector of the received PSDU
470 */
471 virtual void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
472
473 /**
474 * Perform actions that are possibly needed after receiving any frame,
475 * independently of whether the frame is addressed to this station
476 * (e.g., setting the NAV or the TXOP holder).
477 *
478 * @param psdu the received PSDU
479 * @param txVector TX vector of the received PSDU
480 */
481 virtual void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
482
483 /**
484 * Get the updated TX duration of the frame associated with the given TX
485 * parameters if the size of the PSDU addressed to the given receiver
486 * becomes <i>ppduPayloadSize</i>.
487 *
488 * @param ppduPayloadSize the new PSDU size
489 * @param receiver the MAC address of the receiver of the PSDU
490 * @param txParams the TX parameters
491 * @return the updated TX duration
492 */
493 virtual Time GetTxDuration(uint32_t ppduPayloadSize,
494 Mac48Address receiver,
495 const WifiTxParameters& txParams) const;
496
497 /**
498 * Update the TX duration field of the given TX parameters after that the PSDU
499 * addressed to the given receiver has changed.
500 *
501 * @param receiver the MAC address of the receiver of the PSDU
502 * @param txParams the TX parameters
503 */
504 void UpdateTxDuration(Mac48Address receiver, WifiTxParameters& txParams) const;
505
506 /**
507 * Get the size in bytes of the given MPDU, which is to be transmitted with the
508 * given TXVECTOR. The purpose of this method is that it can be overridden to
509 * compute the size of an S-MPDU.
510 *
511 * @param mpdu the given MPDU
512 * @param txVector the given TXVECTOR
513 * @return the size of the MPDU
514 */
515 virtual uint32_t GetPsduSize(Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector) const;
516
517 /**
518 * Notify the given Txop that channel has been released.
519 *
520 * @param txop the given Txop
521 */
522 virtual void NotifyChannelReleased(Ptr<Txop> txop);
523
524 Ptr<Txop> m_dcf; //!< the DCF/EDCAF that gained channel access
525 WifiTxTimer m_txTimer; //!< the timer set upon frame transmission
526 EventId m_navResetEvent; //!< the event to reset the NAV after an RTS
527 EventId m_sendCtsEvent; //!< the event to send a CTS after an (MU-)RTS
528 Ptr<WifiMac> m_mac; //!< the MAC layer on this station
529 Ptr<ApWifiMac> m_apMac; //!< AP MAC layer pointer (null if not an AP)
530 Ptr<StaWifiMac> m_staMac; //!< STA MAC layer pointer (null if not a STA)
531 Ptr<MacTxMiddle> m_txMiddle; //!< the MAC TX Middle on this station
532 Ptr<MacRxMiddle> m_rxMiddle; //!< the MAC RX Middle on this station
533 Ptr<ChannelAccessManager> m_channelAccessManager; //!< the channel access manager
534 Ptr<WifiPhy> m_phy; //!< the PHY layer on this station
535 Mac48Address m_self; //!< the MAC address of this device
536 Mac48Address m_bssid; //!< BSSID address (Mac48Address)
537 Time m_navEnd; //!< NAV expiration time
538 Time m_txNav; //!< the TXNAV timer
539 std::set<Mac48Address> m_sentRtsTo; //!< the STA(s) which we sent an RTS to (waiting for CTS)
540 std::set<Mac48Address>
541 m_sentFrameTo; //!< the STA(s) to which we sent a frame requesting a response
542 std::set<Mac48Address> m_protectedStas; //!< STAs that have replied to an RTS in this TXOP
543 bool m_protectedIfResponded; //!< whether a STA is assumed to be protected if replied to a
544 //!< frame requiring acknowledgment
545 uint8_t m_linkId; //!< the ID of the link this object is associated with
546 MHz_u m_allowedWidth; //!< the allowed width for the current transmission
547 bool m_promisc; //!< Flag if the device is operating in promiscuous mode
548 DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback
549 AckedMpdu m_ackedMpduCallback; //!< the acknowledged MPDU callback
550
551 /**
552 * Finalize the MAC header of the MPDUs in the given PSDU before transmission. Tasks
553 * performed by this method include setting the Power Management flag in the MAC header.
554 *
555 * @param psdu the given PSDU
556 */
557 virtual void FinalizeMacHeader(Ptr<const WifiPsdu> psdu);
558
559 /**
560 * Forward an MPDU down to the PHY layer.
561 *
562 * @param mpdu the MPDU to forward down
563 * @param txVector the TXVECTOR used to transmit the MPDU
564 */
565 virtual void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector);
566
567 /**
568 * Dequeue the given MPDU from the queue in which it is stored.
569 *
570 * @param mpdu the given MPDU
571 */
572 virtual void DequeueMpdu(Ptr<const WifiMpdu> mpdu);
573
574 /**
575 * Compute how to set the Duration/ID field of a frame being transmitted with
576 * the given TX parameters
577 *
578 * @param header the MAC header of the frame
579 * @param size the size of the frame in bytes
580 * @param txParams the TX parameters used to send the frame
581 * @param fragmentedPacket the packet that originated the frame to transmit, in case
582 * the latter is a fragment
583 * @return the computed Duration/ID value
584 */
585 virtual Time GetFrameDurationId(const WifiMacHeader& header,
586 uint32_t size,
587 const WifiTxParameters& txParams,
588 Ptr<Packet> fragmentedPacket) const;
589
590 /**
591 * Compute how to set the Duration/ID field of an RTS frame to send to protect
592 * a frame transmitted with the given TX vector.
593 *
594 * @param rtsTxVector the TX vector used to send the RTS frame
595 * @param txDuration the TX duration of the data frame
596 * @param response the time taken by the response (acknowledgment) to the data frame
597 * @return the computed Duration/ID value for the RTS frame
598 */
599 virtual Time GetRtsDurationId(const WifiTxVector& rtsTxVector,
600 Time txDuration,
601 Time response) const;
602
603 /**
604 * Send RTS to begin RTS-CTS-Data-Ack transaction.
605 *
606 * @param txParams the TX parameters for the data frame
607 */
608 void SendRts(const WifiTxParameters& txParams);
609
610 /**
611 * Send CTS after receiving RTS.
612 *
613 * @param rtsHdr the header of the received RTS
614 * @param rtsTxVector the TXVECTOR used to transmit the RTS
615 * @param rtsSnr the SNR of the RTS in linear scale
616 */
617 virtual void SendCtsAfterRts(const WifiMacHeader& rtsHdr,
618 const WifiTxVector& rtsTxVector,
619 double rtsSnr);
620
621 /**
622 * Send CTS after receiving RTS.
623 *
624 * @param rtsHdr the header of the received RTS
625 * @param ctsTxVector the TXVECTOR to use to transmit the CTS
626 * @param rtsSnr the SNR of the RTS in linear scale
627 */
628 void DoSendCtsAfterRts(const WifiMacHeader& rtsHdr, WifiTxVector& ctsTxVector, double rtsSnr);
629
630 /**
631 * Compute how to set the Duration/ID field of a CTS-to-self frame to send to
632 * protect a frame transmitted with the given TX vector.
633 *
634 * @param ctsTxVector the TX vector used to send the CTS-to-self frame
635 * @param txDuration the TX duration of the data frame
636 * @param response the time taken by the response (acknowledgment) to the data frame
637 * @return the computed Duration/ID value for the CTS-to-self frame
638 */
639 virtual Time GetCtsToSelfDurationId(const WifiTxVector& ctsTxVector,
640 Time txDuration,
641 Time response) const;
642
643 /**
644 * Send CTS for a CTS-to-self mechanism.
645 *
646 * @param txParams the TX parameters for the data frame
647 */
648 void SendCtsToSelf(const WifiTxParameters& txParams);
649
650 /**
651 * Send Normal Ack.
652 *
653 * @param hdr the header of the frame soliciting the Normal Ack
654 * @param dataTxVector the TXVECTOR used to transmit the frame soliciting the Normal Ack
655 * @param dataSnr the SNR of the frame soliciting the Normal Ack in linear scale
656 */
657 void SendNormalAck(const WifiMacHeader& hdr, const WifiTxVector& dataTxVector, double dataSnr);
658
659 /**
660 * Get the next fragment of the current MSDU.
661 * Only called for fragmented MSDUs.
662 *
663 * @return the next fragment of the current MSDU.
664 */
666
667 /**
668 * Take necessary actions upon a transmission success. A non-QoS station
669 * transmits the next fragment, if any, or releases the channel, otherwise.
670 */
671 virtual void TransmissionSucceeded();
672
673 /**
674 * Take necessary actions upon a transmission failure. A non-QoS station
675 * releases the channel when this method is called.
676 *
677 * @param forceCurrentCw whether to force the contention window to stay equal to the current
678 * value (normally, contention window is updated upon TX failure)
679 */
680 virtual void TransmissionFailed(bool forceCurrentCw = false);
681
682 /**
683 * Wrapper for the GetMpdusToDropOnTxFailure function of the remote station manager that
684 * additionally drops the MPDUs in the given PSDU that the remote station manager requested
685 * to drop.
686 *
687 * @param psdu the given PSDU
688 * @return an MPDU that has been dropped, if any, to be notified to the remote station manager
689 * through the appropriate function
690 */
692
693 /**
694 * Called when the Ack timeout expires.
695 *
696 * @param mpdu the MPDU that solicited a Normal Ack response
697 * @param txVector the TXVECTOR used to transmit the frame soliciting the Normal Ack
698 */
699 virtual void NormalAckTimeout(Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector);
700
701 /**
702 * Called when the CTS timeout expires.
703 *
704 * @param rts the RTS that solicited a CTS response
705 * @param txVector the TXVECTOR used to transmit the RTS frame
706 */
707 virtual void CtsTimeout(Ptr<WifiMpdu> rts, const WifiTxVector& txVector);
708 /**
709 * Take required actions when the CTS timer fired after sending an (MU-)RTS to
710 * protect the given PSDU map expires.
711 *
712 * @param psduMap the PSDU map protected by the failed (MU-)RTS
713 */
714 void DoCtsTimeout(const WifiPsduMap& psduMap);
715
716 /**
717 * @return whether CW shall be updated on CTS timeout
718 */
719 virtual bool GetUpdateCwOnCtsTimeout() const;
720
721 /**
722 * @return whether an (MU-)RTS failure shall be reported to the remote station manager
723 */
724 virtual bool GetReportRtsFailed() const;
725
726 /**
727 * Reset this frame exchange manager.
728 */
729 virtual void Reset();
730
731 /**
732 * @param txVector the TXVECTOR decoded from PHY header.
733 * @param psduDuration the duration of the PSDU that is about to be received.
734 *
735 * This method is typically invoked by the lower PHY layer to notify
736 * the MAC layer that the reception of a PSDU is starting.
737 * This is equivalent to the PHY-RXSTART primitive.
738 * If the reception is correct for at least one MPDU of the PSDU
739 * the Receive method will be called after \p psduDuration.
740 */
741 virtual void RxStartIndication(WifiTxVector txVector, Time psduDuration);
742
743 /**
744 * Store information about the MAC header of the MPDU being received.
745 *
746 * @param macHdr the MAC header of the MPDU being received
747 * @param txVector the TXVECTOR used to transmit the PSDU
748 * @param psduDuration the remaining duration of the PSDU
749 */
750 virtual void ReceivedMacHdr(const WifiMacHeader& macHdr,
751 const WifiTxVector& txVector,
752 Time psduDuration);
753
754 /**
755 * Notify the last (re)transmission of a groupcast MPDU using the GCR-UR service.
756 *
757 * @param mpdu the groupcast MPDU
758 */
759 virtual void NotifyLastGcrUrTx(Ptr<const WifiMpdu> mpdu);
760
761 private:
762 /**
763 * Send the current MPDU, which can be acknowledged by a Normal Ack.
764 */
765 void SendMpdu();
766
767 Ptr<WifiMpdu> m_mpdu; //!< the MPDU being transmitted
768 WifiTxParameters m_txParams; //!< the TX parameters for the current frame
769 Ptr<Packet> m_fragmentedPacket; //!< the MSDU being fragmented
770 bool m_moreFragments; //!< true if a fragment has to be sent after a SIFS
772 Ptr<WifiAckManager> m_ackManager; //!< Acknowledgment manager
773
775 m_ongoingRxInfo{}; //!< information about the MAC header of the MPDU being received
776};
777
778} // namespace ns3
779
780#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)
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
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: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.
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:78
WifiAcknowledgment is an abstract base struct.
WifiProtection is an abstract base struct.