[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bugs in errmodel.cc



>>> Biaz Saad said:
 > Hi!
 > 
 > 	I found two bugs in errormodel.cc :
 > 
 > 	1) The variables errPkt_, errByte_ and errTime must be initialized
 > 	to 0. Otherwise, they can start with very high values. Therefore,
 > many simulations will not experience any loss. That is what I observed on 
 > many simulations. Despite a high error rate, no loss happened. I suggest
 > to add the initialization in errmodel.cc (marked with ^^^)
 > 
 > 	ErrorModel::ErrorModel() : Connector(), unit_(EU_PKT), ranvar_(0),
 >         onlink_(0), enable_(1), firstTime_(1), 
 > 	errPkt_(0), errByte_(0),errTime_(0) // Bug 1 : omission
 > 	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 > {
 >         bind("rate_", &rate_);
 >         bind("errPkt_", &errByte_);  // Bug 2 : typo
 > 	      ^^^^^^^^^^^^^^^^^^^
 >         bind("errByte_", &errByte_);
 >         bind("errTime_", &errTime_);
 >         bind("onlink_", &onlink_);
 >         bind("enable_", &onlink_);
 >         bind("off_mac_", &off_mac_);
 > }
 > 

The typo in Bug 2 is certainly a bug (careless cut-and-paste).  But you shouldn't (have to) initialize the said variables in C.  They are init'ed in ns-default.tcl, and by virtue of their being "bound", that gets reflected in C as well.

-- Hari.