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


相关推荐

  • mongobd Databus

    mongobd Databushttp://www.cnblogs.com/huangxincheng/archive/2012/02/19/2357846.html–8天学习http://www.xuebuyuan.com/554017.htmlhttp://www.habadog.com/2011/08/03/mongodb-shell-1-overview/ –mongodb与jshttp

    2022年10月16日
  • QueueUserWorkItem 初步学习

    QueueUserWorkItem 初步学习 DWORDWINAPITestThreadPool(PVOIDpContext);CRITICAL_SECTIONg_cs;int_tmain(intargc,_TCHAR*argv[]){ InitializeCriticalSection(&g_cs); SECURITY_ATTRIBUTESsa; sa.bInheritHandle=TRUE; sa.nLen

    2022年9月2日
  • matlab for循环语句实例_matlab如何循环

    matlab for循环语句实例_matlab如何循环MATLABfor循环MATLAB中for循环是一个重复的控制结构,可以有效地写一个循环,只是执行的次数是特定的。MATLABfor循环语法:MATLAB中的for循环的语法如下:forindex=values…endfor循环的值有下述三种形式之一:格式 描述 initval:endval 将索引变量从初始到终值递增1,并重复执行程序语句,直到索引值大于终值。 initval:step:endval

    2022年10月7日
  • ESP8266模块使用完整教程「建议收藏」

    在我入门ESP8266小黄板的过程中,过程是艰难的,因为网络上的资料太多太乱,官网上的资料不算太完备,而在技术交流群里面的就更乱了,所以想按自己学习所总结到的经验来分享给大家。资源链接:http://pan.baidu.com/s/1i4qjrY9请使用本教程之前先下载以上资源。前言:esp8266我用到的是小黄板测试板,而ESP8266主要有两种固件,一种是AT固件,一种是IOT固件。前者用串

    2022年4月18日
  • CocoaPods的install和update卡在“Anylyzing dependencies”的问题解决方式[效率]

    CocoaPods的install和update卡在“Anylyzing dependencies”的问题解决方式[效率]

    2021年12月9日
  • Server SAN_Windows存储卷设备

    Server SAN_Windows存储卷设备目前,实现云环境中数据的高效存储是云计算提供服务的基本要求。云计算和云存储已经成为提供信息和在线功能的首选方法。云计算和云存储已经成为解决普通IT问题和挑战的热门话题。以数据中心网络为基础的分布式存储是构建云计算的物理实体。通常熟知的存储设备是和计算机主板I/O接口(如IDE、SCSI)相连接的硬盘,由本机操作系统负责读写及管理,这是传统的数据存储技术,称为DAS(直接附加存储)。如果添加网络,可以实现文件共享,这是基于局域网(IP)的文件共享设备,能消除对多个文件服务器的需求。存储作为云计算提供I

    2022年10月28日

发表回复

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

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