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> ()
bool m_enable
True if the error model is enabled.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
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.
uint64_t GetUid(void) const
Returns the packet's Uid.
#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 the RngStream.
PacketList m_packetList
container of sequence number of packets to corrupt
AttributeValue implementation for Boolean.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
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 > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static TypeId GetTypeId(void)
Get the type ID.
double GetRate(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
PacketList m_packetList
container of Uid of packets to corrupt
static TypeId GetTypeId(void)
Get the type ID.
uint8_t m_counter
internal state counter.
General error model that can be used to corrupt packets.
virtual void DoReset(void)
Re-initialize any state.
virtual ~BinaryErrorModel()
virtual void DoReset(void)=0
Re-initialize any state.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~ReceiveListErrorModel()
virtual void DoReset(void)
Re-initialize any state.
virtual ~RateErrorModel()
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet sequence number list const iterator.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
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 GetBurstRate(void) const
static TypeId GetTypeId(void)
Get the type ID.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
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.
std::list< uint32_t > GetList(void) const
virtual void DoReset(void)
Re-initialize any state.
The simplest error model, corrupts even packets and does not corrupt odd ones.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetUnit(enum ErrorUnit error_unit)
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)
Make an EnumChecker pre-configured with a set of allowed values by name.
static TypeId GetTypeId(void)
Get the type ID.
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.
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...
bool IsEnabled(void) const
A base class which provides memory management and object aggregation.
Determine which packets are errored corresponding to an underlying distribution, rate, and unit.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
a unique identifier for an interface.
void SetBurstRate(double rate)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void Enable(void)
Enable the error model.
std::list< uint32_t > GetList(void) const