Optimizing sensor networks involves addressing a wide range of issues steaming from limited energy reserves, computation power, communication capabilities, and self-managing sensor nodes. The ns-2 simulation environment is a flexible tool for network engineers to investigate how various protocols perform with different configurations and topologies. This project presents the extension of network simulator 2 to include the wireless sensor network framework so that its applications can be simulated using the simulator. This project also illustrates their utility with an experiment examining Mobile Ad Hoc Network (MANET) routing within a dynamic sensor network.