1 /* Copyright (c) 2011, 2014. The SimGrid Team.
2 * All rights reserved. */
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. */
8 * Copyright (c) 2008 INRIA
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;
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.
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
23 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
25 #ifndef POINT_TO_POINT_HELPER_H
26 #define POINT_TO_POINT_HELPER_H
30 #include "ns3/object-factory.h"
31 #include "ns3/net-device-container.h"
32 #include "ns3/node-container.h"
33 #include "ns3/deprecated.h"
35 #include "ns3/trace-helper.h"
37 #include "ns3_interface.h"
46 * \brief Build a set of PointToPointNetDevice objects
48 * Normally we eschew multiple inheritance, however, the classes
49 * PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are
52 class MyPointToPointHelper : public PcapHelperForDevice, public AsciiTraceHelperForDevice
56 * Create a MyPointToPointHelper to make life easier when creating point to
59 MyPointToPointHelper ();
60 virtual ~MyPointToPointHelper () {}
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.
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
77 * Set the type of queue to create and associated to each
78 * PointToPointNetDevice created through MyPointToPointHelper::Install.
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 ());
91 * Set an attribute value to be propagated to each NetDevice created by the
94 * \param name the name of the attribute to set
95 * \param value the value of the attribute to set
97 * Set these attributes on each ns3::PointToPointNetDevice created
98 * by MyPointToPointHelper::Install
100 void SetDeviceAttribute (std::string name, const AttributeValue &value);
103 * Set an attribute value to be propagated to each Channel created by the
106 * \param name the name of the attribute to set
107 * \param value the value of the attribute to set
109 * Set these attribute on each ns3::PointToPointChannel created
110 * by MyPointToPointHelper::Install
112 void SetChannelAttribute (std::string name, const AttributeValue &value);
115 * \param c a set of nodes
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.
124 NetDeviceContainer Install (NodeContainer c);
127 * \param a first node
128 * \param b second node
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.
134 NetDeviceContainer Install (Ptr<Node> a, Ptr<Node> b);
137 * \param a first node
138 * \param b second node
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.
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);
147 * \param a first node
148 * \param bName name of second node
150 * Saves you from having to construct a temporary NodeContainer.
152 NetDeviceContainer Install (Ptr<Node> a, std::string bName);
155 * \param aName Name of first node
156 * \param b second node
158 * Saves you from having to construct a temporary NodeContainer.
160 NetDeviceContainer Install (std::string aName, Ptr<Node> b);
163 * \param aNode Name of first node
164 * \param bNode Name of second node
166 * Saves you from having to construct a temporary NodeContainer.
168 NetDeviceContainer Install (std::string aNode, std::string bNode);
172 * \brief Enable pcap output the indicated net device.
174 * NetDevice-specific implementation mechanism for hooking the trace and
175 * writing to the trace file.
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
182 virtual void EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename);
185 * \brief Enable ascii trace output on the indicated net device.
188 * NetDevice-specific implementation mechanism for hooking the trace and
189 * writing to the trace file.
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.
195 virtual void EnableAsciiInternal (
196 Ptr<OutputStreamWrapper> stream,
199 bool explicitFilename);
201 ObjectFactory m_queueFactory;
202 ObjectFactory m_queueFactory_red;
203 ObjectFactory m_channelFactory;
204 ObjectFactory m_remoteChannelFactory;
205 ObjectFactory m_deviceFactory;
210 #endif /* POINT_TO_POINT_HELPER_H */