This paper proposes a new wireless MAC protocol called Optimal DCF (O-DCF). O-DCF modifies the rule of adapting CSMA parameters, such as backoff time and transmission length, based on a function of the supply-demand differential captured by the local queue length. O-DCF is fully compatible with 802.11 hardware, so that it can be easily implemented only with a simple device driver update. O-DCF is inspired by the recent theoretical studies on queue-based CSMA for high throughput and fairness. O-DCF effectively bridges the gap between theory and practice, implemented and tested in an off-the-shelf 802.11 chipset. Through extensive simulations and real experiments with a 16-node wireless network testbed, we evaluate the performance of O-DCF and show that it outperforms other competitive ones, such as 802.11 DCF, optimal CSMA, and DiffQ for various scenarios.