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 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("LoraNetworkController");
31 
32 NS_OBJECT_ENSURE_REGISTERED(LoraNetworkController);
33 
34 TypeId
36 {
37  static TypeId tid =
38  TypeId("ns3::LoraNetworkController").AddConstructor<LoraNetworkController>();
39  return tid;
40 }
41 
43 {
44  NS_LOG_FUNCTION_NOARGS();
45 }
46 
47 LoraNetworkController::LoraNetworkController(Ptr<LoraNetworkStatus> networkStatus)
48  : m_status(networkStatus)
49 {
50  NS_LOG_FUNCTION_NOARGS();
51 }
52 
54 {
55  NS_LOG_FUNCTION_NOARGS();
56 }
57 
58 void
59 LoraNetworkController::Install(Ptr<LoraNetworkControllerComponent> component)
60 {
61  NS_LOG_FUNCTION(this);
62  m_components.push_back(component);
63 }
64 
65 void
66 LoraNetworkController::OnNewPacket(Ptr<const Packet> packet)
67 {
68  NS_LOG_FUNCTION(this << packet);
69 
70  // NOTE As a future optimization, we can allow components to register their
71  // callbacks and only be called in case a certain MAC command is contained.
72  // For now, we call all components.
73 
74  // Inform each component about the new packet
75  for (auto it = m_components.begin(); it != m_components.end(); ++it)
76  {
77  (*it)->OnReceivedPacket(packet, m_status->GetEndDeviceStatus(packet), m_status);
78  }
79 }
80 
81 void
82 LoraNetworkController::BeforeSendingReply(Ptr<LoraEndDeviceStatus> endDeviceStatus)
83 {
84  NS_LOG_FUNCTION(this);
85 
86  // Inform each component about the imminent reply
87  for (auto it = m_components.begin(); it != m_components.end(); ++it)
88  {
89  (*it)->BeforeSendingReply(endDeviceStatus, m_status);
90  }
91 }
92 
93 } // 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.