【正文】
$module cmd routenotify $self } RtModule instproc routenotify { module } { $self instvar next_rtm_ if {$next_rtm_ == } { set next_rtm_ $module } else { $next_rtm_ routenotify $module } } 把 rtmoudule構(gòu)成鏈表 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ā)這個(gè)模塊。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。NS 的 網(wǎng)絡(luò)功能實(shí)體結(jié)構(gòu)及類結(jié)構(gòu) 任三陽 把 N門時(shí)髦的技術(shù)掛在嘴邊不如將一門過時(shí)的技術(shù)記在心里。但是用起來簡單,只需要知道“我的一個(gè)事件,給定一個(gè)時(shí)間,交給它,到時(shí)候它就會處理”就行了 創(chuàng)建對象 _o7,類型為Agent/Null,一個(gè)黑洞 tcl/lib/ Simulator instproc usescheduler type { $self instvar scheduler_ if [info exists scheduler_] { if { [$scheduler_ info class] == Scheduler/$type } { return } else { delete $scheduler_ } } set scheduler_ [new Scheduler/$type] $scheduler_ now } _o4 info class Simulator _o5 info class PacketHeaderManager _o6 info class Scheduler/Calendar _o7 info class Agent/Null _o8 info class AllocAddrBits _o9 info class AllocAddr _o10 info class Address _o11 info class invalid mand name _o11 while executing _o11 info class 目前為止已經(jīng)產(chǎn)生了 10個(gè)對象了 啟動(dòng)過程 2☆ ? set n0 [$ns node] ? set n1 [$ns node] tcl/lib/ Simulator instproc node args { $self instvar Node_ routingAgent_ wiredRouting_ satNodeType_ …… Enablemcast is now done automatically inside Node::init{} XXX node_factory_ is deprecated, HOWEVER, since it39。 $self mkdefaultclassifier 顯式調(diào)用 mand方法的一個(gè)例子。s routing entry to itself at the port demuxer (if there is one) $self addroute $address_ $dmux_把到自己的路由加入進(jìn)去 } if { $port == ―‖ } {會進(jìn)入,因?yàn)橐话悴恢付ǘ丝? set port [$dmux_ allocport [[Simulator instance] nullagent]] } $agent set agent_port_ $port $self addtarget $agent $port } 把該 agent加到node的 agent列表 插敘: Ns的 IP地址 //classifier/ if (strcmp(argv[1],allocport) == 0) { int slot。 return(TCL_OK)。有相關(guān)函數(shù) (類似 routenotify函數(shù) )portnotify,但沒有看到調(diào)用的地方(在 RtModule的 register函數(shù)中調(diào)用了,也就是說在路由模塊既負(fù)責(zé)尋路又負(fù)責(zé)端口的對應(yīng),后者只是一個(gè)虛名,還是由 Classifier/Port自己完成的 )。并且 OTcl還為一些聯(lián)系緊密的c++類構(gòu)造一個(gè) OTcl類 (那些顯式出現(xiàn)了 Class xxx –superclass xxx),例如 Link 只有 OTcl類,因?yàn)樘唵?