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)
上一篇 2021年12月5日 下午3:00
下一篇 2021年12月5日 下午3:00


相关推荐

  • 世纪之战:Python和Java,到底学哪个更好?

    世纪之战:Python和Java,到底学哪个更好?零基础自学java,点击了解:https://how2j.cn本文章转载自(如有侵权联系我删除):微信公众号Java技术栈有人曾经将编程比作做菜,那编程语言就是首先要准备的食材或厨具。尽管在刚开始开发AI时,有很多编程语言都可以满足你的需求,但没有一种编程语言是可以一站式解决AI编程的问题,因为在每一个项目中,不同的目标需要特定的方法。和做菜时的精挑细选一样,在成为一个「高手」…

    2022年7月7日
    21
  • AT24C02 E2PROM芯片详解

    AT24C02 E2PROM芯片详解24C02 是一个 2KBit 的串行 EEPROM 存储器 掉电不丢失 内部含有 256 个字节 在 24C02 里面有一个 8 字节的页写缓冲器 A0 A1 A2 硬件地址引脚 WP 写保护引脚 接高电平只读 接地允许读和写 SCL 和 SDA IIC 总线可以看出对于不同大小的 24Cxx 具有不同的从器件地址 由于 24C02 为 2k 容量 也就是说只需要参考图中第一行的内容 芯片的寻址 AT24C 设备地址

    2026年3月18日
    2
  • mac pycharm2021.11.3激活_在线激活

    (mac pycharm2021.11.3激活)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~3MRUAPM31O-eyJsaWNlbnNlSWQiOi…

    2022年3月29日
    106
  • 探秘AutoGen智能体混合体:从神经网络架构到多智能体协作的实战指南

    探秘AutoGen智能体混合体:从神经网络架构到多智能体协作的实战指南

    2026年3月16日
    2
  • spring事务传播机制实战应用

    spring事务传播机制实战应用最近手头上的编码任务不是很多 可以花点时间深入下 spring 事务管理的学习 在实际应用中也遇到了一些疑惑 这是发在问答区的问题 http www iteye com problems 在这里把实际应用中遇到的事务管理及配置方案进行总结 加深理解 1 先说下我的项目中用到的事务传播机制 SUPPORTSREQU SUPPORTED 用的最多的是

    2026年3月17日
    3
  • php gmssl,GmSSL是什么

    php gmssl,GmSSL是什么GmSSL 是一个开源的密码工具箱 支持 SM2 SM3 SM4 SM9 ZUC 等国密 国家商用密码 算法 SM2 国密数字证书及基于 SM2 证书的 SSL TLS 安全通信协议 支持国密硬件密码设备 提供符合国密规范的编程接口与命令行工具 GmSSL 是一个开源的密码工具箱 支持 SM2 SM3 SM4 SM9 ZUC 等国密 国家商用密码 算法 SM2 国密数字证书及基于 SM2 证书的 SSL TLS

    2026年3月19日
    4

发表回复

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

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