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 
27 NS_LOG_COMPONENT_DEFINE("SatSuperframeSeq");
28 
29 namespace ns3
30 {
31 
32 NS_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 
46 TypeId
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 
61 TypeId
63 {
64  NS_LOG_FUNCTION(this);
65 
66  return GetTypeId();
67 }
68 
69 void
70 SatSuperframeSeq::AddWaveformConf(Ptr<SatWaveformConf> wfConf)
71 {
72  NS_LOG_FUNCTION(this);
73  m_wfConf = wfConf;
74 }
75 
76 Ptr<SatWaveformConf>
78 {
79  NS_LOG_FUNCTION(this);
80  return m_wfConf;
81 }
82 
83 void
84 SatSuperframeSeq::AddSuperframe(Ptr<SatSuperframeConf> conf)
85 {
86  NS_LOG_FUNCTION(this);
87 
88  m_superframe.push_back(conf);
89 }
90 
91 uint32_t
93 {
94  NS_LOG_FUNCTION(this);
95 
96  uint32_t carrierCount = 0;
97 
98  for (uint8_t i = 0; i < m_superframe.size(); i++)
99  {
100  carrierCount += m_superframe[i]->GetCarrierCount();
101  }
102 
103  return carrierCount;
104 }
105 
106 uint32_t
108 {
109  NS_LOG_FUNCTION(this << (uint32_t)seqId);
110 
111  if (seqId >= m_superframe.size())
112  {
113  NS_FATAL_ERROR("SatSuperframeSeq::GetCarrierCount - unsupported sequence id: " << seqId);
114  }
115 
116  return m_superframe[seqId]->GetCarrierCount();
117 }
118 
119 Time
120 SatSuperframeSeq::GetDuration(uint8_t seqId) const
121 {
122  NS_LOG_FUNCTION(this << (uint32_t)seqId);
123 
124  if (seqId >= m_superframe.size())
125  {
126  NS_FATAL_ERROR("SatSuperframeSeq::GetDuration - unsupported sequence id: " << seqId);
127  }
128 
129  return m_superframe[seqId]->GetDuration();
130 }
131 
132 Ptr<SatSuperframeConf>
134 {
135  NS_LOG_FUNCTION(this << (uint32_t)seqId);
136 
137  if (seqId >= m_superframe.size())
138  {
139  NS_FATAL_ERROR("SatSuperframeSeq::GetSuperframeConf - unsupported sequence id: " << seqId);
140  }
141 
142  return m_superframe[seqId];
143 }
144 
145 uint32_t
146 SatSuperframeSeq::GetCarrierId(uint8_t superframeId, uint8_t frameId, uint16_t frameCarrierId) const
147 {
148  NS_LOG_FUNCTION(this << superframeId << frameId << frameCarrierId);
149 
150  if (superframeId >= m_superframe.size())
151  {
152  NS_FATAL_ERROR(
153  "SatSuperframeSeq::GetCarrierCount - unsupported sequence id: " << superframeId);
154  }
155 
156  uint32_t carrierId = m_superframe[superframeId]->GetCarrierId(frameId, frameCarrierId);
157 
158  for (uint8_t i = 0; i < superframeId; i++)
159  {
160  carrierId += m_superframe[i]->GetCarrierCount();
161  }
162 
163  return carrierId;
164 }
165 
166 double
168 {
169  NS_LOG_FUNCTION(this << carrierId);
170 
171  double superFrameStartFrequency = 0.0;
172  uint32_t currentSuperframe = 0;
173  uint32_t lastIdInSuperframe = m_superframe[0]->GetCarrierCount() - 1;
174  uint32_t carrierIdInSuperframe = carrierId;
175 
176  while (carrierId > lastIdInSuperframe)
177  {
178  carrierIdInSuperframe -= m_superframe[currentSuperframe]->GetCarrierCount();
179  superFrameStartFrequency += m_superframe[currentSuperframe]->GetBandwidthHz();
180  currentSuperframe++;
181  lastIdInSuperframe += m_superframe[currentSuperframe]->GetCarrierCount();
182  }
183 
184  double carrierFrequencyInSuperframe =
185  m_superframe[currentSuperframe]->GetCarrierFrequencyHz(carrierIdInSuperframe);
186 
187  return superFrameStartFrequency + carrierFrequencyInSuperframe;
188 }
189 
190 double
192  SatEnums::CarrierBandwidthType_t bandwidthType) const
193 {
194  NS_LOG_FUNCTION(this << carrierId);
195 
196  uint32_t currentSuperframe = 0;
197  uint32_t lastIdInSuperframe = m_superframe[0]->GetCarrierCount() - 1;
198  uint32_t carrierIdInSuperframe = carrierId;
199 
200  while (carrierId > lastIdInSuperframe)
201  {
202  carrierIdInSuperframe -= m_superframe[currentSuperframe]->GetCarrierCount();
203  currentSuperframe++;
204  lastIdInSuperframe += m_superframe[currentSuperframe]->GetCarrierCount();
205  }
206 
207  return m_superframe[currentSuperframe]->GetCarrierBandwidthHz(carrierIdInSuperframe,
208  bandwidthType);
209 }
210 
211 } // namespace ns3
CarrierBandwidthType_t
Types of bandwidth.
~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.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.