Loading...
Searching...
No Matches
satellite-fading-input-trace-container.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: Frans Laakso <frans.laakso@magister.fi>
19 */
20
22
24#include "satellite-id-mapper.h"
25
26#include "ns3/log.h"
27#include "ns3/singleton.h"
28
29#include <ios>
30#include <sstream>
31#include <stdint.h>
32#include <string>
33#include <utility>
34
35NS_LOG_COMPONENT_DEFINE("SatFadingInputTraceContainer");
36
37namespace ns3
38{
39
40NS_OBJECT_ENSURE_REGISTERED(SatFadingInputTraceContainer);
41
42TypeId
44{
45 static TypeId tid = TypeId("ns3::SatFadingInputTraceContainer")
46 .SetParent<SatBaseTraceContainer>()
47 .AddConstructor<SatFadingInputTraceContainer>();
48 return tid;
49}
50
55
57{
58 NS_LOG_FUNCTION(this);
59
60 Reset();
61}
62
63void
65{
66 NS_LOG_FUNCTION(this);
67
68 Reset();
69
70 SatBaseTraceContainer::DoDispose();
71}
72
73void
75{
76 NS_LOG_FUNCTION(this);
77
78 if (!m_container.empty())
79 {
80 m_container.clear();
81 }
82}
83
84Ptr<SatInputFileStreamTimeDoubleContainer>
86{
87 NS_LOG_FUNCTION(this);
88
89 std::stringstream filename;
90 std::string dataPath = SatEnvVariables::GetInstance()->LocateDataDirectory();
91
92 int32_t gwId = Singleton<SatIdMapper>::Get()->GetGwIdWithMac(key.first);
93 int32_t utId = Singleton<SatIdMapper>::Get()->GetUtIdWithMac(key.first);
94 int32_t beamId = Singleton<SatIdMapper>::Get()->GetBeamIdWithMac(key.first);
95
96 if (beamId < 0 || (utId < 0 && gwId < 0))
97 {
98 NS_FATAL_ERROR(
99 "SatFadingInputTraceContainer::AddNode - No such MAC address in the trace ID mapper");
100 }
101 else
102 {
103 if (utId >= 0 && gwId < 0)
104 {
105 filename << dataPath << "/additional-input/fadingtraces/input/BEAM_" << beamId << "_UT_"
106 << utId << "_channelType_" << SatEnums::GetChannelTypeName(key.second);
107 }
108
109 if (gwId >= 0 && utId < 0)
110 {
111 filename << dataPath << "/additional-input/fadingtraces/input/BEAM_" << beamId << "_GW_"
112 << gwId << "_channelType_" << SatEnums::GetChannelTypeName(key.second);
113 }
114 std::pair<container_t::iterator, bool> result = m_container.insert(
115 std::make_pair(key,
116 CreateObject<SatInputFileStreamTimeDoubleContainer>(
117 filename.str().c_str(),
118 std::ios::in,
120
121 if (result.second == false)
122 {
123 NS_FATAL_ERROR("SatFadingInputTraceContainer::AddNode failed");
124 }
125
126 NS_LOG_INFO("Added node with MAC " << key.first << " channel type " << key.second);
127
128 return result.first->second;
129 }
130
131 NS_FATAL_ERROR("SatFadingInputTraceContainer::AddNode failed");
132 return nullptr;
133}
134
135Ptr<SatInputFileStreamTimeDoubleContainer>
137{
138 NS_LOG_FUNCTION(this);
139
140 container_t::iterator iter = m_container.find(key);
141
142 if (iter == m_container.end())
143 {
144 return AddNode(key);
145 }
146
147 return iter->second;
148}
149
150double
152{
153 NS_LOG_FUNCTION(this);
154
155 return FindNode(key)->ProceedToNextClosestTimeSample().at(
157}
158
159} // namespace ns3
static const uint32_t FADING_TRACE_DEFAULT_NUMBER_OF_COLUMNS
Default number of columns for fading traces.
static const uint32_t FADING_TRACE_DEFAULT_FADING_VALUE_INDEX
Default fading value index for fading traces.
static std::string GetChannelTypeName(ChannelType_t channelType)
static Ptr< SatEnvVariables > GetInstance()
std::pair< Address, SatEnums::ChannelType_t > key_t
typedef for map key
static TypeId GetTypeId(void)
NS-3 type id function.
double GetFadingValue(key_t key)
Function for getting the fading value.
void Reset()
Function for resetting the variables.
Ptr< SatInputFileStreamTimeDoubleContainer > AddNode(std::pair< Address, SatEnums::ChannelType_t > key)
Function for adding the node to the map.
Ptr< SatInputFileStreamTimeDoubleContainer > FindNode(key_t key)
Function for finding the container matching the key.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.