Wireless Ad Hoc and Sensor Networks: A Cross-Layer