@@ -278,9 +278,9 @@ InterferenceHelper::CalculateChunkSuccessRate (double snir, Time duration, WifiM
278278}
279279
280280double
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
841849struct 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+
861880struct InterferenceHelper ::SnrPer
862881InterferenceHelper::CalculateLegacyPhyHeaderSnrPer (Ptr<Event> event) const
863882{
0 commit comments