next up previous contents index
Next: 2.3.1.1 Query interface example Up: 2.3 Class and object Previous: 2.3 Class and object   Contents   Index

2.3.1 Component system

The ns-3 component system is motivated in strong part by a recognition that a common use case for ns-2 has been the use of polymorphism to extend protocol models. For instance, specialized versions of TCP such as RenoTcpAgent derive from (and override functions from) class TcpAgent.

However, two problems that have arisen in the ns-2 model are downcasts and ``weak base class.'' Downcasting refers to the procedure of using a base class pointer to an object and querying it at run time to find out type information, used to explicitly cast the pointer to a subclass pointer so that the subclass API can be used. Weak base class refers to the problems that arise when a class cannot be effectively reused (derived from) because it lacks necessary functionality, leading the developer to have to modify the base class and causing proliferation of base class API calls, some of which may not be semantically correct for all subclasses.

ns-3 is using a version of the query interface design pattern to avoid these problems. This design is based on elements of the Component Object Model design2.1 and GNOME Bonobo,2.2although full binary-level compatibility of replaceable components is not supported and we have tried to simplify the syntax and impact on model developers. The aspects of COM that we are using provide:

We do not enforce the COM rule that interfaces are pure abstract and that one must separate the interface from implementation. A different, fuller port of COM to ns-3 was prototyped by Craig Dowell,2.3 who initially suggested the use of COM concepts and implementation for ns-3.



Subsections
next up previous contents index
Next: 2.3.1.1 Query interface example Up: 2.3 Class and object Previous: 2.3 Class and object   Contents   Index
Tom Henderson 2007-06-17