Performance analysis and optimization of CSMA-based wireless mesh networks