satellite-waveform-conf-test.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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
27 #include "../model/satellite-bbframe-conf.h"
28 #include "../model/satellite-enums.h"
29 #include "../model/satellite-link-results.h"
30 #include "../model/satellite-utils.h"
31 #include "../model/satellite-wave-form-conf.h"
32 
33 #include "ns3/boolean.h"
34 #include "ns3/config.h"
35 #include "ns3/log.h"
36 #include "ns3/ptr.h"
37 #include "ns3/satellite-env-variables.h"
38 #include "ns3/singleton.h"
39 #include "ns3/test.h"
40 
41 using namespace ns3;
42 
54 class SatDvbRcs2WaveformTableTestCase : public TestCase
55 {
56  public:
59 
60  private:
61  virtual void DoRun(void);
62 };
63 
65  : TestCase("Test DVB-RCS2 waveform configuration table.")
66 {
67 }
68 
70 {
71 }
72 
73 void
75 {
76  // Set simulation output details
77  Singleton<SatEnvVariables>::Get()->DoInitialize();
78  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-waveform-conf",
79  "dvbrcs2",
80  true);
81 
82  std::string path = Singleton<SatEnvVariables>::Get()->GetDataPath() + "/";
83  std::string fileName = "dvbRcs2Waveforms.txt";
84 
85  // Enable ACM
86  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
87 
88  Ptr<SatLinkResultsDvbRcs2> lr = CreateObject<SatLinkResultsDvbRcs2>();
89  lr->Initialize();
90 
91  Ptr<SatWaveformConf> wf = CreateObject<SatWaveformConf>(path + fileName);
92  wf->InitializeEbNoRequirements(lr);
93 
94  uint32_t refResults[21] = {6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10,
95  11, 11, 11, 12, 12, 12, 12, 12, 12, 12};
96 
97  // 250 kbaud
98  double symbolRate(250000);
99  uint32_t i(0);
100 
101  // Method capable of dumping the waveform conf to standard output
102  /*
103  double rollOff (0.2);
104  double carrierBandwidth = (1.0 + rollOff) * symbolRate;
105  wf->Dump (carrierBandwidth, symbolRate);
106  */
107 
108  for (double d = 60.0; d <= 70.0; d += 0.5)
109  {
110  uint32_t wfid(0);
111  double cnoThreshold = std::numeric_limits<double>::quiet_NaN();
112  bool success =
113  wf->GetBestWaveformId(SatUtils::DbToLinear(d), symbolRate, wfid, cnoThreshold);
114 
115  NS_TEST_ASSERT_MSG_EQ(success, true, "A suitable waveform not found");
116  NS_TEST_ASSERT_MSG_EQ(wfid, refResults[i], "Not expected waveform id");
117  ++i;
118  }
119  Singleton<SatEnvVariables>::Get()->DoDispose();
120 }
121 
131 class SatDvbS2BbFrameConfTestCase : public TestCase
132 {
133  public:
136 
137  private:
138  virtual void DoRun(void);
139 };
140 
142  : TestCase("Test DVB-S2 BBFrame configuration.")
143 {
144 }
145 
147 {
148 }
149 
150 void
152 {
153  // Set simulation output details
154  Singleton<SatEnvVariables>::Get()->DoInitialize();
155  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-waveform-conf", "dvbs2", true);
156 
157  // Tested symbol rate in baud
158  double symbolRate(93750000);
159 
160  Ptr<SatLinkResultsDvbS2> lr = CreateObject<SatLinkResultsDvbS2>();
161  lr->Initialize();
162 
163  // Create BBFrame conf
164  Ptr<SatBbFrameConf> bbFrameConf = CreateObject<SatBbFrameConf>(symbolRate, SatEnums::DVB_S2);
165  bbFrameConf->InitializeCNoRequirements(lr);
166 
167  std::vector<SatEnums::SatModcod_t> modcods;
168  SatEnums::GetAvailableModcodsFwdLink(modcods);
169 
175  // SatEnums::SatBbFrameType_t frameTypes[2] = { SatEnums::SHORT_FRAME,
176  // SatEnums::NORMAL_FRAME,
177  // };
178 
179  SatEnums::SatBbFrameType_t frameTypes[1] = {SatEnums::NORMAL_FRAME};
180 
181  std::cout << "BBFrame config output: " << std::endl;
182  std::cout << "----------------------" << std::endl;
183 
184  // BBFrames
185  for (uint32_t i = 0; i < 1; ++i)
186  {
187  // Modcods
188  for (std::vector<SatEnums::SatModcod_t>::iterator it = modcods.begin(); it != modcods.end();
189  ++it)
190  {
191  // Get BBFrame length in Time
192  Time l = bbFrameConf->GetBbFrameDuration((*it), frameTypes[i]);
193 
194  // Get BBFrame payload in bits
195  uint32_t p = bbFrameConf->GetBbFramePayloadBits(*it, frameTypes[i]);
196 
197  std::cout << "MODCOD: " << SatEnums::GetModcodTypeName(*it)
198  << ", frameType: " << frameTypes[i] << ", length [s]: " << l.GetSeconds()
199  << ", payload [b]: " << p << std::endl;
200  }
201  }
202  Singleton<SatEnvVariables>::Get()->DoDispose();
203 }
204 
209 class SatWaveformConfTestSuite : public TestSuite
210 {
211  public:
213 };
214 
216  : TestSuite("sat-waveform-conf-test", UNIT)
217 {
218  AddTestCase(new SatDvbRcs2WaveformTableTestCase, TestCase::QUICK);
219  AddTestCase(new SatDvbS2BbFrameConfTestCase, TestCase::QUICK);
220 }
221 
222 // Do allocate an instance of this TestSuite
Test case to unit test to create BBFrame conf and its public methods.
Test suite for Satellite free space loss unit test cases.
SatBbFrameType_t
BB frame type used in DVB-S2 FWD link.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatWaveformConfTestSuite satWaveformConfTestSuite