Cross-layer design and optimization of short range wireless networks