How do I Create a New Protocol in Ns2
In general, we have illustrated the essential steps that are functional to create a new protocol in network simulator 2.
Phase: I
As the first process, we have to create the new protocol file in network simulator 2 through creating a folder with new protocol name and source code files in the location of Ns2 ns-allinone-2.35\ns-2.35 with the file extension .cc and .h.
![Creation of New Protocol Files in Ns2](https://www.ns2project.com/wp-content/uploads/2023/06/create-new-protocol-files-in-ns2.png)
Phase: II
Then, we have to compile the new protocol files in Ns2 through modifying the Makefile.in file and we have to add the .cc file name with the location in make file. In addition, we have to add the following files.
~ns-allinone-2.35/ns-2.35/common/packet.h
~ns-allinone-2.35/ns-2.35/tcl/lib/ns-packet.tcl
~ns-allinone-2.35/ns-2.35/tcl/lib/ns-default.tcl
~ns-allinone-2.35/ns-2.35/tcl/lib/ns-lib.tcl
~ns-allinone-2.35/ns-2.35/trace/cmu-trace.h
~ns-allinone-2.35/ns-2.35/trace/cmu-trace.cc
~ns-allinone-2.35/ns-2.35/queue/priqueue.cc
![](https://www.ns2project.com/wp-content/uploads/2023/06/Modify-Makefile.png)
Then, to compile the newly created protocol we have to implement the below mentioned commands.
cd ns-allinone-2.35/ns-2.35/
sudo ./configure
![Configuration of New Protocol](https://www.ns2project.com/wp-content/uploads/2023/06/Configure-New-Protocol-1.png)
sudo make
![](https://www.ns2project.com/wp-content/uploads/2023/06/compile-new-protocol-files-in-ns2.png)
If you do still have any quarrels in the above mentioned processes, you can approach us whenever you like. As well as we are hoping the best initiations from you.