Network simulator is the standard simulator used for designing of new protocols as per considered as best one to give the correct results. NS-2 is the simulator that works in three phases. One is the TCL scripting and other two are the high level language based such as C++ or JAVA. This paper deals with the concept of how to make necessary coding and the various type of scripting for showing optimization of energy and bandwidth in MANETs. This paper also shows how the throughput, bandwidth and energy efficiency of the network structure is optimized by using the NS-2 simulator. The AODV protocol is an extensive protocol being used for routing in ad hoc networks but it does not provide support to error recovery and dead state notation and for this we modified the existing AODV protocol to form its modified version termed as OADOV (Optimized —AODV).