Linux Mandriva 2008 中的网络模拟器 NS-2 - nam 错误:“无法连接到现有 nam 实例”

Linux Mandriva 2008 中的网络模拟器 NS-2 - nam 错误:“无法连接到现有 nam 实例”

主题从这里开始——https://superuser.com/questions/525110/installing-network-simulator-ns-2-allinone-on-linux-mandriva

有一个特定的模拟器-NS-2

它可用于描述网络拓扑、流量源和目的地的配置、所有连接参数(带宽、延迟、丢包概率以及模拟系统的许多其他参数)。

我把它安装在Linux 曼德瑞瓦 2008它有效。

但我不可能实现可视化 - 这是由于奥格

我正在尝试实现一个简单的示例(我再次重复代码)-

ns-simple.tcl:

#Create a simulator object
set ns [new Simulator]

#Define different colors for data flows (for NAM)
$ns color 1 Blue
$ns color 2 Red

#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 NAM trace file
        close $nf
        #Execute NAM on the trace file
        exec nam 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 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail

#Set Queue Size of link (n2-n3) to 10
$ns queue-limit $n2 $n3 10

#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 $n3 orient right

#Monitor the queue for link (n2-n3). (for NAM)
$ns duplex-link-op $n2 $n3 queuePos 0.5


#Setup a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set fid_ 1

#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP


#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null

但我收到错误消息。

[root@localhost ...]# startx -- :1
xauth:  creating new authority file /root/.serverauth.20336


X Window System Version 1.3.0
Release Date: 19 April 2007
X Protocol Version 11, Revision 0, Release 1.3
Build Operating System: Linux_2.6.12-12mdksmp Mandriva
Current Operating System: Linux localhost 2.6.22.9-desktop-1mdv #1 SMP Thu Sep 27 04:07:04 CEST 2007 i686
Build Date: 01 October 2007
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Module Loader present
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.1.log", Time: Sat Dec 29 18:59:34 2012
(==) Using config file: "/etc/X11/xorg.conf"
Using vt 8
(**) RADEON(0): RADEONPreInit
(II) Module already built-in
(II) Module already built-in
(II) Module already built-in
(**) RADEON(0): RADEONScreenInit d0000000 0
(**) RADEON(0): Map: 0xd0000000, 0x01000000
(**) RADEON(0): RADEONSave
(**) RADEON(0): RADEONSaveMode(0x823a6a0)
(**) RADEON(0): Read: 0x00000006 0x00030047 0x00000000
(**) RADEON(0): Read: rd=6, fd=71, pd=3
(**) RADEON(0): RADEONSaveMode returns 0x823a6a0
(**) RADEON(0): RADEONInitMemoryMap() :
(**) RADEON(0):   mem_size         : 0x04000000
(**) RADEON(0):   MC_FB_LOCATION   : 0xd3ffd000
(**) RADEON(0):   MC_AGP_LOCATION  : 0xffffffc0
(**) RADEON(0): RADEONModeInit()
1024x768       78.75  1024 1040 1136 1312   768  769  772  800 (16,16) +H +V
1024x768       78.75  1024 1040 1136 1312   768  769  772  800 (16,16) +H +V
(**) RADEON(0): Pitch = 8388736 bytes (virtualX = 1024, displayWidth = 1024)
(**) RADEON(0): dc=7875, of=15750, fd=350, pd=2
(**) RADEON(0): RADEONInit returns 0x823b050
(**) RADEON(0): RADEONRestoreMode()
(**) RADEON(0): RADEONRestoreMemMapRegisters() :
(**) RADEON(0):   MC_FB_LOCATION   : 0xd3ffd000
(**) RADEON(0):   MC_AGP_LOCATION  : 0xffffffc0
(**) RADEON(0):   Map Changed ! Applying ...
(**) RADEON(0):   Map applied, resetting engine ...
(**) RADEON(0): Updating display base addresses...
(**) RADEON(0): Memory map updated.
(**) RADEON(0): Programming CRTC1, offset: 0x00000000
(**) RADEON(0): Wrote: 0x0000003c 0x0001015e 0x00000000 (0x0000bf00)
(**) RADEON(0): Wrote: rd=60, fd=350, pd=1
(**) RADEON(0): GRPH_BUFFER_CNTL from 20005c5c to 20055c5c
(**) RADEON(0): RADEONSaveScreen(0)
(**) RADEON(0): Setting up initial surfaces
(**) RADEON(0): Initializing fb layer
(**) RADEON(0): Setting up accel memmap
(**) RADEON(0): Initializing backing store
(**) RADEON(0): Setting up final surfaces
(**) RADEON(0): Initializing Acceleration
(**) RADEON(0): EngineInit (16/16)
(**) RADEON(0): Pitch for acceleration = 128
(**) RADEON(0): EngineRestore (16/16)
(**) RADEON(0): Initializing DPMS
(**) RADEON(0): Initializing Cursor
(**) RADEON(0): Initializing color map
(**) RADEON(0): Initializing DGA
(**) RADEON(0): Initializing Xv
(**) RADEON(0): RADEONScreenInit finished
(EE) AIGLX: Screen 0 is not DRI capable
(**) RADEON(0): RADEONSaveScreen(2)

