A cross-layer middleware architecture for time and safety critical applications in MANETs