set ns [new Simulator] $ns rtproto DV set nf [open out1.nam w] set fh [open log1.txt w] $ns trace-all $tr $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace close $nf exec nam out1.nam & exit 0 } for {set i 0} {$i < 10} {incr i} { set n($i) [$ns node] } for {set j 0} {$j < 10} {incr j} { $ns duplex-link $n($j) $n([expr ($j +1)%10]) 1Mb 50ms DropTail } set cbr0 [new Agent/CBR] $ns attach-agent $n(0) $cbr0 $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.01 set null3 [new Agent/Null] $ns attach-agent $n(3) $null3 $ns connect $cbr0 $null3 proc mydump2 {node fh} { global ns set now [$ns now] puts "Routing table of node $node at time $now" set dr [$node rtObject?] $dr dump-routes $fh } #if you want to see every node routing table you can use this other proc #(which doesn't write the output on any file) #proc mydump {} { # global ns # set now [$ns now] # puts "Routing table at time $now" # $ns dump-routelogic-nh # $ns dump-routelogic-distance #} $ns at 1.0 "$cbr0 start" $ns at 8.0 "$cbr0 stop" $ns rtmodel-at 3.0 down $n(0) $n(1) $ns rtmodel-at 6.0 up $n(0) $n(1) $ns at 2.9 "mydump2 $n(2) $fh" $ns at 3.31 "mydump2 $n(2) $fh" $ns at 3.37 "mydump2 $n(2) $fh" $ns at 10.0 "finish" $ns run