Nowadays, increasing in wireless communication users urged the revision and development of new telecommunication technologies. Fifth generation (5G) networks standardization efforts and its stringent coverage and capacity requirements, set to provide an unlimited user experience. Thus, efficient spectrum utilization algorithm based distance of 4G/5G D2D is really demanded. This invention introduces a Fifth-generation (5G) algorithm and prototype which plays a vital role in enhancing proximity communication where a device-to-device (D2D) and vehicle-to-vehicle (V2V) whereby the closely distant nodes communicate with each other without a need for base station is introduced. It helps in increasing the data rate, reducing latency, and increasing bandwidth far more than the expected rates. D2D communication plays a key role in next-generation wireless technology due to the features of reliability, low-latency, and the ultra-wide capacity in comparison to the existing networks. This invention introduce a spectrum allocation and sharing / accessing methods that enables the perfect resource utilization that can bring performance enhancements. Up to this level, the spectrum sharing methods have been examined and analyzed considering a single-cell scenario. This sheds the light on how D2D increases spectral efficiency by utilizing the Macro-cell frequency i.e. the existing resources. The current findings demonstrate that the project has a valuable and realistic commercialization potentiality. Furthermore, we designed a prototype which is based on our designed algorithm and where this prototype is applicable for real base station for 5G network across the nation and this prototype is ready for commercialization. This invention can be commercialized with high possibility and feasible 5G network design as an optimisation of 5G network resources is very important for telecommunication operators that comes at a much lower cost. It is represents the trend for future wireless 5G networks, which can provide high transmission rates and high connectivity to adopt more users in various environments.