wifi: Allow use of RTS as protection if MPDUs are transmitted via the GCR service

This commit is contained in:
Sébastien Deronne
2023-07-23 15:06:56 +02:00
parent 60136d4f38
commit 636f421756
2 changed files with 28 additions and 10 deletions

View File

@@ -772,7 +772,9 @@ FrameExchangeManager::SendRts(const WifiTxParameters& txParams)
NS_LOG_FUNCTION(this << &txParams);
NS_ASSERT(txParams.GetPsduInfoMap().size() == 1);
Mac48Address receiver = txParams.GetPsduInfoMap().begin()->first;
const auto& hdr = txParams.GetPsduInfoMap().begin()->second.header;
const auto receiver = GetIndividuallyAddressedRecipient(m_mac, hdr);
WifiMacHeader rts;
rts.SetType(WIFI_MAC_CTL_RTS);
@@ -1371,7 +1373,7 @@ FrameExchangeManager::ReceiveMpdu(Ptr<const WifiMpdu> mpdu,
NS_ABORT_MSG_IF(inAmpdu, "Received CTS as part of an A-MPDU");
NS_ASSERT(hdr.GetAddr1() == m_self);
Mac48Address sender = m_mpdu->GetHeader().GetAddr1();
const auto sender = GetIndividuallyAddressedRecipient(m_mac, m_mpdu->GetHeader());
NS_LOG_DEBUG("Received CTS from=" << sender);
SnrTag tag;

View File

@@ -747,7 +747,9 @@ WifiRemoteStationManager::GetRtsTxVector(Mac48Address address, MHz_u allowedWidt
WifiTxVector
WifiRemoteStationManager::GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
{
NS_ASSERT(!to.IsGroup());
auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
NS_ASSERT(!to.IsGroup() ||
(m_wifiMac && (m_wifiMac->GetTypeOfStation() == AP) && apMac->GetGcrManager()));
WifiMode ctsMode = GetControlAnswerMode(rtsTxMode);
WifiTxVector v;
v.SetMode(ctsMode);
@@ -969,11 +971,12 @@ void
WifiRemoteStationManager::ReportRtsFailed(const WifiMacHeader& header)
{
NS_LOG_FUNCTION(this << header);
NS_ASSERT(!header.GetAddr1().IsGroup());
const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
NS_ASSERT(!recipient.IsGroup());
AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
m_ssrc[ac]++;
m_macTxRtsFailed(header.GetAddr1());
DoReportRtsFailed(Lookup(header.GetAddr1()));
m_macTxRtsFailed(recipient);
DoReportRtsFailed(Lookup(recipient));
}
void
@@ -1003,8 +1006,9 @@ WifiRemoteStationManager::ReportRtsOk(const WifiMacHeader& header,
double rtsSnr)
{
NS_LOG_FUNCTION(this << header << ctsSnr << ctsMode << rtsSnr);
NS_ASSERT(!header.GetAddr1().IsGroup());
WifiRemoteStation* station = Lookup(header.GetAddr1());
const auto recipient = GetIndividuallyAddressedRecipient(m_wifiMac, header);
NS_ASSERT(!recipient.IsGroup());
WifiRemoteStation* station = Lookup(recipient);
AcIndex ac = QosUtilsMapTidToAc((header.IsQosData()) ? header.GetQosTid() : 0);
station->m_state->m_info.NotifyTxSuccess(m_ssrc[ac]);
m_ssrc[ac] = 0;
@@ -1178,11 +1182,23 @@ WifiRemoteStationManager::NeedRts(const WifiMacHeader& header, const WifiTxParam
{
NS_LOG_FUNCTION(this << header << &txParams);
auto address = header.GetAddr1();
const auto modulationClass = txParams.m_txVector.GetModulationClass();
if (address.IsGroup())
const auto isGcr = IsGcr(m_wifiMac, header);
if (!isGcr && address.IsGroup())
{
return false;
}
if (isGcr)
{
EnumValue<GroupcastProtectionMode> enumValue;
auto apMac = DynamicCast<ApWifiMac>(m_wifiMac);
apMac->GetGcrManager()->GetAttribute("GcrProtectionMode", enumValue);
if (enumValue.Get() != GroupcastProtectionMode::RTS_CTS)
{
return false;
}
address = apMac->GetGcrManager()->GetIndividuallyAddressedRecipient(address);
}
const auto modulationClass = txParams.m_txVector.GetModulationClass();
if (m_erpProtectionMode == RTS_CTS &&
((modulationClass == WIFI_MOD_CLASS_ERP_OFDM) || (modulationClass == WIFI_MOD_CLASS_HT) ||
(modulationClass == WIFI_MOD_CLASS_VHT) || (modulationClass == WIFI_MOD_CLASS_HE) ||