【正文】
該函數(shù)不可見,是二進制的 對應類的 init{} 基類的 init{},最終調(diào)用SplitObject的 init{} $self createshadow $args,進入 c++代碼 .。這里通過 attach把 agent加入到 每個路由模塊的 路由表。 slot = getnxt(nullagent)。其實該模塊的功能是計算路由,而執(zhí)行路由是由 Classifier進行的 路由的執(zhí)行 啟動過程 3☆ ? $ns duplexlink $n0 $n1 1Mb 10ms DropTail tcl/lib/ Simulator instproc duplexlink { n1 n2 bw delay type args } { $self instvar link_ set i1 [$n1 id] set i2 [$n2 id] if [info exists link_($i1:$i2)] { $self removenamlinkconfig $i1 $i2 } eval $self simplexlink $n1 $n2 $bw $delay $type $args eval $self simplexlink $n2 $n1 $bw $delay $type $args Modified by GFR for nixvector routing if { [Simulator set nixrouting] } { Inform nodes of neighbors $n1 setneighbor [$n2 id] $n2 setneighbor [$n1 id] } } $ns duplexlink $n1 $n2 1Mb 10ms DropTail _o17 info class Queue/DropTail _o18 info class SimpleLink _o19 info class Connector _o20 info class Connector _o21 info class DelayLink _o22 info class TTLChecker _o23 info class Queue/DropTail _o24 info class SimpleLink _o25 info class Connector _o26 info class Connector _o27 info class DelayLink _o27 info class DelayLink _o28 info class TTLChecker _o29 info class invalid mand name _o29 while executing _o29 info class 啟動過程 4 ? set tcp [new Agent/TCP] ? set snk [new Agent/TCPSink] ? 在 tcl/lib/ Agent/TCP instproc init {} { eval $self next set ns [Simulator instance] $ns createeventtrace Event $self } Class Agent/Null superclass Agent Agent/Null instproc init args { eval $self next $args } set tcp [new Agent/TCP] _o29 _o29 info class Agent/TCP _o30 info class invalid mand name _o30 while executing _o30 info class set nul [new Agent/TCPSink] _o30 _o30 info class Agent/TCPSink _o31 info class invalid mand name _o31 while executing _o31 info class 啟動過程 5 ? set ftp [new Application/FTP] ? 沒有相關(guān)代碼,說明都使用默認情況:簡單 new一個對象而已 set ftp [new Application/FTP] _o31 _o31 info class Application/FTP _o32 info class invalid mand name _o32 while executing _o32 info class 啟動過程 6 ☆ ? $ns attachagent $n0 $tcp ? $ns attachagent $n1 $snk ? 這一步非常重要,也非常復雜。s nodelist in C++ space $self addnode $node [$node id] set the nodeid in c++ Node ratul $node nodeid [$node id] $node set ns_ $self $self checknodenum return $node } 代碼沒有找到。 ——BBS A poor framework is much better than nothing. ——kkzhou outline ? 1預修知識 ? 2一個最簡單的 ns仿真的啟動過程 ? 3Ns的網(wǎng)絡實體結(jié)構(gòu)和類結(jié)構(gòu) 1預修知識 ? C++、 Tcl、 OTcl的語法 – – – 《 ns與網(wǎng)絡模擬 》 ? 面向?qū)ο蟮乃枷耄禾摂M函數(shù),動態(tài)創(chuàng)建機制 ? Ns的安裝和簡單仿真操作 (論壇上有 ) ? Ns的開發(fā)工具: gdb和 tcldebug(非常簡單 ) ? Ns的分裂對象模型和 tclcl(非常重要而且很難,主要原理是動態(tài)創(chuàng)建機制 ) 要學透, 注意區(qū)分類和對象 ,發(fā)現(xiàn)好多問題都是因為 OTcl理解不透造成的。 一個仿真例子的操作過程 1. 寫場景 tcl腳本 , 2. 運行 ns 3. 察看仿真過程,是否有錯或者是否與預想中的大致相似 nam 4. 分析仿真數(shù)據(jù) ,可以用各種工具 set n