o Download the source tarball here.
o 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.
o 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.
o 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.
For the Source and Codings You can download from here
http://hotfile.com/dl/30721737/1e090d3/ZMAC.rar.html
* NS-2 execution instructions:
TDMA Setup
o 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.
o Consider a topology file, new-scen-
o 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".
o 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" 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).
o 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
o Now, download the tcl script tarball here
o Untar it in any location in your file-system.
o 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.
NS-2
* NS-2 installations instructions:
o Download the source tarball here.
o Untar it in your ns top-level directory: (NS_INSTALL_DIRECTORY)/ns-2.26.
o Add an entry in the Makefile for DRAND files as "drandNS2/drandAgent.o" for the OBJ_CC target.
o Add entry for DRAND packet type in (NS_INSTALL_DIRECTORY)/ns-2.26/tcl/lib/ns-packet.tcl as "DRAND" - sample here.
o Add entry for DRAND packet type in (NS_INSTALL_DIRECTORY)/ns-2.26/common/packet.h as "PT_DRAND" - sample here.
o Replace ns2.26/mac/mac-802_11.cc with this file: There is a small change to enable broadcast for DRAND packets.
o Replace ns2.26/trace/cmu-trace.cc with with this file: This adds support for DRAND packets.
* NS-2 execution instructions:
o Download the tcl script tarball here
o Untar it in any location in your file-system.
o Execute simulation by the follwing command: "ns simple-wireless.tcl
o File "simple-wireless.tcl" runs a simulation of
o For generating the scenario file, use the CMU scenario generator included in the ns2 distribution: (NS_INSTALL_DIRECTORY)/ns-2.26/indep-utils/cmu-scen-gen/setdest. Also, note that the scenario should not contain any node motion, so please use the option "-p 0 -s 0"
o DRAND is composed of two phases - a "HELLO" phase, where nodes send beacons to each other to probe their network neighborhood, and the "DRAND" phase where the DRAND algorithm is run and a TDMA schedule is produced (For more details please refer to the paper "Randomized Dining Philosophers to TDMA Scheduling in Wireless Sensor Networks".
o DRAND output is as follows:
+ MESSAGE sID 82 mCt 15 rReq 0 rGra 0 mTime 27.826388 oneHopCount 7
MESSAGE sID 82 reqCt 1 graCt 7 rejCt 0 relCt 0 twoCt 7
MESSAGE sID 82 Round 20 maxC 0 twoHopMaxC 0 slotNum 11 roundDelay 0.023284 grantDelay 0.018388
+ Some of the noteworthy fields are:
# sID = Node ID
# mCt = Total messages transmitted
# mTime = Total time for the node to get its own time slot
# oneHopCount = Total number of nodes within one hop to this node
# slotNum = TDMA slot assigned by DRAND
Hi,
ReplyDeleteI tried to install and simulate ZMAC in ns-2.26, but I have problem.
After installation everything looks OK, but when I want to run zmacSIM.tcl i got following error:
"$mac trace-target $rcvT"
(procedure "_o15" line 134)
(Node/MobileNode add-interface line 134)
invoked from within
"$node add-interface $chan $propInstance_ $llType_ $macType_ $ifqType_ $ifqlen_ $phyType_ $antType_ $inerrProc_ $outerrProc_ $FECProc_"
(procedure "_o4" line 64)
(Simulator create-wireless-node line 64)
invoked from within
"_o4 create-wireless-node 0"
("eval" body line 1)
invoked from within
"eval $self create-wireless-node $args"
(procedure "_o4" line 14)
(Simulator node line 14)
invoked from within
"$ns_ node $i"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $numNodes } {incr i} {
set node_($i) [$ns_ node $i]
$node_($i) random-motion 0 ;# disable random motion
$god_ new_node $nod..."
(file "multiHopTopoGen.tcl" line 1)
invoked from within
"source.orig multiHopTopoGen.tcl"
("uplevel" body line 1)
invoked from within
"uplevel source.orig [list $fileName]"
(procedure "source" line 12)
invoked from within
"source "multiHopTopoGen.tcl""
(file "simZMAC.tcl" line 99)
I suspect that simZMAC.tcl is OK.
Can anyone pls help me, or do you have an idea where error can be ?
Thanks a lot.
JP
Hi
ReplyDeleteCan you send me about the remaining part (ie) is full code where can i make some trace and refer it .I will try .
Hi,
ReplyDeletethanks a lot for answering.
I used this script:
http://www4.ncsu.edu/~rhee/export/zmac/software/zmac/zmacFiles/zmacTcl.tar.gz
It is script from article part (see above) "TRANSMISSION EXPERIMENTS".
Thanks a lot
JP