We observe that dynamic libraries are natively supported in ns2 (see Tcl load functionality). However, the set of functionalities which can be accounted for by means of this approach is severely limited by the intrinsic structure of the simulator. As an example, new packet types and headers cannot be added to the code.
In order to remove these limitations, we developed a patch enabling dynamic definition of packet types, headers and their corresponding tracers. As mentioned above, this facilitates inter-module communication and collection of statistics. Hence, our patch makes it possible to effectively exploit the benefits of using dynamic libraries thus achieving what we discussed in the bullets above.
Finally, we would like to observe that special care has been taken to ensure backward compatibility: the patch has been designed in order not to interfere with the existing functionalities in ns2. We have been testing this patch on different linux systems since summer 2006, and so far we did not encounter any issue.