NetSim Version | |
NetSim Release | v14.4 or higher |
NetSim Components | All Components |
Here's a detailed guide on Setting up VS Code for NetSim Protocol Source Code Modification & Debugging:
Please read the instructions carefully before starting the installation procedure:
- For NetSim users v14.3 or lower please download and extract the .vscode files to NetSim Source Code of the installation directory (Example: C:\Program Files\NetSim\Standard_v14_3\src\Simulation) and create a new workspace in NetSim and then follow the steps given below.
- Step 1 and Step 2 should be only performed once.
- Even if VS Code is installed in your system, run the batch-file to install its necessary extension. If VS Code is already installed it will pass those steps.
Download
Download VS Code JSON files to support for v14.3 or lower: .vscode.zip
Download the Batch Files required for the installation: NetSim-VSCode-BatchFiles.zip
Step 1: Install Visual Studio Code and Necessary Extensions (DO NOT SKIP THIS STEP EVEN IF VS CODE IS ALREADY INSTALLED)
- Run the provided Batch File which:
- Runs the batch file InstallVSCode.bat
- Installs Visual Studio Code (VSCode).
- Installs the C/C++ Extension Pack needed for development & debugging.
Step 2: Install Visual Studio Build Tools (MSVC Compiler)
- Run the batch file: InstallVSBuildTools.bat
- This batch file should automate the download & silent installation of Visual Studio Build Tools with required components.
Step 3: Open NetSim Source Code in VS Code
- Launch VS Code.
- Click on File > Open Folder
- Navigate to the NetSim source code directory of your workspace and select the folder.
- Example: Documents\NetSim\Workspaces\Default-v14_2\src\Simulation
- VS Code will now open the entire source code workspace.
Step 4: Modify and Compile NetSim Protocol (e.g., AODV)
- Modify the source code of any protocol, e.g., AODV.
- After modifications:
- Press Ctrl + Shift + P.
- Type Run Task and press Enter.
- From the list, select Build AODV (Release x64).
- This will start compiling the AODV project.
- If successful, it will compile with 0 errors.
✅ Compilation is now complete and the modified binary is ready.
Step 5: Setting up Debugging for Run-time
- Open the source code file where you want to debug.
- Add breakpoints by clicking next to the line numbers.
Step 6: Run a Simulation in NetSim UI
- Open the NetSim UI.
- Load or create a scenario that uses the protocol/project you have modified.
- Click on Run to start the simulation.
- This will internally start the NetSim simulation engine (NetSimCore.exe).
- ⚠ Do not proceed further
Step 7: Attach Debugger to NetSimCore.exe
- Go back to VS Code.
- Click on Run > Start Debugging or press F5.
- In the prompt, search for NetSimCore.exe.
- Select NetSimCore.exe from the list.
✅ This will attach the debugger to the running NetSim process.
Step 8: Start Simulation Execution to Hit Breakpoints
- Switch back to the NetSimCore.exe window.
- Continue the simulation
- If your sample scenario involves the modified protocol, VS Code will catch the breakpoints where you added them.
- Now you can perform:
- Continue F5
- Step-over (F10)
- Step-into (F11)
- Or use the UI
- Inspect variables and call stacks.
Summary Workflow
- Install VS Code & Extensions ✅
- Install VS Build Tools (MSVC) ✅
- Open NetSim Source Code Folder ✅
- Modify Protocol Source Code ✅
- Compile using "Run Task > Build AODV" ✅
- Run NetSimCore.exe & Prepare Scenario ✅
- Attach Debugger in VS Code (F5) ✅
- Run Simulation & Debug ✅