networking - 为什么在 TCL 的命令中没有显示结果?
问题描述
我正在尝试在 ns2 中创建简单的网络拓扑。
#Create a simulator object
set ns [new Simulator]
#Open the NAM trac file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedrue
proc finish {} {
global ns nf
$ns flush-trace
#Close the NAM trace file
close $nf
#Execute NAM on the trace file
exec nam out.nam &
exit 0
}
#Create four nodes
for {set i 0} {$i < 6} {incr i} {
set n$i [$ns node]
}
#Changing node colors
$n0 color "red"
$n1 color "yellow"
$n3 color "green"
$n4 color "blue"
#Adding node label
$n0 label "S1"
$n1 label "S2"
$n3 label "D1"
$n4 label "D2"
$n4 label-color "yellow"
#Changing label color
$n0 label-color "green"
$n1 label-color "blue"
$n3 label-color "red"
#Changing shapes
$n2 shape hexagon
$n5 shape hexagon
$n3 shape square
$n4 shape square
#Create the links between the nodes
$ns duplex-link $n0 $n2 10Mb 15ms RED
$ns duplex-link $n1 $n2 10Mb 15ms RED
$ns duplex-link $n2 $n5 10Mb 20ms RED
$ns duplex-link $n5 $n3 12Mb 15ms RED
$ns duplex-link $n4 $n5 10Mb 20ms RED
#Give node position (for NAM)
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n5 orient right
$ns duplex-link-op $n5 $n3 orient right-up
$ns duplex-link-op $n4 $n5 orient left-up
#Change color of link's
$ns duplex-link-op $n0 $n2 color "purple"
$ns duplex-link-op $n1 $n2 color "purple"
$ns duplex-link-op $n5 $n3 color "purple"
$ns duplex-link-op $n4 $n5 color "purple"
#Labling link's
$ns duplex-link-op $n0 $n2 label "<10,15>"
$ns duplex-link-op $n1 $n2 label "<10,15>"
$ns duplex-link-op $n2 $n5 label "<10,20>"
$ns duplex-link-op $n5 $n3 label "<12,15>"
$ns duplex-link-op $n4 $n5 label "<12,15>"
#Calling finish procedure
$ns at 10.0 "finish"
$ns run
我得到了所有的输出,但标记 n4 到 n5 的链接不起作用。但是当我将这条线移到改变链接颜色的上块时它会起作用。这是为什么?
当我尝试更改节点 4 的颜色时也发生了同样的情况。这就是为什么我必须在更改节点 4 的标签后立即放置它。
解决方案
推荐阅读
- swift - 如何跨不同的源代码文件组织格式化程序
- node.js - nodejs 在 JIMP 和 MOZJPEG 之间进行选择
- c++ - 试图将类中的函数定义放在另一个文件中,但我的类的私有成员在定义中
- python - Numpy ndarray 视图方法和基本属性
- python - 使用python搜索文件中的多个字符串,节省时间
- eclipse - eclipse ResolutionException:模块 A 和 B 将包 P 导出到模块 C
- reactjs - “对象作为 React 子项无效(找到:带有键 {type, props} 的对象)。”
- javascript - 如何让我的主页消失并显示画布?
- python - 如何使用Python在第二次出现特定单词后提取文本文件的一部分
- python - 将约束添加到 Python MIP 模型有哪些不同的方法?