Maximizing Network Lifetime Under Reliability Constraints Using a Cross-Layer Design in Dense Wireless Sensor Networks