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/simulator.h"
34#include "ns3/socket.h"
35
36#include <iterator>
37#include <sstream>
38
39#undef NS_LOG_APPEND_CONTEXT
40#define NS_LOG_APPEND_CONTEXT WIFI_TXOP_NS_LOG_APPEND_CONTEXT
41
42namespace ns3
43{
44
46
48
49TypeId
51{
52 static TypeId tid =
53 TypeId("ns3::Txop")
55 .SetGroupName("Wifi")
56 .AddConstructor<Txop>()
57 .AddAttribute("MinCw",
58 "The minimum value of the contention window (just for the first link, "
59 "in case of 11be multi-link devices).",
60 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
61 UintegerValue(15),
63 (uint32_t(Txop::*)() const) & Txop::GetMinCw),
64 MakeUintegerChecker<uint32_t>())
65 .AddAttribute(
66 "MinCws",
67 "The minimum values of the contention window for all the links",
68 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
70 MakeAttributeContainerAccessor<UintegerValue>(&Txop::SetMinCws, &Txop::GetMinCws),
71 MakeAttributeContainerChecker<UintegerValue>(MakeUintegerChecker<uint32_t>()))
72 .AddAttribute("MaxCw",
73 "The maximum value of the contention window (just for the first link, "
74 "in case of 11be multi-link devices).",
75 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
76 UintegerValue(1023),
78 (uint32_t(Txop::*)() const) & Txop::GetMaxCw),
79 MakeUintegerChecker<uint32_t>())
80 .AddAttribute(
81 "MaxCws",
82 "The maximum values of the contention window for all the links",
83 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
85 MakeAttributeContainerAccessor<UintegerValue>(&Txop::SetMaxCws, &Txop::GetMaxCws),
86 MakeAttributeContainerChecker<UintegerValue>(MakeUintegerChecker<uint32_t>()))
87 .AddAttribute(
88 "Aifsn",
89 "The AIFSN: the default value conforms to non-QOS (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
93 MakeUintegerAccessor((void(Txop::*)(uint8_t)) & Txop::SetAifsn,
94 (uint8_t(Txop::*)() const) & Txop::GetAifsn),
95 MakeUintegerChecker<uint8_t>())
96 .AddAttribute(
97 "Aifsns",
98 "The values of AIFSN for all the links",
99 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
101 MakeAttributeContainerAccessor<UintegerValue>(&Txop::SetAifsns, &Txop::GetAifsns),
102 MakeAttributeContainerChecker<UintegerValue>(MakeUintegerChecker<uint8_t>()))
103 .AddAttribute("TxopLimit",
104 "The TXOP limit: the default value conforms to non-QoS "
105 "(just for the first link, in case of 11be multi-link devices).",
106 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
109 (Time(Txop::*)() const) & Txop::GetTxopLimit),
111 .AddAttribute("TxopLimits",
112 "The values of TXOP limit for all the links",
113 TypeId::ATTR_GET | TypeId::ATTR_SET, // do not set at construction time
115 MakeAttributeContainerAccessor<TimeValue>(&Txop::SetTxopLimits,
117 MakeAttributeContainerChecker<TimeValue>(MakeTimeChecker()))
118 .AddAttribute("Queue",
119 "The WifiMacQueue object",
120 PointerValue(),
122 MakePointerChecker<WifiMacQueue>())
123 .AddTraceSource("BackoffTrace",
124 "Trace source for backoff values",
126 "ns3::Txop::BackoffValueTracedCallback")
127 .AddTraceSource("CwTrace",
128 "Trace source for contention window values",
130 "ns3::Txop::CwValueTracedCallback");
131 return tid;
132}
133
136{
137}
138
140 : m_queue(queue)
141{
142 NS_LOG_FUNCTION(this);
144}
145
147{
148 NS_LOG_FUNCTION(this);
149}
150
151void
153{
154 NS_LOG_FUNCTION(this);
155 m_queue = nullptr;
156 m_mac = nullptr;
157 m_rng = nullptr;
158 m_txMiddle = nullptr;
159 m_links.clear();
160}
161
162std::unique_ptr<Txop::LinkEntity>
164{
165 return std::make_unique<LinkEntity>();
166}
167
169Txop::GetLink(uint8_t linkId) const
170{
171 auto it = m_links.find(linkId);
172 NS_ASSERT(it != m_links.cend());
173 NS_ASSERT(it->second); // check that the pointer owns an object
174 return *it->second;
175}
176
177const std::map<uint8_t, std::unique_ptr<Txop::LinkEntity>>&
179{
180 return m_links;
181}
182
183void
184Txop::SwapLinks(std::map<uint8_t, uint8_t> links)
185{
186 NS_LOG_FUNCTION(this);
187
188 decltype(m_links) tmp;
189 tmp.swap(m_links); // move all links to temporary map
190 for (const auto& [from, to] : links)
191 {
192 auto nh = tmp.extract(from);
193 nh.key() = to;
194 m_links.insert(std::move(nh));
195 }
196 // move links remaining in tmp to m_links
197 m_links.merge(tmp);
198}
199
200void
202{
203 NS_LOG_FUNCTION(this);
204 m_txMiddle = txMiddle;
205}
206
207void
209{
210 NS_LOG_FUNCTION(this << mac);
211 m_mac = mac;
212 for (const auto linkId : m_mac->GetLinkIds())
213 {
214 m_links.emplace(linkId, CreateLinkEntity());
215 }
216}
217
218void
220{
221 NS_LOG_FUNCTION(this << &callback);
222 m_droppedMpduCallback = callback;
223 m_queue->TraceConnectWithoutContext("DropBeforeEnqueue",
225 m_queue->TraceConnectWithoutContext("Expired",
227}
228
231{
232 return m_queue;
233}
234
235void
237{
238 SetMinCw(minCw, 0);
239}
240
241void
242Txop::SetMinCws(std::vector<uint32_t> minCws)
243{
244 NS_ABORT_IF(minCws.size() != m_links.size());
245 std::size_t i = 0;
246 for (const auto& [id, link] : m_links)
247 {
248 SetMinCw(minCws[i++], id);
249 }
250}
251
252void
253Txop::SetMinCw(uint32_t minCw, uint8_t linkId)
254{
255 NS_LOG_FUNCTION(this << minCw << linkId);
256 auto& link = GetLink(linkId);
257 bool changed = (link.cwMin != minCw);
258 link.cwMin = minCw;
259 if (changed)
260 {
261 ResetCw(linkId);
262 }
263}
264
265void
267{
268 SetMaxCw(maxCw, 0);
269}
270
271void
272Txop::SetMaxCws(std::vector<uint32_t> maxCws)
273{
274 NS_ABORT_IF(maxCws.size() != m_links.size());
275 std::size_t i = 0;
276 for (const auto& [id, link] : m_links)
277 {
278 SetMaxCw(maxCws[i++], id);
279 }
280}
281
282void
283Txop::SetMaxCw(uint32_t maxCw, uint8_t linkId)
284{
285 NS_LOG_FUNCTION(this << maxCw << linkId);
286 auto& link = GetLink(linkId);
287 bool changed = (link.cwMax != maxCw);
288 link.cwMax = maxCw;
289 if (changed)
290 {
291 ResetCw(linkId);
292 }
293}
294
296Txop::GetCw(uint8_t linkId) const
297{
298 return GetLink(linkId).cw;
299}
300
301void
302Txop::ResetCw(uint8_t linkId)
303{
304 NS_LOG_FUNCTION(this << linkId);
305 auto& link = GetLink(linkId);
306 link.cw = GetMinCw(linkId);
307 m_cwTrace(link.cw, linkId);
308}
309
310void
311Txop::UpdateFailedCw(uint8_t linkId)
312{
313 NS_LOG_FUNCTION(this << linkId);
314 auto& link = GetLink(linkId);
315 // see 802.11-2012, section 9.19.2.5
316 link.cw = std::min(2 * (link.cw + 1) - 1, GetMaxCw(linkId));
317 // if the MU EDCA timer is running, CW cannot be less than MU CW min
318 link.cw = std::max(link.cw, GetMinCw(linkId));
319 m_cwTrace(link.cw, linkId);
320}
321
323Txop::GetBackoffSlots(uint8_t linkId) const
324{
325 return GetLink(linkId).backoffSlots;
326}
327
328Time
329Txop::GetBackoffStart(uint8_t linkId) const
330{
331 return GetLink(linkId).backoffStart;
332}
333
334void
335Txop::UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
336{
337 NS_LOG_FUNCTION(this << nSlots << backoffUpdateBound << linkId);
338 auto& link = GetLink(linkId);
339
340 link.backoffSlots -= nSlots;
341 link.backoffStart = backoffUpdateBound;
342 NS_LOG_DEBUG("update slots=" << nSlots << " slots, backoff=" << link.backoffSlots);
343}
344
345void
346Txop::StartBackoffNow(uint32_t nSlots, uint8_t linkId)
347{
348 NS_LOG_FUNCTION(this << nSlots << linkId);
349 auto& link = GetLink(linkId);
350
351 if (link.backoffSlots != 0)
352 {
353 NS_LOG_DEBUG("reset backoff from " << link.backoffSlots << " to " << nSlots << " slots");
354 }
355 else
356 {
357 NS_LOG_DEBUG("start backoff=" << nSlots << " slots");
358 }
359 link.backoffSlots = nSlots;
360 link.backoffStart = Simulator::Now();
361}
362
363void
364Txop::SetAifsn(uint8_t aifsn)
365{
366 SetAifsn(aifsn, 0);
367}
368
369void
370Txop::SetAifsns(std::vector<uint8_t> aifsns)
371{
372 NS_ABORT_IF(aifsns.size() != m_links.size());
373 std::size_t i = 0;
374 for (const auto& [id, link] : m_links)
375 {
376 SetAifsn(aifsns[i++], id);
377 }
378}
379
380void
381Txop::SetAifsn(uint8_t aifsn, uint8_t linkId)
382{
383 NS_LOG_FUNCTION(this << aifsn << linkId);
384 GetLink(linkId).aifsn = aifsn;
385}
386
387void
389{
390 SetTxopLimit(txopLimit, 0);
391}
392
393void
394Txop::SetTxopLimits(const std::vector<Time>& txopLimits)
395{
396 NS_ABORT_MSG_IF(txopLimits.size() != m_links.size(),
397 "The size of the given vector (" << txopLimits.size()
398 << ") does not match the number of links ("
399 << m_links.size() << ")");
400 std::size_t i = 0;
401 for (const auto& [id, link] : m_links)
402 {
403 SetTxopLimit(txopLimits[i++], id);
404 }
405}
406
407void
408Txop::SetTxopLimit(Time txopLimit, uint8_t linkId)
409{
410 NS_LOG_FUNCTION(this << txopLimit << linkId);
411 NS_ASSERT_MSG((txopLimit.GetMicroSeconds() % 32 == 0),
412 "The TXOP limit must be expressed in multiple of 32 microseconds!");
413 GetLink(linkId).txopLimit = txopLimit;
414}
415
418{
419 return GetMinCw(0);
420}
421
422std::vector<uint32_t>
424{
425 std::vector<uint32_t> ret;
426 ret.reserve(m_links.size());
427 for (const auto& [id, link] : m_links)
428 {
429 ret.push_back(link->cwMin);
430 }
431 return ret;
432}
433
435Txop::GetMinCw(uint8_t linkId) const
436{
437 return GetLink(linkId).cwMin;
438}
439
442{
443 return GetMaxCw(0);
444}
445
446std::vector<uint32_t>
448{
449 std::vector<uint32_t> ret;
450 ret.reserve(m_links.size());
451 for (const auto& [id, link] : m_links)
452 {
453 ret.push_back(link->cwMax);
454 }
455 return ret;
456}
457
459Txop::GetMaxCw(uint8_t linkId) const
460{
461 return GetLink(linkId).cwMax;
462}
463
464uint8_t
466{
467 return GetAifsn(0);
468}
469
470std::vector<uint8_t>
472{
473 std::vector<uint8_t> ret;
474 ret.reserve(m_links.size());
475 for (const auto& [id, link] : m_links)
476 {
477 ret.push_back(link->aifsn);
478 }
479 return ret;
480}
481
482uint8_t
483Txop::GetAifsn(uint8_t linkId) const
484{
485 return GetLink(linkId).aifsn;
486}
487
488Time
490{
491 return GetTxopLimit(0);
492}
493
494std::vector<Time>
496{
497 std::vector<Time> ret;
498 ret.reserve(m_links.size());
499 for (const auto& [id, link] : m_links)
500 {
501 ret.push_back(link->txopLimit);
502 }
503 return ret;
504}
505
506Time
507Txop::GetTxopLimit(uint8_t linkId) const
508{
509 return GetLink(linkId).txopLimit;
510}
511
512bool
514{
515 m_queue->WipeAllExpiredMpdus();
516 bool ret = static_cast<bool>(m_queue->Peek(linkId));
517 NS_LOG_FUNCTION(this << linkId << ret);
518 return ret;
519}
520
521void
523{
524 NS_LOG_FUNCTION(this << packet << &hdr);
525 // remove the priority tag attached, if any
526 SocketPriorityTag priorityTag;
527 packet->RemovePacketTag(priorityTag);
528 Queue(Create<WifiMpdu>(packet, hdr));
529}
530
531void
533{
534 NS_LOG_FUNCTION(this << *mpdu);
535
536 // channel access can be requested on a blocked link, if the reason for blocking the link
537 // is temporary
538 auto linkIds = m_mac->GetMacQueueScheduler()->GetLinkIds(
539 m_queue->GetAc(),
540 mpdu,
541 {WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK,
542 WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY});
543
544 // ignore the links for which a channel access request event is already running
545 for (auto it = linkIds.begin(); it != linkIds.end();)
546 {
547 if (const auto& event = GetLink(*it).accessRequest.event; event.IsRunning())
548 {
549 it = linkIds.erase(it);
550 }
551 else
552 {
553 ++it;
554 }
555 }
556
557 // save the status of the AC queues before enqueuing the MPDU (required to determine if
558 // backoff is needed)
559 std::map<uint8_t, bool> hasFramesToTransmit;
560 for (const auto linkId : linkIds)
561 {
562 hasFramesToTransmit[linkId] = HasFramesToTransmit(linkId);
563 }
564 m_queue->Enqueue(mpdu);
565
566 // shuffle link IDs not to request channel access on links always in the same order
567 std::vector<uint8_t> shuffledLinkIds(linkIds.cbegin(), linkIds.cend());
568 std::shuffle(shuffledLinkIds.begin(), shuffledLinkIds.end(), m_shuffleLinkIdsGen);
569
570 if (!linkIds.empty() && g_log.IsEnabled(ns3::LOG_DEBUG))
571 {
572 std::stringstream ss;
573 std::copy(shuffledLinkIds.cbegin(),
574 shuffledLinkIds.cend(),
575 std::ostream_iterator<uint16_t>(ss, " "));
576 NS_LOG_DEBUG("Request channel access on link IDs: " << ss.str());
577 }
578
579 for (const auto linkId : shuffledLinkIds)
580 {
581 // schedule a call to StartAccessIfNeeded() to request channel access after that all the
582 // packets of a burst have been enqueued, instead of requesting channel access right after
583 // the first packet. The call to StartAccessIfNeeded() is scheduled only after the first
584 // packet
586 this,
587 linkId,
588 hasFramesToTransmit.at(linkId),
590 }
591}
592
593int64_t
594Txop::AssignStreams(int64_t stream)
595{
596 NS_LOG_FUNCTION(this << stream);
597 m_rng->SetStream(stream);
598 return 1;
599}
600
601void
602Txop::StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy)
603{
604 NS_LOG_FUNCTION(this << linkId << hadFramesToTransmit << checkMediumBusy);
605
606 if (!m_mac->GetWifiPhy(linkId))
607 {
608 NS_LOG_DEBUG("No PHY operating on link " << +linkId);
609 return;
610 }
611
612 if (GetLink(linkId).access != NOT_REQUESTED)
613 {
614 NS_LOG_DEBUG("Channel access already requested or granted on link " << +linkId);
615 return;
616 }
617
618 if (!HasFramesToTransmit(linkId))
619 {
620 NS_LOG_DEBUG("No frames to transmit on link " << +linkId);
621 return;
622 }
623
625 hadFramesToTransmit,
626 checkMediumBusy))
627 {
628 GenerateBackoff(linkId);
629 }
630
632}
633
634void
636{
637 NS_LOG_FUNCTION(this);
638 for (const auto& [id, link] : m_links)
639 {
640 ResetCw(id);
641 GenerateBackoff(id);
642 }
643}
644
646Txop::GetAccessStatus(uint8_t linkId) const
647{
648 return GetLink(linkId).access;
649}
650
651void
653{
654 NS_LOG_FUNCTION(this << linkId);
655 GetLink(linkId).access = REQUESTED;
656}
657
658void
659Txop::NotifyChannelAccessed(uint8_t linkId, Time txopDuration)
660{
661 NS_LOG_FUNCTION(this << linkId << txopDuration);
662 GetLink(linkId).access = GRANTED;
663}
664
665void
667{
668 NS_LOG_FUNCTION(this << linkId);
669 GetLink(linkId).access = NOT_REQUESTED;
670 GenerateBackoff(linkId);
671 if (HasFramesToTransmit(linkId))
672 {
674 }
675}
676
677void
678Txop::RequestAccess(uint8_t linkId)
679{
680 NS_LOG_FUNCTION(this << linkId);
681 if (GetLink(linkId).access == NOT_REQUESTED)
682 {
684 }
685}
686
687void
689{
690 uint32_t backoff = m_rng->GetInteger(0, GetCw(linkId));
691 NS_LOG_FUNCTION(this << linkId << backoff);
692 m_backoffTrace(backoff, linkId);
693 StartBackoffNow(backoff, linkId);
694}
695
696void
697Txop::NotifySleep(uint8_t linkId)
698{
699 NS_LOG_FUNCTION(this << linkId);
700}
701
702void
704{
705 NS_LOG_FUNCTION(this);
706 m_queue->Flush();
707}
708
709void
710Txop::NotifyWakeUp(uint8_t linkId)
711{
712 NS_LOG_FUNCTION(this << linkId);
713 // before wake up, no packet can be transmitted
715}
716
717void
719{
720 NS_LOG_FUNCTION(this);
721 for (const auto& [id, link] : m_links)
722 {
723 // before being turned on, no packet can be transmitted
725 }
726}
727
728bool
730{
731 return false;
732}
733
734} // 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)
bool IsRunning() 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
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:413
AttributeValue implementation for Time.
Definition: nstime.h:1406
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:81
Ptr< WifiMac > m_mac
the wifi MAC
Definition: txop.h:562
Time GetTxopLimit() const
Return the TXOP limit.
Definition: txop.cc:489
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
Definition: txop.cc:163
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: txop.cc:594
virtual ChannelAccessStatus GetAccessStatus(uint8_t linkId) const
Definition: txop.cc:646
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:560
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:602
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the Txop has frames to transmit over the given link.
Definition: txop.cc:513
virtual void NotifyOff()
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:703
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Definition: txop.h:564
Ptr< UniformRandomVariable > m_rng
the random stream
Definition: txop.h:563
CwValueTracedCallback m_cwTrace
CW trace value.
Definition: txop.h:572
void DoDispose() override
Destructor implementation.
Definition: txop.cc:152
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:266
uint32_t GetMinCw() const
Return the minimum contention window size.
Definition: txop.cc:417
ChannelAccessStatus
Enumeration for channel access status.
Definition: txop.h:109
@ GRANTED
Definition: txop.h:112
@ NOT_REQUESTED
Definition: txop.h:110
@ REQUESTED
Definition: txop.h:111
virtual void NotifyOn()
When on operation occurs, channel access will be started.
Definition: txop.cc:718
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:311
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:230
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
Definition: txop.cc:208
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:710
virtual void NotifyChannelReleased(uint8_t linkId)
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: txop.cc:666
std::vector< uint32_t > GetMaxCws() const
Return the maximum contention window size for each link.
Definition: txop.cc:447
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:388
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:302
Txop()
Definition: txop.cc:134
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: txop.cc:169
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:729
std::vector< uint32_t > GetMinCws() const
Return the minimum contention window size for each link.
Definition: txop.cc:423
std::vector< uint8_t > GetAifsns() const
Return the number of slots that make up an AIFS for each link.
Definition: txop.cc:471
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound, uint8_t linkId)
Update backoff slots for the given link that nSlots has passed.
Definition: txop.cc:335
Time GetBackoffStart(uint8_t linkId) const
Return the time when the backoff procedure started on the given link.
Definition: txop.cc:329
void SetMaxCws(std::vector< uint32_t > maxCws)
Set the maximum contention window size for each link.
Definition: txop.cc:272
void SetTxopLimits(const std::vector< Time > &txopLimits)
Set the TXOP limit for each link.
Definition: txop.cc:394
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
Definition: txop.h:559
void SwapLinks(std::map< uint8_t, uint8_t > links)
Swap the links based on the information included in the given map.
Definition: txop.cc:184
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:201
std::vector< Time > GetTxopLimits() const
Return the TXOP limit for each link.
Definition: txop.cc:495
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition: txop.cc:178
static TypeId GetTypeId()
Get the type ID.
Definition: txop.cc:50
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:364
uint32_t GetCw(uint8_t linkId) const
Get the current value of the CW variable for the given link.
Definition: txop.cc:296
void SetMinCws(std::vector< uint32_t > minCws)
Set the minimum contention window size for each link.
Definition: txop.cc:242
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
Definition: txop.cc:219
virtual void GenerateBackoff(uint8_t linkId)
Generate a new backoff for the given link now.
Definition: txop.cc:688
BackoffValueTracedCallback m_backoffTrace
backoff trace value
Definition: txop.h:571
virtual void NotifyAccessRequested(uint8_t linkId)
Notify that access request has been received for the given link.
Definition: txop.cc:652
void SetAifsns(std::vector< uint8_t > aifsns)
Set the number of slots that make up an AIFS for each link.
Definition: txop.cc:370
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: txop.h:561
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:146
void StartBackoffNow(uint32_t nSlots, uint8_t linkId)
Definition: txop.cc:346
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:659
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of LinkEntity objects.
Definition: txop.h:583
void RequestAccess(uint8_t linkId)
Request access to the ChannelAccessManager associated with the given link.
Definition: txop.cc:678
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:236
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
Definition: txop.cc:465
uint32_t GetBackoffSlots(uint8_t linkId) const
Return the current number of backoff slots on the given link.
Definition: txop.cc:323
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:522
virtual void NotifySleep(uint8_t linkId)
Notify that the given link switched to sleep mode.
Definition: txop.cc:697
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:441
void DoInitialize() override
Initialize() implementation.
Definition: txop.cc:635
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
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:590
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1185
const std::set< uint8_t > & GetLinkIds() const
Definition: wifi-mac.cc:953
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:884
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
#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
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition: nstime.h:1427
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1407
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:76
#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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:630
#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.
@ 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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_DEBUG
Full voluminous logging to support debugging.
Definition: log.h:112