A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::FdNetDevice Class Reference

a NetDevice to read/write network traffic from/into a file descriptor. More...

#include "fd-net-device.h"

+ Inheritance diagram for ns3::FdNetDevice:
+ Collaboration diagram for ns3::FdNetDevice:

Public Types

enum  EncapsulationMode { DIX , LLC , DIXPI }
 Enumeration of the types of frames supported in the class. More...
 
- Public Types inherited from ns3::NetDevice
typedef void(* LinkChangeTracedCallback) ()
 TracedCallback signature for link changed event.
 
enum  PacketType {
  PACKET_HOST = 1 , NS3_PACKET_HOST = PACKET_HOST , PACKET_BROADCAST , NS3_PACKET_BROADCAST = PACKET_BROADCAST ,
  PACKET_MULTICAST , NS3_PACKET_MULTICAST = PACKET_MULTICAST , PACKET_OTHERHOST , NS3_PACKET_OTHERHOST = PACKET_OTHERHOST
}
 Packet types are used as they are in Linux. More...
 
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketTypePromiscReceiveCallback
 
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
 

Public Member Functions

 FdNetDevice ()
 Constructor for the FdNetDevice.
 
 FdNetDevice (const FdNetDevice &)=delete
 
 ~FdNetDevice () override
 Destructor for the FdNetDevice.
 
void AddLinkChangeCallback (Callback< void > callback) override
 
Address GetAddress () const override
 
Address GetBroadcast () const override
 
Ptr< ChannelGetChannel () const override
 
FdNetDevice::EncapsulationMode GetEncapsulationMode () const
 Get the link layer encapsulation mode of this device.
 
uint32_t GetIfIndex () const override
 
uint16_t GetMtu () const override
 
Address GetMulticast (Ipv4Address multicastGroup) const override
 Make and return a MAC multicast address using the provided multicast group.
 
Address GetMulticast (Ipv6Address addr) const override
 Get the MAC multicast address corresponding to the IPv6 address provided.
 
Ptr< NodeGetNode () const override
 
bool IsBridge () const override
 Return true if the net device is acting as a bridge.
 
bool IsBroadcast () const override
 
bool IsLinkUp () const override
 
bool IsMulticast () const override
 
bool IsPointToPoint () const override
 Return true if the net device is on a point-to-point link.
 
bool NeedsArp () const override
 
bool Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
 
bool SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
 
void SetAddress (Address address) override
 Set the address of this interface.
 
void SetEncapsulationMode (FdNetDevice::EncapsulationMode mode)
 Set the link layer encapsulation mode of this device.
 
void SetFileDescriptor (int fd)
 Set the associated file descriptor.
 
void SetIfIndex (const uint32_t index) override
 
virtual void SetIsBroadcast (bool broadcast)
 Set if the NetDevice is able to send Broadcast messages.
 
virtual void SetIsMulticast (bool multicast)
 Set if the NetDevice is able to send Multicast messages.
 
bool SetMtu (const uint16_t mtu) override
 
void SetNode (Ptr< Node > node) override
 
void SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) override
 
void SetReceiveCallback (NetDevice::ReceiveCallback cb) override
 
void Start (Time tStart)
 Set a start time for the device.
 
void Stop (Time tStop)
 Set a stop time for the device.
 
bool SupportsSendFrom () const override
 
virtual ssize_t Write (uint8_t *buffer, size_t length)
 Write packet data to device.
 
- Public Member Functions inherited from ns3::NetDevice
 ~NetDevice () override
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::NetDevice
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Protected Member Functions

virtual uint8_t * AllocateBuffer (size_t len)
 Allocate packet buffer.
 
void DoDispose () override
 Destructor implementation.
 
void DoInitialize () override
 Method Initialization for start and stop attributes.
 
virtual void FreeBuffer (uint8_t *buf)
 Free the given packet buffer.
 
int GetFileDescriptor () const
 Get the associated file descriptor.
 
void ReceiveCallback (uint8_t *buf, ssize_t len)
 Callback to invoke when a new frame is received.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Protected Attributes

std::queue< std::pair< uint8_t *, ssize_t > > m_pendingQueue
 Number of packets that were received and scheduled for read but not yet read.
 
std::mutex m_pendingReadMutex
 Mutex to increase pending read counter.
 

Private Member Functions

virtual Ptr< FdReaderDoCreateFdReader ()
 Create the FdReader object.
 
virtual void DoFinishStartingDevice ()
 Complete additional actions, if any, to spin up down the device.
 
virtual void DoFinishStoppingDevice ()
 Complete additional actions, if any, to tear down the device.
 
void ForwardUp ()
 Forward the frame to the appropriate callback for processing.
 
