This is the pre-ns-2.28 ns-cgwin page from Nicolas Christin, previously abailable at http://www.sims.berkeley.edu/~christin/ns-cygwin.shtml
      Here are relatively simple instructions to get the
         ns-2
         network simulator package to fully build on Cygwin for Microsoft Windows
         9x/ME/NT/2000/XP. The major differences with the native 
         Win32 build are that (1) you can build allinone, without
         the need for downloading separate components, (2) the
         build process doesn't require VisualStudio to compile any
         component, (3) nam won't
         run as a standalone Windows application, but within the
         Cygwin XFree86
         server, (4) unless you are using an
         older version of Cygwin, validation tests should
 work, and (5), as of ns-2.26, the native Win32 build is not actively maintained anymore, so that you have to use Cygwin.
 You are strongly advised to read the entire set of following instructions first, before proceeding with the actual install.
 
Please do not email me privately about this webpage, ns-2, Cygwin, or XFree86, except for pointing out mistakes or typos in this web page. If you have questions, post them on the ns-users mailing-list instead, out of fairness for other users. See Russ Allbery's excellent page for a complete list of reasons why I will not reply to private emails.
(*)Important remark: due to a few syntactic glitches,ns-allinone-2.1b9a does not compile anymore with recent (>= 3.3) versions of gcc. We have no plans in backporting to 2.1b9a the (trivial) patch which fixes those glitches. You should upgrade to 2.27. If that is not feasible, look at the patch ns-allinone-2.26-cygwin.patch for inspiration on how to fix the few compilation problems, or use gcc-3.2.
    cygwin-1.3.12
    or later. 
    May work with older versions but I have not
            tried, and I would advise against it.
            cygwin-1.3.19-1 or later is recommended to
            ensure that all validation tests pass. (See
                here why.)mount | grep textmodeand if you don't get anything (i.e., it returns an empty string), you should be fine. If the above command does return something, you are quite likely using the DOS text type, and you may be in trouble.
C:\Cygwin (the default) is a good installation directory, C:\Program Files\Cygwin is not.
          XFree86-base, 
            XFree86-bin, XFree86-prog, 
            XFree86-lib, and XFree86-etc packages. 
            They can easily be
            installed via
            the Cygwin
            setup.exe program if you haven't already
            installed them.
            If you are unfamiliar with XFree86 and/or
            Cygwin, we
            recommend you take a look at the 
            Cygwin XFree86 User Guide, and the references
            therein.
          make, patch and diff utilities
            as well as perl (5.6.1 or above). Again,
            those can easily be installed via the Cygwin
            setup.exe program if you haven't already
            installed them.
          gcc (both gcc and
            gcc-g++ packages - and version 3.x, not gcc2!),
             awk, diff,
            tar, gzip. If some of them
            are missing (which you can check from the command line
            by simply issuing the command and see if the shell
            tells you "command not found"), you must install them
            with the Cygwin
            setup.exe program before proceeding.
          w32api package installed on your system. You can verify this by issuing the command 
cygcheck -c w32api | grep w32apiIf this command returns an empty string, install the
w32api package with the Cygwin
            setup.exe program before proceeding.ns-allinone-2.27, available at  http://www.isi.edu/nsnam/dist/ns-allinone-2.27.tar.gz.ns-allinone-2.26, available at  http://www.isi.edu/nsnam/dist/ns-allinone-2.26.tar.gznam-1.9.configure, available here. (To save it, use Right click/Save as..., and save as type "all files")gcc, and XFree86. (To save it, use Right click/Save as...,
and save as type "all files")ns-allinone-2.1b9a patched for gcc-3.2,
            available at 
            http://www.isi.edu/nsnam/dist/ns-allinone-2.1b9a-gcc32.tar.gz
          ns-allinone-2.1b9a does not compile with gcc-3.3.x or above(*). Stick to gcc-3.2.
        ns-allinone-2.27.tar.gz
            file in your Cygwin home directory
            (typically something like
            C:\cygwin\home\nicolas)
install.patch file in your Cygwin
            home directory as well.
          startx)
          bash) prompt, run the following commands (each line corresponds to a separate command):
            
            gzip -d -c ns-allinone-2.27.tar.gz | tar xvf - cd ns-allinone-2.27 patch -p0 < ~/install.patch
