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 "ns3/queue-item.h"
27 #include <map>
28 #include <vector>
29 
30 namespace ns3 {
31 
32 class Packet;
33 class QueueDisc;
34 class NetDeviceQueueInterface;
35 
90 {
91 public:
96  static TypeId GetTypeId (void);
97 
102  virtual TypeId GetInstanceTypeId (void) const;
103 
108 
109  virtual ~TrafficControlLayer ();
110 
129  uint16_t protocolType,
130  Ptr<NetDevice> device);
131 
133  typedef std::vector<Ptr<QueueDisc> > QueueDiscVector;
134 
142  virtual void ScanDevices (void);
143 
150  virtual void SetRootQueueDiscOnDevice (Ptr<NetDevice> device, Ptr<QueueDisc> qDisc);
151 
159 
166  virtual void DeleteRootQueueDiscOnDevice (Ptr<NetDevice> device);
167 
172  void SetNode (Ptr<Node> node);
173 
187  virtual void Receive (Ptr<NetDevice> device, Ptr<const Packet> p,
188  uint16_t protocol, const Address &from,
189  const Address &to, NetDevice::PacketType packetType);
196  virtual void Send (Ptr<NetDevice> device, Ptr<QueueDiscItem> item);
197 
198 protected:
199 
200  virtual void DoDispose (void);
201  virtual void DoInitialize (void);
202  virtual void NotifyNewAggregate (void);
203 
204 private:
223  uint16_t protocol;
224  bool promiscuous;
225  };
226 
231  {
235  };
236 
238  typedef std::vector<struct ProtocolHandlerEntry> ProtocolHandlerList;
239 
244  uint32_t GetNDevices (void) const;
250  Ptr<QueueDisc> GetRootQueueDiscOnDeviceByIndex (uint32_t index) const;
251 
255  std::map<Ptr<NetDevice>, NetDeviceInfo> m_netDevices;
257 };
258 
259 } // namespace ns3
260 
261 #endif // TRAFFICCONTROLLAYER_H
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::TrafficControlLayer::NetDeviceInfo::m_rootQueueDisc
Ptr< QueueDisc > m_rootQueueDisc
the root queue disc on the device
Definition: traffic-control-layer.h:232
ns3::TrafficControlLayer::m_node
Ptr< Node > m_node
The node this TrafficControlLayer object is aggregated to.
Definition: traffic-control-layer.h:253
ns3::TrafficControlLayer::m_netDevices
std::map< Ptr< NetDevice >, NetDeviceInfo > m_netDevices
Map storing the required information for each device with a queue disc installed.
Definition: traffic-control-layer.h:255
ns3::TrafficControlLayer::ProtocolHandlerEntry::protocol
uint16_t protocol
the protocol number
Definition: traffic-control-layer.h:223
ns3::TrafficControlLayer::SetRootQueueDiscOnDevice
virtual void SetRootQueueDiscOnDevice(Ptr< NetDevice > device, Ptr< QueueDisc > qDisc)
This method can be used to set the root queue disc installed on a device.
Definition: traffic-control-layer.cc:202
ns3::TrafficControlLayer::NotifyNewAggregate
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: traffic-control-layer.cc:287
ns3::TrafficControlLayer::TrafficControlLayer
TrafficControlLayer()
Constructor.
Definition: traffic-control-layer.cc:57
ns3::Callback< void, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, NetDevice::PacketType >
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TrafficControlLayer::Receive
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.
Definition: traffic-control-layer.cc:311
ns3::TrafficControlLayer::GetRootQueueDiscOnDeviceByIndex
Ptr< QueueDisc > GetRootQueueDiscOnDeviceByIndex(uint32_t index) const
Required by the object map accessor.
Definition: traffic-control-layer.cc:238
ns3::TrafficControlLayer::GetNDevices
uint32_t GetNDevices(void) const
Required by the object map accessor.
Definition: traffic-control-layer.cc:304
ns3::TrafficControlLayer::NetDeviceInfo
Information to store for each device.
Definition: traffic-control-layer.h:231
ns3::TrafficControlLayer::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: traffic-control-layer.cc:69
ns3::TrafficControlLayer::ScanDevices
virtual void ScanDevices(void)
Collect information needed to determine how to handle packets destined to each of the NetDevices of t...
Definition: traffic-control-layer.cc:116
ns3::TrafficControlLayer::TrafficControlLayer
TrafficControlLayer(TrafficControlLayer const &)
Copy constructor Disable default implementation to avoid misuse.
ns3::TrafficControlLayer::NetDeviceInfo::m_queueDiscsToWake
QueueDiscVector m_queueDiscsToWake
the vector of queue discs to wake
Definition: traffic-control-layer.h:234
ns3::Ptr< NetDevice >
ns3::TrafficControlLayer::ProtocolHandlerEntry
Protocol handler entry.
Definition: traffic-control-layer.h:220
ns3::TrafficControlLayer::SetNode
void SetNode(Ptr< Node > node)
Set node associated with this stack.
Definition: traffic-control-layer.cc:280
ns3::TrafficControlLayer::ProtocolHandlerEntry::promiscuous
bool promiscuous
true if it is a promiscuous handler
Definition: traffic-control-layer.h:224
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::TrafficControlLayer::~TrafficControlLayer
virtual ~TrafficControlLayer()
Definition: traffic-control-layer.cc:63
ns3::TrafficControlLayer::operator=
TrafficControlLayer & operator=(TrafficControlLayer const &)
Assignment operator.
ns3::TrafficControlLayer
Introspection did not find any typical Config paths.
Definition: traffic-control-layer.h:90
ns3::TrafficControlLayer::ProtocolHandlerList
std::vector< struct ProtocolHandlerEntry > ProtocolHandlerList
Typedef for protocol handlers container.
Definition: traffic-control-layer.h:238
ns3::TrafficControlLayer::Send
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission.
Definition: traffic-control-layer.cc:342
ns3::TrafficControlLayer::ProtocolHandlerEntry::handler
Node::ProtocolHandler handler
the protocol handler
Definition: traffic-control-layer.h:221
ns3::TrafficControlLayer::GetRootQueueDiscOnDevice
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
Definition: traffic-control-layer.cc:224
ns3::TrafficControlLayer::QueueDiscVector
std::vector< Ptr< QueueDisc > > QueueDiscVector
Typedef for queue disc vector.
Definition: traffic-control-layer.h:133
ns3::TrafficControlLayer::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the type ID for the instance.
Definition: traffic-control-layer.cc:52
ns3::TrafficControlLayer::DeleteRootQueueDiscOnDevice
virtual void DeleteRootQueueDiscOnDevice(Ptr< NetDevice > device)
This method can be used to remove the root queue disc (and associated filters, classes and queues) in...
Definition: traffic-control-layer.cc:245
ns3::NetDevice::PacketType
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
ns3::TrafficControlLayer::m_handlers
ProtocolHandlerList m_handlers
List of upper-layer handlers.
Definition: traffic-control-layer.h:256
ns3::TrafficControlLayer::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: traffic-control-layer.cc:36
ns3::TrafficControlLayer::NetDeviceInfo::m_ndqi
Ptr< NetDeviceQueueInterface > m_ndqi
the netdevice queue interface
Definition: traffic-control-layer.h:233
ns3::TrafficControlLayer::RegisterProtocolHandler
void RegisterProtocolHandler(Node::ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device)
Register an IN handler.
Definition: traffic-control-layer.cc:98
ns3::TrafficControlLayer::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: traffic-control-layer.cc:79
ns3::TrafficControlLayer::ProtocolHandlerEntry::device
Ptr< NetDevice > device
the NetDevice
Definition: traffic-control-layer.h:222