First thing is you need to know everything with the class hierarchy and project structure of ns2. you need to understand the various classes present in the ns2.
http://www-rp.lip6.fr/ns-doc/ns226-doc/html/index.html
This site has everything with that deals with class hierarchy of the network simulator. All the protocols and their dependencies are covered. Every thing from macro to the base.