A Discrete-Event Network Simulator
API
traffic-control-layer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com>
3  * 2016 Stefano Avallone <stavallo@unina.it>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 #ifndef TRAFFICCONTROLLAYER_H
19 #define TRAFFICCONTROLLAYER_H
20 
21 #include "ns3/address.h"
22 #include "ns3/net-device.h"
23 #include "ns3/node.h"
24 #include "ns3/object.h"
25 #include "ns3/queue-item.h"
26 #include "ns3/traced-callback.h"
27 
28 #include <map>
29 #include <vector>
30 
31 namespace ns3
32 {
33 
34 class Packet;
35 class QueueDisc;
36 class NetDeviceQueueInterface;
37 
93 {
94  public:
99  static TypeId GetTypeId();
100 
105  TypeId GetInstanceTypeId() const override;
106 
111 
112  ~TrafficControlLayer() override;
113 
114  // Delete copy constructor and assignment operator to avoid misuse
117 
136  uint16_t protocolType,
137  Ptr<NetDevice> device);
138 
140  typedef std::vector<Ptr<QueueDisc>> QueueDiscVector;
141 
149  virtual void ScanDevices();
150 
157  virtual void SetRootQueueDiscOnDevice(Ptr<NetDevice> device, Ptr<QueueDisc> qDisc);
158 
166 
173  virtual void DeleteRootQueueDiscOnDevice(Ptr<NetDevice> device);
174 
179  void SetNode(Ptr<Node> node);
180 
194  virtual void Receive(Ptr<NetDevice> device,
196  uint16_t protocol,
197  const Address& from,
198  const Address& to,
199  NetDevice::PacketType packetType);
206  virtual void Send(Ptr<NetDevice> device, Ptr<QueueDiscItem> item);
207 
208  protected:
209  void DoDispose() override;
210  void DoInitialize() override;
211  void NotifyNewAggregate() override;
212 
213  private:
219  {
222  uint16_t protocol;
223  bool promiscuous;
224  };
225 
230  {
234  };
235 
237  typedef std::vector<ProtocolHandlerEntry> ProtocolHandlerList;
238 
243  uint32_t GetNDevices() const;
249  Ptr<QueueDisc> GetRootQueueDiscOnDeviceByIndex(uint32_t index) const;
250 
254  std::map<Ptr<NetDevice>, NetDeviceInfo> m_netDevices;
256 
263 };
264 
265 } // namespace ns3
266 
267 #endif // TRAFFICCONTROLLAYER_H
a polymophic address class
Definition: address.h:101
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the type ID for the instance.
Ptr< QueueDisc > GetRootQueueDiscOnDeviceByIndex(uint32_t index) const
Required by the object map accessor.
void DoInitialize() override
Initialize() implementation.
void DoDispose() override
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_dropped
The trace source fired when the Traffic Control layer drops a packet because no queue disc is install...
std::vector< ProtocolHandlerEntry > ProtocolHandlerList
Typedef for protocol handlers container.
ProtocolHandlerList m_handlers
List of upper-layer handlers.
Ptr< Node > m_node
The node this TrafficControlLayer object is aggregated to.
uint32_t GetNDevices() const
Required by the object map accessor.
std::map< Ptr< NetDevice >, NetDeviceInfo > m_netDevices
Map storing the required information for each device with a queue disc installed.
virtual void DeleteRootQueueDiscOnDevice(Ptr< NetDevice > device)
This method can be used to remove the root queue disc (and associated filters, classes and queues) in...
std::vector< Ptr< QueueDisc > > QueueDiscVector
Typedef for queue disc vector.
virtual void ScanDevices()
Collect information needed to determine how to handle packets destined to each of the NetDevices of t...
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
TrafficControlLayer & operator=(const TrafficControlLayer &)=delete
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.
TrafficControlLayer(const TrafficControlLayer &)=delete
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device.
void RegisterProtocolHandler(Node::ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device)
Register an IN handler.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Information to store for each device.
Ptr< NetDeviceQueueInterface > m_ndqi
the netdevice queue interface
Ptr< QueueDisc > m_rootQueueDisc
the root queue disc on the device
QueueDiscVector m_queueDiscsToWake
the vector of queue discs to wake
Protocol handler entry.
Node::ProtocolHandler handler
the protocol handler
bool promiscuous
true if it is a promiscuous handler
uint16_t protocol
the protocol number
Ptr< NetDevice > device
the NetDevice