Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Shadowing Class Reference

#include <shadowing.h>

Inheritance diagram for Shadowing:

Inheritance graph
[legend]
Collaboration diagram for Shadowing:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Shadowing ()
 ~Shadowing ()
virtual double Pr (PacketStamp *tx, PacketStamp *rx, WirelessPhy *ifp)
virtual int command (int argc, const char *const *argv)
virtual double Pr (PacketStamp *tx, PacketStamp *rx, Phy *)
double Friis (double Pt, double Gt, double Gr, double lambda, double L, double d)

Protected Attributes

RNGranVar
double pathlossExp_
double std_db_
double dist0_
int seed_
char * name
Topographytopo

Constructor & Destructor Documentation

Shadowing::Shadowing  ) 
 

Definition at line 48 of file shadowing.cc.

References dist0_, pathlossExp_, RNG::PREDEF_SEED_SOURCE, ranVar, seed_, RNG::set_seed(), and std_db_.

00049 {
00050         bind("pathlossExp_", &pathlossExp_);
00051         bind("std_db_", &std_db_);
00052         bind("dist0_", &dist0_);
00053         bind("seed_", &seed_);
00054         
00055         ranVar = new RNG;
00056         ranVar->set_seed(RNG::PREDEF_SEED_SOURCE, seed_);
00057 }

Here is the call graph for this function:

Shadowing::~Shadowing  ) 
 

Definition at line 60 of file shadowing.cc.

References ranVar.

00061 {
00062         delete ranVar;
00063 }


Member Function Documentation

int Shadowing::command int  argc,
const char *const *  argv
[virtual]
 

Reimplemented from Propagation.

Definition at line 111 of file shadowing.cc.

References Propagation::command(), RNG::HEURISTIC_SEED_SOURCE, RNG::PREDEF_SEED_SOURCE, ranVar, RNG::RAW_SEED_SOURCE, and RNG::set_seed().

00112 {
00113         if (argc == 4) {
00114                 if (strcmp(argv[1], "seed") == 0) {
00115                         int s = atoi(argv[3]);
00116                         if (strcmp(argv[2], "raw") == 0) {
00117                                 ranVar->set_seed(RNG::RAW_SEED_SOURCE, s);
00118                         } else if (strcmp(argv[2], "predef") == 0) {
00119                                 ranVar->set_seed(RNG::PREDEF_SEED_SOURCE, s);
00120                                 // s is the index in predefined seed array
00121                                 // 0 <= s < 64
00122                         } else if (strcmp(argv[2], "heuristic") == 0) {
00123                                 ranVar->set_seed(RNG::HEURISTIC_SEED_SOURCE, 0);
00124                         }
00125                         return(TCL_OK);
00126                 }
00127         }
00128         
00129         return Propagation::command(argc, argv);
00130 }

Here is the call graph for this function:

double Propagation::Friis double  Pt,
double  Gt,
double  Gr,
double  lambda,
double  L,
double  d
[inherited]
 

Definition at line 92 of file propagation.cc.

References M, and PI.

Referenced by TwoRayGround::Pr(), Pr(), and FreeSpace::Pr().

00093 {
00094         /*
00095          * Friis free space equation:
00096          *
00097          *       Pt * Gt * Gr * (lambda^2)
00098          *   P = --------------------------
00099          *       (4 * pi * d)^2 * L
00100          */
00101   double M = lambda / (4 * PI * d);
00102   return (Pt * Gt * Gr * (M * M)) / L;
00103 }

double Propagation::Pr PacketStamp tx,
PacketStamp rx,
Phy
[virtual, inherited]
 

Definition at line 72 of file propagation.cc.

References abort(), and Propagation::name.

Referenced by WirelessPhy::sendUp().

00073 {
00074         fprintf(stderr,"Propagation model %s not implemented for generic NetIF\n",
00075           name);
00076         abort();
00077         return 0; // Make msvc happy
00078 }

