22 #include "ns3/channel.h"
23 #include "ns3/error-model.h"
24 #include "ns3/llc-snap-header.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/simulator.h"
28 #include "ns3/trace-source-accessor.h"
29 #include "ns3/uinteger.h"
42 TypeId(
"ns3::VirtualNetDevice")
44 .SetGroupName(
"VirtualNetDevice")
48 "The MAC-level Maximum Transmission Unit",
51 MakeUintegerChecker<uint16_t>())
52 .AddTraceSource(
"MacTx",
53 "Trace source indicating a packet has arrived "
54 "for transmission by this device",
56 "ns3::Packet::TracedCallback")
57 .AddTraceSource(
"MacPromiscRx",
58 "A packet has been received by this device, "
59 "has been passed up from the physical layer "
60 "and is being forwarded up the local protocol stack. "
61 "This is a promiscuous trace,",
63 "ns3::Packet::TracedCallback")
64 .AddTraceSource(
"MacRx",
65 "A packet has been received by this device, "
66 "has been passed up from the physical layer "
67 "and is being forwarded up the local protocol stack. "
68 "This is a non-promiscuous trace,",
70 "ns3::Packet::TracedCallback")
74 .AddTraceSource(
"Sniffer",
75 "Trace source simulating a non-promiscuous "
76 "packet sniffer attached to the device",
78 "ns3::Packet::TracedCallback")
79 .AddTraceSource(
"PromiscSniffer",
80 "Trace source simulating a promiscuous "
81 "packet sniffer attached to the device",
83 "ns3::Packet::TracedCallback");
265 uint16_t protocolNumber)
269 return m_sendCb(packet, source, dest, protocolNumber);
a polymophic address class
bool IsNull() 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()
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.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
static TypeId GetTypeId()
Get the type ID.
Ptr< Node > m_node
Pointer to the node.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
Promisc Sniffer trace.
uint32_t GetIfIndex() const override
bool SetMtu(const uint16_t mtu) override
Configure the reported MTU for the virtual device.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
Address GetAddress() const override
uint32_t m_index
Device index.
bool SupportsSendFrom() const override
bool IsMulticast() const override
bool IsLinkUp() const override
void SetAddress(Address address) override
Set the address of this interface.
void AddLinkChangeCallback(Callback< void > callback) override
TracedCallback< Ptr< const Packet > > m_macRxTrace
Rx trace.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetSupportsSendFrom(bool supportsSendFrom)
Configure whether the virtual device supports SendFrom.
void SetNode(Ptr< Node > node) override
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
TracedCallback< Ptr< const Packet > > m_snifferTrace
Sniffer trace.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void SetNeedsArp(bool needsArp)
Configure whether the virtual device needs ARP.
bool NeedsArp() const override
void DoDispose() override
Destructor implementation.
Ptr< Channel > GetChannel() const override
~VirtualNetDevice() override
bool m_needsArp
True if the device needs ARP.
bool IsBroadcast() const override
void SetIfIndex(const uint32_t index) override
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
Promisc Rx trace.
bool m_supportsSendFrom
True if the device supports SendFrm.
void SetIsPointToPoint(bool isPointToPoint)
Configure whether the virtual device is point-to-point.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Ptr< Node > GetNode() const override
Address GetBroadcast() const override
Address m_myAddress
MAC address.
uint16_t GetMtu() const override
PromiscReceiveCallback m_promiscRxCallback
Promisc Rx callback.
ReceiveCallback m_rxCallback
Rx callback.
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
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.
void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb) override
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)