Network simulation plays a crucial role in both networking research and industry. Existing commonly-used Discrete Event Simulations (DES) are based on callback mechanisms for discrete event (DE). However, due to the inability of callbacks to naturally simulate network events, programs in network simulation cannot be written in a sequential workflow. This leads to inherent complexity and poor maintainability, resulting in stack ripping and callback hell. These problems significantly increase simulation development workloads and introduce substantial cognitive loads associated with programming and debugging. To enable more efficient development of network simulation and facilitate the rapid evaluation and evolution of network functions, we propose a novel development paradigm for network simulation named ``CoDES" (\textbf{Co}routine-based \textbf{DES}). To the best of our knowledge, we are the first to focus on optimizing the network simulation development process rather than performance based on the coroutine mechanism. We implement a new network simulation framework based on CoDES that is capable of naturally simulating network events and effectively address key system challenges related to correctness, functionality, compatibility, and overhead. It enables developers to create sequential workflows for network programs and simplifies the code structure, thus reducing development workloads while enhancing code readability and maintainability. We apply this paradigm to a commonly used network simulator, NS-3 to implement Message Passing Interface (MPI), High Precision Congestion Control (HPCC), and Routing Information Protocol (RIP), achieving up to 62.3\% and 82.6\% reduction in code volume and structure complexity without sacrificing simulation accuracy, extending execution time or increasing runtime memory of simulation.
翻译:网络模拟在网络研究与工业应用中均扮演着关键角色。现有的通用离散事件模拟(DES)基于回调机制处理离散事件。然而,由于回调无法自然模拟网络事件,网络模拟中的程序无法按顺序工作流编写,这导致固有的复杂性及低可维护性,进而引发栈撕裂和回调地狱问题。这些问题显著增加了模拟开发工作量,并给编程和调试带来了巨大的认知负荷。为提升网络模拟的开发效率,促进网络功能的快速评估与演进,我们提出了一种名为"CoDES"(基于协程的离散事件模拟)的新型网络模拟开发范式。据我们所知,我们是首个基于协程机制、聚焦于优化网络模拟开发过程(而非性能)的研究。我们基于CoDES实现了一个新型网络模拟框架,该框架能够自然模拟网络事件,并有效解决与正确性、功能性、兼容性及开销相关的关键系统挑战。它使开发者能够为网络程序创建顺序工作流,并简化代码结构,从而在增强代码可读性和可维护性的同时降低开发工作量。我们将这一范式应用于常用网络模拟器NS-3,实现了消息传递接口(MPI)、高精度拥塞控制(HPCC)及路由信息协议(RIP),在不牺牲模拟精度、不延长执行时间或增加运行时内存的前提下,代码量和结构复杂度分别降低了高达62.3%和82.6%。