NS2 Workshop

What is ns2?

Network simulator is a package of tools that simulates behavior of networks such as creating network topologies, log events that happen under any load, analyze the events and understand the network.It uses two languages such as OTCL and C++.


What is the use of C++ in TCL:

  • Used to reduce the packet and event processing time
  • Helps to increase the efficiency of simulation
  • Used to provide details of the protocols and their operation.


Sample code:

In this workshop we are going to discuss about what are the procedures are need to create the tcp source, destination and connection between them.



#TCP Sources
for {set j 1} {$j<=$NumbSrc} { incr j } {
set tcp_src($j) [new Agent/TCP/Reno]

#TCP Destinations
for {set j 1} {$j<=$NumbSrc} { incr j } {
set tcp_snk($j) [new Agent/TCPSink]

for {set j 1} {$j<=$NumbSrc} { incr j } {
$ns attach-agent $S($j) $tcp_src($j)
$ns attach-agent $n3 $tcp_snk($j)
$ns connect $tcp_src($j) $tcp_snk($j)

#Parametrisation of TCP sources
for {set j 1} {$j<=$NumbSrc} { incr j } {
$tcp_src($j) set packetSize_ 552

Journal Support for NS2 Projects