NS-2.27 and Leach

Thursday, April 15, 2004

Incorporating Leach

I thought about using the older version of ns2, but figured that it should be too hard to compile leach with the new version. Besides, there are probably bug fixes that I would want to keep up with. ns2 should have an easier way to incorporate new protocol, instead of modifying existing code.

ns-2.1b5 is the last build LEACH was written for. The directory structure of ns-2.1b5 is different from ns-2.27, and thus, some of the files go into different directories now. Assuming a directory of ns2.27, The following files from the ns-2.27 will change with the LEACH protocol:

/apps/app.cc
/apps/app.h
/mac/channel.cc
/trace/cmu-trace.cc
/trace/cmu-trace.h
/common/packet.cc
/common/packet.h
/mac/phy.cc
/mac/phy.h
/mac/wireless-phy.cc
/mac/wireless-phy.h
/mac/ll.h


These files are unchanged, even though they're included in the MIT_uAMPs distribution. I found that it was unnecessary to incorporate these changes, because those changes had been accepted in ns2.27:

/mac/mac.cc
/mac/mobilenode.cc


The are new files that you will need to add. I put them in the /mac subdirectory

/mac/mac-sensor-timers.cc
/mac/mac-sensor-timers.h
/mac/mac-sensor.cc
/mac/mac-sensor.h


Instead of just copying the old files, I searched for

#ifndef MIT_uAMPS

to see where it is the leach made changes, and made the corresponding changes in the existing ns2.27 code. I will post the new ns2.27 modified LEACH code later.

The Makefile.in also changes. I have added the following definitions:

# MIT uAMP LEACH includes
INCLUDES_MIT = -I./mit/rcs -I./mit/uAMPS

# MIT additions
#
OBJ_MIT = mit/rca/rcagent.o mit/rca/rca-ll.o mit/rca/resource.o mit/rca/energy.o mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPS/bsagent.o


I added $(INCLUDES_MIT) to the end of the definition of $(INCLUDES)

I also added $(OBJ_MIT:.o=.c) to the end of the following:

SRC =
$(OBJ_C:.o=.c) $(OBJ_CC:.o=.cc)
$(OBJ_EMULATE_C:.o=.c) $(OBJ_EMULATE_CC:.o=.cc)
common/tclAppInit.cc common/tkAppInit.cc


And added $(OBJ_MIT) to the end of the following:

OBJ = $(OBJ_C) $(OBJ_CC) $(OBJ_GEN) $(OBJ_COMPAT)

1 Comments:

  • do you hav complete LEACH code that is executable in ns 2.27? please help me. Could you send me the source code plz?

    thank you

    By Blogger 정환, at 10:07 PM  

Post a Comment

<< Home