Physical-layer Aware Control and Optimization in Wireless Networks