The Internet of Vehicles (IoV) has recently become an emerging promising field of research due to the increasing number of vehicles each day. IoV is vehicle communications, which is also a part of the Internet of Things (IoT). Continuous topological changes of vehicular communications are a significant issue in IoV that can affect the change in network scalability, and the shortest routing path. Therefore, organizing efficient and reliable intercommunication routes between vehicular nodes, based on conditions of traffic density is an increasingly challenging issue. For such issues, clustering is one of the solutions, among other routing protocols, such as geocast, topology, and position-based routing. This paper focuses mainly on the scalability and the stability of the topology of IoV. In this study, a novel intelligent system-based algorithm is proposed (CACOIOV), which stabilizes topology by using a metaheuristic clustering algorithm based on the enhancement of Ant Colony Optimization (ACO) in two distinct stages for packet route optimization. Another algorithm, called mobility Dynamic Aware Transmission Range on Local traffic Density (DA-TRLD), is employed together with CACOIOV for the adaptation of transmission range regarding of density in local traffic. The results presented through NS-2 simulations show that the new protocol is superior to both Ad hoc On-demand Distance Vector (AODV) routing and (ACO) protocols based on evaluating routing performance in terms of throughput, packet delivery, and drop ratio, cluster numbers, and average end-to-end delay.