Tcl Tutorial for Beginners

            Tcl includes the general purpose of multi paradigm system programming language and it is denoted as the scripting language with the objective of providing the ability of applications to communicate along others. The Tk is considered as the cross platform widget toolkit and that is deployed to build the GUI. In general, Tcl is enhanced through the interaction of various programs and that is functioning as the embedded interpreter.

Creating Topology Using Tcl

          As the matter of fact, the network topology is essential for the simulation scenario and it has to be created as the fist process. When it comes to Ns2, the topology includes some collection of nodes and links. The topology is capable to set up the new simulator object and that is created in the starting process of script and it is functional using the below mentioned command.

set ns [new Simulator]

       This simulator object includes various members in this functions and that is about permitting the nodes, links and connecting agents.

  • Node
  • The objects based on node is created using the below mentioned command and the member of functions includes the similar class of nodes
set n0 [$ns node]
  • Agent, traffic sources and applications
  •      Application/Traffic/Trace
  • Traffic is generated from a trace file in which the sizes and inter arrival times of the packets are defined
  • Application/Traffic/CBR
  • It is capable to create packets with a constant bit rate
  • Application/FTP
  • It is the production of bulk data that TCP will send
  • Agent/TCP/Sack1
  • TCP with selective acknowledgement
  • Agent/TCP/Reno
  • It is the depiction of Reno TCP sender
  • Agent/TCP
  • It is the Tahoe TCP sender
  • Send
  • This about the creation of CBR traffic source using UDP over the transport protocol and it is attached with the node n1 
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packet_size_ 1000
$udp0 set packet_size_ 1000
$cbr0 set rate_ 1000000
set tcp1 [new Agent/TCP]
$ns attach-agent $n1 $tcp1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$tcp1 set packet_size_ 1000
  • Traffic sinks
  • It is about the flow of terminated processing in TCP and UDP sources have to be functioning with the traffic sinks. The TCP sink is defined as the class agent of TCP sink which is highlighted in the following command. Along with that we have enlisted connection of TCPL commands
set null [new Agent/Null]
$ns attach-agent $n2 $null
$ns connect $udp0 $null
set sink [new Agent/Sink]
$ns attach-agent $n3 $sink
$ns connect $tcp1 $sink
$ns create-connection < srctype> < src> < dsttype> < dst> < pktclass>
  • Monitors
  • It is about the process of queue monitoring the track with the arrival, departure and drops of statistics over the packets and that is highlighted in the below mentioned command
set qmon0 [$ns monitor-queue $n0 $n1]
set parr [$qmon0 set parrivals_]
set bdrop [$qmon0 set bdrops_]

Command in Tcl

       Hereby, our research professionals have highlighted some command based on the functions of Tcl in the following.

  • If command
if {$x <
... 0} {
} elseif {$x == 0} {
} elseif {$x == 1} {
} else {
• While command
while {$i >= 0} {
incr i -1
• For command
for {set i [expr $a-5]} {$i >= 0} {incr i -1} {
• Foreach command
set a {3 5 5} foreach i $a {
puts [expr $i*2]

         We hope that you got a general idea about the Tcl tutorials to precede your research as the beginners. Our research experts provide assistance for all your research needs and we are to join hands with you to show the better heights in your research career.