NS2 need to be recompiled in two cases.
1. When modifying the existing algorithm
By using same header and source files
2. When adding new files/Protocols
By adding new header and source files
Modifying the Existing Algorithm:
Step 1: Change the existing algorithm.
Step 2: execute the following command
Compilation will be success if there are no errors in the modified code and NS will be created.
Step 3: Run TCL script for the modified algorithm.