Resource Optimization in Wireless Sensor Network