Our research professionals with their experience in this field and provided the article based on how to call a function in TCL script.
Create a function in TCL script
TCL script is used for create a function for random position allocation for all nodes in the main file by using the keyword proc,
proc destination1 {} {
global ns val node_
set time 1.0
set now [$ns now]
for {set i 0} {$i< $val(nn) } {incr i} {
set xx [expr rand()*1000 ]
set yy [expr rand()*1000]
$ns at $now “$node_($i) setdest $xx $yy 500000”
}
}
Call a function in TCL script
The following TCL script is used for call a function in the main file,
$ns at 0.5 “destination1”
It is used to call a function by using network simulator object, simulation time and also the function name.
Run the TCL script with function
To run the TCL script with user defined function by execute the following commands,
cd /home/research/Desktop/Tcl_Script
sudo ./ns Main_Script.tcl
We provided this article in step by step process like, create a function, call a function and run TCL script to make it easy for you to call a function in TCL script. If you have any queries, please reach us.