Skip to content

Commit dfc7f88

Browse files
rediet-orangestavallo
authored andcommitted
wifi: Enable windowed PER for PLCP payload
Enables to compute per MPDU PER. Also add a method to get SNR over whole event.
1 parent 90ea875 commit dfc7f88

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed

src/wifi/model/interference-helper.cc

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ InterferenceHelper::CalculateChunkSuccessRate (double snir, Time duration, WifiM
278278
}
279279

280280
double
281-
InterferenceHelper::CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni) const
281+
InterferenceHelper::CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni, std::pair<Time, Time> window) const
282282
{
283-
NS_LOG_FUNCTION (this);
283+
NS_LOG_FUNCTION (this << window.first << window.second);
284284
const WifiTxVector txVector = event->GetTxVector ();
285285
double psr = 1.0; /* Packet Success Rate */
286286
auto j = ni->begin ();
@@ -291,35 +291,43 @@ InterferenceHelper::CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni)
291291
Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (txVector); //packet start time + preamble + L-SIG
292292
Time plcpTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (preamble) + WifiPhy::GetPlcpSigA1Duration (preamble) + WifiPhy::GetPlcpSigA2Duration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A
293293
Time plcpPayloadStart = plcpTrainingSymbolsStart + WifiPhy::GetPlcpTrainingSymbolDuration (txVector) + WifiPhy::GetPlcpSigBDuration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A + Training + SIG-B
294+
Time windowStart = plcpPayloadStart + window.first;
295+
Time windowEnd = plcpPayloadStart + window.second;
294296
double noiseInterferenceW = m_firstPower;
295297
double powerW = event->GetRxPowerW ();
296298
while (++j != ni->end ())
297299
{
298300
Time current = j->first;
299301
NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);
300302
NS_ASSERT (current >= previous);
301-
//Case 1: Both previous and current point to the payload
302-
if (previous >= plcpPayloadStart)
303+
//Case 1: Both previous and current point to the windowed payload
304+
if (previous >= windowStart)
303305
{
304306
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW,
305307
noiseInterferenceW,
306308
txVector.GetChannelWidth ()),
307309
current - previous,
308310
payloadMode, txVector);
309-
NS_LOG_DEBUG ("Both previous and current point to the payload: mode=" << payloadMode << ", psr=" << psr);
311+
NS_LOG_DEBUG ("Both previous and current point to the windowed payload: mode=" << payloadMode << ", psr=" << psr);
310312
}
311-
//Case 2: previous is before payload and current is in the payload
312-
else if (current >= plcpPayloadStart)
313+
//Case 2: previous is before windowed payload and current is in the windowed payload
314+
else if (current >= windowStart)
313315
{
314316
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW,
315317
noiseInterferenceW,
316318
txVector.GetChannelWidth ()),
317-
current - plcpPayloadStart,
319+
current - windowStart,
318320
payloadMode, txVector);
319-
NS_LOG_DEBUG ("previous is before payload and current is in the payload: mode=" << payloadMode << ", psr=" << psr);
321+
NS_LOG_DEBUG ("previous is before windowed payload and current is in the windowed payload: mode=" << payloadMode << ", psr=" << psr);
320322
}
321323
noiseInterferenceW = j->second.GetPower () - powerW;
322324
previous = j->first;
325+
if (previous > windowEnd)
326+
{
327+
NS_LOG_DEBUG ("Stop: new previous=" << previous << " after time window end=" << windowEnd);
328+
break;
329+
}
330+
323331
}
324332
double per = 1 - psr;
325333
return per;
@@ -839,25 +847,36 @@ InterferenceHelper::CalculateNonLegacyPhyHeaderPer (Ptr<const Event> event, NiCh
839847
}
840848

841849
struct InterferenceHelper::SnrPer
842-
InterferenceHelper::CalculatePayloadSnrPer (Ptr<Event> event) const
850+
InterferenceHelper::CalculatePayloadSnrPer (Ptr<Event> event, std::pair<Time, Time> relativeMpduStartStop) const
843851
{
844852
NiChanges ni;
845853
double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
846854
double snr = CalculateSnr (event->GetRxPowerW (),
847855
noiseInterferenceW,
848856
event->GetTxVector ().GetChannelWidth ());
849857

850-
/* calculate the SNIR at the start of the packet and accumulate
858+
/* calculate the SNIR at the start of the MPDU (located through windowing) and accumulate
851859
* all SNIR changes in the snir vector.
852860
*/
853-
double per = CalculatePayloadPer (event, &ni);
861+
double per = CalculatePayloadPer (event, &ni, relativeMpduStartStop);
854862

855863
struct SnrPer snrPer;
856864
snrPer.snr = snr;
857865
snrPer.per = per;
858866
return snrPer;
859867
}
860868

