Super User is a question and answer site for computer enthusiasts and power users. 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

I downloaded the Network Simulator NS-2 from here -

Build ns via GCC 4.2.2 -

tar-xzf ns-allinone-2.35.tar.gz
cd ns-allinone-2.35

Get the error message -

make: *** [tk3d.o] Error 1
tk8.5.10 make failed! Exiting ...
For problem with Tcl / Tk see

I pass on the link - - there a a message - "The Script Archive is under reconstruction. Please come back soon."

Then i try -

cd ns-allinone-2.35/ && export CC=gcc-4.2 CXX=g++-4.2 && ./install   

Get the following message -

* Build tcl8.5.10
checking whether to use symlinks for manpages... no
checking whether to compress the manpages... no
checking whether to add a package name suffix for the manpages... no
checking for gcc... gcc-4.2
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See 'config.log' for more details
tcl8.5.10 configuration failed! Exiting...
Tcl is not part of the ns project. Please see
to see if they have a fix for your platform.

How to properly build the NS-2 in Linux Mandriva?

I updated GCC to version GCC-4.7.2, then installed ns-2.34. Previously made some changes in the source code -

in mac/mac-802_Ext.h(or in mac-802_11Ext.h for ns 2.35), line 65 - add

# include "cstddef";

also-in file linkstate/ls.h at line 137 replace -

void eraseAll () {erase (baseMap :: begin (), baseMap :: end ());}


void eraseAll () {this-> erase (baseMap :: begin (), baseMap :: end ());}

Now let us take a simple test (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

Run (according to -

export DISPLAY localhost:6000
ns ns-simple.tcl

Output -

CBR packet size = 1000
CBR interval = 0.0080000000000000002
[root@localhost ...]# _X11TransSocketINETConnect() can't get address for http://localhost:12000: Name or service not known
nam: couldn't connect to display "http://localhost:6000"

What could this mean? How to get the image?

Next. If I point IP of the remote server on which i installed ns-2, I get the following error -

[root@localhost ...]# export DISPLAY=..ip_of_remote_server_:0.0
[root@localhost ...]# ns ns-simple.tcl
CBR packet size = 1000
CBR interval = 0.0080000000000000002
[root@localhost ...]# Xlib: connection to "ip_of_remote_server_:0.0" refused by server
Xlib: No protocol specified

nam: couldn't connect to display "ip_of_remote_server_:0.0"
share|improve this question
Hello ivanov-void, is this two separate questions? The first part is about compiling ns2, and the second part seems to be about using it, which suggests you have it working. If these are two questions, can you split them so they are two questions here. If not, can you explain a bit about how they relate? – Paul Dec 28 '12 at 8:05
Hello, Paul! Thanks for the reply. I gave a full report - from assembly ns2 to perform a simple test- i could not find complete documentation on installing ns2 on Linux Mandriva. Perhaps installation is not correct (although tests -./​​validate - are successful). – Aleksey Bykov Dec 28 '12 at 8:21
In Network a lot of questions on this topic, but the answers is almost none. – Aleksey Bykov Dec 28 '12 at 8:23
Ah, I see. Is this a typo: export $DISPLAY localhost:6000 ? You don't put the $ when assigning bash variables, and do you have an X11 server with id 6000? – Paul Dec 28 '12 at 8:41
Yes, it's a typo. I corrected, thanks. Port 6000 - this is just an experiment. – Aleksey Bykov Dec 28 '12 at 9:04
up vote 0 down vote accepted

From your log, its looks like you are running the display on the localhost only. My suggestion is to use the following export command:

% export DISPLAY=:0.0

and try running it again. I use this same command on my Ubuntu 12.10 system and it works.

share|improve this answer

About the installation, make sure that you've installed all the necessary tools for building. I had the same issue with an Ubuntu 10.04 and I found this.

The tools I installed:

  • autoconf
  • automake
  • gcc
  • g++
  • build-essential
  • libxmu-dev
  • libtool
  • libxt-dev

I installed them all using apt-get install and it worked.

Good luck.

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.