Z-MAC:
Hybrid MAC for Wireless Sensor Networks
Z-MAC has been implemented on NS-2 (version
2.26) as well as the TinyOS platform for sensor networks:
NS-2
- NS-2 installations
instructions:
- Download the source tarball here.
- Untar it in the "mac" directory of your ns top-level directory:
(NS_INSTALL_DIRECTORY)/ns-2.26/mac. Warning:
the package contains a slightly modified version of "mac.h", so if you
have made changes to mac.h, please do a diff and incorporate the
changes.
- Add an entry in the Makefile for zmac files: "mac/common-mac.o
mac/zmacHCL.o mac/zmac-timers.o mac/common-mac-timers.o" and
remove entries "mac/mac-802_11.o" and "mac/mac-timers.o" for the
OBJ_CC target.
- Replace
(NS_INSTALL_DIRECTORY)/ns-2.26/tcl/lib/ns-mobilenode.tcl with the given
file here, the change is very minor,
to allow packet tracing from the mac layer.
- NS-2 execution
instructions:
TDMA Setup
- Before using Z-MAC, some setup is required. For a given
topology, Z-MAC requires each node to know its TDMA slot. This is
achieved using DRAND, a distributed
TDMA slot assignment algorithm.
- Consider a topology file,
new-scen-<N>-<maxX>-<maxY>, which denotes the X, Y
and Z positions of nodes in the topology in tcl code. Here maxX and
maxY represent the X and Y dimensions of the topology respectively, and
N represents the number of nodes in the network. Such a file could be
generated by the topology generator 'setdest' for large topologies, or
could be hand-written). Note that this naming convention is important
later, so please maintain it for the rest of this section.
- Run the drand application on this topology by following the
execution instructions in the DRAND page above. Save the output in
file, "new-scen-N-X-Y.out".
- This output file contains the information about the TDMA slots
assigned to each node in the topology. We need a script to convert this
information to Tcl code which can be input to the z-mac code. This is
done by the following script: getZMACInput.py.
Execute this script on the output file as follows:
- python getZMACInput.py new-scen-N-X-Y <MAX_NEIGHBOR> 0
- "MAX_NEIGHBOR" is the value of MAX_NEIGHBOR defined in file
mac/zmac.h, which defines the maximum number of two-hop neighbors
allowed in the topology. The value used here and the value in
mac/zmac.h should be the same, or else the program will fail. The
current value used is 30.
- this will create two files, "new-scen-N-X-Y.drand" and
"new-scen-N-X-Y.maxcolor". "new-scen-N-X-Y.drand" contains the slot
assignments, and "new-scen-N-X-Y.maxcolor" contains the frame size
(which is the maximum slot number assigned to any node in the whole
network).
- This completes the TDMA setup for Z-MAC. Three files should
have been generated:
- new-scen-N-X-Y
- new-scen-N-X-Y.drand
- new-scen-N-X-Y.maxcolor
TRANSMISSION EXPERIMENTS
- Now, download the tcl script tarball here
- Untar it in any location in your file-system.
- The file "simZMAC.tcl" is the main file for the simulation of
Z-MAC. Run it as follows:
- ns simZMAC.tcl -numsources .... -nn .....
- simZMAC.tcl takes a number of arguments, which allow the user
to specify different Z-MAC parameters (e.g. To, Tno, LCL/HCL modes,
etc.). The specific details can be found in the README file in the
tarball.
- an output file can be specified as a parameter to
simZMAC.tcl, and at the end of the simulation, performance statistics
can be printed out.
- In case of difficulties, contact Ajit Warrier.
TinyOS