22 #include "ns3/simulator.h"
23 #include "ns3/mac48-address.h"
24 #include "ns3/llc-snap-header.h"
25 #include "ns3/error-model.h"
27 #include "ns3/channel.h"
28 #include "ns3/trace-source-accessor.h"
29 #include "ns3/uinteger.h"
43 .SetGroupName (
"VirtualNetDevice")
45 .AddAttribute (
"Mtu",
"The MAC-level Maximum Transmission Unit",
49 MakeUintegerChecker<uint16_t> ())
50 .AddTraceSource (
"MacTx",
51 "Trace source indicating a packet has arrived "
52 "for transmission by this device",
54 "ns3::Packet::TracedCallback")
55 .AddTraceSource (
"MacPromiscRx",
56 "A packet has been received by this device, "
57 "has been passed up from the physical layer "
58 "and is being forwarded up the local protocol stack. "
59 "This is a promiscuous trace,",
61 "ns3::Packet::TracedCallback")
62 .AddTraceSource (
"MacRx",
63 "A packet has been received by this device, "
64 "has been passed up from the physical layer "
65 "and is being forwarded up the local protocol stack. "
66 "This is a non-promiscuous trace,",
68 "ns3::Packet::TracedCallback")
72 .AddTraceSource (
"Sniffer",
73 "Trace source simulating a non-promiscuous "
74 "packet sniffer attached to the device",
76 "ns3::Packet::TracedCallback")
77 .AddTraceSource (
"PromiscSniffer",
78 "Trace source simulating a promiscuous "
79 "packet sniffer attached to the device",
81 "ns3::Packet::TracedCallback")
269 if (
m_sendCb (packet, source, dest, protocolNumber))
a polymophic address class
bool IsNull(void) const
Check for null implementation.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Network layer to device interface.
PacketType
Packet types are used as they are in Linux.
@ PACKET_OTHERHOST
Packet addressed to someone else.
virtual void DoDispose(void)
Destructor implementation.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
A virtual device, similar to Linux TUN/TAP interfaces.
virtual ~VirtualNetDevice()
Ptr< Node > m_node
Pointer to the node.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
Promisc Sniffer trace.
virtual Ptr< Channel > GetChannel(void) const
uint32_t m_index
Device index.
bool SetMtu(const uint16_t mtu)
Configure the reported MTU for the virtual device.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
TracedCallback< Ptr< const Packet > > m_macRxTrace
Rx trace.
void SetSupportsSendFrom(bool supportsSendFrom)
Configure whether the virtual device supports SendFrom.
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
virtual void SetAddress(Address address)
Set the address of this interface.
TracedCallback< Ptr< const Packet > > m_snifferTrace
Sniffer trace.
void SetNeedsArp(bool needsArp)
Configure whether the virtual device needs ARP.
virtual Ptr< Node > GetNode(void) const
virtual void SetIfIndex(const uint32_t index)
virtual Address GetBroadcast(void) const
bool m_needsArp
True if the device needs ARP.
virtual void DoDispose(void)
Destructor implementation.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetAddress(void) const
static TypeId GetTypeId(void)
Get the type ID.
virtual uint16_t GetMtu(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
Promisc Rx trace.
virtual bool IsBroadcast(void) const
bool m_supportsSendFrom
True if the device supports SendFrm.
virtual bool SupportsSendFrom() const
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
void SetIsPointToPoint(bool isPointToPoint)
Configure whether the virtual device is point-to-point.
virtual bool IsLinkUp(void) const
virtual bool IsMulticast(void) const
Address m_myAddress
MAC address.
virtual uint32_t GetIfIndex(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
PromiscReceiveCallback m_promiscRxCallback
Promisc Rx callback.
ReceiveCallback m_rxCallback
Rx callback.
virtual bool NeedsArp(void) const
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
virtual void SetNode(Ptr< Node > node)
bool m_isPointToPoint
True if the device is a PointToPoint type device.
SendCallback m_sendCb
send callback
TracedCallback< Ptr< const Packet > > m_macTxTrace
Tx trace.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.