|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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 .SetGroupName (
"Spectrum")
64 .AddAttribute (
"TraceFilename",
65 "Name of file to load a trace from.",
69 .AddAttribute (
"TraceLength",
70 "The total length of the fading trace (default value 10 s.)",
74 .AddAttribute (
"SamplesNum",
75 "The number of samples the trace is made of (default 10000)",
78 MakeUintegerChecker<uint32_t> ())
79 .AddAttribute (
"WindowSize",
80 "The size of the window for the fading trace (default value 0.5 s.)",
84 .AddAttribute (
"RbNum",
85 "The number of RB the trace is made of (default 100)",
88 MakeUintegerChecker<uint8_t> ())
89 .AddAttribute (
"RngStreamSetSize",
90 "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.",
93 MakeUintegerChecker<uint64_t> ())
123 std::ifstream ifTraceFile;
124 ifTraceFile.open (
m_traceFile.c_str (), std::ifstream::in);
126 if (!ifTraceFile.good ())
129 NS_ASSERT_MSG(ifTraceFile.good (),
" Fading trace file not found");
134 for (uint32_t i = 0; i <
m_rbNum; i++)
140 ifTraceFile >> sample;
141 rbTimeFadingTrace.push_back (sample);
158 std::map <ChannelRealizationId_t, int >::iterator itOff;
167 std::map <ChannelRealizationId_t, int >::iterator itOff2;
170 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
172 (*itOff2).second = (*itVar).second->GetValue ();
207 int index = ((*itOff).second + now_ms - lastUpdate_ms) %
m_samplesNum;
215 NS_LOG_INFO (
this <<
" FADING now " << now_ms <<
" offset " << (*itOff).second <<
" id " << index <<
" fading " << fading);
217 power = 10 * std::log10 (180000 * power);
219 NS_LOG_LOGIC (
this << subChannel << *vit << power << fading);
221 *vit = std::pow (10., ((power + fading) / 10)) / 180000;
244 std::map <ChannelRealizationId_t, Ptr<UniformRandomVariable> >::iterator itVar;
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual ~TraceFadingLossModel()
virtual void DoInitialize(void)
Initialize() implementation.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::map< ChannelRealizationId_t, Ptr< UniformRandomVariable > > m_startVariableMap
start variable map
Values::iterator ValuesBegin()
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetTraceFileName(std::string fileName)
Set the trace file name.
uint64_t m_lastStream
the last stream
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
spectrum-aware propagation loss model
uint64_t m_streamSetSize
stream set size
void SetTraceLength(Time t)
Set the trace time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void SetNext(Ptr< SpectrumPropagationLossModel > next)
Used to chain various instances of SpectrumPropagationLossModel.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
std::pair< Ptr< const MobilityModel >, Ptr< const MobilityModel > > ChannelRealizationId_t
The couple of mobility node that form a fading channel realization.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint64_t m_currentStream
the current stream
std::string m_traceFile
the trace file name
Time m_traceLength
the trace time
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Simulation virtual time values and global simulation resolution.
Values::iterator ValuesEnd()
Time m_lastWindowUpdate
time of last window update
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
fading loss model based on precalculated fading traces
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Hold variables of type string.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time m_windowSize
window size
uint8_t m_timeGranularity
time granularity
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void LoadTrace()
Load trace function.
static TypeId GetTypeId()
Get the type ID.
bool m_streamsAssigned
is streams assigned?
Ptr< const AttributeChecker > MakeStringChecker(void)
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint8_t m_rbNum
RB number.
Hold an unsigned integer type.
std::map< ChannelRealizationId_t, int > m_windowOffsetsMap
windows offsets map
uint32_t m_samplesNum
number of samples
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
FadingTrace m_fadingTrace
fading trace
std::vector< double > FadingTraceSample
Vector with fading samples in time domain (for a fixed RB)
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.