00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "UWBIRStochasticPathlossModel.h"
00021
00022 double UWBIRStochasticPathlossModel::n1_limit = 1.25;
00023 double UWBIRStochasticPathlossModel::n2_limit = 2;
00024
00025 double UWBIRStochasticPathlossModel::simtruncnormal(double mean, double stddev, double a, int rng) {
00026 double res = a + 1;
00027 while(res > a || res < -a) {
00028 res = normal(mean, stddev, 0);
00029 }
00030 return res;
00031 }
00032
00033 void UWBIRStochasticPathlossModel::filterSignal(Signal& s) {
00034
00035 if (isEnabled) {
00036
00037 TimeMapping<Linear>* attMapping = new TimeMapping<Linear> ();
00038 Argument arg;
00039 Move srcMove = s.getMove();
00040 Coord srcCoord, rcvCoord;
00041 double distance = 0;
00042
00043
00044
00045
00046 n1 = simtruncnormal(0, 1, n1_limit, 1);
00047 n2 = simtruncnormal(0, 1, n2_limit, 2);
00048 n3 = simtruncnormal(0, 1, n2_limit, 3);
00049
00050 gamma = mu_gamma + n1 * sigma_gamma;
00051 sigma = mu_sigma + n3 * sigma_sigma;
00052 S = n2 * sigma;
00053
00054
00055 srcCoord = srcMove.getPositionAt(s.getSignalStart());
00056 rcvCoord = move->getPositionAt(s.getSignalStart());
00057
00058 distance = rcvCoord.distance(srcCoord);
00059
00060
00061
00062
00063
00064
00065
00066
00067 double attenuation = getGhassemzadehPathloss(distance);
00068 pathlosses.record(attenuation);
00069
00070
00071 attMapping->setValue(arg, attenuation);
00072 s.addAttenuation(attMapping);
00073 }
00074 }
00075
00076 double UWBIRStochasticPathlossModel::getNarrowBandFreeSpacePathloss(double fc, double distance) {
00077 double attenuation = 4*M_PI*distance*fc/BaseWorldUtility::speedOfLight;
00078 return 1/(attenuation*attenuation);
00079 }
00080
00081 double UWBIRStochasticPathlossModel::getGhassemzadehPathloss(double distance) {
00082 double attenuation = PL0;
00083 if(distance < d0) {
00084 distance = d0;
00085 }
00086 attenuation = attenuation - 10*gamma*log10(distance/d0);
00087 if (shadowing) {
00088 attenuation = attenuation - S;
00089 }
00090 attenuation = pow(10, attenuation/10);
00091 return attenuation;
00092 }
00093
00094 double UWBIRStochasticPathlossModel::getFDPathloss(double freq, double distance) {
00095 return 0.5*PL0*ntx*nrx*pow(freq/fc, -2*(kappa+1))/pow(distance/d0, pathloss_exponent);
00096 }
00097
00098