【正文】
f instvar next_rtm_ if {$next_rtm_ == } { set next_rtm_ $module } else { $next_rtm_ routenotify $module } } 把 rtmoudule構成鏈表 Node instproc portnotify { module } { $self instvar ptnotif_ lappend ptnotif_ $module } Node RtModule/Base Classifier/Hash/Dest mod_assoc_(_o13)=_o12 classifier_ entry_ 紅色是Node的變量 表示對象之間的聯(lián)系紐帶 數(shù)據(jù)包的傳輸 set n1 [$ns node] _o11 _o11 info class Node _o12 info class RtModule/Base _o13 info class Classifier/Hash/Dest set n2 [$ns node] _o14 _o14 info class Node _o15 info class RtModule/Base _o16 info class Classifier/Hash/Dest _o17 info class invalid mand name _o17 while executing _o17 info class 路由模塊,如果要加入策略路由的話,或者自己開發(fā)路由協(xié)議,需要自己開發(fā)這個模塊。 這一步的所有對象都由這個命令創(chuàng)建 (找到了,其實就是 new Node) 在 c++的Simulator對象中加入該 node對象 new Node之后,會調用 Node類的 init函數(shù) tcl/lib/ if {[llength $args] != 0} { set address_ [lindex $args 0] } else { set address_ $id_ } $self cmd addr $address_。s still used by mobile IP, algorithmic routing, manual routing, and backward pability tests of hierarchical routing, we should keep it around before all related code are wiped out. set node [eval new [Simulator set node_factory_] $args] set Node_([$node id]) $node add to simulator39。 一個仿真例子的操作過程 1. 寫場景 tcl腳本 , 2. 運行 ns 3. 察看仿真過程,是否有錯或者是否與預想中的大致相似 nam 4. 分析仿真數(shù)據(jù) ,可以用各種工具 set ns [new Simulator] set tracefd [ open w] set namfd [open w] $ns traceall $tracefd $ns namtraceall $namfd set n0 [$ns node] set n1 [$ns node] $ns duplexlink $n0 $n1 1Mb 10ms DropTail set tcp [new Agent/TCP] set snk [new Agent/TCPSink] $ns attachagent $n0 $tcp $ns attachagent $n1 $snk set ftp [new Application/FTP] $ftp attachagent $tcp $ns connect $tcp $snk $ns at $ftp start $ns at ―exit 0 $ns run 例子的仿真結果 + 0 1 tcp 1040 0 7 14 0 1 tcp 1040 0 7 14 + 0 1 tcp 1040 0 8 15 r 1 0 ack 40 0 4 11 + 0 1 tcp 1040 0 9 16 V t * v a 0 A t * n 1 p 0 o 0xffffffff c 31 a 1 A t * h 1 m 2147483647 s 0 n t * a 0 s 0 S UP v circle c black i black n t * a 1 s 1 S UP v circle c black i black l t * s 0 d 1 S UP r 1000000 D c black + t s 0 d 1 p tcp e 40 c 0 i 0 a 0 x { 0 null} t s 0 d 1 p tcp e 40 c 0 i 0 a 0 x { 0 null} h t s 0 d 1 p tcp e 40 c 0 i 0 a 0 x { 1 null} r t s 0 d 1 p tcp e 40 c 0 i 0 a 0 x { 0 null} + t s 1 d 0 p ack e 40 c 0 i 1 a 0 x { 0 null} 2一個最簡單的 ns腳本的啟動過程 set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] $ns duplexlink $n0 $n1 1Mb 10ms DropTail set tcp [new Agent/TCP] set snk [new Agent/TCPSink] $ns attachagent $n0 $tcp $ns attachagent $n1 $snk set ftp [new Application/FTP] $ftp attachagent $tcp $ns connect $tcp