a NetDevice to read/write network traffic from/into a netmap file descriptor. More...
#include "netmap-net-device.h"
Public Member Functions | |
NetmapNetDevice () | |
virtual | ~NetmapNetDevice () |
uint32_t | GetBytesInNetmapTxRing () |
Get the number of bytes currently in the netmap transmission ring. | |
int | GetSpaceInNetmapTxRing () const |
Get the number of slots currently available in the netmap transmission ring. | |
void | SetNetDeviceQueue (Ptr< NetDeviceQueue > queue) |
Set the NetDeviceQueue. | |
void | SetNetmapInterfaceRepresentation (struct netmap_if *nifp) |
Set the netmap interface representation. | |
void | SetRxRingsInfo (uint32_t nRxRings, uint32_t nRxRingsSlots) |
Set the netmap receiver rings info. | |
void | SetTxRingsInfo (uint32_t nTxRings, uint32_t nTxRingsSlots) |
Set the netmap transmission rings info. | |
virtual ssize_t | Write (uint8_t *buffer, size_t length) |
The function Writes a packet into the netmap transmission ring. | |
Public Member Functions inherited from ns3::FdNetDevice | |
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< Channel > | GetChannel () 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< Node > | GetNode () 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 |
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< Object > | GetObject () 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< Object > | GetObject (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. | |
SimpleRefCount & | operator= (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::FdNetDevice | |
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. | |
Private Member Functions | |
Ptr< FdReader > | DoCreateFdReader () |
Create the FdReader object. | |
void | DoFinishStartingDevice () |
Complete additional actions, if any, to spin up down the device. | |
void | DoFinishStoppingDevice () |
Complete additional actions, if any, to tear down the device. | |
virtual void | SyncAndNotifyQueue () |
This function syncs netmap ring and notifies netdevice queue. | |
Private Attributes | |
struct netmap_if * | m_nifp |
Netmap interface representation. | |
uint32_t | m_nRxRings |
Number of receiver rings. | |
uint32_t | m_nRxRingsSlots |
Number of slots in the receiver rings. | |
uint32_t | m_nTxRings |
Number of transmission rings. | |
uint32_t | m_nTxRingsSlots |
Number of slots in the transmission rings. | |
Ptr< NetDeviceQueue > | m_queue |
NetDevice queue. | |
uint8_t | m_syncAndNotifyQueuePeriod |
The period of time in us after which the device syncs the netmap ring and notifies queue status. | |
std::thread | m_syncAndNotifyQueueThread |
Thread used to perform the flow control. | |
std::atomic< bool > | m_syncAndNotifyQueueThreadRun |
Running flag of the flow control thread. | |
uint32_t | m_totalQueuedBytes |
Total queued bytes. | |
Additional Inherited Members | |
Public Types inherited from ns3::FdNetDevice | |
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 &, PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Protected Member Functions inherited from ns3::FdNetDevice | |
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 inherited from ns3::FdNetDevice | |
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. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
a NetDevice to read/write network traffic from/into a netmap file descriptor.
A NetmapNetDevice object will read and write packets from/to a netmap file descriptor.
Definition at line 127 of file netmap-net-device.h.
ns3::NetmapNetDevice::NetmapNetDevice | ( | ) |
Definition at line 180 of file netmap-net-device.cc.
References m_nifp, m_nRxRings, m_nRxRingsSlots, m_nTxRings, m_nTxRingsSlots, m_queue, m_syncAndNotifyQueueThreadRun, m_totalQueuedBytes, and NS_LOG_FUNCTION.
|
virtual |
Definition at line 193 of file netmap-net-device.cc.
References m_nifp, m_queue, and NS_LOG_FUNCTION.
Create the FdReader object.
Reimplemented from ns3::FdNetDevice.
Definition at line 201 of file netmap-net-device.cc.
References ns3::Create(), ns3::FdNetDevice::GetMtu(), m_nifp, and NS_LOG_FUNCTION.
|
privatevirtual |
Complete additional actions, if any, to spin up down the device.
Reimplemented from ns3::FdNetDevice.
Definition at line 213 of file netmap-net-device.cc.
References m_syncAndNotifyQueueThread, m_syncAndNotifyQueueThreadRun, NS_LOG_FUNCTION, and SyncAndNotifyQueue().
|
privatevirtual |
Complete additional actions, if any, to tear down the device.
Reimplemented from ns3::FdNetDevice.
Definition at line 222 of file netmap-net-device.cc.
References m_queue, m_syncAndNotifyQueueThread, m_syncAndNotifyQueueThreadRun, and NS_LOG_FUNCTION.
uint32_t ns3::NetmapNetDevice::GetBytesInNetmapTxRing | ( | ) |
Get the number of bytes currently in the netmap transmission ring.
Definition at line 237 of file netmap-net-device.cc.
References m_nifp, m_nTxRingsSlots, and NS_LOG_FUNCTION.
Referenced by SyncAndNotifyQueue().
int ns3::NetmapNetDevice::GetSpaceInNetmapTxRing | ( | ) | const |
Get the number of slots currently available in the netmap transmission ring.
Definition at line 296 of file netmap-net-device.cc.
References m_nifp, and NS_LOG_FUNCTION.
Referenced by SyncAndNotifyQueue().
|
static |
Get the type ID.
Definition at line 164 of file netmap-net-device.cc.
References m_syncAndNotifyQueuePeriod, ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), and ns3::TypeId::SetParent().
void ns3::NetmapNetDevice::SetNetDeviceQueue | ( | Ptr< NetDeviceQueue > | queue | ) |
Set the NetDeviceQueue.
queue | the NetDeviceQueue |
Definition at line 262 of file netmap-net-device.cc.
References m_queue, and NS_LOG_FUNCTION.
void ns3::NetmapNetDevice::SetNetmapInterfaceRepresentation | ( | struct netmap_if * | nifp | ) |
Set the netmap interface representation.
nifp | the pointer to netmap interface representation |
Definition at line 270 of file netmap-net-device.cc.
References m_nifp, and NS_LOG_FUNCTION.
Set the netmap receiver rings info.
nRxRings | the number of receiver rings |
nRxRingsSlots | the number of slots for each receiver ring |
Definition at line 287 of file netmap-net-device.cc.
References m_nRxRings, m_nRxRingsSlots, and NS_LOG_FUNCTION.
Set the netmap transmission rings info.
nTxRings | the number of transmission rings |
nTxRingsSlots | the number of slots for each transmission ring |
Definition at line 278 of file netmap-net-device.cc.
References m_nTxRings, m_nTxRingsSlots, and NS_LOG_FUNCTION.
|
privatevirtual |
This function syncs netmap ring and notifies netdevice queue.
This function runs in a separate thread.
Definition at line 308 of file netmap-net-device.cc.
References GetBytesInNetmapTxRing(), ns3::FdNetDevice::GetFileDescriptor(), GetSpaceInNetmapTxRing(), m_nifp, m_queue, m_syncAndNotifyQueuePeriod, m_syncAndNotifyQueueThreadRun, m_totalQueuedBytes, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
Referenced by DoFinishStartingDevice().
|
virtual |
The function Writes a packet into the netmap transmission ring.
buffer | the pointer to packet |
length | the packet length |
Reimplemented from ns3::FdNetDevice.
Definition at line 349 of file netmap-net-device.cc.
References m_nifp, m_queue, m_totalQueuedBytes, and NS_LOG_FUNCTION.
|
private |
Netmap interface representation.
Definition at line 196 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), ~NetmapNetDevice(), DoCreateFdReader(), GetBytesInNetmapTxRing(), GetSpaceInNetmapTxRing(), SetNetmapInterfaceRepresentation(), SyncAndNotifyQueue(), and Write().
|
private |
Number of receiver rings.
Definition at line 199 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), and SetRxRingsInfo().
|
private |
Number of slots in the receiver rings.
Definition at line 200 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), and SetRxRingsInfo().
|
private |
Number of transmission rings.
Definition at line 197 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), and SetTxRingsInfo().
|
private |
Number of slots in the transmission rings.
Definition at line 198 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), GetBytesInNetmapTxRing(), and SetTxRingsInfo().
|
private |
NetDevice queue.
Definition at line 201 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), ~NetmapNetDevice(), DoFinishStoppingDevice(), SetNetDeviceQueue(), SyncAndNotifyQueue(), and Write().
|
private |
The period of time in us after which the device syncs the netmap ring and notifies queue status.
Definition at line 205 of file netmap-net-device.h.
Referenced by GetTypeId(), and SyncAndNotifyQueue().
|
private |
Thread used to perform the flow control.
Definition at line 203 of file netmap-net-device.h.
Referenced by DoFinishStartingDevice(), and DoFinishStoppingDevice().
|
private |
Running flag of the flow control thread.
Definition at line 204 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), DoFinishStartingDevice(), DoFinishStoppingDevice(), and SyncAndNotifyQueue().
|
private |
Total queued bytes.
Definition at line 202 of file netmap-net-device.h.
Referenced by NetmapNetDevice(), SyncAndNotifyQueue(), and Write().