Recently, a novel cluster-based medium access control (CB-MAC) protocol has been proposed for vehicular ad hoc networks (VANETs). Though performance of CB-MAC protocol is affected by cluster size, no mechanism is provided to manage cluster size efficiently. In this paper, the performance of CB-MAC protocol is optimized for VANETs by optimizing transmission probability with cluster size. Each vehicle should adopt the optimum transmission probability in the cluster which can be obtained by tuning the number of clusters in VANET. Therefore, optimum number of clusters is defined based on the number of vehicles in VANETs. An analytical study based on Markov chain model is provided. Optimum transmission probability, and optimum number of clusters expressions are derived. The microscopic mobility model is generated in SUMO for practical scenario. Simulation results are presented which verify analytical (theoretical) analysis and show that the performance of CB-MAC protocol is maximized in terms of throughput, packet dropping rate (PDR), and delay. Throughput is remarkably increased, whereas PDR and delay are decreased.