A Discrete-Event Network Simulator
API
traffic-control-layer.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Natale Patriciello <natale.patriciello@gmail.com>
4  * 2016 Stefano Avallone <stavallo@unina.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 #ifndef TRAFFICCONTROLLAYER_H
20 #define TRAFFICCONTROLLAYER_H
21 
22 #include "ns3/object.h"
23 #include "ns3/address.h"
24 #include "ns3/net-device.h"
25 #include "ns3/node.h"
26 #include "queue-disc.h"
27 #include <map>
28 #include <vector>
29 
30 namespace ns3 {
31 
32 class Packet;
33 class QueueDiscItem;
34 
89 {
90 public:
95  static TypeId GetTypeId (void);
96 
101  virtual TypeId GetInstanceTypeId (void) const;
102 
107 
126  uint16_t protocolType,
127  Ptr<NetDevice> device);
128 
130  typedef std::vector<Ptr<QueueDisc> > QueueDiscVector;
131 
139  virtual void SetupDevice (Ptr<NetDevice> device);
140 
147  virtual void SetRootQueueDiscOnDevice (Ptr<NetDevice> device, Ptr<QueueDisc> qDisc);
148 
156 
163  virtual void DeleteRootQueueDiscOnDevice (Ptr<NetDevice> device);
164 
169  void SetNode (Ptr<Node> node);
170 
184  virtual void Receive (Ptr<NetDevice> device, Ptr<const Packet> p,
185  uint16_t protocol, const Address &from,
186  const Address &to, NetDevice::PacketType packetType);
193  virtual void Send (Ptr<NetDevice> device, Ptr<QueueDiscItem> item);
194 
197 
198 protected:
199 
200  virtual void DoDispose (void);
201  virtual void DoInitialize (void);
202  virtual void NotifyNewAggregate (void);
203 
204 private:
222  uint16_t protocol;
223  bool promiscuous;
224  };
225 
229  struct NetDeviceInfo {
232  QueueDiscVector queueDiscsToWake;
233  SelectQueueCallback selectQueueCallback;
234  };
235 
237  typedef std::vector<struct ProtocolHandlerEntry> ProtocolHandlerList;
238 
243  uint32_t GetNDevices (void) const;
249  Ptr<QueueDisc> GetRootQueueDiscOnDeviceByIndex (uint32_t index) const;
250 
254  std::map<Ptr<NetDevice>, NetDeviceInfo> m_netDevices;
255  ProtocolHandlerList m_handlers;
256 };
257 
258 } // namespace ns3
259 
260 #endif // TRAFFICCONTROLLAYER_H
virtual void DeleteRootQueueDiscOnDevice(Ptr< NetDevice > device)
This method can be used to remove the root queue disc (and associated filters, classes and queues) in...
Callback< uint8_t, Ptr< QueueItem > > SelectQueueCallback
Callback invoked to determine the tx queue selected for a given packet.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device.
Introspection did not find any typical Config paths.
ProtocolHandlerList m_handlers
List of upper-layer handlers.
Ptr< QueueDisc > rootQueueDisc
the root queue disc on the device
bool promiscuous
true if it is a promiscuous handler
virtual void DoInitialize(void)
Initialize() implementation.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:606
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
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
Definition: address.h:90
void SetNode(Ptr< Node > node)
Set node associated with this stack.
Ptr< NetDeviceQueueInterface > ndqi
the netdevice queue interface
std::vector< Ptr< QueueDisc > > QueueDiscVector
Typedef for queue disc vector.
Ptr< NetDevice > device
the NetDevice
std::vector< struct ProtocolHandlerEntry > ProtocolHandlerList
Typedef for protocol handlers container.
QueueDiscVector queueDiscsToWake
the vector of queue discs to wake
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the type ID.
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.
TrafficControlLayer & operator=(TrafficControlLayer const &)
Assignment operator Disable default implementation to avoid misuse.
std::map< Ptr< NetDevice >, NetDeviceInfo > m_netDevices
Map storing the required information for each device with a queue disc installed. ...
Protocol handler entry.
virtual void SetupDevice(Ptr< NetDevice > device)
Perform the operations that the traffic control layer needs to do when an IPv4/v6 interface is added ...
uint32_t GetNDevices(void) const
Required by the object map accessor.
Information to store for each device.
Node::ProtocolHandler handler
the protocol handler
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual TypeId GetInstanceTypeId(void) const
Get the type ID for the instance.
virtual void DoDispose(void)
Destructor implementation.
SelectQueueCallback selectQueueCallback
the select queue callback
a unique identifier for an interface.
Definition: type-id.h:58
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.