./install
export NS_HOME=`pwd` export PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:\ $NS_HOME/otcl-1.8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.4.5/libraryTo avoid retyping these commands everytime you login you can do the following, after having updated your environment variables as described above:
pwd at the command prompt/home/XXX/ns-allinone-2.27/ (where XXX is your login name)~/.bashrc file by adding the following commands to it:
export NS_HOME=/home/XXX/ns-allinone-2.27/ export PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:\ $NS_HOME/otcl-1.8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.4.5/librarywhere you replace
/home/XXX/ns-allinone-2.27/ by whatever pwd returned.
Make sure you respect the line breaks as shown above.
cd ns-2.27; ./validateafter having updated your
PATH,
LD_LIBRARY_PATH, and TCL_LIBRARY
environment variables as described above.
Note that the regression suite should work on 
                Cygwin,
                contrary to classical Win32 builds. Some tests
                may fail on old versions of Cygwin, this is described later.)
          ns-allinone-2.27 in your Cygwin environment../configure
after installation results in an error regarding the X11
library being missing. A quick workaround is discussed in 
this post in the ns-users mailing-list archives. ns-allinone-2.26.tar.gz
            file in your Cygwin home directory
            (typically something like
            C:\cygwin\home\nicolas)
nam-1.9.configure and ns-allinone-2.26-cygwin.patch files in your Cygwin
            home directory as well.
          startx)
          bash) prompt, run the following commands (each line corresponds to a separate command):
            
            gzip -d -c ns-allinone-2.26.tar.gz | tar xvf - mv nam-1.9.configure ns-allinone-2.26/nam-1.9/configure cd ns-allinone-2.26 patch -p0 < ~/ns-allinone-2.26-cygwin.patch
./install
export NS_HOME=`pwd` export PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:\ $NS_HOME/otcl-1.0a8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.3.2/libraryTo avoid retyping these commands everytime you login you can do the following, after having updated your environment variables as described above:
pwd at the command prompt/home/XXX/ns-allinone-2.26/ (where XXX is your login name)~/.bashrc file by adding the following commands to it:
export NS_HOME=/home/XXX/ns-allinone-2.26/ export PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:\ $NS_HOME/otcl-1.0a8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.3.2/librarywhere you replace
/home/XXX/ns-allinone-2.26/ by whatever pwd returned.
Make sure you respect the line breaks as shown above.
cd ns-2.26; ./validateafter having updated your
PATH,
LD_LIBRARY_PATH, and TCL_LIBRARY
environment variables as described above.
Note that the regression suite should work on 
                Cygwin,
                contrary to classical Win32 builds. Some tests
                may fail on old versions of Cygwin, this is described later.)
          ns-allinone-2.26 in your Cygwin environment.ns-allinone-2.1b9a-gcc32.tar.gz
            file in your Cygwin home directory
            (typically something like
            C:\cygwin\home\nicolas)
          ns-allinone-2.1b9a-gcc32-cygwin.patch file
            in your Cygwin
            home directory as well.
          startx)
          bash) prompt, run the following commands (each line corresponds to a separate command):
            
            gzip -d -c ns-allinone-2.1b9a-gcc32.tar.gz | tar xvf - cd ns-allinone-2.1b9a patch -p0 < ../ns-allinone-2.1b9a-gcc32-cygwin.patchYou should get an output resembling:
patching file ./gt-itm/src/Makefile patching file ./install patching file ./nam-1.0a11a/config.sub patching file ./nam-1.0a11a/configure patching file ./ns-2.1b9a/bin/raw2xg patching file ./ns-2.1b9a/diffusion3/lib/nr/nr.hh patching file ./ns-2.1b9a/tcl/test/test-suite-simple-full.tcl patching file ./sgb/Makefile patching file ./tcl8.3.2/generic/tcl.h patching file ./tcl8.3.2/unix/Makefile.inIf you are running a version of Cygwin between 1.3.12 and 1.3.16-1, you need to modify the
install file in the top
directory of the distribution. Replace 
            cd ./xgraph-$XGRAPHVER ./configureby
