A Discrete-Event Network Simulator
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
10
12#include "network-status.h"
13
14namespace ns3
15{
16namespace lorawan
17{
18
19NS_LOG_COMPONENT_DEFINE("NetworkController");
20
22
23TypeId
25{
26 static TypeId tid = TypeId("ns3::NetworkController")
28 .AddConstructor<NetworkController>()
29 .SetGroupName("lorawan");
30 return tid;
31}
32
37
43
48
49void
51{
52 NS_LOG_FUNCTION(this);
53 m_components.push_back(component);
54}
55
56void
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
72void
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
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:999
This class collects a series of components that deal with various aspects of managing the network,...
void Install(Ptr< NetworkControllerComponent > component)
Add a new NetworkControllerComponent.
Ptr< NetworkStatus > m_status
A pointer to the NetworkStatus object.
void OnNewPacket(Ptr< const Packet > packet)
Method that is called by the NetworkServer application when a new packet is received.
NetworkController()
Default constructor.
void BeforeSendingReply(Ptr< EndDeviceStatus > endDeviceStatus)
Method that is called by the NetworkScheduler just before sending a reply to a certain end device.
static TypeId GetTypeId()
Register this type.
std::list< Ptr< NetworkControllerComponent > > m_components
List of NetworkControllerComponent objects.
~NetworkController() override
Destructor.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.