24 #include <ns3/simulator.h>
32 NS_OBJECT_ENSURE_REGISTERED(SatMarkovModel);
33 NS_LOG_COMPONENT_DEFINE(
"SatMarkovModel");
39 TypeId(
"ns3::SatMarkovModel").SetParent<Object>().AddConstructor<SatMarkovModel>();
44 : m_probabilities(new double[3 * 3]),
48 NS_LOG_FUNCTION(
this);
50 NS_FATAL_ERROR(
"SatMarkovModel::SatMarkovModel - Constructor not in use");
54 : m_probabilities(new double[numOfStates * numOfStates]),
55 m_numOfStates(numOfStates),
56 m_currentState(initialState)
58 NS_LOG_FUNCTION(
this << numOfStates);
60 NS_LOG_INFO(
"Creating Markov model for " << numOfStates
74 NS_LOG_FUNCTION(
this);
82 NS_LOG_FUNCTION(
this);
91 NS_LOG_FUNCTION(
this);
103 NS_LOG_FUNCTION(
this);
111 NS_LOG_FUNCTION(
this << newState);
115 NS_FATAL_ERROR(
"SatMarkovModel::SetState - Invalid state");
124 NS_LOG_FUNCTION(
this);
126 NS_LOG_INFO(
"Doing transition, current state: " <<
m_currentState);
134 if ((fabs(total - 1.0) > std::numeric_limits<double>::epsilon()))
136 NS_FATAL_ERROR(
"SatMarkovModel::DoTransition - Probability sum does not match");
139 double r = total * (std::rand() / double(RAND_MAX));
141 NS_LOG_INFO(
"Random value: " << r);
148 NS_LOG_INFO(
"State " << i <<
" accumulated value: " << acc);
152 NS_LOG_INFO(
"Transition done, new state: " << i);
157 NS_LOG_INFO(
"Transition done, new state: " <<
m_numOfStates - 1);
165 NS_LOG_FUNCTION(
this << from <<
" " << to <<
" " << probability);
167 NS_LOG_INFO(
"Setting probability, from: " << from <<
" to: " << to
168 <<
" 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.