Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ns3: gosh this code is ugly
[simgrid.git] / src / surf / ns3 / my-point-to-point-helper.h
1 /* Copyright (c) 2011, 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 /*
8  * Copyright (c) 2008 INRIA
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation;
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
24  */
25 #ifndef POINT_TO_POINT_HELPER_H
26 #define POINT_TO_POINT_HELPER_H
27
28 #include <string>
29
30 #include "ns3/object-factory.h"
31 #include "ns3/net-device-container.h"
32 #include "ns3/node-container.h"
33 #include "ns3/deprecated.h"
34
35 #include "ns3/trace-helper.h"
36
37 #include "ns3_interface.h"
38
39 namespace ns3 {
40
41 class Queue;
42 class NetDevice;
43 class Node;
44
45 /**
46  * \brief Build a set of PointToPointNetDevice objects
47  *
48  * Normally we eschew multiple inheritance, however, the classes 
49  * PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are
50  * "mixins".
51  */
52 class MyPointToPointHelper : public PcapHelperForDevice, public AsciiTraceHelperForDevice
53 {
54 public:
55   /**
56    * Create a MyPointToPointHelper to make life easier when creating point to
57    * point networks.
58    */
59   MyPointToPointHelper ();
60   virtual ~MyPointToPointHelper () {}
61
62   /**
63    * Each point to point net device must have a queue to pass packets through.
64    * This method allows one to set the type of the queue that is automatically
65    * created when the device is created and attached to a node.
66    *
67    * \param type the type of queue
68    * \param n1 the name of the attribute to set on the queue
69    * \param v1 the value of the attribute to set on the queue
70    * \param n2 the name of the attribute to set on the queue
71    * \param v2 the value of the attribute to set on the queue
72    * \param n3 the name of the attribute to set on the queue
73    * \param v3 the value of the attribute to set on the queue
74    * \param n4 the name of the attribute to set on the queue
75    * \param v4 the value of the attribute to set on the queue
76    *
77    * Set the type of queue to create and associated to each
78    * PointToPointNetDevice created through MyPointToPointHelper::Install.
79    */
80   void SetQueue (std::string type,
81                  std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
82                  std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
83                  std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
84                  std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
85                  std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
86                  std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
87                  std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
88                  std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue ());
89
90   /**
91    * Set an attribute value to be propagated to each NetDevice created by the
92    * helper.
93    *
94    * \param name the name of the attribute to set
95    * \param value the value of the attribute to set
96    *
97    * Set these attributes on each ns3::PointToPointNetDevice created
98    * by MyPointToPointHelper::Install
99    */
100   void SetDeviceAttribute (std::string name, const AttributeValue &value);
101
102   /**
103    * Set an attribute value to be propagated to each Channel created by the
104    * helper.
105    *
106    * \param name the name of the attribute to set
107    * \param value the value of the attribute to set
108    *
109    * Set these attribute on each ns3::PointToPointChannel created
110    * by MyPointToPointHelper::Install
111    */
112   void SetChannelAttribute (std::string name, const AttributeValue &value);
113
114   /**
115    * \param c a set of nodes
116    *
117    * This method creates a ns3::PointToPointChannel with the
118    * attributes configured by MyPointToPointHelper::SetChannelAttribute,
119    * then, for each node in the input container, we create a 
120    * ns3::PointToPointNetDevice with the requested attributes, 
121    * a queue for this ns3::NetDevice, and associate the resulting 
122    * ns3::NetDevice with the ns3::Node and ns3::PointToPointChannel.
123    */
124   NetDeviceContainer Install (NodeContainer c);
125
126   /**
127    * \param a first node
128    * \param b second node
129    *
130    * Saves you from having to construct a temporary NodeContainer. 
131    * Also, if MPI is enabled, for distributed simulations, 
132    * appropriate remote point-to-point channels are created.
133    */
134   NetDeviceContainer Install (Ptr<Node> a, Ptr<Node> b);
135
136   /**
137    * \param a first node
138    * \param b second node
139    *
140    * Saves you from having to construct a temporary NodeContainer.
141    * Also, if MPI is enabled, for distributed simulations,
142    * appropriate remote point-to-point channels are created.
143    */
144   NetDeviceContainer Install (Ptr<Node> a, e_ns3_network_element_type_t type_a, Ptr<Node> b, e_ns3_network_element_type_t type_b);
145
146   /**
147    * \param a first node
148    * \param bName name of second node
149    *
150    * Saves you from having to construct a temporary NodeContainer.
151    */
152   NetDeviceContainer Install (Ptr<Node> a, std::string bName);
153
154   /**
155    * \param aName Name of first node
156    * \param b second node
157    *
158    * Saves you from having to construct a temporary NodeContainer.
159    */
160   NetDeviceContainer Install (std::string aName, Ptr<Node> b);
161
162   /**
163    * \param aNode Name of first node
164    * \param bNode Name of second node
165    *
166    * Saves you from having to construct a temporary NodeContainer.
167    */
168   NetDeviceContainer Install (std::string aNode, std::string bNode);
169
170 private:
171   /**
172    * \brief Enable pcap output the indicated net device.
173    *
174    * NetDevice-specific implementation mechanism for hooking the trace and
175    * writing to the trace file.
176    *
177    * \param prefix Filename prefix to use for pcap files.
178    * \param nd Net device for which you want to enable tracing.
179    * \param promiscuous If true capture all possible packets available at the device.
180    * \param explicitFilename Treat the prefix as an explicit filename if true
181    */
182   virtual void EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename);
183
184   /**
185    * \brief Enable ascii trace output on the indicated net device.
186    * \internal
187    *
188    * NetDevice-specific implementation mechanism for hooking the trace and
189    * writing to the trace file.
190    *
191    * \param stream The output stream object to use when logging ascii traces.
192    * \param prefix Filename prefix to use for ascii trace files.
193    * \param nd Net device for which you want to enable tracing.
194    */
195   virtual void EnableAsciiInternal (
196     Ptr<OutputStreamWrapper> stream,
197     std::string prefix,
198     Ptr<NetDevice> nd,
199     bool explicitFilename);
200
201   ObjectFactory m_queueFactory;
202   ObjectFactory m_queueFactory_red;
203   ObjectFactory m_channelFactory;
204   ObjectFactory m_remoteChannelFactory;
205   ObjectFactory m_deviceFactory;
206 };
207
208 } // namespace ns3
209
210 #endif /* POINT_TO_POINT_HELPER_H */