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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#include "
network-controller.h
"
10
11
#include "
network-controller-components.h
"
12
#include "
network-status.h
"
13
14
namespace
ns3
15
{
16
namespace
lorawan
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"NetworkController"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(
NetworkController
);
22
23
TypeId
24
NetworkController::GetTypeId
()
25
{
26
static
TypeId
tid =
TypeId
(
"ns3::NetworkController"
)
27
.
SetParent
<
Object
>()
28
.AddConstructor<NetworkController>()
29
.SetGroupName(
"lorawan"
);
30
return
tid;
31
}
32
33
NetworkController::NetworkController
()
34
{
35
NS_LOG_FUNCTION_NOARGS
();
36
}
37
38
NetworkController::NetworkController
(
Ptr<NetworkStatus>
networkStatus)
39
:
m_status
(networkStatus)
40
{
41
NS_LOG_FUNCTION_NOARGS
();
42
}
43
44
NetworkController::~NetworkController
()
45
{
46
NS_LOG_FUNCTION_NOARGS
();
47
}
48
49
void
50
NetworkController::Install
(
Ptr<NetworkControllerComponent>
component)
51
{
52
NS_LOG_FUNCTION
(
this
);
53
m_components
.push_back(component);
54
}
55
56
void
57
NetworkController::OnNewPacket
(
Ptr<const Packet>
packet)
58
{
59
NS_LOG_FUNCTION
(
this
<< packet);
60
61
// NOTE As a future optimization, we can allow components to register their
62
// callbacks and only be called in case a certain MAC command is contained.
63
// For now, we call all components.
64
65
// Inform each component about the new packet
66
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
67
{
68
(*it)->OnReceivedPacket(packet,
m_status
->GetEndDeviceStatus(packet),
m_status
);
69
}
70
}
71
72
void
73
NetworkController::BeforeSendingReply
(
Ptr<EndDeviceStatus>
endDeviceStatus)
74
{
75
NS_LOG_FUNCTION
(
this
);
76
77
// Inform each component about the imminent reply
78
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
79
{
80
(*it)->BeforeSendingReply(endDeviceStatus,
m_status
);
81
}
82
}
83
84
}
// namespace lorawan
85
}
// namespace ns3
ns3::Object::Object
Object()
Caller graph was not generated because of its size.
Definition
object.cc:93
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:999
ns3::lorawan::NetworkController
This class collects a series of components that deal with various aspects of managing the network,...
Definition
network-controller.h:32
ns3::lorawan::NetworkController::Install
void Install(Ptr< NetworkControllerComponent > component)
Add a new NetworkControllerComponent.
Definition
network-controller.cc:50
ns3::lorawan::NetworkController::m_status
Ptr< NetworkStatus > m_status
A pointer to the NetworkStatus object.
Definition
network-controller.h:73
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:57
ns3::lorawan::NetworkController::NetworkController
NetworkController()
Default constructor.
Definition
network-controller.cc:33
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:73
ns3::lorawan::NetworkController::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
network-controller.cc:24
ns3::lorawan::NetworkController::m_components
std::list< Ptr< NetworkControllerComponent > > m_components
List of NetworkControllerComponent objects.
Definition
network-controller.h:75
ns3::lorawan::NetworkController::~NetworkController
~NetworkController() override
Destructor.
Definition
network-controller.cc:44
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
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:231
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
network-controller-components.h
network-controller.h
network-status.h
src
lorawan
model
network-controller.cc
Generated on
for ns-3 by
1.15.0