wifi: Keep timestamp when replacing a BAR in ScheduleBar()

This commit is contained in:
Stefano Avallone
2023-02-13 17:30:38 +01:00
parent ad4d9cc5cd
commit 4544305b45
6 changed files with 30 additions and 30 deletions

View File

@@ -600,8 +600,6 @@ BlockAckManager::NotifyDiscardedMpdu(Ptr<const WifiMpdu> mpdu)
// schedule a BlockAckRequest
NS_LOG_DEBUG("Schedule a Block Ack Request for agreement (" << recipient << ", " << +tid
<< ")");
Ptr<Packet> bar = Create<Packet>();
bar->AddHeader(GetBlockAckReqHeader(recipient, tid));
WifiMacHeader hdr;
hdr.SetType(WIFI_MAC_CTL_BACKREQ);
@@ -612,7 +610,7 @@ BlockAckManager::NotifyDiscardedMpdu(Ptr<const WifiMpdu> mpdu)
hdr.SetNoRetry();
hdr.SetNoMoreFragments();
ScheduleBar(Create<WifiMpdu>(bar, hdr));
ScheduleBar(GetBlockAckReqHeader(recipient, tid), hdr);
}
void
@@ -660,31 +658,27 @@ BlockAckManager::GetBlockAckReqHeader(const Mac48Address& recipient, uint8_t tid
}
void
BlockAckManager::ScheduleBar(Ptr<WifiMpdu> bar)
BlockAckManager::ScheduleBar(const CtrlBAckRequestHeader& reqHdr, const WifiMacHeader& hdr)
{
NS_LOG_FUNCTION(this << *bar);
NS_ASSERT(bar->GetHeader().IsBlockAckReq());
NS_LOG_FUNCTION(this << reqHdr << hdr);
CtrlBAckRequestHeader reqHdr;
bar->GetPacket()->PeekHeader(reqHdr);
uint8_t tid = reqHdr.GetTidInfo();
WifiContainerQueueId queueId(WIFI_CTL_QUEUE,
WIFI_UNICAST,
bar->GetHeader().GetAddr1(),
std::nullopt);
WifiContainerQueueId queueId(WIFI_CTL_QUEUE, WIFI_UNICAST, hdr.GetAddr1(), std::nullopt);
auto pkt = Create<Packet>();
pkt->AddHeader(reqHdr);
Ptr<WifiMpdu> item = nullptr;
// if a BAR for the given agreement is present, replace it with the new one
while ((item = m_queue->PeekByQueueId(queueId, item)))
{
if (item->GetHeader().IsBlockAckReq() &&
item->GetHeader().GetAddr1() == bar->GetHeader().GetAddr1())
if (item->GetHeader().IsBlockAckReq() && item->GetHeader().GetAddr1() == hdr.GetAddr1())
{
CtrlBAckRequestHeader otherHdr;
item->GetPacket()->PeekHeader(otherHdr);
if (otherHdr.GetTidInfo() == tid)
{
auto bar = Create<WifiMpdu>(pkt, hdr, item->GetTimestamp());
// replace item with bar
m_queue->Replace(item, bar);
return;
@@ -692,7 +686,7 @@ BlockAckManager::ScheduleBar(Ptr<WifiMpdu> bar)
}
}
m_queue->Enqueue(bar);
m_queue->Enqueue(Create<WifiMpdu>(pkt, hdr));
}
void

View File

@@ -408,18 +408,19 @@ class BlockAckManager : public Object
CtrlBAckRequestHeader GetBlockAckReqHeader(const Mac48Address& recipient, uint8_t tid) const;
/**
* \param bar the BlockAckRequest to enqueue
* \param reqHdr the BlockAckRequest header
* \param hdr the 802.11 MAC header
*
* Enqueue the given BlockAckRequest into the queue storing the next (MU-)BAR
* Enqueue the given BlockAckRequest into the queue storing the next BAR
* frames to transmit. If a BAR for the same recipient and TID is already present
* in the queue, it is replaced by the new one. If the given BAR is retransmitted,
* it is placed at the head of the queue, otherwise at the tail.
*/
void ScheduleBar(Ptr<WifiMpdu> bar);
void ScheduleBar(const CtrlBAckRequestHeader& reqHdr, const WifiMacHeader& hdr);
/**
* \param muBar the MU-BAR Trigger Frame to enqueue
*
* Enqueue the given MU-BAR Trigger Frame into the queue storing the next (MU-)BAR
* Enqueue the given MU-BAR Trigger Frame into the queue storing the next MU-BAR
* frames to transmit. If the given MU-BAR Trigger Frame is retransmitted,
* it is placed at the head of the queue, otherwise at the tail.
*/

View File

@@ -509,8 +509,9 @@ HeFrameExchangeManager::SendPsduMap()
uint8_t tid = *tids.begin();
NS_ASSERT(m_edca);
m_edca->GetBaManager()->ScheduleBar(
m_mac->GetQosTxop(tid)->PrepareBlockAckRequest(psdu.second->GetAddr1(), tid));
auto [reqHdr, hdr] =
m_mac->GetQosTxop(tid)->PrepareBlockAckRequest(psdu.second->GetAddr1(), tid);
m_edca->GetBaManager()->ScheduleBar(reqHdr, hdr);
}
}

