NS2 Network Simulator: Otcl Basics Links
NS2 Network Simulator: Otcl Basics Links
REPORT
Introduction
Otcl basics
LINKS
Procedures
One can define new procedures with the proc command. The first argument to proc is the
name of the procedure and the second argument contains the list of the argument names to
that procedure. For instance a procedure that calculates the sum of two numbers can be
defined as follow
pg. 1
Data Communication and networking[CE253] 18dcs133
set a 5
set b 5
proc sum {a b} {
expr $a + $b
}
STARTING PROCEDURE
CODE
#Simulator is a class
pg. 2
Data Communication and networking[CE253] 18dcs133
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exit0}
pg. 3
Data Communication and networking[CE253] 18dcs133
#Create a TCP Sink agent (a traffic sink) for TCP and attach it to node n3
$ns run
pg. 4
Data Communication and networking[CE253] 18dcs133
Topology
pg. 5
Data Communication and networking[CE253] 18dcs133
pg. 6