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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 【转载】使用Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结

    【转载】使用Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结

    2021年11月18日
  • SpringCloud之SpringCloud常见面试题, SOA和微服务关系, SpringCloud和Dubbo区别, Eureka和Zookeeper区别「建议收藏」

    SpringCloud之SpringCloud常见面试题, SOA和微服务关系, SpringCloud和Dubbo区别, Eureka和Zookeeper区别「建议收藏」1.SpringCloud是什么SpringCloud是一系列框架的集合,集成SpringBoot,提供很多优秀服务:服务发现和注册,统一配置中心,负载均衡,网关,熔断器等。2.SpringCloud的优势因为SpringCloud源于Spring,所以它的质量,稳定性,持续性都是可以保证的。SpringCloiud天热支持SpringBoot框架,就可以提高开发效率,能够实现需求。SpringCloud更新很快,后期支持很给力。SpringCloud可以用来开发微服务。3.Sp

    2022年6月4日
  • Ubuntu 14.04 Desktop的Raid1安装总结

    Ubuntu 14.04 Desktop的Raid1安装总结安装基于Ubuntu14.04Desktop的Raid1。由于采用UEFI/GPT方式作为系统启动方式,在安装过程中出现了很多异常情况。本文记录安装的过程。

    2022年7月15日
  • CAP理论中, P(partition tolerance, 分区容错性)的合理解释

    CAP理论中, P(partition tolerance, 分区容错性)的合理解释在CAP理论中,对partitiontolerance分区容错性的解释一般指的是分布式网络中部分网络不可用时,系统依然正常对外提供服务,而传统的系统设计中往往将这个放在最后一位.这篇文章对这个此进行了分析和重新定义,并说明了在不同规模分布式系统中的重要性.The‘CAP’theoremisahottopicinthedesignofdistributeddat…

    2022年7月25日
  • 简单网页的制作_html简单网页制作

    简单网页的制作_html简单网页制作前言:虽然现在有很多网页模板可以套用,但是不写代码就永远不能进步!简单介绍:HTML是一种超文本标记语言,简单来说就是用来做网页的,没有别的脚本语言的加持下只能做静态网页。在有其它脚本语言JavaScript(JS)和PHP语言的加持下就可以做动态网页,甚至可以做耗费精力和时间的响应式网站。刚才说的静态网页、动态网页和响应式网站显然都是后话了,到后边还有伪静态网页,这些到后面再讲。HTML编译器:Dreamweaver和WebStorm写一个简单网页可以先用记事本废话不多

    2022年10月13日
  • mysql面试题目及答案_docker 面试题

    mysql面试题目及答案_docker 面试题1.事务的基本特征原子性(atomicity):一个事务必须视为一个不可分割的最小工作单元,整个事务中的所有操作要么全部提交成功,要么全部失败回滚,对于一个事务来说,不可能只执行其中的一部分操作,这就是事务的原子性。一致性(consistency):数据库总数从一个一致性的状态转换到另一个一致性的状态。隔离性(isolation):一个事务所做的修改在最终提交以前,对其他事务是不可见的…

    2022年8月27日

发表回复

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

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