cd ./xgraph-$XGRAPHVER ./configure touch stamp-h
./installIf the patch failed, resulting in an error, it probably means that you modified the
ns tree prior to trying to apply the
patch, or are not using ns-allinone-2.1b9a-gcc32. Jump
to the section on what the patch actually does,
and do the changes by hand.export NS_HOME=`pwd` export PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:\ $NS_HOME/otcl-1.0a8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.3.2/libraryTo avoid retyping these commands everytime you login you can do the following, after having updated your environment variables as described above:
pwd at the command prompt/home/XXX/ns-allinone-2.1b9a/ (where XXX is your login name)~/.bashrc file by adding the following commands to it:
export NS_HOME=/home/XXX/ns-allinone-2.1b9a/ export PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:\ $NS_HOME/otcl-1.0a8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.3.2/librarywhere you replace
/home/XXX/ns-allinone-2.1b9a/ by whatever pwd returned.
Make sure you respect the line breaks as shown above.
cd ns-2.1b9a; ./validateafter having updated your
PATH,
LD_LIBRARY_PATH, and TCL_LIBRARY
environment variables as described above.
Note that the regression suite should work on  
                Cygwin,
                contrary to classical Win32 builds. Some tests
                may fail for old versions of Cygwin, though, this is described later.)
          ns-allinone-2.1b9a in your Cygwin environment.patch
            command, what the patch actually does is detailed at
            the end of the email.
          startx.
          PATH,
            LD_LIBRARY_PATH and
            TCL_LIBRARY environment variables as you
            were told when the install script
            completed, and you should be all set. (Note: I am
            talking about the PATH environment
            variable in Cygwin, not the
            Windows PATH variable.)
          nam will run under XFree86 for
                Cygwin, it
                will be a window in your XFree86 server,
                not a "Windows window".
          cygwin-1.3.19-1 or
            a later version, some validation tests fail. These
            failures are caused by event reordering and are not a
            cause for concern. Tests that may fail are: 
            cygwin-1.3.12
                and cygwin-1.3.18-1:
                test-all-intserv,
                test-all-plm,
                test-all-WLtutorial,
                test-all-diffusion3
              cygwin-1.3.16-1:
                test-all-friendly,
                test-all-mcache,
                test-all-webcache,
                test-all-wireless-shadowing,
                test-all-wireless-lan-aodv,
                test-all-wireless-gridkeeper,
                test-all-wireless-diffusion,
                test-all-wireless-lan-newnode,
                test-all-cbq-v1,
                test-all-tagged-trace.
              cygwin-1.3.19-1 or later.
          Queue/PI does not work out of the box.
This is not Cygwin-specific (the same problem was also reported
on Mandrake Linux 9.0), and is explained in 
in 
that post to the ns-users
mailing-list. 
nse) isn't even compiled.
            nse currently only runs on BSD,  Linux and MacOS X (as of ns-2.26),
            so this is not surprising. I am working on getting it to
            run on Cygwin - not completely straightforward, but it
            appears to be doable. Stay tuned for a patch. 
          xgraph,
            cweb, zlib,
            otcl, tclcl, or
            tk. These guys compile out of the box.
          sgb Makefile is modified
            so that the line 
            rm test.gb sample.out test_io test_graph test_flip test_sampleis replaced by
rm -f test.gb sample.out test_io.exe test_graph.exe\ test_flip.exe test_sample.exe
gt-itm/src/Makefile is modified so that
            the line starting with eval.o is moved
            before the line starting with
            edriver.o, and the line starting with
            edriver.o is moved before the line
            starting with edriver. (Note: this is not
            Cygwin specific, I
            believe it's just a plain old bug.)
                tcl8.3.2. In
            generic/tcl.h, before the lines 
            /* * For C++ compilers, use extern "C" */the patch adds
/* CYGWIN */ #ifdef __CYGWIN__ #define HAVE_TM_ZONE 1 #endifThe timezone in the
tm structure defined in 
            sys/time.h is one of these types that are
            weirdly defined in Cygwin, so
            ./configure doesn't get it right, but it
            does exist.unix/Makefile.in, the stub
            (re)generation has to be removed. In other words, the
            lines 
            
$(GENERIC_DIR)/tclStubInit.c: $(GENERIC_DIR)/tcl.decls \
                $(GENERIC_DIR)/tclInt.decls
        $(TCL_EXE) $(TOOL_DIR)/genStubs.tcl $(GENERIC_DIR) \
                $(GENERIC_DIR)/tcl.decls $(GENERIC_DIR)/tclInt.decls
are deleted. The stubs have no reason to be regenerated, and if
they are, make bails out because of a circular
dependency. For some reason, this line is called at the first
compile on Cygwin, and it
shouldn't. Removing it is a pretty dirty hack, but it works. A
cleaner solution (via an autoconf test) would be
appreciated.
                install file of ns-allinone-2.26, 02/28/2003]
          ns itself has to be patched. 
            diffusion3/lib/nr.hh as follows. The
                lines 
                #ifdef sparc typedef char int8_t; #elseare replaced by