void NotifyLinkUp ()
 Notify that the link is up and ready.
 
void StartDevice ()
 Spin up the device.
 
void StopDevice ()
 Tear down the device.
 
bool TransmitStart (Ptr< Packet > p)
 Start Sending a Packet Down the Wire.
 

Private Attributes

Mac48Address m_address
 The net device mac address.
 
EncapsulationMode m_encapMode
 The type of encapsulation of the received/transmitted frames.
 
int m_fd
 The file descriptor used for receive/send network traffic.
 
Ptr< FdReaderm_fdReader
 Reader for the file descriptor.
 
uint32_t m_ifIndex
 The ns-3 interface index (in the sense of net device index) that has been assigned to this network device.
 
bool m_isBroadcast
 Flag indicating whether or not the underlying net device supports broadcast.
 
bool m_isMulticast
 Flag indicating whether or not the underlying net device supports multicast.
 
TracedCallback m_linkChangeCallbacks
 Callbacks to fire if the link changes state (up or down).
 
bool m_linkUp
 Flag indicating whether or not the link is up.
 
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
 The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).
 
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
 The trace source fired for packets successfully received by the device but which are dropped before being forwarded up to higher layers (at the L2/L3 transition).
 
TracedCallback< Ptr< const Packet > > m_macRxTrace
 The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).
 
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
 The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are dropped before being queued for transmission.
 
TracedCallback< Ptr< const Packet > > m_macTxTrace
 The trace source fired when packets come into the "top" of the device at the L3/L2 transition, before being queued for transmission.
 
uint32_t m_maxPendingReads
 Maximum number of packets that can be received and scheduled for read but not yet read.
 
uint16_t m_mtu
 The MTU associated to the file descriptor technology.
 
Ptr< Nodem_node
 The ns-3 node associated to the net device.
 
uint32_t m_nodeId
 a copy of the node id so the read thread doesn't have to GetNode() in in order to find the node ID.
 
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
 The trace source fired when the phy layer drops a packet it has received.
 
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
 The trace source fired when the phy layer drops a packet as it tries to transmit it.
 
NetDevice::PromiscReceiveCallback m_promiscRxCallback
 The callback used to notify higher layers that a packet has been received in promiscuous mode.
 
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
 A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
 
NetDevice::ReceiveCallback m_rxCallback
 The callback used to notify higher layers that a packet has been received.
 
TracedCallback< Ptr< const Packet > > m_snifferTrace
 A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
 
EventId m_startEvent
 NetDevice start event.
 
EventId m_stopEvent
 NetDevice stop event.
 
Time m_tStart
 Time to start spinning up the device.
 
Time m_tStop
 Time to start tearing down the device.
 

Additional Inherited Members

Detailed Description

a NetDevice to read/write network traffic from/into a file descriptor.

A FdNetDevice object will read and write frames/packets from/to a file descriptor. This file descriptor might be associated to a Linux TAP/TUN device, to a socket or to a user space process, allowing the simulation to exchange traffic with the "outside-world"

Config Paths

ns3::FdNetDevice is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/DeviceList/[i]/$ns3::FdNetDevice"

Attributes

  • Address: The MAC address of this device.
  • EncapsulationMode: The link-layer encapsulation type to use.
  • RxQueueSize: Maximum size of the read queue. This value limits number of packets that have been read from the network into a memory buffer but have not yet been processed by the simulator.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 1000
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • Start: The simulation time at which to spin up the device thread.
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • Stop: The simulation time at which to tear down the device thread.
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
    • Support level: SUPPORTED

TraceSources

  • MacPromiscRx: A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack. This is a promiscuous trace,
  • MacRx: A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack. This is a non-promiscuous trace,
  • MacTx: Trace source indicating a packet has arrived for transmission by this device
  • MacTxDrop: Trace source indicating a packet has been dropped by the device before transmission
  • PromiscSniffer: Trace source simulating a promiscuous packet sniffer attached to the device
  • Sniffer: Trace source simulating a non-promiscuous packet sniffer attached to the device

Group: FdNetDevice

Size of this type is 552 bytes (on a 64-bit architecture).

Definition at line 72 of file fd-net-device.h.

Member Enumeration Documentation

◆ EncapsulationMode

Enumeration of the types of frames supported in the class.

Enumerator
DIX 

DIX II / Ethernet II packet.

LLC 

802.2 LLC/SNAP Packet

DIXPI 

When using TAP devices, if flag IFF_NO_PI is not set on the device, IP packets will have an extra header: Flags [2 bytes] Proto [2 bytes] Raw protocol(IP, IPv6, etc) frame.

Definition at line 84 of file fd-net-device.h.

Constructor & Destructor Documentation

