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 // NS_DEPRECATED_3_42
69 .AddAttribute(
70 "MinCw",
71 "The minimum value of the contention window (just for the first link, "
72 "in case of 11be multi-link devices).",
73 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
74 UintegerValue(15),
75 MakeUintegerAccessor(static_cast<void (Txop::*)(uint32_t)>(&Txop::SetMinCw),
76 static_cast<uint32_t (Txop::*)() const>(&Txop::GetMinCw)),
79 "Use MinCws attribute instead of MinCw")
80 .AddAttribute(
81 "MinCws",
82 "The minimum values of the contention window for all the links (sorted in "
83 "increasing order of link ID). An empty vector is ignored and the default value "
84 "as per Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
85 "this is a non-AP STA, these values could be overridden by values advertised by "
86 "the AP through EDCA Parameter Set elements.",
90 // NS_DEPRECATED_3_42
91 .AddAttribute(
92 "MaxCw",
93 "The maximum value of the contention window (just for the first link, "
94 "in case of 11be multi-link devices).",
95 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
96 UintegerValue(1023),
97 MakeUintegerAccessor(static_cast<void (Txop::*)(uint32_t)>(&Txop::SetMaxCw),
98 static_cast<uint32_t (Txop::*)() const>(&Txop::GetMaxCw)),
101 "Use MaxCws attribute instead of MaxCw")
102 .AddAttribute(
103 "MaxCws",
104 "The maximum values of the contention window for all the links (sorted in "
105 "increasing order of link ID). An empty vector is ignored and the default value "
106 "as per Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
107 "this is a non-AP STA, these values could be overridden by values advertised by "
108 "the AP through EDCA Parameter Set elements.",
112 // NS_DEPRECATED_3_42
113 .AddAttribute(
114 "Aifsn",
115 "The AIFSN: the default value conforms to non-QOS (just for the first link, "
116 "in case of 11be multi-link devices).",
117 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
118 UintegerValue(2),
119 MakeUintegerAccessor(static_cast<void (Txop::*)(uint8_t)>(&Txop::SetAifsn),
120 static_cast<uint8_t (Txop::*)() const>(&Txop::GetAifsn)),
123 "Use Aifsns attribute instead of Aifsn")
124 .AddAttribute(
125 "Aifsns",
126 "The values of AIFSN for all the links (sorted in increasing order "
127 "of link ID). An empty vector is ignored and the default value as per "
128 "Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
129 "this is a non-AP STA, these values could be overridden by values advertised by "
130 "the AP through EDCA Parameter Set elements.",
134 // NS_DEPRECATED_3_42
135 .AddAttribute(
136 "TxopLimit",
137 "The TXOP limit: the default value conforms to non-QoS "
138 "(just for the first link, in case of 11be multi-link devices).",
139 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
141 MakeTimeAccessor(static_cast<void (Txop::*)(Time)>(&Txop::SetTxopLimit),
142 static_cast<Time (Txop::*)() const>(&Txop::GetTxopLimit)),
145 "Use TxopLimits attribute instead of TxopLimit")
146 .AddAttribute(
147 "TxopLimits",
148 "The values of TXOP limit for all the links (sorted in increasing order "
149 "of link ID). An empty vector is ignored and the default value as per "
150 "Table 9-155 of the IEEE 802.11-2020 standard will be used. Note that, if "
151 "this is a non-AP STA, these values could be overridden by values advertised by "
152 "the AP through EDCA Parameter Set elements.",
157 .AddAttribute("Queue",
158 "The WifiMacQueue object",
159 PointerValue(),
162 .AddTraceSource("BackoffTrace",
163 "Trace source for backoff values",
165 "ns3::Txop::BackoffValueTracedCallback")
166 .AddTraceSource("CwTrace",
167 "Trace source for contention window values",
169 "ns3::Txop::CwValueTracedCallback");
170 return tid;
171}
172
178
180{
181 NS_LOG_FUNCTION(this);
182}
183
184void
186{
187 NS_LOG_FUNCTION(this);
188 m_queue = nullptr;
189 m_mac = nullptr;
190 m_rng = nullptr;
191 m_txMiddle = nullptr;
192 m_links.clear();
193}
194
195void
197{
198 NS_LOG_FUNCTION(this << aci);
199 NS_ABORT_MSG_IF(m_queue, "Wifi MAC queue can only be created once");
201}
202
203std::unique_ptr<Txop::LinkEntity>
205{
206 return std::make_unique<LinkEntity>();
207}
208
210Txop::GetLink(uint8_t linkId) const
211{
212 auto it = m_links.find(linkId);
213 NS_ASSERT(it != m_links.cend());
214 NS_ASSERT(it->second); // check that the pointer owns an object
215 return *it->second;
216}
217
218const std::map<uint8_t, std::unique_ptr<Txop::LinkEntity>>&
220{
221 return m_links;
222}
223
224void
225Txop::SwapLinks(std::map<uint8_t, uint8_t> links)
226{
227 NS_LOG_FUNCTION(this);
228
229 decltype(m_links) tmp;
230 tmp.swap(m_links); // move all links to temporary map
231 for (const auto& [from, to] : links)
232 {
233 auto nh = tmp.extract(from);
234 nh.key() = to;
235 m_links.insert(std::move(nh));
236 }
237 // move links remaining in tmp to m_links
238 m_links.merge(tmp);
239}
240
241void
243{
244 NS_LOG_FUNCTION(this);
245 m_txMiddle = txMiddle;
246}
247
248void
250{
251 NS_LOG_FUNCTION(this << mac);
252 m_mac = mac;
253 for (const auto linkId : m_mac->GetLinkIds())
254 {
255 m_links.emplace(linkId, CreateLinkEntity());
256 }
257}
258
259void
261{
262 NS_LOG_FUNCTION(this << &callback);
263 m_droppedMpduCallback = callback;
264 m_queue->TraceConnectWithoutContext("DropBeforeEnqueue",
266 m_queue->TraceConnectWithoutContext("Expired",
268}
269
272{
273 return m_queue;
274}
275
276void
278{
279 SetMinCw(minCw, 0);
280}
281
282void
283Txop::SetMinCws(const std::vector<uint32_t>& minCws)
284{
285 if (minCws.empty())
286 {
287 // an empty vector is passed to use the default values specified by the standard
288 return;
289 }
290
291 NS_ABORT_MSG_IF(!m_links.empty() && minCws.size() != m_links.size(),
292 "The size of the given vector (" << minCws.size()
293 << ") does not match the number of links ("
294 << m_links.size() << ")");
295 m_userAccessParams.cwMins = minCws;
296
297 std::size_t i = 0;
298 for (const auto& [id, link] : m_links)
299 {
300 SetMinCw(minCws[i++], id);
301 }
302}
303
304void
305Txop::SetMinCw(uint32_t minCw, uint8_t linkId)
306{
307 NS_LOG_FUNCTION(this << minCw << linkId);
308 NS_ASSERT_MSG(!m_links.empty(),
309 "This function can only be called after that links have been created");
310 auto& link = GetLink(linkId);
311 bool changed = (link.cwMin != minCw);
312 link.cwMin = minCw;
313 if (changed)
314 {
315 ResetCw(linkId);
316 }
317}
318
319void
321{
322 SetMaxCw(maxCw, 0);
323}
324
325void
326Txop::SetMaxCws(const std::vector<uint32_t>& maxCws)
327{
328 if (maxCws.empty())
329 {
330 // an empty vector is passed to use the default values specified by the standard
331 return;
332 }
333
334 NS_ABORT_MSG_IF(!m_links.empty() && maxCws.size() != m_links.size(),
335 "The size of the given vector (" << maxCws.size()
336 << ") does not match the number of links ("
337 << m_links.size() << ")");
338 m_userAccessParams.cwMaxs = maxCws;
339
340 std::size_t i = 0;
341 for (const auto& [id, link] : m_links)
342 {
343 SetMaxCw(maxCws[i++], id);
344 }
345}
346
347void
348Txop::SetMaxCw(uint32_t maxCw, uint8_t linkId)
349{
350 NS_LOG_FUNCTION(this << maxCw << linkId);
351 NS_ASSERT_MSG(!m_links.empty(),
352 "This function can only be called after that links have been created");
353 auto& link = GetLink(linkId);
354 bool changed = (link.cwMax != maxCw);
355 link.cwMax = maxCw;
356 if (changed)
357 {
358 ResetCw(linkId);
359 }
360}
361
363Txop::GetCw(uint8_t linkId) const
364{
365 return GetLink(linkId).cw;
366}
367
368std::size_t
369Txop::GetStaRetryCount(uint8_t linkId) const
370{
371 return GetLink(linkId).staRetryCount;
372}
373
374void
375Txop::ResetCw(uint8_t linkId)
376{
377 NS_LOG_FUNCTION(this << linkId);
378 auto& link = GetLink(linkId);
379 link.cw = GetMinCw(linkId);
380 m_cwTrace(link.cw, linkId);
381 link.staRetryCount = 0;
382}
383
384void
385Txop::UpdateFailedCw(uint8_t linkId)
386{
387 NS_LOG_FUNCTION(this << linkId);
388 auto& link = GetLink(linkId);
389
390 if (link.staRetryCount < m_mac->GetFrameRetryLimit())
391 {
392 // If QSRC[AC] is less than dot11ShortRetryLimit,
393 // - QSRC[AC] shall be incremented by 1.
394 // - CW[AC] shall be set to the lesser of CWmax[AC] and 2^QSRC[AC] × (CWmin[AC] + 1) – 1.
395 // (Section 10.23.2.2 of 802.11-2020)
396 ++link.staRetryCount;
397 link.cw =
398 std::min(GetMaxCw(linkId), (1 << link.staRetryCount) * (GetMinCw(linkId) + 1) - 1);
399 }
400 else
401 {
402 // Else
403 // - QSRC[AC] shall be set to 0.
404 // - CW[AC] shall be set to CWmin[AC].
405 link.staRetryCount = 0;
406 link.cw = GetMinCw(linkId);
407 }
408
409 m_cwTrace(link.cw, linkId);
410}
411
413Txop::GetBackoffSlots(uint8_t linkId) const
414{
415 return GetLink(linkId).backoffSlots;
416}
417
418Time
419Txop::GetBackoffStart(uint8_t linkId) const
420{
421 return GetLink(linkId).backoffStart;
422}
423
424void
425Txop::UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
426{
427 NS_LOG_FUNCTION(this << nSlots << backoffUpdateBound << linkId);
428 auto& link = GetLink(linkId);
429
430 link.backoffSlots -= nSlots;
431 link.backoffStart = backoffUpdateBound;
432 NS_LOG_DEBUG("update slots=" << nSlots << " slots, backoff=" << link.backoffSlots);
433}
434
435void
436Txop::StartBackoffNow(uint32_t nSlots, uint8_t linkId)
437{
438 NS_LOG_FUNCTION(this << nSlots << linkId);
439 auto& link = GetLink(linkId);
440
441 if (link.backoffSlots != 0)
442 {
443 NS_LOG_DEBUG("reset backoff from " << link.backoffSlots << " to " << nSlots << " slots");
444 }
445 else
446 {
447 NS_LOG_DEBUG("start backoff=" << nSlots << " slots");
448 }
449 link.backoffSlots = nSlots;
450 link.backoffStart = Simulator::Now();
451}
452
453void
454Txop::SetAifsn(uint8_t aifsn)
455{
456 SetAifsn(aifsn, 0);
457}
458
459void
460Txop::SetAifsns(const std::vector<uint8_t>& aifsns)
461{
462 if (aifsns.empty())
463 {
464 // an empty vector is passed to use the default values specified by the standard
465 return;
466 }
467
468 NS_ABORT_MSG_IF(!m_links.empty() && aifsns.size() != m_links.size(),
469 "The size of the given vector (" << aifsns.size()
470 << ") does not match the number of links ("
471 << m_links.size() << ")");
472 m_userAccessParams.aifsns = aifsns;
473
474 std::size_t i = 0;
475 for (const auto& [id, link] : m_links)
476 {
477 SetAifsn(aifsns[i++], id);
478 }
479}
480
481void
482Txop::SetAifsn(uint8_t aifsn, uint8_t linkId)
483{
484 NS_LOG_FUNCTION(this << aifsn << linkId);
485 NS_ASSERT_MSG(!m_links.empty(),
486 "This function can only be called after that links have been created");
487 GetLink(linkId).aifsn = aifsn;
488}
489
490void
492{
493 SetTxopLimit(txopLimit, 0);
494}
495
496void
497Txop::SetTxopLimits(const std::vector<Time>& txopLimits)
498{
499 if (txopLimits.empty())
500 {
501 // an empty vector is passed to use the default values specified by the standard
502 return;
503 }
504
505 NS_ABORT_MSG_IF(!m_links.empty() && txopLimits.size() != m_links.size(),
506 "The size of the given vector (" << txopLimits.size()
507 << ") does not match the number of links ("
508 << m_links.size() << ")");
509 m_userAccessParams.txopLimits = txopLimits;
510
511 std::size_t i = 0;
512 for (const auto& [id, link] : m_links)
513 {
514 SetTxopLimit(txopLimits[i++], id);
515 }
516}
517
518void
519Txop::SetTxopLimit(Time txopLimit, uint8_t linkId)
520{
521 NS_LOG_FUNCTION(this << txopLimit << linkId);
522 NS_ASSERT_MSG(txopLimit.IsPositive(), "TXOP limit cannot be negative");
523 NS_ASSERT_MSG((txopLimit.GetMicroSeconds() % 32 == 0),
524 "The TXOP limit must be expressed in multiple of 32 microseconds!");
525 NS_ASSERT_MSG(!m_links.empty(),
526 "This function can only be called after that links have been created");
527 GetLink(linkId).txopLimit = txopLimit;
528}
529
532{
533 return m_userAccessParams;
534}
535
538{
539 return GetMinCw(0);
540}
541
542std::vector<uint32_t>
544{
545 std::vector<uint32_t> ret;
546 ret.reserve(m_links.size());
547 for (const auto& [id, link] : m_links)
548 {
549 ret.push_back(link->cwMin);
550 }
551 return ret;
552}
553
555Txop::GetMinCw(uint8_t linkId) const
556{
557 return GetLink(linkId).cwMin;
558}
559
562{
563 return GetMaxCw(0);
564}
565
566std::vector<uint32_t>
568{
569 std::vector<uint32_t> ret;
570 ret.reserve(m_links.size());
571 for (const auto& [id, link] : m_links)
572 {
573 ret.push_back(link->cwMax);
574 }
575 return ret;
576}
577
579Txop::GetMaxCw(uint8_t linkId) const
580{
581 return GetLink(linkId).cwMax;
582}
583
584uint8_t
586{
587 return GetAifsn(0);
588}
589
590std::vector<uint8_t>
592{
593 std::vector<uint8_t> ret;
594 ret.reserve(m_links.size());
595 for (const auto& [id, link] : m_links)
596 {
597 ret.push_back(link->aifsn);
598 }
599 return ret;
600}
601
602uint8_t
603Txop::GetAifsn(uint8_t linkId) const
604{
605 return GetLink(linkId).aifsn;
606}
607
608Time
610{
611 return GetTxopLimit(0);
612}
613
614std::vector<Time>
616{
617 std::vector<Time> ret;
618 ret.reserve(m_links.size());
619 for (const auto& [id, link] : m_links)
620 {
621 ret.push_back(link->txopLimit);
622 }
623 return ret;
624}
625
626Time
627Txop::GetTxopLimit(uint8_t linkId) const
628{
629 return GetLink(linkId).txopLimit;
630}
631
632bool
634{
635 m_queue->WipeAllExpiredMpdus();
636 bool ret = static_cast<bool>(m_queue->Peek(linkId));
637 NS_LOG_FUNCTION(this << linkId << ret);
638 return ret;
639}
640
641void
643{
644 NS_LOG_FUNCTION(this << *mpdu);
645
646 // channel access can be requested on a blocked link, if the reason for blocking the link
647 // is temporary
648 auto linkIds = m_mac->GetMacQueueScheduler()->GetLinkIds(
649 m_queue->GetAc(),
650 mpdu,
651 {WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK,
652 WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY});
653
654 // ignore the links for which a channel access request event is already running
655 for (auto it = linkIds.begin(); it != linkIds.end();)
656 {
657 if (const auto& event = GetLink(*it).accessRequest.event; event.IsPending())
658 {
659 it = linkIds.erase(it);
660 }
661 else
662 {
663 ++it;
664 }
665 }
666
667 // save the status of the AC queues before enqueuing the MPDU (required to determine if
668 // backoff is needed)
669 std::map<uint8_t, bool> hasFramesToTransmit;
670 for (const auto linkId : linkIds)
671 {
672 hasFramesToTransmit[linkId] = HasFramesToTransmit(linkId);
673 }
674 m_queue->Enqueue(mpdu);
675
676 // shuffle link IDs not to request channel access on links always in the same order
677 std::vector<uint8_t> shuffledLinkIds(linkIds.cbegin(), linkIds.cend());
678 Shuffle(shuffledLinkIds.begin(), shuffledLinkIds.end(), m_shuffleLinkIdsGen.GetRv());
679
680 if (!linkIds.empty() && g_log.IsEnabled(ns3::LOG_DEBUG))
681 {
682 std::stringstream ss;
683 std::copy(shuffledLinkIds.cbegin(),
684 shuffledLinkIds.cend(),
685 std::ostream_iterator<uint16_t>(ss, " "));
686 NS_LOG_DEBUG("Request channel access on link IDs: " << ss.str());
687 }
688
689 for (const auto linkId : shuffledLinkIds)
690 {
691 // schedule a call to StartAccessIfNeeded() to request channel access after that all the
692 // packets of a burst have been enqueued, instead of requesting channel access right after
693 // the first packet. The call to StartAccessIfNeeded() is scheduled only after the first
694 // packet
696 this,
697 linkId,
698 hasFramesToTransmit.at(linkId),
700 }
701}
702
703int64_t
704Txop::AssignStreams(int64_t stream)
705{
706 NS_LOG_FUNCTION(this << stream);
707 m_rng->SetStream(stream);
708 return 1;
709}
710
711void
712Txop::StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
713{
714 NS_LOG_FUNCTION(this << linkId << hadFramesToTransmit << checkMediumBusy);
715
716 if (!m_mac->GetWifiPhy(linkId))
717 {
718 NS_LOG_DEBUG("No PHY operating on link " << +linkId);
719 return;
720 }
721
722 if (GetLink(linkId).access != NOT_REQUESTED)
723 {
724 NS_LOG_DEBUG("Channel access already requested or granted on link " << +linkId);
725 return;
726 }
727
728 if (!HasFramesToTransmit(linkId))
729 {
730 NS_LOG_DEBUG("No frames to transmit on link " << +linkId);
731 return;
732 }
733
734 if (m_mac->GetChannelAccessManager(linkId)->NeedBackoffUponAccess(this,
735 hadFramesToTransmit,
736 checkMediumBusy))
737 {
738 GenerateBackoff(linkId);
739 }
740
741 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
742}
743
744void
746{
747 NS_LOG_FUNCTION(this);
748 for (const auto& [id, link] : m_links)
749 {
750 ResetCw(id);
751 GenerateBackoff(id);
752 }
753}
754
756Txop::GetAccessStatus(uint8_t linkId) const
757{
758 return GetLink(linkId).access;
759}
760
761void
763{
764 NS_LOG_FUNCTION(this << linkId);
765 GetLink(linkId).access = REQUESTED;
766}
767
768void
769Txop::NotifyChannelAccessed(uint8_t linkId, Time txopDuration)
770{
771 NS_LOG_FUNCTION(this << linkId << txopDuration);
772 GetLink(linkId).access = GRANTED;
773}
774
775void
777{
778 NS_LOG_FUNCTION(this << linkId);
779 GetLink(linkId).access = NOT_REQUESTED;
780 GenerateBackoff(linkId);
781 if (HasFramesToTransmit(linkId))
782 {
784 }
785}
786
787void
788Txop::RequestAccess(uint8_t linkId)
789{
790 NS_LOG_FUNCTION(this << linkId);
791 if (GetLink(linkId).access == NOT_REQUESTED)
792 {
793 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
794 }
795}
796
797void
799{
800 uint32_t backoff = m_rng->GetInteger(0, GetCw(linkId));
801 NS_LOG_FUNCTION(this << linkId << backoff);
802 m_backoffTrace(backoff, linkId);
803 StartBackoffNow(backoff, linkId);
804}
805
806void
807Txop::NotifySleep(uint8_t linkId)
808{
809 NS_LOG_FUNCTION(this << linkId);
810}
811
812void
814{
815 NS_LOG_FUNCTION(this);
816 m_queue->Flush();
817}
818
819void
820Txop::NotifyWakeUp(uint8_t linkId)
821{
822 NS_LOG_FUNCTION(this << linkId);
823 // before wake up, no packet can be transmitted
825}
826
827void
829{
830 NS_LOG_FUNCTION(this);
831 for (const auto& [id, link] : m_links)
832 {
833 // before being turned on, no packet can be transmitted
835 }
836}
837
838bool
840{
841 return false;
842}
843
844} // 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:595
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:1432
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:609
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
Definition txop.cc:204
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition txop.cc:704
virtual ChannelAccessStatus GetAccessStatus(uint8_t linkId) const
Definition txop.cc:756
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:712
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the Txop has frames to transmit over the given link.
Definition txop.cc:633
virtual void NotifyOff()
When off operation occurs, the queue gets cleaned up.
Definition txop.cc:813
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:369
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:185
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition txop.cc:320
void SetMaxCws(const std::vector< uint32_t > &maxCws)
Set the maximum contention window size for each link.
Definition txop.cc:326
uint32_t GetMinCw() const
Return the minimum contention window size.
Definition txop.cc:537
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:828
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:385
void SetAifsns(const std::vector< uint8_t > &aifsns)
Set the number of slots that make up an AIFS for each link.
Definition txop.cc:460
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:271
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition txop.cc:249
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:820
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition txop.cc:776
std::vector< uint32_t > GetMaxCws() const
Return the maximum contention window size for each link.
Definition txop.cc:567
virtual void Queue(Ptr< WifiMpdu > mpdu)
Definition txop.cc:642
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition txop.cc:491
virtual void CreateQueue(AcIndex aci)
Create a wifi MAC queue containing packets of the given AC.
Definition txop.cc:196
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:375
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition txop.cc:210
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition txop.cc:839
std::vector< uint32_t > GetMinCws() const
Return the minimum contention window size for each link.
Definition txop.cc:543
std::vector< uint8_t > GetAifsns() const
Return the number of slots that make up an AIFS for each link.
Definition txop.cc:591
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
Update backoff slots for the given link that nSlots has passed.
Definition txop.cc:425
Time GetBackoffStart(uint8_t linkId) const
Return the time when the backoff procedure started on the given link.
Definition txop.cc:419
void SetTxopLimits(const std::vector< Time > &txopLimits)
Set the TXOP limit for each link.
Definition txop.cc:497
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:225
const UserDefinedAccessParams & GetUserAccessParams() const
Definition txop.cc:531
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition txop.cc:242
std::vector< Time > GetTxopLimits() const
Return the TXOP limit for each link.
Definition txop.cc:615
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition txop.cc:219
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:454
uint32_t GetCw(uint8_t linkId) const
Get the current value of the CW variable for the given link.
Definition txop.cc:363
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition txop.cc:260
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:798
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:762
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:179
void StartBackoffNow(uint32_t nSlots, uint8_t linkId)
Definition txop.cc:436
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:769
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:283
void RequestAccess(uint8_t linkId)
Request access to the ChannelAccessManager associated with the given link.
Definition txop.cc:788
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition txop.cc:277
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
Definition txop.cc:585
uint32_t GetBackoffSlots(uint8_t linkId) const
Return the current number of backoff slots on the given link.
Definition txop.cc:413
virtual void NotifySleep(uint8_t linkId)
Notify that the given link switched to sleep mode.
Definition txop.cc:807
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:561
void DoInitialize() override
Initialize() implementation.
Definition txop.cc:745
a unique identifier for an interface.
Definition type-id.h:49
@ ATTR_GET
The attribute can be read.
Definition type-id.h:54
@ ATTR_SET
The attribute can be written.
Definition type-id.h:55
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
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:1433
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1453
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:1357
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:72
@ WIFI_MAC_DROP_EXPIRED_LIFETIME
Definition wifi-mac.h:73
@ 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