# This ins't a complete script, but only a few lines where the use
# of the token bucket shaper can be seen


# Function to insert the shaper between two nodes
Simulator instproc insert-shaper {shaper n1 n2} {
         $self instvar link_
         set sid [$n1 id]
         set did [$n2 id]
         set templink $link_($sid:$did)
         set linktarget [$templink get-target]
         $templink set-target $shaper
         $shaper target $linktarget
} 

SimpleLink instproc set-target {tg} {
    $self instvar link_
    $link_ target $tg
}

SimpleLink instproc get-target {} {
    $self instvar link_
    set tg [$link_ target]
    return $tg 
}

 
#Create two nodes
set n0 [$ns node]
set n1 [$ns node]
 
  
#Create the shaper
set shaper [new DSShaper]
$shaper set-peak-rate 500000
$shaper set-burst-size 16000
$shaper set-queue-length 3
$shaper set-fid 1
 
#Insert the shaper between nodes n0 and n1
$ns insert-shaper $shaper $n0 $n1
 
 