◆ FdNetDevice() [1/2]

ns3::FdNetDevice::FdNetDevice ( )

Constructor for the FdNetDevice.

Definition at line 157 of file fd-net-device.cc.

References NS_LOG_FUNCTION.

◆ ~FdNetDevice()

ns3::FdNetDevice::~FdNetDevice ( )
override

Destructor for the FdNetDevice.

Definition at line 172 of file fd-net-device.cc.

References NS_LOG_FUNCTION.

◆ FdNetDevice() [2/2]

ns3::FdNetDevice::FdNetDevice ( const FdNetDevice & )
delete

Member Function Documentation

◆ AddLinkChangeCallback()

void ns3::FdNetDevice::AddLinkChangeCallback ( Callback< void > callback)
overridevirtual
Parameters
callbackthe callback to invoke

Add a callback invoked whenever the link status changes to UP. This callback is typically used by the IP/ARP layer to flush the ARP cache and by IPv6 stack to flush NDISC cache whenever the link goes up.

Implements ns3::NetDevice.

Definition at line 724 of file fd-net-device.cc.

References ns3::TracedCallback< Ts >::ConnectWithoutContext(), and m_linkChangeCallbacks.

+ Here is the call graph for this function:

◆ AllocateBuffer()

uint8_t * ns3::FdNetDevice::AllocateBuffer ( size_t len)
protectedvirtual

Allocate packet buffer.

Parameters
lenthe length of the buffer
Returns
A pointer to the newly allocated buffer.

Reimplemented in ns3::DpdkNetDevice.

Definition at line 393 of file fd-net-device.cc.

Referenced by SendFrom().

+ Here is the caller graph for this function:

◆ DoCreateFdReader()

Ptr< FdReader > ns3::FdNetDevice::DoCreateFdReader ( )
privatevirtual

Create the FdReader object.

Returns
the created FdReader object

Reimplemented in ns3::NetmapNetDevice.

Definition at line 249 of file fd-net-device.cc.

References ns3::Create(), m_mtu, and NS_LOG_FUNCTION.

Referenced by StartDevice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoDispose()

void ns3::FdNetDevice::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 191 of file fd-net-device.cc.

References ns3::Object::DoDispose(), NS_LOG_FUNCTION, and StopDevice().

+ Here is the call graph for this function:

◆ DoFinishStartingDevice()

void ns3::FdNetDevice::DoFinishStartingDevice ( )
privatevirtual

Complete additional actions, if any, to spin up down the device.

Reimplemented in ns3::NetmapNetDevice.

Definition at line 260 of file fd-net-device.cc.

References NS_LOG_FUNCTION.

Referenced by StartDevice().

+ Here is the caller graph for this function:

◆ DoFinishStoppingDevice()

void ns3::FdNetDevice::DoFinishStoppingDevice ( )
privatevirtual

Complete additional actions, if any, to tear down the device.

Reimplemented in ns3::DpdkNetDevice, and ns3::NetmapNetDevice.

Definition at line 266 of file fd-net-device.cc.

References NS_LOG_FUNCTION.

Referenced by StopDevice().

+ Here is the caller graph for this function:

◆ DoInitialize()

void ns3::FdNetDevice::DoInitialize ( )
overrideprotectedvirtual

Method Initialization for start and stop attributes.

Reimplemented from ns3::Object.

Definition at line 178 of file fd-net-device.cc.

References ns3::Object::DoInitialize(), ns3::Time::IsZero(), m_tStart, m_tStop, NS_LOG_FUNCTION, Start(), and Stop().

+ Here is the call graph for this function:

◆ ForwardUp()

void ns3::FdNetDevice::ForwardUp ( )
private

◆ FreeBuffer()

void ns3::FdNetDevice::FreeBuffer ( uint8_t * buf)
protectedvirtual

Free the given packet buffer.

Parameters
bufthe buffer to free

Reimplemented in ns3::DpdkNetDevice.

Definition at line 399 of file fd-net-device.cc.

Referenced by ForwardUp(), SendFrom(), and StopDevice().

+ Here is the caller graph for this function:

◆ GetAddress()

Address ns3::FdNetDevice::GetAddress ( ) const
overridevirtual
Returns
the current Address of this interface.

Implements ns3::NetDevice.

Definition at line 668 of file fd-net-device.cc.

References m_address.

◆ GetBroadcast()

Address ns3::FdNetDevice::GetBroadcast ( ) const
overridevirtual
Returns
the broadcast address supported by this netdevice.

Calling this method is invalid if IsBroadcast returns not true.

Implements ns3::NetDevice.

Definition at line 742 of file fd-net-device.cc.

References ns3::Mac48Address::GetBroadcast().

