A group of nodes that can progress execution automatically by changing their behavior to adapt to the environment is called cognitive radio networks (CRNs). Though several routing protocols inverting the CRNs decisions are proposed to combine the variable degrees of adaptation, these protocols provide quality of service (QoS) assurance to the networks. This study suggests an optimization algorithm based on one of the inspired approaches (particularly the improved bat swarm algorithm) to expedite the reconnaissance for the best paths. It is to create cognitive routing protocols, transmit data packets effectively, and impose complexities as a result of the evolving climate of the reachable spectrum. The optimization problem is being solved using this algorithm. The transmission mechanism is made scalable, effectual, and adaptive with an increasing number of nodes using the bat swarm method presented in this study. This paper suggests a method that more effectively fulfills QoS requirements and demonstrates how to control residual bandwidth, time delay, and packet loss ratio. Meanwhile, the same algorithm also favors service requirements and highlights some important characteristics of the bat swarm algorithm. Finally, simulation results illustrate that the proposed work offers efficient bandwidth exploitation.