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