$ns cost $n1 $n2 10        # set cost of link \textbf{from} $n1 \textbf{to} $n2 to 10;
        $ns cost $n2 $n1  5        # set cost of link in reverse direction to 5;
        [$ns link $n1 $n2] cost?   # query cost of link from $n1 to $n2;
        [$ns link $n2 $n1] cost?   # query cost of link in reverse direction;
Notice that the procedure sets the cost along one direction only.
Similarly, the procedure
[]cost?../ns-2/route-proto.tclLink::cost?
returns the cost of traversing the specified unidirectional link.
The default cost of a link is 1.