SlideShare a Scribd company logo
Ajit K Nayak, Ph.D.
Dept of CSIT, ITER
An Introduction to NS2:
The Network Simulator
What is Simulation ?
Network simulation is a technique where a program models the behavior
of a network either by calculating the interaction between the different
network entities (hosts/, etc.) using mathematical formulas, or actually
capturing and playing back observations from a production network.
NS2 Architecture
Sample Input Script (Tcl)
set ns [new Simulator]
set n0 [$ns node]
set n1 [$ns node]
$ns at 0.0 "$n0 label Sender“
$ns at 0.0 "$n1 label Receiver“
set nf [open test.nam w]
$ns namtrace-all $nf
set f [open test.tr w]
$ns trace-all $f
$ns duplex-link $n0 $n1 0.2Mb 200ms DropTail
$ns duplex-link-op $n0 $n1 orient right
. . .
Sample output traces
- 2.846272 0 2 ack 576 ------- 0 0.0 4.0 15545 61
r 2.851664 0 2 ack 576 ------- 0 0.0 4.0 14473 59
+ 2.851664 2 3 ack 576 ------- 0 0.0 4.0 14473 59
d 2.851664 2 3 ack 576 ------- 0 0.0 4.0 14473 59
r 2.854576 3 2 ack 40 ------- 1 4.0 0.0 3217 48
n -t * -s 0 -x 200 -y 30 -Z 0 -z 30 -v circle -c black
c -t * -i 8 -n red
c -t * -i 1 -n black
c -t * -i 2 -n orange
c -t * -i 6 -n tan
c -t * -i 7 -n purple
c -t * -i 3 -n green
+ -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC
- -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC
h -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC
r -t 0.002355848 -s 2 -d -1 -p message -e 32 -c 2 -a 0 -i 0 -k MAC
Output (NAM Trace)
Run the
NAM trace
using
Network
AniMator
package
Output (Packet Trace)
Extract required data from packet trace (shell, awk, perl, C, etc…)
Plot the data using gnuPlot, Xgraph, MsExcel etc.
Where to go?
Learn Tcl/OTcl
Write Tcl scripts for network simulation
Execute the simulation
Observe the result in NAM
Learn to extract Info from Packet trace
Plot using any plotting software
Measure the protocol/network performance
Tcl/OTcl - Basics
 Everything in Tool comand language(Tcl) is a command
followed by a number of arguments, which are
separated by whitespace.
 command arg1 arg2 ... argn.
 To Execute a Tcl script
Method 1:
 Start the NS environment
 $ ns (this will start the shell)
%
% puts stdout “Hello World”
Hello World
%
Method 2:
 Write the Tcl command(s) in a
file and save it to <fileName>.tcl,
then execute as follows in (OS
shell)
$ ns <fileName>.tcl
Tcl/OTcl – I/O Commands
 Printing(output): puts
 puts $<var>
 puts <constant>
 Reading(input): gets
 gets stdin <var>
 Comment: #
 # This is my first tcl script
Tcl/OTcl - Variables
 Tcl is a dynamically typed language
 Need not to declare variable types (datatypes).
 A variable can store anything, irrespective of type and
type checking is done at runtime.
 Variable initialization.
 Syntax: set <variable> <value>
 Example:
 % set intVar 10
 % set a [expr 2.5*10]
 % puts {intVar is $intVar}
 % puts $a
Tcl/OTcl – control structure-I
Control Structures:
if {$z == 6} then { puts “Correct!”}
for {set i =0} {$i < 5} {incr i } {
puts “$i * $i equals [expr $i * $i]”
}
Other branching-constructs
switch <string> {
<pattern_1> {
<body_1>
}
<pattern_2> {
<body_2>
}
. . .
<default> {
body
}
}
Tcl/OTcl – control structure-II
Other Loop constructs
while {<test>} {
<body>
}
foreach {<var1> <var2>} <var> {
<body>
}
Example:
set observations {Bhubaneswar 35 49 Cuttack 32 45 Bolangir 18 30}
foreach {town Tmin Tmax} $observations {
set Tavg [expr ($Tmin+$Tmax)/2.0]
puts “$town $Tavg"
}
break, continue
Tcl/OTcl – Array
Required to store multiple elements. These are
implemented as associative maps.
i.e. it associates an array index (key) with an array element. Unlike
‘C/C++’ arrays, the Tcl array index can be a string.
Example
set myArray(0) 1
set myArray(1) 65
set Link(pktsize) 512
set Link(protocol) “IEEE 802.11"
puts $myArray(0)
puts $myArray(1)
puts $Link(pktsize)
puts $Link(protocol)
Tcl/OTcl – Procedure
The ‘proc’ command creates a new command.
Syntax: proc <procName> <args> <body>
Example:
# procedure without args
proc myCommand {} {
puts “My first Tcl command"
}
myCommand #proc call
# procedure with args
proc avg {min max} {
return [expr ($min + $max) / 2]
}
set average [avg 10 20]; puts $average #proc call
Tcl – Practice Progs.
Write Tcl scripts for the followings
to add two given numbers.
To find largest among three numbers
To print a day given a number (1-7) using switch
To add all odd numbers (1-100)
To read and print one array containing name and
roll numbers of some students.
Write a procedure to find the sum of the digits of a
given number. Use this procedure to find sum of
the digits for a given range of numbers.
End of NS2 Part I
Thank You