View File

@@ -520,7 +520,10 @@ HtFrameExchangeManager::GetBar(AcIndex ac,
{
if (queue->PeekByTidAndAddress(tid, recipient))
{
selectedBar = m_mac->GetQosTxop(ac)->PrepareBlockAckRequest(recipient, tid);
auto [reqHdr, hdr] = m_mac->GetQosTxop(ac)->PrepareBlockAckRequest(recipient, tid);
auto pkt = Create<Packet>();
pkt->AddHeader(reqHdr);
selectedBar = Create<WifiMpdu>(pkt, hdr);
baManager->RemoveFromSendBarIfDataQueuedList(recipient, tid);
queue->Enqueue(selectedBar);
break;
@@ -1041,7 +1044,8 @@ HtFrameExchangeManager::SendPsdu()
uint8_t tid = *tids.begin();
Ptr<QosTxop> edca = m_mac->GetQosTxop(tid);
GetBaManager(tid)->ScheduleBar(edca->PrepareBlockAckRequest(m_psdu->GetAddr1(), tid));
auto [reqHdr, hdr] = edca->PrepareBlockAckRequest(m_psdu->GetAddr1(), tid);
GetBaManager(tid)->ScheduleBar(reqHdr, hdr);
Simulator::Schedule(txDuration, &HtFrameExchangeManager::TransmissionSucceeded, this);
}
@@ -1401,7 +1405,8 @@ HtFrameExchangeManager::MissedBlockAck(Ptr<WifiPsdu> psdu,
else
{
// missed block ack after data frame with Implicit BAR Ack policy
GetBaManager(tid)->ScheduleBar(edca->PrepareBlockAckRequest(recipient, tid));
auto [reqHdr, hdr] = edca->PrepareBlockAckRequest(recipient, tid);
GetBaManager(tid)->ScheduleBar(reqHdr, hdr);
}
resetCw = false;
}

View File

@@ -287,7 +287,7 @@ QosTxop::GetBaStartingSequence(Mac48Address address, uint8_t tid) const
return m_baManager->GetOriginatorStartingSequence(address, tid);
}
Ptr<WifiMpdu>
std::pair<CtrlBAckRequestHeader, WifiMacHeader>
QosTxop::PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
{
NS_LOG_FUNCTION(this << recipient << +tid);
@@ -297,8 +297,6 @@ QosTxop::PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
CtrlBAckRequestHeader reqHdr =
m_baManager->GetBlockAckReqHeader(recipientMld.value_or(recipient), tid);
Ptr<Packet> bar = Create<Packet>();
bar->AddHeader(reqHdr);
WifiMacHeader hdr;
hdr.SetType(WIFI_MAC_CTL_BACKREQ);
@@ -309,7 +307,7 @@ QosTxop::PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
hdr.SetNoRetry();
hdr.SetNoMoreFragments();
return Create<WifiMpdu>(bar, hdr);
return {reqHdr, hdr};
}
bool

View File

@@ -136,14 +136,15 @@ class QosTxop : public Txop
/**
* \param recipient Address of recipient.
* \param tid traffic ID.
* \return the BlockAckRequest to send
* \return the BlockAckRequest header and the MAC header for the BlockAckReq
*
* Prepare a BlockAckRequest to be sent to <i>recipient</i> for Traffic ID
* <i>tid</i>. The header for the BlockAckRequest is requested to the QosTxop
* corresponding to the given TID. A block ack agreement with the given recipient
* for the given TID must have been established by such QosTxop.
*/
Ptr<WifiMpdu> PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const;
std::pair<CtrlBAckRequestHeader, WifiMacHeader> PrepareBlockAckRequest(Mac48Address recipient,
uint8_t tid) const;
/* Event handlers */
/**