23#include "ns3/uinteger.h"
24#include <ns3/double.h>
26#include <ns3/mobility-model.h>
27#include <ns3/simulator.h>
28#include <ns3/spectrum-value.h>
29#include <ns3/string.h>
30#include <ns3/trace-fading-loss-model.h>
42 : m_streamsAssigned(false)
59 TypeId(
"ns3::TraceFadingLossModel")
61 .SetGroupName(
"Spectrum")
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<uint32_t>())
90 "The number of RNG streams reserved for the fading model. The maximum number of "
91 "streams that are needed for an LTE FDD scenario is 2 * numUEs * numeNBs.",
94 MakeUintegerChecker<uint64_t>());
122 std::ifstream ifTraceFile;
125 if (!ifTraceFile.good())
128 NS_ASSERT_MSG(ifTraceFile.good(),
" Fading trace file not found");
139 ifTraceFile >> sample;
140 rbTimeFadingTrace.push_back(sample);
155 std::map<ChannelRealizationId_t, int>::iterator itOff;
165 std::map<ChannelRealizationId_t, int>::iterator itOff2;
168 std::map<ChannelRealizationId_t, Ptr<UniformRandomVariable>>::iterator itVar;
170 (*itOff2).second = (*itVar).second->GetValue();
177 NS_LOG_LOGIC(
this <<
"insert new channel realization, m_windowOffsetMap.size () = "
181 startV->SetAttribute(
187 "not enough streams, consider increasing the StreamSetSize attribute");
196 .insert(std::pair<ChannelRealizationId_t, int>(mobilityPair, startV->GetValue()))
201 Values::iterator vit = rxPsd->ValuesBegin();
213 int index = ((*itOff).second + now_ms - lastUpdate_ms) %
m_samplesNum;
215 while (vit != rxPsd->ValuesEnd())
221 NS_LOG_INFO(
this <<
" FADING now " << now_ms <<
" offset " << (*itOff).second <<
" id "
222 << index <<
" fading " << fading);
224 power = 10 * std::log10(180000 * power);
226 NS_LOG_LOGIC(
this << subChannel << *vit << power << fading);
228 *vit = std::pow(10., ((power + fading) / 10)) / 180000;
249 std::map<ChannelRealizationId_t, Ptr<UniformRandomVariable>>::iterator itVar;
256 "not enough streams, consider increasing the StreamSetSize attribute");
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
spectrum-aware propagation loss model
void SetNext(Ptr< SpectrumPropagationLossModel > next)
Used to chain various instances of SpectrumPropagationLossModel.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
fading loss model based on precalculated fading traces
uint32_t m_rbNum
RB number.
uint64_t m_streamSetSize
stream set size
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Time m_traceLength
the trace time
std::string m_traceFile
the trace file name
Time m_lastWindowUpdate
time of last window update
void SetTraceLength(Time t)
Set the trace time.
uint32_t m_samplesNum
number of samples
std::pair< Ptr< const MobilityModel >, Ptr< const MobilityModel > > ChannelRealizationId_t
The couple of mobility node that form a fading channel realization.
~TraceFadingLossModel() override
std::vector< double > FadingTraceSample
Vector with fading samples in time domain (for a fixed RB)
uint32_t m_timeGranularity
time granularity
void SetTraceFileName(std::string fileName)
Set the trace file name.
bool m_streamsAssigned
is streams assigned?
static TypeId GetTypeId()
Get the type ID.
std::map< ChannelRealizationId_t, int > m_windowOffsetsMap
windows offsets map
std::map< ChannelRealizationId_t, Ptr< UniformRandomVariable > > m_startVariableMap
start variable map
uint64_t m_currentStream
the current stream
void LoadTrace()
Load trace function.
FadingTrace m_fadingTrace
fading trace
Time m_windowSize
window size
uint64_t m_lastStream
the last stream
void DoInitialize() override
Initialize() implementation.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.