Analysis and optimization of a cross-layer adaptation mechanism for real-time applications in wireless networks