|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #ifndef FD_NET_DEVICE_H
23 #define FD_NET_DEVICE_H
25 #include "ns3/address.h"
26 #include "ns3/callback.h"
27 #include "ns3/data-rate.h"
28 #include "ns3/event-id.h"
29 #include "ns3/mac48-address.h"
30 #include "ns3/net-device.h"
32 #include "ns3/packet.h"
34 #include "ns3/system-condition.h"
35 #include "ns3/traced-callback.h"
36 #include "ns3/unix-fd-reader.h"
37 #include "ns3/system-mutex.h"
154 virtual void SetIfIndex (
const uint32_t index);
159 virtual bool SetMtu (
const uint16_t mtu);
160 virtual uint16_t
GetMtu (
void)
const;
196 virtual ssize_t
Write (uint8_t *buffer,
size_t length);
a unique identifier for an interface.
virtual void DoFinishStartingDevice(void)
Complete additional actions, if any, to spin up down the device.
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsMulticast(void) const
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
int m_fd
The file descriptor used for receive/send network traffic.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
virtual uint32_t GetIfIndex(void) const
An identifier for simulation events.
FdReader::Data DoRead(void)
The read implementation.
uint32_t m_maxPendingReads
Maximum number of packets that can be received and scheduled for read but not yet read.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ForwardUp(void)
Forward the frame to the appropriate callback for processing.
virtual Address GetBroadcast(void) const
Time m_tStart
Time to start spinning up the device.
Ptr< Node > m_node
The ns-3 node associated to the net device.
void StartDevice(void)
Spin up the device.
void SetFileDescriptor(int fd)
Set the associated file descriptor.
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void DoDispose(void)
Destructor implementation.
A class which provides a relatively platform-independent Mutual Exclusion thread synchronization prim...
uint32_t m_ifIndex
The ns-3 interface index (in the sense of net device index) that has been assigned to this network de...
Ipv4 addresses are stored in host order in this class.
static TypeId GetTypeId(void)
Get the type ID.
Describes an IPv6 address.
FdNetDevice()
Constructor for the FdNetDevice.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
void SetEncapsulationMode(FdNetDevice::EncapsulationMode mode)
Set the link layer encapsulation mode of this device.
virtual Ptr< FdReader > DoCreateFdReader(void)
Create the FdReader object.
uint32_t m_bufferSize
size of the read buffer
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
std::queue< std::pair< uint8_t *, ssize_t > > m_pendingQueue
Number of packets that were received and scheduled for read but not yet read.
void Start(Time tStart)
Set a start time for the device.
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 d...
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
EncapsulationMode
Enumeration of the types of frames supported in the class.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
void StopDevice(void)
Tear down the device.
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
@ DIX
DIX II / Ethernet II packet.
int GetFileDescriptor(void) const
Get the associated file descriptor.
uint16_t m_mtu
The MTU associated to the file descriptor technology.
Ptr< FdReader > m_fdReader
Reader for the file descriptor.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
Mac48Address m_address
The net device mac address.
a polymophic address class
virtual void DoFinishStoppingDevice(void)
Complete additional actions, if any, to tear down the device.
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual void SetAddress(Address address)
Set the address of this interface.
virtual bool SupportsSendFrom() const
virtual Ptr< Node > GetNode(void) const
virtual void SetNode(Ptr< Node > node)
Simulation virtual time values and global simulation resolution.
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but which are dropped before b...
virtual bool IsLinkUp(void) const
virtual void SetIfIndex(const uint32_t index)
bool m_isMulticast
Flag indicating whether or not the underlying net device supports multicast.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
a NetDevice to read/write network traffic from/into a file descriptor.
FdNetDevice(FdNetDevice const &)
Copy constructor.
virtual bool IsBroadcast(void) const
SystemMutex m_pendingReadMutex
Mutex to increase pending read counter.
A class that asynchronously reads from a file descriptor.
virtual void SetIsBroadcast(bool broadcast)
Set if the NetDevice is able to send Broadcast messages.
virtual uint8_t * AllocateBuffer(size_t len)
Allocate packet buffer.
void SetBufferSize(uint32_t bufferSize)
Set size of the read buffer.
EventId m_stopEvent
NetDevice stop event.
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.
bool m_isBroadcast
Flag indicating whether or not the underlying net device supports broadcast.
virtual void DoInitialize(void)
Method Initialization for start and stop attributes.
@ DIXPI
When using TAP devices, if flag IFF_NO_PI is not set on the device, IP packets will have an extra hea...
virtual ssize_t Write(uint8_t *buffer, size_t length)
Write packet data to device.
FdNetDevice::EncapsulationMode GetEncapsulationMode(void) const
Get the link layer encapsulation mode of this device.
Forward calls to a chain of Callback.
virtual Ptr< Channel > GetChannel(void) const
virtual uint16_t GetMtu(void) const
EncapsulationMode m_encapMode
The type of encapsulation of the received/transmitted frames.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
TracedCallback m_linkChangeCallbacks
Callbacks to fire if the link changes state (up or down).
EventId m_startEvent
NetDevice start event.
virtual void FreeBuffer(uint8_t *buf)
Free the given packet buffer.
virtual ~FdNetDevice()
Destructor for the FdNetDevice.
Time m_tStop
Time to start tearing down the device.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
@ LLC
802.2 LLC/SNAP Packet
virtual Address GetAddress(void) const
virtual void SetIsMulticast(bool multicast)
Set if the NetDevice is able to send Multicast messages.
virtual bool NeedsArp(void) const
This class performs the actual data reading from the sockets.
void Stop(Time tStop)
Set a stop time for the device.
Network layer to device interface.
A structure representing data read.
bool m_linkUp
Flag indicating whether or not the link is up.
void NotifyLinkUp(void)
Notify that the link is up and ready.