1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2005,2006,2007 INRIA 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation; 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 19 * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu> 20 * Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS 21 * Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model 22 * Pavel Boyko <boyko@iitp.ru> for matrix 23 */ 24 25 #ifndef PROPAGATION_LOSS_MODEL_H 26 #define PROPAGATION_LOSS_MODEL_H 27 28 #include "ns3/object.h" 29 #include "ns3/random-variable-stream.h" 30 #include <map> 31 32 namespace ns3 { 33 34 /** 35 * \defgroup propagation Propagation Models 36 * 37 */ 38 39 class MobilityModel; 40 41 /** 42 * \ingroup propagation 43 * 44 * \brief Models the propagation loss through a transmission medium 45 * 46 * Calculate the receive power (dbm) from a transmit power (dbm) 47 * and a mobility model for the source and destination positions. 48 */ 49 class PropagationLossModel : public Object 50 { 51 public: 52 /** 53 * Get the type ID. 54 * \brief Get the type ID. 55 * \return the object TypeId 56 */ 57 static TypeId GetTypeId (void); 58 59 PropagationLossModel (); 60 virtual ~PropagationLossModel (); 61 62 /** 63 * \brief Enables a chain of loss models to act on the signal 64 * \param next The next PropagationLossModel to add to the chain 65 * 66 * This method of chaining propagation loss models only works commutatively 67 * if the propagation loss of all models in the chain are independent 68 * of transmit power. 69 */ 70 void SetNext (Ptr<PropagationLossModel> next); 71 72 /** 73 * \brief Gets the next PropagationLossModel in the chain of loss models 74 * that act on the signal. 75 * \returns The next PropagationLossModel in the chain 76 * 77 * This method of chaining propagation loss models only works commutatively 78 * if the propagation loss of all models in the chain are independent 79 * of transmit power. 80 */ 81 Ptr<PropagationLossModel> GetNext (); 82 83 /** 84 * Returns the Rx Power taking into account all the PropagationLossModel(s) 85 * chained to the current one. 86 * 87 * \param txPowerDbm current transmission power (in dBm) 88 * \param a the mobility model of the source 89 * \param b the mobility model of the destination 90 * \returns the reception power after adding/multiplying propagation loss (in dBm) 91 */ 92 double CalcRxPower (double txPowerDbm, 93 Ptr<MobilityModel> a, 94 Ptr<MobilityModel> b) const; 95 96 /** 97 * If this loss model uses objects of type RandomVariableStream, 98 * set the stream numbers to the integers starting with the offset 99 * 'stream'. Return the number of streams (possibly zero) that 100 * have been assigned. If there are PropagationLossModels chained 101 * together, this method will also assign streams to the 102 * downstream models. 103 * 104 * \param stream 105 * \return the number of stream indices assigned by this model 106 */ 107 int64_t AssignStreams (int64_t stream); 108 109 private: 110 /** 111 * \brief Copy constructor 112 * 113 * Defined and unimplemented to avoid misuse 114 */ 115 PropagationLossModel (const PropagationLossModel &); 116 /** 117 * \brief Copy constructor 118 * 119 * Defined and unimplemented to avoid misuse 120 * \returns 121 */ 122 PropagationLossModel &operator = (const PropagationLossModel &); 123 124 /** 125 * Returns the Rx Power taking into account only the particular 126 * PropagationLossModel. 127 * 128 * \param txPowerDbm current transmission power (in dBm) 129 * \param a the mobility model of the source 130 * \param b the mobility model of the destination 131 * \returns the reception power after adding/multiplying propagation loss (in dBm) 132 */ 133 virtual double DoCalcRxPower (double txPowerDbm, 134 Ptr<MobilityModel> a, 135 Ptr<MobilityModel> b) const = 0; 136 137 /** 138 * Subclasses must implement this; those not using random variables 139 * can return zero 140 */ 141 virtual int64_t DoAssignStreams (int64_t stream) = 0; 142 143 Ptr<PropagationLossModel> m_next; //!< Next propagation loss model in the list 144 }; 145 146 /** 147 * \ingroup propagation 148 * 149 * \brief The propagation loss follows a random distribution. 150 */ 151 class RandomPropagationLossModel : public PropagationLossModel 152 { 153 public: 154 /** 155 * \brief Get the type ID. 156 * \return the object TypeId 157 */ 158 static TypeId GetTypeId (void); 159 160 RandomPropagationLossModel (); 161 virtual ~RandomPropagationLossModel (); 162 163 private: 164 /** 165 * \brief Copy constructor 166 * 167 * Defined and unimplemented to avoid misuse 168 */ 169 RandomPropagationLossModel (const RandomPropagationLossModel &); 170 /** 171 * \brief Copy constructor 172 * 173 * Defined and unimplemented to avoid misuse 174 * \returns 175 */ 176 RandomPropagationLossModel & operator = (const RandomPropagationLossModel &); 177 virtual double DoCalcRxPower (double txPowerDbm, 178 Ptr<MobilityModel> a, 179 Ptr<MobilityModel> b) const; 180 virtual int64_t DoAssignStreams (int64_t stream); 181 Ptr<RandomVariableStream> m_variable; //!< random generator 182 }; 183 184 /** 185 * \ingroup propagation 186 * 187 * \brief a Friis propagation loss model 188 * 189 * The Friis propagation loss model was first described in 190 * "A Note on a Simple Transmission Formula", by 191 * "Harald T. Friis". 192 * 193 * The original equation was described as: 194 * \f$ \frac{P_r}{P_t} = \frac{A_r A_t}{d^2\lambda^2} \f$ 195 * with the following equation for the case of an 196 * isotropic antenna with no heat loss: 197 * \f$ A_{isotr.} = \frac{\lambda^2}{4\pi} \f$ 198 * 199 * The final equation becomes: 200 * \f$ \frac{P_r}{P_t} = \frac{\lambda^2}{(4 \pi d)^2} \f$ 201 * 202 * Modern extensions to this original equation are: 203 * \f$ P_r = \frac{P_t G_t G_r \lambda^2}{(4 \pi d)^2 L}\f$ 204 * 205 * With: 206 * - \f$ P_r \f$ : reception power (W) 207 * - \f$ P_t \f$ : transmission power (W) 208 * - \f$ G_t \f$ : transmission gain (unit-less) 209 * - \f$ G_r \f$ : reception gain (unit-less) 210 * - \f$ \lambda \f$ : wavelength (m) 211 * - \f$ d \f$ : distance (m) 212 * - \f$ L \f$ : system loss (unit-less) 213 * 214 * In the implementation, \f$ \lambda \f$ is calculated as 215 * \f$ \frac{C}{f} \f$, where \f$ C = 299792458\f$ m/s is the speed of light in 216 * vacuum, and \f$ f \f$ is the frequency in Hz which can be configured by 217 * the user via the Frequency attribute. 218 * 219 * The Friis model is valid only for propagation in free space within 220 * the so-called far field region, which can be considered 221 * approximately as the region for \f$ d > 3 \lambda \f$. 222 * The model will still return a value for \f$ d < 3 \lambda \f$, as 223 * doing so (rather than triggering a fatal error) is practical for 224 * many simulation scenarios. However, we stress that the values 225 * obtained in such conditions shall not be considered realistic. 226 * 227 * Related with this issue, we note that the Friis formula is 228 * undefined for \f$ d = 0 \f$, and results in 229 * \f$ P_r > P_t \f$ for \f$ d < \lambda / 2 \sqrt{\pi} \f$. 230 * Both these conditions occur outside of the far field region, so in 231 * principle the Friis model shall not be used in these conditions. 232 * In practice, however, Friis is often used in scenarios where accurate 233 * propagation modeling is not deemed important, and values of \f$ d = 234 * 0 \f$ can occur. To allow practical use of the model in such 235 * scenarios, we have to 1) return some value for \f$ d = 0 \f$, and 236 * 2) avoid large discontinuities in propagation loss values (which 237 * could lead to artifacts such as bogus capture effects which are 238 * much worse than inaccurate propagation loss values). The two issues 239 * are conflicting, as, according to the Friis formula, 240 * \f$\lim_{d \to 0 } P_r = +\infty \f$; 241 * so if, for \f$ d = 0 \f$, we use a fixed loss value, we end up with an infinitely large 242 * discontinuity, which as we discussed can cause undesirable 243 * simulation artifacts. 244 * 245 * To avoid these artifact, this implementation of the Friis model 246 * provides an attribute called MinLoss which allows to specify the 247 * minimum total loss (in dB) returned by the model. This is used in 248 * such a way that 249 * \f$ P_r \f$ continuously increases for \f$ d \to 0 \f$, until 250 * MinLoss is reached, and then stay constant; this allow to 251 * return a value for \f$ d = 0 \f$ and at the same time avoid 252 * discontinuities. The model won't be much realistic, but at least 253 * the simulation artifacts discussed before are avoided. The default value of 254 * MinLoss is 0 dB, which means that by default the model will return 255 * \f$ P_r = P_t \f$ for \f$ d <= \lambda / 2 \sqrt{\pi} \f$. We note 256 * that this value of \f$ d \f$ is outside of the far field 257 * region, hence the validity of the model in the far field region is 258 * not affected. 259 * 260 */ 261 class FriisPropagationLossModel : public PropagationLossModel 262 { 263 public: 264 /** 265 * \brief Get the type ID. 266 * \return the object TypeId 267 */ 268 static TypeId GetTypeId (void); 269 FriisPropagationLossModel (); 270 /** 271 * \param frequency (Hz) 272 * 273 * Set the carrier frequency used in the Friis model 274 * calculation. 275 */ 276 void SetFrequency (double frequency); 277 /** 278 * \param systemLoss (dimension-less) 279 * 280 * Set the system loss used by the Friis propagation model. 281 */ 282 void SetSystemLoss (double systemLoss); 283 284 /** 285 * \param minLoss the minimum loss (dB) 286 * 287 * no matter how short the distance, the total propagation loss (in 288 * dB) will always be greater or equal than this value 289 */ 290 void SetMinLoss (double minLoss); 291 292 /** 293 * \return the minimum loss. 294 */ 295 double GetMinLoss (void) const; 296 297 /** 298 * \returns the current frequency (Hz) 299 */ 300 double GetFrequency (void) const; 301 /** 302 * \returns the current system loss (dimension-less) 303 */ 304 double GetSystemLoss (void) const; 305 306 private: 307 /** 308 * \brief Copy constructor 309 * 310 * Defined and unimplemented to avoid misuse 311 */ 312 FriisPropagationLossModel (const FriisPropagationLossModel &); 313 /** 314 * \brief Copy constructor 315 * 316 * Defined and unimplemented to avoid misuse 317 * \returns 318 */ 319 FriisPropagationLossModel & operator = (const FriisPropagationLossModel &); 320 321 virtual double DoCalcRxPower (double txPowerDbm, 322 Ptr<MobilityModel> a, 323 Ptr<MobilityModel> b) const; 324 virtual int64_t DoAssignStreams (int64_t stream); 325 326 /** 327 * Transforms a Dbm value to Watt 328 * \param dbm the Dbm value 329 * \return the Watts 330 */ 331 double DbmToW (double dbm) const; 332 333 /** 334 * Transforms a Watt value to Dbm 335 * \param w the Watt value 336 * \return the Dbm 337 */ 338 double DbmFromW (double w) const; 339 340 double m_lambda; //!< the carrier wavelength 341 double m_frequency; //!< the carrier frequency 342 double m_systemLoss; //!< the system loss 343 double m_minLoss; //!< the minimum loss 344 }; 345 346 /** 347 * \ingroup propagation 348 * 349 * \brief a Two-Ray Ground propagation loss model ported from NS2 350 * 351 * Two-ray ground reflection model. 352 * 353 * \f$ Pr = \frac{P_t * G_t * G_r * (H_t^2 * H_r^2)}{d^4 * L} \f$ 354 * 355 * The original equation in Rappaport's book assumes L = 1. 356 * To be consistent with the free space equation, L is added here. 357 * 358 * Ht and Hr are set at the respective nodes z coordinate plus a model parameter 359 * set via SetHeightAboveZ. 360 * 361 * The two-ray model does not give a good result for short distances, due to the 362 * oscillation caused by constructive and destructive combination of the two 363 * rays. Instead the Friis free-space model is used for small distances. 364 * 365 * The crossover distance, below which Friis is used, is calculated as follows: 366 * 367 * \f$ dCross = \frac{(4 * \pi * H_t * H_r)}{\lambda} \f$ 368 * 369 * In the implementation, \f$ \lambda \f$ is calculated as 370 * \f$ \frac{C}{f} \f$, where \f$ C = 299792458\f$ m/s is the speed of light in 371 * vacuum, and \f$ f \f$ is the frequency in Hz which can be configured by 372 * the user via the Frequency attribute. 373 */ 374 class TwoRayGroundPropagationLossModel : public PropagationLossModel 375 { 376 public: 377 /** 378 * \brief Get the type ID. 379 * \return the object TypeId 380 */ 381 static TypeId GetTypeId (void); 382 TwoRayGroundPropagationLossModel (); 383 384 /** 385 * \param frequency (Hz) 386 * 387 * Set the carrier frequency used in the TwoRayGround model 388 * calculation. 389 */ 390 void SetFrequency (double frequency); 391 392 /** 393 * \param systemLoss (dimension-less) 394 * 395 * Set the system loss used by the TwoRayGround propagation model. 396 */ 397 void SetSystemLoss (double systemLoss); 398 /** 399 * \param minDistance the minimum distance 400 * 401 * Below this distance, the txpower is returned 402 * unmodified as the rxpower. 403 */ 404 void SetMinDistance (double minDistance); 405 /** 406 * \returns the minimum distance. 407 */ 408 double GetMinDistance (void) const; 409 410 /** 411 * \returns the current frequency (Hz) 412 */ 413 double GetFrequency (void) const; 414 415 /** 416 * \returns the current system loss (dimension-less) 417 */ 418 double GetSystemLoss (void) const; 419 /** 420 * \param heightAboveZ the model antenna height above the node's Z coordinate 421 * 422 * Set the model antenna height above the node's Z coordinate 423 */ 424 void SetHeightAboveZ (double heightAboveZ); 425 426 private: 427 /** 428 * \brief Copy constructor 429 * 430 * Defined and unimplemented to avoid misuse 431 */ 432 TwoRayGroundPropagationLossModel (const TwoRayGroundPropagationLossModel &); 433 /** 434 * \brief Copy constructor 435 * 436 * Defined and unimplemented to avoid misuse 437 * \returns 438 */ 439 TwoRayGroundPropagationLossModel & operator = (const TwoRayGroundPropagationLossModel &); 440 441 virtual double DoCalcRxPower (double txPowerDbm, 442 Ptr<MobilityModel> a, 443 Ptr<MobilityModel> b) const; 444 virtual int64_t DoAssignStreams (int64_t stream); 445 446 /** 447 * Transforms a Dbm value to Watt 448 * \param dbm the Dbm value 449 * \return the Watts 450 */ 451 double DbmToW (double dbm) const; 452 453 /** 454 * Transforms a Watt value to Dbm 455 * \param w the Watt value 456 * \return the Dbm 457 */ 458 double DbmFromW (double w) const; 459 460 double m_lambda; //!< the carrier wavelength 461 double m_frequency; //!< the carrier frequency 462 double m_systemLoss; //!< the system loss 463 double m_minDistance; //!< minimum distance for the model 464 double m_heightAboveZ; //!< antenna height above the node's Z coordinate 465 }; 466 467 /** 468 * \ingroup propagation 469 * 470 * \brief a log distance propagation model. 471 * 472 * This model calculates the reception power with a so-called 473 * log-distance propagation model: 474 * \f$ L = L_0 + 10 n log_{10}(\frac{d}{d_0})\f$ 475 * 476 * where: 477 * - \f$ n \f$ : the path loss distance exponent 478 * - \f$ d_0 \f$ : reference distance (m) 479 * - \f$ L_0 \f$ : path loss at reference distance (dB) 480 * - \f$ d \f$ : distance (m) 481 * - \f$ L \f$ : path loss (dB) 482 * 483 * When the path loss is requested at a distance smaller than 484 * the reference distance, the tx power is returned. 485 * 486 */ 487 class LogDistancePropagationLossModel : public PropagationLossModel 488 { 489 public: 490 /** 491 * \brief Get the type ID. 492 * \return the object TypeId 493 */ 494 static TypeId GetTypeId (void); 495 LogDistancePropagationLossModel (); 496 497 /** 498 * \param n the path loss exponent. 499 * Set the path loss exponent. 500 */ 501 void SetPathLossExponent (double n); 502 /** 503 * \returns the current path loss exponent. 504 */ 505 double GetPathLossExponent (void) const; 506 507 /** 508 * Set the reference path loss at a given distance 509 * \param referenceDistance reference distance 510 * \param referenceLoss reference path loss 511 */ 512 void SetReference (double referenceDistance, double referenceLoss); 513 514 private: 515 /** 516 * \brief Copy constructor 517 * 518 * Defined and unimplemented to avoid misuse 519 */ 520 LogDistancePropagationLossModel (const LogDistancePropagationLossModel &); 521 /** 522 * \brief Copy constructor 523 * 524 * Defined and unimplemented to avoid misuse 525 * \returns 526 */ 527 LogDistancePropagationLossModel & operator = (const LogDistancePropagationLossModel &); 528 529 virtual double DoCalcRxPower (double txPowerDbm, 530 Ptr<MobilityModel> a, 531 Ptr<MobilityModel> b) const; 532 virtual int64_t DoAssignStreams (int64_t stream); 533 534 /** 535 * Creates a default reference loss model 536 * \return a default reference loss model 537 */ 538 static Ptr<PropagationLossModel> CreateDefaultReference (void); 539 540 double m_exponent; //!< model exponent 541 double m_referenceDistance; //!< reference distance 542 double m_referenceLoss; //!< reference loss 543 }; 544 545 /** 546 * \ingroup propagation 547 * 548 * \brief A log distance path loss propagation model with three distance 549 * fields. This model is the same as ns3::LogDistancePropagationLossModel 550 * except that it has three distance fields: near, middle and far with 551 * different exponents. 552 * 553 * Within each field the reception power is calculated using the log-distance 554 * propagation equation: 555 * \f[ L = L_0 + 10 \cdot n_0 log_{10}(\frac{d}{d_0})\f] 556 * Each field begins where the previous ends and all together form a continuous function. 557 * 558 * There are three valid distance fields: near, middle, far. Actually four: the 559 * first from 0 to the reference distance is invalid and returns txPowerDbm. 560 * 561 * \f[ \underbrace{0 \cdots\cdots}_{=0} \underbrace{d_0 \cdots\cdots}_{n_0} \underbrace{d_1 \cdots\cdots}_{n_1} \underbrace{d_2 \cdots\cdots}_{n_2} \infty \f] 562 * 563 * Complete formula for the path loss in dB: 564 * 565 * \f[\displaystyle L = 566 \begin{cases} 567 0 & d < d_0 \\ 568 L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0}) & d_0 \leq d < d_1 \\ 569 L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d}{d_1}) & d_1 \leq d < d_2 \\ 570 L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d_2}{d_1}) + 10 \cdot n_2 \log_{10}(\frac{d}{d_2})& d_2 \leq d 571 \end{cases}\f] 572 * 573 * where: 574 * - \f$ L \f$ : resulting path loss (dB) 575 * - \f$ d \f$ : distance (m) 576 * - \f$ d_0, d_1, d_2 \f$ : three distance fields (m) 577 * - \f$ n_0, n_1, n_2 \f$ : path loss distance exponent for each field (unitless) 578 * - \f$ L_0 \f$ : path loss at reference distance (dB) 579 * 580 * When the path loss is requested at a distance smaller than the reference 581 * distance \f$ d_0 \f$, the tx power (with no path loss) is returned. The 582 * reference distance defaults to 1m and reference loss defaults to 583 * ns3::FriisPropagationLossModel with 5.15 GHz and is thus \f$ L_0 \f$ = 46.67 dB. 584 */ 585 class ThreeLogDistancePropagationLossModel : public PropagationLossModel 586 { 587 public: 588 /** 589 * \brief Get the type ID. 590 * \return the object TypeId 591 */ 592 static TypeId GetTypeId (void); 593 ThreeLogDistancePropagationLossModel (); 594 595 // Parameters are all accessible via attributes. 596 597 private: 598 /** 599 * \brief Copy constructor 600 * 601 * Defined and unimplemented to avoid misuse 602 */ 603 ThreeLogDistancePropagationLossModel (const ThreeLogDistancePropagationLossModel&); 604 /** 605 * \brief Copy constructor 606 * 607 * Defined and unimplemented to avoid misuse 608 * \returns 609 */ 610 ThreeLogDistancePropagationLossModel& operator= (const ThreeLogDistancePropagationLossModel&); 611 612 virtual double DoCalcRxPower (double txPowerDbm, 613 Ptr<MobilityModel> a, 614 Ptr<MobilityModel> b) const; 615 virtual int64_t DoAssignStreams (int64_t stream); 616 617 double m_distance0; //!< Beginning of the first (near) distance field 618 double m_distance1; //!< Beginning of the second (middle) distance field. 619 double m_distance2; //!< Beginning of the third (far) distance field. 620 621 double m_exponent0; //!< The exponent for the first field. 622 double m_exponent1; //!< The exponent for the second field. 623 double m_exponent2; //!< The exponent for the third field. 624 625 double m_referenceLoss; //!< The reference loss at distance d0 (dB). 626 }; 627 628 /** 629 * \ingroup propagation 630 * 631 * \brief Nakagami-m fast fading propagation loss model. 632 * 633 * This propagation loss model implements the Nakagami-m fast fading 634 * model, which accounts for the variations in signal strength due to multipath 635 * fading. The model does not account for the path loss due to the 636 * distance traveled by the signal, hence for typical simulation usage it 637 * is recommended to consider using it in combination with other models 638 * that take into account this aspect. 639 * 640 * The Nakagami-m distribution is applied to the power level. The probability 641 * density function is defined as 642 * \f[ p(x; m, \omega) = \frac{2 m^m}{\Gamma(m) \omega^m} x^{2m - 1} e^{-\frac{m}{\omega} x^2} \f] 643 * with \f$ m \f$ the fading depth parameter and \f$ \omega \f$ the average received power. 644 * 645 * It is implemented by either a ns3::GammaRandomVariable or a 646 * ns3::ErlangRandomVariable random variable. 647 * 648 * The implementation of the model allows to specify different values of the m parameter (and hence different fading profiles) 649 * for three different distance ranges: 650 * \f[ \underbrace{0 \cdots\cdots}_{m_0} \underbrace{d_1 \cdots\cdots}_{m_1} \underbrace{d_2 \cdots\cdots}_{m_2} \infty \f] 651 * 652 * For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. Thus 653 * this model also implements Rayleigh distribution based fast fading. 654 */ 655 class NakagamiPropagationLossModel : public PropagationLossModel 656 { 657 public: 658 /** 659 * \brief Get the type ID. 660 * \return the object TypeId 661 */ 662 static TypeId GetTypeId (void); 663 664 NakagamiPropagationLossModel (); 665 666 // Parameters are all accessible via attributes. 667 668 private: 669 /** 670 * \brief Copy constructor 671 * 672 * Defined and unimplemented to avoid misuse 673 */ 674 NakagamiPropagationLossModel (const NakagamiPropagationLossModel&); 675 /** 676 * \brief Copy constructor 677 * 678 * Defined and unimplemented to avoid misuse 679 * \returns 680 */ 681 NakagamiPropagationLossModel& operator= (const NakagamiPropagationLossModel&); 682 683 virtual double DoCalcRxPower (double txPowerDbm, 684 Ptr<MobilityModel> a, 685 Ptr<MobilityModel> b) const; 686 virtual int64_t DoAssignStreams (int64_t stream); 687 688 double m_distance1; //!< Distance1 689 double m_distance2; //!< Distance2 690 691 double m_m0; //!< m for distances smaller than Distance1 692 double m_m1; //!< m for distances smaller than Distance2 693 double m_m2; //!< m for distances greater than Distance2 694 695 Ptr<ErlangRandomVariable> m_erlangRandomVariable; //!< Erlang random variable 696 Ptr<GammaRandomVariable> m_gammaRandomVariable; //!< Gamma random variable 697 }; 698 699 /** 700 * \ingroup propagation 701 * 702 * \brief Return a constant received power level independent of the transmit 703 * power 704 * 705 * The received power is constant independent of the transmit power. The user 706 * must set received power level through the Rss attribute or public 707 * SetRss() method. Note that if this loss model is chained to other loss 708 * models via SetNext() method, it can only be the first loss model in such 709 * a chain, or else it will disregard the losses computed by loss models 710 * that precede it in the chain. 711 */ 712 class FixedRssLossModel : public PropagationLossModel 713 { 714 public: 715 /** 716 * \brief Get the type ID. 717 * \return the object TypeId 718 */ 719 static TypeId GetTypeId (void); 720 721 FixedRssLossModel (); 722 virtual ~FixedRssLossModel (); 723 /** 724 * \param rss (dBm) the received signal strength 725 * 726 * Set the received signal strength (RSS) in dBm. 727 */ 728 void SetRss (double rss); 729 730 private: 731 /** 732 * \brief Copy constructor 733 * 734 * Defined and unimplemented to avoid misuse 735 */ 736 FixedRssLossModel (const FixedRssLossModel &); 737 /** 738 * \brief Copy constructor 739 * 740 * Defined and unimplemented to avoid misuse 741 * \returns 742 */ 743 FixedRssLossModel & operator = (const FixedRssLossModel &); 744 745 virtual double DoCalcRxPower (double txPowerDbm, 746 Ptr<MobilityModel> a, 747 Ptr<MobilityModel> b) const; 748 749 virtual int64_t DoAssignStreams (int64_t stream); 750 double m_rss; //!< the received signal strength 751 }; 752 753 /** 754 * \ingroup propagation 755 * 756 * \brief The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions. 757 * 758 * This is supposed to be used by synthetic tests. Note that by default propagation loss is assumed to be symmetric. 759 */ 760 class MatrixPropagationLossModel : public PropagationLossModel 761 { 762 public: 763 /** 764 * \brief Get the type ID. 765 * \return the object TypeId 766 */ 767 static TypeId GetTypeId (void); 768 769 MatrixPropagationLossModel (); 770 virtual ~MatrixPropagationLossModel (); 771 772 /** 773 * \brief Set loss (in dB, positive) between pair of ns-3 objects 774 * (typically, nodes). 775 * 776 * \param a ma Source mobility model 777 * \param b mb Destination mobility model 778 * \param loss a -> b path loss, positive in dB 779 * \param symmetric If true (default), both a->b and b->a paths will be affected 780 */ 781 void SetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b, double loss, bool symmetric = true); 782 783 /** 784 * Set the default propagation loss (in dB, positive) to be used, infinity if not set 785 * \param defaultLoss the default proagation loss 786 */ 787 void SetDefaultLoss (double defaultLoss); 788 789 private: 790 /** 791 * \brief Copy constructor 792 * 793 * Defined and unimplemented to avoid misuse 794 */ 795 MatrixPropagationLossModel (const MatrixPropagationLossModel &); 796 /** 797 * \brief Copy constructor 798 * 799 * Defined and unimplemented to avoid misuse 800 * \returns 801 */ 802 MatrixPropagationLossModel &operator = (const MatrixPropagationLossModel &); 803 804 virtual double DoCalcRxPower (double txPowerDbm, 805 Ptr<MobilityModel> a, 806 Ptr<MobilityModel> b) const; 807 808 virtual int64_t DoAssignStreams (int64_t stream); 809 private: 810 double m_default; //!< default loss 811 812 /// Typedef: Mobility models pair 813 typedef std::pair< Ptr<MobilityModel>, Ptr<MobilityModel> > MobilityPair; 814 815 std::map<MobilityPair, double> m_loss; //!< Propagation loss between pair of nodes 816 }; 817 818 /** 819 * \ingroup propagation 820 * 821 * \brief The propagation loss depends only on the distance (range) between transmitter and receiver. 822 * 823 * The single MaxRange attribute (units of meters) determines path loss. 824 * Receivers at or within MaxRange meters receive the transmission at the 825 * transmit power level. Receivers beyond MaxRange receive at power 826 * -1000 dBm (effectively zero). 827 */ 828 class RangePropagationLossModel : public PropagationLossModel 829 { 830 public: 831 /** 832 * \brief Get the type ID. 833 * \return the object TypeId 834 */ 835 static TypeId GetTypeId (void); 836 RangePropagationLossModel (); 837 private: 838 /** 839 * \brief Copy constructor 840 * 841 * Defined and unimplemented to avoid misuse 842 */ 843 RangePropagationLossModel (const RangePropagationLossModel&); 844 /** 845 * \brief Copy constructor 846 * 847 * Defined and unimplemented to avoid misuse 848 * \returns 849 */ 850 RangePropagationLossModel& operator= (const RangePropagationLossModel&); 851 virtual double DoCalcRxPower (double txPowerDbm, 852 Ptr<MobilityModel> a, 853 Ptr<MobilityModel> b) const; 854 virtual int64_t DoAssignStreams (int64_t stream); 855 private: 856 double m_range; //!< Maximum Transmission Range (meters) 857 }; 858 859 } // namespace ns3 860 861 #endif /* PROPAGATION_LOSS_MODEL_H */ 862