+ Here is the call graph for this function:

◆ GetChannel()

Ptr< Channel > ns3::FdNetDevice::GetChannel ( ) const
overridevirtual
Returns
the channel this NetDevice is connected to. The value returned can be zero if the NetDevice is not yet connected to any channel or if the underlying NetDevice has no concept of a channel. i.e., callers must check for zero and be ready to handle it.

Implements ns3::NetDevice.

Definition at line 693 of file fd-net-device.cc.

◆ GetEncapsulationMode()

FdNetDevice::EncapsulationMode ns3::FdNetDevice::GetEncapsulationMode ( ) const

Get the link layer encapsulation mode of this device.

Returns
The link layer encapsulation mode of this device.

Definition at line 207 of file fd-net-device.cc.

References m_encapMode, and NS_LOG_FUNCTION.

◆ GetFileDescriptor()

int ns3::FdNetDevice::GetFileDescriptor ( ) const
protected

Get the associated file descriptor.

Returns
the associated file descriptor

Definition at line 656 of file fd-net-device.cc.

References m_fd.

Referenced by ns3::NetmapNetDevice::SyncAndNotifyQueue().

+ Here is the caller graph for this function:

◆ GetIfIndex()

uint32_t ns3::FdNetDevice::GetIfIndex ( ) const
overridevirtual
Returns
index ifIndex of the device

Implements ns3::NetDevice.

Definition at line 687 of file fd-net-device.cc.

References m_ifIndex.

◆ GetMtu()

uint16_t ns3::FdNetDevice::GetMtu ( ) const
overridevirtual
Returns
the link-level MTU in bytes for this interface.

This value is typically used by the IP layer to perform IP fragmentation when needed.

Implements ns3::NetDevice.

Definition at line 712 of file fd-net-device.cc.

References m_mtu.

Referenced by ns3::NetmapNetDevice::DoCreateFdReader().

+ Here is the caller graph for this function:

◆ GetMulticast() [1/2]

Address ns3::FdNetDevice::GetMulticast ( Ipv4Address multicastGroup) const
overridevirtual

Make and return a MAC multicast address using the provided multicast group.

RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet multicast address by placing the low-order 23-bits of the IP address into the low-order 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex). Similar RFCs exist for Ipv6 and Eui64 mappings. This method performs the multicast address creation function appropriate to the underlying MAC address of the device. This MAC address is encapsulated in an abstract Address to avoid dependencies on the exact MAC address format.

In the case of net devices that do not support multicast, clients are expected to test NetDevice::IsMulticast and avoid attempting to map multicast packets. Subclasses of NetDevice that do support multicasting are expected to override this method and provide an implementation appropriate to the particular device.

Parameters
multicastGroupThe IP address for the multicast group destination of the packet.
Returns
The MAC multicast Address used to send packets to the provided multicast group.
Warning
Calling this method is invalid if IsMulticast returns not true.
See also
IsMulticast()

Implements ns3::NetDevice.

Definition at line 760 of file fd-net-device.cc.

References ns3::Mac48Address::GetMulticast().

+ Here is the call graph for this function:

◆ GetMulticast() [2/2]

Address ns3::FdNetDevice::GetMulticast ( Ipv6Address addr) const
overridevirtual

Get the MAC multicast address corresponding to the IPv6 address provided.

Parameters
addrIPv6 address
Returns
the MAC multicast address
Warning
Calling this method is invalid if IsMulticast returns not true.

Implements ns3::NetDevice.

Definition at line 766 of file fd-net-device.cc.

References ns3::Mac48Address::GetMulticast().

+ Here is the call graph for this function:

◆ GetNode()

Ptr< Node > ns3::FdNetDevice::GetNode ( ) const
overridevirtual
Returns
the node base class which contains this network interface.

When a subclass needs to get access to the underlying node base class to print the nodeid for example, it can invoke this method.

Implements ns3::NetDevice.

Definition at line 784 of file fd-net-device.cc.

References m_node.

◆ GetTypeId()

TypeId ns3::FdNetDevice::GetTypeId ( )
static

◆ IsBridge()

bool ns3::FdNetDevice::IsBridge ( ) const
overridevirtual

Return true if the net device is acting as a bridge.

Returns
value of m_isBridge flag

Implements ns3::NetDevice.

Definition at line 772 of file fd-net-device.cc.

◆ IsBroadcast()

bool ns3::FdNetDevice::IsBroadcast ( ) const
overridevirtual
Returns
true if this interface supports a broadcast address, false otherwise.

Implements ns3::NetDevice.

Definition at line 730 of file fd-net-device.cc.

References m_isBroadcast.

◆ IsLinkUp()

