Discovering network elements in a dynamic and optimized manner and being able to contend with ever-growing traffic is a key requirement for current networking environments. In software-defined networks (SDNs), the controller collects the topology information from the data plane and maintains an abstract view of the entire network, which is crucial for the proper functioning of applications and network services. However, there is still the need for an enhanced protocol for automatic discovery and mechanisms of autoconfiguration of network elements according to new policies and business requirements. To overcome this challenge, this paper presents a novel protocol that, unlike existing approaches, enables a distributed layer-2 discovery without the need for previous network configurations or controller knowledge of the network. By using this mechanism, the SDN controller can discover the network view without incurring scalability issues, while taking advantage of the shortest control paths toward each switch. The obtained results show that our enhanced protocol is efficient in terms of time and message load over a wide range of generated networks and outperforms the state-of-the-art techniques. INDEX TERMS Network management, protocols, software-defined networks, topology discovery. CRISTINA CERVELLÓ-PASTOR received the M.Sc. and Ph.D. degrees in telecommunication engineering from the Barcelona School of Telecommunications Engineering, Politècnica de Catalunya, Barcelona, Spain, where she is currently an Associate Professor and the Head of the Department of Network Engineering. Being part of the BAMPLA Research Group, she is responsible and actively participated in diverse national and European competitive projects (NOVI, FEDER-ICA, ATDMA, A@DAN, Euro-NGI, Euro-FGI, and EURONF) and private funding research and development projects. She has published diverse papers in national and international journals and conferences. She is supervising dissertation in the field of management, optimal resource allocation, topology discovery, and routing in software-defined networks/NFV and 5G.