Research, Implementation and Security Analysis of Connected and Autonomous Vehicles (CAVs) using Machine Learning Algorithms