24 #include <ns3/simulator.h>
31 NS_OBJECT_ENSURE_REGISTERED(SatMarkovModel);
32 NS_LOG_COMPONENT_DEFINE(
"SatMarkovModel");
38 TypeId(
"ns3::SatMarkovModel").SetParent<Object>().AddConstructor<SatMarkovModel>();
43 : m_probabilities(new double[3 * 3]),
47 NS_LOG_FUNCTION(
this);
49 NS_FATAL_ERROR(
"SatMarkovModel::SatMarkovModel - Constructor not in use");
53 : m_probabilities(new double[numOfStates * numOfStates]),
54 m_numOfStates(numOfStates),
55 m_currentState(initialState)
57 NS_LOG_FUNCTION(
this << numOfStates);
59 NS_LOG_INFO(
"Creating Markov model for " << numOfStates
73 NS_LOG_FUNCTION(
this);
81 NS_LOG_FUNCTION(
this);
90 NS_LOG_FUNCTION(
this);
102 NS_LOG_FUNCTION(
this);
110 NS_LOG_FUNCTION(
this << newState);
114 NS_FATAL_ERROR(
"SatMarkovModel::SetState - Invalid state");
123 NS_LOG_FUNCTION(
this);
125 NS_LOG_INFO(
"Doing transition, current state: " <<
m_currentState);
133 if ((fabs(total - 1.0) > std::numeric_limits<double>::epsilon()))
135 NS_FATAL_ERROR(
"SatMarkovModel::DoTransition - Probability sum does not match");
138 double r = total * (std::rand() / double(RAND_MAX));
140 NS_LOG_INFO(
"Random value: " << r);
147 NS_LOG_INFO(
"State " << i <<
" accumulated value: " << acc);
151 NS_LOG_INFO(
"Transition done, new state: " << i);
156 NS_LOG_INFO(
"Transition done, new state: " <<
m_numOfStates - 1);
164 NS_LOG_FUNCTION(
this << from <<
" " << to <<
" " << probability);
166 NS_LOG_INFO(
"Setting probability, from: " << from <<
" to: " << to
167 <<
" probability: " << probability);
uint32_t m_numOfStates
Number of states.
static TypeId GetTypeId(void)
NS-3 function for type id.
void Reset()
Clear used variables.
void SetProbability(uint32_t from, uint32_t to, double probability)
Function for setting the probability values.
uint32_t GetState() const
Function for returning the current state.
void DoDispose()
Do needed dispose actions.
double * m_probabilities
Markov state change probabilities.
uint32_t m_currentState
Current state.
uint32_t DoTransition()
Function for evaluating the state change.
SatMarkovModel()
Constructor.
~SatMarkovModel()
Destructor.
void SetState(uint32_t newState)
Function for setting the state.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.