Loading...
Searching...
No Matches
satellite-bstp-controller.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 Magister Solutions Ltd.
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: Jani Puttonen <jani.puttonen@magister.fi>
19 */
20
22
24
25#include "ns3/boolean.h"
26#include "ns3/double.h"
27#include "ns3/enum.h"
28#include "ns3/log.h"
29#include "ns3/nstime.h"
30#include "ns3/simulator.h"
31#include "ns3/string.h"
32
33#include <algorithm>
34#include <utility>
35#include <vector>
36
37NS_LOG_COMPONENT_DEFINE("SatBstpController");
38
39namespace ns3
40{
41
42NS_OBJECT_ENSURE_REGISTERED(SatBstpController);
43
47 m_configFileName("SatBstpConf.txt"),
48 m_superFrameDuration(MilliSeconds(100)),
50{
51 NS_LOG_FUNCTION(this);
52}
53
54void
56{
57 NS_LOG_FUNCTION(this);
58
59 Object::NotifyConstructionCompleted();
60
62 {
63 m_staticBstp = Create<SatStaticBstp>(m_configFileName);
64 }
66 {
67 NS_FATAL_ERROR("Beam hopping supports currently only STATIC mode!");
68 }
69}
70
75
76void
78{
79 NS_LOG_FUNCTION(this);
80
81 if (m_staticBstp)
82 {
83 m_staticBstp->CheckValidity();
84 }
85
87}
88
89TypeId
91{
92 static TypeId tid =
93 TypeId("ns3::SatBstpController")
94 .SetParent<Object>()
95 .AddConstructor<SatBstpController>()
96 .AddAttribute("BeamHoppingMode",
97 "Beam hopping mode.",
99 MakeEnumAccessor<SatBstpController::BeamHoppingType_t>(
101 MakeEnumChecker(SatBstpController::BH_STATIC,
102 "Static",
104 "Dynamic"))
105 .AddAttribute("StaticBeamHoppingConfigFileName",
106 "Configuration file name for static beam hopping.",
107 StringValue("SatBstpConf_GW1.txt"),
108 MakeStringAccessor(&SatBstpController::m_configFileName),
109 MakeStringChecker())
110 .AddAttribute("SuperframeDuration",
111 "Superframe duration in Time.",
112 TimeValue(MilliSeconds(10)),
114 MakeTimeChecker());
115 return tid;
116}
117
118void
120{
121 NS_LOG_FUNCTION(this);
122
123 for (CallbackContainer_t::iterator it = m_gwNdCallbacks.begin(); it != m_gwNdCallbacks.end();
124 ++it)
125 {
126 it->second.Nullify();
127 }
128
129 Object::DoDispose();
130}
131
132void
134 uint32_t userFreqId,
135 uint32_t feederFreqId,
136 uint32_t gwId,
138{
139 NS_LOG_FUNCTION(this << beamId << userFreqId << feederFreqId << gwId);
140
145
146 NS_LOG_INFO("Add beam: " << beamId << ", userFreqId: " << userFreqId
147 << ", feederFreqId: " << feederFreqId << ", gwId: " << gwId);
148
149 if (m_staticBstp)
150 {
151 m_staticBstp->AddEnabledBeamInfo(beamId, userFreqId, feederFreqId, gwId);
152 }
153
154 m_gwNdCallbacks.insert(std::make_pair(beamId, cb));
155}
156
157void
159{
160 NS_LOG_FUNCTION(this);
161
162 uint32_t validityInSuperframes(1);
163
164 if (m_staticBstp)
165 {
166 // Read next BSTP configuration
167 std::vector<uint32_t> nextConf = m_staticBstp->GetNextConf();
168
169 // First column is the validity
170 validityInSuperframes = nextConf.front();
171
172 // Read BSTP entry and do configuration
173 for (CallbackContainer_t::iterator it = m_gwNdCallbacks.begin();
174 it != m_gwNdCallbacks.end();
175 ++it)
176 {
177 uint32_t beamId = (*it).first;
178
184 if (std::find(nextConf.begin() + 1, nextConf.end(), beamId) != nextConf.end())
185 {
186 (*it).second(true);
187 }
188 else
189 {
190 (*it).second(false);
191 }
192 }
193 }
194 else
195 {
196 NS_FATAL_ERROR("Dynamic beam switching time plan not yet supported!");
197 }
198
202 Time nextConfigurationDuration(validityInSuperframes * m_superFrameDuration);
203 Simulator::Schedule(nextConfigurationDuration, &SatBstpController::DoBstpConfiguration, this);
204}
205
206} // namespace ns3
SatBstpController class is responsible of enabling and disabling configurable spot-beams defined by a...
virtual void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
virtual ~SatBstpController()
Destructor for SatRequestManager.
static TypeId GetTypeId(void)
inherited from Object
SatBstpController()
Default constructor.
void Initialize()
Initialize the beam hopping configurations.
Ptr< SatStaticBstp > m_staticBstp
Beam switching time plan.
void AddNetDeviceCallback(uint32_t beamId, uint32_t userFreqId, uint32_t feederFreqId, uint32_t gwId, SatBstpController::ToggleCallback cb)
Add a callback to the SatNetDevice of GW matching to a certain beam id.
virtual void DoDispose()
Dispose of this class instance.
Callback< void, bool > ToggleCallback
Callback to fetch queue statistics.
void DoBstpConfiguration()
Periodical method to enable/disable certain beam ids related to the scheduling and transmission of BB...
Time m_superFrameDuration
Superframe duration in Time.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.