Loading...
Searching...
No Matches
satellite-superframe-sequence.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 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: Sami Rantanen <sami.rantanen@magister.fi>
19 */
20
22
23#include "ns3/log.h"
24#include "ns3/nstime.h"
25#include "ns3/object.h"
26
27NS_LOG_COMPONENT_DEFINE("SatSuperframeSeq");
28
29namespace ns3
30{
31
32NS_OBJECT_ENSURE_REGISTERED(SatSuperframeSeq);
33
34// Super frame conf
35
37{
38 NS_LOG_FUNCTION(this);
39}
40
42{
43 NS_LOG_FUNCTION(this);
44}
45
46TypeId
48{
49 static TypeId tid = TypeId("ns3::SatSuperframeSeq")
50 .SetParent<Object>()
51 .AddConstructor<SatSuperframeSeq>()
52 .AddAttribute("TargetDuration",
53 "Target duration time.",
54 TimeValue(MilliSeconds(100)),
55 MakeTimeAccessor(&SatSuperframeSeq::m_targetDuration),
56 MakeTimeChecker());
57
58 return tid;
59}
60
61void
62SatSuperframeSeq::AddWaveformConf(Ptr<SatWaveformConf> wfConf)
63{
64 NS_LOG_FUNCTION(this);
65 m_wfConf = wfConf;
66}
67
68Ptr<SatWaveformConf>
70{
71 NS_LOG_FUNCTION(this);
72 return m_wfConf;
73}
74
75void
76SatSuperframeSeq::AddSuperframe(Ptr<SatSuperframeConf> conf)
77{
78 NS_LOG_FUNCTION(this);
79
80 m_superframe.push_back(conf);
81}
82
83uint32_t
85{
86 NS_LOG_FUNCTION(this);
87
88 uint32_t carrierCount = 0;
89
90 for (uint8_t i = 0; i < m_superframe.size(); i++)
91 {
92 carrierCount += m_superframe[i]->GetCarrierCount();
93 }
94
95 return carrierCount;
96}
97
98uint32_t
100{
101 NS_LOG_FUNCTION(this << (uint32_t)seqId);
102
103 if (seqId >= m_superframe.size())
104 {
105 NS_FATAL_ERROR("SatSuperframeSeq::GetCarrierCount - unsupported sequence id: " << seqId);
106 }
107
108 return m_superframe[seqId]->GetCarrierCount();
109}
110
111Time
113{
114 NS_LOG_FUNCTION(this << (uint32_t)seqId);
115
116 if (seqId >= m_superframe.size())
117 {
118 NS_FATAL_ERROR("SatSuperframeSeq::GetDuration - unsupported sequence id: " << seqId);
119 }
120
121 return m_superframe[seqId]->GetDuration();
122}
123
124Ptr<SatSuperframeConf>
126{
127 NS_LOG_FUNCTION(this << (uint32_t)seqId);
128
129 if (seqId >= m_superframe.size())
130 {
131 NS_FATAL_ERROR("SatSuperframeSeq::GetSuperframeConf - unsupported sequence id: " << seqId);
132 }
133
134 return m_superframe[seqId];
135}
136
137uint32_t
138SatSuperframeSeq::GetCarrierId(uint8_t superframeId, uint8_t frameId, uint16_t frameCarrierId) const
139{
140 NS_LOG_FUNCTION(this << superframeId << frameId << frameCarrierId);
141
142 if (superframeId >= m_superframe.size())
143 {
144 NS_FATAL_ERROR(
145 "SatSuperframeSeq::GetCarrierCount - unsupported sequence id: " << superframeId);
146 }
147
148 uint32_t carrierId = m_superframe[superframeId]->GetCarrierId(frameId, frameCarrierId);
149
150 for (uint8_t i = 0; i < superframeId; i++)
151 {
152 carrierId += m_superframe[i]->GetCarrierCount();
153 }
154
155 return carrierId;
156}
157
158double
160{
161 NS_LOG_FUNCTION(this << carrierId);
162
163 double superFrameStartFrequency = 0.0;
164 uint32_t currentSuperframe = 0;
165 uint32_t lastIdInSuperframe = m_superframe[0]->GetCarrierCount() - 1;
166 uint32_t carrierIdInSuperframe = carrierId;
167
168 while (carrierId > lastIdInSuperframe)
169 {
170 carrierIdInSuperframe -= m_superframe[currentSuperframe]->GetCarrierCount();
171 superFrameStartFrequency += m_superframe[currentSuperframe]->GetBandwidthHz();
172 currentSuperframe++;
173 lastIdInSuperframe += m_superframe[currentSuperframe]->GetCarrierCount();
174 }
175
176 double carrierFrequencyInSuperframe =
177 m_superframe[currentSuperframe]->GetCarrierFrequencyHz(carrierIdInSuperframe);
178
179 return superFrameStartFrequency + carrierFrequencyInSuperframe;
180}
181
182double
184 SatEnums::CarrierBandwidthType_t bandwidthType) const
185{
186 NS_LOG_FUNCTION(this << carrierId);
187
188 uint32_t currentSuperframe = 0;
189 uint32_t lastIdInSuperframe = m_superframe[0]->GetCarrierCount() - 1;
190 uint32_t carrierIdInSuperframe = carrierId;
191
192 while (carrierId > lastIdInSuperframe)
193 {
194 carrierIdInSuperframe -= m_superframe[currentSuperframe]->GetCarrierCount();
195 currentSuperframe++;
196 lastIdInSuperframe += m_superframe[currentSuperframe]->GetCarrierCount();
197 }
198
199 return m_superframe[currentSuperframe]->GetCarrierBandwidthHz(carrierIdInSuperframe,
200 bandwidthType);
201}
202
203} // namespace ns3
CarrierBandwidthType_t
Types of bandwidth.
This class implements super frame sequence.
~SatSuperframeSeq()
Destructor for SatSuperframeSeq.
Ptr< SatSuperframeConf > GetSuperframeConf(uint8_t seqId) const
Get superframe conf of the sequence.
double GetCarrierFrequencyHz(uint32_t carrierId) const
Get the center frequency of the requested carrier.
SatSuperframeSeq()
Default constructor for SatSuperframeConf.
static TypeId GetTypeId(void)
Get the type ID.
void AddSuperframe(Ptr< SatSuperframeConf > conf)
Add super frame (configuration) to super frame sequence.
uint32_t GetCarrierId(uint8_t superframeId, uint8_t frameId, uint16_t frameCarrierId) const
Get global carrier id.
void AddWaveformConf(Ptr< SatWaveformConf > wfConf)
Add waveform configuration class instance to this superframe sequence.
Ptr< SatWaveformConf > GetWaveformConf() const
Get waveform configuration.
SatSuperframeConfList m_superframe
Super frame sequences.
Time GetDuration(uint8_t seqId) const
Get duration of the super frame.
Time m_targetDuration
Target duration time for sequence.
double GetCarrierBandwidthHz(uint32_t carrierId, SatEnums::CarrierBandwidthType_t bandwidthType) const
Get the bandwidth of the requested carrier.
uint32_t GetCarrierCount() const
Get carrier count of the super frame sequence.
Ptr< SatWaveformConf > m_wfConf
Waveform configurations.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.