We consider a random-access-based ad hoc network, where different links use mini-slots to contend for the channel, and then successful links transmit data packets, as in CSMA. The focus of our study is to develop optimal strategies for physical-layer-aware (PHY-aware) distributed scheduling, which involves a joint process of channel probing and distributed scheduling. Because of channel fading and cochannel interference, the signal-to-interference-plus-noise-ratio (SINR) across links is highly dynamic and can exhibit significant variation. In the low SINR case, further channel probing is likely to lead to better SINR conditions and hence yield higher throughput. The desired tradeoff boils down to judiciously choosing the optimal stopping strategy for channel probing before data transmissions. In this paper, we investigate PHY-aware distributed scheduling, aiming to maximize the overall network throughput. The problem under consideration is inherently challenging: 1) multiple links can transmit successfully simultaneously and the number of simultaneously transmitting links is random; and 2) the network throughput is the sum rate of all transmitting links, but each link involved in the transmission has no knowledge of the instantaneous rates of other links, and the stopping decision is made in a distributed manner based on local information only. We use optimal stopping theory to tackle this challenge, and show that the optimal policy for distributed scheduling has a threshold structure. Accordingly, after a channel probing, a link would proceed with data transmissions only if a function of its instantaneous rate is greater than the optimal rate threshold. Observing that the network throughput depends heavily on the contention probability of each link, we generalize the study to jointly optimize the rate threshold and the contention probability, and propose a two-stage algorithm for computing the pair of optimal rate threshold and contention probability by using fract- ional optimization and geometric programming.