22 #include "ns3/object-map.h"
23 #include "ns3/packet.h"
24 #include "ns3/socket.h"
25 #include "ns3/queue-disc.h"
38 .SetGroupName (
"TrafficControl")
40 .AddAttribute (
"RootQueueDiscList",
"The list of root queue discs associated to this Traffic Control layer.",
44 MakeObjectMapChecker<QueueDisc> ())
78 if (ndi->second.rootQueueDisc)
86 for (uint32_t i = 0; i < devQueueIface->GetNTxQueues (); i++)
89 ndi->second.queueDiscsToWake.push_back (ndi->second.rootQueueDisc);
94 NS_ASSERT_MSG (ndi->second.rootQueueDisc->GetNQueueDiscClasses () == devQueueIface->GetNTxQueues (),
95 "The number of child queue discs does not match the number of netdevice queues");
96 for (uint32_t i = 0; i < devQueueIface->GetNTxQueues (); i++)
99 ndi->second.rootQueueDisc->GetQueueDiscClass (i)->GetQueueDisc ()));
100 ndi->second.queueDiscsToWake.push_back (ndi->second.rootQueueDisc->GetQueueDiscClass (i)->GetQueueDisc ());
105 ndi->second.rootQueueDisc->Initialize ();
123 NS_LOG_DEBUG (
"The setup for this device has been already done.");
129 device->AggregateObject (devQueueIface);
134 devQueueIface->CreateTxQueues ();
141 <<
" SetupDevice only can insert an entry in the m_netDevices map");
161 NS_LOG_DEBUG (
"Handler for NetDevice: " << device <<
" registered for protocol " <<
162 protocolType <<
".");
183 NS_ASSERT_MSG (ndi->second.rootQueueDisc == 0,
"Cannot install a root queue disc on a "
184 <<
"device already having one. Delete the existing queue disc first.");
185 ndi->second.rootQueueDisc = qDisc;
199 return ndi->second.rootQueueDisc;
217 <<
" installed on device " << device);
220 ndi->second.rootQueueDisc = 0;
221 ndi->second.queueDiscsToWake.clear ();
237 Ptr<Node> node = this->GetObject<Node> ();
260 NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
264 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
268 || (i->device != 0 && i->device == device))
271 || i->protocol == protocol)
273 NS_LOG_DEBUG (
"Found handler for packet " << p <<
", protocol " <<
274 protocol <<
" and NetDevice " << device <<
276 i->handler (device, p, protocol, from, to, packetType);
284 NS_FATAL_ERROR (
"Handler for protocol " << p <<
" and device " << device <<
285 " not found. It isn't forwarded up; it dies here.");
294 NS_LOG_DEBUG (
"Send packet to device " << device <<
" protocol number " <<
295 item->GetProtocol ());
304 if (devQueueIface->GetNTxQueues () > 1)
306 if (!ndi->second.selectQueueCallback.IsNull ())
308 txq = ndi->second.selectQueueCallback (item);
318 NS_ASSERT (txq < devQueueIface->GetNTxQueues ());
320 if (ndi->second.rootQueueDisc == 0)
324 if (!devQueueIface->GetTxQueue (txq)->IsStopped ())
328 if (devQueueIface->GetNTxQueues () == 1)
331 item->GetPacket ()->RemovePacketTag (priorityTag);
333 device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
340 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.
Smart pointer class similar to boost::intrusive_ptr.
#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.
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.
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.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
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.
Information to store for each device.
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.