a NetDevice to read/write network traffic from/into a file descriptor. More...
#include "fd-net-device.h"
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) (void) |
TracedCallback signature for link changed event. More... | |
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 &, enum PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Public Member Functions | |
FdNetDevice () | |
Constructor for the FdNetDevice. More... | |
FdNetDevice (FdNetDevice const &)=delete | |
virtual | ~FdNetDevice () |
Destructor for the FdNetDevice. More... | |
virtual void | AddLinkChangeCallback (Callback< void > callback) |
virtual Address | GetAddress (void) const |
virtual Address | GetBroadcast (void) const |
virtual Ptr< Channel > | GetChannel (void) const |
FdNetDevice::EncapsulationMode | GetEncapsulationMode (void) const |
Get the link layer encapsulation mode of this device. More... | |
virtual uint32_t | GetIfIndex (void) const |
virtual uint16_t | GetMtu (void) const |
virtual Address | GetMulticast (Ipv4Address multicastGroup) const |
Make and return a MAC multicast address using the provided multicast group. More... | |
virtual Address | GetMulticast (Ipv6Address addr) const |
Get the MAC multicast address corresponding to the IPv6 address provided. More... | |
virtual Ptr< Node > | GetNode (void) const |
virtual bool | IsBridge (void) const |
Return true if the net device is acting as a bridge. More... | |
virtual bool | IsBroadcast (void) const |
virtual bool | IsLinkUp (void) const |
virtual bool | IsMulticast (void) const |
virtual bool | IsPointToPoint (void) const |
Return true if the net device is on a point-to-point link. More... | |
virtual bool | NeedsArp (void) const |
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) |
virtual void | SetAddress (Address address) |
Set the address of this interface. More... | |
void | SetEncapsulationMode (FdNetDevice::EncapsulationMode mode) |
Set the link layer encapsulation mode of this device. More... | |
void | SetFileDescriptor (int fd) |
Set the associated file descriptor. More... | |
virtual void | SetIfIndex (const uint32_t index) |
virtual void | SetIsBroadcast (bool broadcast) |
Set if the NetDevice is able to send Broadcast messages. More... | |
virtual void | SetIsMulticast (bool multicast) |
Set if the NetDevice is able to send Multicast messages. More... | |
virtual bool | SetMtu (const uint16_t mtu) |
virtual void | SetNode (Ptr< Node > node) |
virtual void | SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) |
virtual void | SetReceiveCallback (NetDevice::ReceiveCallback cb) |
void | Start (Time tStart) |
Set a start time for the device. More... | |
void | Stop (Time tStop) |
Set a stop time for the device. More... | |
virtual bool | SupportsSendFrom () const |
virtual ssize_t | Write (uint8_t *buffer, size_t length) |
Write packet data to device. More... | |
Public Member Functions inherited from ns3::NetDevice | |
virtual | ~NetDevice () |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose (void) |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator (void) const |
Get an iterator to the Objects aggregated to this one. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
Get the most derived TypeId for this Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (void) const |
Get a pointer to the requested aggregated Object. More... | |
void | Initialize (void) |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized (void) const |
Check if the object has been initialized. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= ([[maybe_unused]] const SimpleRefCount &o) |
Assignment operator. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising erros. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::NetDevice | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
virtual uint8_t * | AllocateBuffer (size_t len) |
Allocate packet buffer. More... | |
virtual void | DoDispose (void) |
Destructor implementation. More... | |
virtual void | DoInitialize (void) |
Method Initialization for start and stop attributes. More... | |
virtual void | FreeBuffer (uint8_t *buf) |
Free the given packet buffer. More... | |
int | GetFileDescriptor (void) const |
Get the associated file descriptor. More... | |
void | ReceiveCallback (uint8_t *buf, ssize_t len) |
Callback to invoke when a new frame is received. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | NotifyNewAggregate (void) |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted (void) |
Notifier called once the ObjectBase is fully constructed. More... | |
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. More... | |
std::mutex | m_pendingReadMutex |
Mutex to increase pending read counter. More... | |
Private Member Functions | |
virtual Ptr< FdReader > | DoCreateFdReader (void) |
Create the FdReader object. More... | |
virtual void | DoFinishStartingDevice (void) |
Complete additional actions, if any, to spin up down the device. More... | |
virtual void | DoFinishStoppingDevice (void) |
Complete additional actions, if any, to tear down the device. More... | |
void | ForwardUp (void) |
Forward the frame to the appropriate callback for processing. More... | |
void | NotifyLinkUp (void) |
Notify that the link is up and ready. More... | |
void | StartDevice (void) |
Spin up the device. More... | |
void | StopDevice (void) |
Tear down the device. More... | |
bool | TransmitStart (Ptr< Packet > p) |
Start Sending a Packet Down the Wire. More... | |
Private Attributes | |
Mac48Address | m_address |
The net device mac address. More... | |
EncapsulationMode | m_encapMode |
The type of encapsulation of the received/transmitted frames. More... | |
int | m_fd |
The file descriptor used for receive/send network traffic. More... | |
Ptr< FdReader > | m_fdReader |
Reader for the file descriptor. More... | |
uint32_t | m_ifIndex |
The ns-3 interface index (in the sense of net device index) that has been assigned to this network device. More... | |
bool | m_isBroadcast |
Flag indicating whether or not the underlying net device supports broadcast. More... | |
bool | m_isMulticast |
Flag indicating whether or not the underlying net device supports multicast. More... | |
TracedCallback | m_linkChangeCallbacks |
Callbacks to fire if the link changes state (up or down). More... | |
bool | m_linkUp |
Flag indicating whether or not the link is up. More... | |
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). More... | |
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). More... | |
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). More... | |
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. More... | |
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. More... | |
uint32_t | m_maxPendingReads |
Maximum number of packets that can be received and scheduled for read but not yet read. More... | |
uint16_t | m_mtu |
The MTU associated to the file descriptor technology. More... | |
Ptr< Node > | m_node |
The ns-3 node associated to the net device. More... | |
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. More... | |
TracedCallback< Ptr< const Packet > > | m_phyRxDropTrace |
The trace source fired when the phy layer drops a packet it has received. More... | |
TracedCallback< Ptr< const Packet > > | m_phyTxDropTrace |
The trace source fired when the phy layer drops a packet as it tries to transmit it. More... | |
NetDevice::PromiscReceiveCallback | m_promiscRxCallback |
The callback used to notify higher layers that a packet has been received in promiscuous mode. More... | |
TracedCallback< Ptr< const Packet > > | m_promiscSnifferTrace |
A trace source that emulates a promiscuous mode protocol sniffer connected to the device. More... | |
NetDevice::ReceiveCallback | m_rxCallback |
The callback used to notify higher layers that a packet has been received. More... | |
TracedCallback< Ptr< const Packet > > | m_snifferTrace |
A trace source that emulates a non-promiscuous protocol sniffer connected to the device. More... | |
EventId | m_startEvent |
NetDevice start event. More... | |
EventId | m_stopEvent |
NetDevice stop event. More... | |
Time | m_tStart |
Time to start spinning up the device. More... | |
Time | m_tStop |
Time to start tearing down the device. More... | |
Additional Inherited Members | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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"
ns3::FdNetDevice is accessible through the following paths with Config::Set and Config::Connect:
Size of this type is 528 bytes (on a 64-bit architecture).
Definition at line 84 of file fd-net-device.h.
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 96 of file fd-net-device.h.
ns3::FdNetDevice::FdNetDevice | ( | ) |
Constructor for the FdNetDevice.
Definition at line 168 of file fd-net-device.cc.
References NS_LOG_FUNCTION.
|
virtual |
Destructor for the FdNetDevice.
Definition at line 183 of file fd-net-device.cc.
References NS_LOG_FUNCTION.
|
delete |
|
virtual |
callback | the 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 735 of file fd-net-device.cc.
References ns3::TracedCallback< Ts >::ConnectWithoutContext(), and m_linkChangeCallbacks.
|
protectedvirtual |
Allocate packet buffer.
len | the length of the buffer |
Reimplemented in ns3::DpdkNetDevice.
Definition at line 406 of file fd-net-device.cc.
Referenced by SendFrom().
Create the FdReader object.
Reimplemented in ns3::NetmapNetDevice.
Definition at line 260 of file fd-net-device.cc.
References m_mtu, and NS_LOG_FUNCTION.
Referenced by StartDevice().
|
protectedvirtual |
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 202 of file fd-net-device.cc.
References ns3::Object::DoDispose(), NS_LOG_FUNCTION, and StopDevice().
|
privatevirtual |
Complete additional actions, if any, to spin up down the device.
Reimplemented in ns3::NetmapNetDevice.
Definition at line 271 of file fd-net-device.cc.
References NS_LOG_FUNCTION.
Referenced by StartDevice().
|
privatevirtual |
Complete additional actions, if any, to tear down the device.
Reimplemented in ns3::NetmapNetDevice, and ns3::DpdkNetDevice.
Definition at line 277 of file fd-net-device.cc.
References NS_LOG_FUNCTION.
Referenced by StopDevice().
|
protectedvirtual |
Method Initialization for start and stop attributes.
Reimplemented from ns3::Object.
Definition at line 189 of file fd-net-device.cc.
References ns3::Object::DoInitialize(), m_tStart, m_tStop, NS_LOG_FUNCTION, ns3::Seconds(), Start(), and Stop().
|
private |
Forward the frame to the appropriate callback for processing.
Definition at line 418 of file fd-net-device.cc.
References ns3::Packet::Copy(), DIXPI, FreeBuffer(), ns3::EthernetHeader::GetDestination(), ns3::EthernetHeader::GetLengthType(), ns3::EthernetHeader::GetSerializedSize(), ns3::LlcSnapHeader::GetSerializedSize(), ns3::Packet::GetSize(), ns3::EthernetHeader::GetSource(), ns3::LlcSnapHeader::GetType(), ns3::Mac48Address::IsBroadcast(), ns3::Mac48Address::IsGroup(), ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), LLC, m_address, m_encapMode, m_macPromiscRxTrace, m_macRxTrace, m_pendingQueue, m_pendingReadMutex, m_phyRxDropTrace, m_promiscRxCallback, m_promiscSnifferTrace, m_rxCallback, m_snifferTrace, ns3::NetDevice::NS3_PACKET_BROADCAST, ns3::NetDevice::NS3_PACKET_HOST, ns3::NetDevice::NS3_PACKET_MULTICAST, ns3::NetDevice::NS3_PACKET_OTHERHOST, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Packet::RemoveHeader(), and ns3::RemovePIHeader().
Referenced by ReceiveCallback().
|
protectedvirtual |
Free the given packet buffer.
buf | the buffer to free |
Reimplemented in ns3::DpdkNetDevice.
Definition at line 412 of file fd-net-device.cc.
Referenced by ForwardUp(), SendFrom(), and StopDevice().
|
virtual |
Implements ns3::NetDevice.
Definition at line 679 of file fd-net-device.cc.
References m_address.
|
virtual |
Calling this method is invalid if IsBroadcast returns not true.
Implements ns3::NetDevice.
Definition at line 753 of file fd-net-device.cc.
Implements ns3::NetDevice.
Definition at line 704 of file fd-net-device.cc.
FdNetDevice::EncapsulationMode ns3::FdNetDevice::GetEncapsulationMode | ( | void | ) | const |
Get the link layer encapsulation mode of this device.
Definition at line 218 of file fd-net-device.cc.
References m_encapMode, and NS_LOG_FUNCTION.
|
protected |
Get the associated file descriptor.
Definition at line 667 of file fd-net-device.cc.
References m_fd.
Referenced by ns3::NetmapNetDevice::SyncAndNotifyQueue().
|
virtual |
Implements ns3::NetDevice.
Definition at line 698 of file fd-net-device.cc.
References m_ifIndex.
|
virtual |
This value is typically used by the IP layer to perform IP fragmentation when needed.
Implements ns3::NetDevice.
Definition at line 723 of file fd-net-device.cc.
References m_mtu.
Referenced by ns3::NetmapNetDevice::DoCreateFdReader().
|
virtual |
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.
multicastGroup | The IP address for the multicast group destination of the packet. |
Implements ns3::NetDevice.
Definition at line 771 of file fd-net-device.cc.
References ns3::Mac48Address::GetMulticast().
|
virtual |
Get the MAC multicast address corresponding to the IPv6 address provided.
addr | IPv6 address |
Implements ns3::NetDevice.
Definition at line 777 of file fd-net-device.cc.
References ns3::Mac48Address::GetMulticast().
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 795 of file fd-net-device.cc.
References m_node.
|
static |
Get the type ID.
Definition at line 81 of file fd-net-device.cc.
References DIX, DIXPI, LLC, m_address, m_encapMode, m_macPromiscRxTrace, m_macRxTrace, m_macTxDropTrace, m_macTxTrace, m_maxPendingReads, m_promiscSnifferTrace, m_snifferTrace, m_tStart, m_tStop, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeMac48AddressAccessor(), ns3::MakeMac48AddressChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().
|
virtual |
Return true if the net device is acting as a bridge.
Implements ns3::NetDevice.
Definition at line 783 of file fd-net-device.cc.
|
virtual |
Implements ns3::NetDevice.
Definition at line 741 of file fd-net-device.cc.
References m_isBroadcast.
|
virtual |
Implements ns3::NetDevice.
Reimplemented in ns3::DpdkNetDevice.
Definition at line 729 of file fd-net-device.cc.
References m_linkUp.
Referenced by SendFrom().
|
virtual |
Implements ns3::NetDevice.
Definition at line 759 of file fd-net-device.cc.
References m_isMulticast.
|
virtual |
Return true if the net device is on a point-to-point link.
Implements ns3::NetDevice.
Definition at line 789 of file fd-net-device.cc.
|
virtual |
Called by higher-layers to check if this NetDevice requires ARP to be used.
Implements ns3::NetDevice.
Definition at line 812 of file fd-net-device.cc.
|
private |
Notify that the link is up and ready.
Definition at line 685 of file fd-net-device.cc.
References m_linkChangeCallbacks, and m_linkUp.
Referenced by StartDevice().
|
protected |
Callback to invoke when a new frame is received.
buf | a buffer containing the received frame |
len | the length of the frame |
Definition at line 310 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().
|
virtual |
packet | packet sent from above down to Network Device |
dest | mac address of the destination (already resolved) |
protocolNumber | identifies 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
Implements ns3::NetDevice.
Definition at line 561 of file fd-net-device.cc.
References m_address, NS_LOG_FUNCTION, and SendFrom().
|
virtual |
packet | packet sent from above down to Network Device |
source | source mac address (so called "MAC spoofing") |
dest | mac address of the destination (already resolved) |
protocolNumber | identifies 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.
Implements ns3::NetDevice.
Definition at line 568 of file fd-net-device.cc.
References ns3::Packet::AddHeader(), ns3::AddPIHeader(), AllocateBuffer(), ns3::Mac48Address::ConvertFrom(), ns3::Packet::CopyData(), DIXPI, FreeBuffer(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), 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().
|
virtual |
Set the address of this interface.
address | address to set |
Implements ns3::NetDevice.
Definition at line 673 of file fd-net-device.cc.
References first::address, ns3::Mac48Address::ConvertFrom(), and m_address.
void ns3::FdNetDevice::SetEncapsulationMode | ( | FdNetDevice::EncapsulationMode | mode | ) |
Set the link layer encapsulation mode of this device.
mode | The link layer encapsulation mode of this device. |
Definition at line 210 of file fd-net-device.cc.
References m_encapMode, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
void ns3::FdNetDevice::SetFileDescriptor | ( | int | fd | ) |
Set the associated file descriptor.
fd | the file descriptor |
Definition at line 658 of file fd-net-device.cc.
References m_fd.
|
virtual |
index | ifIndex of the device |
Implements ns3::NetDevice.
Definition at line 692 of file fd-net-device.cc.
References m_ifIndex.
|
virtual |
Set if the NetDevice is able to send Broadcast messages.
broadcast | true if the NetDevice can send Broadcast |
Definition at line 747 of file fd-net-device.cc.
References m_isBroadcast.
|
virtual |
Set if the NetDevice is able to send Multicast messages.
multicast | true if the NetDevice can send Multicast |
Definition at line 765 of file fd-net-device.cc.
References m_isMulticast.
|
virtual |
mtu | MTU value, in bytes, to set for the device |
Override for default MTU defined on a per-type basis.
Implements ns3::NetDevice.
Definition at line 710 of file fd-net-device.cc.
References m_mtu.
node | the node associated to this netdevice. |
This method is called from ns3::Node::AddDevice.
Implements ns3::NetDevice.
Definition at line 801 of file fd-net-device.cc.
References ns3::Node::GetId(), m_node, and m_nodeId.
|
virtual |
cb | callback 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 824 of file fd-net-device.cc.
References m_promiscRxCallback.
|
virtual |
cb | callback 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 818 of file fd-net-device.cc.
References m_rxCallback.
void ns3::FdNetDevice::Start | ( | Time | tStart | ) |
Set a start time for the device.
tStart | the start time |
Definition at line 225 of file fd-net-device.cc.
References ns3::Simulator::Cancel(), m_startEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartDevice().
Referenced by DoInitialize().
|
private |
Spin up the device.
Definition at line 241 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().
void ns3::FdNetDevice::Stop | ( | Time | tStop | ) |
Set a stop time for the device.
tStop | the stop time |
Definition at line 233 of file fd-net-device.cc.
References ns3::Simulator::Cancel(), m_stopEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StopDevice().
Referenced by DoInitialize().
|
private |
Tear down the device.
Definition at line 283 of file fd-net-device.cc.
References DoFinishStoppingDevice(), FreeBuffer(), m_fd, m_fdReader, m_pendingQueue, and NS_LOG_FUNCTION.
Referenced by DoDispose(), and Stop().
|
virtual |
Implements ns3::NetDevice.
Definition at line 830 of file fd-net-device.cc.
Start Sending a Packet Down the Wire.
p | packet to send |
|
virtual |
Write packet data to device.
buffer | The data. |
length | The data length. |
Reimplemented in ns3::NetmapNetDevice, and ns3::DpdkNetDevice.
Definition at line 649 of file fd-net-device.cc.
References m_fd, and NS_LOG_FUNCTION.
Referenced by SendFrom().
|
private |
The net device mac address.
Definition at line 324 of file fd-net-device.h.
Referenced by ForwardUp(), GetAddress(), GetTypeId(), Send(), and SetAddress().
|
private |
The type of encapsulation of the received/transmitted frames.
Definition at line 329 of file fd-net-device.h.
Referenced by ForwardUp(), GetEncapsulationMode(), GetTypeId(), SendFrom(), and SetEncapsulationMode().
|
private |
The file descriptor used for receive/send network traffic.
Definition at line 314 of file fd-net-device.h.
Referenced by GetFileDescriptor(), SetFileDescriptor(), StartDevice(), StopDevice(), and Write().
Reader for the file descriptor.
Definition at line 319 of file fd-net-device.h.
Referenced by StartDevice(), and StopDevice().
|
private |
The ns-3 interface index (in the sense of net device index) that has been assigned to this network device.
Definition at line 304 of file fd-net-device.h.
Referenced by GetIfIndex(), and SetIfIndex().
|
private |
Flag indicating whether or not the underlying net device supports broadcast.
Definition at line 346 of file fd-net-device.h.
Referenced by IsBroadcast(), and SetIsBroadcast().
|
private |
Flag indicating whether or not the underlying net device supports multicast.
Definition at line 352 of file fd-net-device.h.
Referenced by IsMulticast(), and SetIsMulticast().
|
private |
Callbacks to fire if the link changes state (up or down).
Definition at line 340 of file fd-net-device.h.
Referenced by AddLinkChangeCallback(), and NotifyLinkUp().
|
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 335 of file fd-net-device.h.
Referenced by IsLinkUp(), and NotifyLinkUp().
|
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.
Definition at line 411 of file fd-net-device.h.
Referenced by ForwardUp(), and GetTypeId().
|
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).
Definition at line 429 of file fd-net-device.h.
|
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.
Definition at line 420 of file fd-net-device.h.
Referenced by ForwardUp(), and GetTypeId().
|
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.
Definition at line 402 of file fd-net-device.h.
Referenced by GetTypeId(), and SendFrom().
|
private |
The trace source fired when packets come into the "top" of the device at the L3/L2 transition, before being queued for transmission.
Definition at line 394 of file fd-net-device.h.
Referenced by GetTypeId(), and SendFrom().
|
private |
Maximum number of packets that can be received and scheduled for read but not yet read.
Definition at line 357 of file fd-net-device.h.
Referenced by GetTypeId(), and ReceiveCallback().
|
private |
The MTU associated to the file descriptor technology.
Definition at line 309 of file fd-net-device.h.
Referenced by DoCreateFdReader(), GetMtu(), SendFrom(), and SetMtu().
The ns-3 node associated to the net device.
Definition at line 292 of file fd-net-device.h.
|
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 299 of file fd-net-device.h.
Referenced by ReceiveCallback(), and SetNode().
|
protected |
Number of packets that were received and scheduled for read but not yet read.
Definition at line 243 of file fd-net-device.h.
Referenced by ns3::DpdkNetDevice::DoFinishStoppingDevice(), ForwardUp(), ReceiveCallback(), and StopDevice().
|
protected |
Mutex to increase pending read counter.
Definition at line 238 of file fd-net-device.h.
Referenced by ns3::DpdkNetDevice::DoFinishStoppingDevice(), ForwardUp(), and ReceiveCallback().
|
private |
The trace source fired when the phy layer drops a packet it has received.
Definition at line 446 of file fd-net-device.h.
Referenced by ForwardUp().
|
private |
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Definition at line 439 of file fd-net-device.h.
|
private |
The callback used to notify higher layers that a packet has been received in promiscuous mode.
Definition at line 386 of file fd-net-device.h.
Referenced by ForwardUp(), and SetPromiscReceiveCallback().
|
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.
Definition at line 486 of file fd-net-device.h.
Referenced by ForwardUp(), GetTypeId(), and SendFrom().
|
private |
The callback used to notify higher layers that a packet has been received.
Definition at line 381 of file fd-net-device.h.
Referenced by ForwardUp(), and SetReceiveCallback().
|
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.
Definition at line 466 of file fd-net-device.h.
Referenced by ForwardUp(), GetTypeId(), and SendFrom().
|
private |
|
private |
|
private |
Time to start spinning up the device.
Definition at line 362 of file fd-net-device.h.
Referenced by DoInitialize(), and GetTypeId().
|
private |
Time to start tearing down the device.
Definition at line 367 of file fd-net-device.h.
Referenced by DoInitialize(), and GetTypeId().