Which Language is used in Ns3

In general, there are several programming languages which are used for the implementation process. In particular, Ns3 is mainly using two significant languages such as C++ and python.

Additionally, the fundamental packages are required to start the process in Ns3 along with its installation and they are implemented through the following commands.

apt install g++ python3 cmake ninja-build git

apt install g++ python3

apt install g++ python2

python3 -m pip install –user cppyy

apt install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3

apt install g++ python3 python3-dev pkg-config sqlite3 cmake

Now, let’s look into the sample codes based on python. In the following, we have highlighted the sample codes for the process that are mentioned below.

  • Node creation
  • Application creation
  • Simulation implementation

Sample code for node creation process in python

nodes = ns.network.NodeContainer()


Sample code for to create applications in python

serverApps = echoServer.Install(nodes.Get(1))



echoClient = ns.applications.UdpEchoClientHelper(interfaces.GetAddress(1), 9)

echoClient.SetAttribute(“MaxPackets”, ns.core.UintegerValue(1))

echoClient.SetAttribute(“Interval”, ns.core.TimeValue(ns.core.Seconds (1.0)))

echoClient.SetAttribute(“PacketSize”, ns.core.UintegerValue(1024))

clientApps = echoClient.Install(nodes.Get(0))



Sample code for simulation implementation in python


Sample Code about Data Communication in Ns3

Consequently, we can implement the simulation in main file through the utilization of below mentioned command.

cd /home/research/ns-allinone-3.26/ns-3.26

./waf shell

Execution of Main File in Ns3

python scratch/MainFile.py

Run Python Based Main File in Ns3

On the other hand, we have an alternative process for the implementation of .cc main file. For your reference, we have highlighted that process in the following with the sample code in .cc.

Scratch Folder to Store Main Simulation File

Python Based Main File in Ns3

Next, we have implemented the .cc based main file through executing the following command.

sudo ./waf –run Main –vis

Execution of Main File Using Waf Command

Finally, the result acquired through this process has been depicted in the following screen.

Result of Main File Execution

If you want to know more information about the sorts of Ns3 implementation then contact us to grab some innovative knowledge in this process.

Opening Time


Lunch Time


Break Time


Closing Time


  • award1
  • award2