版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、NS 的網(wǎng)絡(luò)功能實(shí)體結(jié)構(gòu)及類結(jié)構(gòu),Infonet. Lab. Dept. EEIS USTC 周曉波 20051010,把N門時(shí)髦的技術(shù)掛在嘴邊不如將一門過時(shí)的技術(shù)記在心里。BBS,A poor framework is much better than nothing. kkzhou,outline,1 預(yù)修知識(shí) 2 一個(gè)最簡(jiǎn)單的ns仿真的啟動(dòng)過程 3 Ns的網(wǎng)絡(luò)實(shí)體結(jié)構(gòu)和類結(jié)構(gòu),1預(yù)修知識(shí),C+、Tcl、OTcl的語法 ns與網(wǎng)絡(luò)模擬 面向?qū)ο蟮乃枷耄禾摂M函數(shù),動(dòng)態(tài)創(chuàng)建機(jī)制 Ns的安裝和簡(jiǎn)單仿真操作(實(shí)驗(yàn)室論壇上有) Ns的開發(fā)工具:gdb和tcldebug(非常簡(jiǎn)單) Ns的分裂對(duì)象模型
2、和tclcl(非常重要而且很難,主要原理是動(dòng)態(tài)創(chuàng)建機(jī)制),要學(xué)透,注意區(qū)分類和對(duì)象,發(fā)現(xiàn)好多問題都是因?yàn)镺Tcl理解不透造成的。,一個(gè)仿真例子的操作過程,寫場(chǎng)景tcl腳本,temp.tcl 運(yùn)行ns temp.tcl 察看仿真過程,是否有錯(cuò)或者是否與預(yù)想中的大致相似nam tmp.nam 分析仿真數(shù)據(jù)tmp.tr,可以用各種工具,set ns new Simulator set tracefd open tmp.tr w set namfd open tmp.nam w $ns trace-all $tracefd $ns namtrace-all $namfd set n0 $ns node
3、 set n1 $ns node $ns duplex-link $n0 $n1 1Mb 10ms DropTail set tcp new Agent/TCP set snk new Agent/TCPSink $ns attach-agent $n0 $tcp $ns attach-agent $n1 $snk set ftp new Application/FTP $ftp attach-agent $tcp $ns connect $tcp $snk $ns at 0.1 $ftp start $ns at 5.0 “exit 0 $ns run,注意:仿真的目的??梢哉J(rèn)為,對(duì)一個(gè)協(xié)議
4、的改進(jìn)包括功能和性能兩種情況。一般來說是仿真是要分析一個(gè)協(xié)議的性能。功能性的分析不需要仿真。,例子的仿真結(jié)果,+ 0.29792 0 1 tcp 1040 - 0 0.0 1.0 7 14 - 0.29792 0 1 tcp 1040 - 0 0.0 1.0 7 14 + 0.29792 0 1 tcp 1040 - 0 0.0 1.0 8 15 r 0.30624 1 0 ack 40 - 0 1.0 0.0 4 11 + 0.30624 0 1 tcp 1040 - 0 0.0 1.0 9 16,tmp.tr文件內(nèi)容節(jié)選,V -t * -v 1.0a5 -a 0 A -t * -n 1 -
5、p 0 -o 0 xffffffff -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 0.029999999999999999 -c black + -t 0.1 -s 0 -d 1 -p tcp -e 40 -c 0 -i 0 -a 0 -x 0.0 1.0 0 - null - -
6、t 0.1 -s 0 -d 1 -p tcp -e 40 -c 0 -i 0 -a 0 -x 0.0 1.0 0 - null h -t 0.1 -s 0 -d 1 -p tcp -e 40 -c 0 -i 0 -a 0 -x 0.0 1.0 -1 - null r -t 0.13032 -s 0 -d 1 -p tcp -e 40 -c 0 -i 0 -a 0 -x 0.0 1.0 0 - null + -t 0.13032 -s 1 -d 0 -p ack -e 40 -c 0 -i 1 -a 0 -x 1.0 0.0 0 - null,tmp.nam文件內(nèi)容節(jié)選,預(yù)修知識(shí),C+、Tcl、
7、OTcl的語法 ns與網(wǎng)絡(luò)模擬 面向?qū)ο蟮乃枷耄禾摂M函數(shù),動(dòng)態(tài)創(chuàng)建機(jī)制 Ns的安裝和簡(jiǎn)單仿真操作(實(shí)驗(yàn)室論壇上有) Ns的開發(fā)工具:gdb和tcldebug(非常簡(jiǎn)單) Ns的分裂對(duì)象模型和tclcl(非常重要而且很難,主要原理是動(dòng)態(tài)創(chuàng)建機(jī)制),虛擬函數(shù)(以c+為例),class A public: virtual void vf()printf(“in A:vf()”); void f1() printf(“in A:f1()”) void fA() printf(“in A:fA()”) Private: int a1, a2; class B : public A public: vir
8、tual void vf()printf(“in B:vf”); void f1() printf(“in B:f1()”) void fB() printf(“in B:fB()”) private”: int b1, b2; ,void main() A *pa1 = new A; A *pa2; B *pb1 = new B; pa1-f1(); pa1-fA(); pa1-vf(); pb1-f1(); pb1-fA(); pb1-vf(); pa2 = (A*)pb1; pa2-f1(); pa2-fA(); pa2-vf(); / pa2-fB(); ,class A public
9、: virtual void vf()printf(“in A:vf()”); void f1() printf(“in A:f1()”) void fA() printf(“in A:fA()”) class B : public A public: virtual void vf()printf(“in B:vf”); void f1() printf(“in B:f1()”) void fB() printf(“in B:fB()”) ,in A:f1(),in A:fA(),in A:vf(),in B:f1(),in A:fA(),in B:vf(),in A:f1(),in A:f
10、A(),in B:vf(),語法出錯(cuò),類A的實(shí)例(對(duì)象),Poiter_to_A:vf,Poiter_to_B:vf,A* pa = new A; Pa-xx();,B* pb = new B; Pb-xx();,A* pa = (A*)pb; Pa-xx();,類B的實(shí)例(對(duì)象),X,預(yù)修知識(shí),C+、Tcl、OTcl的語法 ns與網(wǎng)絡(luò)模擬 面向?qū)ο蟮乃枷耄禾摂M函數(shù),動(dòng)態(tài)創(chuàng)建機(jī)制 Ns的安裝和簡(jiǎn)單仿真操作(實(shí)驗(yàn)室論壇上有) Ns的開發(fā)工具:gdb和tcldebug(非常簡(jiǎn)單) Ns的分裂對(duì)象模型和tclcl(非常重要而且很難,主要原理是動(dòng)態(tài)創(chuàng)建機(jī)制),要學(xué)透,發(fā)現(xiàn)好多問題都是因?yàn)镺Tcl理解不
11、透造成的。,動(dòng)態(tài)創(chuàng)建機(jī)制(以c+為例),定義:以字符串指定類型(也就是類),能夠創(chuàng)建出對(duì)象。 例如:已知一個(gè)字符串name = “CString”,如何new出一個(gè)CString對(duì)象 用處:很多。是整個(gè)復(fù)合文檔技術(shù)的基礎(chǔ),例如word、ppt、pdf等 在ns中的用處:在tcl中創(chuàng)建c+對(duì)象。 例如: set ftp new Agent/UDP 創(chuàng)建了OTcl對(duì)象Agent/UDP,和c+對(duì)象UdpAgent,MFC對(duì)動(dòng)態(tài)創(chuàng)建的實(shí)現(xiàn),/B.h class B : public A DECLARE_DYNCREATE(B) ; /B.cpp IMPLEMENT_DYNCREATE(B, A),#
12、define DECLARE_DYNCREATE(class_name) DECLARE_DYNAMIC(class_name) static CObject* PASCAL CreateObject(); #define DECLARE_DYNAMIC(class_name) public: static const CRuntimeClass class#class_name; virtual CRuntimeClass* GetRuntimeClass() const; #define IMPLEMENT_DYNCREATE(class_name, base_class_name) CO
13、bject* PASCAL class_name:CreateObject() return new class_name; IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0 xFFFF, class_name:CreateObject, NULL) #define IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew, class_init) AFX_COMDAT const CRuntimeClass class_name:class#class_na
14、me = #class_name, sizeof(class class_name), wSchema, pfnNew, RUNTIME_CLASS(base_class_name), NULL, class_init ; CRuntimeClass* class_name:GetRuntimeClass() const return RUNTIME_CLASS(class_name); #define RUNTIME_CLASS(class_name) _RUNTIME_CLASS(class_name) #define _RUNTIME_CLASS(class_name) (CRuntim
15、eClass*)( virtual CRuntimeClass* GetRuntimeClass() const; static CObject* PASCAL CreateObject(); ; /B.cpp IMPLEMENT_DYNCREATE(B, A) CObject* PASCAL class_name:CreateObject() return new class_name; AFX_COMDAT const CRuntimeClass class_name:class#class_name = #class_name, sizeof(class class_name), wSc
16、hema, pfnNew, (CRuntimeClass*)( ,class_name:CreateObject,預(yù)設(shè)初始值為0 xFFFF,NULL,/B.h class B : public A public: static const CRuntimeClass class#B; virtual CRuntimeClass* GetRuntimeClass() const; static CObject* PASCAL CreateObject(); ; /B.cpp CObject* PASCAL B:CreateObject() return new B; AFX_COMDAT co
17、nst CRuntimeClass B:class#B = #B, sizeof(class B), 0 xFFFF, B:CreateObject, (CRuntimeClass*)( ,類A(不是A的對(duì)象),?,函數(shù)指針,static CRuntimeClass:pFirstClass,struct CRuntimeClass LPCSTR m_lpszClassName; int m_nObjectSize; UINT m_wSchema; CObject* (PASCAL* m_pfnCreateObject)(); CRuntimeClass* m_pBaseClass; CRunt
18、imeClass* m_pNextClass; const AFX_CLASSINIT* m_pClassInit; ,ns中的動(dòng)態(tài)創(chuàng)建機(jī)制,class Idcus:public Agent; static class IdcusClass:TclClass public: IdcusClass():TclClass(Agent/Idcus) TclObject *create(int, const char* const*) return (new Idcus(); class_idcus;,class TclClass static TclClass* all_; TclClass* ne
19、xt_; OTclClass* class_; const char* classname_; virtual TclObject* create(int argc, const char*const*argv) ; TclClass:TclClass(const char* classname) : class_(0), classname_(classname) if (Tcl:instance().interp()!=NULL) bind(); else next_ = all_; all_ = this; ,指向隊(duì)尾,后面會(huì)講詳細(xì)過程,java中的動(dòng)態(tài)創(chuàng)建呢?,class Class,
20、自己去看看,仔細(xì)體會(huì),outline,1預(yù)修知識(shí) 2一個(gè)最簡(jiǎn)單的ns仿真的啟動(dòng)過程 3Ns的網(wǎng)絡(luò)實(shí)體結(jié)構(gòu)和類結(jié)構(gòu),2一個(gè)最簡(jiǎn)單的ns腳本的啟動(dòng)過程,set ns new Simulator set n0 $ns node set n1 $ns node $ns duplex-link $n0 $n1 1Mb 10ms DropTail set tcp new Agent/TCP set snk new Agent/TCPSink $ns attach-agent $n0 $tcp $ns attach-agent $n1 $snk set ftp new Application/FTP $ft
21、p attach-agent $tcp $ns connect $tcp $snk proc finish exit 0 $ns at 0.1 $ftp start $ns at 5.0 finish $ns run,一個(gè)注意點(diǎn)!,ns的功能實(shí)體(完成對(duì)數(shù)據(jù)包的處理)對(duì)應(yīng)一個(gè)個(gè)c+對(duì)象;管理和調(diào)度系統(tǒng)由Tcl/OTcl完成。 那么數(shù)據(jù)包是如何從一個(gè)對(duì)象傳遞到另一個(gè)對(duì)象的呢? uptarget_ downtarget_ 就是上面這兩個(gè)變量(也許名字不同) 看代碼是要對(duì)target_之類的變量多留意 例如(下一頁) 這兩個(gè)變量是如何被賦值的呢?就是我們要討論的問題。,Tcl/OTcl是管理者,C+
22、是打工仔!,Ns的類結(jié)構(gòu),最簡(jiǎn)單情況下網(wǎng)絡(luò)實(shí)體結(jié)構(gòu),啟動(dòng)過程0,當(dāng)命令行運(yùn)行ns,會(huì)創(chuàng)建3個(gè)對(duì)象_o1, _o2, _o3 _o1和_o2是RNG,_o3是Import (tclcl/tcl-import.tcl),simulator:/ins/ns-2.28/idcus$ ns % set a new Application/FTP _o4 % _o1 info class RNG % _o2 info class RNG % _o3 info class Import % _o4 info class Application/FTP,啟動(dòng)過程1,set ns new Simulator,#
23、tclcl/tcl-object.tcl proc new className args set o SplitObject getid if catch $className create $o $args msg if string match _FAILED_SHADOW_OBJECT_ $msg # # The shadow object failed to be allocated. # delete $o return global errorInfo error class $className: constructor failed: $msg $errorInfo retur
24、n $o ,“Simulator create 4” 該操作創(chuàng)建一個(gè)Simulator對(duì)象,并調(diào)用它的init函數(shù)進(jìn)行初始化,啟動(dòng)過程1,Simulator instproc init args ,#tcl/lib/ns-lib.tcl Simulator instproc init args $self create_packetformat $self use-scheduler Calendar $self set nullAgent_ new Agent/Null $self set-address-format def if lindex $args 0 = -multicast $
25、self multicast $args eval $self next $args ,這個(gè)還未找到代碼位置(找到了),可以猜想是創(chuàng)建數(shù)據(jù)包的頭標(biāo)對(duì)應(yīng)的數(shù)據(jù)結(jié)構(gòu),創(chuàng)建對(duì)象_o5,類型為PacketHeaderManager,創(chuàng)建對(duì)象_o6,類型為Scheduler/Calender,一個(gè)非常重要的類,單線程的ns能模擬多節(jié)點(diǎn)的網(wǎng)絡(luò),就是通過它來調(diào)度。但是用起來簡(jiǎn)單,只需要知道“我的一個(gè)事件,給定一個(gè)時(shí)間,交給它,到時(shí)候它就會(huì)處理”就行了,創(chuàng)建對(duì)象_o7,類型為Agent/Null,一個(gè)黑洞,#tcl/lib/ns-packet.tcl Simulator instproc create_pac
26、ketformat PacketHeaderManager instvar tab_ set pm new PacketHeaderManager foreach cl PacketHeader info subclass if info exists tab_($cl) set off $pm allochdr $cl $cl offset $off $self set packetManager_ $pm ,這一段設(shè)置各個(gè)頭標(biāo)的offset,這在處理頭標(biāo)的時(shí)候會(huì)經(jīng)常用到,例如 hdr_ip *hip = hdr_ip:access(p); return (hdr_ip*) p-access
27、(offset_); return (,#tcl/lib/ns-lib.tcl Simulator instproc use-scheduler 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 ,dbg1.8 _o4 info class Simulator dbg1.9 _o5 i
28、nfo class PacketHeaderManager dbg1.10 _o6 info class Scheduler/Calendar dbg1.11 _o7 info class Agent/Null dbg1.12 _o8 info class AllocAddrBits dbg1.13 _o9 info class AllocAddr dbg1.14 _o10 info class Address dbg1.15 _o11 info class invalid command name _o11 while executing _o11 info class dbg1.16 db
29、g1.16,目前為止已經(jīng)產(chǎn)生了10個(gè)對(duì)象了,啟動(dòng)過程2,set n0 $ns node set n1 $ns node,#tcl/lib/ns-lib.tcl Simulator instproc node args $self instvar Node_ routingAgent_ wiredRouting_ satNodeType_ # Enable-mcast is now done automatically inside Node:init # # XXX node_factory_ is deprecated, HOWEVER, since its still used by #
30、mobile IP, algorithmic routing, manual routing, and backward # compability 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 simulators nodelist in C+ space $self add-
31、node $node $node id #set the nodeid in c+ Node - ratul $node nodeid $node id $node set ns_ $self $self check-node-num return $node ,代碼沒有找到。 這一步的所有對(duì)象都由這個(gè)命令創(chuàng)建(找到了,其實(shí)就是new Node),在c+的Simulator對(duì)象中加入該node對(duì)象,new Node之后,會(huì)調(diào)用Node類的init函數(shù) #tcl/lib/ns-node.tcl if llength $args != 0 set address_ lindex $args 0 e
32、lse set address_ $id_ $self cmd addr $address_; $self mk-default-classifier,顯式調(diào)用command方法的一個(gè)例子。介紹一下command函數(shù),Node instproc mk-default-classifier Node instvar module_list_ # At minimum we should enable base module foreach modname Node set module_list_ $self register-module new RtModule/$modname ,Node
33、 instproc register-module mod $self instvar reg_module_ $mod register $self set reg_module_($mod module-name) $mod ,module_list_是Node的變量!只有Base一個(gè)值,RtModule/Base instproc register node $self next $node $self instvar classifier_ set classifier_ new Classifier/Hash/Dest 32 $classifier_ set mask_ AddrPa
34、rams NodeMask 1 $classifier_ set shift_ AddrParams NodeShift 1 # XXX Base should ALWAYS be the first module to be installed. $node install-entry $self $classifier_ ,每一個(gè)RtModule/xxx在register函數(shù)中都會(huì)new一個(gè)classifier,Node instproc install-entry module clsfr hook $self instvar classifier_ mod_assoc_ hook_as
35、soc_ if info exists classifier_ if info exists mod_assoc_($classifier_) $self unregister-module $mod_assoc_($classifier_) unset mod_assoc_($classifier_) # Connect the new classifier to the existing classifier chain, # if there is any. if info exists hook_assoc_($classifier_) if $hook = target $clsfr
36、 target $hook_assoc($classifier_) elseif $hook != $clsfr install $hook $hook_assoc_($classifier_) set hook_assoc_($clsfr) $hook_assoc_($classifier_) unset hook_assoc_($classifier_) set mod_assoc_($clsfr) $module set classifier_ $clsfr ,保存最后一次調(diào)用時(shí)的clsfr,module列表,以classifier為索引,classifier列表,以classifier
37、為索引,Classifier instproc install slot val $self set slots_($slot) $val $self cmd install $slot $val ,RtModule_3,clfr_3,hook_assoc_(clfr_2),hook_assoc_(clfr_3),mod_assoc_(clfr_3),mod_assoc_(clfr_2),RtModule_2,clfr_2,RtModule_1,clfr_1,hook_assoc_(clfr_1)?,mod_assoc_(clfr_1),Node instproc insert-entry m
38、odule clsfr hook $self instvar classifier_ mod_assoc_ hook_assoc_ if $hook != # Build a classifier chain when specified set hook_assoc_($clsfr) $classifier_ if $hook = target $clsfr target $classifier_ elseif $hook != $clsfr install $hook $classifier_ # Associate this module to the classifier, so if
39、 the classifier is # removed later, well remove the module as well. set mod_assoc_($clsfr) $module set classifier_ $clsfr ,RtModule_3,clfr_3,hook_assoc_(clfr_2),hook_assoc_(clfr_3),mod_assoc_(clfr_3),mod_assoc_(clfr_2),RtModule_2,clfr_2,RtModule_1,clfr_1,hook_assoc_(clfr_1)?,mod_assoc_(clfr_1),RtMod
40、ule instproc register node # Attach to node and register routing notifications $self attach-node $node $node route-notify $self $node port-notify $self ,進(jìn)入到rtmodule的c+代碼中,把該節(jié)點(diǎn)的指針交給rtmodule的一個(gè)變量,Node instproc route-notify module $self instvar rtnotif_ if $rtnotif_ = set rtnotif_ $module else $rtnotif
41、_ route-notify $module $module cmd route-notify $self ,RtModule instproc route-notify module $self instvar next_rtm_ if $next_rtm_ = set next_rtm_ $module else $next_rtm_ route-notify $module ,把rtmoudule構(gòu)成鏈表,Node instproc port-notify module $self instvar ptnotif_ lappend ptnotif_ $module ,Node,RtMod
42、ule/Base,Classifier/Hash/Dest,mod_assoc_(_o13)=_o12,classifier_,entry_,紅色是Node的變量,表示對(duì)象之間的聯(lián)系紐帶,數(shù)據(jù)包的傳輸,dbg1.23 set n1 $ns node _o11 dbg1.24 _o11 info class Node dbg1.25 _o12 info class RtModule/Base dbg1.26 _o13 info class Classifier/Hash/Dest dbg1.28 set n2 $ns node _o14 dbg1.29 _o14 info class Node
43、dbg1.30 _o15 info class RtModule/Base dbg1.31 _o16 info class Classifier/Hash/Dest dbg1.32 _o17 info class invalid command name _o17 while executing _o17 info class dbg1.33,路由模塊,如果要加入策略路由的話,或者自己開發(fā)路由協(xié)議,需要自己開發(fā)這個(gè)模塊。其實(shí)該模塊的功能是計(jì)算路由,而執(zhí)行路由是由Classifier進(jìn)行的,路由的執(zhí)行,插敘:最簡(jiǎn)單情形下的網(wǎng)絡(luò)實(shí)體,啟動(dòng)過程3,$ns duplex-link $n0 $n1 1M
44、b 10ms DropTail,#tcl/lib/ns-lib.tcl Simulator instproc duplex-link n1 n2 bw delay type args $self instvar link_ set i1 $n1 id set i2 $n2 id if info exists link_($i1:$i2) $self remove-nam-linkconfig $i1 $i2 eval $self simplex-link $n1 $n2 $bw $delay $type $args eval $self simplex-link $n2 $n1 $bw $de
45、lay $type $args # Modified by GFR for nix-vector routing if Simulator set nix-routing # Inform nodes of neighbors $n1 set-neighbor $n2 id $n2 set-neighbor $n1 id ,插敘:?jiǎn)尾ス?jié) 點(diǎn)的構(gòu)造,#tcl/lib/ns-lib.tcl Simulator instproc simplex-link n1 n2 bw delay qtype args if info exists queueMap_($qtype) set qtype $que
46、ueMap_($qtype) set q new Queue/$qtype set link_($sid:$did) new SimpleLink $n1 $n2 $bw $delay $q . ,這個(gè)語句創(chuàng)建Queue/TropTail的一個(gè)對(duì)象,#tcl/lib/ns-link.tcl SimpleLink instproc init src dst bw delay q lltype DelayLink $self next $src $dst $self instvar link_ queue_ head_ toNode_ ttl_ $self instvar drophead_ se
47、t ns Simulator instance set drophead_ new Connector $drophead_ target $ns set nullAgent_ set head_ new Connector $head_ set link_ $self #set head_ $queue_ - replace by the following # xxx this is hacky if $q info class info heritage ErrModule = ErrorModule $head_ target $q classifier else $head_ tar
48、get $q ,Link instproc init src dst $self next $self instvar id_ set id_ Link set nl_ Link set nl_ expr $id_ + 1 $self instvar trace_ fromNode_ toNode_ color_ oldColor_ set fromNode_ $src set toNode_ $dst set color_ black set oldColor_ black set trace_ ,set queue_ $q set link_ new $lltype $link_ set
49、bandwidth_ $bw $link_ set delay_ $delay $queue_ target $link_ $link_ target $dst entry $queue_ drop-target $drophead_ # XXX # put the ttl checker after the delay # so we dont have to worry about accounting # for ttl-drops within the trace and/or monitor # fabric # set ttl_ new TTLChecker $ttl_ targe
50、t $link_ target $self ttl-drop-trace $link_ target $ttl_,對(duì)target_、drop-target_、uptarget_和downtarget_之類的變量要高度注意!因?yàn)閷?duì)它們的賦值決定了數(shù)據(jù)包的走向。,# Finally, if running a multicast simulation, # put the iif for the neighbor node. if $ns multicast? $self enable-mcast $src $dst $ns instvar srcRt_ if info exists srcRt_
51、 if $srcRt_ = 1 $self enable-src-rt $src $dst $head_ ,Queue/DropTail,SimpleLink,DelayLink,TTLCheck,Connector,Connector,target_,target_,target_,target_,Agent/Null,droptarget_,target_,entry_,target_,表示數(shù)據(jù)包的傳輸,entry_,fromnode_,tonode_,head_,dbg1.33 $ns duplex-link $n1 $n2 1Mb 10ms DropTail dbg1.34 _o17
52、info class Queue/DropTail dbg1.35 _o18 info class SimpleLink dbg1.36 _o19 info class Connector dbg1.37 _o20 info class Connector dbg1.38 _o21 info class DelayLink dbg1.39 _o22 info class TTLChecker dbg1.40 _o23 info class Queue/DropTail,dbg1.41 _o24 info class SimpleLink dbg1.42 _o25 info class Conn
53、ector dbg1.43 _o26 info class Connector dbg1.44 _o27 info class DelayLink dbg1.45 _o27 info class DelayLink dbg1.46 _o28 info class TTLChecker dbg1.47 _o29 info class invalid command name _o29 while executing _o29 info class dbg1.48,啟動(dòng)過程4,set tcp new Agent/TCP set snk new Agent/TCPSink 在tcl/lib/ns-a
54、gent.tcl中,Agent/TCP instproc init eval $self next set ns Simulator instance $ns create-eventtrace Event $self ,Class Agent/Null -superclass Agent Agent/Null instproc init args eval $self next $args ,dbg1.55 set tcp new Agent/TCP _o29 dbg1.56 _o29 info class Agent/TCP dbg1.57 _o30 info class invalid
55、command name _o30 while executing _o30 info class dbg1.58 set nul new Agent/TCPSink _o30 dbg1.59 _o30 info class Agent/TCPSink dbg1.60 _o31 info class invalid command name _o31 while executing _o31 info class dbg1.61,啟動(dòng)過程5,set ftp new Application/FTP 沒有相關(guān)代碼,說明都使用默認(rèn)情況:簡(jiǎn)單new一個(gè)對(duì)象而已,dbg1.61 set ftp new
56、Application/FTP _o31 dbg1.62 _o31 info class Application/FTP dbg1.63 _o32 info class invalid command name _o32 while executing _o32 info class dbg1.64,啟動(dòng)過程6 ,$ns attach-agent $n0 $tcp $ns attach-agent $n1 $snk 這一步非常重要,也非常復(fù)雜。因?yàn)檫@一步完成了 路由模塊的加載 Agent和node的連接,#tcl/lib/ns-lib.tcl Simulator instproc attach
57、-agent node agent $node attach $agent ,% _o33 info class Classifier/Port % _o32 info class Classifier/Port % _o34 info class invalid command name _o34,這兩步創(chuàng)建了兩個(gè)對(duì)象,#tcl/lib/ns-node.tcl Node instproc attach agent port $self instvar agents_ address_ dmux_ lappend agents_ $agent $agent set node_ $self $a
58、gent set agent_addr_ AddrParams addr2id $address_ if $dmux_ = “” #會(huì)進(jìn)入這里,因?yàn)檫€沒有給dmux賦過值 # Use the default mask_ and port_ values set dmux_ new Classifier/Port # point the nodes routing entry to itself # at the port demuxer (if there is one) $self add-route $address_ $dmux_#把到自己的路由加入進(jìn)去 if $port = “” #會(huì)進(jìn)入,因?yàn)橐话悴恢付ǘ丝?set port $dmux_ alloc-port Simulator instance nullagent $agent set agent_port_ $port $self add-target $agent $port ,把該agent加到node的agent列表,插敘:Ns的IP地址,/classifier/classifier.cc if (strcmp(argv1,alloc-port) = 0) int slot; NsObject* nullagent = (NsObject*)TclObject:lookup(argv2); slot =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 蜜蜂養(yǎng)殖場(chǎng)生產(chǎn)制度
- 消毒生產(chǎn)設(shè)備采購制度
- 生產(chǎn)指揮車輛管理制度
- 車站安全生產(chǎn)告誡制度
- 農(nóng)業(yè)生產(chǎn)廢棄物制度
- 林業(yè)生產(chǎn)用工管理制度
- 2026浙江南方水泥有限公司校園招聘參考考試試題附答案解析
- 直接生產(chǎn)費(fèi)用報(bào)銷制度
- 廚房生產(chǎn)內(nèi)控制度
- 車間設(shè)備生產(chǎn)安全制度
- 2026年九江職業(yè)大學(xué)單招職業(yè)適應(yīng)性考試題庫帶答案解析
- 天車設(shè)備使用協(xié)議書
- 發(fā)泡混凝土地面防滑施工方案
- 產(chǎn)教融合項(xiàng)目匯報(bào)
- 2025-2026學(xué)年湖北省襄陽市襄城區(qū)襄陽市第四中學(xué)高一上學(xué)期9月月考英語試題
- 蘇少版(五線譜)(2024)八年級(jí)上冊(cè)音樂全冊(cè)教案
- 江蘇省城鎮(zhèn)供水管道清洗工程估價(jià)表及工程量計(jì)算標(biāo)準(zhǔn) 2025
- 2025年國家能源局公務(wù)員面試備考指南及模擬題集
- 醫(yī)院感控人員理論知識(shí)考核試題及答案
- 2025遼寧鐵道職業(yè)技術(shù)學(xué)院?jiǎn)握锌荚囄幕刭|(zhì)數(shù)學(xué)練習(xí)題及參考答案詳解(完整版)
- 珍愛健康-遠(yuǎn)離油脂課件
評(píng)論
0/150
提交評(píng)論