Ad hoc and Wireless Sensor Networks