NS2 nam中节点及数据流颜色设置

NS2 nam中节点及数据流颜色设置

大家好,又见面了,我是全栈君,祝每个程序员都可以多学几门语言。

NS2 节点颜色设置在http://hi.baidu.com/jrwen0/item/d105c642f4c3ce36fb89601b说明的比較具体,大家能够參见。

        我这里想说的是数据流颜色的设置,相信大家试过非常多次,没有效果。有线的我參看这这里http://www.cs.virginia.edu/~cs757/slidespdf/cs757-ns2-tutorial-exercise.pdf,执行了里面的example2.tcl,程序例如以下

#Create a simulator object

set ns [new Simulator]
#Define different colors for data flows
<span style="color:#ff0000;">$ns color 1 Blue
$ns color 2 Red</span>
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam –a out.nam &
exit 0
}
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Create links between the nodes
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 1Mb 10ms SFQ
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
#Monitor the queue for the link between node 2 and node 3
$ns duplex-link-op $n2 $n3 queuePos 0.5
#Create a UDP agent and attach it to node n0
<span style="color:#ff0000;">set udp0 [new Agent/UDP]
$udp0 set class_ 1</span>
$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create a UDP agent and attach it to node n1
<span style="background-color: rgb(255, 255, 255);"><span style="color:#ff0000;">set udp1 [new Agent/UDP]</span></span>
<span style="color:#ff0000;">$udp1 set class_ 2</span>
$ns attach-agent $n1 $udp1
# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
#Create a Null agent (a traffic sink) and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0 
$ns connect $udp1 $null0
#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 4.0 "$cbr1 stop"
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run

红色会数据流颜色设置,相信看了第一个链接,大家也看到移动节点设置须要在802.15.4的情况下才有颜色,可是我们移动环境下都用802.11,临时链接中给出的方法临时还无法解决这个问题。希望大家踊跃讨论问题的解决方法。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/118485.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 外地人在北京的真实状态(漫画)

    这就是外地人在北京的真实状态! 北京这个城市看似中国的首都,实则在这里很不容易,但是感谢阿Q的存在,能把这种苦逼包装成一种高大上的状态。早上每天5:30起床睡眠不足,我们包装成早期…

    2021年6月21日
    185
  • hexo latex 换行 多行公式 终极解决方案

    hexo latex 换行 多行公式 终极解决方案hexo的LaTeX可算把我给折腾死了。。。问题:多行公式无法显示(hexo-renderer-marked,mathjax)看到网上说是因为渲染引擎把\\渲染成\,然后才交给mathjax渲染公式都说把hexo-renderer-marked换成hexo-renderer-kramed,然后再node_modules/kramed/lib/rules/inline.js里修改escape项,照做了,确实解决了问题,但是却出现了新的问题:复杂公式显示错乱,遂放弃。又看到在node_modules/m

    2022年5月14日
    45
  • Windows API——SHFileOperation——文件操作

    Windows API——SHFileOperation——文件操作1intSHFileOperation(LPSHFILEOPSTRUCTlpFileOp);如果执行成功返回0.1typedefstruct_SHFILEOPSTRUCT{2HWNDhwnd;//指向发送消息的窗口3UINTwFunc;//执行的操作4LPCTSTRpFrom;//源文件名5LPCTSTRpTo;//目标文件

    2022年7月18日
    13
  • linux dlopen 内存版本,dlopen函数详解

    linux dlopen 内存版本,dlopen函数详解Linux提供了一套API来动态装载库。下面列出了这些API:-dlopen,打开一个库,并为使用该库做些准备。-dlsym,在打开的库中查找符号的值。-dlclose,关闭库。-dlerror,返回一个描述最后一次调用dlopen、dlsym,或dlclose的错误信息的字符串。C语言用户需要包含头文件dlfcn.h才能使用上述API。glibc还增加了两个POSIX标准中没有的API:…

    2025年7月14日
    0
  • Delphi2007 下安装ActiveX控件[通俗易懂]

    Delphi2007 下安装ActiveX控件[通俗易懂]此英文文章来自codegear官方网站,但是是讲在BDS2006 下如何安装,我在delphi2007下用此方法,一样通过,原文如下 Description:HowtoimportanActiveXcontrolinBDS2006?Answer/Solution:Herestheprocedureforimportingandinstalling

    2022年5月14日
    36
  • 量子搜索算法例题详解_量子算法与编程入门

    量子搜索算法例题详解_量子算法与编程入门量子搜索算法Groversearch问题定义:Problem:f:{0,1,2,3,……,N−1}→{0,1}f:{0,1,2,3,……,N−1}→{0,1}找到f(x)=1的x解法经典解法:经典解法很简单,就是把每一个都看一遍,如果只有一个x对应的f(x)=1,那么平均是要看一半,才能找到那个x。时间复杂度O(N)量子解法:使用Groversea…

    2025年5月22日
    1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号