67 #include "ns3/packet.h"
68 #include "ns3/assert.h"
70 #include "ns3/boolean.h"
72 #include "ns3/double.h"
73 #include "ns3/string.h"
74 #include "ns3/pointer.h"
86 .SetGroupName(
"Network")
87 .AddAttribute (
"IsEnabled",
"Whether this ErrorModel is enabled or not.",
155 .SetGroupName(
"Network")
157 .AddAttribute (
"ErrorUnit",
"The error unit",
163 .AddAttribute (
"ErrorRate",
"The error rate.",
166 MakeDoubleChecker<double> ())
167 .AddAttribute (
"RanVar",
"The decision variable attached to this error model.",
168 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
170 MakePointerChecker<RandomVariableStream> ())
264 double per = 1 - std::pow (1.0 -
m_rate,
static_cast<double> (p->
GetSize ()));
273 double per = 1 - std::pow (1.0 -
m_rate,
static_cast<double> (8 * p->
GetSize ()) );
295 .SetGroupName(
"Network")
297 .AddAttribute (
"ErrorRate",
"The burst error event.",
300 MakeDoubleChecker<double> ())
301 .AddAttribute (
"BurstStart",
"The decision variable attached to this error model.",
302 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
304 MakePointerChecker<RandomVariableStream> ())
305 .AddAttribute (
"BurstSize",
"The number of packets being corrupted at one drop.",
306 StringValue (
"ns3::UniformRandomVariable[Min=1|Max=4]"),
308 MakePointerChecker<RandomVariableStream> ())
424 .SetGroupName(
"Network")
465 uint32_t uid = p->
GetUid ();
492 static TypeId tid =
TypeId (
"ns3::ReceiveListErrorModel")
494 .SetGroupName(
"Network")
560 .AddConstructor<BinaryErrorModel> ()
The simplest error model, corrupts even packets and does not corrupt odd ones.
uint8_t m_counter
internal state counter.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~BinaryErrorModel()
virtual void DoReset(void)
Re-initialize any state.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
AttributeValue implementation for Boolean.
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)
virtual void DoReset(void)
Re-initialize any state.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< RandomVariableStream > m_burstSize
the number of packets being flagged as errored
virtual ~BurstErrorModel()
uint32_t m_currentBurstSz
the current burst size
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
double GetBurstRate(void) const
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
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.
bool IsEnabled(void) const
static TypeId GetTypeId(void)
Get the type ID.
void Disable(void)
Disable the error model.
void Enable(void)
Enable the error model.
void Reset(void)
Reset any state associated with the error model.
virtual bool DoCorrupt(Ptr< Packet > p)=0
Corrupt a packet according to the specified model.
virtual void DoReset(void)=0
Re-initialize any state.
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.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
std::list< uint32_t > GetList(void) const
virtual ~ListErrorModel()
void SetList(const std::list< uint32_t > &packetlist)
virtual void DoReset(void)
Re-initialize any state.
PacketList m_packetList
container of Uid of packets to corrupt
static TypeId GetTypeId(void)
Get the type ID.
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet Uid list const iterator.
A base class which provides memory management and object aggregation.
uint64_t GetUid(void) const
Returns the packet's Uid.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer 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).
void SetRate(double rate)
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
virtual bool DoCorruptBit(Ptr< Packet > p)
Corrupt a packet (bit unit).
RateErrorModel::ErrorUnit GetUnit(void) const
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
enum ErrorUnit m_unit
Error rate unit.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~RateErrorModel()
virtual void DoReset(void)
Re-initialize any state.
Ptr< RandomVariableStream > m_ranvar
rng stream
void SetUnit(enum ErrorUnit error_unit)
virtual bool DoCorruptPkt(Ptr< Packet > p)
Corrupt a packet (packet unit).
double GetRate(void) const
void SetRandomVariable(Ptr< RandomVariableStream >)
Provide a list of Packets to corrupt.
virtual ~ReceiveListErrorModel()
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoReset(void)
Re-initialize any state.
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet sequence number list const iterator.
uint32_t m_timesInvoked
number of times the error model has been invoked
PacketList m_packetList
container of sequence number of packets to corrupt
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
std::list< uint32_t > GetList(void) const
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 AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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 > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.