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/traced-callback.h"
26#include "ns3/node.h"
27#include "ns3/queue-item.h"
28#include <map>
29#include <vector>
30
31namespace ns3 {
32
33class Packet;
34class QueueDisc;
35class NetDeviceQueueInterface;
36
91{
92public:
97 static TypeId GetTypeId (void);
98
103 virtual TypeId GetInstanceTypeId (void) const;
104
109
110 virtual ~TrafficControlLayer ();
111
112 // Delete copy constructor and assignment operator to avoid misuse
115
134 uint16_t protocolType,
135 Ptr<NetDevice> device);
136
138 typedef std::vector<Ptr<QueueDisc> > QueueDiscVector;
139
147 virtual void ScanDevices (void);
148
155 virtual void SetRootQueueDiscOnDevice (Ptr<NetDevice> device, Ptr<QueueDisc> qDisc);
156
164
171 virtual void DeleteRootQueueDiscOnDevice (Ptr<NetDevice> device);
172
177 void SetNode (Ptr<Node> node);
178
192 virtual void Receive (Ptr<NetDevice> device, Ptr<const Packet> p,
193 uint16_t protocol, const Address &from,
194 const Address &to, NetDevice::PacketType packetType);
201 virtual void Send (Ptr<NetDevice> device, Ptr<QueueDiscItem> item);
202
203protected:
204
205 virtual void DoDispose (void);
206 virtual void DoInitialize (void);
207 virtual void NotifyNewAggregate (void);
208
209private:
217 uint16_t protocol;
219 };
220
225 {
229 };
230
232 typedef std::vector<struct ProtocolHandlerEntry> ProtocolHandlerList;
233
238 uint32_t GetNDevices (void) const;
245
249 std::map<Ptr<NetDevice>, NetDeviceInfo> m_netDevices;
251
258};
259
260} // namespace ns3
261
262#endif // TRAFFICCONTROLLAYER_H
a polymophic address class
Definition: address.h:91
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
A base class which provides memory management and object aggregation.
Definition: object.h:88
Forward calls to a chain of Callback.
Introspection did not find any typical Config paths.
Ptr< QueueDisc > GetRootQueueDiscOnDeviceByIndex(uint32_t index) const
Required by the object map accessor.
virtual void ScanDevices(void)
Collect information needed to determine how to handle packets destined to each of the NetDevices of t...
TrafficControlLayer(TrafficControlLayer const &)=delete
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< struct ProtocolHandlerEntry > ProtocolHandlerList
Typedef for protocol handlers container.
ProtocolHandlerList m_handlers
List of upper-layer handlers.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID for the instance.
uint32_t GetNDevices(void) const
Required by the object map accessor.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Node > m_node
The node this TrafficControlLayer object is aggregated to.
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 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.
virtual void DoDispose(void)
Destructor implementation.
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.
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
virtual void DoInitialize(void)
Initialize() implementation.
TrafficControlLayer & operator=(TrafficControlLayer const &)=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