22 #include "ns3/object-vector.h"
23 #include "ns3/packet.h"
24 #include "ns3/queue-disc.h"
37 .SetGroupName (
"TrafficControl")
39 .AddAttribute (
"RootQueueDiscList",
"The list of root queue discs associated to this Traffic Control layer.",
42 MakeObjectVectorChecker<QueueDisc> ())
82 device->Initialize ();
89 devQueueIface->SetQueueDiscInstalled (
true);
94 for (uint32_t i = 0; i < devQueueIface->GetTxQueuesN (); i++)
103 "The number of child queue discs does not match the number of netdevice queues");
104 for (uint32_t i = 0; i < devQueueIface->GetTxQueuesN (); i++)
108 qdMap->second.second.push_back (
m_rootQueueDiscs[j]->GetQueueDiscClass (i)->GetQueueDisc ());
127 NS_LOG_DEBUG (
"The setup for this device has been already done.");
133 device->AggregateObject (devQueueIface);
137 "This is a bug: SetupDevice should be called only once per device");
156 NS_LOG_DEBUG (
"Handler for NetDevice: " << device <<
" registered for protocol " <<
157 protocolType <<
".");
166 NS_ASSERT_MSG (index < m_node->GetNDevices (),
"The provided device does not belong to"
167 <<
" the node which this TrafficControlLayer object is aggregated to" );
174 <<
"device already having one. Delete the existing queue disc first.");
185 NS_ASSERT_MSG (index < m_node->GetNDevices (),
"The provided device does not belong to"
186 <<
" the node which this TrafficControlLayer object is aggregated to" );
200 NS_ASSERT_MSG (index < m_node->GetNDevices (),
"The provided device does not belong to"
201 <<
" the node which this TrafficControlLayer object is aggregated to" );
204 <<
" installed on device " << device);
223 Ptr<Node> node = this->GetObject<Node> ();
248 NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
252 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
256 || (i->device != 0 && i->device == device))
259 || i->protocol == protocol)
261 NS_LOG_DEBUG (
"Found handler for packet " << p <<
", protocol " <<
262 protocol <<
" and NetDevice " << device <<
264 i->handler (device, p, protocol, from, to, packetType);
272 NS_FATAL_ERROR (
"Handler for protocol " << p <<
" and device " << device <<
273 " not found. It isn't forwarded up; it dies here.");
282 NS_LOG_DEBUG (
"Send packet to device " << device <<
" protocol number " <<
283 item->GetProtocol ());
291 uint8_t txq = devQueueIface->GetSelectedQueue (item);
292 NS_ASSERT (txq < devQueueIface->GetTxQueuesN ());
294 if (qdMap->second.second.empty ())
298 if (!devQueueIface->GetTxQueue (txq)->IsStopped ())
301 device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
308 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.
Traffic control layer definition.
ProtocolHandlerList m_handlers
List of upper-layer handlers.
bool promiscuous
true if it is a promiscuous handler
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
#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
std::pair< Ptr< NetDeviceQueueInterface >, QueueDiscVector > NetDeviceInfo
Typedef for queue disc vector.
uint32_t GetDeviceIndex(Ptr< NetDevice > device)
Lookup a given Ptr in the node's list of devices.
a polymophic address class
void SetNode(Ptr< Node > node)
Set node associated with this stack.
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.
QueueDiscVector m_rootQueueDiscs
This vector stores the root queue discs installed on all the devices of the node. ...
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 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.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device)
This method can be used to get the root queue disc installed on a device.
Node::ProtocolHandler handler
the protocol handler
std::map< Ptr< NetDevice >, NetDeviceInfo > m_netDeviceQueueToQueueDiscMap
This map plays the role of the qdisc field of the netdev_queue struct in Linux.
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.
TypeId SetParent(TypeId tid)
Set the parent TypeId.