We consider a set of networked controllers where multiple control systems coexist with their control loops closed over a shared wireless network that induces random delays and packet losses. This system requires a joint design of the wireless network and the controllers, where the design objective is to optimize the control performance. This performance is a complex function of the controller design and the network parameters, such as throughput, packet delay and packet loss probability. Random delays and packet losses in the feedback loop impose new challenges on the optimal controller design. We first investigate controller design with randomly dropped packets. We prove the separation of estimation and control under certain assumptions of the network and show that the Kalman filter can be modified to generate the optimal state estimate when part or all of the observation is lost. The wireless network needs to provide a sufficient throughput for each of the sensor measurements in order to guarantee the stability of the Kalman filter. We then focus on the wireless network design for this controller. The goal of optimizing the control performance imposes implicit tradeoffs on the wireless network design as opposed to the explicit tradeoffs typical in wireless data and voice applications. Specifically, the tradeoffs between network throughput, time delay and packet loss probability are intricate and implicit in the control performance index, which complicates network optimization. We show that this optimization requires a cross-layer design framework, and propose such a framework for a broad class of networked control applications. We then illustrate this framework by a cross-layer optimization of the link layer, MAC layer, and sample period selection in a double inverted pendulum system.