The Internet of Things (IoT) faces significant challenges in the requirements of sensitive task latency, reasonable resource allocation and reliability for resource transactions. This paper introduces a novel method for road resource allocation in the IoT context of connected and autonomous electric vehicles (CAEVs). The proposed algorithm leverages the ant colony algorithm (ACA) to effectively allocate and coordinate road resources within groups of CAEVs. By considering the energy consumption and pheromone volatilization, the allocation and coordination process of road resources are optimized. To improve the linear packet loss of RED, we adopt the advanced ACA and CRED in the NS2 platform. The experimental results demonstrate that the proposed method outperforms the RED algorithm in packet loss rate and delay time, significantly enhancing system efficiency and performance. Furthermore, the combination of the CRED algorithm and ant colony algorithm successfully mitigates short-term congestion and identifies optimized paths with minimal delay.