Analysis and Optimization of Cooperative Wireless Networks