a NetDevice to read/write network traffic from/into a Dpdk enabled port. More...
#include "dpdk-net-device.h"
Inheritance diagram for ns3::DpdkNetDevice:
Collaboration diagram for ns3::DpdkNetDevice:Public Member Functions | |
| DpdkNetDevice () | |
| Constructor for the DpdkNetDevice. More... | |
| ~DpdkNetDevice () | |
| Destructor for the DpdkNetDevice. More... | |
| virtual uint8_t * | AllocateBuffer (size_t len) |
| Allocate packet buffer. More... | |
| void | CheckAllPortsLinkStatus (void) |
| Check the link status of all ports in up to 9s and print them finally. More... | |
| virtual void | FreeBuffer (uint8_t *buf) |
| Free the given packet buffer. More... | |
| void | HandleRx () |
| Receive packets in burst from the nic to the rx_buffer. More... | |
| void | HandleTx () |
| Transmit packets in burst from the tx_buffer to the nic. More... | |
| void | InitDpdk (int argc, char **argv, std::string dpdkDriver) |
| Initialize Dpdk. More... | |
| bool | IsLinkUp (void) const |
| Check the status of the link. More... | |
| void | SetDeviceName (std::string deviceName) |
| Set device name. More... | |
Public Member Functions inherited from ns3::FdNetDevice | |
| 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 () |
| virtual void | AddLinkChangeCallback (Callback< void > callback)=0 |
| virtual Address | GetAddress (void) const =0 |
| virtual Address | GetBroadcast (void) const =0 |
| virtual Ptr< Channel > | GetChannel (void) const =0 |
| virtual uint32_t | GetIfIndex (void) const =0 |
| virtual uint16_t | GetMtu (void) const =0 |
| virtual Address | GetMulticast (Ipv4Address multicastGroup) const =0 |
| Make and return a MAC multicast address using the provided multicast group. More... | |
| virtual Address | GetMulticast (Ipv6Address addr) const =0 |
| Get the MAC multicast address corresponding to the IPv6 address provided. More... | |
| virtual Ptr< Node > | GetNode (void) const =0 |
| virtual bool | IsBridge (void) const =0 |
| Return true if the net device is acting as a bridge. More... | |
| virtual bool | IsBroadcast (void) const =0 |
| virtual bool | IsLinkUp (void) const =0 |
| virtual bool | IsMulticast (void) const =0 |
| virtual bool | IsPointToPoint (void) const =0 |
| Return true if the net device is on a point-to-point link. More... | |
| virtual bool | NeedsArp (void) const =0 |
| virtual bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0 |
| virtual bool | SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0 |
| virtual void | SetAddress (Address address)=0 |
| Set the address of this interface. More... | |
| virtual void | SetIfIndex (const uint32_t index)=0 |
| virtual bool | SetMtu (const uint16_t mtu)=0 |
| virtual void | SetNode (Ptr< Node > node)=0 |
| virtual void | SetPromiscReceiveCallback (PromiscReceiveCallback cb)=0 |
| virtual void | SetReceiveCallback (ReceiveCallback cb)=0 |
| virtual bool | SupportsSendFrom (void) const =0 |
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) | |
| Copy constructor. More... | |
| uint32_t | GetReferenceCount (void) const |
| Get the reference count of the object. More... | |
| SimpleRefCount & | operator= (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... | |
| virtual TypeId | GetInstanceTypeId (void) const =0 |
| Get the most derived TypeId for this Object. 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 int | LaunchCore (void *arg) |
| A function to handle rx & tx operations. More... | |
| static void | SignalHandler (int signum) |
| A signal handler for SIGINT and SIGTERM signals. More... | |
Static Public Member Functions inherited from ns3::FdNetDevice | |
| 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 | |
| ssize_t | Write (uint8_t *buffer, size_t length) |
| Write packet data to device. More... | |
Protected Member Functions inherited from ns3::FdNetDevice | |
| 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 | DoDispose (void) |
| Destructor implementation. More... | |
| virtual void | DoInitialize (void) |
| Initialize() implementation. 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::string | m_deviceName |
| The device name;. More... | |
| uint16_t | m_portId |
| The port number of the device to be used. More... | |
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. More... | |
| SystemMutex | m_pendingReadMutex |
| Mutex to increase pending read counter. More... | |
Private Member Functions | |
| void | DoFinishStoppingDevice (void) |
| Complete additional actions, if any, to tear down the device. More... | |
Private Attributes | |
| uint32_t | m_maxRxPktBurst |
| Size of Rx burst. More... | |
| uint32_t | m_maxTxPktBurst |
| Size of Tx burst. More... | |
| struct rte_mempool * | m_mempool |
| Packet memory pool. More... | |
| uint32_t | m_mempoolCacheSize |
| Mempool cache size. More... | |
| uint16_t | m_nbRxDesc |
| Number of Rx descriptors. More... | |
| uint16_t | m_nbTxDesc |
| Number of Tx descriptors. More... | |
| struct rte_eth_dev_tx_buffer * | m_rxBuffer |
| Buffer to handle burst reception. More... | |
| struct rte_eth_dev_tx_buffer * | m_txBuffer |
| Buffer to handle burst transmission. More... | |
| EventId | m_txEvent |
| Event for stale packet transmission. More... | |
| Time | m_txTimeout |
| The time to wait before transmitting burst from Tx buffer. More... | |
Static Private Attributes | |
| static volatile bool | m_forceQuit = false |
| Condition variable for Dpdk to stop. More... | |
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) (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 |
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 Dpdk enabled port.
A DpdkNetDevice object will read and write frames/packets from/to a Dpdk enabled port.
Definition at line 48 of file dpdk-net-device.h.
| ns3::DpdkNetDevice::DpdkNetDevice | ( | ) |
Constructor for the DpdkNetDevice.
Definition at line 96 of file dpdk-net-device.cc.
References NS_LOG_FUNCTION.
| ns3::DpdkNetDevice::~DpdkNetDevice | ( | ) |
Destructor for the DpdkNetDevice.
Definition at line 102 of file dpdk-net-device.cc.
References ns3::Simulator::Cancel(), m_forceQuit, m_portId, m_txEvent, and NS_LOG_FUNCTION.
Here is the call graph for this function:
|
virtual |
Allocate packet buffer.
| len | the length of the buffer |
Reimplemented from ns3::FdNetDevice.
Definition at line 417 of file dpdk-net-device.cc.
References m_mempool.
| void ns3::DpdkNetDevice::CheckAllPortsLinkStatus | ( | void | ) |
Check the link status of all ports in up to 9s and print them finally.
Definition at line 122 of file dpdk-net-device.cc.
References CHECK_INTERVAL, m_forceQuit, m_portId, MAX_CHECK_TIME, and NS_LOG_FUNCTION.
Referenced by InitDpdk().
Here is the caller graph for this function:
|
privatevirtual |
Complete additional actions, if any, to tear down the device.
Reimplemented from ns3::FdNetDevice.
Definition at line 475 of file dpdk-net-device.cc.
References FreeBuffer(), ns3::FdNetDevice::m_pendingQueue, and ns3::FdNetDevice::m_pendingReadMutex.
Here is the call graph for this function:
|
virtual |
Free the given packet buffer.
| buf | the pointer to the buffer to be freed |
Reimplemented from ns3::FdNetDevice.
Definition at line 429 of file dpdk-net-device.cc.
Referenced by DoFinishStoppingDevice().
Here is the caller graph for this function:
|
static |
Get the type ID.
Definition at line 56 of file dpdk-net-device.cc.
References m_maxRxPktBurst, m_maxTxPktBurst, m_mempoolCacheSize, m_nbRxDesc, m_nbTxDesc, m_txTimeout, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeUintegerAccessor(), ns3::MicroSeconds(), and ns3::TypeId::SetParent().
Here is the call graph for this function:| void ns3::DpdkNetDevice::HandleRx | ( | ) |
Receive packets in burst from the nic to the rx_buffer.
Definition at line 205 of file dpdk-net-device.cc.
References m_maxRxPktBurst, m_portId, and m_rxBuffer.
Referenced by LaunchCore().
Here is the caller graph for this function:| void ns3::DpdkNetDevice::HandleTx | ( | ) |
Transmit packets in burst from the tx_buffer to the nic.
Definition at line 198 of file dpdk-net-device.cc.
References m_portId, and m_txBuffer.
Referenced by Write().
Here is the caller graph for this function:| void ns3::DpdkNetDevice::InitDpdk | ( | int | argc, |
| char ** | argv, | ||
| std::string | dpdkDriver | ||
| ) |
Initialize Dpdk.
Initializes EAL.
| argc | Dpdk EAL args count. |
| argv | Dpdk EAL args list. |
| dpdkDriver | Dpdk Driver to bind NIC to. |
Definition at line 258 of file dpdk-net-device.cc.
References CheckAllPortsLinkStatus(), LaunchCore(), m_deviceName, m_forceQuit, m_maxRxPktBurst, m_maxTxPktBurst, m_mempool, m_mempoolCacheSize, m_nbRxDesc, m_nbTxDesc, m_portId, m_rxBuffer, m_txBuffer, NS_LOG_FUNCTION, NS_LOG_INFO, and SignalHandler().
Here is the call graph for this function:
|
virtual |
Check the status of the link.
Reimplemented from ns3::FdNetDevice.
Definition at line 251 of file dpdk-net-device.cc.
|
static |
A function to handle rx & tx operations.
| arg | a pointer to the DpdkNetDevice |
Definition at line 232 of file dpdk-net-device.cc.
References HandleRx(), and m_forceQuit.
Referenced by InitDpdk().
Here is the call graph for this function:
Here is the caller graph for this function:| void ns3::DpdkNetDevice::SetDeviceName | ( | std::string | deviceName | ) |
Set device name.
| deviceName | The device name. |
Definition at line 114 of file dpdk-net-device.cc.
References m_deviceName, and NS_LOG_FUNCTION.
|
static |
A signal handler for SIGINT and SIGTERM signals.
| signum | The signal number. |
Definition at line 187 of file dpdk-net-device.cc.
References m_forceQuit.
Referenced by InitDpdk().
Here is the caller graph for this function:
|
protectedvirtual |
Write packet data to device.
| buffer | The data. |
| length | The data length. |
Reimplemented from ns3::FdNetDevice.
Definition at line 445 of file dpdk-net-device.cc.
References ns3::Simulator::Cancel(), HandleTx(), m_maxTxPktBurst, m_portId, m_txBuffer, m_txEvent, m_txTimeout, NS_LOG_ERROR, and ns3::Simulator::Schedule().
Here is the call graph for this function:
|
protected |
The device name;.
Definition at line 150 of file dpdk-net-device.h.
Referenced by InitDpdk(), and SetDeviceName().
|
staticprivate |
Condition variable for Dpdk to stop.
Definition at line 157 of file dpdk-net-device.h.
Referenced by ~DpdkNetDevice(), CheckAllPortsLinkStatus(), InitDpdk(), LaunchCore(), and SignalHandler().
|
private |
Size of Rx burst.
Definition at line 187 of file dpdk-net-device.h.
Referenced by GetTypeId(), HandleRx(), and InitDpdk().
|
private |
Size of Tx burst.
Definition at line 192 of file dpdk-net-device.h.
Referenced by GetTypeId(), InitDpdk(), and Write().
|
private |
Packet memory pool.
Definition at line 162 of file dpdk-net-device.h.
Referenced by AllocateBuffer(), and InitDpdk().
|
private |
Mempool cache size.
Definition at line 197 of file dpdk-net-device.h.
Referenced by GetTypeId(), and InitDpdk().
|
private |
Number of Rx descriptors.
Definition at line 202 of file dpdk-net-device.h.
Referenced by GetTypeId(), and InitDpdk().
|
private |
Number of Tx descriptors.
Definition at line 207 of file dpdk-net-device.h.
Referenced by GetTypeId(), and InitDpdk().
|
protected |
The port number of the device to be used.
Definition at line 145 of file dpdk-net-device.h.
Referenced by ~DpdkNetDevice(), CheckAllPortsLinkStatus(), HandleRx(), HandleTx(), InitDpdk(), and Write().
|
private |
Buffer to handle burst reception.
Definition at line 172 of file dpdk-net-device.h.
Referenced by HandleRx(), and InitDpdk().
|
private |
Buffer to handle burst transmission.
Definition at line 167 of file dpdk-net-device.h.
Referenced by HandleTx(), InitDpdk(), and Write().
|
private |
Event for stale packet transmission.
Definition at line 177 of file dpdk-net-device.h.
Referenced by ~DpdkNetDevice(), and Write().
|
private |
The time to wait before transmitting burst from Tx buffer.
Definition at line 182 of file dpdk-net-device.h.
Referenced by GetTypeId(), and Write().