TCL/OTCL
Extending NS: Adding a Variable to an Object
Adding RawPut and GoodPut to
TCPSink
Object
Locate the proper class source files: ns/tcp/tcp-sink.h and ns/tcp/tcp-sink.cc
Add the variables in the class definition (ns/tcp/tcp-sink.h) file
Add "bind()" calls in the class constructor TcpSink::TcpSink() to make associations with TCL variable names
Add usage instructions. Here, we update RawPut and GoodPut when data is received (see TcpSink::recv()).
Technically, we can use the variable in NS script now, as:
[$TcpSinkObjectVariable set RawPut]
[$TcpSinkObjectVariable set GoodPut]
However, TCL variable must be initialized in ns/tcl/lib/ns-default.tcl:
Agent/TCPSink set RawPut 0
Agent/TCPSink set GoodPut 0