跑步纳秒:

[root@localhost ...]# export DISPLAY=localhost:1
[root@localhost ...]# ns ns-simple.tcl
CBR packet size = 1000
CBR interval = 0.0080000000000000002
[root@localhost ...]# **nam: couldn't connect to display "localhost:1"**

我尝试重建, 像他们说的那样这里,我的remote-create-animator函数看起来像这样 -

AnimControl instproc remote-create-animator {trace_file args} {
    catch "array set opts $args"
    AnimControl instvar PORT_FILE_
    if [catch {set f [open $PORT_FILE_ RDONLY]}] {
        error "Cannot read server port from $PORT_FILE_"
    }
    set port [read $f]
    close $f

        puts -nonewline "Cannot connect to existing nam instance. "
    puts "Starting a new one..."
    $self local-create-animator $trace_file [join $args]

    #if [catch {set sock [socket localhost $port]}] {
    #   puts -nonewline "Cannot connect to existing nam instance. "
    #   puts "Starting a new one..."
    #   $self local-create-animator $trace_file [join $args]
    #} else {
    #   if {$trace_file == ""} {
    # puts "A nam instance already exists. Use nam <trace file> to view an animation"
    #       close $sock
    #   } else {
    #   global tcl_platform
    #   if {$tcl_platform(platform) == "windows"} {
    #       if [regexp {^(\\\\|[A-Za-z]:[/\\])} $trace_file] {
    #           set tf $trace_file  ;# Absolute pathname
    #       } else {
    #           set tf [pwd]/$trace_file    ;# Relative pathname
    #       }
    #   } else {
    #       if [regexp {^[~/]} $trace_file] {
    #           set tf $trace_file  ;# Absolute pathname
    #       } else {
    #           set tf [pwd]/$trace_file ;# Relative pathname
    #       }
    #   }
    #   puts $sock "CA $tf [join $args]"
    #   flush $sock
    #   close $sock
    #   }
    #}
}

但一切都没有改变。现在的消息是——"Cannot connect to existing nam instance. Starting a new one..."

和所有 ..

如何获取图片?我将非常感谢您提供信息!

谢谢!

答案1

我已经很久没有使用 NS2 了,但如果我没记错的话,你的 X11 隧道可能有问题。您是否使用 SSH 连接到运行 NS2 的 Linux 服务器?尝试输入 xclock 并查看是否可以看到时钟...您需要在使用 SSH 的任何程序上启用隧道。

如果你使用putty,只需在X11下勾选隧道即可

您还应该确保您的 Xserver 正在运行(我个人使用 Xming)。

答案2

我做了以下事情。

安装星铭6.9.0.31

X-转发:

1)DISPLAYbashrcbash_profile中删除变量/etc/profile

2)在文件中/etc/ssh/sshd_config我添加了以下内容:

...
ListenAddress ip_of_remote_server
...

3)取消注释:

...
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
...

4)腻子设置:

SSH-> X11:

Enable X11 forwarding;
X display location: localhost:0;

然后运行以下命令:

[root@localhost ...]# echo $DISPLAY
localhost:11.0
[root@localhost ...]# ns ns-simple.tcl
CBR packet size = 1000
CBR interval = 0.0080000000000000002
[root@localhost ...]# Cannot connect to existing nam instance. Starting a new one...

之后出现——

在此输入图像描述 在此输入图像描述

现在一切都很好。多谢!

相关内容