Loading...
Searching...
No Matches
satellite-ut-helper.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 * Copyright (c) 2018 CNES
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Sami Rantanen <sami.rantanen@magister.fi>
20 * Author: Mathias Ettinger <mettinger@viveris.toulouse.fr>
21 */
22
23#include "satellite-ut-helper.h"
24
25#include "ns3/boolean.h"
26#include "ns3/callback.h"
27#include "ns3/config.h"
28#include "ns3/double.h"
29#include "ns3/enum.h"
30#include "ns3/log.h"
31#include "ns3/pointer.h"
32#include "ns3/satellite-channel-estimation-error-container.h"
33#include "ns3/satellite-channel.h"
34#include "ns3/satellite-enums.h"
35#include "ns3/satellite-net-device.h"
36#include "ns3/satellite-phy-rx-carrier-conf.h"
37#include "ns3/satellite-typedefs.h"
38
39#include <string>
40
41NS_LOG_COMPONENT_DEFINE("SatUtHelper");
42
43namespace ns3
44{
45
46NS_OBJECT_ENSURE_REGISTERED(SatUtHelper);
47
48TypeId
50{
51 static TypeId tid =
52 TypeId("ns3::SatUtHelper")
53 .SetParent<Object>()
54 .AddAttribute("DaFwdLinkInterferenceModel",
55 "Forward link interference model for dedicated access",
57 MakeEnumAccessor<SatPhyRxCarrierConf::InterferenceModel>(
60 "Constant",
62 "Trace",
64 "PerPacket",
66 "PerFragment"))
67 .AddAttribute(
68 "FwdLinkErrorModel",
69 "Forward link error model",
71 MakeEnumAccessor<SatPhyRxCarrierConf::ErrorModel>(&SatUtHelper::m_errorModel),
72 MakeEnumChecker(SatPhyRxCarrierConf::EM_NONE,
73 "None",
75 "Constant",
77 "AVI"))
78 .AddAttribute("FwdLinkConstantErrorRate",
79 "Constant error rate",
80 DoubleValue(0.01),
81 MakeDoubleAccessor(&SatUtHelper::m_daConstantErrorRate),
82 MakeDoubleChecker<double>())
83 .AddAttribute("LowerLayerServiceConf",
84 "Pointer to lower layer service configuration.",
85 PointerValue(),
86 MakePointerAccessor(&SatUtHelper::m_llsConf),
87 MakePointerChecker<SatLowerLayerServiceConf>())
88 .AddAttribute("EnableChannelEstimationError",
89 "Enable channel estimation error in forward link receiver at UT.",
90 BooleanValue(true),
92 MakeBooleanChecker())
93 .AddAttribute("UseCrdsaOnlyForControlPackets",
94 "CRDSA utilized only for control packets or also for user data.",
95 BooleanValue(false),
96 MakeBooleanAccessor(&SatUtHelper::m_crdsaOnlyForControl),
97 MakeBooleanChecker())
98 .AddAttribute("AsynchronousReturnAccess",
99 "Use asynchronous access methods on the return channel.",
100 BooleanValue(false),
101 MakeBooleanAccessor(&SatUtHelper::m_asyncAccess),
102 MakeBooleanChecker())
103 .AddTraceSource("Creation",
104 "Creation traces",
105 MakeTraceSourceAccessor(&SatUtHelper::m_creationTrace),
106 "ns3::SatTypedefs::CreationCallback");
107 return tid;
108}
109
118 m_llsConf(),
121 m_asyncAccess(false),
123{
124 NS_LOG_FUNCTION(this);
125
126 // this default constructor should be never called
127 NS_FATAL_ERROR("SatUtHelper::SatUtHelper - Constructor not in use");
128}
129
131 uint32_t fwdLinkCarrierCount,
132 Ptr<SatSuperframeSeq> seq,
136 RandomAccessSettings_s randomAccessSettings)
137 : m_carrierBandwidthConverter(carrierBandwidthConverter),
138 m_fwdLinkCarrierCount(fwdLinkCarrierCount),
139 m_superframeSeq(seq),
140 m_readCtrlCb(readCb),
141 m_reserveCtrlCb(reserveCb),
142 m_sendCtrlCb(sendCb),
147 m_llsConf(),
150 m_raSettings(randomAccessSettings)
151{
152 NS_LOG_FUNCTION(this << fwdLinkCarrierCount << seq);
153 m_deviceFactory.SetTypeId("ns3::SatNetDevice");
154 m_channelFactory.SetTypeId("ns3::SatChannel");
155
156 m_llsConf = CreateObject<SatLowerLayerServiceConf>();
157}
158
159void
160SatUtHelper::Initialize(Ptr<SatLinkResultsFwd> lrFwd)
161{
162 NS_LOG_FUNCTION(this);
163 /*
164 * Forward channel link results (DVB-S2 or DVB-S2X) are created for UTs.
165 */
167 {
168 m_linkResults = lrFwd;
169 }
170}
171
172void
173SatUtHelper::SetDeviceAttribute(std::string n1, const AttributeValue& v1)
174{
175 NS_LOG_FUNCTION(this << n1);
176
177 m_deviceFactory.Set(n1, v1);
178}
179
180void
181SatUtHelper::SetChannelAttribute(std::string n1, const AttributeValue& v1)
182{
183 NS_LOG_FUNCTION(this << n1);
184
185 m_channelFactory.Set(n1, v1);
186}
187
188void
189SatUtHelper::SetPhyAttribute(std::string n1, const AttributeValue& v1)
190{
191 NS_LOG_FUNCTION(this << n1);
192
193 Config::SetDefault("ns3::SatUtPhy::" + n1, v1);
194}
195
196NetDeviceContainer
197SatUtHelper::Install(NodeContainer c,
198 uint32_t satId,
199 uint32_t beamId,
200 Ptr<SatChannel> fCh,
201 Ptr<SatChannel> rCh,
202 Ptr<SatNetDevice> gwNd,
203 Ptr<SatNcc> ncc,
204 Address satUserAddress,
207{
208 NS_LOG_FUNCTION(this << satId << beamId << fCh << rCh << gwNd << ncc << satUserAddress);
209
210 NetDeviceContainer devs;
211
212 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
213 {
214 devs.Add(
215 Install(*i, satId, beamId, fCh, rCh, gwNd, ncc, satUserAddress, cbChannel, cbRouting));
216 }
217
218 return devs;
219}
220
221void
222SatUtHelper::EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb)
223{
224 NS_LOG_FUNCTION(this);
225
226 TraceConnect("Creation", "SatUtHelper", cb);
227}
228
229} // namespace ns3
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
Callback< void, Address, Address > RoutingUpdateCallback
Callback to update routing and ARP tables after handover.
Callback< uint32_t, uint32_t > SendCtrlMsgCallback
Callback to send a control message and allocate a recv ID for it.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
Callback< SatChannelPair::ChannelPair_t, uint32_t, uint32_t > ChannelPairGetterCallback
Callback for retrieving a pair of SatChannel associated to a beam.
Information of beam users liken UTs and their users.
Callback< double, SatEnums::ChannelType_t, uint32_t, SatEnums::CarrierBandwidthType_t > CarrierBandwidthConverter_t
Callback for carrier bandwidths.
Creates needed objects for UT nodes like SatOrbiterNetDevice objects.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
SatPhy::ErrorModel m_errorModel
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
SatPhy::InterferenceModel m_daInterferenceModel
RandomAccessSettings_s m_raSettings
The used random access model settings.
bool m_enableChannelEstimationError
Enable channel estimation error modeling at forward link receiver (= UT).
SatMac::ReadCtrlMsgCallback m_readCtrlCb
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
void SetPhyAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Phy created by the helper.
void Initialize(Ptr< SatLinkResultsFwd > lrFwd)
ObjectFactory m_channelFactory
NetDeviceContainer Install(NodeContainer c, uint32_t satId, uint32_t beamId, Ptr< SatChannel > fCh, Ptr< SatChannel > rCh, Ptr< SatNetDevice > gwNd, Ptr< SatNcc > ncc, Address satUserAddress, SatPhy::ChannelPairGetterCallback cbChannel, SatMac::RoutingUpdateCallback cbRouting)
Ptr< SatLinkResults > m_linkResults
Ptr< SatLowerLayerServiceConf > m_llsConf
Configured lower layer service configuration.
SatUtHelper()
Default constructor.
SatTypedefs::CarrierBandwidthConverter_t m_carrierBandwidthConverter
ObjectFactory m_deviceFactory
bool m_crdsaOnlyForControl
Planned CRDSA usage:
SatMac::SendCtrlMsgCallback m_sendCtrlCb
Ptr< SatSuperframeSeq > m_superframeSeq
SatMac::ReserveCtrlMsgCallback m_reserveCtrlCb
static TypeId GetTypeId(void)
Derived from Object.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Define RandomAccessSettings as a struct.