Building networked control systems over wireless networks is an extremely challenging task, as the wireless communication characteristics such as random packet losses and delay, significantly affect the stability and the performance of the control systems. We present a novel approach to the design of wireless networked control system. This approach decomposes the design concerns into two factors and addresses them separately in two design spaces -- stability of the system is ensured using a passivity-based architecture at the control layer, while the performance of the system is optimized at the communication layer by adjusting the network operation parameters. This paper focuses on the design of IEEE 802.11-based wireless network. In particular, we present a MAC controller that dynamically adjusts the retransmission limit to track the optimal trade-off between packet losses and transmission delays and thus optimizes the overall control system performance. Simulation results show that our approach significantly improves the performance of the networked control systems.