Optimal Number of Clusters in Dense Wireless Sensor Networks: A Cross-Layer Approach