For a quick introduction of myself I am currently working towards my masters in Computer Science, at the University of Northern British Columbia, and my current focus is on Sensor Networks, and as the LEACH algorithm seams to be a very good example of a clustering algorithm, it has been the starting point for a lot of my work. This page provides the files which I have started working with, the collection includes ns-2.1b5 from http://www.isi.edu/nsnam/ns/ns-build.html and of course the MIT extensions which I was able to download from Wendi Heinzelman's page. The files available here are a collection of others work, with some very minor changes by me. Hopefully everything here works for you, I have been working on Sun machines at my university, running SunOS 5.9, I have not been able to test any other operating systems, but I would expect things should work on other platforms.
Before the details I'd like to give a big thanks to Jason Tillett, from his post on the ns users message board I was able to get a bunch of the information that eventually helped me to set up the LEACH algorithms in ns. More then anything else though Jason's comments on how he got things to work helped prove to me that it was possible, something I doubted up until that point.
Anyway, the instructions are not completely straight forward, but hopefully there is enough there to get things working and if not feel free to send me an email.
1. First thing you'll need to do is download this file. The file contains the allinon ns-2.1b5, and the MIT extensions. I have also made some minor modifications to some of the files so that the install will actually work. One of the changes made was to tell the install to use the gcc compiler if available, so for users without this compiler there maybe problems. For my install however, not using the gcc compiler created problems, so I would suggest trying to get a good version of gcc.
2. Next you are going to want to extract the files, change to the directory you wish to be the parent of your ns install and extract the files.
ie: if the archive is in the root directory a subdirectory ns-allinone-2.1b5 will be created, if you wish to install else where just keep track of the parent.
First type: gunzip ns-allinone-2.1b5.plus.MIT_uAMPS.tar.gz
Then type: tar -xvf ns-allinone-2.1b5.plus.MIT_uAMPS.tar
This should set up the files you need.
3. Now change to /full_parent_path/ns-allinone-2.1b5/ and run ./install
Again where the full_parent_path refers to the directory where you decided to install ns ('pwd' from the command prompt will give you the path if you can't figure it out).
4. At this point you need to set up some environment variable so, add to your .bash_profile
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/full_parent_path/ns-allinone-2.1b5/otcl-1.0a4
uAMPS_LIBRARY=/full_parent_path/ns-allinone-2.1b5/ns-2.1b5/mit/uAMPS
RCA_LIBRARY=/full_parent_path/ns-allinone-2.1b5/ns-2.1b5/mit/rca
export LD_LIBRARY_PATH uAMPS_LIBRARY RCA_LIBRARY
Of course at this point you will need to make sure these changes take effect (opening a new terminal should make sure things work out).
5. This step is a real pain, but I haven't been able to find a way around it yet. You will need to change to /full_parent_path/ns-allinone-2.1b5/ns-2.1b5/tcl/mobility and correct the defunct symbolic links. The files leach.tcl, leach-c.tcl, mte.tcl, and stat-clus.tcl can all be removed if they exist. It is very possible though that they wont be there, in either case they now need to be be created with:
ln -s /full_parent_path/ns-allinone-2.1b5/ns-2.1b5/mit/uAMPS/sims/leach.tcl leach.tcl
ln -s /full_parent_path/ns-allinone-2.1b5/ns-2.1b5/mit/uAMPS/sims/leach-c.tcl leach-c.tcl
ln -s /full_parent_path//ns-allinone-2.1b5/ns-2.1b5/mit/uAMPS/sims/mte.tcl mte.tcl
ln -s /full_parent_path/ns-allinone-2.1b5/ns-2.1b5/mit/uAMPS/sims/stat-clus.tcl stat-clus.tcl
I think that should be it. You can now switch into your ns-2.1b5 directory (/full_parent_path/ns-allinone-2.1b5/ns-2.1b5/) and run the sample script provided (sample_script), this should give you a lot of output helping to show you things are working correctly. There is a modified version if you are interested in having both the original ns-2.1b5 running, and the extend 2.1b5 with LEACH, but if your interested in that send me an email I can help you out.
From there I think you should be set, or at least able to run the sample_script. Figuring out the output format, and actually using LEACH to it's fullest is another thing. As I get there though I will update the website. Hopefully this has helped and please email me with any mistakes, or any ways of making these instructions easier to follow. Thanks and enjoy LEACH!