Loading...
Searching...
No Matches
satellite-interference-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("SatInterferenceInputTraceContainer");
36
37namespace ns3
38{
39
40NS_OBJECT_ENSURE_REGISTERED(SatInterferenceInputTraceContainer);
41
42TypeId
44{
45 static TypeId tid = TypeId("ns3::SatInterferenceInputTraceContainer")
46 .SetParent<SatBaseTraceContainer>()
47 .AddConstructor<SatInterferenceInputTraceContainer>();
48 return tid;
49}
50
55
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 return nullptr;
99 }
100 else
101 {
102 if (utId >= 0 && gwId < 0)
103 {
104 filename << dataPath << "/additional-input/interferencetraces/input/BEAM_" << beamId
105 << "_UT_" << utId << "_channelType_"
106 << SatEnums::GetChannelTypeName(key.second);
107 }
108
109 if (gwId >= 0 && utId < 0)
110 {
111 filename << dataPath << "/additional-input/interferencetraces/input/BEAM_" << beamId
112 << "_GW_" << gwId << "_channelType_"
113 << SatEnums::GetChannelTypeName(key.second);
114 }
115
116 std::pair<container_t::iterator, bool> result = m_container.insert(
117 std::make_pair(key,
118 CreateObject<SatInputFileStreamTimeDoubleContainer>(
119 filename.str().c_str(),
120 std::ios::in,
122
123 if (result.second == false)
124 {
125 NS_FATAL_ERROR("SatInterferenceInputTraceContainer::AddNode failed");
126 }
127
128 NS_LOG_INFO("Added node with MAC " << key.first << " channel type " << key.second);
129
130 return result.first->second;
131 }
132
133 NS_FATAL_ERROR("SatInterferenceInputTraceContainer::AddNode failed");
134 return nullptr;
135}
136
137Ptr<SatInputFileStreamTimeDoubleContainer>
139{
140 NS_LOG_FUNCTION(this);
141
142 container_t::iterator iter = m_container.find(key);
143
144 if (iter == m_container.end())
145 {
146 return AddNode(key);
147 }
148
149 return iter->second;
150}
151
152double
154{
155 NS_LOG_FUNCTION(this);
156
157 return FindNode(key)->ProceedToNextClosestTimeSample().at(
159}
160
161} // namespace ns3
static const uint32_t INTF_TRACE_DEFAULT_INTF_DENSITY_INDEX
Default interference density index for interference traces.
static const uint32_t INTF_TRACE_DEFAULT_NUMBER_OF_COLUMNS
Default number of columns for interference traces.
static std::string GetChannelTypeName(ChannelType_t channelType)
static Ptr< SatEnvVariables > GetInstance()
double GetInterferenceDensity(key_t key)
Function for getting the interference density.
Ptr< SatInputFileStreamTimeDoubleContainer > FindNode(key_t key)
Function for finding the container matching the key.
Ptr< SatInputFileStreamTimeDoubleContainer > AddNode(std::pair< Address, SatEnums::ChannelType_t > key)
Function for adding the node to the map.
std::pair< Address, SatEnums::ChannelType_t > key_t
typedef for map key
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.