21 #include "ns3/net-device-queue-interface.h" 
   23 #include "ns3/object-map.h" 
   24 #include "ns3/packet.h" 
   25 #include "ns3/socket.h" 
   26 #include "ns3/queue-disc.h" 
   40     .SetGroupName (
"TrafficControl")
 
   42     .AddAttribute (
"RootQueueDiscList", 
"The list of root queue discs associated to this Traffic Control layer.",
 
   46                    MakeObjectMapChecker<QueueDisc> ())
 
   82   : m_rootQueueDisc (rootQueueDisc),
 
   84     m_queueDiscsToWake (queueDiscsToWake),
 
   85     m_selectQueueCallback (selectQueueCallback)
 
  104       if (ndi->second.m_rootQueueDisc)
 
  109               for (uint8_t i = 0; i < devQueueIface->GetNTxQueues (); i++)
 
  112                   ndi->second.m_queueDiscsToWake.push_back (ndi->second.m_rootQueueDisc);
 
  117               NS_ASSERT_MSG (ndi->second.m_rootQueueDisc->GetNQueueDiscClasses () == devQueueIface->GetNTxQueues (),
 
  118                              "The number of child queue discs does not match the number of netdevice queues");
 
  119               for (uint8_t i = 0; i < devQueueIface->GetNTxQueues (); i++)
 
  122                                                                   ndi->second.m_rootQueueDisc->GetQueueDiscClass (i)->GetQueueDisc ()));
 
  123                   ndi->second.m_queueDiscsToWake.push_back (ndi->second.m_rootQueueDisc->GetQueueDiscClass (i)->GetQueueDisc ());
 
  128           ndi->second.m_rootQueueDisc->Initialize ();
 
  146       NS_LOG_DEBUG (
"The setup for this device has been already done.");
 
  152   device->AggregateObject (devQueueIface);
 
  156   if (devQueueIface->GetNTxQueues () == 0 && !devQueueIface->GetLateTxQueuesCreation ())
 
  158       devQueueIface->CreateTxQueues ();
 
  166                  << 
"  SetupDevice only can insert an entry in the m_netDevices map");
 
  169                         std::forward_as_tuple (device),
 
  187   NS_LOG_DEBUG (
"Handler for NetDevice: " << device << 
" registered for protocol " <<
 
  188                 protocolType << 
".");
 
  209   NS_ASSERT_MSG (ndi->second.m_rootQueueDisc == 0, 
"Cannot install a root queue disc on a " 
  210                   << 
"device already having one. Delete the existing queue disc first.");
 
  211   ndi->second.m_rootQueueDisc = qDisc;
 
  225   return ndi->second.m_rootQueueDisc;
 
  243                  << 
" installed on device " << device);
 
  246   ndi->second.m_rootQueueDisc = 0;
 
  247   ndi->second.m_queueDiscsToWake.clear ();
 
  263       Ptr<Node> node = this->GetObject<Node> ();
 
  286   NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
 
  290   for (ProtocolHandlerList::iterator i = 
m_handlers.begin ();
 
  294           || (i->device != 0 && i->device == device))
 
  297               || i->protocol == protocol)
 
  299               NS_LOG_DEBUG (
"Found handler for packet " << p << 
", protocol " <<
 
  300                             protocol << 
" and NetDevice " << device <<
 
  302               i->handler (device, p, protocol, from, to, packetType);
 
  310       NS_FATAL_ERROR (
"Handler for protocol " << p << 
" and device " << device <<
 
  311                       " not found. It isn't forwarded up; it dies here.");
 
  320   NS_LOG_DEBUG (
"Send packet to device " << device << 
" protocol number " <<
 
  321                 item->GetProtocol ());
 
  330   if (devQueueIface->GetNTxQueues () > 1)
 
  332       if (!ndi->second.m_selectQueueCallback.IsNull ())
 
  334           txq = ndi->second.m_selectQueueCallback (item);
 
  344   NS_ASSERT (txq < devQueueIface->GetNTxQueues ());
 
  346   if (ndi->second.m_rootQueueDisc == 0)
 
  350       if (!devQueueIface->GetTxQueue (txq)->IsStopped ())
 
  354           if (devQueueIface->GetNTxQueues () == 1)
 
  357               item->GetPacket ()->RemovePacketTag (priorityTag);
 
  359           device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
 
  366       item->SetTxQueueIndex (txq);
 
virtual void DeleteRootQueueDiscOnDevice(Ptr< NetDevice > device)
This method can be used to remove the root queue disc (and associated filters, classes and queues) in...
 
virtual void DoInitialize(void)
Initialize() implementation. 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device. 
 
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
Introspection did not find any typical Config paths. 
 
ProtocolHandlerList m_handlers
List of upper-layer handlers. 
 
bool promiscuous
true if it is a promiscuous handler 
 
virtual void DoInitialize(void)
Initialize() implementation. 
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
PacketType
Packet types are used as they are in Linux. 
 
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
 
virtual void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Called by NetDevices, incoming packet. 
 
uint16_t protocol
the protocol number 
 
a polymophic address class 
 
void SetNode(Ptr< Node > node)
Set node associated with this stack. 
 
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
 
indicates whether the socket has a priority set. 
 
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
 
Ptr< NetDevice > GetDevice(uint32_t index) const 
Retrieve the index-th NetDevice associated to this node. 
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
Network device transmission queue interface. 
 
std::vector< Ptr< QueueDisc > > QueueDiscVector
Typedef for queue disc vector. 
 
virtual ~TrafficControlLayer()
 
Ptr< NetDevice > device
the NetDevice 
 
uint32_t GetNDevices(void) const 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Information to store for each device. 
 
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission. 
 
Ptr< Node > m_node
The node this TrafficControlLayer object is aggregated to. 
 
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const 
This method can be used to get the root queue disc installed on a device. 
 
std::map< Ptr< NetDevice >, NetDeviceInfo > m_netDevices
Map storing the required information for each device with a queue disc installed. ...
 
virtual void SetupDevice(Ptr< NetDevice > device)
Perform the operations that the traffic control layer needs to do when an IPv4/v6 interface is added ...
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
uint32_t GetNDevices(void) const 
Required by the object map accessor. 
 
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector. 
 
Node::ProtocolHandler handler
the protocol handler 
 
A base class which provides memory management and object aggregation. 
 
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated. 
 
virtual TypeId GetInstanceTypeId(void) const 
Get the type ID for the instance. 
 
Container for a set of ns3::Object pointers. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
TrafficControlLayer()
Constructor. 
 
a unique identifier for an interface. 
 
void RegisterProtocolHandler(Node::ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device)
Register an IN handler. 
 
Ptr< QueueDisc > GetRootQueueDiscOnDeviceByIndex(uint32_t index) const 
Required by the object map accessor. 
 
TypeId SetParent(TypeId tid)
Set the parent TypeId.