Cross-layer design of random access wireless networks