wifi: WifiMacQueue Peek methods return pointers to non-const items
MPDUs stay in the queue until acknowledged or discarded. Normal operations on the TX path consist in peeking one or more frames and transmit them. Operations performed before transmission, such as aggregation, setting the QoS Ack policy, setting the Duration/ID, etc., require the ability to modify the frames.
This commit is contained in:
committed by
Stefano Avallone
parent
c9c01e7e2b
commit
9362cea5bd
@@ -907,8 +907,8 @@ FrameExchangeManager::NotifyInternalCollision (Ptr<Txop> txop)
|
||||
// sent. As an approximation, we consider the frame peeked from the queues of the AC.
|
||||
Ptr<QosTxop> qosTxop = (txop->IsQosTxop () ? StaticCast<QosTxop> (txop) : nullptr);
|
||||
|
||||
Ptr<const WifiMacQueueItem> mpdu = (qosTxop ? qosTxop->PeekNextMpdu ()
|
||||
: txop->GetWifiMacQueue ()->Peek ());
|
||||
auto mpdu = (qosTxop ? StaticCast<const WifiMacQueueItem> (qosTxop->PeekNextMpdu ())
|
||||
: txop->GetWifiMacQueue ()->Peek ());
|
||||
|
||||
if (mpdu)
|
||||
{
|
||||
|
||||
@@ -1281,7 +1281,6 @@ HeFrameExchangeManager::ReceiveBasicTrigger (const CtrlTriggerHeader& trigger, c
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem> mpdu;
|
||||
Ptr<WifiPsdu> psdu;
|
||||
WifiTxParameters txParams;
|
||||
WifiTxVector tbTxVector = GetHeTbTxVector (trigger, hdr.GetAddr2 ());
|
||||
@@ -1303,7 +1302,8 @@ HeFrameExchangeManager::ReceiveBasicTrigger (const CtrlTriggerHeader& trigger, c
|
||||
txParams.m_txVector = tbTxVector;
|
||||
|
||||
// first, check if there is a pending BlockAckReq frame
|
||||
if ((mpdu = edca->GetBaManager ()->GetBar (false, tid, hdr.GetAddr2 ()))
|
||||
if (Ptr<const WifiMacQueueItem> mpdu;
|
||||
(mpdu = edca->GetBaManager ()->GetBar (false, tid, hdr.GetAddr2 ()))
|
||||
&& TryAddMpdu (mpdu, txParams, ppduDuration))
|
||||
{
|
||||
NS_LOG_DEBUG ("Sending a BAR within a TB PPDU");
|
||||
@@ -1312,7 +1312,8 @@ HeFrameExchangeManager::ReceiveBasicTrigger (const CtrlTriggerHeader& trigger, c
|
||||
}
|
||||
|
||||
// otherwise, check if a suitable data frame is available
|
||||
if ((mpdu = edca->PeekNextMpdu (tid, hdr.GetAddr2 ())))
|
||||
if (Ptr<WifiMacQueueItem> mpdu;
|
||||
(mpdu = edca->PeekNextMpdu (tid, hdr.GetAddr2 ())))
|
||||
{
|
||||
Ptr<WifiMacQueueItem> item = edca->GetNextMpdu (mpdu, txParams, ppduDuration, false);
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ HtFrameExchangeManager::StartFrameExchange (Ptr<QosTxop> edca, Time availableTim
|
||||
return true;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem> peekedItem = edca->PeekNextMpdu ();
|
||||
Ptr<WifiMacQueueItem> peekedItem = edca->PeekNextMpdu ();
|
||||
|
||||
// Even though channel access is requested when the queue is not empty, at
|
||||
// the time channel access is granted the lifetime of the packet might be
|
||||
@@ -469,7 +469,7 @@ HtFrameExchangeManager::SendMpduFromBaManager (Ptr<QosTxop> edca, Time available
|
||||
}
|
||||
|
||||
bool
|
||||
HtFrameExchangeManager::SendDataFrame (Ptr<const WifiMacQueueItem> peekedItem,
|
||||
HtFrameExchangeManager::SendDataFrame (Ptr<WifiMacQueueItem> peekedItem,
|
||||
Time availableTime, bool initialFrame)
|
||||
{
|
||||
NS_ASSERT (peekedItem && peekedItem->GetHeader ().IsQosData ()
|
||||
|
||||
@@ -314,7 +314,7 @@ protected:
|
||||
* limit can be exceeded
|
||||
* \return true if frame is transmitted, false otherwise
|
||||
*/
|
||||
virtual bool SendDataFrame (Ptr<const WifiMacQueueItem> peekedItem,
|
||||
virtual bool SendDataFrame (Ptr<WifiMacQueueItem> peekedItem,
|
||||
Time availableTime, bool initialFrame);
|
||||
|
||||
/**
|
||||
|
||||
@@ -223,7 +223,7 @@ MpduAggregator::GetNextAmpdu (Ptr<WifiMacQueueItem> mpdu, WifiTxParameters& txPa
|
||||
mpduList.push_back (nextMpdu);
|
||||
|
||||
// If allowed by the BA agreement, get the next MPDU
|
||||
Ptr<const WifiMacQueueItem> peekedMpdu;
|
||||
Ptr<WifiMacQueueItem> peekedMpdu;
|
||||
peekedMpdu = qosTxop->PeekNextMpdu (tid, recipient, nextMpdu);
|
||||
nextMpdu = 0;
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ QosFrameExchangeManager::StartFrameExchange (Ptr<QosTxop> edca, Time availableTi
|
||||
{
|
||||
NS_LOG_FUNCTION (this << edca << availableTime << initialFrame);
|
||||
|
||||
Ptr<const WifiMacQueueItem> mpdu = edca->PeekNextMpdu ();
|
||||
Ptr<WifiMacQueueItem> mpdu = edca->PeekNextMpdu ();
|
||||
|
||||
// Even though channel access is requested when the queue is not empty, at
|
||||
// the time channel access is granted the lifetime of the packet might be
|
||||
|
||||
@@ -352,13 +352,13 @@ QosTxop::IsQosOldPacket (Ptr<const WifiMacQueueItem> mpdu)
|
||||
return false;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem>
|
||||
QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient, Ptr<const WifiMacQueueItem> item)
|
||||
Ptr<WifiMacQueueItem>
|
||||
QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient, Ptr<WifiMacQueueItem> item)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << +tid << recipient << item);
|
||||
|
||||
// lambda to peek the next frame
|
||||
auto peek = [this, &tid, &recipient, &item] () -> Ptr<const WifiMacQueueItem>
|
||||
auto peek = [this, &tid, &recipient, &item] () -> Ptr<WifiMacQueueItem>
|
||||
{
|
||||
if (tid == 8 && recipient.IsBroadcast ()) // undefined TID and recipient
|
||||
{
|
||||
@@ -439,7 +439,7 @@ QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient, Ptr<const WifiMacQue
|
||||
}
|
||||
|
||||
Ptr<WifiMacQueueItem>
|
||||
QosTxop::GetNextMpdu (Ptr<const WifiMacQueueItem> peekedItem, WifiTxParameters& txParams,
|
||||
QosTxop::GetNextMpdu (Ptr<WifiMacQueueItem> peekedItem, WifiTxParameters& txParams,
|
||||
Time availableTime, bool initialFrame)
|
||||
{
|
||||
NS_ASSERT (peekedItem);
|
||||
|
||||
@@ -308,9 +308,9 @@ public:
|
||||
* \param item the item after which the search starts from
|
||||
* \returns the peeked frame.
|
||||
*/
|
||||
Ptr<const WifiMacQueueItem> PeekNextMpdu (uint8_t tid = 8,
|
||||
Mac48Address recipient = Mac48Address::GetBroadcast (),
|
||||
Ptr<const WifiMacQueueItem> item = nullptr);
|
||||
Ptr<WifiMacQueueItem> PeekNextMpdu (uint8_t tid = 8,
|
||||
Mac48Address recipient = Mac48Address::GetBroadcast (),
|
||||
Ptr<WifiMacQueueItem> item = nullptr);
|
||||
/**
|
||||
* Prepare the frame to transmit starting from the MPDU that has been previously
|
||||
* peeked by calling PeekNextMpdu. A frame is only returned if it meets the
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
* \param initialFrame true if the frame is the initial PPDU of a TXOP
|
||||
* \return the frame to transmit or a null pointer if no frame meets the time constraints
|
||||
*/
|
||||
Ptr<WifiMacQueueItem> GetNextMpdu (Ptr<const WifiMacQueueItem> peekedItem, WifiTxParameters& txParams,
|
||||
Ptr<WifiMacQueueItem> GetNextMpdu (Ptr<WifiMacQueueItem> peekedItem, WifiTxParameters& txParams,
|
||||
Time availableTime, bool initialFrame);
|
||||
|
||||
/**
|
||||
|
||||
@@ -222,7 +222,7 @@ WifiMacQueue::Peek (void) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem>
|
||||
Ptr<WifiMacQueueItem>
|
||||
WifiMacQueue::PeekByAddress (Mac48Address dest, Ptr<const WifiMacQueueItem> item) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << dest << item);
|
||||
@@ -248,7 +248,7 @@ WifiMacQueue::PeekByAddress (Mac48Address dest, Ptr<const WifiMacQueueItem> item
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem>
|
||||
Ptr<WifiMacQueueItem>
|
||||
WifiMacQueue::PeekByTid (uint8_t tid, Ptr<const WifiMacQueueItem> item) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << +tid << item);
|
||||
@@ -273,7 +273,7 @@ WifiMacQueue::PeekByTid (uint8_t tid, Ptr<const WifiMacQueueItem> item) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem>
|
||||
Ptr<WifiMacQueueItem>
|
||||
WifiMacQueue::PeekByTidAndAddress (uint8_t tid, Mac48Address dest, Ptr<const WifiMacQueueItem> item) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << +tid << dest << item);
|
||||
@@ -299,7 +299,7 @@ WifiMacQueue::PeekByTidAndAddress (uint8_t tid, Mac48Address dest, Ptr<const Wif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem>
|
||||
Ptr<WifiMacQueueItem>
|
||||
WifiMacQueue::PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets,
|
||||
Ptr<const WifiMacQueueItem> item) const
|
||||
{
|
||||
|
||||
@@ -144,8 +144,8 @@ public:
|
||||
*
|
||||
* \return the peeked packet or nullptr if no packet was found
|
||||
*/
|
||||
Ptr<const WifiMacQueueItem> PeekByAddress (Mac48Address dest,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
Ptr<WifiMacQueueItem> PeekByAddress (Mac48Address dest,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
/**
|
||||
* Search and return, if present in the queue, the first packet having the
|
||||
* TID equal to <i>tid</i>. If <i>item</i> is not a null pointer, the search
|
||||
@@ -158,8 +158,8 @@ public:
|
||||
*
|
||||
* \return the peeked packet or nullptr if no packet was found
|
||||
*/
|
||||
Ptr<const WifiMacQueueItem> PeekByTid (uint8_t tid,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
Ptr<WifiMacQueueItem> PeekByTid (uint8_t tid,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
/**
|
||||
* Search and return, if present in the queue, the first packet having the
|
||||
* receiver address equal to <i>dest</i>, and TID equal to <i>tid</i>.
|
||||
@@ -175,8 +175,8 @@ public:
|
||||
*
|
||||
* \return the peeked packet or nullptr if no packet was found
|
||||
*/
|
||||
Ptr<const WifiMacQueueItem> PeekByTidAndAddress (uint8_t tid, Mac48Address dest,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
Ptr<WifiMacQueueItem> PeekByTidAndAddress (uint8_t tid, Mac48Address dest,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
/**
|
||||
* Return first available packet for transmission. If <i>item</i> is not a null
|
||||
* pointer, the search starts from the packet following <i>item</i> in the queue;
|
||||
@@ -188,8 +188,8 @@ public:
|
||||
*
|
||||
* \return the peeked packet or nullptr if no packet was found
|
||||
*/
|
||||
Ptr<const WifiMacQueueItem> PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
Ptr<WifiMacQueueItem> PeekFirstAvailable (const Ptr<QosBlockedDestinations> blockedPackets = nullptr,
|
||||
Ptr<const WifiMacQueueItem> item = nullptr) const;
|
||||
/**
|
||||
* Remove the packet in the front of the queue.
|
||||
*
|
||||
|
||||
@@ -194,7 +194,7 @@ AmpduAggregationTest::DoRun (void)
|
||||
|
||||
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
|
||||
|
||||
Ptr<const WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
Ptr<WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
WifiTxParameters txParams;
|
||||
txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader (), m_phy->GetChannelWidth ());
|
||||
Ptr<WifiMacQueueItem> item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true);
|
||||
@@ -425,7 +425,7 @@ TwoLevelAggregationTest::DoRun (void)
|
||||
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (Create<Packet> (1500), hdr));
|
||||
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (Create<Packet> (1500), hdr));
|
||||
|
||||
Ptr<const WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
Ptr<WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
WifiTxParameters txParams;
|
||||
txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader (), m_phy->GetChannelWidth ());
|
||||
htFem->TryAddMpdu (peeked, txParams, Time::Min ());
|
||||
@@ -689,7 +689,7 @@ HeAggregationTest::DoRunSubTest (uint16_t bufferSize)
|
||||
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
|
||||
}
|
||||
|
||||
Ptr<const WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
Ptr<WifiMacQueueItem> peeked = m_mac->GetBEQueue ()->PeekNextMpdu ();
|
||||
WifiTxParameters txParams;
|
||||
txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader (), m_phy->GetChannelWidth ());
|
||||
Ptr<WifiMacQueueItem> item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true);
|
||||
|
||||
@@ -199,7 +199,7 @@ TestMultiUserScheduler::SelectTxFormat (void)
|
||||
|
||||
for (auto& sta : staList)
|
||||
{
|
||||
Ptr<const WifiMacQueueItem> peeked = m_apMac->GetQosTxop (AC_BE)->PeekNextMpdu (0, sta.second);
|
||||
Ptr<WifiMacQueueItem> peeked = m_apMac->GetQosTxop (AC_BE)->PeekNextMpdu (0, sta.second);
|
||||
|
||||
if (!peeked)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user