A Discrete-Event Network Simulator
API
traffic-control-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Universita' degli Studi di Napoli Federico II
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  * Author: Stefano Avallone <stavallo@unina.it>
19  */
20 #ifndef TRAFFIC_CONTROL_HELPER_H
21 #define TRAFFIC_CONTROL_HELPER_H
22 
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include "ns3/object-factory.h"
27 #include "ns3/net-device-container.h"
28 #include "ns3/queue-disc-container.h"
29 
30 namespace ns3 {
31 
32 class QueueDisc;
33 
41 {
42 public:
49 
50  virtual ~QueueDiscFactory () {}
51 
57  void AddInternalQueue (ObjectFactory factory);
58 
64  void AddPacketFilter (ObjectFactory factory);
65 
72  uint16_t AddQueueDiscClass (ObjectFactory factory);
73 
80  void SetChildQueueDisc (uint16_t classId, uint16_t handle);
81 
88  Ptr<QueueDisc> CreateQueueDisc (const std::vector<Ptr<QueueDisc> > & queueDiscs);
89 
90 private:
97 
101  std::vector<ObjectFactory> m_internalQueuesFactory;
103  std::vector<ObjectFactory> m_packetFiltersFactory;
105  std::vector<ObjectFactory> m_queueDiscClassesFactory;
107  std::map<uint16_t, uint16_t> m_classIdChildHandleMap;
108 };
109 
110 
121 {
122 public:
128  virtual ~TrafficControlHelper () {}
129 
136  static TrafficControlHelper Default (void);
137 
176  uint16_t SetRootQueueDisc (std::string type,
177  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
178  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
179  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
180  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
181  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
182  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
183  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
184  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
185  std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
186  std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
187  std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
188  std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
189  std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
190  std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
191  std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
192 
217  void AddInternalQueues (uint16_t handle, uint16_t count, std::string type,
218  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
219  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
220  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
221  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
222  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
223  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
224  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
225  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
226 
250  void AddPacketFilter (uint16_t handle, std::string type,
251  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
252  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
253  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
254  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
255  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
256  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
257  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
258  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
259 
260  typedef std::vector<uint16_t> ClassIdList;
261 
287  ClassIdList AddQueueDiscClasses (uint16_t handle, uint16_t count, std::string type,
288  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
289  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
290  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
291  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
292  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
293  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
294  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
295  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
296 
337  uint16_t AddChildQueueDisc (uint16_t handle, uint16_t classId, std::string type,
338  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
339  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
340  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
341  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
342  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
343  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
344  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
345  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
346  std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
347  std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
348  std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
349  std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
350  std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
351  std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
352  std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
353 
354  typedef std::vector<uint16_t> HandleList;
355 
396  HandleList AddChildQueueDiscs (uint16_t handle, const ClassIdList &classes, std::string type,
397  std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
398  std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
399  std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
400  std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
401  std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
402  std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
403  std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
404  std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
405  std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
406  std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
407  std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
408  std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
409  std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
410  std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
411  std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
412 
424 
436 
443  void Uninstall (NetDeviceContainer c);
444 
451  void Uninstall (Ptr<NetDevice> d);
452 
453 private:
455  std::vector<QueueDiscFactory> m_queueDiscFactory;
457  std::vector<Ptr<QueueDisc> > m_queueDiscs;
458 };
459 
460 } // namespace ns3
461 
462 #endif /* TRAFFIC_CONTROL_HELPER_H */
QueueDiscContainer Install(NetDeviceContainer c)
QueueDiscFactory()
Default constructor.
Hold a value for an Attribute.
Definition: attribute.h:68
std::vector< ObjectFactory > m_queueDiscClassesFactory
Vector of factories to create queue disc classes.
std::vector< Ptr< QueueDisc > > m_queueDiscs
Vector of all the created queue discs.
void Uninstall(NetDeviceContainer c)
ClassIdList AddQueueDiscClasses(uint16_t handle, uint16_t count, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue())
Helper function used to add the given number of queue disc classes (of the given type and with the gi...
void AddPacketFilter(uint16_t handle, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue())
Helper function used to add a packet filter (of the given type and with the given attributes) to the ...
void SetChildQueueDisc(uint16_t classId, uint16_t handle)
Set the (child) queue disc to attach to a class.
Holds a vector of ns3::QueueDisc pointers.
ObjectFactory m_queueDiscFactory
Factory to create this queue disc.
TrafficControlHelper()
Create a TrafficControlHelper to make life easier when creating QueueDisc objects.
A class for an empty attribute value.
Definition: attribute.h:234
holds a vector of ns3::NetDevice pointers
Build a set of QueueDisc objects.
Ptr< QueueDisc > CreateQueueDisc(const std::vector< Ptr< QueueDisc > > &queueDiscs)
Create a queue disc with the currently stored configuration.
HandleList AddChildQueueDiscs(uint16_t handle, const ClassIdList &classes, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to attach a child queue disc (of the given type and with the given attributes) t...
uint16_t AddChildQueueDisc(uint16_t handle, uint16_t classId, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to attach a child queue disc (of the given type and with the given attributes) t...
std::vector< uint16_t > ClassIdList
uint16_t AddQueueDiscClass(ObjectFactory factory)
Add a factory to create a queue disc class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
std::vector< ObjectFactory > m_internalQueuesFactory
Vector of factories to create internal queues.
void AddInternalQueue(ObjectFactory factory)
Add a factory to create an internal queue.
void AddPacketFilter(ObjectFactory factory)
Add a factory to create a packet filter.
Instantiate subclasses of ns3::Object.
std::vector< ObjectFactory > m_packetFiltersFactory
Vector of factories to create packet filters.
std::vector< QueueDiscFactory > m_queueDiscFactory
QueueDisc factory, stores the configuration of all the queue discs.
void AddInternalQueues(uint16_t handle, uint16_t count, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue())
Helper function used to add the given number of internal queues (of the given type and with the given...
std::map< uint16_t, uint16_t > m_classIdChildHandleMap
Map storing the associations between class IDs and child queue disc handles.
This class stores object factories required to create a queue disc and all of its components (packet ...
static TrafficControlHelper Default(void)
std::vector< uint16_t > HandleList