With the exponential growth of mobile devices and high capabilities of intelligence, global communication network traffic is expected to experience remarkable growth in the next few years, as it leads us to poor network experience. The Device-to-Device (D2D) is a prominent solution to further expand the user experience and network performance. To improve it many nature-inspired computing algorithms are widely used. In line with this, we use swarm-based algorithms for network performance improvement. In this paper, we propose a swarm optimization-based resource allocation methodology for Device-to-Device communication, especially since we are focusing on the Bee fly pattern to optimize the resource available resources within the network's proximity area. Where all bees are working together to find the best optimal availability of the network's services, hereafter mobile users get served with a respective set of resources. If the performance is not up to the pre-defined threshold value then the system adds another set of available network resources and relay nodes. It leads to relay-assisted D2D pair communication based on the Bee fly pattern. It improves the D2D mobile pair's user experience in terms of energy, delay, and mobility support. To validate our results we compare our outcome with state-of-the-art works and provide detailed observations subject to various listed parameters. INDEX TERMS Device-to-device communication, Resource allocation, Performance analysis, Quality of Service(QoS), Quality of Experience (QoE). I. INTRODUCTION T HE mobile communication network is one of the most popular communication systems. The Device-to-Device (D2D) communication network is a promising method to enhance the performance of networks. It enables the network devices for direct transmission within the closely located users [1], [2], it may happen without or at least network dependency. The initial studies have proven that direct communication improves spectrum reuse, throughput maximization, energy consumption, coverage, and minimum end-to-end latency, user performance in terms of Quality of Service (QoS) and Quality of Experience (QoE). Thereafter it motivated the researchers to add it and became an integral part of Fifth Generation (5G) network technology [3], [4], [5], [6], [7]. The 5G and beyond (5GB) communication system is supported by an all-IP backbone. It consists of mobile users, radio access technologies (RAT), and network hardware such as eNBs, mobile switching center (MSC), mobile databases, mobility management devices, etc. [8], [9], [10]. The current era of 5G research was not enough for user-based QoS/QoE. 5GB networks provide used for better amalgamation of devicecentric communication technology, it is an emerging concept to improve cellular network performance with intelligent gNBs, and dynamic network database support [11]. It is the core motivation behind cloud-based network embodiment with 5G technologies, where a centralized cellular network is not capable of overcoming the cutting-edge network issue...