资源描述:
《DSR协议分析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、分类: 网络模拟器(NS2) MANET路由协议2013-07-0411:35 141人阅读 评论(0) 收藏 举报NS2网络通信Sourcecode : Notallfliesin./dsr/directoryareusedbythens-2.theroutingagentisimplementedasAgent/DSRAgent. Thus,thesourcecodesinclude:·dsragent.cc(h): DSRagentclass.majorstatemachinehandlingroutings.Importantv
2、ariables; net_id,mac_id inIDtype.(IPandMACaddress),bothofthemareinitialziedbytclcommandstosettheinitlavalie,thecommadsare"addr"amd"mac_addr"·hdr_sr.cc(h):definehdr_srclass.·request_table.cc(h)·Path.h(cc): Pathclass.First,definestruct ID,ithasanunsignedlongaddraenumofID_typ
3、e,andatimestampt.andtheninPathclass, ID[] isthekeymembersofthepath,andoperator[]isdefinedtoreturnanelementofIDarray.thuswhenevertheSRPacket.route[n]willreturntothereferenceofID[n].Othermembervariablesinclude cur_index, len,·srpacket.h: JustdefineSRPacketclasswhichencloset
4、hehdr_srasafullpacket.TheSRPacketconstructhastwoparameters,anormalpacketandaSR(SourceRoute)Header(apathvariable).Theconstructorof"path"classmakesapathfromthebitsofanNSsourcerouteheader.AndtheothertwovariablesoftheSRpacketare"dst"and"src"IPaddresses.DataStructureforRouteIti
5、sfoundthatsrh->addrandp.routearetwodifferentstructures.srh()isalwaysalongwiththepacket.however,whenDSRagentreceivedapacket,itwill SRPacketp(packet,srh); Thisgeneratea"p"whichisfrequentlyusedbyallotherfunctions.rememberpdoesnotgoalongwiththepacketleavingdsragent.Beforeth
6、epacketwassentoutoftheagent,anotherstatementwillbeusedtoupdate"SRH"in sendOutPacketwithRoute p.route.fillSR(srh);Also,thetap()entryisalsogenerateapforitsuse.however,anotherentrypointofagent"xmitFailed"usesrh()directly.Specialtclinterface.Unlessotherroutingprotocol,thens-2
7、.1b9a,hasaspecialnodetypenamedas"SRNodeNew".Fromthoseroutinesinthens-lib.tcl.Wecanseethatspeical.Also,thereisatclfileinmobiloty/dsr.tclisalsorelated.Simulatorinstproccreate-node-instanceargs{$selfinstvarroutingAgent_#DSRisaspecialcaseif{$routingAgent_=="DSR"}{setnodeclass[
8、$selfset-dsr-nodetype]}else{setnodeclassNode/MobileNode}return[evalnew$nodeclass$args]}Si