|   | A Discrete-Event Network Simulator | API | 
	  
	
	
       
 
Go to the documentation of this file.
   22 #include "ns3/system-thread.h" 
   23 #include "ns3/uinteger.h" 
   24 #include <sys/ioctl.h> 
   36     .SetGroupName (
"Network")
 
   97   : m_bufferSize (65536),
 
  126   struct netmap_ring *rxring;
 
  128   uint32_t rxRingIndex = 0;
 
  132   while (rxRingIndex < m_nifp->ni_rx_rings)
 
  134       rxring = NETMAP_RXRING (
m_nifp, rxRingIndex);
 
  136       if (!nm_ring_empty (rxring))
 
  138           uint32_t i = rxring->cur;
 
  139           uint8_t *buffer = (uint8_t *) NETMAP_BUF (rxring, rxring->slot[i].buf_idx);
 
  140           len = rxring->slot[i].len;
 
  141           NS_LOG_DEBUG (
"Received a packet of " << len << 
" bytes");
 
  144           memcpy (buf, buffer, len);
 
  147           rxring->head = rxring->cur = nm_ring_next (rxring, i);
 
  149           ioctl (
m_fd, NIOCRXSYNC, NULL);
 
  174     .SetGroupName (
"FdNetDevice")
 
  176     .AddAttribute (
"SyncAndNotifyQueuePeriod",
 
  177                    "The period of time (in number of us) after which the device syncs the netmap ring and notifies queue status.",
 
  180                    MakeUintegerChecker<uint8_t> ());
 
  212   fdReader->SetBufferSize (
GetMtu () + 22);
 
  213   fdReader->SetNetmapIfp (
m_nifp);
 
  245   struct netmap_ring *txring;
 
  246   txring = NETMAP_TXRING (
m_nifp, 0);
 
  248   int tail = txring->tail;
 
  253   uint32_t bytesInQueue = 0;
 
  255   for (
int i = 1; i < inQueue; i++)
 
  257       bytesInQueue += txring->slot[tail].len;
 
  304   struct netmap_ring *txring;
 
  305   txring = NETMAP_TXRING (
m_nifp, 0);
 
  307   return nm_ring_space (txring);
 
  316   struct netmap_ring *txring = NETMAP_TXRING (
m_nifp, 0);
 
  318   uint32_t prevTotalTransmittedBytes = 0;
 
  328       uint32_t deltaBytes = totalTransmittedBytes - prevTotalTransmittedBytes;
 
  329       NS_LOG_DEBUG (deltaBytes << 
" delta transmitted bytes");
 
  330       prevTotalTransmittedBytes = totalTransmittedBytes;
 
  333           m_queue->NotifyTransmittedBytes (deltaBytes);
 
  346       NS_LOG_DEBUG (
"Space in the netmap ring of " << nm_ring_space (txring) << 
" packets");
 
  358   struct netmap_ring *txring;
 
  361   txring = NETMAP_TXRING (
m_nifp, 0);
 
  371   if (!nm_ring_empty (txring))
 
  374       uint32_t i = txring->cur;
 
  375       uint8_t *buf = (uint8_t *) NETMAP_BUF (txring, txring->slot[i].buf_idx);
 
  377       memcpy (buf, buffer, length);
 
  378       txring->slot[i].len = length;
 
  380       txring->head = txring->cur = nm_ring_next (txring, i);
 
  386       m_queue->NotifyQueuedBytes (length);
 
  389       if (nm_ring_space (txring) == 0)
 
  
 
static TypeId GetTypeId(void)
Get the type ID.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
int m_fd
The file descriptor to read from.
void SetBufferSize(uint32_t bufferSize)
Set size of the read buffer.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< NetDeviceQueue > m_queue
NetDevice queue.
virtual void Wake(void)
Called by the device to wake the queue disc associated with this device transmission queue.
std::mutex m_mutex
Mutex to serialize the operations performed on the queue.
uint32_t m_totalQueuedBytes
Total queued bytes.
a NetDevice to read/write network traffic from/into a netmap file descriptor.
void SetNetDeviceQueue(Ptr< NetDeviceQueue > queue)
Set the NetDeviceQueue.
uint32_t m_nRxRings
Number of receiver rings.
void DoFinishStoppingDevice(void)
Complete additional actions, if any, to tear down the device.
virtual void SyncAndNotifyQueue()
This function syncs netmap ring and notifies netdevice queue.
uint32_t m_bufferSize
size of the read buffer
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void Start(void)
Called by the device to start this device transmission queue.
int GetFileDescriptor(void) const
Get the associated file descriptor.
NetmapNetDeviceFdReader()
FdReader::Data DoRead(void)
The read implementation.
static TypeId GetTypeId(void)
Get the type ID.
Smart pointer class similar to boost::intrusive_ptr.
virtual ~NetmapNetDevice()
uint32_t m_nRxRingsSlots
Number of slots in the receiver rings.
void DoFinishStartingDevice(void)
Complete additional actions, if any, to spin up down the device.
int GetSpaceInNetmapTxRing() const
Get the number of slots currently available in the netmap transmission ring.
virtual bool IsStopped(void) const
Get the status of the device transmission queue.
Network device transmission queue.
virtual bool IsStopped(void) const
Get the status of the device transmission queue.
virtual ssize_t Write(uint8_t *buffer, size_t length)
The function Writes a packet into the netmap transmission ring.
struct netmap_if * m_nifp
Netmap interface representation.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
virtual ~NetDeviceQueueLock()
std::atomic< bool > m_syncAndNotifyQueueThreadRun
Running flag of the flow control thread.
uint32_t m_nTxRingsSlots
Number of slots in the transmission rings.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
virtual void Stop(void)
Called by the device to stop this device transmission queue.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void SetTxRingsInfo(uint32_t nTxRings, uint32_t nTxRingsSlots)
Set the netmap transmission rings info.
a NetDevice to read/write network traffic from/into a file descriptor.
uint32_t m_nTxRings
Number of transmission rings.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual void Wake(void)
Called by the device to wake the queue disc associated with this device transmission queue.
virtual void NotifyQueuedBytes(uint32_t bytes)
Called by the netdevice to report the number of bytes queued to the device queue.
void SetRxRingsInfo(uint32_t nRxRings, uint32_t nRxRingsSlots)
Set the netmap receiver rings info.
void SetNetmapInterfaceRepresentation(struct netmap_if *nifp)
Set the netmap interface representation.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint8_t m_syncAndNotifyQueuePeriod
The period of time in us after which the device syncs the netmap ring and notifies queue status.
Network device transmission queue with lock.
Ptr< FdReader > DoCreateFdReader(void)
Create the FdReader object.
virtual void Stop(void)
Called by the device to stop this device transmission queue.
Hold an unsigned integer type.
virtual uint16_t GetMtu(void) const
virtual void Start(void)
Called by the device to start this device transmission queue.
uint32_t GetBytesInNetmapTxRing()
Get the number of bytes currently in the netmap transmission ring.
virtual void NotifyTransmittedBytes(uint32_t bytes)
Called by the netdevice to report the number of bytes it is going to transmit.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual void NotifyTransmittedBytes(uint32_t bytes)
Called by the netdevice to report the number of bytes it is going to transmit.
struct netmap_if * m_nifp
Netmap interface representation.
void SetNetmapIfp(struct netmap_if *nifp)
Set netmap interface representation.
A structure representing data read.
Ptr< SystemThread > m_syncAndNotifyQueueThread
Thread used to perform the flow control.
virtual void NotifyQueuedBytes(uint32_t bytes)
Called by the netdevice to report the number of bytes queued to the device queue.