问题描述
我正在尝试使用 nam 运行以下代码.
I'm trying to run the below code using nam.
set ns [new Simulator]
set nf [open lab1.nam w]
$ns namtrace-all $nf
set f [open lab1.tr w]
proc record {} {
global sink f
set ns [Simulator instance]
set time 0.12
set bw [$sink set bytes_]
set now [$ns now]
puts $f "$now [expr (($bw/$time)*8/1000000)]"
$sink set bytes_ 0
$ns at [expr $now+$time] "record"
}
proc finish {} {
global ns nf f
$ns flush-trace
close $nf
close $f
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 4Mb 10ms DropTail
set udp0 [new Agent/UDP]
$udp0 set packetSize_ 1500
$ns attach-agent $n0 $udp0
set traffic0 [new Application/Traffic/CBR]
$traffic0 set packetsize_ 1500
$traffic0 set interval_ 0.01
$traffic0 attach-agent $udp0
set sink [new Agent/LossMonitor]
$ns attach-agent $n1 $sink
$ns connect $udp0 $sink
$ns at 0.0 "record"
$ns at 2.0 "$traffic0 start"
$ns at 10.0 "$traffic0 stop"
$ns at 12.0 "finish"
$ns run
我正在尝试使用 VirtualBox 和 Windows 7 32 位在虚拟机上运行它.
I'm trying to run it on a Virtual Machine using VirtualBox with windows 7 32bit.
首先在 cmd 上执行命令 ns lab1.tcl
在此之后,我尝试使用命令 nam lab1.nam
打开 nam .当我这样做时,我收到消息
On cmd first i execute the command ns lab1.tcl
After this im trying to open nam , using the command nam lab1.nam
.When i do this, i get the message
Nam 实际上正在运行但没有正常运行,这意味着它总是创建 210 字节的数据包,我的代码不会影响我给出的任何数据包大小.
Nam is actually then running but not properly,meaning it always creates packets of 210 bytes and my code doesn't affect this whatever packetsize i give.
推荐答案
不是错误.当不存在 nam 窗口时,Nam 将随时显示该消息.
Not an error. Nam will show that message any time, when no nam window is present.
我的测试:$ ns235-64-orig user7375077.tcl
... 结果:lab1.nam 288.5kB, lab1.tr 3.3kB.
My test : $ ns235-64-orig user7375077.tcl
... Result : lab1.nam 288.5kB, lab1.tr 3.3kB .
$ nam lab1.nam
: OK ...
使用了 ns-2.35 股票.没有补丁..... 您是否添加了一些可能使 nam 工作不佳的更改?(或者可能是 Cygwin 创建的 nam 已损坏?)
A stock ns-2.35 was used. No patching. .... May be you added some changes which can make nam work poorly ? ( Or may be it is the Cygwin created nam being corrupt ? )
建议:使用正版 Linux 操作系统使您的ns2 工作".轻松安装:1) 安装VirtualBox".2) 将 Linux 操作系统安装到 VirtualBox 中.安全的操作系统选择:Redhat CentOS 6.8 http://ftp.funet.fi/pub/mirrors/centos.org/6.8/isos/x86_64/CentOS-6.8-x86_64-LiveCD.iso
Suggestions : Make your "ns2 work" with a genuine Linux OS. Easy install : 1) Install 'VirtualBox'. 2) Install the Linux OS(´s) into VirtualBox. The safe OS choice : Redhat CentOS 6.8 http://ftp.funet.fi/pub/mirrors/centos.org/6.8/isos/x86_64/CentOS-6.8-x86_64-LiveCD.iso
这篇关于ns2 无法连接到现有的 nam 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!