bool ns3::FdNetDevice::IsLinkUp ( ) const
overridevirtual
Returns
true if link is up; false otherwise

Implements ns3::NetDevice.

Definition at line 718 of file fd-net-device.cc.

References m_linkUp.

Referenced by SendFrom().

+ Here is the caller graph for this function:

◆ IsMulticast()

bool ns3::FdNetDevice::IsMulticast ( ) const
overridevirtual
Returns
value of m_isMulticast flag

Implements ns3::NetDevice.

Definition at line 748 of file fd-net-device.cc.

References m_isMulticast.

◆ IsPointToPoint()

bool ns3::FdNetDevice::IsPointToPoint ( ) const
overridevirtual

Return true if the net device is on a point-to-point link.

Returns
value of m_isPointToPoint flag

Implements ns3::NetDevice.

Definition at line 778 of file fd-net-device.cc.

◆ NeedsArp()

bool ns3::FdNetDevice::NeedsArp ( ) const
overridevirtual
Returns
true if ARP is needed, false otherwise.

Called by higher-layers to check if this NetDevice requires ARP to be used.

Implements ns3::NetDevice.

Definition at line 801 of file fd-net-device.cc.

◆ NotifyLinkUp()

void ns3::FdNetDevice::NotifyLinkUp ( )
private

Notify that the link is up and ready.

Definition at line 674 of file fd-net-device.cc.

References m_linkChangeCallbacks, and m_linkUp.

Referenced by StartDevice().

+ Here is the caller graph for this function:

◆ ReceiveCallback()

void ns3::FdNetDevice::ReceiveCallback ( uint8_t * buf,
ssize_t len )
protected

Callback to invoke when a new frame is received.

Parameters
bufa buffer containing the received frame
lenthe length of the frame

Definition at line 299 of file fd-net-device.cc.

References ForwardUp(), m_maxPendingReads, m_nodeId, m_pendingQueue, m_pendingReadMutex, ns3::MakeEvent(), NS_LOG_FUNCTION, NS_LOG_WARN, and ns3::Simulator::ScheduleWithContext().

+ Here is the call graph for this function:

◆ Send()

bool ns3::FdNetDevice::Send ( Ptr< Packet > packet,
const Address & dest,
uint16_t protocolNumber )
overridevirtual
Parameters
packetpacket sent from above down to Network Device
destmac address of the destination (already resolved)
protocolNumberidentifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received.

Called from higher layer to send packet into Network Device to the specified destination Address

Returns
whether the Send operation succeeded

Implements ns3::NetDevice.

Definition at line 547 of file fd-net-device.cc.

References m_address, NS_LOG_FUNCTION, and SendFrom().

+ Here is the call graph for this function:

◆ SendFrom()

bool ns3::FdNetDevice::SendFrom ( Ptr< Packet > packet,
const Address & source,
const Address & dest,
uint16_t protocolNumber )
overridevirtual
Parameters
packetpacket sent from above down to Network Device
sourcesource mac address (so called "MAC spoofing")
destmac address of the destination (already resolved)
protocolNumberidentifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received.

Called from higher layer to send packet into Network Device with the specified source and destination Addresses.

Returns
whether the Send operation succeeded

Implements ns3::NetDevice.

Definition at line 554 of file fd-net-device.cc.

References ns3::AddPIHeader(), AllocateBuffer(), ns3::Mac48Address::ConvertFrom(), DIXPI, FreeBuffer(), IsLinkUp(), LLC, m_encapMode, m_macTxDropTrace, m_macTxTrace, m_mtu, m_promiscSnifferTrace, m_snifferTrace, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), ns3::EthernetHeader::SetSource(), ns3::LlcSnapHeader::SetType(), and Write().

Referenced by Send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetAddress()

void ns3::FdNetDevice::SetAddress ( Address address)
overridevirtual

Set the address of this interface.

Parameters
addressaddress to set

Implements ns3::NetDevice.

Definition at line 662 of file fd-net-device.cc.

References ns3::Mac48Address::ConvertFrom(), and m_address.

+ Here is the call graph for this function:

◆ SetEncapsulationMode()

void ns3::FdNetDevice::SetEncapsulationMode ( FdNetDevice::EncapsulationMode mode)

Set the link layer encapsulation mode of this device.

Parameters
modeThe link layer encapsulation mode of this device.

Definition at line 199 of file fd-net-device.cc.

References m_encapMode, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

◆ SetFileDescriptor()

void ns3::FdNetDevice::SetFileDescriptor ( int fd)

Set the associated file descriptor.

Parameters
fdthe file descriptor

Definition at line 647 of file fd-net-device.cc.

References m_fd.

◆ SetIfIndex()

