IEEE 802.15.4 MAC implementation in NS-2


In case that you use and/or modify any code provided at this site for your own research and subsequent publications, we request that you

a) provide a suitable acknowledgement and

b) provide us with a copy of your code



Our interest is in the analysis of the performance of the contention access part (CAP) of IEEE 802.15.4 MAC organized in a star topology and operating in beacon-enabled mode with all the nodes being within the hearing range of each other. The model simplifications that we have made in order to do this are the following.

1. The 802.15.4 superframe is assumed to consist fully of the active period. Since our interest is in the CAP, there is no contention-free period (CFP) in the superframe.

2. There are assumed to be nodes connected to a PAN coordinator in a star topology and communicating with it directly.

3. All the nodes are assumed to be within the carrier sensing range of each other. This assumption removes the possibility of hidden nodes and the resulting collisions.

4. There are no MAC level acknowledgements.

5. The MAC layer does not have an interface queue. It accepts new packets from the upper layer only when it not attempting to transmit a previously received packet.

6. Since we are analyzing the star topology, there is no need for a routing layer.


In order to substantiate the analysis, we have used the NS-2 module for IEEE 802.15.4 developed by Jianliang Zheng for simulations. We have had to modify the code significantly for the following reasons. All the modifications were done in release 2.28.

1. There are a few bugs in the NS-2 module.

2. The energy model present in NS-2 does not support sleep state (nor transitions among states) and needed to be updated.

3. We have incorporated in each node the ability to shut itself down when there are no packets to be transmitted.

4. Our model simplifications (like that of the absence of an interface queue) required that some parts of the code be changed.


Since no real documentation exists on the NS-2 implementation, we provide here a fundamental description of the flow of code when a packet outgoing or an incoming packet is received by the MAC.

The changes made to the NS-2 module are described in this file along with the reasons for the modifications and list of files affected.

A sample tcl file can be found here.

All the files changed are available here.


Our paper describing the analysis has been accepted for publication in ACM Transactions on Sensor Networks. A draft of the paper can be found here. The NS-2 code provided here is in keeping with the model/assumptions described in the report. Please use the code in conjunction with the report. Also check out the presentation that I made to the IEEE 802.15.4b WG at the IEEE LMSC Plenary in Vancouver in November, 2005.


Please contact me at if you have questions or comments.

You can find details of my research activities at my personal webpage.


free statistics visitors since Feb 2006