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


相关推荐

  • CMake Error: The current CMakeCache.txt directory is different…[通俗易懂]

    CMake Error: The current CMakeCache.txt directory is different…[通俗易懂]零、问题描述开始学ROS时,需要编译别人的功能包,常常把别人的工作空间拿过来使用,但编译时会出现各种错误,如下的目录问题:CMakeError:ThecurrentCMakeCache.txtdirectory/home/vistar/desktop/catkin_ws/build/CMakeCache.txtisdifferentthanthedirectory/ho……………

    2025年7月25日
    1
  • systick的使用方法_cleardevice函数

    systick的使用方法_cleardevice函数systick的原理前一篇博文有介绍,简而言之就是SysTick定时器是一个24位的倒计数,当倒计数为0时,将从RELOAD寄存器中取值作为定时器的初始值,同时可以选择在这个时候产生中断(异常号:15

    2022年8月6日
    5
  • SpringBatch文档

    SpringBatch文档第一章SpringBatch入门第一节SpringBatch概述SpringBatch是一个轻量级的、完善的批处理框架,旨在帮助企业建立健壮、高效的批处理应用。SpringBatch是Spring的一个子项目,使用Java语言并基于Spring框架为基础开发,使得已经使用Spring框架的开发者或者企业更容易访问和利用企业服务。SpringBatch提供了大量可重用的组件…

    2022年5月28日
    41
  • win8.1 android驱动安装失败,Win8.1版系统显卡驱动安装失败的解决方法[通俗易懂]

    win8.1 android驱动安装失败,Win8.1版系统显卡驱动安装失败的解决方法[通俗易懂]图形卡驱动程序是用于驱动图形卡的程序,它是与硬件相对应的软件。驱动程序是由硬件制造商根据操作系统编写的配置文件。可以说,没有驱动程序,计算机中的硬件将无法工作。不同的操作系统具有不同的硬件驱动程序。为了确保硬件的兼容性并增强硬件的功能,各种硬件制造商将不断升级驱动程序。以下是解决Win8.1显卡驱动程序安装对每个人都不好的方法的集合,希望对您有所帮助。解决Win8.1显卡驱动程序安装错误的…

    2022年6月10日
    40
  • MATLAB函数fir1「建议收藏」

    MATLAB函数fir1「建议收藏」fir1基于窗函数的fir滤波器设计;主要形式:b=fir1(n,Wn)b=fir1(n,Wn,ftype)b=fir1(___,window)b=fir1(___,scaleopt)系数的含义n—滤波器阶数。Wn—截止频率,0≤Wn≤1,Wn=1对应于采样频率的一半。当设计带通和带阻滤波器时,Wn=[W1W2],W1≤…

    2022年7月17日
    35
  • 5G 信道一览表

    5G 信道一览表各个地区2.4G及5G信道一览表美洲(FCC)2.412~2.462GHz:11个信道5.15~5.35GHz,5.725~5.825GHz;12个信道中国2.412~2.472GHz:13个信道5.725~5.825GHz:4个信道ETSI2.412~2.472GHz:13个信道5.15~5.35GHz:8个信道5470…

    2022年6月7日
    267

发表回复

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

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