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 .AddAttribute (
"IsEnabled",
"Whether this ErrorModel is enabled or not.",
89 MakeBooleanChecker ())
154 .AddConstructor<RateErrorModel> ()
155 .AddAttribute (
"ErrorUnit",
"The error unit",
161 .AddAttribute (
"ErrorRate",
"The error rate.",
164 MakeDoubleChecker<double> ())
165 .AddAttribute (
"RanVar",
"The decision variable attached to this error model.",
166 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
168 MakePointerChecker<RandomVariableStream> ())
262 double per = 1 - std::pow (1.0 -
m_rate, static_cast<double> (p->
GetSize ()));
271 double per = 1 - std::pow (1.0 -
m_rate, static_cast<double> (8 * p->
GetSize ()) );
293 .AddConstructor<BurstErrorModel> ()
294 .AddAttribute (
"ErrorRate",
"The burst error event.",
297 MakeDoubleChecker<double> ())
298 .AddAttribute (
"BurstStart",
"The decision variable attached to this error model.",
299 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
301 MakePointerChecker<RandomVariableStream> ())
302 .AddAttribute (
"BurstSize",
"The number of packets being corrupted at one drop.",
303 StringValue (
"ns3::UniformRandomVariable[Min=1|Max=4]"),
305 MakePointerChecker<RandomVariableStream> ())
421 .AddConstructor<ListErrorModel> ()
461 uint32_t uid = p->
GetUid ();
488 static TypeId tid =
TypeId (
"ns3::ReceiveListErrorModel")
490 .AddConstructor<ReceiveListErrorModel> ()
bool m_enable
True if the error model is enabled.
virtual void DoReset(void)
Re-initialize any state.
void SetRandomBurstSize(Ptr< RandomVariableStream > burstSz)
virtual bool DoCorrupt(Ptr< Packet > p)=0
Corrupt a packet according to the specified model.
std::list< uint32_t > GetList(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
PacketList m_packetList
container of sequence number of packets to corrupt
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
hold variables of type string
std::list< uint32_t > GetList(void) const
static TypeId GetTypeId(void)
Get the type ID.
uint64_t GetUid(void) const
Returns the packet's Uid.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
PacketList m_packetList
container of Uid of packets to corrupt
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
General error model that can be used to corrupt packets.
virtual void DoReset(void)
Re-initialize any state.
virtual void DoReset(void)=0
Re-initialize any state.
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~ReceiveListErrorModel()
virtual ~RateErrorModel()
virtual uint32_t GetInteger(void)=0
Returns a random integer integer from the underlying distribution.
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet sequence number list const iterator.
bool IsEnabled(void) const
hold variables of type 'enum'
virtual bool DoCorruptBit(Ptr< Packet > p)
Corrupt a packet (bit unit).
Ptr< RandomVariableStream > m_burstStart
the error decision variable
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void SetRate(double rate)
Ptr< RandomVariableStream > m_burstSize
the number of packets being flagged as errored
Provide a list of Packet uids to corrupt.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
enum ErrorUnit m_unit
Error rate unit.
virtual void DoReset(void)
Re-initialize any state.
virtual bool DoCorruptByte(Ptr< Packet > p)
Corrupt a packet (Byte unit).
Ptr< RandomVariableStream > m_ranvar
rng stream
uint32_t m_counter
keep track of the number of packets being errored until it reaches m_burstSize
void Disable(void)
Disable the error model.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
virtual ~BurstErrorModel()
uint32_t m_timesInvoked
number of times the error model has been invoked
virtual ~ListErrorModel()
double GetRate(void) const
static TypeId GetTypeId(void)
Get the type ID.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
void SetRandomVariable(Ptr< RandomVariableStream > ranVar)
void SetList(const std::list< uint32_t > &packetlist)
void Reset(void)
Reset any state associated with the error model.
virtual void DoReset(void)
Re-initialize any state.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void SetUnit(enum ErrorUnit error_unit)
static TypeId GetTypeId(void)
Get the type ID.
double GetBurstRate(void) const
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
virtual bool DoCorruptPkt(Ptr< Packet > p)
Corrupt a packet (packet unit).
Determine which bursts of packets are errored corresponding to an underlying distribution, burst rate, and burst size.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t m_currentBurstSz
the current burst size
Provide a list of Packets to corrupt.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool IsCorrupt(Ptr< Packet > pkt)
Note: Depending on the error model, this function may or may not alter the contents of the packet upo...
void SetList(const std::list< uint32_t > &packetlist)
void SetRandomVariable(Ptr< RandomVariableStream >)
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet Uid list const iterator.
double m_burstRate
the burst error event
static TypeId GetTypeId(void)
Get the type ID.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
a base class which provides memory management and object aggregation
Determine which packets are errored corresponding to an underlying distribution, rate, and unit.
Hold a floating point type.
RateErrorModel::ErrorUnit GetUnit(void) const
a unique identifier for an interface.
void SetBurstRate(double rate)
TypeId SetParent(TypeId tid)
void Enable(void)
Enable the error model.