More Related Content

What's hot (20)

PDF
LTI System, Basic Types of Digital signals, Basic Operations, Causality, Stab...
Waqas Afzal
 
PPTX
Ant colony optimization
Suman Chatterjee
 
PPTX
Hand gesture recognition
bakhti rahman
 
PPTX
Implementation of Reversable Logic Based Design using Submicron Technology
Sai Viswanath
 
PPT
Seminar On Kalman Filter And Its Applications
Barnali Dey
 
PDF
digital signal-processing-lab-manual
Ahmed Alshomi
 
PDF
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
Amr E. Mohamed
 
PPTX
convolution
AbhishekLalkiya
 
PPTX
Digital Signal Processing Tutorial Using Python
indracjr
 
PDF
Multiple Choice Questions on Frequency Response Analysis
VijayalaxmiKumbhar
 
PDF
AI simple search strategies
Renas Rekany
 
PPT
Lecture13
INDHULEKSHMI M.C
 
PDF
01. design & analysis of agorithm intro & complexity analysis
Onkar Nath Sharma
 
PPTX
Pole-Zero Placement Method of Filter Design.pptx
SannaSharma1
 
PDF
AI Informed Search Strategies by Examples
Ahmed Gad
 
PPTX
Genetic algorithms vs Traditional algorithms
Dr. C.V. Suresh Babu
 
PPT
Unit I & II in Principles of Soft computing
Sivagowry Shathesh
 
PPTX
Cyclic code non systematic
Nihal Gupta
 
PPTX
Kalman filter for object tracking
Mohit Yadav
 
PPTX
Reed Solomon encoder and decoder \ ريد سلمون
Muhammed Abdulmahdi
 
LTI System, Basic Types of Digital signals, Basic Operations, Causality, Stab...
Waqas Afzal
 
Ant colony optimization
Suman Chatterjee
 
Hand gesture recognition
bakhti rahman
 
Implementation of Reversable Logic Based Design using Submicron Technology
Sai Viswanath
 
Seminar On Kalman Filter And Its Applications
Barnali Dey
 
digital signal-processing-lab-manual
Ahmed Alshomi
 
DSP_2018_FOEHU - Lec 06 - FIR Filter Design
Amr E. Mohamed
 
convolution
AbhishekLalkiya
 
Digital Signal Processing Tutorial Using Python
indracjr
 
Multiple Choice Questions on Frequency Response Analysis
VijayalaxmiKumbhar
 
AI simple search strategies
Renas Rekany
 
Lecture13
INDHULEKSHMI M.C
 
01. design & analysis of agorithm intro & complexity analysis
Onkar Nath Sharma
 
Pole-Zero Placement Method of Filter Design.pptx
SannaSharma1
 
AI Informed Search Strategies by Examples
Ahmed Gad
 
Genetic algorithms vs Traditional algorithms
Dr. C.V. Suresh Babu
 
Unit I & II in Principles of Soft computing
Sivagowry Shathesh
 
Cyclic code non systematic
Nihal Gupta
 
Kalman filter for object tracking
Mohit Yadav
 
Reed Solomon encoder and decoder \ ريد سلمون
Muhammed Abdulmahdi
 

Viewers also liked (20)

PPT
Uml Omg Fundamental Certification 1
Ricardo Quintero
 
PDF
Introduction to database-Transaction Concurrency and Recovery
Ajit Nayak
 
