Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Theme begins here - http://superuser.com/questions/525110/installing-network-simulator-ns-2-allinone-on-linux-mandriva

There is a certain emulator- NS-2.

It can be used to describe the network topology, configuration of source and destination of traffic, all connection parameters (bandwidth, delay, packet loss probability, and many other parameters of the simulated system).

I installed it on Linux Mandriva 2008 and it works.

But I not possible to achieve visualization -this is due with Xorg.

I'm trying to implement a simple example (I repeat the code again) -


#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

But I get error message.

[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 #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)

Run ns:

[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"**

I tried to rebuild the nam, as they say here, my remote-create-animator function looks like this -

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
    #   }

But nothing has changed. Message now is - "Cannot connect to existing nam instance. Starting a new one..."

And all ..

How to get the picture? I would be very grateful for the information!


share|improve this question
up vote 2 down vote accepted

It has been a long time since I used NS2, but if I recall correctly you may have a problem with tunneling your X11. Are you using SSH to connect to the linux server running the NS2? Try typing xclock and see if you can see the clock... You need to enable tunneling on whatever program you are using to SSH.

If you use putty it is just a matter of ticking the tunneling under X11

You should also make sure your Xserver is running (I personally use Xming).

share|improve this answer
Thanks for the answer, brooc! Yes, I use Putty client and protocol SSH. I tried to execute command xclock, but the clock did not see. Thanks, I'll try to enable tunneling! – Aleksey Bykov Dec 29 '12 at 16:54
You will also need some Xserver on your windows machine like Xming. – brooc Dec 29 '12 at 17:08
Thank you, brooc! – Aleksey Bykov Dec 29 '12 at 17:16

I did the following.

Install Xming


1) Remove the variable DISPLAY from bashrc, bash_profile and from /etc/profile

2) In the file */etc/ssh/sshd_config* I added following:

ListenAddress ip_of_remote_server

3) Uncomment:

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

4) Putty settings:

SSH-> X11:

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

Then run following:

[root@localhost ...]# echo $DISPLAY
[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...

After that appears -

enter image description here enter image description here

Now everything is fine. Thanks a lot!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.