A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
one-shot-sender-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#include "
one-shot-sender-helper.h
"
10
11
#include "ns3/double.h"
12
#include "ns3/log.h"
13
#include "ns3/one-shot-sender.h"
14
#include "ns3/simulator.h"
15
#include "ns3/string.h"
16
#include "ns3/trace-source-accessor.h"
17
18
namespace
ns3
19
{
20
namespace
lorawan
21
{
22
23
NS_LOG_COMPONENT_DEFINE
(
"OneShotSenderHelper"
);
24
25
OneShotSenderHelper::OneShotSenderHelper
()
26
{
27
m_factory
.
SetTypeId
(
"ns3::OneShotSender"
);
28
}
29
30
OneShotSenderHelper::~OneShotSenderHelper
()
31
{
32
}
33
34
void
35
OneShotSenderHelper::SetSendTime
(
Time
sendTime)
36
{
37
m_sendTime
= sendTime;
38
}
39
40
void
41
OneShotSenderHelper::SetAttribute
(std::string name,
const
AttributeValue
& value)
42
{
43
m_factory
.
Set
(name, value);
44
}
45
46
ApplicationContainer
47
OneShotSenderHelper::Install
(
Ptr<Node>
node)
const
48
{
49
return
ApplicationContainer
(
InstallPriv
(node));
50
}
51
52
ApplicationContainer
53
OneShotSenderHelper::Install
(
NodeContainer
c)
const
54
{
55
ApplicationContainer
apps;
56
for
(
auto
i = c.
Begin
(); i != c.
End
(); ++i)
57
{
58
apps.
Add
(
InstallPriv
(*i));
59
}
60
61
return
apps;
62
}
63
64
Ptr<Application>
65
OneShotSenderHelper::InstallPriv
(
Ptr<Node>
node)
const
66
{
67
NS_LOG_FUNCTION
(
this
<< node->GetId());
68
69
Ptr<OneShotSender>
app =
m_factory
.
Create
<
OneShotSender
>();
70
71
app->SetSendTime(
m_sendTime
);
72
73
app->SetNode(node);
74
node->AddApplication(app);
75
76
return
app;
77
}
78
}
// namespace lorawan
79
}
// namespace ns3
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition
application-container.h:33
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition
application-container.cc:59
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::NodeContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Definition
node-container.cc:55
ns3::NodeContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Definition
node-container.cc:49
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition
object-factory.h:213
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::lorawan::OneShotSenderHelper::SetSendTime
void SetSendTime(Time sendTime)
Set the send time of the applications.
Definition
one-shot-sender-helper.cc:35
ns3::lorawan::OneShotSenderHelper::m_factory
ObjectFactory m_factory
The object factory.
Definition
one-shot-sender-helper.h:84
ns3::lorawan::OneShotSenderHelper::m_sendTime
Time m_sendTime
Time at which the OneShotSender applications will be configured to send the packet.
Definition
one-shot-sender-helper.h:85
ns3::lorawan::OneShotSenderHelper::~OneShotSenderHelper
~OneShotSenderHelper()
Destructor.
Definition
one-shot-sender-helper.cc:30
ns3::lorawan::OneShotSenderHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Definition
one-shot-sender-helper.cc:41
ns3::lorawan::OneShotSenderHelper::Install
ApplicationContainer Install(NodeContainer c) const
Install a OneShotSender application on each node of the input container configured with all the attri...
Definition
one-shot-sender-helper.cc:53
ns3::lorawan::OneShotSenderHelper::OneShotSenderHelper
OneShotSenderHelper()
Default constructor.
Definition
one-shot-sender-helper.cc:25
ns3::lorawan::OneShotSenderHelper::InstallPriv
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install a OneShotSender application on the input Node configured with all the attributes set with Set...
Definition
one-shot-sender-helper.cc:65
ns3::lorawan::OneShotSender
Packet sender application to send a single packet.
Definition
one-shot-sender.h:29
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
one-shot-sender-helper.h
src
lorawan
helper
one-shot-sender-helper.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0