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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#ifndef APPLICATIONS_HELPER_H
10#define APPLICATIONS_HELPER_H
11
13#include "node-container.h"
14
15#include <ns3/address.h>
16#include <ns3/attribute.h>
17#include <ns3/object-factory.h>
18
19#include <string>
20
21namespace ns3
22{
23
24/**
25 * \brief A helper to make it easier to instantiate an application on a set of nodes.
26 */
28{
29 public:
30 /**
31 * Create an application of a given type ID
32 *
33 * @param typeId the type ID.
34 */
35 explicit ApplicationHelper(TypeId typeId);
36
37 /**
38 * Create an application of a given type ID
39 *
40 * @param typeId the type ID expressed as a string.
41 */
42 explicit ApplicationHelper(const std::string& typeId);
43
44 /**
45 * Allow the helper to be repurposed for another application type
46 *
47 * @param typeId the type ID.
48 */
49 void SetTypeId(TypeId typeId);
50
51 /**
52 * Allow the helper to be repurposed for another application type
53 *
54 * @param typeId the type ID expressed as a string.
55 */
56 void SetTypeId(const std::string& typeId);
57
58 /**
59 * Helper function used to set the underlying application attributes.
60 *
61 * @param name the name of the application attribute to set
62 * @param value the value of the application attribute to set
63 */
64 void SetAttribute(const std::string& name, const AttributeValue& value);
65
66 /**
67 * Install an application on each node of the input container
68 * configured with all the attributes set with SetAttribute.
69 *
70 * @param c NodeContainer of the set of nodes on which an application
71 * will be installed.
72 * @return Container of Ptr to the applications installed.
73 */
75
76 /**
77 * Install an application on the node configured with all the
78 * attributes set with SetAttribute.
79 *
80 * @param node The node on which an application will be installed.
81 * @return Container of Ptr to the applications installed.
82 */
84
85 /**
86 * Install an application on the node configured with all the
87 * attributes set with SetAttribute.
88 *
89 * @param nodeName The node on which an application will be installed.
90 * @return Container of Ptr to the applications installed.
91 */
92 ApplicationContainer Install(const std::string& nodeName);
93
94 /**
95 * Assigns a unique (monotonically increasing) stream number to all applications that match the
96 * configured type of this application helper instance. Return the number of streams (possibly
97 * zero) that have been assigned. The Install() method should have previously been called by the
98 * user.
99 *
100 * @param stream first stream index to use
101 * @param c NodeContainer of the set of nodes for which the application should be modified to
102 * use a fixed stream
103 * @return the number of stream indices assigned by this helper
104 */
105 int64_t AssignStreams(NodeContainer c, int64_t stream);
106
107 /**
108 * Assign a fixed random variable stream number to the random variables used by all the
109 * applications. Return the number of streams (possibly zero) that have been assigned. The
110 * Install() method should have previously been called by the user.
111 *
112 * @param stream first stream index to use
113 * @param c NodeContainer of the set of nodes for which their applications should be modified to
114 * use a fixed stream
115 * @return the number of stream indices assigned by this helper
116 */
117 static int64_t AssignStreamsToAllApps(NodeContainer c, int64_t stream);
118
119 protected:
120 /**
121 * Install an application on the node configured with all the
122 * attributes set with SetAttribute.
123 *
124 * @param node The node on which an application will be installed.
125 * @return Ptr to the application installed.
126 */
128
129 ObjectFactory m_factory; //!< Object factory.
130};
131
132} // namespace ns3
133
134#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.
ApplicationHelper(TypeId typeId)
Create an application of a given type ID.
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:59
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.