Procedure in ns2

  • Procedure can be written in tcl using the following command
  • Example1: Without Arguments

    add1
    set a 10
    set b 15
    proc add1 {}
    {
    global a b
    set value [expr $a+$b]
    puts "value = $value"
    }

  • Example2:  With Arguments

    add2 10 20
    proc add2 {p q}
    {
    global ns
    set result [expr $p*$q]
    puts "result=$result"