23 #include <ns3/trace-fading-loss-model.h>
24 #include <ns3/mobility-model.h>
25 #include <ns3/spectrum-value.h>
27 #include <ns3/string.h>
28 #include <ns3/double.h>
29 #include "ns3/uinteger.h"
31 #include <ns3/simulator.h>
61 .AddConstructor<TraceFadingLossModel> ()
62 .AddAttribute (
"TraceFilename",
63 "Name of file to load a trace from.",
67 .AddAttribute (
"TraceLength",
68 "The total length of the fading trace (default value 10 s.)",
72 .AddAttribute (
"SamplesNum",
73 "The number of samples the trace is made of (default 10000)",
76 MakeUintegerChecker<uint32_t> ())
77 .AddAttribute (
"WindowSize",
78 "The size of the window for the fading trace (default value 0.5 s.)",
82 .AddAttribute (
"RbNum",
83 "The number of RB the trace is made of (default 100)",
86 MakeUintegerChecker<uint8_t> ())
116 std::ifstream ifTraceFile;
117 ifTraceFile.open (
m_traceFile.c_str (), std::ifstream::in);
119 if (!ifTraceFile.good ())
122 NS_ASSERT_MSG(ifTraceFile.good (),
" Fading trace file not found");
127 for (uint32_t i = 0; i <
m_rbNum; i++)
133 ifTraceFile >> sample;
134 rbTimeFadingTrace.push_back (sample);
151 std::map <ChannelRealizationId_t, int >::iterator itOff;
160 std::map <ChannelRealizationId_t, int >::iterator itOff2;
163 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
165 (*itOff2).second = (*itVar).second->GetValue ();
178 m_windowOffsetsMap.insert (std::pair<ChannelRealizationId_t,int> (mobilityPair, startV->GetValue ()));
194 int index = ((*itOff).second + now_ms - lastUpdate_ms) %
m_samplesNum;
202 NS_LOG_INFO (
this <<
" FADING now " << now_ms <<
" offset " << (*itOff).second <<
" id " << index <<
" fading " << fading);
204 power = 10 * std::log10 (180000 * power);
206 NS_LOG_LOGIC (
this << subChannel << *vit << power << fading);
208 *vit = std::pow (10., ((power + fading) / 10)) / 180000;
227 int64_t currentStream = stream;
228 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
232 (*itVar).second->SetStream (currentStream);
235 return (currentStream - stream);