53#include "ns3/assert.h"
54#include "ns3/boolean.h"
55#include "ns3/double.h"
58#include "ns3/packet.h"
59#include "ns3/pointer.h"
60#include "ns3/string.h"
76 .SetGroupName(
"Network")
77 .AddAttribute(
"IsEnabled",
78 "Whether this ErrorModel is enabled or not.",
145 TypeId(
"ns3::RateErrorModel")
147 .SetGroupName(
"Network")
149 .AddAttribute(
"ErrorUnit",
158 "ERROR_UNIT_PACKET"))
159 .AddAttribute(
"ErrorRate",
164 .AddAttribute(
"RanVar",
165 "The decision variable attached to this error model.",
166 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
260 double per = 1 - std::pow(1.0 -
m_rate,
static_cast<double>(p->GetSize()));
269 double per = 1 - std::pow(1.0 -
m_rate,
static_cast<double>(8 * p->GetSize()));
290 TypeId(
"ns3::BurstErrorModel")
292 .SetGroupName(
"Network")
294 .AddAttribute(
"ErrorRate",
295 "The burst error event.",
299 .AddAttribute(
"BurstStart",
300 "The decision variable attached to this error model.",
301 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
304 .AddAttribute(
"BurstSize",
305 "The number of packets being corrupted at one drop.",
306 StringValue(
"ns3::UniformRandomVariable[Min=1|Max=4]"),
422 .SetGroupName(
"Network")
462 auto uid = p->GetUid();
489 static TypeId tid =
TypeId(
"ns3::ReceiveListErrorModel")
491 .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.
Smart pointer class similar to boost::intrusive_ptr.
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#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 AttributeChecker > MakeDoubleChecker()
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)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)