Extending NS by adding a new basic network object usually involves working around making OTcl linkage from C++ code, since the object class in the data path should be written in C++ for efficiency reason. This section introduces C++/OTcl linkages available in NS by giving an example of creating a simple and dull agent called " MyAgent " that has no behavior of an agent (i.e. no packet creation and transmission). Figures 18 to 21 show parts of the C++ source file for "MyAgent", together which makes a complete implementation (with 3 extra header lines). Also, an OTcl script with which you can test "MyAgent" is presented at the end of this section. Export C++ class to OTcl Suppose that you created a new network object class in C++, say " MyAgent " that is derived from the " Agent " class, and want to make it possible to create an instance of this object in OTcl. To do this you have to define a linkage object, say " MyAgentClass "...
When you’re curious, you find lots of interesting things to do.