869+
double
870+
InterferenceHelper::CalculateSnr (Ptr<Event> event) const
871+
{
872+
NiChanges ni;
873+
double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
874+
double snr = CalculateSnr (event->GetRxPowerW (),
875+
noiseInterferenceW,
876+
event->GetTxVector ().GetChannelWidth ());
877+
return snr;
878+
}
879+
861880
struct InterferenceHelper::SnrPer
862881
InterferenceHelper::CalculateLegacyPhyHeaderSnrPer (Ptr<Event> event) const
863882
{

src/wifi/model/interference-helper.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,25 @@ class InterferenceHelper
173173
void AddForeignSignal (Time duration, double rxPower);
174174
/**
175175
* Calculate the SNIR at the start of the payload and accumulate
176-
* all SNIR changes in the snir vector.
176+
* all SNIR changes in the snir vector for each MPDU of an A-MPDU.
177+
* This workaround is required in order to provide one PER per MPDU, for
178+
* reception success/failure evaluation, while hiding aggregation details from
179+
* this class.
177180
*
178181
* \param event the event corresponding to the first time the corresponding packet arrives
182+
* \param relativeMpduStartStop the time window (pair of start and end times) of PLCP payload to focus on
179183
*
180-
* \return struct of SNR and PER
184+
* \return struct of SNR and PER (with PER being evaluated over the provided time window)
185+
*/
186+
struct InterferenceHelper::SnrPer CalculatePayloadSnrPer (Ptr<Event> event, std::pair<Time, Time> relativeMpduStartStop) const;
187+
/**
188+
* Calculate the SNIR for the event (starting from now until the event end).
189+
*
190+
* \param event the event corresponding to the first time the corresponding packet arrives
191+
*
192+
* \return the SNR for the packet
181193
*/
182-
struct InterferenceHelper::SnrPer CalculatePayloadSnrPer (Ptr<Event> event) const;
194+
double CalculateSnr (Ptr<Event> event) const;
183195
/**
184196
* Calculate the SNIR at the start of the legacy PHY header and accumulate
185197
* all SNIR changes in the snir vector.
@@ -295,15 +307,17 @@ class InterferenceHelper
295307
*/
296308
double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
297309
/**
298-
* Calculate the error rate of the given payload. The payload can be divided into
310+
* Calculate the error rate of the given PLCP payload only in the provided time
311+
* window (thus enabling per MPDU PER information). The PLCP payload can be divided into
299312
* multiple chunks (e.g. due to interference from other transmissions).
300313
*
301314
* \param event
302315
* \param ni
316+
* \param window time window (pair of start and end times) of PLCP payload to focus on
303317
*
304318
* \return the error rate of the payload
305319
*/
306-
double CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni) const;
320+
double CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni, std::pair<Time, Time> window) const;
307321
/**
308322
* Calculate the error rate of the legacy PHY header. The legacy PHY header
309323
* can be divided into multiple chunks (e.g. due to interference from other transmissions).

src/wifi/model/wifi-phy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,7 @@ WifiPhy::EndReceive (Ptr<Packet> packet, WifiPreamble preamble, MpduType mpdutyp
27392739
NS_ASSERT (event->GetEndTime () == Simulator::Now ());
27402740

27412741
InterferenceHelper::SnrPer snrPer;
2742-
snrPer = m_interference.CalculatePayloadSnrPer (event);
2742+
snrPer = m_interference.CalculatePayloadSnrPer (event, std::make_pair (NanoSeconds (0), Simulator::Now () - event->GetStartTime ())); //TODO update with correct MPDU relative start and stop times
27432743
m_interference.NotifyRxEnd ();
27442744
m_currentEvent = 0;
27452745

0 commit comments

Comments
 (0)