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
network-controller.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
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: Davide Magrin <magrinda@dei.unipd.it>
18
*/
19
20
#include "
network-controller.h
"
21
22
namespace
ns3
23
{
24
namespace
lorawan
25
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"NetworkController"
);
28
29
NS_OBJECT_ENSURE_REGISTERED
(NetworkController);
30
31
TypeId
32
NetworkController::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::NetworkController"
)
35
.
SetParent
<
Object
>()
36
.AddConstructor<NetworkController>()
37
.SetGroupName(
"lorawan"
);
38
return
tid;
39
}
40
41
NetworkController::NetworkController
()
42
{
43
NS_LOG_FUNCTION_NOARGS
();
44
}
45
46
NetworkController::NetworkController
(
Ptr<NetworkStatus>
networkStatus)
47
: m_status(networkStatus)
48
{
49
NS_LOG_FUNCTION_NOARGS
();
50
}
51
52
NetworkController::~NetworkController
()
53
{
54
NS_LOG_FUNCTION_NOARGS
();
55
}
56
57
void
58
NetworkController::Install
(
Ptr<NetworkControllerComponent>
component)
59
{
60
NS_LOG_FUNCTION
(
this
);
61
m_components
.push_back(component);
62
}
63
64
void
65
NetworkController::OnNewPacket
(
Ptr<const Packet>
packet)
66
{
67
NS_LOG_FUNCTION
(
this
<< packet);
68
69
// NOTE As a future optimization, we can allow components to register their
70
// callbacks and only be called in case a certain MAC command is contained.
71
// For now, we call all components.
72
73
// Inform each component about the new packet
74
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
75
{
76
(*it)->OnReceivedPacket(packet,
m_status
->GetEndDeviceStatus(packet),
m_status
);
77
}
78
}
79
80
void
81
NetworkController::BeforeSendingReply
(
Ptr<EndDeviceStatus>
endDeviceStatus)
82
{
83
NS_LOG_FUNCTION
(
this
);
84
85
// Inform each component about the imminent reply
86
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
87
{
88
(*it)->BeforeSendingReply(endDeviceStatus,
m_status
);
89
}
90
}
91
92
}
// namespace lorawan
93
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:932
ns3::lorawan::NetworkController::Install
void Install(Ptr< NetworkControllerComponent > component)
Add a new NetworkControllerComponent.
Definition:
network-controller.cc:58
ns3::lorawan::NetworkController::m_status
Ptr< NetworkStatus > m_status
A pointer to the NetworkStatus object.
Definition:
network-controller.h:86
ns3::lorawan::NetworkController::OnNewPacket
void OnNewPacket(Ptr< const Packet > packet)
Method that is called by the NetworkServer application when a new packet is received.
Definition:
network-controller.cc:65
ns3::lorawan::NetworkController::NetworkController
NetworkController()
Default constructor.
Definition:
network-controller.cc:41
ns3::lorawan::NetworkController::BeforeSendingReply
void BeforeSendingReply(Ptr< EndDeviceStatus > endDeviceStatus)
Method that is called by the NetworkScheduler just before sending a reply to a certain end device.
Definition:
network-controller.cc:81
ns3::lorawan::NetworkController::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
network-controller.cc:32
ns3::lorawan::NetworkController::m_components
std::list< Ptr< NetworkControllerComponent > > m_components
List of NetworkControllerComponent objects.
Definition:
network-controller.h:88
ns3::lorawan::NetworkController::~NetworkController
~NetworkController() override
Destructor.
Definition:
network-controller.cc:52
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:206
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:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
network-controller.h
src
lorawan
model
network-controller.cc
Generated on Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6