void ns3::FdNetDevice::SetIfIndex ( const uint32_t index)
overridevirtual
Parameters
indexifIndex of the device

Implements ns3::NetDevice.

Definition at line 681 of file fd-net-device.cc.

References m_ifIndex.

◆ SetIsBroadcast()

void ns3::FdNetDevice::SetIsBroadcast ( bool broadcast)
virtual

Set if the NetDevice is able to send Broadcast messages.

Parameters
broadcasttrue if the NetDevice can send Broadcast

Definition at line 736 of file fd-net-device.cc.

References m_isBroadcast.

◆ SetIsMulticast()

void ns3::FdNetDevice::SetIsMulticast ( bool multicast)
virtual

Set if the NetDevice is able to send Multicast messages.

Parameters
multicasttrue if the NetDevice can send Multicast

Definition at line 754 of file fd-net-device.cc.

References m_isMulticast.

◆ SetMtu()

bool ns3::FdNetDevice::SetMtu ( const uint16_t mtu)
overridevirtual
Parameters
mtuMTU value, in bytes, to set for the device
Returns
whether the MTU value was within legal bounds

Override for default MTU defined on a per-type basis.

Implements ns3::NetDevice.

Definition at line 699 of file fd-net-device.cc.

References m_mtu.

◆ SetNode()

void ns3::FdNetDevice::SetNode ( Ptr< Node > node)
overridevirtual
Parameters
nodethe node associated to this netdevice.

This method is called from ns3::Node::AddDevice.

Implements ns3::NetDevice.

Definition at line 790 of file fd-net-device.cc.

References m_node, and m_nodeId.

◆ SetPromiscReceiveCallback()

void ns3::FdNetDevice::SetPromiscReceiveCallback ( NetDevice::PromiscReceiveCallback cb)
overridevirtual
Parameters
cbcallback to invoke whenever a packet has been received in promiscuous mode and must be forwarded to the higher layers.

Enables netdevice promiscuous mode and sets the callback that will handle promiscuous mode packets. Note, promiscuous mode packets means all packets, including those packets that can be sensed by the netdevice but which are intended to be received by other hosts.

Implements ns3::NetDevice.

Definition at line 813 of file fd-net-device.cc.

References m_promiscRxCallback.

◆ SetReceiveCallback()

void ns3::FdNetDevice::SetReceiveCallback ( NetDevice::ReceiveCallback cb)
overridevirtual
Parameters
cbcallback to invoke whenever a packet has been received and must be forwarded to the higher layers.

Set the callback to be used to notify higher layers when a packet has been received.

Implements ns3::NetDevice.

Definition at line 807 of file fd-net-device.cc.

References m_rxCallback.

◆ Start()

void ns3::FdNetDevice::Start ( Time tStart)

Set a start time for the device.

Parameters
tStartthe start time

Definition at line 214 of file fd-net-device.cc.

References ns3::Simulator::Cancel(), m_startEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartDevice().

Referenced by DoInitialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartDevice()

void ns3::FdNetDevice::StartDevice ( )
private

Spin up the device.

Definition at line 230 of file fd-net-device.cc.

