Loading...
Searching...
No Matches
lora-network-controller.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2017 University of Padova
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Davide Magrin <magrinda@dei.unipd.it>
19 *
20 * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21 */
22
24
25#include <stdint.h>
26
27namespace ns3
28{
29
30NS_LOG_COMPONENT_DEFINE("LoraNetworkController");
31
32NS_OBJECT_ENSURE_REGISTERED(LoraNetworkController);
33
34TypeId
36{
37 static TypeId tid = TypeId("ns3::LoraNetworkController")
38 .SetParent<Object>()
39 .AddConstructor<LoraNetworkController>();
40 return tid;
41}
42
44{
45 NS_LOG_FUNCTION_NOARGS();
46}
47
48LoraNetworkController::LoraNetworkController(Ptr<LoraNetworkStatus> networkStatus)
49 : m_status(networkStatus)
50{
51 NS_LOG_FUNCTION_NOARGS();
52}
53
55{
56 NS_LOG_FUNCTION_NOARGS();
57}
58
59void
60LoraNetworkController::Install(Ptr<LoraNetworkControllerComponent> component)
61{
62 NS_LOG_FUNCTION(this);
63 m_components.push_back(component);
64}
65
66void
67LoraNetworkController::OnNewPacket(Ptr<const Packet> packet)
68{
69 NS_LOG_FUNCTION(this << packet);
70
71 // NOTE As a future optimization, we can allow components to register their
72 // callbacks and only be called in case a certain MAC command is contained.
73 // For now, we call all components.
74
75 // Inform each component about the new packet
76 for (auto it = m_components.begin(); it != m_components.end(); ++it)
77 {
78 (*it)->OnReceivedPacket(packet, m_status->GetEndDeviceStatus(packet), m_status);
79 }
80}
81
82void
83LoraNetworkController::BeforeSendingReply(Ptr<LoraEndDeviceStatus> endDeviceStatus)
84{
85 NS_LOG_FUNCTION(this);
86
87 // Inform each component about the imminent reply
88 for (auto it = m_components.begin(); it != m_components.end(); ++it)
89 {
90 (*it)->BeforeSendingReply(endDeviceStatus, m_status);
91 }
92}
93
94} // namespace ns3
This class collects a series of components that deal with various aspects of managing the network,...
void Install(Ptr< LoraNetworkControllerComponent > component)
Add a new LoraNetworkControllerComponent.
void OnNewPacket(Ptr< const Packet > packet)
Method that is called by the NetworkServer when a new packet is received.
Ptr< LoraNetworkStatus > m_status
void BeforeSendingReply(Ptr< LoraEndDeviceStatus > endDeviceStatus)
Method that is called by the NetworkScheduler just before sending a reply to a certain End Device.
std::list< Ptr< LoraNetworkControllerComponent > > m_components
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.