PPTX
The Ultimate gift
Sebastien Juras
 
PPTX
Six things to know about your brain to become an expert
Sebastien Juras
 
PPT
Uml Omg Fundamental Certification 5
Ricardo Quintero
 
PPTX
The badguy summary
Sebastien Juras
 
PDF
Software Engineering an Introduction
Ajit Nayak
 
PPTX
Innovation is almost impossible for older companies
Sebastien Juras
 
PPTX
Is your company fully engaged towards innovation?
Sebastien Juras
 
PPTX
Things to know to improve your willpower
Sebastien Juras
 
PDF
Operating Systems Part III-Memory Management
Ajit Nayak
 
PDF
Software Engineering :Behavioral Modelling - I Sequence diagram
Ajit Nayak
 
PPTX
Psychology explains the power of Storytelling
Sebastien Juras
 
PDF
Manual 02
Ricardo Quintero
 
PPT
03 administracion de requisitos
Ricardo Quintero
 
PPTX
The Bad Guy in your company and how have him under control
Sebastien Juras
 
PPT
Omg Fundamental Certification 4
Ricardo Quintero
 
PDF
Database Programming using SQL
Ajit Nayak
 
PPTX
Perfiles UML
Jose R. Hilera
 
PDF
Computer Networks Module III
Ajit Nayak
 
Uml Omg Fundamental Certification 1
Ricardo Quintero
 
Introduction to database-Transaction Concurrency and Recovery
Ajit Nayak
 
The Ultimate gift
Sebastien Juras
 
Six things to know about your brain to become an expert
Sebastien Juras
 
Uml Omg Fundamental Certification 5
Ricardo Quintero
 
The badguy summary
Sebastien Juras
 
Software Engineering an Introduction
Ajit Nayak
 
Innovation is almost impossible for older companies
Sebastien Juras
 
Is your company fully engaged towards innovation?
Sebastien Juras
 
Things to know to improve your willpower
Sebastien Juras
 
Operating Systems Part III-Memory Management
Ajit Nayak
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Ajit Nayak
 
Psychology explains the power of Storytelling
Sebastien Juras
 
Manual 02
Ricardo Quintero
 
03 administracion de requisitos
Ricardo Quintero
 
The Bad Guy in your company and how have him under control
Sebastien Juras
 
Omg Fundamental Certification 4
Ricardo Quintero
 
Database Programming using SQL
Ajit Nayak
 
Perfiles UML
Jose R. Hilera
 
Computer Networks Module III
Ajit Nayak
 
Ad

Similar to Ns2: Introduction - Part I (20)

PDF
study-of-network-simulator.pdf
Jayaprasanna4
 
PDF
Ns2: OTCL - PArt II
Ajit Nayak
 
PPTX
NErwork Lab Simulation Introduction.pptx
AmbikaVenkatesh4
 
PPTX
Working with NS2
chanchal214
 
PDF
Ns2pre
Pratik Joshi
 
PDF
Cs757 ns2-tutorial-exercise
Pratik Joshi
 
PDF
cscn1819.pdf
Anil Sagar
 
PPTX
~Ns2~
Bhaseerun nisha
 
PPT
Ns fundamentals 1
narmada alaparthi
 
PDF
Ns tutorial
SAMMMATHEW
 
PPT
Network Simulator Tutorial
cscarcas
 
PPT
Ns2
ganeshan2k1
 
PPT
Session 1 introduction to ns2
thenmozhi ravichandran
 
PDF
Introduction to ns2
ProfDrSharadSharma
 
PPT
Venkat ns2
venkatnampally
 
PPT
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
PPT
Tut hemant ns2
crescent000
 
PPTX
Network Simulator overview and its working
singhparmpreet
 
PDF
An introduction to_ns_nam_and_o_tcl_scripting
Dani Aristiyawan
 
study-of-network-simulator.pdf
Jayaprasanna4
 
Ns2: OTCL - PArt II
Ajit Nayak
 
NErwork Lab Simulation Introduction.pptx
AmbikaVenkatesh4
 
Working with NS2
chanchal214
 
Ns2pre
Pratik Joshi
 
Cs757 ns2-tutorial-exercise
Pratik Joshi
 
cscn1819.pdf
Anil Sagar
 
Ns fundamentals 1
narmada alaparthi
 
Ns tutorial
SAMMMATHEW
 
Network Simulator Tutorial
cscarcas
 
