Obstacles Avoidance and Optimal Path Determination in Mobile Ad hoc Network