Alexandre, The original is a big TCL. This excerpt can help you.
Enjoy! Sidney Doria UFCG / BRAZIL Thanks to Priscila Doria (UFCG), who created this scenario script. Thanks to somebody who created the two special routines. ------------ # Create six nodes (some of them are routers) set x [$ns node] set y [$ns node] set z [$ns node] set w [$ns node] set r1 [$ns node] set r2 [$ns node] set r3 [$ns node] set r4 [$ns node] set a [$ns node] set b [$ns node] set c [$ns node] set d [$ns node] # Configure node colors (NAM) $x color green $y color red $z color purple $w color white $r1 shape box $r2 shape box $r3 shape box $r4 shape box $a color green $b color red $c color purple $d color white # Connect them. $ns duplex-link $r1 $x 10Mb 1ms DropTail $ns duplex-link $r1 $c 10Mb 1ms DropTail $ns duplex-link $r1 $r2 2Mb 20ms DropTail $ns duplex-link $r2 $y 10Mb 1ms DropTail $ns duplex-link $r2 $d 10Mb 1ms DropTail $ns duplex-link $r2 $r3 10Mb 40ms DropTail $ns duplex-link $r3 $z 10Mb 1ms DropTail $ns duplex-link $r3 $a 10Mb 1ms DropTail $ns duplex-link $r3 $r4 2Mb 20ms DropTail $ns duplex-link $r4 $w 10Mb 1ms DropTail $ns duplex-link $r4 $b 10Mb 1ms DropTail $ns duplex-link $r4 $r1 10Mb 40ms DropTail # NAM organization (orientation) $ns duplex-link-op $r1 $x orient up $ns duplex-link-op $r1 $c orient left $ns duplex-link-op $r1 $r2 orient right $ns duplex-link-op $r2 $y orient right $ns duplex-link-op $r2 $d orient up $ns duplex-link-op $r2 $r3 orient down $ns duplex-link-op $r3 $z orient right $ns duplex-link-op $r3 $a orient down $ns duplex-link-op $r3 $r4 orient left $ns duplex-link-op $r4 $w orient left $ns duplex-link-op $r4 $b orient down $ns duplex-link-op $r4 $r1 orient up # Alexandre, these two routines help in the static routing construction # Returns the local link that leads to # the next hop node with the passed # node address parameter. If no link to # the given node exists, the procedure # returns -1. Node instproc nexthop2link { nexthop } { #$self instvar link_ set ns_ [Simulator instance] foreach {index link} [$ns_ array get link_] { set L [split $index :] set src [lindex $L 0] if {$src == [$self id]} { set dst [lindex $L 1] if {$dst == $nexthop} { # Cost Debug #puts "Src:$src Dst:$dst Link:$link" #puts "[$link info class]" # End Cost Debug return $link } } } return -1 } # # This procedure is used to add explicitly # routes to a node, overriding the routing # policy used (e.g. shortest path routing). # Tested currently with static ns2 routing. # Essentially, it is used to add policy-routing # entries in realistic network topologies. # # Parameters: # # node: the ns2 node, to which the route # entry is added to. This parameter # is of type Node. # dst: the destination, to which the route # entry refers to. This parameter # is of type Node. # via: the next hope node, that the local node # will use to access the destination node. # This parameter is of type Node. # ########################################################## proc addExplicitRoute {node dst via } { set link2via [$node nexthop2link [$via node-addr]] if {$link2via != -1} { $node add-route [$dst node-addr] [$link2via head] } else { puts "Warning: No link exists between node [$node node-addr] and [$via node-addr]. Explicit route not added." } } # Routing Table! $ns at 0 "addExplicitRoute $r1 $z $r4" $ns at 0 "addExplicitRoute $r1 $a $r2" $ns at 0 "addExplicitRoute $r1 $w $r4" $ns at 0 "addExplicitRoute $r2 $w $r1" $ns at 0 "addExplicitRoute $r2 $b $r3" $ns at 0 "addExplicitRoute $r2 $x $r1" $ns at 0 "addExplicitRoute $r3 $x $r2" $ns at 0 "addExplicitRoute $r3 $c $r4" $ns at 0 "addExplicitRoute $r3 $y $r2" $ns at 0 "addExplicitRoute $r4 $y $r3" $ns at 0 "addExplicitRoute $r4 $d $r1" $ns at 0 "addExplicitRoute $r4 $z $r3" ------------ 2010/5/17 Alexandre Jaron <alexandre.ja...@gmail.com>: > > Hello, > > I built a wired topology in which I want to edit routing tables for a > certain number of nodes. > I want to tell a node, every packet coming from this node forward them to > that node. Just as simple as it is. > > I found something on the Internet : [$node set ragent_] addstaticroute > <number of hops> <next hop> <destination node> <interface> > But 'ragent' is unknown, and I don't know how to write down the arguments, > what is the interface arg? next hop, is it an address, a node ? > > Looking forward to your answer, > Kind regards, > > Alexandre Jaron. > MSc student at the King's College London. > -- Sidney Doria Redes ad hoc móveis Doutorado em Computação UFCG Brasil "Nessa jornada, o conhecimento será o seu escudo..." (Mestre dos Magos no episódio do grimoire de ouro)