32 NS_OBJECT_ENSURE_REGISTERED(SatMarkovContainer);
33 NS_LOG_COMPONENT_DEFINE(
"SatMarkovContainer");
39 TypeId(
"ns3::SatMarkovContainer")
41 .AddConstructor<SatMarkovContainer>()
42 .AddTraceSource(
"FadingTrace",
43 "The trace for fading values",
45 "ns3::SatMarkovContainer::FadingTraceCallback");
50 : m_markovModel(nullptr),
51 m_markovConf(nullptr),
53 m_fader_down(nullptr),
58 m_cooldownPeriodLength(),
59 m_minimumPositionChangeInMeters(),
60 m_latestCalculatedFadingValue_up(),
61 m_latestCalculatedFadingValue_down(),
62 m_latestCalculationTime_up(),
63 m_latestCalculationTime_down(),
64 m_enableSetLock(false),
65 m_enableStateLock(false),
67 m_latestStateChangeTime(),
70 NS_LOG_FUNCTION(
this);
71 NS_FATAL_ERROR(
"SatMarkovContainer::SatMarkovContainer - Constructor not in use");
77 : m_markovModel(nullptr),
78 m_markovConf(markovConf),
80 m_fader_down(nullptr),
81 m_numOfStates(markovConf->GetStateCount()),
82 m_numOfSets(markovConf->GetNumOfSets()),
83 m_currentState(markovConf->GetInitialState()),
84 m_cooldownPeriodLength(markovConf->GetCooldownPeriod()),
85 m_minimumPositionChangeInMeters(markovConf->GetMinimumPositionChange()),
86 m_latestCalculatedFadingValue_up(0.0),
87 m_latestCalculatedFadingValue_down(0.0),
88 m_latestCalculationTime_up(Now()),
89 m_latestCalculationTime_down(Now()),
90 m_enableSetLock(false),
91 m_enableStateLock(false),
93 m_latestStateChangeTime(Now()),
94 m_currentElevation(elevation),
95 m_useDecibels(markovConf->AreDecibelsUsed())
97 NS_LOG_FUNCTION(
this);
114 NS_LOG_INFO(
"Creating SatMarkovContainer, States: "
123 NS_LOG_FUNCTION(
this);
131 NS_LOG_FUNCTION(
this);
134 SatBaseFading::DoDispose();
140 NS_LOG_FUNCTION(
this);
154 NS_LOG_FUNCTION(
this << faderType);
179 NS_FATAL_ERROR(
"SatMarkovContainer::CreateFaders - Invalid fader type");
187 NS_LOG_FUNCTION(
this << channelType);
191 NS_LOG_INFO(
"Getting fading");
195 NS_LOG_INFO(
"Cool down period has passed, calculating new fading value");
205 NS_LOG_INFO(
"Cool down period in effect, using old fading value");
217 NS_LOG_FUNCTION(
this << channelType);
230 NS_FATAL_ERROR(
"SatMarkovContainer::GetCachedFadingValue - Invalid channel type");
239 NS_LOG_FUNCTION(
this);
270 NS_LOG_FUNCTION(
this << channelType);
293 NS_FATAL_ERROR(
"SatMarkovContainer::HasCooldownPeriodPassed - Invalid channel type");
302 NS_LOG_FUNCTION(
this << set);
304 std::vector<std::vector<double>> probabilities =
m_markovConf->GetElevationProbabilities(set);
306 NS_LOG_INFO(
"Updating probabilities...");
314 NS_LOG_INFO(
"------");
321 NS_LOG_FUNCTION(
this << channelType);
375 NS_FATAL_ERROR(
"SatMarkovContainer::CalculateFading - Invalid channel type");
384 NS_LOG_FUNCTION(
this << newSet <<
" " << newState);
388 NS_FATAL_ERROR(
"SatMarkovContainer::LockToSetAndState - Invalid state");
392 NS_FATAL_ERROR(
"SatMarkovContainer::LockToSetAndState - Invalid set");
407 NS_LOG_FUNCTION(
this << newSet);
411 NS_FATAL_ERROR(
"SatMarkovContainer::LockToSet - Invalid set");
425 NS_LOG_FUNCTION(
this);
428 uint32_t newState = 0;
446 NS_LOG_FUNCTION(
this);
450 uint32_t newState = 0;
465 NS_LOG_FUNCTION(
this);
474 NS_LOG_FUNCTION(
this);
Base class for fading models such as Markov-based fading or fading trace.
Callback< double > VelocityCallback
Gets velocity in m/s.
Callback< double > ElevationCallback
Gets elevation angle in degrees.
ChannelType_t
Types of channel.
MarkovFaderType_t
Possible types of Markov state faders.
double DoGetFading(Address macAddress, SatEnums::ChannelType_t channeltype)
Function for getting the fading.
void UpdateProbabilities(uint32_t set)
Function for updating the state change probabilities.
Time m_latestCalculationTime_up
Latest calculation time for uplink fading value.
bool m_useDecibels
Defines whether the calculations should return the fading value in decibels or not.
double m_minimumPositionChangeInMeters
Minimum state change distance in meters.
void UnlockSetAndState()
Function for unlocking the parameter set and state.
SatMarkovContainer()
Constructor.
void EvaluateStateChange(SatEnums::ChannelType_t channelType)
Function for evaluating state change.
void DoDispose()
Do needed dispose actions.
uint32_t m_currentState
Current state.
double m_latestCalculatedFadingValue_down
Latest calculated downlink fading value.
Time m_latestCalculationTime_down
Latest calculation time for downlink fading value.
uint32_t m_numOfSets
Number of parameter sets available.
double GetCachedFadingValue(SatEnums::ChannelType_t channelType)
Function for getting the cached fading values.
double m_latestCalculatedFadingValue_up
Latest calculated uplink fading value.
void LockToSet(uint32_t newSet)
Function for locking the parameter set.
void RandomizeLockedSetAndState()
Function for locking the parameter set and state to random values.
Ptr< SatMarkovConf > m_markovConf
Markoc model configuration.
TracedCallback< double, SatEnums::ChannelType_t, double > m_fadingTrace
Fading trace function.
bool m_enableSetLock
Variable for disabling the parameter set change.
uint32_t m_numOfStates
Number of states available.
double CalculateFading(SatEnums::ChannelType_t channelType)
Function for calculating the fading value.
VelocityCallback m_velocity
Node movement velocity.
void Reset()
Clear used variables.
~SatMarkovContainer()
Destructor.
double CalculateDistanceSinceLastStateChange()
Function for calculating the distance since latest state change position.
static TypeId GetTypeId(void)
NS-3 function for type id.
bool HasCooldownPeriodPassed(SatEnums::ChannelType_t channelType)
Function for checking whether the cooldown period has passed.
uint32_t m_currentSet
Current parameter set.
ElevationCallback m_currentElevation
Current elevation value.
bool m_enableStateLock
Variable for disabling state changes.
void RandomizeLockedState(uint32_t set)
Function for locking the state to random value.
Ptr< SatBaseFader > m_fader_up
Uplink fader.
Time m_cooldownPeriodLength
Cooldown period length in time.
Time m_latestStateChangeTime
Latest calculation time for state change.
Ptr< SatBaseFader > m_fader_down
Downlink fader.
void LockToSetAndState(uint32_t newSet, uint32_t newState)
Function for locking the parameter set and state.
void CreateFaders(SatMarkovConf::MarkovFaderType_t faderType)
Function for creating the Markov state faders.
Ptr< SatMarkovModel > m_markovModel
Markov model object.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.