摘要:VANET is one of the most important parts in smart cities. However, heterogeneous network devices used by different vehicles make data exchange among vehicles become particularly difficult. To solve the problem, a distributed service sharing middleware for VANET called VssOSGi is proposed in the paper. In this middleware, various kinds of functions provided by sensing devices in vehicles are virtually abstracted as services in the network, which decouples applications from devices and provides a unified platform for data exchange among vehicles. As the movements of cars lead to dynamic changes of the network topology, the service discoveries for these vehicles are easily to be invalidated. The paper proposes a distributed service directory selection algorithm SSWA (Stability and Sharing-oriented Weight-based Algorithm) and introduces a service discovery mechanism to make service discoveries for vehicles more effectively and timely. The simulation results show that the proposed middleware could realize widely service discoveries in VANET. Moreover, it requires shorter service response time and less communication traffic with the growing amount of vehicles.