Showing posts with label cygwin. Show all posts
Showing posts with label cygwin. Show all posts

Aug 31, 2006

How to install the tcl-debug onto Cygwin + ns2 release 2.28

[ns] [Answer] How to install the tcl-debug onto Cygwin + ns2 release 2.28
tk424 tk424 at umr.edu
Thu Jun 16 10:23:08 PDT 2005

Dear NS-users,

I decided to email to share my experience how to install the tcl-debug2.0.
I've seen some emails from NS mailing list archive providing useful information.
I recommend you to try the STANDARD method to install tcl-debug suggested by
(1) the NS-manual, Chap. 22.1. Tcl-level debugging.
(2) the archive, Title: [ns] re:how to debug TCL by Jiangtao Luo (Nov.2004)
http://mailman.isi.edu/pipermail/ns-users/2004-November/045925.html
(3) The README file given by Tcl-debug

But I needed some more information and help to make my tcl-debug work.
The help is mostly from the other NS users in the archive, Regina Rosales Hain, and Prof. Larry Pyeatt.
By sharing my experience, some of you may save time and effort. :)
The method in this email is just one option and there are so many other (and easy) ways to deal with problems as well.

------------------------------------------------------------------------------------
Target:
Information about the installation of tcl-debugger for NS-2;
tcl-debug is suggested on the official NS-2 website.
I've got the same installation problem as minisivakumar vellore (Mar. 2005), which I didn't find the solution in the archive yet.

------------------------------------------------------------------------------------
Assumption:
Installation of Cygwin and NS-2 is successful.
(This email only deals with the installation of tcl-debug.)
Tcl-debug will be installed onto a directory parallel to the NS-2 directory, i.e. ~ns (by the convention in the NS manual)

------------------------------------------------------------------------------------
My system:
OS: Windows XP + Cygwin (http://www.cygwin.com/setup.exe)
(I guess the Cygwin DLL release version is 1.5.17-1 <http://cygwin.com/ml/cygwin-announce/2005-05/msg00029.html> )
NS-2: release 2.28 all-in-one package
(http://www.isi.edu/nsnam/dist/ns-allinone-2.28.tar.gz)
Tcl debugger: tcl-debug version 1.7
(http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz)

NS-2 is installed on the user's home directory, /home/UserID;
therefore. /home/UserID/ns-allinone-2.28
------------------------------------------------------------------------------------
Refered links:
http://www.cygwin.com/
http://www.isi.edu/nsnam/ns/
http://mailman.isi.edu/pipermail/ns-users/

------------------------------------------------------------------------------------
Installation of tcl-debug

1. Download the tcl-debug and move the downloaded file to NS-2 root directory, i.e. ns-allinone-2.28.
To download, http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz
You should be in the NS-2 root directory
$ cd /home/UserID/ns-allinone-2.28

UserID is your account. For example, the account name phil4u becomes /home/phil4u/ns-allinone-2.28

2. Extract the downloaded tcl-debug file.
$ tar -xfz tcl-debug.tar.gz

Then, the extracted files will be automatically copied into a new directory, tcl-debug-2.0
Note: The reason we extract the files into a directory PARALLEL to the directory ~ns,
i.e. /home/UserID/ns-allinone-2.28/ns-2.28, is because of the step 4.3.

3. Compile the tcl-debug and move the created loadable library to the NS-2 library directory
1) Move to the directory where tcl-debug is.
$ cd tcl-debug-2.0

2) Configure and compile tcl-debug
$ ./configure
$ make

3) Check whether a loadable library (*.a) is created after compilation.
See if a file "libtcldbg.a" is there.
As its name, this file is the loadable "library for tcl debug".

4) Copy the loadable library to the NS-2 library directory, /home/UserID/ns-allinone-2.28/ns-2.28/lib or ~ns/lib
$ cp *.a ../ns-2.28/lib

Note: After compilation, we don't get an executable file, but a loadable library.

4. Compile the NS-2
1) Go to the directory ~ns/lib and check whether the loadable library is properly copied.
$ cd ../ns-2.28/lib
$ ls

2) Move to the directory ~ns, /home/UserID/ns-allinone-2.28/ns-2.28
cd ..

3) Configure NS-2 with an option enabling tcl-debug
$ ./configure --with-tcldebug

Note: You should see lines showing that the directory of tcl-debug is recognized.
If you don't see this line below, you should get back to the previous steps.

Checking for libtcldbg... -L/home/UserID/ns-allinone-2.28/ns-2.28/ ../tcl-debug-2.0 -ltcldbg

I see this line above a line given below,

checking dmallc... not requested with --with-dmalloc

4) Erase previous compilation record
$ make clean

Note: This step is important!

5) Compile NS-2
$ make
Now the tcl-debug is embedded to the created NS-2 executable file "ns.exe" for cygwin

6) Check if you can run the NS-2 excutable.
$ ns
%
As you know, NS-2 works fine if you see %. ( Press ctrl+C )

7) Copy this NS-2 excutable to the ns-allinone-2.28/bin directory
$ cp ns.exe ../lib/

