A joint data link layer and network layer design for cluster-based wireless sensor networks