64 #include "ns3/assert.h"
65 #include "ns3/boolean.h"
66 #include "ns3/double.h"
69 #include "ns3/packet.h"
70 #include "ns3/pointer.h"
71 #include "ns3/string.h"
87 .SetGroupName(
"Network")
88 .AddAttribute(
"IsEnabled",
89 "Whether this ErrorModel is enabled or not.",
156 TypeId(
"ns3::RateErrorModel")
158 .SetGroupName(
"Network")
160 .AddAttribute(
"ErrorUnit",
169 "ERROR_UNIT_PACKET"))
170 .AddAttribute(
"ErrorRate",
174 MakeDoubleChecker<double>())
175 .AddAttribute(
"RanVar",
176 "The decision variable attached to this error model.",
177 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
179 MakePointerChecker<RandomVariableStream>());
271 double per = 1 - std::pow(1.0 -
m_rate,
static_cast<double>(p->
GetSize()));
280 double per = 1 - std::pow(1.0 -
m_rate,
static_cast<double>(8 * p->
GetSize()));
301 TypeId(
"ns3::BurstErrorModel")
303 .SetGroupName(
"Network")
305 .AddAttribute(
"ErrorRate",
306 "The burst error event.",
309 MakeDoubleChecker<double>())
310 .AddAttribute(
"BurstStart",
311 "The decision variable attached to this error model.",
312 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
314 MakePointerChecker<RandomVariableStream>())
315 .AddAttribute(
"BurstSize",
316 "The number of packets being corrupted at one drop.",
317 StringValue(
"ns3::UniformRandomVariable[Min=1|Max=4]"),
319 MakePointerChecker<RandomVariableStream>());
433 .SetGroupName(
"Network")
500 static TypeId tid =
TypeId(
"ns3::ReceiveListErrorModel")
502 .SetGroupName(
"Network")
The simplest error model, corrupts even packets and does not corrupt odd ones.
uint8_t m_counter
internal state counter.
void DoReset() override
Re-initialize any state.
~BinaryErrorModel() override
static TypeId GetTypeId()
Get the type ID.
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
Determine which bursts of packets are errored corresponding to an underlying distribution,...
Ptr< RandomVariableStream > m_burstStart
the error decision variable
void SetRandomVariable(Ptr< RandomVariableStream > ranVar)
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
Ptr< RandomVariableStream > m_burstSize
the number of packets being flagged as errored
uint32_t m_currentBurstSz
the current burst size
double GetBurstRate() const
void DoReset() override
Re-initialize any state.
static TypeId GetTypeId()
Get the type ID.
double m_burstRate
the burst error event
void SetBurstRate(double rate)
uint32_t m_counter
keep track of the number of packets being errored until it reaches m_burstSize
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
~BurstErrorModel() override
void SetRandomBurstSize(Ptr< RandomVariableStream > burstSz)
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
General error model that can be used to corrupt packets.
bool m_enable
True if the error model is enabled.
void Reset()
Reset any state associated with the error model.
void Enable()
Enable the error model.
virtual bool DoCorrupt(Ptr< Packet > p)=0
Corrupt a packet according to the specified model.
virtual void DoReset()=0
Re-initialize any state.
static TypeId GetTypeId()
Get the type ID.
void Disable()
Disable the error model.
bool IsCorrupt(Ptr< Packet > pkt)
Note: Depending on the error model, this function may or may not alter the contents of the packet upo...
Provide a list of Packet uids to corrupt.
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
~ListErrorModel() override
void DoReset() override
Re-initialize any state.
void SetList(const std::list< uint64_t > &packetlist)
std::list< uint64_t > GetList() const
static TypeId GetTypeId()
Get the type ID.
PacketList m_packetList
container of Uid of packets to corrupt
A base class which provides memory management and object aggregation.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint64_t GetUid() const
Returns the packet's Uid.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
virtual uint32_t GetInteger()
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Determine which packets are errored corresponding to an underlying distribution, rate,...
virtual bool DoCorruptByte(Ptr< Packet > p)
Corrupt a packet (Byte unit).
ErrorUnit m_unit
Error rate unit.
void SetRate(double rate)
void DoReset() override
Re-initialize any state.
virtual bool DoCorruptBit(Ptr< Packet > p)
Corrupt a packet (bit unit).
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetUnit(ErrorUnit error_unit)
static TypeId GetTypeId()
Get the type ID.
~RateErrorModel() override
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
Ptr< RandomVariableStream > m_ranvar
rng stream
virtual bool DoCorruptPkt(Ptr< Packet > p)
Corrupt a packet (packet unit).
void SetRandomVariable(Ptr< RandomVariableStream >)
RateErrorModel::ErrorUnit GetUnit() const
Provide a list of Packets to corrupt.
void DoReset() override
Re-initialize any state.
bool DoCorrupt(Ptr< Packet > p) override
Corrupt a packet according to the specified model.
static TypeId GetTypeId()
Get the type ID.
~ReceiveListErrorModel() override
uint32_t m_timesInvoked
number of times the error model has been invoked
std::list< uint32_t > GetList() const
PacketList m_packetList
container of sequence number of packets to corrupt
void SetList(const std::list< uint32_t > &packetlist)
Hold variables of type string.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)