Fixed PER bug.
--- a/src/devices/uan/uan-phy-gen.cc Wed Apr 01 22:50:54 2009 -0700
+++ b/src/devices/uan/uan-phy-gen.cc Thu Apr 02 23:34:42 2009 -0700
@@ -32,6 +32,7 @@
#include "ns3/uan-tx-mode.h"
#include "ns3/node.h"
#include "ns3/uinteger.h"
+#include "ns3/random-variable.h"
#include <iostream>
NS_LOG_COMPONENT_DEFINE("UanPhyGen");
@@ -74,7 +75,9 @@
const UanTransducer::ArrivalList &arrivalList) const
{
if(mode.GetModType() == UanTxMode::OTHER)
- NS_LOG_WARN("Calculating SINR for unsupported modulation type");
+ {
+ NS_LOG_WARN("Calculating SINR for unsupported modulation type");
+ }
//Ideally here, you could implement modulation specific models to
//calculate SINR of incoming packets.
@@ -141,11 +144,20 @@
double ts = 1.0 / mode.GetPhyRateSps();
double clearingTime = (m_hops-1.0)*ts;
- double effRxPowerDb = rxPowerDb + KpToDb(pdp.SumTapsNc(Seconds(0), Seconds(ts)));
+ double csp = pdp.SumTapsNc(Seconds(0), Seconds(ts));
+ NS_LOG_DEBUG("Symbol duration = " << ts << " Captured signal power: " << csp);
+ UanPdp::Iterator tmpIt = pdp.GetBegin();
+ for(;tmpIt != pdp.GetEnd();tmpIt++)
+ {
+ NS_LOG_DEBUG("Delay = " << tmpIt->GetDelay().GetSeconds() << " amp = " << tmpIt->GetAmp());
+ }
+
+ double effRxPowerDb = rxPowerDb + KpToDb(csp);
+
double isiKpa = DbToKp(rxPowerDb)*pdp.SumTapsNc(Seconds(ts+clearingTime), Seconds(2.0*ts+clearingTime));
UanTransducer::ArrivalList::const_iterator it = arrivalList.begin();
- double intKp = 0;
+ double intKp = -DbToKp(effRxPowerDb);
for(;it != arrivalList.end();it++)
{
UanPdp intPdp = it->GetPdp();
@@ -157,8 +169,11 @@
int32_t syms = (uint32_t) ( (double) tDelta / (ts + clearingTime));
tDelta = tDelta - syms*(ts + clearingTime);
+ //Align to pktRx
if(arrTime < it->GetArrivalTime())
- tDelta = ts+clearingTime - tDelta;
+ {
+ tDelta = ts+clearingTime - tDelta;
+ }
double intPower = 0.0;
if(tDelta < ts)
@@ -182,7 +197,7 @@
double totalIntDb = KpToDb(isiKpa + intKp + DbToKp(ambNoiseDb));
- 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.");
+ 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.");
return effRxPowerDb - totalIntDb;
}
@@ -531,7 +546,9 @@
else
m_state = IDLE;
- if(m_minRxSinrDb > m_rxThreshDb)
+ UniformVariable pg;
+
+ if(pg.GetValue(0, 1) > m_per->CalcPer(m_minRxSinrDb, txMode))
{
m_rxOkLogger(pkt, m_minRxSinrDb, txMode);
NotifyListenersRxGood();
--- a/src/devices/uan/uan-prop-model.cc Wed Apr 01 22:50:54 2009 -0700
+++ b/src/devices/uan/uan-prop-model.cc Thu Apr 02 23:34:42 2009 -0700
@@ -161,20 +161,19 @@
double
UanPdp::SumTapsNc(Time begin, Time end)
{
- if(GetNTaps()==0)
+ Iterator it = GetBegin();
+ Time pdelay = it->GetDelay();
+ double sum=0;
+ for(;it != GetEnd();it++)
{
- return 0;
- }
-
- Iterator it = GetBegin();
- double sum;
- while(it->GetDelay() < end && it != GetEnd())
- {
- if(it->GetDelay() > begin)
- sum += abs(it->GetAmp());
- it++;
- if(it == GetEnd())
- break;
+ if(it->GetDelay() - pdelay > end)
+ {
+ break;
+ }
+ else if(it->GetDelay() - pdelay >= begin)
+ {
+ sum += abs(it->GetAmp());
+ }
}
return sum;
}
@@ -182,20 +181,19 @@
std::complex<double>
UanPdp::SumTapsC(Time begin, Time end)
{
- if(GetNTaps()==0)
+ Iterator it = GetBegin();
+ Time pdelay = it->GetDelay();
+ std::complex<double> sum=0;
+ for(;it != GetEnd();it++)
{
- return 0;
- }
-
- Iterator it = GetBegin();
- std::complex<double> sum;
- while(it->GetDelay() < end)
- {
- if(it->GetDelay() > begin)
- sum += it->GetAmp();
- it++;
- if(it == GetEnd())
- break;
+ if(it->GetDelay() - pdelay > end)
+ {
+ break;
+ }
+ else if(it->GetDelay() - pdelay >= begin)
+ {
+ sum += it->GetAmp();
+ }
}
return sum;
}