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
361void
362Txop::ResetCw(uint8_t linkId)
363{
364 NS_LOG_FUNCTION(this << linkId);
365 auto& link = GetLink(linkId);
366 link.cw = GetMinCw(linkId);
367 m_cwTrace(link.cw, linkId);
368}
369
370void
371Txop::UpdateFailedCw(uint8_t linkId)
372{
373 NS_LOG_FUNCTION(this << linkId);
374 auto& link = GetLink(linkId);
375 // see 802.11-2012, section 9.19.2.5
376 link.cw = std::min(2 * (link.cw + 1) - 1, GetMaxCw(linkId));
377 // if the MU EDCA timer is running, CW cannot be less than MU CW min
378 link.cw = std::max(link.cw, GetMinCw(linkId));
379 m_cwTrace(link.cw, linkId);
380}
381
383Txop::GetBackoffSlots(uint8_t linkId) const
384{
385 return GetLink(linkId).backoffSlots;
386}
387
388Time
389Txop::GetBackoffStart(uint8_t linkId) const
390{
391 return GetLink(linkId).backoffStart;
392}
393
394void
395Txop::UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
396{
397 NS_LOG_FUNCTION(this << nSlots << backoffUpdateBound << linkId);
398 auto& link = GetLink(linkId);
399
400 link.backoffSlots -= nSlots;
401 link.backoffStart = backoffUpdateBound;
402 NS_LOG_DEBUG("update slots=" << nSlots << " slots, backoff=" << link.backoffSlots);
403}
404
405void
406Txop::StartBackoffNow(uint32_t nSlots, uint8_t linkId)
407{
408 NS_LOG_FUNCTION(this << nSlots << linkId);
409 auto& link = GetLink(linkId);
410
411 if (link.backoffSlots != 0)
412 {
413 NS_LOG_DEBUG("reset backoff from " << link.backoffSlots << " to " << nSlots << " slots");
414 }
415 else
416 {
417 NS_LOG_DEBUG("start backoff=" << nSlots << " slots");
418 }
419 link.backoffSlots = nSlots;
420 link.backoffStart = Simulator::Now();
421}
422
423void
424Txop::SetAifsn(uint8_t aifsn)
425{
426 SetAifsn(aifsn, 0);
427}
428
429void
430Txop::SetAifsns(const std::vector<uint8_t>& aifsns)
431{
432 if (aifsns.empty())
433 {
434 // an empty vector is passed to use the default values specified by the standard
435 return;
436 }
437
438 NS_ABORT_MSG_IF(!m_links.empty() && aifsns.size() != m_links.size(),
439 "The size of the given vector (" << aifsns.size()
440 << ") does not match the number of links ("
441 << m_links.size() << ")");
442 m_userAccessParams.aifsns = aifsns;
443
444 std::size_t i = 0;
445 for (const auto& [id, link] : m_links)
446 {
447 SetAifsn(aifsns[i++], id);
448 }
449}
450
451void
452Txop::SetAifsn(uint8_t aifsn, uint8_t linkId)
453{
454 NS_LOG_FUNCTION(this << aifsn << linkId);
455 NS_ASSERT_MSG(!m_links.empty(),
456 "This function can only be called after that links have been created");
457 GetLink(linkId).aifsn = aifsn;
458}
459
460void
462{
463 SetTxopLimit(txopLimit, 0);
464}
465
466void
467Txop::SetTxopLimits(const std::vector<Time>& txopLimits)
468{
469 if (txopLimits.empty())
470 {
471 // an empty vector is passed to use the default values specified by the standard
472 return;
473 }
474
475 NS_ABORT_MSG_IF(!m_links.empty() && txopLimits.size() != m_links.size(),
476 "The size of the given vector (" << txopLimits.size()
477 << ") does not match the number of links ("
478 << m_links.size() << ")");
479 m_userAccessParams.txopLimits = txopLimits;
480
481 std::size_t i = 0;
482 for (const auto& [id, link] : m_links)
483 {
484 SetTxopLimit(txopLimits[i++], id);
485 }
486}
487
488void
489Txop::SetTxopLimit(Time txopLimit, uint8_t linkId)
490{
491 NS_LOG_FUNCTION(this << txopLimit << linkId);
492 NS_ASSERT_MSG(txopLimit.IsPositive(), "TXOP limit cannot be negative");
493 NS_ASSERT_MSG((txopLimit.GetMicroSeconds() % 32 == 0),
494 "The TXOP limit must be expressed in multiple of 32 microseconds!");
495 NS_ASSERT_MSG(!m_links.empty(),
496 "This function can only be called after that links have been created");
497 GetLink(linkId).txopLimit = txopLimit;
498}
499
502{
503 return m_userAccessParams;
504}
505
508{
509 return GetMinCw(0);
510}
511
512std::vector<uint32_t>
514{
515 std::vector<uint32_t> ret;
516 ret.reserve(m_links.size());
517 for (const auto& [id, link] : m_links)
518 {
519 ret.push_back(link->cwMin);
520 }
521 return ret;
522}
523
525Txop::GetMinCw(uint8_t linkId) const
526{
527 return GetLink(linkId).cwMin;
528}
529
532{
533 return GetMaxCw(0);
534}
535
536std::vector<uint32_t>
538{
539 std::vector<uint32_t> ret;
540 ret.reserve(m_links.size());
541 for (const auto& [id, link] : m_links)
542 {
543 ret.push_back(link->cwMax);
544 }
545 return ret;
546}
547
549Txop::GetMaxCw(uint8_t linkId) const
550{
551 return GetLink(linkId).cwMax;
552}
553
554uint8_t
556{
557 return GetAifsn(0);
558}
559
560std::vector<uint8_t>
562{
563 std::vector<uint8_t> ret;
564 ret.reserve(m_links.size());
565 for (const auto& [id, link] : m_links)
566 {
567 ret.push_back(link->aifsn);
568 }
569 return ret;
570}
571
572uint8_t
573Txop::GetAifsn(uint8_t linkId) const
574{
575 return GetLink(linkId).aifsn;
576}
577
578Time
580{
581 return GetTxopLimit(0);
582}
583
584std::vector<Time>
586{
587 std::vector<Time> ret;
588 ret.reserve(m_links.size());
589 for (const auto& [id, link] : m_links)
590 {
591 ret.push_back(link->txopLimit);
592 }
593 return ret;
594}
595
596Time
597Txop::GetTxopLimit(uint8_t linkId) const
598{
599 return GetLink(linkId).txopLimit;
600}
601
602bool
604{
605 m_queue->WipeAllExpiredMpdus();
606 bool ret = static_cast<bool>(m_queue->Peek(linkId));
607 NS_LOG_FUNCTION(this << linkId << ret);
608 return ret;
609}
610
611void
613{
614 NS_LOG_FUNCTION(this << *mpdu);
615
616 // channel access can be requested on a blocked link, if the reason for blocking the link
617 // is temporary
618 auto linkIds = m_mac->GetMacQueueScheduler()->GetLinkIds(
619 m_queue->GetAc(),
620 mpdu,
621 {WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK,
622 WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY});
623
624 // ignore the links for which a channel access request event is already running
625 for (auto it = linkIds.begin(); it != linkIds.end();)
626 {
627 if (const auto& event = GetLink(*it).accessRequest.event; event.IsPending())
628 {
629 it = linkIds.erase(it);
630 }
631 else
632 {
633 ++it;
634 }
635 }
636
637 // save the status of the AC queues before enqueuing the MPDU (required to determine if
638 // backoff is needed)
639 std::map<uint8_t, bool> hasFramesToTransmit;
640 for (const auto linkId : linkIds)
641 {
642 hasFramesToTransmit[linkId] = HasFramesToTransmit(linkId);
643 }
644 m_queue->Enqueue(mpdu);
645
646 // shuffle link IDs not to request channel access on links always in the same order
647 std::vector<uint8_t> shuffledLinkIds(linkIds.cbegin(), linkIds.cend());
648 Shuffle(shuffledLinkIds.begin(), shuffledLinkIds.end(), m_shuffleLinkIdsGen.GetRv());
649
650 if (!linkIds.empty() && g_log.IsEnabled(ns3::LOG_DEBUG))
651 {
652 std::stringstream ss;
653 std::copy(shuffledLinkIds.cbegin(),
654 shuffledLinkIds.cend(),
655 std::ostream_iterator<uint16_t>(ss, " "));
656 NS_LOG_DEBUG("Request channel access on link IDs: " << ss.str());
657 }
658
659 for (const auto linkId : shuffledLinkIds)
660 {
661 // schedule a call to StartAccessIfNeeded() to request channel access after that all the
662 // packets of a burst have been enqueued, instead of requesting channel access right after
663 // the first packet. The call to StartAccessIfNeeded() is scheduled only after the first
664 // packet
666 this,
667 linkId,
668 hasFramesToTransmit.at(linkId),
670 }
671}
672
673int64_t
674Txop::AssignStreams(int64_t stream)
675{
676 NS_LOG_FUNCTION(this << stream);
677 m_rng->SetStream(stream);
678 return 1;
679}
680
681void
682Txop::StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
683{
684 NS_LOG_FUNCTION(this << linkId << hadFramesToTransmit << checkMediumBusy);
685
686 if (!m_mac->GetWifiPhy(linkId))
687 {
688 NS_LOG_DEBUG("No PHY operating on link " << +linkId);
689 return;
690 }
691
692 if (GetLink(linkId).access != NOT_REQUESTED)
693 {
694 NS_LOG_DEBUG("Channel access already requested or granted on link " << +linkId);
695 return;
696 }
697
698 if (!HasFramesToTransmit(linkId))
699 {
700 NS_LOG_DEBUG("No frames to transmit on link " << +linkId);
701 return;
702 }
703
704 if (m_mac->GetChannelAccessManager(linkId)->NeedBackoffUponAccess(this,
705 hadFramesToTransmit,
706 checkMediumBusy))
707 {
708 GenerateBackoff(linkId);
709 }
710
711 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
712}
713
714void
716{
717 NS_LOG_FUNCTION(this);
718 for (const auto& [id, link] : m_links)
719 {
720 ResetCw(id);
721 GenerateBackoff(id);
722 }
723}
724
726Txop::GetAccessStatus(uint8_t linkId) const
727{
728 return GetLink(linkId).access;
729}
730
731void
733{
734 NS_LOG_FUNCTION(this << linkId);
735 GetLink(linkId).access = REQUESTED;
736}
737
738void
739Txop::NotifyChannelAccessed(uint8_t linkId, Time txopDuration)
740{
741 NS_LOG_FUNCTION(this << linkId << txopDuration);
742 GetLink(linkId).access = GRANTED;
743}
744
745void
747{
748 NS_LOG_FUNCTION(this << linkId);
749 GetLink(linkId).access = NOT_REQUESTED;
750 GenerateBackoff(linkId);
751 if (HasFramesToTransmit(linkId))
752 {
754 }
755}
756
757void
758Txop::RequestAccess(uint8_t linkId)
759{
760 NS_LOG_FUNCTION(this << linkId);
761 if (GetLink(linkId).access == NOT_REQUESTED)
762 {
763 m_mac->GetChannelAccessManager(linkId)->RequestAccess(this);
764 }
765}
766
767void
769{
770 uint32_t backoff = m_rng->GetInteger(0, GetCw(linkId));
771 NS_LOG_FUNCTION(this << linkId << backoff);
772 m_backoffTrace(backoff, linkId);
773 StartBackoffNow(backoff, linkId);
774}
775
776void
777Txop::NotifySleep(uint8_t linkId)
778{
779 NS_LOG_FUNCTION(this << linkId);
780}
781
782void
784{
785 NS_LOG_FUNCTION(this);
786 m_queue->Flush();
787}
788
789void
790Txop::NotifyWakeUp(uint8_t linkId)
791{
792 NS_LOG_FUNCTION(this << linkId);
793 // before wake up, no packet can be transmitted
795}
796
797void
799{
800 NS_LOG_FUNCTION(this);
801 for (const auto& [id, link] : m_links)
802 {
803 // before being turned on, no packet can be transmitted
805 }
806}
807
808bool
810{
811 return false;
812}
813
814} // 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
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:554
Time GetTxopLimit() const
Return the TXOP limit.
Definition txop.cc:579
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:674
virtual ChannelAccessStatus GetAccessStatus(uint8_t linkId) const
Definition txop.cc:726
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition txop.h:552
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:682
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the Txop has frames to transmit over the given link.
Definition txop.cc:603
virtual void NotifyOff()
When off operation occurs, the queue gets cleaned up.
Definition txop.cc:783
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Definition txop.h:556
Ptr< UniformRandomVariable > m_rng
the random stream
Definition txop.h:555
CwValueTracedCallback m_cwTrace
CW trace value.
Definition txop.h:564
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:507
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:798
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:371
void SetAifsns(const std::vector< uint8_t > &aifsns)
Set the number of slots that make up an AIFS for each link.
Definition txop.cc:430
static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT
no packet available for transmission was in the queue
Definition txop.h:390
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:790
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition txop.cc:746
std::vector< uint32_t > GetMaxCws() const
Return the maximum contention window size for each link.
Definition txop.cc:537
virtual void Queue(Ptr< WifiMpdu > mpdu)
Definition txop.cc:612
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition txop.cc:461
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:362
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:809
std::vector< uint32_t > GetMinCws() const
Return the minimum contention window size for each link.
Definition txop.cc:513
std::vector< uint8_t > GetAifsns() const
Return the number of slots that make up an AIFS for each link.
Definition txop.cc:561
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
Update backoff slots for the given link that nSlots has passed.
Definition txop.cc:395
Time GetBackoffStart(uint8_t linkId) const
Return the time when the backoff procedure started on the given link.
Definition txop.cc:389
void SetTxopLimits(const std::vector< Time > &txopLimits)
Set the TXOP limit for each link.
Definition txop.cc:467
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition txop.h:551
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:501
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:585
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:424
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:577
virtual void GenerateBackoff(uint8_t linkId)
Generate a new backoff for the given link now.
Definition txop.cc:768
BackoffValueTracedCallback m_backoffTrace
backoff trace value
Definition txop.h:563
virtual void NotifyAccessRequested(uint8_t linkId)
Notify that access request has been received for the given link.
Definition txop.cc:732
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition txop.h:553
static constexpr bool CHECK_MEDIUM_BUSY
generation of backoff (also) depends on the busy/idle state of the medium
Definition txop.h:392
~Txop() override
Definition txop.cc:172
void StartBackoffNow(uint32_t nSlots, uint8_t linkId)
Definition txop.cc:406
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:739
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of LinkEntity objects.
Definition txop.h:575
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:758
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:555
uint32_t GetBackoffSlots(uint8_t linkId) const
Return the current number of backoff slots on the given link.
Definition txop.cc:383
virtual void NotifySleep(uint8_t linkId)
Notify that the given link switched to sleep mode.
Definition txop.cc:777
static constexpr bool DONT_CHECK_MEDIUM_BUSY
generation of backoff is independent of the busy/idle state of the medium
Definition txop.h:394
uint32_t GetMaxCw() const
Return the maximum contention window size.
Definition txop.cc:531
void DoInitialize() override
Initialize() implementation.
Definition txop.cc:715
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 > 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
#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:1320
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 > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
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
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
DCF/EDCA access parameters for all the links provided by users via this class' attributes or the corr...
Definition txop.h:430
std::vector< uint32_t > cwMins
the minimum contention window values for all the links
Definition txop.h:431
std::vector< uint8_t > aifsns
the AIFSN values for all the links
Definition txop.h:433
std::vector< uint32_t > cwMaxs
the maximum contention window values for all the links
Definition txop.h:432
std::vector< Time > txopLimits
TXOP limit values for all the links.
Definition txop.h:434