This class applies a parameterized packet error rate to incoming packets. This allows the user to easily study the robustness of its system to packet loss. More...
#include <PERModel.h>
Inherits AnalogueModel.

Public Member Functions | |
| PERModel (double per) | |
| The PERModel constructor takes as argument the packet error rate to apply (must be between 0 and 1). | |
| virtual void | filterSignal (Signal &s) |
| Has to be overriden by every implementation. | |
Protected Attributes | |
| double | packetErrorRate |
This class applies a parameterized packet error rate to incoming packets. This allows the user to easily study the robustness of its system to packet loss.
Definition at line 15 of file PERModel.h.
| void PERModel::filterSignal | ( | Signal & | s | ) | [virtual] |
Has to be overriden by every implementation.
Filters a specified Signal by adding an attenuation over time to the Signal.
Implements AnalogueModel.
Definition at line 3 of file PERModel.cc.
References Signal::addAttenuation(), Signal::getSignalLength(), Signal::getSignalStart(), and TimeMapping< Interpolator >::setValue().
{
simtime_t start = s.getSignalStart();
simtime_t end = start + s.getSignalLength();
double attenuationFactor = 1; // no attenuation
if(packetErrorRate > 0 && uniform(0, 1) < packetErrorRate) {
attenuationFactor = 0; // absorb all energy so that the receveir cannot receive anything
}
TimeMapping<Linear>* attMapping = new TimeMapping<Linear> ();
Argument arg;
attMapping->setValue(arg, attenuationFactor);
s.addAttenuation(attMapping);
}
1.7.1