The integration of communication infrastructures into traditional power systems, transforming them into cyber-physical power systems (CPPS), accentuates the significance of communication in influencing system performance and sustainability. This paper presents a versatile, innovative cyber-physical co-simulation framework that integrates the physical power system and communication networks, uniting OPAL-RT, a network simulator (ns3), and Docker containers into a sophisticated platform, facilitating intensive studies into CPPS dynamics. The proposed experimental study provides an innovative way to assess the frequency control response of a cyber-physical inverter-based microgrid (MG), addressing the MG sustainability challenges. We consider diverse real-world scenarios, focusing on communication delays and distributed denial of service (DDoS) attacks within the communication channels. We propose a precise ns3-based communication model that bridges the MG’s primary and secondary control layers, an aspect often overlooked in previous studies; this is a noteworthy contribution to elucidating the adverse impacts of communication latency on MG frequency performance. The experimental results demonstrate the effectiveness of the centralized secondary controller in eliminating the frequency deviations. Furthermore, the findings offer insights into stable and unstable regions, revealing how the communication delay value affects the frequency stability under different operating conditions. In addition, the developed real-time DDoS attacks model within the proposed communication surface unveils crucial insights into the MG’s resilience to cyber threats. This work’s revelations offer a foundational awareness of MG vulnerabilities, paving the way for designing robust and resilient communication networks and control strategies within the cyber-physical inverter-based microgrids.