Session 1 introduction to ns2
thenmozhi ravichandran
 
Introduction to ns2
ProfDrSharadSharma
 
Venkat ns2
venkatnampally
 
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
Tut hemant ns2
crescent000
 
Network Simulator overview and its working
singhparmpreet
 
An introduction to_ns_nam_and_o_tcl_scripting
Dani Aristiyawan
 
Ad

More from Ajit Nayak (20)

PDF
Software Engineering : Software testing
Ajit Nayak
 
PDF
Software Engineering :Behavioral Modelling - II State diagram
Ajit Nayak
 
PDF
Software Engineering :UML class diagrams
Ajit Nayak
 
PDF
Software Engineering : OOAD using UML
Ajit Nayak
 
PDF
Software Engineering : Requirement Analysis & Specification
Ajit Nayak
 
PDF
Software Engineering : Process Models
Ajit Nayak
 
PDF
NS2: AWK and GNUplot - PArt III
Ajit Nayak
 
PDF
Socket programming using C
Ajit Nayak
 
PDF
Object Oriented Analysis Design using UML
Ajit Nayak
 
PDF
Parallel programming using MPI
Ajit Nayak
 
PDF
Operating Systems Part I-Basics
Ajit Nayak
 
PDF
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Ajit Nayak
 
PDF
Introduction to database-Formal Query language and Relational calculus
Ajit Nayak
 
PDF
Introduction to database-Normalisation
Ajit Nayak
 
PDF
Introduction to database-ER Model
Ajit Nayak
 
PDF
Computer Networks Module II
Ajit Nayak
 
PDF
Computer Networks Module I
Ajit Nayak
 
PDF
Object Oriented Programming using C++ Part III
Ajit Nayak
 
PDF
Object Oriented Programming using C++ Part I
Ajit Nayak
 
PDF
Object Oriented Programming using C++ Part II
Ajit Nayak
 
Software Engineering : Software testing
Ajit Nayak
 
Software Engineering :Behavioral Modelling - II State diagram
Ajit Nayak
 
Software Engineering :UML class diagrams
Ajit Nayak
 
Software Engineering : OOAD using UML
Ajit Nayak
 
Software Engineering : Requirement Analysis & Specification
Ajit Nayak
 
Software Engineering : Process Models
Ajit Nayak
 
NS2: AWK and GNUplot - PArt III
Ajit Nayak
 
Socket programming using C
Ajit Nayak
 
Object Oriented Analysis Design using UML
Ajit Nayak
 
Parallel programming using MPI
Ajit Nayak
 
Operating Systems Part I-Basics
Ajit Nayak
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Ajit Nayak
 
Introduction to database-Formal Query language and Relational calculus
Ajit Nayak
 
Introduction to database-Normalisation
Ajit Nayak
 
Introduction to database-ER Model
Ajit Nayak
 
Computer Networks Module II
Ajit Nayak
 
Computer Networks Module I
Ajit Nayak
 
Object Oriented Programming using C++ Part III
Ajit Nayak
 
Object Oriented Programming using C++ Part I
Ajit Nayak
 
Object Oriented Programming using C++ Part II
Ajit Nayak
 

Recently uploaded (20)

PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
PPTX
Destructive Tests corrosion engineer (1).pptx
zeidali3
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
Day2 B2 Best.pptx
helenjenefa1
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
Destructive Tests corrosion engineer (1).pptx
zeidali3
 
Hashing Introduction , hash functions and techniques
sailajam21
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Thermal runway and thermal stability.pptx
godow93766
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 

