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