#if defined (sparc) || defined (__CYGWIN__) typedef char int8_t; #else
indep-utils/cmu-scen-gen/setdest/setdest.cc
                and
                indep-utils/cmu-scen-gen/setdest/setdest2.cc
                include a file that does not exist in Cygwin. In
                both files, one has to replace 
                #if !defined(sun)by
#if !defined(sun) && !defined(__CYGWIN__)to make sure
setdest compiles.bin/raw2xg (a simple Perl
                script) has to be modified, because
                diff is not smart enough to infer that
                1e-05 and 1.e-05 are the same thing, causing some
                validation tests to fail while they are in fact
                successful. We take care of this issue, by
                replacing 
                return ($time, $flow * $flow_factor + ($seq % $modulus) * $scale);by
$plotted = $flow * $flow_factor + ($seq % $modulus) * $scale; $plotted =~ s/\.e/e/g; # to ensure Cygwin compatibility return ($time, $plotted);
tcl/test/test-suite-simple-full.tcl as
                follows. First, we replace 
                
sub BEGIN { $c = 0; @p = @a = @d = @lu = @ld = (); }
/^[\+-] / && do {
by 
                
sub BEGIN { $c = 0; @p = @a = @d = @lu = @ld = (); }
$plotted = $F[7] + ($F[10] % 90040) * 0.00001;
$plotted =~ s/\.e/e/g; # needed for Cygwin compatibility
/^[\+-] / && do {
and then, 
                
push(@p, $F[1], ' ',            \
        $F[7] + ($F[10] % 90040) * 0.00001, "\n");
by 
                
push(@p, $F[1], ' ',            \
       $plotted, "\n");
everywhere. Observant people will have noted this is in fact 
                exactly the same fix as in the previous item,
                except that this particular test doesn't use
                raw2xg but in fact inlines the same
                code, probably for historical reasons.tcl/test/test-suite-wireless-lan-newnode.tcl.
                A file isn't properly closed in the version of
                ns that is currently shipped. While
                this doesn't matter much on UNIX, Windows won't
                let you remove that file until it's closed, causing
                the test to miserably fail. This can be easily
                remedied by replacing 
                
TestSuite instproc finish-basenode {} {
        $self instvar ns_
        global quiet opt
 
        $ns_ flush-trace
by 
                
TestSuite instproc finish-basenode {} {
        $self instvar ns_
        global quiet opt tracefd
 
        $ns_ flush-trace
        flush $tracefd
        close $tracefd
nam has to be patched. In
            config.sub, cygwin32* has to
            be replaced by cygwin*.2.1b9a without the
    gcc-3.2 patches), you will first have to get
    ns-2 to compile with gcc-3.2. A roadmap of
    the changes is available in the ns-users
    mailing-list archives (search them!)
    at 
    http://mailman.isi.edu/pipermail/ns-users/2002-September/025559.html,
    
    http://mailman.isi.edu/pipermail/ns-users/2002-October/026168.html,
    
    http://mailman.isi.edu/pipermail/ns-users/2002-October/026186.html,
    and 
    http://mailman.isi.edu/pipermail/ns-users/2002-October/026138.html,
    and 
    http://mailman.isi.edu/pipermail/ns-users/2002-October/026389.html
    for nam. (Entire discussion and ideas courtesy of George
    Riley, Igor Sobrado, Jun He, Piyush Kenghar, and myself.) 
ns-allinone-2.1b6a, as well as a patched tree for gcc-3.2 of ns-allinone-2.1b6a. He has made all of this available in this page.  Presumably, you only need to go through the Cygwin specific modifications detailed above to get 2.1b6a to compile in Cygwin, but I haven't tried it.
    
    
    
Last modified: