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"
87 .AddAttribute (
"IsEnabled",
"Whether this ErrorModel is enabled or not.",
90 MakeBooleanChecker ())
156 .AddConstructor<RateErrorModel> ()
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 ()) );
296 .AddConstructor<BurstErrorModel> ()
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> ())
425 .AddConstructor<ListErrorModel> ()
465 uint32_t uid = p->
GetUid ();
493 static TypeId tid =
TypeId (
"ns3::ReceiveListErrorModel")
495 .AddConstructor<ReceiveListErrorModel> ()
virtual void DoReset(void)
void SetRandomBurstSize(Ptr< RandomVariableStream > burstSz)
std::list< uint32_t > GetList(void) const
#define NS_LOG_FUNCTION(parameters)
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)
hold variables of type string
std::list< uint32_t > GetList(void) const
static TypeId GetTypeId(void)
uint64_t GetUid(void) const
A packet is allocated a new uid when it is created empty or with zero-filled payload.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
virtual bool DoCorrupt(Ptr< Packet >)=0
General error model that can be used to corrupt packets.
virtual void DoReset(void)
virtual void DoReset(void)=0
virtual double GetValue(void)=0
Returns a random double from the underlying distribution.
static TypeId GetTypeId(void)
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
bool IsEnabled(void) const
hold variables of type 'enum'
virtual bool DoCorruptBit(Ptr< Packet > p)
Ptr< RandomVariableStream > m_burstStart
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
Provide a list of Packet uids to corrupt.
virtual bool DoCorrupt(Ptr< Packet > p)
virtual void DoReset(void)
virtual bool DoCorruptByte(Ptr< Packet > p)
Ptr< RandomVariableStream > m_ranvar
void Disable(void)
Disable the error model.
virtual bool DoCorrupt(Ptr< Packet > p)
virtual ~BurstErrorModel()
virtual ~ListErrorModel()
double GetRate(void) const
static TypeId GetTypeId(void)
virtual bool DoCorrupt(Ptr< Packet > p)
void SetRandomVariable(Ptr< RandomVariableStream > ranVar)
void SetList(const std::list< uint32_t > &packetlist)
void Reset(void)
Reset any state associated with the error model.
NS_LOG_COMPONENT_DEFINE("ErrorModel")
virtual void DoReset(void)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
#define NS_ASSERT_MSG(condition, message)
void SetUnit(enum ErrorUnit error_unit)
static TypeId GetTypeId(void)
double GetBurstRate(void) const
virtual bool DoCorrupt(Ptr< Packet > p)
virtual bool DoCorruptPkt(Ptr< Packet > p)
Determine which bursts of packets are errored corresponding to an underlying distribution, burst rate, and burst size.
uint32_t m_currentBurstSz
Provide a list of Packets to corrupt.
#define NS_LOG_DEBUG(msg)
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
static TypeId GetTypeId(void)
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.