  We analyze the performance of CSMA in multi-channel wireless networks,
accounting for the random nature of traffic. Specifically, we assess the
ability of CSMA to fully utilize the radio resources and in turn to stabilize
the network in a dynamic setting with flow arrivals and departures. We prove
that CSMA is optimal in ad-hoc mode but not in infrastructure mode, when all
data flows originate from or are destined to some access points, due to the
inherent bias of CSMA against downlink traffic. We propose a slight
modification of CSMA, that we refer to as flow-aware CSMA, which corrects this
bias and makes the algorithm optimal in all cases. The analysis is based on
some time-scale separation assumption which is proved valid in the limit of
large flow sizes.