References DoCreateFdReader(), DoFinishStartingDevice(), m_fd, m_fdReader, ns3::MakeCallback(), NotifyLinkUp(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by Start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Stop()

void ns3::FdNetDevice::Stop ( Time tStop)

Set a stop time for the device.

Parameters
tStopthe stop time

Definition at line 222 of file fd-net-device.cc.

References ns3::Simulator::Cancel(), m_stopEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StopDevice().

Referenced by DoInitialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StopDevice()

void ns3::FdNetDevice::StopDevice ( )
private

Tear down the device.

Definition at line 272 of file fd-net-device.cc.

References DoFinishStoppingDevice(), FreeBuffer(), m_fd, m_fdReader, m_pendingQueue, and NS_LOG_FUNCTION.

Referenced by DoDispose(), and Stop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SupportsSendFrom()

bool ns3::FdNetDevice::SupportsSendFrom ( ) const
overridevirtual
Returns
true if this interface supports a bridging mode, false otherwise.

Implements ns3::NetDevice.

Definition at line 819 of file fd-net-device.cc.

◆ TransmitStart()

bool ns3::FdNetDevice::TransmitStart ( Ptr< Packet > p)
private

Start Sending a Packet Down the Wire.

Parameters
ppacket to send
Returns
true if success, false on failure

◆ Write()

ssize_t ns3::FdNetDevice::Write ( uint8_t * buffer,
size_t length )
virtual

Write packet data to device.

Parameters
bufferThe data.
lengthThe data length.
Returns
The size of data written.

Reimplemented in ns3::DpdkNetDevice, and ns3::NetmapNetDevice.

Definition at line 638 of file fd-net-device.cc.

References m_fd, and NS_LOG_FUNCTION.

Referenced by SendFrom().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_address

Mac48Address ns3::FdNetDevice::m_address
private

The net device mac address.

Definition at line 316 of file fd-net-device.h.

Referenced by ForwardUp(), GetAddress(), GetTypeId(), Send(), and SetAddress().

◆ m_encapMode

EncapsulationMode ns3::FdNetDevice::m_encapMode
private

The type of encapsulation of the received/transmitted frames.

Definition at line 321 of file fd-net-device.h.

Referenced by ForwardUp(), GetEncapsulationMode(), GetTypeId(), SendFrom(), and SetEncapsulationMode().

◆ m_fd

int ns3::FdNetDevice::m_fd
private

The file descriptor used for receive/send network traffic.

Definition at line 306 of file fd-net-device.h.

Referenced by GetFileDescriptor(), SetFileDescriptor(), StartDevice(), StopDevice(), and Write().

◆ m_fdReader

Ptr<FdReader> ns3::FdNetDevice::m_fdReader
private

Reader for the file descriptor.

Definition at line 311 of file fd-net-device.h.

Referenced by StartDevice(), and StopDevice().

◆ m_ifIndex

uint32_t ns3::FdNetDevice::m_ifIndex
private

The ns-3 interface index (in the sense of net device index) that has been assigned to this network device.

Definition at line 296 of file fd-net-device.h.

Referenced by GetIfIndex(), and SetIfIndex().

◆ m_isBroadcast

bool ns3::FdNetDevice::m_isBroadcast
private

Flag indicating whether or not the underlying net device supports broadcast.

Definition at line 338 of file fd-net-device.h.

Referenced by IsBroadcast(), and SetIsBroadcast().

◆ m_isMulticast

bool ns3::FdNetDevice::m_isMulticast
private

Flag indicating whether or not the underlying net device supports multicast.

Definition at line 344 of file fd-net-device.h.

Referenced by IsMulticast(), and SetIsMulticast().

◆ m_linkChangeCallbacks

TracedCallback ns3::FdNetDevice::m_linkChangeCallbacks
private

Callbacks to fire if the link changes state (up or down).

Definition at line 332 of file fd-net-device.h.

Referenced by AddLinkChangeCallback(), and NotifyLinkUp().

◆ m_linkUp

bool ns3::FdNetDevice::m_linkUp
private

Flag indicating whether or not the link is up.

In this case, whether or not the device is connected to a channel.

Definition at line 327 of file fd-net-device.h.

Referenced by IsLinkUp(), and NotifyLinkUp().

◆ m_macPromiscRxTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_macPromiscRxTrace
private

The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).

This is a promiscuous trace.

See also
class CallBackTraceSource

Definition at line 404 of file fd-net-device.h.

Referenced by ForwardUp(), and GetTypeId().

◆ m_macRxDropTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_macRxDropTrace
private

The trace source fired for packets successfully received by the device but which are dropped before being forwarded up to higher layers (at the L2/L3 transition).

See also
class CallBackTraceSource

Definition at line 422 of file fd-net-device.h.

◆ m_macRxTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_macRxTrace
private

The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).

This is a non-promiscuous trace.

See also
class CallBackTraceSource

Definition at line 413 of file fd-net-device.h.

Referenced by ForwardUp(), and GetTypeId().

◆ m_macTxDropTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_macTxDropTrace
private

The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are dropped before being queued for transmission.

See also
class CallBackTraceSource

Definition at line 395 of file fd-net-device.h.

Referenced by GetTypeId(), and SendFrom().

◆ m_macTxTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_macTxTrace
private

The trace source fired when packets come into the "top" of the device at the L3/L2 transition, before being queued for transmission.

See also
class CallBackTraceSource

Definition at line 387 of file fd-net-device.h.

Referenced by GetTypeId(), and SendFrom().

◆ m_maxPendingReads

uint32_t ns3::FdNetDevice::m_maxPendingReads
private

Maximum number of packets that can be received and scheduled for read but not yet read.

Definition at line 349 of file fd-net-device.h.

Referenced by GetTypeId(), and ReceiveCallback().

◆ m_mtu

uint16_t ns3::FdNetDevice::m_mtu
private

The MTU associated to the file descriptor technology.

Definition at line 301 of file fd-net-device.h.

Referenced by DoCreateFdReader(), GetMtu(), SendFrom(), and SetMtu().

◆ m_node

Ptr<Node> ns3::FdNetDevice::m_node
private

The ns-3 node associated to the net device.

Definition at line 283 of file fd-net-device.h.

Referenced by GetNode(), and SetNode().

