A Discrete-Event Network Simulator
API
qos-frame-exchange-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19
21
22#include "ap-wifi-mac.h"
23#include "wifi-mac-queue.h"
24#include "wifi-mac-trailer.h"
25
26#include "ns3/abort.h"
27#include "ns3/log.h"
28
29#undef NS_LOG_APPEND_CONTEXT
30#define NS_LOG_APPEND_CONTEXT std::clog << "[link=" << +m_linkId << "][mac=" << m_self << "] "
31
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("QosFrameExchangeManager");
36
37NS_OBJECT_ENSURE_REGISTERED(QosFrameExchangeManager);
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::QosFrameExchangeManager")
45 .AddConstructor<QosFrameExchangeManager>()
46 .SetGroupName("Wifi")
47 .AddAttribute("PifsRecovery",
48 "Perform a PIFS recovery as a response to transmission failure "
49 "within a TXOP",
50 BooleanValue(true),
53 .AddAttribute("SetQueueSize",
54 "Whether to set the Queue Size subfield of the QoS Control field "
55 "of QoS data frames sent by non-AP stations",
56 BooleanValue(false),
59 return tid;
60}
61
63 : m_initialFrame(false)
64{
65 NS_LOG_FUNCTION(this);
66}
67
69{
71}
72
73void
75{
76 NS_LOG_FUNCTION(this);
77 m_edca = nullptr;
78 m_edcaBackingOff = nullptr;
81}
82
83bool
85{
86 NS_LOG_FUNCTION(this);
89
90 WifiMacHeader cfEnd;
92 cfEnd.SetDsNotFrom();
93 cfEnd.SetDsNotTo();
94 cfEnd.SetNoRetry();
95 cfEnd.SetNoMoreFragments();
96 cfEnd.SetDuration(Seconds(0));
98 cfEnd.SetAddr2(m_self);
99
101
103 cfEndTxVector,
104 m_phy->GetPhyBand());
105
106 // Send the CF-End frame if the remaining duration is long enough to transmit this frame
107 if (m_edca->GetRemainingTxop(m_linkId) > txDuration)
108 {
109 NS_LOG_DEBUG("Send CF-End frame");
110 m_phy->Send(Create<WifiPsdu>(Create<Packet>(), cfEnd), cfEndTxVector);
112 return true;
113 }
114
116 m_edca = nullptr;
117 return false;
118}
119
120void
122{
123 NS_LOG_FUNCTION(this);
126
127 // Release the channel if it has not been idle for the last PIFS interval
130 {
132 m_edca = nullptr;
133 }
134 else
135 {
136 // the txopDuration parameter is unused because we are not starting a new TXOP
138 }
139}
140
141void
143{
144 NS_LOG_FUNCTION(this);
147
148 NS_LOG_DEBUG("Cancel PIFS recovery being attempted by EDCAF " << m_edca);
151}
152
153bool
155{
156 NS_LOG_FUNCTION(this << edca << allowedWidth);
157
159 {
160 // Another AC (having AIFS=1 or lower, if the user changed the default settings)
161 // gained channel access while performing PIFS recovery. Abort PIFS recovery
163 }
164
165 // TODO This will become an assert once no Txop is installed on a QoS station
166 if (!edca->IsQosTxop())
167 {
168 m_edca = nullptr;
169 return FrameExchangeManager::StartTransmission(edca, allowedWidth);
170 }
171
172 m_allowedWidth = allowedWidth;
173 auto qosTxop = StaticCast<QosTxop>(edca);
174 return StartTransmission(qosTxop, qosTxop->GetTxopLimit(m_linkId));
175}
176
177bool
179{
180 NS_LOG_FUNCTION(this << edca << txopDuration);
181
183 {
184 // Another AC (having AIFS=1 or lower, if the user changed the default settings)
185 // gained channel access while performing PIFS recovery. Abort PIFS recovery
187 }
188
189 if (m_txTimer.IsRunning())
190 {
192 }
193 m_dcf = edca;
194 m_edca = edca;
195
196 // We check if this EDCAF invoked the backoff procedure (without terminating
197 // the TXOP) because the transmission of a non-initial frame of a TXOP failed
198 bool backingOff = (m_edcaBackingOff == m_edca);
199
200 if (backingOff)
201 {
206
207 // clear the member variable
208 m_edcaBackingOff = nullptr;
209 }
210
212 {
213 // TXOP limit is not null. We have to check if this EDCAF is starting a
214 // new TXOP. This includes the case when the transmission of a non-initial
215 // frame of a TXOP failed and backoff was invoked without terminating the
216 // TXOP. In such a case, we assume that a new TXOP is being started if it
217 // elapsed more than TXOPlimit since the start of the paused TXOP. Note
218 // that GetRemainingTxop returns 0 iff Now - TXOPstart >= TXOPlimit
220 (backingOff && m_edca->GetRemainingTxop(m_linkId).IsZero()))
221 {
222 // starting a new TXOP
223 m_edca->NotifyChannelAccessed(m_linkId, txopDuration);
224
225 if (StartFrameExchange(m_edca, txopDuration, true))
226 {
227 m_initialFrame = true;
228 return true;
229 }
230
231 // TXOP not even started, return false
232 NS_LOG_DEBUG("No frame transmitted");
234 m_edca = nullptr;
235 return false;
236 }
237
238 // We are continuing a TXOP, check if we can transmit another frame
240
242 {
243 NS_LOG_DEBUG("Not enough remaining TXOP time");
244 return SendCfEndIfNeeded();
245 }
246
247 return true;
248 }
249
250 // we get here if TXOP limit is null
251 m_initialFrame = true;
252
253 if (StartFrameExchange(m_edca, Time::Min(), true))
254 {
256 return true;
257 }
258
259 NS_LOG_DEBUG("No frame transmitted");
261 m_edca = nullptr;
262 return false;
263}
264
265bool
267 Time availableTime,
268 bool initialFrame)
269{
270 NS_LOG_FUNCTION(this << edca << availableTime << initialFrame);
271
272 Ptr<WifiMpdu> mpdu = edca->PeekNextMpdu(m_linkId);
273
274 // Even though channel access is requested when the queue is not empty, at
275 // the time channel access is granted the lifetime of the packet might be
276 // expired and the queue might be empty.
277 if (!mpdu)
278 {
279 NS_LOG_DEBUG("Queue empty");
280 return false;
281 }
282
283 WifiTxParameters txParams;
284 txParams.m_txVector =
286
287 Ptr<WifiMpdu> item = edca->GetNextMpdu(m_linkId, mpdu, txParams, availableTime, initialFrame);
288
289 if (!item)
290 {
291 NS_LOG_DEBUG("Not enough time to transmit a frame");
292 return false;
293 }
294
295 NS_ASSERT_MSG(!item->GetHeader().IsQosData() || !item->GetHeader().IsQosAmsdu(),
296 "We should not get an A-MSDU here");
297
298 // check if the MSDU needs to be fragmented
299 item = GetFirstFragmentIfNeeded(item);
300
301 // update the protection method if the frame was fragmented
302 if (item->IsFragment() && item->GetSize() != mpdu->GetSize())
303 {
304 WifiTxParameters fragmentTxParams;
305 fragmentTxParams.m_txVector = txParams.m_txVector;
306 txParams.m_protection = GetProtectionManager()->TryAddMpdu(item, fragmentTxParams);
307 NS_ASSERT(txParams.m_protection);
308 }
309
310 SendMpduWithProtection(item, txParams);
311
312 return true;
313}
314
315bool
317 WifiTxParameters& txParams,
318 Time availableTime) const
319{
320 NS_ASSERT(mpdu);
321 NS_LOG_FUNCTION(this << *mpdu << &txParams << availableTime);
322
323 // check if adding the given MPDU requires a different protection method
324 Time protectionTime = Time::Min(); // uninitialized
325 if (txParams.m_protection)
326 {
327 protectionTime = txParams.m_protection->protectionTime;
328 }
329
330 std::unique_ptr<WifiProtection> protection;
331 protection = GetProtectionManager()->TryAddMpdu(mpdu, txParams);
332 bool protectionSwapped = false;
333
334 if (protection)
335 {
336 // the protection method has changed, calculate the new protection time
337 CalculateProtectionTime(protection.get());
338 protectionTime = protection->protectionTime;
339 // swap unique pointers, so that the txParams that is passed to the next
340 // call to IsWithinLimitsIfAddMpdu is the most updated one
341 txParams.m_protection.swap(protection);
342 protectionSwapped = true;
343 }
344 NS_ASSERT(protectionTime != Time::Min());
345 NS_LOG_DEBUG("protection time=" << protectionTime);
346
347 // check if adding the given MPDU requires a different acknowledgment method
348 Time acknowledgmentTime = Time::Min(); // uninitialized
349 if (txParams.m_acknowledgment)
350 {
351 acknowledgmentTime = txParams.m_acknowledgment->acknowledgmentTime;
352 }
353
354 std::unique_ptr<WifiAcknowledgment> acknowledgment;
355 acknowledgment = GetAckManager()->TryAddMpdu(mpdu, txParams);
356 bool acknowledgmentSwapped = false;
357
358 if (acknowledgment)
359 {
360 // the acknowledgment method has changed, calculate the new acknowledgment time
361 CalculateAcknowledgmentTime(acknowledgment.get());
362 acknowledgmentTime = acknowledgment->acknowledgmentTime;
363 // swap unique pointers, so that the txParams that is passed to the next
364 // call to IsWithinLimitsIfAddMpdu is the most updated one
365 txParams.m_acknowledgment.swap(acknowledgment);
366 acknowledgmentSwapped = true;
367 }
368 NS_ASSERT(acknowledgmentTime != Time::Min());
369 NS_LOG_DEBUG("acknowledgment time=" << acknowledgmentTime);
370
371 Time ppduDurationLimit = Time::Min();
372 if (availableTime != Time::Min())
373 {
374 ppduDurationLimit = availableTime - protectionTime - acknowledgmentTime;
375 }
376
377 if (!IsWithinLimitsIfAddMpdu(mpdu, txParams, ppduDurationLimit))
378 {
379 // adding MPDU failed, restore protection and acknowledgment methods
380 // if they were swapped
381 if (protectionSwapped)
382 {
383 txParams.m_protection.swap(protection);
384 }
385 if (acknowledgmentSwapped)
386 {
387 txParams.m_acknowledgment.swap(acknowledgment);
388 }
389 return false;
390 }
391
392 // the given MPDU can be added, hence update the txParams
393 txParams.AddMpdu(mpdu);
394 UpdateTxDuration(mpdu->GetHeader().GetAddr1(), txParams);
395
396 return true;
397}
398
399bool
401 const WifiTxParameters& txParams,
402 Time ppduDurationLimit) const
403{
404 NS_ASSERT(mpdu);
405 NS_LOG_FUNCTION(this << *mpdu << &txParams << ppduDurationLimit);
406
407 // A QoS station only has to check that the MPDU transmission time does not
408 // exceed the given limit
409 return IsWithinSizeAndTimeLimits(mpdu->GetSize(),
410 mpdu->GetHeader().GetAddr1(),
411 txParams,
412 ppduDurationLimit);
413}
414
415bool
417 Mac48Address receiver,
418 const WifiTxParameters& txParams,
419 Time ppduDurationLimit) const
420{
421 NS_LOG_FUNCTION(this << ppduPayloadSize << receiver << &txParams << ppduDurationLimit);
422
423 if (ppduDurationLimit != Time::Min() && ppduDurationLimit.IsNegative())
424 {
425 NS_LOG_DEBUG("ppduDurationLimit is null or negative, time limit is trivially exceeded");
426 return false;
427 }
428
429 if (ppduPayloadSize > WifiPhy::GetMaxPsduSize(txParams.m_txVector.GetModulationClass()))
430 {
431 NS_LOG_DEBUG("the frame exceeds the max PSDU size");
432 return false;
433 }
434
435 // Get the maximum PPDU Duration based on the preamble type
436 Time maxPpduDuration = GetPpduMaxTime(txParams.m_txVector.GetPreambleType());
437
438 Time txTime = GetTxDuration(ppduPayloadSize, receiver, txParams);
439 NS_LOG_DEBUG("PPDU duration: " << txTime.As(Time::MS));
440
441 if ((ppduDurationLimit.IsStrictlyPositive() && txTime > ppduDurationLimit) ||
442 (maxPpduDuration.IsStrictlyPositive() && txTime > maxPpduDuration))
443 {
445 "the frame does not meet the constraint on max PPDU duration or PPDU duration limit");
446 return false;
447 }
448
449 return true;
450}
451
452Time
454 uint32_t size,
455 const WifiTxParameters& txParams,
456 Ptr<Packet> fragmentedPacket) const
457{
458 NS_LOG_FUNCTION(this << header << size << &txParams << fragmentedPacket);
459
460 // TODO This will be removed once no Txop is installed on a QoS station
461 if (!m_edca)
462 {
463 return FrameExchangeManager::GetFrameDurationId(header, size, txParams, fragmentedPacket);
464 }
465
467 {
468 return FrameExchangeManager::GetFrameDurationId(header, size, txParams, fragmentedPacket);
469 }
470
471 NS_ASSERT(txParams.m_acknowledgment &&
472 txParams.m_acknowledgment->acknowledgmentTime != Time::Min());
473
474 // under multiple protection settings, if the TXOP limit is not null, Duration/ID
475 // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016).
476 // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8
477 // of 802.11-2016)
480 txParams.m_acknowledgment->acknowledgmentTime);
481}
482
483Time
485 Time txDuration,
486 Time response) const
487{
488 NS_LOG_FUNCTION(this << rtsTxVector << txDuration << response);
489
490 // TODO This will be removed once no Txop is installed on a QoS station
491 if (!m_edca)
492 {
493 return FrameExchangeManager::GetRtsDurationId(rtsTxVector, txDuration, response);
494 }
495
497 {
498 return FrameExchangeManager::GetRtsDurationId(rtsTxVector, txDuration, response);
499 }
500
501 // under multiple protection settings, if the TXOP limit is not null, Duration/ID
502 // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016).
503 // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8
504 // of 802.11-2016)
507 Seconds(0));
508}
509
510Time
512 Time txDuration,
513 Time response) const
514{
515 NS_LOG_FUNCTION(this << ctsTxVector << txDuration << response);
516
517 // TODO This will be removed once no Txop is installed on a QoS station
518 if (!m_edca)
519 {
520 return FrameExchangeManager::GetCtsToSelfDurationId(ctsTxVector, txDuration, response);
521 }
522
524 {
525 return FrameExchangeManager::GetCtsToSelfDurationId(ctsTxVector, txDuration, response);
526 }
527
528 // under multiple protection settings, if the TXOP limit is not null, Duration/ID
529 // is set to cover the remaining TXOP time (Sec. 9.2.5.2 of 802.11-2016).
530 // The TXOP holder may exceed the TXOP limit in some situations (Sec. 10.22.2.8
531 // of 802.11-2016)
534 Seconds(0));
535}
536
537void
539{
540 NS_LOG_FUNCTION(this << *mpdu << txVector);
541
542 WifiMacHeader& hdr = mpdu->GetHeader();
543
544 if (hdr.IsQosData() && m_mac->GetTypeOfStation() == STA &&
545 (m_setQosQueueSize || hdr.IsQosEosp()))
546 {
547 uint8_t tid = hdr.GetQosTid();
548 hdr.SetQosEosp();
549 hdr.SetQosQueueSize(m_mac->GetQosTxop(tid)->GetQosQueueSize(tid, hdr.GetAddr1()));
550 }
552}
553
554void
556{
557 NS_LOG_DEBUG(this);
558
559 // TODO This will be removed once no Txop is installed on a QoS station
560 if (!m_edca)
561 {
563 return;
564 }
565
568 {
569 NS_LOG_DEBUG("Schedule another transmission in a SIFS");
572
573 // we are continuing a TXOP, hence the txopDuration parameter is unused
575 }
576 else
577 {
579 m_edca = nullptr;
580 }
581 m_initialFrame = false;
582}
583
584void
586{
587 NS_LOG_FUNCTION(this);
588
589 // TODO This will be removed once no Txop is installed on a QoS station
590 if (!m_edca)
591 {
593 return;
594 }
595
596 if (m_initialFrame)
597 {
598 // The backoff procedure shall be invoked by an EDCAF when the transmission
599 // of an MPDU in the initial PPDU of a TXOP fails (Sec. 10.22.2.2 of 802.11-2016)
600 NS_LOG_DEBUG("TX of the initial frame of a TXOP failed: terminate TXOP");
602 m_edca = nullptr;
603 }
604 else
605 {
607 "Cannot transmit more than one frame if TXOP Limit is zero");
608
609 // A STA can perform a PIFS recovery or perform a backoff as a response to
610 // transmission failure within a TXOP. How it chooses between these two is
611 // implementation dependent. (Sec. 10.22.2.2 of 802.11-2016)
612 if (m_pifsRecovery)
613 {
614 // we can continue the TXOP if the carrier sense mechanism indicates that
615 // the medium is idle in a PIFS
616 NS_LOG_DEBUG("TX of a non-initial frame of a TXOP failed: perform PIFS recovery");
620 }
621 else
622 {
623 // In order not to terminate (yet) the TXOP, we call the NotifyChannelReleased
624 // method of the Txop class, which only generates a new backoff value and
625 // requests channel access if needed,
626 NS_LOG_DEBUG("TX of a non-initial frame of a TXOP failed: invoke backoff");
627 m_edca->Txop::NotifyChannelReleased(m_linkId);
629 m_edca = nullptr;
630 }
631 }
632 m_initialFrame = false;
633}
634
635void
637{
638 NS_LOG_FUNCTION(this << psdu << txVector);
639
640 SetTxopHolder(psdu, txVector);
641
642 // APs store buffer size report of associated stations
643 if (m_mac->GetTypeOfStation() == AP && psdu->GetAddr1() == m_self)
644 {
645 for (const auto& mpdu : *PeekPointer(psdu))
646 {
647 const WifiMacHeader& hdr = mpdu->GetHeader();
648
649 if (hdr.IsQosData() && hdr.IsQosEosp())
650 {
651 NS_LOG_DEBUG("Station " << hdr.GetAddr2() << " reported a buffer status of "
652 << +hdr.GetQosQueueSize()
653 << " for tid=" << +hdr.GetQosTid());
654 StaticCast<ApWifiMac>(m_mac)->SetBufferStatus(hdr.GetQosTid(),
655 hdr.GetAddr2(),
656 hdr.GetQosQueueSize());
657 }
658 }
659 }
660
662}
663
664void
666{
667 NS_LOG_FUNCTION(this << psdu << txVector);
668
669 const WifiMacHeader& hdr = psdu->GetHeader(0);
670
671 if (hdr.IsQosData() || hdr.IsMgt() || hdr.IsRts())
672 {
673 m_txopHolder = psdu->GetAddr2();
674 }
675 else if (hdr.IsCts() || hdr.IsAck())
676 {
677 m_txopHolder = psdu->GetAddr1();
678 }
679}
680
681void
683 RxSignalInfo rxSignalInfo,
684 const WifiTxVector& txVector,
685 bool inAmpdu)
686{
687 // The received MPDU is either broadcast or addressed to this station
688 NS_ASSERT(mpdu->GetHeader().GetAddr1().IsGroup() || mpdu->GetHeader().GetAddr1() == m_self);
689
690 double rxSnr = rxSignalInfo.snr;
691 const WifiMacHeader& hdr = mpdu->GetHeader();
692
693 if (hdr.IsCfEnd())
694 {
695 // reset NAV
697 return;
698 }
699
700 if (hdr.IsRts())
701 {
702 NS_ABORT_MSG_IF(inAmpdu, "Received RTS as part of an A-MPDU");
703
704 // If a non-VHT STA receives an RTS frame with the RA address matching the
705 // MAC address of the STA and the MAC address in the TA field in the RTS
706 // frame matches the saved TXOP holder address, then the STA shall send the
707 // CTS frame after SIFS, without regard for, and without resetting, its NAV.
708 // (sec. 10.22.2.4 of 802.11-2016)
709 if (hdr.GetAddr2() == m_txopHolder || m_navEnd <= Simulator::Now())
710 {
711 NS_LOG_DEBUG("Received RTS from=" << hdr.GetAddr2() << ", schedule CTS");
714 this,
715 hdr,
716 txVector.GetMode(),
717 rxSnr);
718 }
719 else
720 {
721 NS_LOG_DEBUG("Received RTS from=" << hdr.GetAddr2() << ", cannot schedule CTS");
722 }
723 return;
724 }
725
726 if (hdr.IsQosData())
727 {
729 {
730 NS_LOG_DEBUG("Received " << hdr.GetTypeString() << " from=" << hdr.GetAddr2()
731 << ", schedule ACK");
734 this,
735 hdr,
736 txVector,
737 rxSnr);
738 }
739
740 // Forward up the frame if it is not a QoS Null frame
741 if (hdr.HasData())
742 {
743 m_rxMiddle->Receive(mpdu, m_linkId);
744 }
745
746 // the received data frame has been processed
747 return;
748 }
749
750 return FrameExchangeManager::ReceiveMpdu(mpdu, rxSignalInfo, txVector, inAmpdu);
751}
752
753} // namespace ns3
#define max(a, b)
Definition: 80211b.c:43
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
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 SendMpduWithProtection(Ptr< WifiMpdu > mpdu, WifiTxParameters &txParams)
Send an MPDU with the given TX parameters (with the specified protection).
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.
void SendNormalAck(const WifiMacHeader &hdr, const WifiTxVector &dataTxVector, double dataSnr)
Send Normal Ack.
Mac48Address m_self
the MAC address of this device
virtual void TransmissionFailed()
Take necessary actions upon a transmission failure.
uint16_t m_allowedWidth
the allowed width in MHz for the current transmission
WifiTxTimer m_txTimer
the timer set upon frame transmission
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr)
Send CTS after receiving RTS.
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 ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector)
Forward an MPDU down to the PHY layer.
virtual void CalculateProtectionTime(WifiProtection *protection) const
Calculate the time required to protect a frame according to the given protection method.
Ptr< WifiAckManager > GetAckManager() const
Get the Acknowledgment Manager used by this node.
virtual void NavResetTimeout()
Reset the NAV upon expiration of the NAV reset timer.
Ptr< WifiProtectionManager > GetProtectionManager() const
Get the Protection Manager used by this node.
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.
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...
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
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)
Time m_navEnd
NAV expiration time.
void DoDispose() override
Destructor implementation.
virtual bool StartTransmission(Ptr< Txop > dcf, uint16_t allowedWidth)
Request the FrameExchangeManager to start a frame exchange sequence.
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
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
QosFrameExchangeManager handles the frame exchange sequences for QoS stations.
EventId m_pifsRecoveryEvent
event associated with an attempt of PIFS recovery
void ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector) override
Forward an MPDU down to the PHY layer.
void ReceiveMpdu(Ptr< const WifiMpdu > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu) override
This method handles the reception of an MPDU (possibly included in an A-MPDU)
void TransmissionFailed() override
Take necessary actions upon a transmission failure.
virtual bool StartFrameExchange(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Start a frame exchange (including protection frames and acknowledgment frames as needed) that fits wi...
virtual void SetTxopHolder(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Set the TXOP holder, if needed, based on the received frame.
Time GetFrameDurationId(const WifiMacHeader &header, uint32_t size, const WifiTxParameters &txParams, Ptr< Packet > fragmentedPacket) const override
Compute how to set the Duration/ID field of a frame being transmitted with the given TX parameters.
Time GetCtsToSelfDurationId(const WifiTxVector &ctsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of a CTS-to-self frame to send to protect a frame transmitte...
Ptr< QosTxop > m_edca
the EDCAF that gained channel access
virtual bool IsWithinLimitsIfAddMpdu(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the given MPDU can be added to the frame being built (as described by the given TX para...
Mac48Address m_txopHolder
MAC address of the TXOP holder.
bool StartTransmission(Ptr< Txop > edca, uint16_t allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
Time GetRtsDurationId(const WifiTxVector &rtsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of an RTS frame to send to protect a frame transmitted with ...
virtual bool SendCfEndIfNeeded()
Send a CF-End frame to indicate the completion of the TXOP, provided that the remaining duration is l...
bool m_initialFrame
true if transmitting the initial frame of a TXOP
void TransmissionSucceeded() override
Take necessary actions upon a transmission success.
static TypeId GetTypeId()
Get the type ID.
bool m_pifsRecovery
true if performing a PIFS recovery after failure
Ptr< Txop > m_edcaBackingOff
channel access function that invoked backoff during TXOP
void PreProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Perform actions that are possibly needed when receiving any frame, independently of whether the frame...
bool m_setQosQueueSize
whether to set the Queue Size subfield of the QoS Control field of QoS data frames
void PifsRecovery()
Perform a PIFS recovery as a response to transmission failure within a TXOP.
virtual bool IsWithinSizeAndTimeLimits(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the transmission time of the frame being built (as described by the given TX parameters...
void CancelPifsRecovery()
Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery release the channel.
bool TryAddMpdu(Ptr< const WifiMpdu > mpdu, WifiTxParameters &txParams, Time availableTime) const
Recompute the protection and acknowledgment methods to use if the given MPDU is added to the frame be...
void DoDispose() override
Destructor implementation.
void NotifyChannelReleased(uint8_t linkId) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: qos-txop.cc:566
virtual Time GetRemainingTxop(uint8_t linkId) const
Return the remaining duration in the current TXOP on the given link.
Definition: qos-txop.cc:581
Ptr< WifiMpdu > PeekNextMpdu(uint8_t linkId, uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast(), Ptr< WifiMpdu > item=nullptr)
Peek the next frame to transmit on the given link to the given receiver and of the given TID from the...
Definition: qos-txop.cc:368
Ptr< WifiMpdu > GetNextMpdu(uint8_t linkId, Ptr< WifiMpdu > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame)
Prepare the frame to transmit on the given link starting from the MPDU that has been previously peeke...
Definition: qos-txop.cc:454
void NotifyChannelAccessed(uint8_t linkId, Time txopDuration) override
Called by the FrameExchangeManager to notify that channel access has been granted on the given link f...
Definition: qos-txop.cc:547
virtual bool IsTxopStarted(uint8_t linkId) const
Return true if a TXOP has started on the given link.
Definition: qos-txop.cc:558
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition: nstime.h:350
bool IsNegative() const
Exactly equivalent to t <= 0.
Definition: nstime.h:323
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
Definition: nstime.h:286
@ MS
millisecond
Definition: nstime.h:117
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:417
bool IsZero() const
Exactly equivalent to t == 0.
Definition: nstime.h:314
Time GetTxopLimit() const
Return the TXOP limit.
Definition: txop.cc:473
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: txop.cc:585
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:646
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
bool IsAck() const
Return true if the header is an Ack header.
bool IsCts() const
Return true if the header is a CTS header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
void SetNoMoreFragments()
Un-set the More Fragment bit in the Frame Control Field.
bool IsMgt() const
Return true if the Type is Management.
uint32_t GetSize() const
Return the size of the WifiMacHeader in octets.
bool IsCfEnd() const
Return true if the header is a CF-End header.
void SetDsNotFrom()
Un-set the From DS bit in the Frame Control field.
bool IsQosEosp() const
Return if the end of service period (EOSP) is set.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetQosQueueSize(uint8_t size)
Set the Queue Size subfield in the QoS control field.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
Mac48Address GetAddr2() const
Return the address in the Address 2 field.
const char * GetTypeString() const
Return a string corresponds to the header type.
bool HasData() const
Return true if the header type is DATA and is not DATA_NULL.
QosAckPolicy GetQosAckPolicy() const
Return the QoS Ack policy in the QoS control field.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
bool IsRts() const
Return true if the header is a RTS header.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
uint8_t GetQosQueueSize() const
Get the Queue Size subfield in the QoS control field.
void SetDsNotTo()
Un-set the To DS bit in the Frame Control field.
void SetNoRetry()
Un-set the Retry bit in the Frame Control field.
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument.
Definition: wifi-phy.cc:1635
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:728
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1422
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition: wifi-phy.cc:1451
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:950
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:752
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
Definition: wifi-psdu.cc:269
Mac48Address GetAddr2() const
Get the Transmitter Address (TA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:128
Mac48Address GetAddr1() const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition: wifi-psdu.cc:113
WifiTxVector GetDataTxVector(const WifiMacHeader &header, uint16_t allowedWidth)
WifiTxVector GetRtsTxVector(Mac48Address address)
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
std::unique_ptr< WifiProtection > m_protection
protection method
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
void AddMpdu(Ptr< const WifiMpdu > mpdu)
Record that an MPDU is being added to the current frame.
bool IsRunning() const
Return true if the timer is running.
void Cancel()
Cancel the timer.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
WifiPreamble GetPreambleType() const
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:850
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:488
@ STA
Definition: wifi-mac.h:60
@ AP
Definition: wifi-mac.h:61
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
uint32_t GetRtsSize()
Return the total RTS size (including FCS trailer).
Definition: wifi-utils.cc:103
@ WIFI_MAC_CTL_END
uint32_t GetCtsSize()
Return the total CTS size (including FCS trailer).
Definition: wifi-utils.cc:111
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:70
double snr
SNR in linear scale.
Definition: phy-entity.h:71