From df97ca42be1c8b1f147498d41803992243766aba Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 9 Aug 2023 15:57:19 +0200 Subject: [PATCH] wifi: Schedule channel access request upon enqueuing a packet This allows us to request channel access after that all the packets of a burst are enqueued, instead of requesting channel access right after the first packet --- src/wifi/model/txop.cc | 9 ++++++++- src/wifi/model/txop.h | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 1a645db79..c601c14eb 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -545,7 +545,14 @@ Txop::Queue(Ptr mpdu) m_queue->Enqueue(mpdu); for (const auto linkId : linkIds) { - StartAccessIfNeeded(linkId); + // schedule a call to StartAccessIfNeeded() to request channel access after that all the + // packets of a burst have been enqueued, instead of requesting channel access right after + // the first packet. The call to StartAccessIfNeeded() is scheduled only after the first + // packet + if (auto& event = GetLink(linkId).accessRequest.event; !event.IsRunning()) + { + event = Simulator::ScheduleNow(&Txop::StartAccessIfNeeded, this, linkId); + } } } diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index 189d2d545..84a341fc8 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -509,6 +509,12 @@ class Txop : public Object uint8_t aifsn{0}; //!< the AIFSN Time txopLimit{0}; //!< the TXOP limit time ChannelAccessStatus access{NOT_REQUESTED}; //!< channel access status + + mutable class + { + friend void Txop::Queue(Ptr); + EventId event; + } accessRequest; //!< access request event, to be used by Txop::Queue() only }; /**