UWBIRIEEE802154APathlossModel.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        UWBIRIEEE802154APathlossModel.h
00003  *
00004  * author:      Jerome Rousselot <jerome.rousselot@csem.ch>
00005  *
00006  * copyright:   (C) 2008-2009 Centre Suisse d'Electronique et Microtechnique (CSEM) SA
00007  *        Systems Engineering
00008  *              Real-Time Software and Networking
00009  *              Jaquet-Droz 1, CH-2002 Neuchatel, Switzerland.
00010  *
00011  *              This program is free software; you can redistribute it
00012  *              and/or modify it under the terms of the GNU General Public
00013  *              License as published by the Free Software Foundation; either
00014  *              version 2 of the License, or (at your option) any later
00015  *              version.
00016  *              For further information see file COPYING
00017  *              in the top level directory
00018  * description: this AnalogueModel implements the IEEE 802.15.4A Channel Model
00019  ***************************************************************************/
00020 
00021 #ifndef _UWBIRIEEE802154APATHLOSSMODEL_H
00022 #define _UWBIRIEEE802154APATHLOSSMODEL_H
00023 
00024 #include "AnalogueModel.h"
00025 #include "MappingUtils.h"
00026 #include "Signal_.h"
00027 #include "BaseWorldUtility.h"
00028 #include "IEEE802154A.h"
00029 //#include "AlohaMacLayer.h"
00030 #include "Move.h"
00031 #include "SimpleTimeConstMapping.h"
00032 #include <math.h>
00033 #include <limits>
00034 
00064 class UWBIRIEEE802154APathlossModel : public AnalogueModel {
00065 
00066 public:
00067 
00068   /*
00069    * @brief Default constructor.
00070    */
00071     UWBIRIEEE802154APathlossModel(int _channelModel, double _threshold, const Move* _move, bool shadowing=true):
00072       channelModel(_channelModel), tapThreshold(_threshold), doShadowing(shadowing),
00073       doSmallScaleShadowing(false), move(_move), nbCalls(0)  {
00074       // Check that this model is supported
00075       assert(implemented_CMs[channelModel]);
00076       // load the model parameters
00077       cfg = CMconfigs[channelModel];
00078       averagePowers.setName("averagePower");
00079       pathlosses.setName("pathloss");
00080     }
00081 
00082     /*
00083      * @brief Applies the model to an incoming signal.
00084      */
00085     void filterSignal(Signal& s);
00086 
00087     /*@brief Utility function to use a Rayleigh random variable
00088      *
00089      */
00090     double Rayleigh(double param);
00091 
00092     /* @brief Lists implemented channel models.
00093      * */
00094     static const bool implemented_CMs[];
00095 
00096     struct CMconfig {
00097       double PL0;         // pathloss at 1 m distance (*not* in dB)
00098       double n;         // pathloss exponent
00099       double sigma_s;       // shadowing standard deviation (unused)
00100       double Aant;        // antenna loss (always 3 dB)
00101       double kappa;       // frequency dependence of the pathloss
00102     double Lmean;       // mean number of clusters
00103       double Lambda;          // inter-cluster arrival rate (clusters *per second*)
00104     // ray arrival rates (mixed Poisson model parameters, in seconds)
00105       double lambda_1, lambda_2, Beta;
00106       double Gamma;       // inter-cluster decay constant
00107       double k_gamma, gamma_0;  // intra-cluster decay time constant parameters
00108       double sigma_cluster;   // cluster shadowing variance (*not* in dB)
00109       double m_0, k_m;      // Nakagami m factor mean
00110       double var_m_0, var_k_m;  // Nakagami m factor variance
00111       double strong_m_0;      // Nakagami m factor for strong components
00112       // parameters for alternative PDP shape
00113       double gamma_rise; double gamma_1; double xi;
00114     };
00115 
00116     /* @brief Known models configuration
00117      **/
00118     static const CMconfig CMconfigs[];
00119 
00120 
00121 protected:
00122 
00125   int channelModel;
00126 
00127   /* @brief Selected configuration
00128        **/
00129       CMconfig cfg;
00130 
00131     // configure cluster threshold
00132     double tapThreshold; // Only generates taps with at most 10 dB attenuation
00133 
00134     double doShadowing; //activates block shadowing
00135     double doSmallScaleShadowing; // activates small-scale shadowing
00136 
00137     // channel statistical characterization parameters
00138     // (should be xml-ized)
00139     // First environment: Residential LOS
00140     static const double PL0 = 0.000040738; // -43.9 dB
00141     static const double pathloss_exponent = 1.79;
00142     static const double meanL = 3;
00143     static const double Lambda = 0.047E9;
00144     static const double lambda1 = 1.54E9;
00145     static const double lambda2 = 0.15E9;
00146     static const double Beta = 0.095;
00147     static const double Gamma = 22.61E-9;
00148     static const double k_gamma = 0;
00149     static const double gamma_0 = 12.53 * 0.001 * 0.001 * 0.01;
00150     static const double sigma_cluster = 1.883649089; // 2.75 dB
00151 
00152     static const double fc = 4.492E9; // mandatory band 3, center frequency, Hz
00153     static const double BW = 500E6;  //  mandatory band 3, bandwidth, Hz
00154     static const double fcMHz = 4492; // mandatory band 3, center frequency, MHz
00155 
00156     static const double d0 = 1;
00157 
00158     // antenna parameters
00159     static const double ntx = 1;
00160     static const double nrx = 1;
00161 
00162 
00163     const Move* move;
00164     TimeMapping<Linear>* newTxPower;
00165     ConstMapping* txPower;
00166     Argument arg;
00167     MappingIterator* pulsesIter;
00168     // number of clusters
00169     double L;
00170     // block shadowing
00171     double S;
00172     // start time of cluster number "cluster"
00173     simtime_t clusterStart;
00174     simtime_t gamma_l;
00175     double Mcluster;
00176     // cluster integrated energy
00177     double Omega_l;
00178     // distance between source and receiver
00179     double distance;
00180 
00181     double averagePower; // statistics counter (useful for model validation, should converges towards 1)
00182     long nbCalls;
00183     cOutVector averagePowers;
00184     cOutVector pathlosses;  // outputs computed pathlosses. Allows to compute Eb = Epulse*pathloss for Eb/N0 computations. (N0 is the noise sampled by the receiver)
00185 
00186     /*
00187      * Generates taps for the considered pulse, with the current channel parameters
00188      */
00189     void addEchoes(simtime_t pulseStart);
00190 
00191     /*
00192      * @brief Computes the pathloss as a function of center frequency and bandwidth given in MHz
00193      */
00194     double getPathloss(double fc, double BW);
00195 
00196 };
00197 
00198 #endif  /* _UWBIRIEEE802154APATHLOSSMODEL_H */
00199