Here is the call graph for this function:

double Shadowing::Pr PacketStamp tx,
PacketStamp rx,
WirelessPhy ifp
[virtual]
 

Reimplemented from Propagation.

Definition at line 66 of file shadowing.cc.

References dist0_, Propagation::Friis(), PacketStamp::getAntenna(), WirelessPhy::getL(), WirelessPhy::getLambda(), MobileNode::getLoc(), PacketStamp::getNode(), Antenna::getRxGain(), Antenna::getTxGain(), PacketStamp::getTxPr(), Antenna::getX(), Antenna::getY(), Antenna::getZ(), RNG::normal(), pathlossExp_, pow(), Pr(), ranVar, and std_db_.

Referenced by Pr(), and ShadowingVis::Pr().

00067 {
00068         double L = ifp->getL();         // system loss
00069         double lambda = ifp->getLambda();   // wavelength
00070 
00071         double Xt, Yt, Zt;              // loc of transmitter
00072         double Xr, Yr, Zr;              // loc of receiver
00073 
00074         t->getNode()->getLoc(&Xt, &Yt, &Zt);
00075         r->getNode()->getLoc(&Xr, &Yr, &Zr);
00076 
00077         // Is antenna position relative to node position?
00078         Xr += r->getAntenna()->getX();
00079         Yr += r->getAntenna()->getY();
00080         Zr += r->getAntenna()->getZ();
00081         Xt += t->getAntenna()->getX();
00082         Yt += t->getAntenna()->getY();
00083         Zt += t->getAntenna()->getZ();
00084 
00085         double dX = Xr - Xt;
00086         double dY = Yr - Yt;
00087         double dZ = Zr - Zt;
00088         double dist = sqrt(dX * dX + dY * dY + dZ * dZ);
00089 
00090         // get antenna gain
00091         double Gt = t->getAntenna()->getTxGain(dX, dY, dZ, lambda);
00092         double Gr = r->getAntenna()->getRxGain(dX, dY, dZ, lambda);
00093 
00094         // calculate receiving power at reference distance
00095         double Pr0 = Friis(t->getTxPr(), Gt, Gr, lambda, L, dist0_);
00096 
00097         // calculate average power loss predicted by path loss model
00098         double avg_db = -10.0 * pathlossExp_ * log10(dist/dist0_);
00099    
00100         // get power loss by adding a log-normal random variable (shadowing)
00101         // the power loss is relative to that at reference distance dist0_
00102         double powerLoss_db = avg_db + ranVar->normal(0.0, std_db_);
00103 
00104         // calculate the receiving power at dist
00105         double Pr = Pr0 * pow(10.0, powerLoss_db/10.0);
00106         
00107         return Pr;
00108 }

Here is the call graph for this function:


Member Data Documentation

double Shadowing::dist0_ [protected]
 

Definition at line 46 of file shadowing.h.

Referenced by Pr(), and Shadowing().

char* Propagation::name [protected, inherited]
 

Definition at line 90 of file propagation.h.

Referenced by Propagation::Pr(), and Propagation::Propagation().

double Shadowing::pathlossExp_ [protected]
 

Definition at line 44 of file shadowing.h.

Referenced by Pr(), and Shadowing().

RNG* Shadowing::ranVar [protected]
 

Definition at line 42 of file shadowing.h.

Referenced by command(), Pr(), Shadowing(), and ~Shadowing().

int Shadowing::seed_ [protected]
 

Definition at line 47 of file shadowing.h.

Referenced by Shadowing().

double Shadowing::std_db_ [protected]
 

Definition at line 45 of file shadowing.h.

Referenced by Pr(), and Shadowing().

Topography* Propagation::topo [protected, inherited]
 

Definition at line 91 of file propagation.h.

Referenced by Propagation::command(), and Propagation::Propagation().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:22:36 2004 for NS2.26SourcesOriginal by doxygen 1.3.3