欢迎来到天天文库
浏览记录
ID:52523000
大小:44.00 KB
页数:6页
时间:2020-03-28
《NS2仿真实例汇总.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、NS-2仿真模拟实例汇总(以方路平的书为主)1.例4.5a:DropTail队列管理的NS_2模拟实例(P161)setns[newSimulator]setnf[openout.namw]$nsnamtrace-all$nfsettf[openout.trw]setwindowVsTime[openwinw]setparam[openparametersw]$nstrace-all$tfprocfinish{}{globalnsnftf$nsflush-traceclose$nfclose$tfexecnamout.nam&exit
2、0}setn2[$nsnode]setn3[$nsnode]$nsduplex-link$n2$n30.7Mb20msDropTailsetNumbSrc3setDuration50for{setj1}{$j<=$NumbSrc}{incrj}{setS($j)[$nsnode]}setrng[newRNG]$rngseed2setRVstart[newRandomVariable/Uniform]$RVstartsetmin_0$RVstartsetmax_7$RVstartuse-rng$rngfor{seti1}{$i<=$Nu
3、mbSrc}{incri}{setstartT($i)[expr[$RVstartvalue]]setdly($i)1puts$param"startT($i)$startT($i)sec"}for{setj1}{$j<=$NumbSrc}{incrj}{$nsduplex-link$S($j)$n210Mb$dly($j)msDropTail$nsqueue-limit$S($j)$n220}$nsqueue-limit$n2$n3100for{setj1}{$j<=$NumbSrc}{incrj}{settcp_src($j)[n
4、ewAgent/TCP/Reno]$tcp_src($j)setwindow_8000}for{setj1}{$j<=$NumbSrc}{incrj}{settcp_snk($j)[newAgent/TCPSink]}for{setj1}{$j<=$NumbSrc}{incrj}{$nsattach-agent$S($j)$tcp_src($j)$nsattach-agent$n3$tcp_snk($j)$nsconnect$tcp_src($j)$tcp_snk($j)}for{setj1}{$j<=$NumbSrc}{incrj}
5、{setftp($j)[$tcp_src($j)attach-sourceFTP]}for{setj1}{$j<=$NumbSrc}{incrj}{$tcp_src($j)setpacketSize_552}for{seti1}{$i<=$NumbSrc}{incri}{$nsat$startT($i)"$ftp($i)start"$nsat$Duration"$ftp($i)stop"}procplotWindow{tcpSourcefilek}{globalnsNumbSrcsettime0.03setnow[$nsnow]set
6、cwnd[$tcpSourcesetcwnd_]if{$k==1}{puts-nonewline$file"$nowt$cwndt"}else{if{$k<$NumbSrc}{puts-nonewline$file"$cwndt"}}if{$k==$NumbSrc}{puts-nonewline$file"$cwnd"}$nsat[expr$now+$time]"plotWindow$tcpSource$file$k"}for{setj1}{$j<=$NumbSrc}{incrj}{$nsat0.1"plotWindow$t
7、cp_src($j)$windowVsTime$j"}$nsmonitor-queue$n2$n3[openqueue.trw]0.05[$nslink$n2$n3]queue-sample-timeout$nsat[expr$Duration]"finish"$nsrun1.例4.5b:RED队列管理的NS-2模拟实例(P164)setns[newSimulator]setnf[openout.namw]$nsnamtrace-all$nfsettf[openout.trw]setwindowVsTime[openwinw]setp
8、aram[openparametersw]$nstrace-all$tfprocfinish{}{globalnsnftf$nsflush-traceclose$nfclose$tfexecnamout.nam&exit
此文档下载收益归作者所有