Road safety applications provided by the Vehicular ad hoc networks demand less delay, high throughput, and reliable communication under highly dense traffic conditions. It becomes very challenging to design a network that suits the high mobility of vehicles and frequently chang ing network topology. To overcome these challenges in the network, we propose a new algorithm to dynamically adapt the contention window size (DYCW) to the vehicle density conditions. Along with that, we have introduced a cooperative relay vehicle for relaying the safety mes sages that failed to reach the destination. We have also carried out analytical study of the proposed model and the simulation results for the our model show that using DYCW enhances the system functioning by leading to higher throughput with stability in the performance and decreases both the delay and the packet drop ratio (PDR) of the system.