Highway on-ramp merging is considered as one of the main factors that causes traffic congestion on highways. The drivers along the on-ramp need to carefully adjust vehicle speeds to enter the mainline, while the drivers on the mainline should modify vehicle speeds or change lanes during a short period to accommodate the merging of vehicles from the on-ramp, which heavily affects upstream traffic flows. In congested traffic conditions, such maneuvers if inefficiently performed will lead to high risks of collisions and excessive energy consumption and pollutant emissions. Since the emergence of Connected and Automated Vehicle (CAV) technology, where vehicles can be driven by different degrees of autonomy and also with the capability to communicate with other vehicles and infrastructures, numerous applications have been developed for highway on-ramp merging scenario. In this work, we present an innovative approach to this scenario, where distributed consensus protocol is developed for CAVs to cooperate with each other locally by using Vehicle-to-X (V2X) communications. A Road Side Unit (RSU) installed in the merging area can receive vehicles’ information from both the mainline and the on-ramp using Vehicle-to-Infrastructure (V2I) communications, and assign vehicles with sequences based on their earliest possible arrival time at the merging area. Then vehicles adopt distributed consensus protocol with Vehicle-to-Vehicle (V2V) communications to adapt their speeds and accelerations to the preceding vehicles (either physical ones on the same lane or virtual ones projected from the other lane). After vehicles along the on-ramp merge into the mainline, a new vehicle string (either tightly-coupled or loosely-coupled) is created. A comprehensive simulation study is conducted, and system-wide benefits in terms of traffic throughput and energy saving are also demonstrated in the work.