Fixed PER bug.
1.1 --- a/src/devices/uan/uan-phy-gen.cc Wed Apr 01 22:50:54 2009 -0700
1.2 +++ b/src/devices/uan/uan-phy-gen.cc Thu Apr 02 23:34:42 2009 -0700
1.3 @@ -32,6 +32,7 @@
1.4 #include "ns3/uan-tx-mode.h"
1.5 #include "ns3/node.h"
1.6 #include "ns3/uinteger.h"
1.7 +#include "ns3/random-variable.h"
1.8
1.9 #include <iostream>
1.10 NS_LOG_COMPONENT_DEFINE("UanPhyGen");
1.11 @@ -74,7 +75,9 @@
1.12 const UanTransducer::ArrivalList &arrivalList) const
1.13 {
1.14 if(mode.GetModType() == UanTxMode::OTHER)
1.15 - NS_LOG_WARN("Calculating SINR for unsupported modulation type");
1.16 + {
1.17 + NS_LOG_WARN("Calculating SINR for unsupported modulation type");
1.18 + }
1.19
1.20 //Ideally here, you could implement modulation specific models to
1.21 //calculate SINR of incoming packets.
1.22 @@ -141,11 +144,20 @@
1.23 double ts = 1.0 / mode.GetPhyRateSps();
1.24 double clearingTime = (m_hops-1.0)*ts;
1.25
1.26 - double effRxPowerDb = rxPowerDb + KpToDb(pdp.SumTapsNc(Seconds(0), Seconds(ts)));
1.27 + double csp = pdp.SumTapsNc(Seconds(0), Seconds(ts));
1.28 + NS_LOG_DEBUG("Symbol duration = " << ts << " Captured signal power: " << csp);
1.29 + UanPdp::Iterator tmpIt = pdp.GetBegin();
1.30 + for(;tmpIt != pdp.GetEnd();tmpIt++)
1.31 + {
1.32 + NS_LOG_DEBUG("Delay = " << tmpIt->GetDelay().GetSeconds() << " amp = " << tmpIt->GetAmp());
1.33 + }
1.34 +
1.35 + double effRxPowerDb = rxPowerDb + KpToDb(csp);
1.36 +
1.37 double isiKpa = DbToKp(rxPowerDb)*pdp.SumTapsNc(Seconds(ts+clearingTime), Seconds(2.0*ts+clearingTime));
1.38
1.39 UanTransducer::ArrivalList::const_iterator it = arrivalList.begin();
1.40 - double intKp = 0;
1.41 + double intKp = -DbToKp(effRxPowerDb);
1.42 for(;it != arrivalList.end();it++)
1.43 {
1.44 UanPdp intPdp = it->GetPdp();
1.45 @@ -157,8 +169,11 @@
1.46 int32_t syms = (uint32_t) ( (double) tDelta / (ts + clearingTime));
1.47 tDelta = tDelta - syms*(ts + clearingTime);
1.48
1.49 + //Align to pktRx
1.50 if(arrTime < it->GetArrivalTime())
1.51 - tDelta = ts+clearingTime - tDelta;
1.52 + {
1.53 + tDelta = ts+clearingTime - tDelta;
1.54 + }
1.55
1.56 double intPower = 0.0;
1.57 if(tDelta < ts)
1.58 @@ -182,7 +197,7 @@
1.59
1.60 double totalIntDb = KpToDb(isiKpa + intKp + DbToKp(ambNoiseDb));
1.61
1.62 - NS_LOG_DEBUG("Calculating SINR: RxPower = " << rxPowerDb << " dB. Effective Rx power " << effRxPowerDb << " dB. Number of interferers = " << arrivalList.size() << " Interference + noise power = " << totalIntDb << " dB. SINR = " << rxPowerDb - totalIntDb << " dB.");
1.63 + NS_LOG_DEBUG("Calculating SINR: RxPower = " << rxPowerDb << " dB. Effective Rx power " << effRxPowerDb << " dB. Number of interferers = " << arrivalList.size() << " Interference + noise power = " << totalIntDb << " dB. SINR = " << effRxPowerDb - totalIntDb << " dB.");
1.64 return effRxPowerDb - totalIntDb;
1.65 }
1.66
1.67 @@ -531,7 +546,9 @@
1.68 else
1.69 m_state = IDLE;
1.70
1.71 - if(m_minRxSinrDb > m_rxThreshDb)
1.72 + UniformVariable pg;
1.73 +
1.74 + if(pg.GetValue(0, 1) > m_per->CalcPer(m_minRxSinrDb, txMode))
1.75 {
1.76 m_rxOkLogger(pkt, m_minRxSinrDb, txMode);
1.77 NotifyListenersRxGood();
2.1 --- a/src/devices/uan/uan-prop-model.cc Wed Apr 01 22:50:54 2009 -0700
2.2 +++ b/src/devices/uan/uan-prop-model.cc Thu Apr 02 23:34:42 2009 -0700
2.3 @@ -161,20 +161,19 @@
2.4 double
2.5 UanPdp::SumTapsNc(Time begin, Time end)
2.6 {
2.7 - if(GetNTaps()==0)
2.8 + Iterator it = GetBegin();
2.9 + Time pdelay = it->GetDelay();
2.10 + double sum=0;
2.11 + for(;it != GetEnd();it++)
2.12 {
2.13 - return 0;
2.14 - }
2.15 -
2.16 - Iterator it = GetBegin();
2.17 - double sum;
2.18 - while(it->GetDelay() < end && it != GetEnd())
2.19 - {
2.20 - if(it->GetDelay() > begin)
2.21 - sum += abs(it->GetAmp());
2.22 - it++;
2.23 - if(it == GetEnd())
2.24 - break;
2.25 + if(it->GetDelay() - pdelay > end)
2.26 + {
2.27 + break;
2.28 + }
2.29 + else if(it->GetDelay() - pdelay >= begin)
2.30 + {
2.31 + sum += abs(it->GetAmp());
2.32 + }
2.33 }
2.34 return sum;
2.35 }
2.36 @@ -182,20 +181,19 @@
2.37 std::complex<double>
2.38 UanPdp::SumTapsC(Time begin, Time end)
2.39 {
2.40 - if(GetNTaps()==0)
2.41 + Iterator it = GetBegin();
2.42 + Time pdelay = it->GetDelay();
2.43 + std::complex<double> sum=0;
2.44 + for(;it != GetEnd();it++)
2.45 {
2.46 - return 0;
2.47 - }
2.48 -
2.49 - Iterator it = GetBegin();
2.50 - std::complex<double> sum;
2.51 - while(it->GetDelay() < end)
2.52 - {
2.53 - if(it->GetDelay() > begin)
2.54 - sum += it->GetAmp();
2.55 - it++;
2.56 - if(it == GetEnd())
2.57 - break;
2.58 + if(it->GetDelay() - pdelay > end)
2.59 + {
2.60 + break;
2.61 + }
2.62 + else if(it->GetDelay() - pdelay >= begin)
2.63 + {
2.64 + sum += it->GetAmp();
2.65 + }
2.66 }
2.67 return sum;
2.68 }