Basic implementation of a SimplePathlossModel that uses SimplePathlossConstMapping (that is subclassed from SimpleConstMapping) as attenuation-Mapping. More...
#include <SimplePathlossModel.h>
Inherits AnalogueModel.
Public Member Functions | |
SimplePathlossModel (double alpha, double carrierFrequency, const Move *myMove, bool useTorus, const Coord &playgroundSize, bool debug) | |
Initializes the analogue model. myMove and playgroundSize need to be valid as long as this instance exists. | |
virtual void | filterSignal (Signal &s) |
Filters a specified Signal by adding an attenuation over time to the Signal. | |
virtual double | calcPathloss (const Coord &myPos, const Coord &sendersPos) |
Method to calculate the attenuation value for pathloss. | |
Protected Attributes | |
double | pathLossAlphaHalf |
Path loss coefficient. | |
double | carrierFrequency |
carrier frequency needed for calculation | |
const Move & | myMove |
stores my Move pattern | |
const bool | useTorus |
Information needed about the playground. | |
const Coord & | playgroundSize |
The size of the playground. | |
bool | debug |
Whether debug messages should be displayed. | |
Friends | |
class | SimplePathlossConstMapping |
Basic implementation of a SimplePathlossModel that uses SimplePathlossConstMapping (that is subclassed from SimpleConstMapping) as attenuation-Mapping.
An example config.xml for this AnalogueModel can be the following:
<AnalogueModel type="SimplePathlossModel"> <!-- Environment parameter of the pathloss formula If ommited default value is 3.5--> <parameter name="alpha" type="double" value="3.5"/> <!-- Carrier frequency of the signal in Hz If ommited the carrier frequency from the connection manager is taken if available otherwise set to default frequency of 2.412e+9--> <parameter name="carrierFrequency" type="double" value="2.412e+9"/> </AnalogueModel>
Definition at line 85 of file SimplePathlossModel.h.
SimplePathlossModel::SimplePathlossModel | ( | double | alpha, | |
double | carrierFrequency, | |||
const Move * | myMove, | |||
bool | useTorus, | |||
const Coord & | playgroundSize, | |||
bool | debug | |||
) | [inline] |
Initializes the analogue model. myMove and playgroundSize need to be valid as long as this instance exists.
The constructor needs some specific knowledge in order to create its mapping properly:
alpha | the coefficient alpha (specified e.g. in config.xml and passed in constructor call) | |
carrierFrequency | the carrier frequency | |
myMove | a pointer to the hosts move pattern | |
useTorus | information about the playground the host is moving in | |
playgroundSize | information about the playground the host is moving in | |
debug | display debug messages? |
Definition at line 125 of file SimplePathlossModel.h.
: pathLossAlphaHalf(alpha * 0.5), carrierFrequency(carrierFrequency), myMove(*myMove), useTorus(useTorus), playgroundSize(playgroundSize), debug(debug) { }
double SimplePathlossModel::calcPathloss | ( | const Coord & | myPos, | |
const Coord & | sendersPos | |||
) | [virtual] |
Method to calculate the attenuation value for pathloss.
Functionality is similar to pathloss-calculation in BasicSnrEval from Mobility-frame work.
Note: This method is not used directly anymore. Instead the actual pathloss is calculated in SimplePathlossConstMappings "getValue()" method.
Definition at line 77 of file SimplePathlossModel.cc.
References carrierFrequency, M_PI, pathLossAlphaHalf, playgroundSize, BaseWorldUtility::speedOfLight, Coord::sqrdist(), Coord::sqrTorusDist(), and useTorus.
{ /* * maybe we can reuse an already calculated value for the square-distance * at this point. * */ double sqrdistance = 0.0; if (useTorus) { sqrdistance = myPos.sqrTorusDist(sendersPos, playgroundSize); } else { sqrdistance = myPos.sqrdist(sendersPos); } splmEV << "sqrdistance is: " << sqrdistance << endl; double attenuation = 1.0; // wavelength in metres double wavelength = (BaseWorldUtility::speedOfLight/carrierFrequency); splmEV << "wavelength is: " << wavelength << endl; if (sqrdistance > 1.0) { attenuation = (wavelength * wavelength) / (16.0 * M_PI * M_PI) * (pow(sqrdistance, -1.0*pathLossAlphaHalf)); } splmEV << "attenuation is: " << attenuation << endl; return attenuation; }
void SimplePathlossModel::filterSignal | ( | Signal & | s | ) | [virtual] |
Filters a specified Signal by adding an attenuation over time to the Signal.
Get start of the signal
claim the Move pattern of the sender from the Signal
Calculate the distance factor
Implements AnalogueModel.
Definition at line 28 of file SimplePathlossModel.cc.
References Signal::addAttenuation(), carrierFrequency, Dimension::frequency, ConstMapping::getDimensionSet(), Signal::getMove(), Move::getPositionAt(), Signal::getSignalLength(), Signal::getSignalStart(), Signal::getTransmissionPower(), DimensionSet::hasDimension(), M_PI, myMove, pathLossAlphaHalf, playgroundSize, BaseWorldUtility::speedOfLight, Coord::sqrdist(), Coord::sqrTorusDist(), DimensionSet::timeDomain, DimensionSet::timeFreqDomain, and useTorus.
{ simtime_t sStart = s.getSignalStart(); simtime_t sEnd = s.getSignalLength() + sStart; Coord sendersPos = s.getMove().getPositionAt(sStart); Coord myPos = myMove.getPositionAt(sStart); double sqrDistance = useTorus ? myPos.sqrTorusDist(sendersPos, playgroundSize) : myPos.sqrdist(sendersPos); splmEV << "sqrdistance is: " << sqrDistance << endl; if(sqrDistance <= 1.0) { //attenuation is negligible return; } // wavelength in meters (this is only used for debug purposes here // the actual effect of the wavelength on the attenuation is // calculated in SimplePathlossConstMappings "getValue()" method). double wavelength = (BaseWorldUtility::speedOfLight/carrierFrequency); splmEV << "wavelength is: " << wavelength << endl; // the part of the attenuation only depending on the distance double distFactor = pow(sqrDistance, -pathLossAlphaHalf) / (16.0 * M_PI * M_PI); splmEV << "distance factor is: " << distFactor << endl; //is our signal to attenuate defined over frequency? bool hasFrequency = s.getTransmissionPower()->getDimensionSet().hasDimension(Dimension::frequency); splmEV << "Signal contains frequency dimension: " << (hasFrequency ? "yes" : "no") << endl; const DimensionSet& domain = hasFrequency ? DimensionSet::timeFreqDomain : DimensionSet::timeDomain; //create the Attenuation mapping which takes the distance factor as parameter //to calculate the attenuation from this and the frequency used for the transmission //see the classes "getValue()" for more SimplePathlossConstMapping* attMapping = new SimplePathlossConstMapping( domain, this, distFactor); /* at last add the created attenuation mapping to the signal */ s.addAttenuation(attMapping); }