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
namespace
ns3
12
{
13
namespace
lorawan
14
{
15
16
NS_LOG_COMPONENT_DEFINE
(
"NetworkController"
);
17
18
NS_OBJECT_ENSURE_REGISTERED
(NetworkController);
19
20
TypeId
21
NetworkController::GetTypeId
()
22
{
23
static
TypeId
tid =
TypeId
(
"ns3::NetworkController"
)
24
.
SetParent
<
Object
>()
25
.AddConstructor<NetworkController>()
26
.SetGroupName(
"lorawan"
);
27
return
tid;
28
}
29
30
NetworkController::NetworkController
()
31
{
32
NS_LOG_FUNCTION_NOARGS
();
33
}
34
35
NetworkController::NetworkController
(
Ptr<NetworkStatus>
networkStatus)
36
: m_status(networkStatus)
37
{
38
NS_LOG_FUNCTION_NOARGS
();
39
}
40
41
NetworkController::~NetworkController
()
42
{
43
NS_LOG_FUNCTION_NOARGS
();
44
}
45
46
void
47
NetworkController::Install
(
Ptr<NetworkControllerComponent>
component)
48
{
49
NS_LOG_FUNCTION
(
this
);
50
m_components
.push_back(component);
51
}
52
53
void
54
NetworkController::OnNewPacket
(
Ptr<const Packet>
packet)
55
{
56
NS_LOG_FUNCTION
(
this
<< packet);
57
58
// NOTE As a future optimization, we can allow components to register their
59
// callbacks and only be called in case a certain MAC command is contained.
60
// For now, we call all components.
61
62
// Inform each component about the new packet
63
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
64
{
65
(*it)->OnReceivedPacket(packet,
m_status
->GetEndDeviceStatus(packet),
m_status
);
66
}
67
}
68
69
void
70
NetworkController::BeforeSendingReply
(
Ptr<EndDeviceStatus>
endDeviceStatus)
71
{
72
NS_LOG_FUNCTION
(
this
);
73
74
// Inform each component about the imminent reply
75
for
(
auto
it =
m_components
.begin(); it !=
m_components
.end(); ++it)
76
{
77
(*it)->BeforeSendingReply(endDeviceStatus,
m_status
);
78
}
79
}
80
81
}
// namespace lorawan
82
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::lorawan::NetworkController::Install
void Install(Ptr< NetworkControllerComponent > component)
Add a new NetworkControllerComponent.
Definition
network-controller.cc:47
ns3::lorawan::NetworkController::m_status
Ptr< NetworkStatus > m_status
A pointer to the NetworkStatus object.
Definition
network-controller.h:75
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:54
ns3::lorawan::NetworkController::NetworkController
NetworkController()
Default constructor.
Definition
network-controller.cc:30
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:70
ns3::lorawan::NetworkController::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
network-controller.cc:21
ns3::lorawan::NetworkController::m_components
std::list< Ptr< NetworkControllerComponent > > m_components
List of NetworkControllerComponent objects.
Definition
network-controller.h:77
ns3::lorawan::NetworkController::~NetworkController
~NetworkController() override
Destructor.
Definition
network-controller.cc:41
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_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:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
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 Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0