欢迎来到天天文库
浏览记录
ID:38199933
大小:17.72 KB
页数:3页
时间:2019-05-25
《路由协议-dsr》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#wrls1.tcl#A3-nodeexampleforad-hocsimulationwithDSDV#Defineoptionssetval(chan)Channel/WirelessChannel;#channeltypesetval(prop)Propagation/TwoRayGround;#radio-propagationmodelsetval(netif)Phy/WirelessPhy;#networkinterfacetypesetval(mac)Mac/802_11;#MACtypesetval(ifq)CMUPriQu
2、eue;#interfacequeuetypesetval(ll)LL;#linklayertypesetval(ant)Antenna/OmniAntenna;#antennamodelsetval(ifqlen)50;#maxpacketinifqsetval(nn)3;#numberofmobilenodessetval(rp)DSR;#routingprotocolsetval(x)500;#Xdimensionoftopographysetval(y)400;#Ydimensionoftopographysetval(stop)1
3、50;#timeofsimulationendsetns[newSimulator]settracefd[opensimple.trw]setwindowVsTime2[openwin.trw]setnamtrace[opensimwrls.namw]$nstrace-all$tracefd$nsnamtrace-all-wireless$namtrace$val(x)$val(y)#setuptopographyobjectsettopo[newTopography]$topoload_flatgrid$val(x)$val(y)crea
4、te-god$val(nn)##Creatennmobilenodes[$val(nn)]andattachthemtothechannel.##configurethenodes$nsnode-config-adhocRouting$val(rp)-llType$val(ll)-macType$val(mac)-ifqType$val(ifq)-ifqLen$val(ifqlen)-antType$val(ant)-propType$val(prop)-phyType$val(netif)-channelType$val(
5、chan)-topoInstance$topo-agentTraceON-routerTraceON-macTraceOFF-movementTraceONfor{seti0}{$i<$val(nn)}{incri}{setnode_($i)[$nsnode]}#Provideinitiallocationofmobilenodes$node_(0)setX_5.0$node_(0)setY_5.0$node_(0)setZ_0.0$node_(1)setX_490.0$node_(1)setY_285.0$node_(1)set
6、Z_0.0$node_(2)setX_150.0$node_(2)setY_240.0$node_(2)setZ_0.0#Generationofmovements$nsat10.0"$node_(0)setdest250.0250.03.0"$nsat15.0"$node_(1)setdest45.0285.05.0"$nsat110.0"$node_(0)setdest480.0300.05.0"#SetaTCPconnectionbetweennode_(0)andnode_(1)settcp[newAgent/TCP/Newreno
7、]$tcpsetclass_2setsink[newAgent/TCPSink]$nsattach-agent$node_(0)$tcp$nsattach-agent$node_(1)$sink$nsconnect$tcp$sinksetftp[newApplication/FTP]$ftpattach-agent$tcp$nsat10.0"$ftpstart"#PrintingthewindowsizeprocplotWindow{tcpSourcefile}{globalnssettime0.01setnow[$nsnow]setcwn
8、d[$tcpSourcesetcwnd_]puts$file"$now$cwnd"$nsat[expr$now+$time]"plotWindow$tcpSource$file"
此文档下载收益归作者所有