◆ m_nodeId

uint32_t ns3::FdNetDevice::m_nodeId
private

a copy of the node id so the read thread doesn't have to GetNode() in in order to find the node ID.

Thread unsafe reference counting in multithreaded apps is not a good thing.

Definition at line 290 of file fd-net-device.h.

Referenced by ReceiveCallback(), and SetNode().

◆ m_pendingQueue

std::queue<std::pair<uint8_t*, ssize_t> > ns3::FdNetDevice::m_pendingQueue
protected

Number of packets that were received and scheduled for read but not yet read.

Definition at line 234 of file fd-net-device.h.

Referenced by ns3::DpdkNetDevice::DoFinishStoppingDevice(), ForwardUp(), ReceiveCallback(), and StopDevice().

◆ m_pendingReadMutex

std::mutex ns3::FdNetDevice::m_pendingReadMutex
protected

Mutex to increase pending read counter.

Definition at line 229 of file fd-net-device.h.

Referenced by ns3::DpdkNetDevice::DoFinishStoppingDevice(), ForwardUp(), and ReceiveCallback().

◆ m_phyRxDropTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_phyRxDropTrace
private

The trace source fired when the phy layer drops a packet it has received.

See also
class CallBackTraceSource

Definition at line 439 of file fd-net-device.h.

Referenced by ForwardUp().

◆ m_phyTxDropTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_phyTxDropTrace
private

The trace source fired when the phy layer drops a packet as it tries to transmit it.

Todo
Remove: this TracedCallback is never invoked.
See also
class CallBackTraceSource

Definition at line 432 of file fd-net-device.h.

◆ m_promiscRxCallback

NetDevice::PromiscReceiveCallback ns3::FdNetDevice::m_promiscRxCallback
private

The callback used to notify higher layers that a packet has been received in promiscuous mode.

Definition at line 379 of file fd-net-device.h.

Referenced by ForwardUp(), and SetPromiscReceiveCallback().

◆ m_promiscSnifferTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_promiscSnifferTrace
private

A trace source that emulates a promiscuous mode protocol sniffer connected to the device.

This trace source fire on packets destined for any host just like your average everyday packet sniffer.

On the transmit size, this trace hook will fire after a packet is dequeued from the device queue for transmission. In Linux, for example, this would correspond to the point just before a device hard_start_xmit where dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET ETH_P_ALL handlers.

On the receive side, this trace hook will fire when a packet is received, just before the receive callback is executed. In Linux, for example, this would correspond to the point at which the packet is dispatched to packet sniffers in netif_receive_skb.

See also
class CallBackTraceSource

Definition at line 479 of file fd-net-device.h.

Referenced by ForwardUp(), GetTypeId(), and SendFrom().

◆ m_rxCallback

NetDevice::ReceiveCallback ns3::FdNetDevice::m_rxCallback
private

The callback used to notify higher layers that a packet has been received.

Definition at line 373 of file fd-net-device.h.

Referenced by ForwardUp(), and SetReceiveCallback().

◆ m_snifferTrace

TracedCallback<Ptr<const Packet> > ns3::FdNetDevice::m_snifferTrace
private

A trace source that emulates a non-promiscuous protocol sniffer connected to the device.

Unlike your average everyday sniffer, this trace source will not fire on PACKET_OTHERHOST events.

On the transmit size, this trace hook will fire after a packet is dequeued from the device queue for transmission. In Linux, for example, this would correspond to the point just before a device hard_start_xmit where dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET ETH_P_ALL handlers.

On the receive side, this trace hook will fire when a packet is received, just before the receive callback is executed. In Linux, for example, this would correspond to the point at which the packet is dispatched to packet sniffers in netif_receive_skb.

See also
class CallBackTraceSource

Definition at line 459 of file fd-net-device.h.

Referenced by ForwardUp(), GetTypeId(), and SendFrom().

◆ m_startEvent

EventId ns3::FdNetDevice::m_startEvent
private

NetDevice start event.

Definition at line 364 of file fd-net-device.h.

Referenced by Start().

◆ m_stopEvent

EventId ns3::FdNetDevice::m_stopEvent
private

NetDevice stop event.

Definition at line 368 of file fd-net-device.h.

Referenced by Stop().

◆ m_tStart

Time ns3::FdNetDevice::m_tStart
private

Time to start spinning up the device.

Definition at line 354 of file fd-net-device.h.

Referenced by DoInitialize(), and GetTypeId().

◆ m_tStop

Time ns3::FdNetDevice::m_tStop
private

Time to start tearing down the device.

Definition at line 359 of file fd-net-device.h.

Referenced by DoInitialize(), and GetTypeId().


The documentation for this class was generated from the following files: