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