Logo AND Algorithmique Numérique Distribuée

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