58 double step_period,
ChState ch_state)
64 , step_period(step_period)
69 p_gb >= 0.0 && p_gb <= 1.0 && p_bg >= 0.0 &&
p_bg <= 1.0);
84 double new_p_gg = c1 *
p_bg + c2 *
p_gb;
85 if (RNG::defaultrng()->uniform_double() > new_p_gg) {
89 double new_p_bb = c1 *
p_gb + c2 *
p_bg;
90 if (RNG::defaultrng()->uniform_double() > new_p_bb) {
112 Tcl &tcl = Tcl::instance();
115 if (strcasecmp(argv[1],
"getChState") == 0) {
118 }
else if (strcasecmp(argv[1],
"getBER") == 0) {
119 tcl.resultf(
"%f",
getBER());
124 std::cerr <<
"TCL: unknown MCLink command" << std::endl;
132 : TclClass(
"Module/UW/HMMPHYSICAL/MCLINK")
136 create(
int argc,
const char *
const * argv)
140 return (
new MCLink(std::stod(argv[4]), std::stod(argv[5]),
141 std::stod(argv[6]), std::stod(argv[7]),std::stod(argv[8])));
145 if (strcasecmp(argv[9],
"GOOD") == 0) {
147 }
else if (strcasecmp(argv[9],
"BAD") == 0) {
150 std::cerr <<
"TCL: MCLink state must be GOOD or BAD"
154 return (
new MCLink(std::stod(argv[4]), std::stod(argv[5]),
155 std::stod(argv[6]), std::stod(argv[7]),std::stod(argv[8]),ch_state));
157 std::cerr <<
"TCL: check MCLink constructor args" << std::endl;
TclObject * create(int argc, const char *const *argv)
MCLink class models the BER of a directed link between two nodes.
ChState ch_state
last channel state
double p_gb
Prob of transition from good to bad channel.
double ber_good
BER with good channel.
double last_update
last time channel state has been updated
double p_bg
Prob of transition from bad to good channel.
virtual ChState updateChState()
Called upon packet reception, decides and returns the new channel state updates the members state and...
virtual int command(int, const char *const *)
TCL command interpreter.
double ber_bad
BER with bad channel.
MCLink()
Default constructor of MCLink class.
double step_period
period (s) for channel transition between states
MCLinkClass class_module_mclink
Definition of MCLink class.