5. Check if the tcl-debug works.
Now the installation is done. You can check if the debugger works by adding a line "debug 1" into a tcl script.
For example,
1) pick a tcl script in ~ns/tcl/ex directory, say wireless-test.tcl,
and modify this tcl script with a text editor.

set ns_ [new Simulator]
debug 1; # this line calls the tcl-debug
set chan [new $opt(chan)]

2) Run the wireless-test.tcl
$ ns wireless-test.tcl

After running this script, you will see the following lines if the installation is successful.
2: lappend auto_path $dbg_library
dbg2.0>

If you still see the error message while you think you've done right so far, please check step 4.1, 4.3. 4.4, 4.6.
Good luck!

Tae-hyung Kim

tags :

Aug 27, 2006

Building ns-2 on Cygwin [versions 2.27, 2.26 and 2.1b9a]

Thinking of getting the older version of Ns-2 Network Simulator, but having problem with installation in cygwin. You can refer to the archived Nicolas Christin's page, here.



tags :


Jun 4, 2006

Using Perl with Cygwin

Some of us are using PERL on our Windows boxes to process data, etc. Many are also using cygwin to have a UNIX-like environment. This page offers some tips on getting ActiveState's PERL to work within a cygwin environment.

First, many folks recommend using a cygwin version of Perl if you are going to use cygwin as it avoids some of the problems I have addresed below. That may be a viable solution for you. I had already invested time in building my tools based on ActiveState (which has a richer set of add-ins, like modules). The cygwin folks also recommend getting a cygwin implementation of Xemacs.

The Problem

The problem basically boils down to the fact that cygwin attempts to offer a UNIX like file-system structure where absolute path names start with / instead of a windows style (e.g. c:). ActiveState's perl does not understand this UNIX style names. The very quick work around which I used for a long time was to always call perl scripts with absolute, windows-style path names (so cygwin does no conversion.) That is:

d:/parris/perl/stats.pl

works but

stats.pl

doesn't, even though d:/parris/perl is in the path. When you try to run a script relying on the #!c:/perl/bin/perl.exe syntax to specify the program that should process the script the shell (in this case cygwin's bash) effectively executes a command like:

c:/perl/bin/perl.exe absolute_script_name

If you are running from DOS everything is ok as this looks like:

c:/perl/bin/perl.exe d:/parris/perl/stats.pl

But with cygwin it looks like:

c:/perl/bin/perl.exe /cygdrive/d/parris/perl/stats.pl

and Perl balks with "no such file" because it can't resolve this pathname.

The Solution

To fix this problem, I use an intermediate shell script instead of the perl exectuable which takes the filename passed, converts it to a windows style pathname and then calls perl to process the script. The first line of my perl scripts looks like:

#!/usr/local/bin/perl

and /usr/local/bin/perl looks like:

#!/bin/sh

# This is necessary to make perl work with cygwin. Cygwin passes
# "cygwin style" paths to the program in the #! statement and ActiveState
# perl does not know what /cygwin/d/... means.

# So, we put #!/usr/local/bin/perl in the perl script and this is called
# This routine translates the path name to something of type d:/

args=""
while [ $# -gt 0 ]
do
var=$1
shift

if test "`echo $var | grep '/'`" = "$var"
then
# cygpath does the /cygwin/d/ to d:/ conversion
var=`cygpath -w $var`

# but then we have to swap \ for / (extra \ needed because the
# shell makes a first pass at removing the \.
var=`echo "$var" | sed 's/\\\/\\//g'`
fi
args="$args $var"

done
# finally the command is to call perl with the name of the script and the args.
cmd="c:/perl/bin/perl.exe $args"
$cmd

This uses the cygwin command, cygpath to convert to a windows style pathname and then convers \ to / before calling perl. This script could certainly be a lot more robust but it gets the job done for me.

** source

tags :

Jan 22, 2006

Network Simulator, NS-2

Network Simulator, NS-2 is a discrete event based simulator. It's a dual language simulator which consists of Object oriented Tcl/Tk and C++ as part of the front-end interpreter. Users can create simulator object through intrepeter and objects can be instantiated within the intrepreter.

Network Simulator, NS-2 manual can be obtained from here.

I used NS-2 on Cygwin.

There is a wiki on how to install and run Ns-2 on Cygwin.

** Before running Ns-2 cygwin, we need to set the path for Ns-2 in Cygwin

Copy the following path and paste it at the bottom of .bashrc file (this is for Cygwin and Ns-2 version 2.29)
---------------------------------------------------------------

export NS_HOME=`pwd`/ns-allinone-2.29
export PATH=$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/otcl-1.11:$NS_HOME/lib:$NS_HOME/tcl8.4.11/
unix:$NS_HOME/tk8.4.11/ unix:$LD_LIBRARY_PATH

export TCL_LIBRARY=$NS_HOME/tcl8.4.11/library

Basically to start running Ns-2 on Cygwin, we need to initiate the graphical mode by typing "startxwin.bat"














and we can run any ns-2 tcl script by entering the ns command followed by the script

example :

ns example1.tcl