Ns2: Introduction - Part I

  • 1. Ajit K Nayak, Ph.D. Dept of CSIT, ITER An Introduction to NS2: The Network Simulator
  • 2. What is Simulation ? Network simulation is a technique where a program models the behavior of a network either by calculating the interaction between the different network entities (hosts/, etc.) using mathematical formulas, or actually capturing and playing back observations from a production network.
  • 4. Sample Input Script (Tcl) set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] $ns at 0.0 "$n0 label Sender“ $ns at 0.0 "$n1 label Receiver“ set nf [open test.nam w] $ns namtrace-all $nf set f [open test.tr w] $ns trace-all $f $ns duplex-link $n0 $n1 0.2Mb 200ms DropTail $ns duplex-link-op $n0 $n1 orient right . . .
  • 5. Sample output traces - 2.846272 0 2 ack 576 ------- 0 0.0 4.0 15545 61 r 2.851664 0 2 ack 576 ------- 0 0.0 4.0 14473 59 + 2.851664 2 3 ack 576 ------- 0 0.0 4.0 14473 59 d 2.851664 2 3 ack 576 ------- 0 0.0 4.0 14473 59 r 2.854576 3 2 ack 40 ------- 1 4.0 0.0 3217 48 n -t * -s 0 -x 200 -y 30 -Z 0 -z 30 -v circle -c black c -t * -i 8 -n red c -t * -i 1 -n black c -t * -i 2 -n orange c -t * -i 6 -n tan c -t * -i 7 -n purple c -t * -i 3 -n green + -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC - -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC h -t 0.001635381 -s 0 -d -1 -p message -e 90 -c 2 -a 0 -i 0 -k MAC r -t 0.002355848 -s 2 -d -1 -p message -e 32 -c 2 -a 0 -i 0 -k MAC
  • 6. Output (NAM Trace) Run the NAM trace using Network AniMator package
  • 7. Output (Packet Trace) Extract required data from packet trace (shell, awk, perl, C, etc…) Plot the data using gnuPlot, Xgraph, MsExcel etc.
  • 8. Where to go? Learn Tcl/OTcl Write Tcl scripts for network simulation Execute the simulation Observe the result in NAM Learn to extract Info from Packet trace Plot using any plotting software Measure the protocol/network performance
  • 9. Tcl/OTcl - Basics  Everything in Tool comand language(Tcl) is a command followed by a number of arguments, which are separated by whitespace.  command arg1 arg2 ... argn.  To Execute a Tcl script Method 1:  Start the NS environment  $ ns (this will start the shell) % % puts stdout “Hello World” Hello World % Method 2:  Write the Tcl command(s) in a file and save it to <fileName>.tcl, then execute as follows in (OS shell) $ ns <fileName>.tcl
  • 10. Tcl/OTcl – I/O Commands  Printing(output): puts  puts $<var>  puts <constant>  Reading(input): gets  gets stdin <var>  Comment: #  # This is my first tcl script
  • 11. Tcl/OTcl - Variables  Tcl is a dynamically typed language  Need not to declare variable types (datatypes).  A variable can store anything, irrespective of type and type checking is done at runtime.  Variable initialization.  Syntax: set <variable> <value>  Example:  % set intVar 10  % set a [expr 2.5*10]  % puts {intVar is $intVar}  % puts $a
  • 12. Tcl/OTcl – control structure-I Control Structures: if {$z == 6} then { puts “Correct!”} for {set i =0} {$i < 5} {incr i } { puts “$i * $i equals [expr $i * $i]” } Other branching-constructs switch <string> { <pattern_1> { <body_1> } <pattern_2> { <body_2> } . . . <default> { body } }
  • 13. Tcl/OTcl – control structure-II Other Loop constructs while {<test>} { <body> } foreach {<var1> <var2>} <var> { <body> } Example: set observations {Bhubaneswar 35 49 Cuttack 32 45 Bolangir 18 30} foreach {town Tmin Tmax} $observations { set Tavg [expr ($Tmin+$Tmax)/2.0] puts “$town $Tavg" } break, continue
  • 14. Tcl/OTcl – Array Required to store multiple elements. These are implemented as associative maps. i.e. it associates an array index (key) with an array element. Unlike ‘C/C++’ arrays, the Tcl array index can be a string. Example set myArray(0) 1 set myArray(1) 65 set Link(pktsize) 512 set Link(protocol) “IEEE 802.11" puts $myArray(0) puts $myArray(1) puts $Link(pktsize) puts $Link(protocol)
  • 15. Tcl/OTcl – Procedure The ‘proc’ command creates a new command. Syntax: proc <procName> <args> <body> Example: # procedure without args proc myCommand {} { puts “My first Tcl command" } myCommand #proc call # procedure with args proc avg {min max} { return [expr ($min + $max) / 2] } set average [avg 10 20]; puts $average #proc call
  • 16. Tcl – Practice Progs. Write Tcl scripts for the followings to add two given numbers. To find largest among three numbers To print a day given a number (1-7) using switch To add all odd numbers (1-100) To read and print one array containing name and roll numbers of some students. Write a procedure to find the sum of the digits of a given number. Use this procedure to find sum of the digits for a given range of numbers.
  • 17. End of NS2 Part I Thank You