wifi: Reduce use of std::make_pair

This commit is contained in:
Sébastien Deronne
2023-11-11 17:23:42 +01:00
committed by Sébastien Deronne
parent 5a5ab62b4d
commit 24d270d0ae
3 changed files with 27 additions and 39 deletions

View File

@@ -461,9 +461,8 @@ HePhy::DoGetEvent(Ptr<const WifiPpdu> ppdu, RxPowerWattPerChannelBand& rxPowersW
// detection window. If a preamble is received after the preamble detection window, it is stored
// anyway because this is needed for HE TB PPDUs in order to properly update the received power
// in InterferenceHelper. The map is cleaned anyway at the end of the current reception.
const auto uidPreamblePair = std::make_pair(ppdu->GetUid(), ppdu->GetPreamble());
const auto& currentPreambleEvents = GetCurrentPreambleEvents();
const auto it = currentPreambleEvents.find(uidPreamblePair);
const auto it = currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
if (const auto isResponseToTrigger = (m_previouslyTxPpduUid == ppdu->GetUid());
ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU || isResponseToTrigger)
{
@@ -836,8 +835,8 @@ HePhy::DoStartReceivePayload(Ptr<Event> event)
{
NS_LOG_DEBUG("Receiving PSDU in HE TB PPDU");
uint16_t staId = GetStaId(ppdu);
m_signalNoiseMap.insert({std::make_pair(ppdu->GetUid(), staId), SignalNoiseDbm()});
m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
m_signalNoiseMap.insert({{ppdu->GetUid(), staId}, SignalNoiseDbm()});
m_statusPerMpduMap.insert({{ppdu->GetUid(), staId}, std::vector<bool>()});
// for HE TB PPDUs, ScheduleEndOfMpdus and EndReceive are scheduled by
// StartReceiveMuPayload
NS_ASSERT(!m_beginMuPayloadRxEvents.empty());
@@ -959,8 +958,8 @@ HePhy::StartReceiveMuPayload(Ptr<Event> event)
m_endRxPayloadEvents.push_back(
Simulator::Schedule(payloadDuration, &HePhy::EndReceivePayload, this, event));
uint16_t staId = GetStaId(ppdu);
m_signalNoiseMap.insert({std::make_pair(ppdu->GetUid(), staId), SignalNoiseDbm()});
m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
m_signalNoiseMap.insert({{ppdu->GetUid(), staId}, SignalNoiseDbm()});
m_statusPerMpduMap.insert({{ppdu->GetUid(), staId}, std::vector<bool>()});
// Notify the MAC about the start of a new HE TB PPDU, so that it can reschedule the timeout
NotifyPayloadBegin(ppdu->GetTxVector(), payloadDuration);
}
@@ -990,14 +989,12 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
ru.GetRuType(),
ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(group.front().first, group.back().second);
// for a TX spectrum, the guard bandwidth is a function of the transmission channel width
// and the spectrum width equals the transmission channel width (hence bandIndex equals 0)
auto indices = ConvertHeRuSubcarriers(channelWidth,
GetGuardBandwidth(channelWidth),
m_wifiPhy->GetSubcarrierSpacing(),
subcarrierRange,
{group.front().first, group.back().second},
0);
auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices);
return {indices, frequencies};
@@ -1014,15 +1011,13 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
ru.GetRuType(),
ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(group.front().first, group.back().second);
// for an RX spectrum, the guard bandwidth is a function of the operating channel width
// and the spectrum width equals the operating channel width
auto indices = ConvertHeRuSubcarriers(
channelWidth,
GetGuardBandwidth(m_wifiPhy->GetChannelWidth()),
m_wifiPhy->GetSubcarrierSpacing(),
subcarrierRange,
{group.front().first, group.back().second},
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth));
auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices);
return {indices, frequencies};
@@ -1047,13 +1042,11 @@ HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const
nonOfdmaRu.GetRuType(),
nonOfdmaRu.GetPhyIndex(channelWidth,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(groupPreamble.front().first, groupPreamble.back().second);
auto indices = ConvertHeRuSubcarriers(
channelWidth,
GetGuardBandwidth(m_wifiPhy->GetChannelWidth()),
m_wifiPhy->GetSubcarrierSpacing(),
subcarrierRange,
{groupPreamble.front().first, groupPreamble.back().second},
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth));
auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices);
return {indices, frequencies};
@@ -1764,7 +1757,7 @@ HePhy::GetWifiConstPsduMap(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVecto
staId = txVector.GetHeMuUserInfoMap().begin()->first;
}
return WifiConstPsduMap({std::make_pair(staId, psdu)});
return WifiConstPsduMap({{staId, psdu}});
}
uint32_t

View File

