What is Ns2

Let’s have a look about the most important keynotes based on network simulator 2 through this article.

Generally, the network simulator version 2 is abbreviated as Ns2 and that is defined as the discrete event network simulator which is widely deployed to simulate and analyze the characteristics of the computer networks. In addition, it is used for the creation of simulation projects that are highlighted in the following.

  • Satellite
  • WSN
  • VANET
  • MANET

Network Communication in Ns2

Hereby, we are capable to create the network communication in network simulator 2 based on the traffic agents such as UDP, TCP and etc. and the traffic sources such as CBR, FTP and etc.

  • Sample code for FTP traffic source using TCP

set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$tcp0 set packet_size_ 512

  • Sample code for CBR traffic source using UDP

set udp0 [new Agent/UDP]

 $ns attach-agent $n0 $udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 attach-agent $udp0

$cbr0 set packet_size_ 512

At the end, we have concluded this article with some sample source codes based on network simulator2.