|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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> ()
a unique identifier for an interface.
virtual ~ReceiveListErrorModel()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetRandomVariable(Ptr< RandomVariableStream > ranVar)
virtual bool DoCorruptBit(Ptr< Packet > p)
Corrupt a packet (bit unit).
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint8_t m_counter
internal state counter.
AttributeValue implementation for Boolean.
The simplest error model, corrupts even packets and does not corrupt odd ones.
void SetBurstRate(double rate)
double GetBurstRate(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
PacketList m_packetList
container of Uid of packets to corrupt
void SetUnit(enum ErrorUnit error_unit)
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Provide a list of Packet uids to corrupt.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
std::list< uint32_t > GetList(void) const
virtual void DoReset(void)
Re-initialize any state.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
General error model that can be used to corrupt packets.
bool IsEnabled(void) const
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t m_currentBurstSz
the current burst size
void Enable(void)
Enable the error model.
void Reset(void)
Reset any state associated with the error model.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
double GetRate(void) const
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.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
virtual void DoReset(void)
Re-initialize any state.
bool m_enable
True if the error model is enabled.
PacketList m_packetList
container of sequence number of packets to corrupt
virtual void DoReset(void)=0
Re-initialize any state.
uint32_t m_timesInvoked
number of times the error model has been invoked
Ptr< RandomVariableStream > m_burstStart
the error decision variable
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
virtual ~BinaryErrorModel()
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoReset(void)
Re-initialize any state.
Determine which bursts of packets are errored corresponding to an underlying distribution,...
void SetList(const std::list< uint32_t > &packetlist)
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
virtual bool DoCorrupt(Ptr< Packet > p)=0
Corrupt a packet according to the specified model.
void SetList(const std::list< uint32_t > &packetlist)
static TypeId GetTypeId(void)
Get the type ID.
A base class which provides memory management and object aggregation.
void Disable(void)
Disable the error model.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
double m_burstRate
the burst error event
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet Uid list const iterator.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
enum ErrorUnit m_unit
Error rate unit.
std::list< uint32_t >::const_iterator PacketListCI
Typedef: packet sequence number list const iterator.
virtual ~RateErrorModel()
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual bool DoCorruptPkt(Ptr< Packet > p)
Corrupt a packet (packet unit).
RateErrorModel::ErrorUnit GetUnit(void) const
bool IsCorrupt(Ptr< Packet > pkt)
Note: Depending on the error model, this function may or may not alter the contents of the packet upo...
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 string.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
void SetRandomBurstSize(Ptr< RandomVariableStream > burstSz)
Ptr< const AttributeAccessor > MakeDoubleAccessor(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.
void SetRate(double rate)
virtual bool DoCorruptByte(Ptr< Packet > p)
Corrupt a packet (Byte unit).
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< RandomVariableStream > m_ranvar
rng stream
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
Determine which packets are errored corresponding to an underlying distribution, rate,...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual ~BurstErrorModel()
virtual ~ListErrorModel()
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint32_t m_counter
keep track of the number of packets being errored until it reaches m_burstSize
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
virtual void DoReset(void)
Re-initialize any state.
Ptr< RandomVariableStream > m_burstSize
the number of packets being flagged as errored
virtual void DoReset(void)
Re-initialize any state.
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
Provide a list of Packets to corrupt.
std::list< uint32_t > GetList(void) const
void SetRandomVariable(Ptr< RandomVariableStream >)
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
uint64_t GetUid(void) const
Returns the packet's Uid.