Escape from Callback Hell! A New Programming Paradigm for Network Simulation

📅 2026-05-16
📈 Citations: 0
Influential: 0
📄 PDF

career value

206K/year
🤖 AI Summary
Traditional callback-based discrete-event network simulators often suffer from fragmented logic, leading to “callback hell” and stack tearing, which result in complex and poorly maintainable code. This work proposes CoDES—a novel coroutine-based paradigm for discrete-event simulation—that reimagines coroutines not merely as a performance optimization but as a foundational mechanism to reconstruct the network simulation development workflow. By enabling developers to express network events in a natural, sequential manner, CoDES significantly enhances code clarity. Integrated into NS-3, CoDES supports sequential modeling of protocols such as MPI, HPCC, and RIP, achieving up to a 62.3% reduction in code volume and an 82.6% decrease in structural complexity, all while preserving simulation accuracy, runtime performance, and memory overhead.
📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

Callback Hell
Network Simulation
Discrete Event Simulation
Code Maintainability
Programming Complexity
Innovation

Methods, ideas, or system contributions that make the work stand out.

Coroutine
Discrete Event Simulation
Network Simulation
Callback Hell
CoDES