Loading...
Searching...
No Matches
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
26
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
41using namespace ns3;
42
54class 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
72
73void
75{
76 // Set simulation output details
77 SatEnvVariables::GetInstance()->DoInitialize();
78 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-waveform-conf", "dvbrcs2", true);
79
80 std::string path = SatEnvVariables::GetInstance()->GetDataPath() + "/";
81 std::string folderName = "scenarios/geo-33E/waveforms";
82
83 // Enable ACM
84 Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
85
86 Ptr<SatLinkResultsDvbRcs2> lr = CreateObject<SatLinkResultsDvbRcs2>();
87 lr->Initialize();
88
89 Ptr<SatWaveformConf> wf = CreateObject<SatWaveformConf>(path + folderName);
90 wf->InitializeEbNoRequirements(lr);
91
92 uint32_t refResults[21] = {6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10,
93 11, 11, 11, 12, 12, 12, 12, 12, 12, 12};
94
95 // 250 kbaud
96 double symbolRate(250000);
97 uint32_t i(0);
98
99 // Method capable of dumping the waveform conf to standard output
100 /*
101 double rollOff (0.2);
102 double carrierBandwidth = (1.0 + rollOff) * symbolRate;
103 wf->Dump (carrierBandwidth, symbolRate);
104 */
105
106 for (double d = 60.0; d <= 70.0; d += 0.5)
107 {
108 uint32_t wfid(0);
109 double cnoThreshold = std::numeric_limits<double>::quiet_NaN();
110 bool success =
111 wf->GetBestWaveformId(SatUtils::DbToLinear(d), symbolRate, wfid, cnoThreshold);
112
113 NS_TEST_ASSERT_MSG_EQ(success, true, "A suitable waveform not found");
114 NS_TEST_ASSERT_MSG_EQ(wfid, refResults[i], "Not expected waveform id");
115 ++i;
116 }
117 SatEnvVariables::GetInstance()->DoDispose();
118}
119
129class SatDvbS2BbFrameConfTestCase : public TestCase
130{
131 public:
134
135 private:
136 virtual void DoRun(void);
137};
138
140 : TestCase("Test DVB-S2 BBFrame configuration.")
141{
142}
143
147
148void
150{
151 // Set simulation output details
152 SatEnvVariables::GetInstance()->DoInitialize();
153 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-waveform-conf", "dvbs2", true);
154
155 // Tested symbol rate in baud
156 double symbolRate(93750000);
157
158 Ptr<SatLinkResultsDvbS2> lr = CreateObject<SatLinkResultsDvbS2>();
159 lr->Initialize();
160
161 // Create BBFrame conf
162 Ptr<SatBbFrameConf> bbFrameConf = CreateObject<SatBbFrameConf>(symbolRate, SatEnums::DVB_S2);
163 bbFrameConf->InitializeCNoRequirements(lr);
164
165 std::vector<SatEnums::SatModcod_t> modcods;
167
172
173 // SatEnums::SatBbFrameType_t frameTypes[2] = { SatEnums::SHORT_FRAME,
174 // SatEnums::NORMAL_FRAME,
175 // };
176
178
179 std::cout << "BBFrame config output: " << std::endl;
180 std::cout << "----------------------" << std::endl;
181
182 // BBFrames
183 for (uint32_t i = 0; i < 1; ++i)
184 {
185 // Modcods
186 for (std::vector<SatEnums::SatModcod_t>::iterator it = modcods.begin(); it != modcods.end();
187 ++it)
188 {
189 // Get BBFrame length in Time
190 Time l = bbFrameConf->GetBbFrameDuration((*it), frameTypes[i]);
191
192 // Get BBFrame payload in bits
193 uint32_t p = bbFrameConf->GetBbFramePayloadBits(*it, frameTypes[i]);
194
195 std::cout << "MODCOD: " << SatEnums::GetModcodTypeName(*it)
196 << ", frameType: " << frameTypes[i] << ", length [s]: " << l.GetSeconds()
197 << ", payload [b]: " << p << std::endl;
198 }
199 }
200 SatEnvVariables::GetInstance()->DoDispose();
201}
202
207class SatWaveformConfTestSuite : public TestSuite
208{
209 public:
211};
212
214 : TestSuite("sat-waveform-conf-test", Type::UNIT)
215{
216 AddTestCase(new SatDvbRcs2WaveformTableTestCase, TestCase::Duration::QUICK);
217 AddTestCase(new SatDvbS2BbFrameConfTestCase, TestCase::Duration::QUICK);
218}
219
220// 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.
static std::string GetModcodTypeName(SatModcod_t modcod)
static void GetAvailableModcodsFwdLink(std::vector< SatModcod_t > &modcods)
static Ptr< SatEnvVariables > GetInstance()
static T DbToLinear(T db)
Converts decibels to linear.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatWaveformConfTestSuite satWaveformConfTestSuite