A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
application-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 DERONNE SOFTWARE ENGINEERING
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18 */
19
20#ifndef APPLICATIONS_HELPER_H
21#define APPLICATIONS_HELPER_H
22
24#include "node-container.h"
25
26#include <ns3/address.h>
27#include <ns3/attribute.h>
28#include <ns3/object-factory.h>
29
30#include <string>
31
32namespace ns3
33{
34
35/**
36 * \brief A helper to make it easier to instantiate an application on a set of nodes.
37 */
39{
40 public:
41 /**
42 * Create an application of a given type ID
43 *
44 * @param typeId the type ID.
45 */
46 explicit ApplicationHelper(TypeId typeId);
47
48 /**
49 * Create an application of a given type ID
50 *
51 * @param typeId the type ID expressed as a string.
52 */
53 explicit ApplicationHelper(const std::string& typeId);
54
55 /**
56 * Allow the helper to be repurposed for another application type
57 *
58 * @param typeId the type ID.
59 */
60 void SetTypeId(TypeId typeId);
61
62 /**
63 * Allow the helper to be repurposed for another application type
64 *
65 * @param typeId the type ID expressed as a string.
66 */
67 void SetTypeId(const std::string& typeId);
68
69 /**
70 * Helper function used to set the underlying application attributes.
71 *
72 * @param name the name of the application attribute to set
73 * @param value the value of the application attribute to set
74 */
75 void SetAttribute(const std::string& name, const AttributeValue& value);
76
77 /**
78 * Install an application on each node of the input container
79 * configured with all the attributes set with SetAttribute.
80 *
81 * @param c NodeContainer of the set of nodes on which an application
82 * will be installed.
83 * @return Container of Ptr to the applications installed.
84 */
86
87 /**
88 * Install an application on the node configured with all the
89 * attributes set with SetAttribute.
90 *
91 * @param node The node on which an application will be installed.
92 * @return Container of Ptr to the applications installed.
93 */
95
96 /**
97 * Install an application on the node configured with all the
98 * attributes set with SetAttribute.
99 *
100 * @param nodeName The node on which an application will be installed.
101 * @return Container of Ptr to the applications installed.
102 */
103 ApplicationContainer Install(const std::string& nodeName);
104
105 /**
106 * Assigns a unique (monotonically increasing) stream number to all applications that match the
107 * configured type of this application helper instance. Return the number of streams (possibly
108 * zero) that have been assigned. The Install() method should have previously been called by the
109 * user.
110 *
111 * @param stream first stream index to use
112 * @param c NodeContainer of the set of nodes for which the application should be modified to
113 * use a fixed stream
114 * @return the number of stream indices assigned by this helper
115 */
116 int64_t AssignStreams(NodeContainer c, int64_t stream);
117
118 /**
119 * Assign a fixed random variable stream number to the random variables used by all the
120 * applications. Return the number of streams (possibly zero) that have been assigned. The
121 * Install() method should have previously been called by the user.
122 *
123 * @param stream first stream index to use
124 * @param c NodeContainer of the set of nodes for which their applications should be modified to
125 * use a fixed stream
126 * @return the number of stream indices assigned by this helper
127 */
128 static int64_t AssignStreamsToAllApps(NodeContainer c, int64_t stream);
129
130 protected:
131 /**
132 * Install an application on the node configured with all the
133 * attributes set with SetAttribute.
134 *
135 * @param node The node on which an application will be installed.
136 * @return Ptr to the application installed.
137 */
139
140 ObjectFactory m_factory; //!< Object factory.
141};
142
143} // namespace ns3
144
145#endif /* APPLICATIONS_HELPER_H */
holds a vector of ns3::Application pointers.
A helper to make it easier to instantiate an application on a set of nodes.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
ObjectFactory m_factory
Object factory.
static int64_t AssignStreamsToAllApps(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by all the applications.
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assigns a unique (monotonically increasing) stream number to all applications that match the configur...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetTypeId(TypeId typeId)
Allow the helper to be repurposed for another application type.
virtual Ptr< Application > DoInstall(Ptr< Node > node)
Install an application on the node configured with all the attributes set with SetAttribute.
Hold a value for an Attribute.
Definition: attribute.h:70
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.