The Internet of Vehicles (IoV) is a specialized iteration of the Internet of Things (IoT) tailored to facilitate communication and connectivity among vehicles and their environment. It harnesses the power of advanced technologies such as cloud computing, wireless communication, and data analytics to seamlessly exchange real-time data among vehicles, road-side infrastructure, traffic management systems, and other entities. The primary objectives of this real-time data exchange include enhancing road safety, reducing traffic congestion, boosting traffic flow efficiency, and enriching the driving experience. Through the IoV, vehicles can share information about traffic conditions, weather forecasts, road hazards, and other relevant data, fostering smarter, safer, and more efficient transportation networks. Developing, implementing and maintaining sophisticated techniques for detecting attacks present significant challenges and costs, which might limit their deployment, especially in smaller settings or those with constrained resources. To overcome these drawbacks, this article outlines developing an innovative attack detection model for the IoV using advanced deep learning techniques. The model aims to enhance security in vehicular networks by efficiently identifying attacks. Initially, data is collected from online databases and subjected to an optimal feature extraction process. During this phase, the Enhanced Exploitation in Hybrid Leader-based Optimization (EEHLO) method is employed to select the optimal features. These features are utilized by a Complex-Valued Dilated Recurrent Neural Network (CV-DRNN) to detect attacks within vehicle networks accurately. The performance of this novel attack detection model is rigorously evaluated and compared with that of traditional models using a variety of metrics.