1.1 --- a/scratch/cwexp.cc Wed Apr 01 16:00:30 2009 -0700
1.2 +++ b/scratch/cwexp.cc Wed Apr 01 22:50:54 2009 -0700
1.3 @@ -111,9 +111,9 @@
1.4 pktskth.Install(nc);
1.5 pktskth.Install(sink);
1.6
1.7 - Ptr<UanPropModelBh> prop = CreateObject<UanPropModelBh>("ConfigFile", StringValue("../uan-apps/exbhconfig.cfg"));
1.8 + Ptr<UanPropModelBh> prop = CreateObject<UanPropModelBh>("ConfigFile", StringValue("exbhconfig.cfg"));
1.9 Ptr<UanPropModelIdeal> iprop = CreateObject<UanPropModelIdeal>();
1.10 - Ptr<UanChannel> channel = CreateObject<UanChannel>("PropagationModel", PointerValue(iprop));
1.11 + Ptr<UanChannel> channel = CreateObject<UanChannel>("PropagationModel", PointerValue(prop));
1.12
1.13 //Create net device and nodes with UanHelper
1.14 NetDeviceContainer devices = uan.Install(nc, channel);
1.15 @@ -130,7 +130,7 @@
1.16 }
1.17
1.18 mobility.SetPositionAllocator(pos);
1.19 - mobility.SetMobilityModel("ns3::StaticMobilityModel");
1.20 + mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1.21 mobility.Install(sink);
1.22
1.23 NS_LOG_DEBUG("Position of sink: " << sink.Get(0)->GetObject<MobilityModel>()->GetPosition());
1.24 @@ -229,6 +229,8 @@
1.25 exp.m_Avgs = 7;
1.26 exp.m_mldatfile = std::string("cwexpmlout.dat");
1.27 std::string gnudatfile("cwexpgnuout.dat");
1.28 + std::string perModel = "ns3::UanPhyPerGenDefault";
1.29 + std::string sinrModel = "ns3::UanPhyCalcSinrDefault";
1.30
1.31 CommandLine cmd;
1.32 cmd.AddValue("NumNodes", "Number of transmitting nodes", exp.m_NumNodes);
1.33 @@ -242,13 +244,23 @@
1.34 cmd.AddValue("Averages", "Number of topologies to test for each cw point", exp.m_Avgs);
1.35 cmd.AddValue("MlFile", "Name for plain text file output", exp.m_mldatfile);
1.36 cmd.AddValue("GnuFile", "Name for GNU Plot output", gnudatfile);
1.37 + cmd.AddValue("PerModel", "PER model name", perModel);
1.38 + cmd.AddValue("SinrModel", "SINR model name", sinrModel);
1.39
1.40 cmd.Parse(argc, argv);
1.41
1.42 exp.m_SlotTime = Seconds(slottime);
1.43 + ObjectFactory obf;
1.44 + obf.SetTypeId(perModel);
1.45 + Ptr<UanPhyPer> per = obf.Create<UanPhyPer>();
1.46 + obf.SetTypeId(sinrModel);
1.47 + Ptr<UanPhyCalcSinr> sinr = obf.Create<UanPhyCalcSinr>();
1.48
1.49 UanHelper uan;
1.50 - uan.SetPhy("ns3::UanPhyDual");
1.51 +
1.52 + uan.SetPhy(std::string("ns3::UanPhyGen"),
1.53 + std::string("PerFunctor"), PointerValue(per),
1.54 + std::string("SinrFunctor"), PointerValue(sinr));
1.55
1.56
1.57 Gnuplot gp;
2.1 --- a/src/devices/uan/uan-phy-gen.cc Wed Apr 01 16:00:30 2009 -0700
2.2 +++ b/src/devices/uan/uan-phy-gen.cc Wed Apr 01 22:50:54 2009 -0700
2.3 @@ -64,6 +64,43 @@
2.4 return tid;
2.5 }
2.6
2.7 +double
2.8 +UanPhyCalcSinrDefault::CalcSinrDb(Ptr<Packet> pkt,
2.9 + Time arrTime,
2.10 + double rxPowerDb,
2.11 + double ambNoiseDb,
2.12 + UanTxMode mode,
2.13 + UanPdp pdp,
2.14 + const UanTransducer::ArrivalList &arrivalList) const
2.15 +{
2.16 + if(mode.GetModType() == UanTxMode::OTHER)
2.17 + NS_LOG_WARN("Calculating SINR for unsupported modulation type");
2.18 +
2.19 + //Ideally here, you could implement modulation specific models to
2.20 + //calculate SINR of incoming packets.
2.21 + //e.g. If two packets are separated in frequency, or
2.22 + //are using orthogonal hopping codes in FH-FSK or whatever, or in some other
2.23 + //way occupy (nearly) orthogonal channels then the interference calculation
2.24 + //should reflect this.
2.25 +
2.26 + //The default ignores mode data and assumes that all rxpower transmitted is
2.27 + //captured by the receiver, and that all signal power associated with
2.28 + //interfering packets effects SINR identically to additional ambient noise.
2.29 +
2.30 + double intKp = -DbToKp(rxPowerDb); //This packet is in the arrivalList
2.31 + UanTransducer::ArrivalList::const_iterator it = arrivalList.begin();
2.32 + for(;it != arrivalList.end();it++)
2.33 + {
2.34 + intKp += DbToKp(it->GetRxPowerDb());
2.35 + }
2.36 +
2.37 + double totalIntDb = KpToDb(intKp + DbToKp(ambNoiseDb));
2.38 +
2.39 + NS_LOG_DEBUG("Calculating SINR: RxPower = " << rxPowerDb << " dB. Number of interferers = " << arrivalList.size() << " Interference + noise power = " << totalIntDb << " dB. SINR = " << rxPowerDb - totalIntDb << " dB.");
2.40 + return rxPowerDb - totalIntDb;
2.41 +}
2.42 +
2.43 +
2.44 UanPhyCalcSinrFhFsk::UanPhyCalcSinrFhFsk()
2.45 {
2.46
2.47 @@ -112,7 +149,7 @@
2.48 for(;it != arrivalList.end();it++)
2.49 {
2.50 UanPdp intPdp = it->GetPdp();
2.51 - double tDelta = abs(arrTime.GetSeconds() - it->GetArrivalTime().GetSeconds());
2.52 + double tDelta = std::abs(arrTime.GetSeconds() - it->GetArrivalTime().GetSeconds());
2.53 //We want tDelta in terms of a single symbol (i.e. if tDelta = 7.3 symbol+clearing
2.54 //times, the offset in terms of the arriving symbol power is
2.55 //0.3 symbol+clearing times.
2.56 @@ -151,41 +188,6 @@
2.57
2.58
2.59
2.60 -double
2.61 -UanPhyCalcSinrDefault::CalcSinrDb(Ptr<Packet> pkt,
2.62 - Time arrTime,
2.63 - double rxPowerDb,
2.64 - double ambNoiseDb,
2.65 - UanTxMode mode,
2.66 - UanPdp pdp,
2.67 - const UanTransducer::ArrivalList &arrivalList) const
2.68 -{
2.69 - if(mode.GetModType() == UanTxMode::OTHER)
2.70 - NS_LOG_WARN("Calculating SINR for unsupported modulation type");
2.71 -
2.72 - //Ideally here, you could implement modulation specific models to
2.73 - //calculate SINR of incoming packets.
2.74 - //e.g. If two packets are separated in frequency, or
2.75 - //are using orthogonal hopping codes in FH-FSK or whatever, or in some other
2.76 - //way occupy (nearly) orthogonal channels then the interference calculation
2.77 - //should reflect this.
2.78 -
2.79 - //The default ignores mode data and assumes that all rxpower transmitted is
2.80 - //captured by the receiver, and that all signal power associated with
2.81 - //interfering packets effects SINR identically to additional ambient noise.
2.82 -
2.83 - double intKp = -DbToKp(rxPowerDb); //This packet is in the arrivalList
2.84 - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin();
2.85 - for(;it != arrivalList.end();it++)
2.86 - {
2.87 - intKp += DbToKp(it->GetRxPowerDb());
2.88 - }
2.89 -
2.90 - double totalIntDb = KpToDb(intKp + DbToKp(ambNoiseDb));
2.91 -
2.92 - NS_LOG_DEBUG("Calculating SINR: RxPower = " << rxPowerDb << " dB. Number of interferers = " << arrivalList.size() << " Interference + noise power = " << totalIntDb << " dB. SINR = " << rxPowerDb - totalIntDb << " dB.");
2.93 - return rxPowerDb - totalIntDb;
2.94 -}
2.95
2.96 UanPhyPerGenDefault::UanPhyPerGenDefault()
2.97 {
3.1 --- a/src/devices/uan/uan-prop-model.cc Wed Apr 01 16:00:30 2009 -0700
3.2 +++ b/src/devices/uan/uan-prop-model.cc Wed Apr 01 22:50:54 2009 -0700
3.3 @@ -161,12 +161,20 @@
3.4 double
3.5 UanPdp::SumTapsNc(Time begin, Time end)
3.6 {
3.7 + if(GetNTaps()==0)
3.8 + {
3.9 + return 0;
3.10 + }
3.11 +
3.12 Iterator it = GetBegin();
3.13 double sum;
3.14 - while(it->GetDelay() < end)
3.15 + while(it->GetDelay() < end && it != GetEnd())
3.16 {
3.17 if(it->GetDelay() > begin)
3.18 sum += abs(it->GetAmp());
3.19 + it++;
3.20 + if(it == GetEnd())
3.21 + break;
3.22 }
3.23 return sum;
3.24 }
3.25 @@ -174,12 +182,20 @@
3.26 std::complex<double>
3.27 UanPdp::SumTapsC(Time begin, Time end)
3.28 {
3.29 + if(GetNTaps()==0)
3.30 + {
3.31 + return 0;
3.32 + }
3.33 +
3.34 Iterator it = GetBegin();
3.35 std::complex<double> sum;
3.36 while(it->GetDelay() < end)
3.37 {
3.38 if(it->GetDelay() > begin)
3.39 sum += it->GetAmp();
3.40 + it++;
3.41 + if(it == GetEnd())
3.42 + break;
3.43 }
3.44 return sum;
3.45 }