24 #include "ns3/core-module.h"
26 #include "ns3/satellite-id-mapper.h"
27 #include "ns3/satellite-rx-cno-input-trace-container.h"
28 #include "ns3/satellite-topology.h"
29 #include "ns3/singleton.h"
34 NS_LOG_COMPONENT_DEFINE(
"SatelliteCnoHelper");
39 NS_OBJECT_ENSURE_REGISTERED(SatCnoHelper);
45 TypeId(
"ns3::SatCnoHelper").SetParent<Object>().AddConstructor<SatCnoHelper>();
52 NS_LOG_FUNCTION(
this);
58 : m_satHelper(nullptr),
61 Config::Set(
"/ChannelList/*/$ns3::SatChannel/RxPowerCalculationMode",
66 : m_satHelper(satHelper),
69 Config::Set(
"/ChannelList/*/$ns3::SatChannel/RxPowerCalculationMode",
85 NS_FATAL_ERROR(
"Can only apply custom GWs C/N0 on feeder channels");
89 NS_FATAL_ERROR(
"Trying to set custom C/N0 several time for same node and channel");
107 NS_FATAL_ERROR(
"Can only apply custom UTs C/N0 on user channels");
111 NS_FATAL_ERROR(
"Trying to set custom C/N0 several time for same node and channel");
127 SetGwNodeCno(Singleton<SatTopology>::Get()->GetGwNode(nodeId), channel, cno);
133 SetUtNodeCno(Singleton<SatTopology>::Get()->GetUtNode(nodeId), channel, cno);
139 for (uint32_t i = 0; i < nodes.GetN(); i++)
148 for (uint32_t i = 0; i < nodes.GetN(); i++)
159 NS_FATAL_ERROR(
"Can only apply custom GWs C/N0 on feeder channels");
163 NS_FATAL_ERROR(
"Trying to set custom C/N0 several time for same node and channel");
181 NS_FATAL_ERROR(
"Can only apply custom UTs C/N0 on user channels");
185 NS_FATAL_ERROR(
"Trying to set custom C/N0 several time for same node and channel");
201 SetGwNodeCnoFile(Singleton<SatTopology>::Get()->GetGwNode(nodeId), channel, path);
207 SetUtNodeCnoFile(Singleton<SatTopology>::Get()->GetUtNode(nodeId), channel, path);
213 Singleton<SatRxCnoInputTraceContainer>::Get()->Reset();
215 std::pair<Address, SatEnums::ChannelType_t> key;
216 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
217 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
223 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); it++)
226 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetGwMacWithNode(gwNode),
228 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCno(key, 0);
229 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetGwMacWithNode(gwNode),
231 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCno(key, 0);
234 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
237 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetUtMacWithNode(utNode),
239 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCno(key, 0);
240 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetUtMacWithNode(utNode),
242 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCno(key, 0);
249 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); it++)
252 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetGwMacWithNode(gwNode),
254 Singleton<SatRxCnoInputTraceContainer>::Get()->AddNode(key);
255 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetGwMacWithNode(gwNode),
257 Singleton<SatRxCnoInputTraceContainer>::Get()->AddNode(key);
260 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); it++)
263 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetUtMacWithNode(utNode),
265 Singleton<SatRxCnoInputTraceContainer>::Get()->AddNode(key);
266 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetUtMacWithNode(utNode),
268 Singleton<SatRxCnoInputTraceContainer>::Get()->AddNode(key);
277 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetGwMacWithNode(params.node),
282 key = std::make_pair(Singleton<SatIdMapper>::Get()->GetUtMacWithNode(params.node),
288 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCno(key, params.cno);
293 Singleton<SatRxCnoInputTraceContainer>::Get()->SetRxCnoFile(key, params.pathToFile);
303 if (params.node == node && params.channelType == channel)
void ApplyConfiguration()
Apply configuration to all the satellite channels Needs to be done after node creation.
void SetGwNodeCnoFile(Ptr< Node > node, SatEnums::ChannelType_t channel, std::string path)
Set a constant C/N0 for one GW node and one channel direction.
static TypeId GetTypeId(void)
Get the type ID.
bool m_useTraces
Use C/N0 input traces instead of power calculation from antenna gain.
std::vector< cnoCustomParams_s > m_customCno
Array storing manual C/N0 updates (constant or custom file)
void UseTracesForDefault(bool useTraces)
Set m_useTraces attribute.
void SetUtNodeCnoFile(Ptr< Node > node, SatEnums::ChannelType_t channel, std::string path)
Set a constant C/N0 for one UT node and one channel direction.
void SetGwNodeCno(Ptr< Node > node, SatEnums::ChannelType_t channel, double cno)
Set a constant C/N0 for one GW node and one channel direction.
bool CheckDuplicate(Ptr< Node > node, SatEnums::ChannelType_t channel)
Verify if a node has already been set.
TypeId GetInstanceTypeId(void) const
Get the type ID of object instance.
void SetUtNodeCno(Ptr< Node > node, SatEnums::ChannelType_t channel, double cno)
Set a constant C/N0 for one UT node and one channel direction.
SatCnoHelper()
Default constructor.
ChannelType_t
Types of channel.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the custom C/N0 for some nodes.
SatEnums::ChannelType_t channelType