@@ -816,7 +816,7 @@ InterferenceHelper::GetPreviousPosition(Time moment, NiChangesPerBand::iterator
InterferenceHelper::NiChanges::iterator
InterferenceHelper::AddNiChangeEvent(Time moment, NiChange change, NiChangesPerBand::iterator niIt)
{
return niIt->second.insert(GetNextPosition(moment, niIt), std::make_pair(moment, change));
return niIt->second.insert(GetNextPosition(moment, niIt), {moment, change});
}
void

View File

@@ -210,7 +210,7 @@ PhyEntity::CalculatePhyPreambleAndHeaderDuration(const WifiTxVector& txVector) c
WifiConstPsduMap
PhyEntity::GetWifiConstPsduMap(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) const
{
return WifiConstPsduMap({std::make_pair(SU_STA_ID, psdu)});
return WifiConstPsduMap({{SU_STA_ID, psdu}});
}
Ptr<const WifiPsdu>
@@ -229,8 +229,7 @@ PhyEntity::GetPhyHeaderSections(const WifiTxVector& txVector, Time ppduStart) co
while (field != WIFI_PPDU_FIELD_DATA)
{
Time duration = GetDuration(field, txVector);
map[field] =
std::make_pair(std::make_pair(start, start + duration), GetSigMode(field, txVector));
map[field] = {{start, start + duration}, GetSigMode(field, txVector)};
// Move to next field
start += duration;
field = GetNextField(field, txVector.GetPreambleType());
@@ -524,8 +523,7 @@ PhyEntity::DropPreambleEvent(Ptr<const WifiPpdu> ppdu, WifiPhyRxfailureReason re
{
NS_LOG_FUNCTION(this << ppdu << reason << endRx);
m_wifiPhy->NotifyRxDrop(GetAddressedPsduInPpdu(ppdu), reason);
auto it = m_wifiPhy->m_currentPreambleEvents.find(
std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()));
auto it = m_wifiPhy->m_currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
if (it != m_wifiPhy->m_currentPreambleEvents.end())
{
m_wifiPhy->m_currentPreambleEvents.erase(it);
@@ -542,8 +540,7 @@ void
PhyEntity::ErasePreambleEvent(Ptr<const WifiPpdu> ppdu, Time rxDuration)
{
NS_LOG_FUNCTION(this << ppdu << rxDuration);
auto it = m_wifiPhy->m_currentPreambleEvents.find(
std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()));
auto it = m_wifiPhy->m_currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
if (it != m_wifiPhy->m_currentPreambleEvents.end())
{
m_wifiPhy->m_currentPreambleEvents.erase(it);
@@ -583,8 +580,8 @@ PhyEntity::DoStartReceivePayload(Ptr<Event> event)
Ptr<const WifiPpdu> ppdu = event->GetPpdu();
NS_LOG_DEBUG("Receiving PSDU");
uint16_t staId = GetStaId(ppdu);
m_signalNoiseMap.insert({std::make_pair(ppdu->GetUid(), staId), SignalNoiseDbm()});
m_statusPerMpduMap.insert({std::make_pair(ppdu->GetUid(), staId), std::vector<bool>()});
m_signalNoiseMap.insert({{ppdu->GetUid(), staId}, SignalNoiseDbm()});
m_statusPerMpduMap.insert({{ppdu->GetUid(), staId}, std::vector<bool>()});
ScheduleEndOfMpdus(event);
const auto& txVector = event->GetPpdu()->GetTxVector();
Time payloadDuration = ppdu->GetTxDuration() - CalculatePhyPreambleAndHeaderDuration(txVector);
@@ -678,7 +675,7 @@ PhyEntity::EndOfMpdu(Ptr<Event> event,
<< ", correct reception: " << rxInfo.first << ", Signal/Noise: "
<< rxInfo.second.signal << "/" << rxInfo.second.noise << "dBm");
auto signalNoiseIt = m_signalNoiseMap.find(std::make_pair(ppdu->GetUid(), staId));
auto signalNoiseIt = m_signalNoiseMap.find({ppdu->GetUid(), staId});
NS_ASSERT(signalNoiseIt != m_signalNoiseMap.end());
signalNoiseIt->second = rxInfo.second;
@@ -686,7 +683,7 @@ PhyEntity::EndOfMpdu(Ptr<Event> event,
rxSignalInfo.snr = rxInfo.second.signal / rxInfo.second.noise;
rxSignalInfo.rssi = rxInfo.second.signal;
auto statusPerMpduIt = m_statusPerMpduMap.find(std::make_pair(ppdu->GetUid(), staId));
auto statusPerMpduIt = m_statusPerMpduMap.find({ppdu->GetUid(), staId});
NS_ASSERT(statusPerMpduIt != m_statusPerMpduMap.end());
statusPerMpduIt->second.push_back(rxInfo.first);
@@ -715,9 +712,9 @@ PhyEntity::EndReceivePayload(Ptr<Event> event)
Ptr<const WifiPsdu> psdu = GetAddressedPsduInPpdu(ppdu);
m_wifiPhy->NotifyRxEnd(psdu);
auto signalNoiseIt = m_signalNoiseMap.find(std::make_pair(ppdu->GetUid(), staId));
auto signalNoiseIt = m_signalNoiseMap.find({ppdu->GetUid(), staId});
NS_ASSERT(signalNoiseIt != m_signalNoiseMap.end());
auto statusPerMpduIt = m_statusPerMpduMap.find(std::make_pair(ppdu->GetUid(), staId));
auto statusPerMpduIt = m_statusPerMpduMap.find({ppdu->GetUid(), staId});
NS_ASSERT(statusPerMpduIt != m_statusPerMpduMap.end());
if (std::count(statusPerMpduIt->second.begin(), statusPerMpduIt->second.end(), true))
@@ -792,7 +789,7 @@ PhyEntity::GetReceptionStatus(Ptr<const WifiPsdu> psdu,
channelWidthAndBand.first,
channelWidthAndBand.second,
staId,
std::make_pair(relativeMpduStart, relativeMpduStart + mpduDuration));
{relativeMpduStart, relativeMpduStart + mpduDuration});
WifiMode mode = event->GetPpdu()->GetTxVector().GetMode(staId);
NS_LOG_DEBUG("rate=" << (mode.GetDataRate(event->GetPpdu()->GetTxVector(), staId))
@@ -813,12 +810,12 @@ PhyEntity::GetReceptionStatus(Ptr<const WifiPsdu> psdu,
m_wifiPhy->m_postReceptionErrorModel->IsCorrupt(psdu->GetPacket()->Copy())))
{
NS_LOG_DEBUG("Reception succeeded: " << psdu);
return std::make_pair(true, signalNoise);
return {true, signalNoise};
}
else
{
NS_LOG_DEBUG("Reception failed: " << psdu);
return std::make_pair(false, signalNoise);
return {false, signalNoise};
}
}
@@ -826,7 +823,7 @@ std::pair<uint16_t, WifiSpectrumBandInfo>
PhyEntity::GetChannelWidthAndBand(const WifiTxVector& txVector, uint16_t /* staId */) const
{
uint16_t channelWidth = GetRxChannelWidth(txVector);
return std::make_pair(channelWidth, GetPrimaryBand(channelWidth));
return {channelWidth, GetPrimaryBand(channelWidth)};
}
const std::map<std::pair<uint64_t, WifiPreamble>, Ptr<Event>>&
@@ -840,8 +837,7 @@ PhyEntity::AddPreambleEvent(Ptr<Event> event)
{
NS_LOG_FUNCTION(this << *event);
Ptr<const WifiPpdu> ppdu = event->GetPpdu();
m_wifiPhy->m_currentPreambleEvents.insert(
{std::make_pair(ppdu->GetUid(), ppdu->GetPreamble()), event});
m_wifiPhy->m_currentPreambleEvents.insert({{ppdu->GetUid(), ppdu->GetPreamble()}, event});
}
Ptr<Event>
@@ -849,9 +845,8 @@ PhyEntity::DoGetEvent(Ptr<const WifiPpdu> ppdu, RxPowerWattPerChannelBand& rxPow
{
// We store all incoming preamble events, and a decision is made at the end of the preamble
// detection window.
const auto uidPreamblePair = std::make_pair(ppdu->GetUid(), ppdu->GetPreamble());
const auto& currentPreambleEvents = GetCurrentPreambleEvents();
const auto it = currentPreambleEvents.find(uidPreamblePair);
const auto it = currentPreambleEvents.find({ppdu->GetUid(), ppdu->GetPreamble()});
if (it != currentPreambleEvents.cend())
{
// received another signal with the same content
@@ -982,7 +977,7 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
<< event->GetPpdu()->GetUid());
m_wifiPhy->NotifyRxDrop(GetAddressedPsduInPpdu(event->GetPpdu()), BUSY_DECODING_PREAMBLE);
auto it = m_wifiPhy->m_currentPreambleEvents.find(
std::make_pair(event->GetPpdu()->GetUid(), event->GetPpdu()->GetPreamble()));
{event->GetPpdu()->GetUid(), event->GetPpdu()->GetPreamble()});
m_wifiPhy->m_currentPreambleEvents.erase(it);
// This is needed to cleanup the m_firstPowerPerBand so that the first power corresponds to
// the power at the start of the PPDU