20 #include "simple-net-device.h"
21 #include "simple-channel.h"
23 #include "ns3/packet.h"
25 #include "ns3/pointer.h"
26 #include "ns3/error-model.h"
27 #include "ns3/trace-source-accessor.h"
33 NS_OBJECT_ENSURE_REGISTERED (SimpleNetDevice);
36 SimpleNetDevice::GetTypeId (
void)
38 static TypeId tid = TypeId (
"ns3::SimpleNetDevice")
39 .SetParent<NetDevice> ()
40 .AddConstructor<SimpleNetDevice> ()
41 .AddAttribute (
"ReceiveErrorModel",
42 "The receiver error model used to simulate packet loss",
44 MakePointerAccessor (&SimpleNetDevice::m_receiveErrorModel),
45 MakePointerChecker<ErrorModel> ())
46 .AddTraceSource (
"PhyRxDrop",
47 "Trace source indicating a packet has been dropped by the device during reception",
53 SimpleNetDevice::SimpleNetDevice ()
63 SimpleNetDevice::Receive (Ptr<Packet> packet, uint16_t protocol,
64 Mac48Address to, Mac48Address from)
69 if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
79 else if (to.IsBroadcast ())
83 else if (to.IsGroup ())
91 m_rxCallback (
this, packet, protocol, from);
92 if (!m_promiscCallback.IsNull ())
94 m_promiscCallback (
this, packet, protocol, from, to, packetType);
99 SimpleNetDevice::SetChannel (Ptr<SimpleChannel> channel)
103 m_channel->Add (
this);
110 m_receiveErrorModel = em;
220 m_channel->Send (packet, protocolNumber, to, m_address,
this);
229 m_channel->Send (packet, protocolNumber, to, from,
this);
264 m_receiveErrorModel = 0;
273 m_promiscCallback = cb;
virtual Address GetAddress(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
virtual Ptr< Channel > GetChannel(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void SetIfIndex(const uint32_t index)
virtual void DoDispose(void)
virtual bool IsBroadcast(void) const
virtual bool NeedsArp(void) const
virtual bool IsMulticast(void) const
a polymophic address class
virtual void SetNode(Ptr< Node > node)
static Mac48Address GetMulticast(Ipv4Address address)
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
static Mac48Address ConvertFrom(const Address &address)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint16_t GetMtu(void) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
virtual Ptr< Node > GetNode(void) const
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetAddress(Address address)
virtual void DoDispose(void)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual Address GetBroadcast(void) const
virtual uint32_t GetIfIndex(void) const
virtual bool SupportsSendFrom(void) const
virtual bool IsLinkUp(void) const