Debug ns3 in Visual Studio Code
git clone https://github.com/iqhy/ns3-vscode.git
bash install.sh
- Open VSCode and install the Remote - Containers extension
- Press F1, choose "Remote Container : attach to running container", then choose the "ns3-vscode" container. (If remote server is used, connect to it first)
- Install the C/C++ extension in the container
- Open folder
/usr/ns-allinone-3.34/ns-3.34
- Open file
scratch/scratch-simulator.cc
, set a breakpoint in the main function and press F5. The program will run and stop at the breakpoint.
Now you can debug your own ns3 code in VSCode.
使用 Visual Studio Code 调试 ns3
git clone https://github.com/iqhy/ns3-vscode.git
bash install.sh
- 打开 VSCode, 安装 Remote - Containers 插件
- 按下 F1,选择 Remote Container : attach to running container,选择 ns3-vscode 容器。(如果使用的是远程服务器,先连接到服务器)
- 在容器内安装 C/C++ 插件
- 使用 VSCode 在容器内打开文件夹
/usr/ns-allinone-3.34/ns-3.34
- 打开
scratch
文件夹中的scratch-simulator.cc
文件,在主函数中设置一个断点后按 F5 。程序将运行并在断点处停止。
现在你可以使用 VSCode 调试你自己的代码了。