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>
42 : m_streamsAssigned (false)
62 .AddConstructor<TraceFadingLossModel> ()
63 .AddAttribute (
"TraceFilename",
64 "Name of file to load a trace from.",
68 .AddAttribute (
"TraceLength",
69 "The total length of the fading trace (default value 10 s.)",
73 .AddAttribute (
"SamplesNum",
74 "The number of samples the trace is made of (default 10000)",
77 MakeUintegerChecker<uint32_t> ())
78 .AddAttribute (
"WindowSize",
79 "The size of the window for the fading trace (default value 0.5 s.)",
83 .AddAttribute (
"RbNum",
84 "The number of RB the trace is made of (default 100)",
87 MakeUintegerChecker<uint8_t> ())
88 .AddAttribute (
"RngStreamSetSize",
89 "The number of RNG streams reserved for the fading model. The maximum number of streams that are needed for an LTE FDD scenario is 2 * numUEs * numeNBs.",
92 MakeUintegerChecker<uint64_t> ())
122 std::ifstream ifTraceFile;
123 ifTraceFile.open (
m_traceFile.c_str (), std::ifstream::in);
125 if (!ifTraceFile.good ())
128 NS_ASSERT_MSG(ifTraceFile.good (),
" Fading trace file not found");
133 for (uint32_t i = 0; i <
m_rbNum; i++)
139 ifTraceFile >> sample;
140 rbTimeFadingTrace.push_back (sample);
157 std::map <ChannelRealizationId_t, int >::iterator itOff;
166 std::map <ChannelRealizationId_t, int >::iterator itOff2;
169 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
171 (*itOff2).second = (*itVar).second->GetValue ();
190 m_windowOffsetsMap.insert (std::pair<ChannelRealizationId_t,int> (mobilityPair, startV->GetValue ()));
195 Values::iterator vit = rxPsd->ValuesBegin ();
206 int index = ((*itOff).second + now_ms - lastUpdate_ms) %
m_samplesNum;
208 while (vit != rxPsd->ValuesEnd ())
214 NS_LOG_INFO (
this <<
" FADING now " << now_ms <<
" offset " << (*itOff).second <<
" id " << index <<
" fading " << fading);
216 power = 10 * std::log10 (180000 * power);
218 NS_LOG_LOGIC (
this << subChannel << *vit << power << fading);
220 *vit = std::pow (10., ((power + fading) / 10)) / 180000;
243 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
keep track of time values and allow control of global simulation resolution
FadingTrace m_fadingTrace
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
int64_t AssignStreams(int64_t stream)
std::vector< double > FadingTraceSample
hold variables of type string
virtual void DoInitialize(void)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
static TypeId GetTypeId()
double GetSeconds(void) const
std::pair< Ptr< const MobilityModel >, Ptr< const MobilityModel > > ChannelRealizationId_t
The couple of mobility mnode that form a fading channel realization.
hold objects of type ns3::Time
Hold an unsigned integer type.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
std::map< ChannelRealizationId_t, Ptr< UniformRandomVariable > > m_startVariableMap
void SetTraceFileName(std::string fileName)
uint8_t m_timeGranularity
void SetTraceLength(Time t)
#define NS_LOG_LOGIC(msg)
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
void SetNext(Ptr< SpectrumPropagationLossModel > next)
#define NS_ASSERT_MSG(condition, message)
virtual ~TraceFadingLossModel()
std::map< ChannelRealizationId_t, int > m_windowOffsetsMap
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
spectrum-aware propagation loss model
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface.
int64_t GetMilliSeconds(void) const
TypeId SetParent(TypeId tid)