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