ns2笔记(5)

2020-04-17 04:14

??? # 0 | 0 | 0 ??? # 1 | 0 | 0 ??? # 2 | 0 | 0 ??? # ??? ???

??? set god [God instance] ;# ? ??? ???

??? #使用setdest内部过程引发移动节点运动

??? #在模拟时间200s时,节点1开始从位置(500,500)移动到(500,900),速度为2.0m/s ??? #在模拟时间500s时,节点1开始从位置(500,900)移动到(500,100),速度为2.0m/s ??? $ns at 200.0 \ ??? $ns at 500.0 \ ??? ???

??? #在节点0和节点2之间建立一条CBR/UDP的连接,且在时间为100s的时候开始传送 ??? set udp(0) [new Agent/UDP] ??? $udp(0) set fid_ 1

??? $ns attach-agent $node(0) $udp(0) ??? set null(0) [new Agent/Null] ??? $ns attach-agent $node(2) $null(0) ???

??? set cbr(0) [new Application/Traffic/CBR] ??? $cbr(0) set packetSize_ 200 ??? $cbr(0) set interval_ 2.0 ??? $cbr(0) set random_ 1 ??? $cbr(0) set maxpkts_ 10000 ??? $cbr(0) attach-agent $udp(0) ??? $ns connect $udp(0) $null(0) ??? $ns at 100.0 \ ??? ???

??? #在Nam中定义节点初始所在位置

??? for {set i 0} {$i<$var(nn)} {incr i} {

??? $ns initial_node_pos $node($i) 60 ;#只有定义了移动模型后,这个函数才能被调用 ??? } ??? ???

??? #定义节点模拟的结束时间

??? for {set i 0} {$i<$var(nn)} {incr i} {

??? $ns at $var(stop) \ ;#重新设置移动节点属性 ??? }

??? $ns at $var(stop) \

??? $ns at $var(stop) \NS2 exiting.../\ ??? proc stop {} {

??? global ns tracefd namfd ??? $ns flush-trace ??? close $tracefd ??? close $namfd ??? } ???

??? puts $tracefd \ ??? puts $tracefd \ ??? puts $tracefd \ ??? puts \ ??? ??? $ns run


ns2笔记(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:昆明钢铁股份有限公司调查

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: