20 #include "error-channel.h"
21 #include "error-net-device.h"
22 #include "ns3/simulator.h"
23 #include "ns3/packet.h"
31 NS_OBJECT_ENSURE_REGISTERED (ErrorChannel);
34 ErrorChannel::GetTypeId (
void)
36 static TypeId tid = TypeId (
"ns3::ErrorChannel")
37 .SetParent<Channel> ()
38 .AddConstructor<ErrorChannel> ()
43 ErrorChannel::ErrorChannel ()
63 ErrorChannel::Send (
Ptr<Packet> p, uint16_t protocol,
68 for (std::vector<
Ptr<ErrorNetDevice> >::const_iterator i = m_devices.begin (); i != m_devices.end (); ++i)
75 if( !jumping || jumpingState%2 )
78 &ErrorNetDevice::Receive, tmp, p->
Copy (), protocol, to, from);
84 &ErrorNetDevice::Receive, tmp, p->
Copy (), protocol, to, from);
91 ErrorChannel::Add (Ptr<ErrorNetDevice> device)
93 m_devices.push_back (device);
99 return m_devices.size ();
109 TypeId BinaryErrorModel::GetTypeId (
void)
113 .AddConstructor<BinaryErrorModel> ()
118 BinaryErrorModel::BinaryErrorModel ()
123 BinaryErrorModel::~BinaryErrorModel ()
129 BinaryErrorModel::DoCorrupt (Ptr<Packet> p)
135 bool ret = counter%2;
141 BinaryErrorModel::Reset (
void)
147 BinaryErrorModel::DoReset (
void)
#define NS_LOG_FUNCTION(parameters)
#define NS_LOG_COMPONENT_DEFINE(name)
General error model that can be used to corrupt packets.
bool IsEnabled(void) const
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
void SetJumpingMode(bool mode)
Set if the odd packets are delayed (even ones are not delayed ever)
Ptr< Packet > Copy(void) const
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
void SetJumpingTime(Time delay)
Set the delay for the odd packets (even ones are not delayed)
virtual uint32_t GetNDevices(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual Ptr< NetDevice > GetDevice(uint32_t i) const