Markov chain-based optimization of multihop IEEE 802.15.4 wireless sensor networks