A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
txop.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#include "txop.h"
10
12#include "mac-tx-middle.h"
14#include "wifi-mac-queue.h"
15#include "wifi-mac-trailer.h"
16#include "wifi-mac.h"
17#include "wifi-phy.h"
18
19#include "ns3/attribute-container.h"
20#include "ns3/log.h"
21#include "ns3/pointer.h"
22#include "ns3/shuffle.h"
23#include "ns3/simulator.h"
24#include "ns3/socket.h"
25
26#include <iterator>
27#include <sstream>
28
29#undef NS_LOG_APPEND_CONTEXT
30#define NS_LOG_APPEND_CONTEXT WIFI_TXOP_NS_LOG_APPEND_CONTEXT
31
32namespace ns3
33{
34
36
38
39TypeId
41{
42 static TypeId tid =
43 TypeId("ns3::Txop")
45 .SetGroupName("Wifi")
46 .AddConstructor<Txop>()
47 .AddAttribute("AcIndex",
48 "The AC index of the packets contained in the wifi MAC queue of this "
49 "Txop object.",
53 "AC_BE",
54 AC_BK,
55 "AC_BK",
56 AC_VI,
57 "AC_VI",
58 AC_VO,
59 "AC_VO",
61 "AC_BE_NQOS",
62 AC_VI,
63 "AC_VI",
65 "AC_BEACON",
67 "AC_UNDEF"))
68 .AddAttribute("MinCw",
69 "The minimum value of the contention window (just for the first link, "
70 "in case of 11be multi-link devices).",
71 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
72 UintegerValue(15),
74 (uint32_t(Txop::*)() const) & Txop::GetMinCw),
77 "Use MinCws attribute instead of MinCw")
78 .AddAttribute(
79 "MinCws",
80 "The minimum values of the contention window for all the links (sorted in "
81 "increasing order of link ID). An empty vector is ignored and the default value "
82 "as per Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
83 "this is a non-AP STA, these values could be overridden by values advertised by "
84 "the AP through EDCA Parameter Set elements.",
88 .AddAttribute("MaxCw",
89 "The maximum value of the contention window (just for the first link, "
90 "in case of 11be multi-link devices).",
91 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
92 UintegerValue(1023),
94 (uint32_t(Txop::*)() const) & Txop::GetMaxCw),
97 "Use MaxCws attribute instead of MaxCw")
98 .AddAttribute(
99 "MaxCws",
100 "The maximum values of the contention window for all the links (sorted in "
101 "increasing order of link ID). An empty vector is ignored and the default value "
102 "as per Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
103 "this is a non-AP STA, these values could be overridden by values advertised by "
104 "the AP through EDCA Parameter Set elements.",
108 .AddAttribute(
109 "Aifsn",
110 "The AIFSN: the default value conforms to non-QOS (just for the first link, "
111 "in case of 11be multi-link devices).",
112 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
113 UintegerValue(2),
114 MakeUintegerAccessor((void(Txop::*)(uint8_t)) & Txop::SetAifsn,
115 (uint8_t(Txop::*)() const) & Txop::GetAifsn),
118 "Use Aifsns attribute instead of Aifsn")
119 .AddAttribute(
120 "Aifsns",
121 "The values of AIFSN for all the links (sorted in increasing order "
122 "of link ID). An empty vector is ignored and the default value as per "
123 "Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
124 "this is a non-AP STA, these values could be overridden by values advertised by "
125 "the AP through EDCA Parameter Set elements.",
129 .AddAttribute("TxopLimit",
130 "The TXOP limit: the default value conforms to non-QoS "
131 "(just for the first link, in case of 11be multi-link devices).",
132 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
135 (Time(Txop::*)() const) & Txop::GetTxopLimit),
138 "Use TxopLimits attribute instead of TxopLimit")
139 .AddAttribute(
140 "TxopLimits",
141 "The values of TXOP limit for all the links (sorted in increasing order "
142 "of link ID). An empty vector is ignored and the default value as per "
143 "Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
144 "this is a non-AP STA, these values could be overridden by values advertised by "
145 "the AP through EDCA Parameter Set elements.",
150 .AddAttribute("Queue",
151 "The WifiMacQueue object",
152 PointerValue(),
155 .AddTraceSource("BackoffTrace",
156 "Trace source for backoff values",
158 "ns3::Txop::BackoffValueTracedCallback")
159 .AddTraceSource("CwTrace",
160 "Trace source for contention window values",
162 "ns3::Txop::CwValueTracedCallback");
163 return tid;
164}
165
171
173{
174 NS_LOG_FUNCTION(this);
175}
176
177void
179{
180 NS_LOG_FUNCTION(this);
181 m_queue = nullptr;
182 m_mac = nullptr;
183 m_rng = nullptr;
184 m_txMiddle = nullptr;
185 m_links.clear();
186}
187
188void
190{
191 NS_LOG_FUNCTION(this << aci);
192 NS_ABORT_MSG_IF(m_queue, "Wifi MAC queue can only be created once");
194}
195
196std::unique_ptr<Txop::LinkEntity>
198{
199 return std::make_unique<LinkEntity>();
200}
201
203Txop::GetLink(uint8_t linkId) const
204{
205 auto it = m_links.find(linkId);
206 NS_ASSERT(it != m_links.cend());
207 NS_ASSERT(it->second); // check that the pointer owns an object
208 return *it->second;
209}
210
211const std::map<uint8_t, std::unique_ptr<Txop::LinkEntity>>&
213{
214 return m_links;
215}
216
217void
218Txop::SwapLinks(std::map<uint8_t, uint8_t> links)
219{
220 NS_LOG_FUNCTION(this);
221
222 decltype(m_links) tmp;
223 tmp.swap(m_links); // move all links to temporary map
224 for (const auto& [from, to] : links)
225 {
226 auto nh = tmp.extract(from);
227 nh.key() = to;
228 m_links.insert(std::move(nh));
229 }
230 // move links remaining in tmp to m_links
231 m_links.merge(tmp);
232}
233
234void
236{
237 NS_LOG_FUNCTION(this);
238 m_txMiddle = txMiddle;
239}
240
241void
243{
244 NS_LOG_FUNCTION(this << mac);
245 m_mac = mac;
246 for (const auto linkId : m_mac->GetLinkIds())
247 {
248 m_links.emplace(linkId, CreateLinkEntity());
249 }
250}
251
252void
254{
255 NS_LOG_FUNCTION(this << &callback);
256 m_droppedMpduCallback = callback;
257 m_queue->TraceConnectWithoutContext("DropBeforeEnqueue",
259 m_queue->TraceConnectWithoutContext("Expired",
261}
262
265{
266 return m_queue;
267}
268
269void
271{
272 SetMinCw(minCw, 0);
273}
274
275void
276Txop::SetMinCws(const std::vector<uint32_t>& minCws)
277{
278 if (minCws.empty())
279 {
280 // an empty vector is passed to use the default values specified by the standard
281 return;
282 }
283
284 NS_ABORT_MSG_IF(!m_links.empty() && minCws.size() != m_links.size(),
285 "The size of the given vector (" << minCws.size()
286 << ") does not match the number of links ("
287 << m_links.size() << ")");
288 m_userAccessParams.cwMins = minCws;
289
290 std::size_t i = 0;
291 for (const auto& [id, link] : m_links)
292 {
293 SetMinCw(minCws[i++], id);
294 }
295}
296
297void
298Txop::SetMinCw(uint32_t minCw, uint8_t linkId)
299{
300 NS_LOG_FUNCTION(this << minCw << linkId);
301 NS_ASSERT_MSG(!m_links.empty(),
302 "This function can only be called after that links have been created");
303 auto& link = GetLink(linkId);
304 bool changed = (link.cwMin != minCw);
305 link.cwMin = minCw;
306 if (changed)
307 {
308 ResetCw(linkId);
309 }
310}
311
312void
314{
315 SetMaxCw(maxCw, 0);
316}
317
318void
319Txop::SetMaxCws(const std::vector<uint32_t>& maxCws)
320{
321 if (maxCws.empty())
322 {
323 // an empty vector is passed to use the default values specified by the standard
324 return;
325 }
326
327 NS_ABORT_MSG_IF(!m_links.empty() && maxCws.size() != m_links.size(),
328 "The size of the given vector (" << maxCws.size()
329 << ") does not match the number of links ("
330 << m_links.size() << ")");
331 m_userAccessParams.cwMaxs = maxCws;
332
333 std::size_t i = 0;
334 for (const auto& [id, link] : m_links)
335 {
336 SetMaxCw(maxCws[i++], id);
337 }
338}
339
340void
341Txop::SetMaxCw(uint32_t maxCw, uint8_t linkId)
342{
343 NS_LOG_FUNCTION(this << maxCw << linkId);
344 NS_ASSERT_MSG(!m_links.empty(),
345 "This function can only be called after that links have been created");
346 auto& link = GetLink(linkId);
347 bool changed = (link.cwMax != maxCw);
348 link.cwMax = maxCw;
349 if (changed)
350 {
351 ResetCw(linkId);
352 }
353}
354
356Txop::GetCw(uint8_t linkId) const
357{
358 return GetLink(linkId).cw;
359}
360
361std::size_t
362Txop::GetStaRetryCount(uint8_t linkId) const
363{
364 return GetLink(linkId).staRetryCount;
365}
366
367void
368Txop::ResetCw(uint8_t linkId)
369{
370 NS_LOG_FUNCTION(this << linkId);
371 auto& link = GetLink(linkId);
372 link.cw = GetMinCw(linkId);
373 m_cwTrace(link.cw, linkId);
374 link.staRetryCount = 0;
375}
376
377void
378Txop::UpdateFailedCw(uint8_t linkId)
379{
380 NS_LOG_FUNCTION(this << linkId);
381 auto& link = GetLink(linkId);
382
383 if (link.staRetryCount < m_mac->GetFrameRetryLimit())
384 {
385 // If QSRC[AC] is less than dot11ShortRetryLimit,
386 // - QSRC[AC] shall be incremented by 1.
387 // - CW[AC] shall be set to the lesser of CWmax[AC] and 2^QSRC[AC] × (CWmin[AC] + 1) – 1.
388 // (Section 10.23.2.2 of 802.11-2020)
389 ++link.staRetryCount;
390 link.cw =
391 std::min(GetMaxCw(linkId), (1 << link.staRetryCount) * (GetMinCw(linkId) + 1) - 1);
392 }
393 else
394 {
395 // Else
396 // - QSRC[AC] shall be set to 0.
397 // - CW[AC] shall be set to CWmin[AC].
398 link.staRetryCount = 0;
399 link.cw = GetMinCw(linkId);
400 }
401
402 m_cwTrace(link.cw, linkId);
403}
404
406Txop::GetBackoffSlots(uint8_t linkId) const
407{
408 return GetLink(linkId).backoffSlots;
409}
410
411Time
412Txop::GetBackoffStart(uint8_t linkId) const
413{
414 return GetLink(linkId).backoffStart;
415}
416
417void
418Txop::UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
419{
420 NS_LOG_FUNCTION(this << nSlots << backoffUpdateBound << linkId);
421 auto& link = GetLink(linkId);
422
423 link.backoffSlots -= nSlots;
424 link.backoffStart = backoffUpdateBound;
425 NS_LOG_DEBUG("update slots=" << nSlots << " slots, backoff=" << link.backoffSlots);
426}
427
428void
429Txop::StartBackoffNow(uint32_t nSlots, uint8_t linkId)
430{
431 NS_LOG_FUNCTION(this << nSlots << linkId);
432 auto& link = GetLink(linkId);
433
434 if (link.backoffSlots != 0)
435 {
436 NS_LOG_DEBUG("reset backoff from " << link.backoffSlots << " to " << nSlots << " slots");
437 }
438 else
439 {
440 NS_LOG_DEBUG("start backoff=" << nSlots << " slots");
441 }
442 link.backoffSlots = nSlots;
443 link.backoffStart = Simulator::Now();
444}
445
446void
447Txop::SetAifsn(uint8_t aifsn)
448{
449 SetAifsn(aifsn, 0);
450}
451
452void
453Txop::SetAifsns(const std::vector<uint8_t>& aifsns)
454{
455 if (aifsns.empty())
456 {
457 // an empty vector is passed to use the default values specified by the standard
458 return;
459 }
460
461 NS_ABORT_MSG_IF(!m_links.empty() && aifsns.size() != m_links.size(),
462 "The size of the given vector (" << aifsns.size()
463 << ") does not match the number of links ("
464 << m_links.size() << ")");
465 m_userAccessParams.aifsns = aifsns;
466
467 std::size_t i = 0;
468 for (const auto& [id, link] : m_links)
469 {
470 SetAifsn(aifsns[i++], id);
471 }
472}
473
474void
475Txop::SetAifsn(uint8_t aifsn, uint8_t linkId)
476{
477 NS_LOG_FUNCTION(this << aifsn << linkId);
478 NS_ASSERT_MSG(!m_links.empty(),
479 "This function can only be called after that links have been created");
480 GetLink(linkId).aifsn = aifsn;
481}
482
483void
485{
486 SetTxopLimit(txopLimit, 0);
487}
488
489void
490Txop::SetTxopLimits(const std::vector<Time>& txopLimits)
491{
492 if (txopLimits.empty())
493 {
494 // an empty vector is passed to use the default values specified by the standard
495 return;
496 }
497
498 NS_ABORT_MSG_IF(!m_links.empty() && txopLimits.size() != m_links.size(),
499 "The size of the given vector (" << txopLimits.size()
500 << ") does not match the number of links ("
501 << m_links.size() << ")");
502 m_userAccessParams.txopLimits = txopLimits;
503
504 std::size_t i = 0;
505 for (const auto& [id, link] : m_links)
506 {
507 SetTxopLimit(txopLimits[i++], id);
508 }
509}
510
511void
512Txop::SetTxopLimit(Time txopLimit, uint8_t linkId)
513{
514 NS_LOG_FUNCTION(this << txopLimit << linkId);
515 NS_ASSERT_MSG(txopLimit.IsPositive(), "TXOP limit cannot be negative");
516 NS_ASSERT_MSG((txopLimit.GetMicroSeconds() % 32 == 0),
517 "The TXOP limit must be expressed in multiple of 32 microseconds!");
518 NS_ASSERT_MSG(!m_links.empty(),
519 "This function can only be called after that links have been created");
520 GetLink(linkId).txopLimit = txopLimit;
521}
522
525{
526 return m_userAccessParams;
527}
528
531{
532 return GetMinCw(0);
533}
534
535std::vector<uint32_t>
537{
538 std::vector<uint32_t> ret;
539 ret.reserve(m_links.size());
540 for (const auto& [id, link] : m_links)
541 {
542 ret.push_back(link->cwMin);
543 }
544 return ret;
545}
546
548Txop::GetMinCw(uint8_t linkId) const
549{
550 return GetLink(linkId).cwMin;
551}
552
555{
556 return GetMaxCw(0);
557}
558
559std::vector<uint32_t>
561{
562 std::vector<uint32_t> ret;
563 ret.reserve(m_links.size());
564 for (const auto& [id, link] : m_links)
565 {
566 ret.push_back(link->cwMax);
567 }
568 return ret;
569}
570
572Txop::GetMaxCw(uint8_t linkId) const
573{
574 return GetLink(linkId).cwMax;
575}
576
577uint8_t
579{
580 return GetAifsn(0);
581}
582
583std::vector<uint8_t>
585{
586 std::vector<uint8_t> ret;
587 ret.reserve(m_links.size());
588 for (const auto& [id, link] : m_links)
589 {
590 ret.push_back(link->aifsn);
591 }
592 return ret;
593}
594
595uint8_t
596Txop::GetAifsn(uint8_t linkId) const
597{
598 return GetLink(linkId).aifsn;
599}
600
601Time
603{
604 return GetTxopLimit(0);
605}
606
607std::vector<Time>
609{
610 std::vector<Time> ret;
611 ret.reserve(m_links.size());
612 for (const auto& [id, link] : m_links)
613 {
614 ret.push_back(link->txopLimit);
615 }
616 return ret;
617}
618
619Time
620Txop::GetTxopLimit(uint8_t linkId) const
621{
622 return GetLink(linkId).txopLimit;
623}
624
625bool
627{
628 m_queue->WipeAllExpiredMpdus();
629 bool ret = static_cast<bool>(m_queue->Peek(linkId));
630 NS_LOG_FUNCTION(this << linkId << ret);
631 return ret;
632}
633
634void
636{
637 NS_LOG_FUNCTION(this << *mpdu);
638
639 // channel access can be requested on a blocked link, if the reason for blocking the link
640 // is temporary
641 auto linkIds = m_mac->GetMacQueueScheduler()->GetLinkIds(
642 m_queue->GetAc(),
643 mpdu,
644 {WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK,
645 WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY});
646
647 // ignore the links for which a channel access request event is already running
648 for (auto it = linkIds.begin(); it != linkIds.end();)
649 {
650 if (const auto& event = GetLink(*it).accessRequest.event; event.IsPending())
651 {
652 it = linkIds.erase(it);
653 }
654 else
655 {
656 ++it;
657 }
658 }
659
660 // save the status of the AC queues before enqueuing the MPDU (required to determine if
661 // backoff is needed)
662 std::map<uint8_t, bool> hasFramesToTransmit;
663 for (const auto linkId : linkIds)
664 {
665 hasFramesToTransmit[linkId] = HasFramesToTransmit(linkId);
666 }
667 m_queue->Enqueue(mpdu);
668
669 // shuffle link IDs not to request channel access on links always in the same order
670 std::vector<uint8_t> shuffledLinkIds(linkIds.cbegin(), linkIds.cend());
671 Shuffle(shuffledLinkIds.begin(), shuffledLinkIds.end(), m_shuffleLinkIdsGen.GetRv());
672
673 if (!linkIds.empty() && g_log.IsEnabled(ns3::LOG_DEBUG))
674 {
675 std::stringstream ss;
676 std::copy(shuffledLinkIds.cbegin(),
677 shuffledLinkIds.cend(),
678 std::ostream_iterator<uint16_t>(ss, " "));
679 NS_LOG_DEBUG("Request channel access on link IDs: " << ss.str());
680 }
681
682 for (const auto linkId : shuffledLinkIds)
683 {
684 // schedule a call to StartAccessIfNeeded() to request channel access after that all the
685 // packets of a burst have been enqueued, instead of requesting channel access right after
686 // the first packet. The call to StartAccessIfNeeded() is scheduled only after the first
687 // packet
689 this,
690 linkId,
691 hasFramesToTransmit.at(linkId),
693 }
694}
695
696int64_t
697Txop::AssignStreams(int64_t stream)
698{
699 NS_LOG_FUNCTION(this << stream);
700 m_rng->SetStream(stream);
701 return 1;
702}
703
704void
705Txop::StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
706{
707 NS_LOG_FUNCTION(this << linkId << hadFramesToTransmit << checkMediumBusy);
708
709 if (!m_mac->GetWifiPhy(linkId))
710 {
711 NS_LOG_DEBUG("No PHY operating on link " << +linkId);
712 return;
713 }
714
715 if (GetLink(linkId).access != NOT_REQUESTED)
716 {
717 NS_LOG_DEBUG("Channel access already requested or granted on link " << +linkId);
718 return;
719 }
720
721 if (!HasFramesToTransmit(linkId))
722 {
723 NS_LOG_DEBUG("No frames to transmit on link " << +linkId);
724 return;
725 }
726
727 if (m_mac->GetChannelAccessManager(linkId)->NeedBackoffUponAccess(this,
728 hadFramesToTransmit,
729 checkMediumBusy))
730 {
731 GenerateBackoff(linkId);
732 }
733
734 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
735}
736
737void
739{
740 NS_LOG_FUNCTION(this);
741 for (const auto& [id, link] : m_links)
742 {
743 ResetCw(id);
744 GenerateBackoff(id);
745 }
746}
747
749Txop::GetAccessStatus(uint8_t linkId) const
750{
751 return GetLink(linkId).access;
752}
753
754void
756{
757 NS_LOG_FUNCTION(this << linkId);
758 GetLink(linkId).access = REQUESTED;
759}
760
761void
762Txop::NotifyChannelAccessed(uint8_t linkId, Time txopDuration)
763{
764 NS_LOG_FUNCTION(this << linkId << txopDuration);
765 GetLink(linkId).access = GRANTED;
766}
767
768void
770{
771 NS_LOG_FUNCTION(this << linkId);
772 GetLink(linkId).access = NOT_REQUESTED;
773 GenerateBackoff(linkId);
774 if (HasFramesToTransmit(linkId))
775 {
777 }
778}
779
780void
781Txop::RequestAccess(uint8_t linkId)
782{
783 NS_LOG_FUNCTION(this << linkId);
784 if (GetLink(linkId).access == NOT_REQUESTED)
785 {
786 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
787 }
788}
789
790void
792{
793 uint32_t backoff = m_rng->GetInteger(0, GetCw(linkId));
794 NS_LOG_FUNCTION(this << linkId << backoff);
795 m_backoffTrace(backoff, linkId);
796 StartBackoffNow(backoff, linkId);
797}
798
799void
800Txop::NotifySleep(uint8_t linkId)
801{
802 NS_LOG_FUNCTION(this << linkId);
803}
804
805void
807{
808 NS_LOG_FUNCTION(this);
809 m_queue->Flush();
810}
811
812void
813Txop::NotifyWakeUp(uint8_t linkId)
814{
815 NS_LOG_FUNCTION(this << linkId);
816 // before wake up, no packet can be transmitted
818}
819
820void
822{
823 NS_LOG_FUNCTION(this);
824 for (const auto& [id, link] : m_links)
825 {
826 // before being turned on, no packet can be transmitted
828 }
829}
830
831bool
833{
834 return false;
835}
836
837} // namespace ns3
A container for one type of attribute.
auto Bind(BoundArgs &&... bargs)
Bind a variable number of arguments.
Definition callback.h:543
Hold variables of type enum.
Definition enum.h:52
A base class which provides memory management and object aggregation.
Definition object.h:78
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition simulator.h:594
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
bool IsPositive() const
Exactly equivalent to t >= 0.
Definition nstime.h:322
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:402
AttributeValue implementation for Time.
Definition nstime.h:1431
Handles the packet queue and stores DCF/EDCA access parameters (one Txop per AC).
Definition txop.h:56
Ptr< WifiMac > m_mac
the wifi MAC
Definition txop.h:568
Time GetTxopLimit() const
Return the TXOP limit.
Definition txop.cc:602
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
Definition txop.cc:197
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition txop.cc:697
virtual ChannelAccessStatus GetAccessStatus(uint8_t linkId) const
Definition txop.cc:749
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition txop.h:566
void StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
Request channel access on the given link after the occurrence of an event that possibly requires to g...
Definition txop.cc:705
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the Txop has frames to transmit over the given link.
Definition txop.cc:626
virtual void NotifyOff()
When off operation occurs, the queue gets cleaned up.
Definition txop.cc:806
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Definition txop.h:570
std::size_t GetStaRetryCount(uint8_t linkId) const
Get the Station Short Retry Count (SSRC) maintained by non-QoS stations or the QoS STA Retry Count (Q...
Definition txop.cc:362
Ptr< UniformRandomVariable > m_rng
the random stream
Definition txop.h:569
CwValueTracedCallback m_cwTrace
CW trace value.
Definition txop.h:578
void DoDispose() override
Destructor implementation.
Definition txop.cc:178
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition txop.cc:313
void SetMaxCws(const std::vector< uint32_t > &maxCws)
Set the maximum contention window size for each link.
Definition txop.cc:319
uint32_t GetMinCw() const
Return the minimum contention window size.
Definition txop.cc:530
ChannelAccessStatus
Enumeration for channel access status.
Definition txop.h:76
@ GRANTED
Definition txop.h:79
@ NOT_REQUESTED
Definition txop.h:77
@ REQUESTED
Definition txop.h:78
virtual void NotifyOn()
When on operation occurs, channel access will be started.
Definition txop.cc:821
void UpdateFailedCw(uint8_t linkId)
Update the value of the CW variable for the given link to take into account a transmission failure.
Definition txop.cc:378
void SetAifsns(const std::vector< uint8_t > &aifsns)
Set the number of slots that make up an AIFS for each link.
Definition txop.cc:453
static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT
no packet available for transmission was in the queue
Definition txop.h:409
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition txop.cc:264
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition txop.cc:242
virtual void NotifyWakeUp(uint8_t linkId)
When wake up operation occurs on a link, channel access on that link will be restarted.
Definition txop.cc:813
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition txop.cc:769
std::vector< uint32_t > GetMaxCws() const
Return the maximum contention window size for each link.
Definition txop.cc:560
virtual void Queue(Ptr< WifiMpdu > mpdu)
Definition txop.cc:635
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition txop.cc:484
virtual void CreateQueue(AcIndex aci)
Create a wifi MAC queue containing packets of the given AC.
Definition txop.cc:189
void ResetCw(uint8_t linkId)
Update the value of the CW variable for the given link to take into account a transmission success or...
Definition txop.cc:368
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition txop.cc:203
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition txop.cc:832
std::vector< uint32_t > GetMinCws() const
Return the minimum contention window size for each link.
Definition txop.cc:536
std::vector< uint8_t > GetAifsns() const
Return the number of slots that make up an AIFS for each link.
Definition txop.cc:584
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
Update backoff slots for the given link that nSlots has passed.
Definition txop.cc:418
Time GetBackoffStart(uint8_t linkId) const
Return the time when the backoff procedure started on the given link.
Definition txop.cc:412
void SetTxopLimits(const std::vector< Time > &txopLimits)
Set the TXOP limit for each link.
Definition txop.cc:490
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition txop.h:565
void SwapLinks(std::map< uint8_t, uint8_t > links)
Swap the links based on the information included in the given map.
Definition txop.cc:218
const UserDefinedAccessParams & GetUserAccessParams() const
Definition txop.cc:524
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition txop.cc:235
std::vector< Time > GetTxopLimits() const
Return the TXOP limit for each link.
Definition txop.cc:608
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition txop.cc:212
static TypeId GetTypeId()
Get the type ID.
Definition txop.cc:40
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition txop.cc:447
uint32_t GetCw(uint8_t linkId) const
Get the current value of the CW variable for the given link.
Definition txop.cc:356
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition txop.cc:253
UserDefinedAccessParams m_userAccessParams
user-defined DCF/EDCA access parameters
Definition txop.h:591
virtual void GenerateBackoff(uint8_t linkId)
Generate a new backoff for the given link now.
Definition txop.cc:791
BackoffValueTracedCallback m_backoffTrace
backoff trace value
Definition txop.h:577
virtual void NotifyAccessRequested(uint8_t linkId)
Notify that access request has been received for the given link.
Definition txop.cc:755
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition txop.h:567
static constexpr bool CHECK_MEDIUM_BUSY
generation of backoff (also) depends on the busy/idle state of the medium
Definition txop.h:411
~Txop() override
Definition txop.cc:172
void StartBackoffNow(uint32_t nSlots, uint8_t linkId)
Definition txop.cc:429
virtual void NotifyChannelAccessed(uint8_t linkId, Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted on the given link f...
Definition txop.cc:762
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of LinkEntity objects.
Definition txop.h:589
void SetMinCws(const std::vector< uint32_t > &minCws)
Set the minimum contention window size for each link.
Definition txop.cc:276
void RequestAccess(uint8_t linkId)
Request access to the ChannelAccessManager associated with the given link.
Definition txop.cc:781
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition txop.cc:270
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
Definition txop.cc:578
uint32_t GetBackoffSlots(uint8_t linkId) const
Return the current number of backoff slots on the given link.
Definition txop.cc:406
virtual void NotifySleep(uint8_t linkId)
Notify that the given link switched to sleep mode.
Definition txop.cc:800
static constexpr bool DONT_CHECK_MEDIUM_BUSY
generation of backoff is independent of the busy/idle state of the medium
Definition txop.h:413
uint32_t GetMaxCw() const
Return the maximum contention window size.
Definition txop.cc:554
void DoInitialize() override
Initialize() implementation.
Definition txop.cc:738
a unique identifier for an interface.
Definition type-id.h:48
@ ATTR_GET
The attribute can be read.
Definition type-id.h:53
@ ATTR_SET
The attribute can be written.
Definition type-id.h:54
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
Definition type-id.h:65
Hold an unsigned integer type.
Definition uinteger.h:34
Ptr< UniformRandomVariable > GetRv() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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:75
Ptr< AttributeChecker > MakeAttributeContainerChecker()
Make uninitialized AttributeContainerChecker using explicit types.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition enum.h:221
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition nstime.h:1432
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1452
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
@ WIFI_MAC_DROP_FAILED_ENQUEUE
Definition wifi-mac.h:71
@ WIFI_MAC_DROP_EXPIRED_LIFETIME
Definition wifi-mac.h:72
@ AC_BE_NQOS
Non-QoS.
Definition qos-utils.h:72
@ AC_BE
Best Effort.
Definition qos-utils.h:64
@ AC_VO
Voice.
Definition qos-utils.h:70
@ AC_VI
Video.
Definition qos-utils.h:68
@ AC_BK
Background.
Definition qos-utils.h:66
@ AC_UNDEF
Total number of ACs.
Definition qos-utils.h:76
@ AC_BEACON
Beacon queue.
Definition qos-utils.h:74
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:179
void Shuffle(RND_ACCESS_ITER first, RND_ACCESS_ITER last, Ptr< UniformRandomVariable > rv)
Shuffle the elements in the range first to last.
Definition shuffle.h:48
@ LOG_DEBUG
Full voluminous logging to support debugging.
Definition log.h:101
DCF/EDCA access parameters for all the links provided by users via this class' attributes or the corr...
Definition txop.h:449
std::vector< uint32_t > cwMins
the minimum contention window values for all the links
Definition txop.h:450
std::vector< uint8_t > aifsns
the AIFSN values for all the links
Definition txop.h:452
std::vector< uint32_t > cwMaxs
the maximum contention window values for all the links
Definition txop.h:451
std::vector< Time > txopLimits
TXOP limit values for all the links.
Definition txop.h:453