Optical networks are changing as new advanced technologies emerge. With each passing year, their sizes and capabilities expand. The standard architecture for network control and management cannot handle all of these complexities. The proliferation of cloud services and the massive volume of traffic provided by content delivery networks are driving the present fast increase in Internet traffic. This obviously exacerbates congestion concerns in communication networks, with a focus on the core and backbone components in particular. Software-defined networking (SDN) is evolving into a consolidated network management system that comprises a variety of strategies aiming at network management that are based primarily on one basic principle: decoupling control plane decisions from data plane activities. An essential resource allocation strategy in an all-optical network is routing and wavelength assignment. A novel SDN-based approach is proposed to address the problem of old methods mixed with new architecture in optical networks. The network resources were optimized for optimal scheduling using a binary hybrid topology particle swarm optimization method. In terms of recovery time, blockage rate, and resource consumption, simulation results demonstrate that the suggested technique outperforms previous classical methods.