From Nsnam
Jump to: navigation, search

Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summer Projects

Installation - Troubleshooting - User FAQ - HOWTOs - Samples - Models - Education - Contributed Code - Papers

Return to GSoC 2015 Accepted Projects page.

802.15.4 realistic MAC and Energy Model

  • Abstract: The IEEE 802.15.4 standard defines the physical and media access control layers for LR-WPANs (Low-Rate Wireless Personal Area Networks), and is one of the enabling technologies for Wireless Sensor Networks as well as the emerging Internet of Things applications. The ns-3 network simulator currently offers support for simulating LR-WPANs as specified by the IEEE standard 802.15.4 (2006). The current MAC implementation however, lacks sleep features. The radio is assumed to be always active, which is not true for nodes deployed in the field which usually employ some sort of sleep/wake mechanism in order to conserve energy. The goal of this project is therefore to develop a realistic MAC model and link it with the energy model in order to simulate realistic scenarios where a node’s energy can get depleted resulting in changes in the network topology. Most of WSN research is focused on developing energy efficient protocols at each level of the protocol stack and hence this project, along with allowing for more realistic simulations would also help researchers to test the energy efficiency of their protocols running on top of 802.15.4 nodes.
  • About me: I’m currently in the final year of B.E. (Electrical and Electronics) at BITS Pilani, India. My main research interest is in networked embedded systems, specifically WSNs and IoT.



  • 802.15.4 Energy Model:

Development of LrWpan Radio Energy model that models the energy consumption of 802.15.4 nodes.

  • 802.15.4 Phy layer support for duty cycling MAC protocols:

Modifications to the LrWpanPhy model in order to support linking with the LrWpan Radio Energy model.

  • RDC layer for the 802.15.4 MAC:

RDC layer for testing the newly developed Energy model - development of the ContikiMAC Radio Duty Cycling Protocol is planned.

  • Linking the RDC layer with the 802.15.4 Energy Model

Integration of the 802.15.4 Energy Model and the new 802.15.4 MAC Model.

Researchers can test their own protocols by developing their own models and linking with the developed 802.15.4 Energy Model.


  • Week1
* Define the various classes. Implement the energy model.
  • Week2-3
* Modify the Phy model. Define and implement the PhyListener for the energy model. 
* Define the energy model test class for testing the energy model. Test and document.
  • Week4-5
* New Mac layer implementation.
  • Week6-7
* Test the working of the newly developed MAC model and check the flow of outgoing and incoming packets. 
* Debug any issues that may arise.
  • Week8-9
* Start development of the ContikiMAC model. 
* Test the working of ContikiMAC.
  • Week10-11
* Integration of the energy module and the Mac module. Test the basic implementation of ContikiMAC, along with the energy model. 
* Validation of the model.
  • Week12
* Define scope for future work. Optimizations. Buffer period.

Energy Model

The energy model consists of 2 major components:

  • Energy source.
  • Device energy model.

The Device energy model is used to represent the energy consumed by a specific device on a node (eg. a LrWpan radio device). The LrWpanRadioEnergyModel class (derived from DeviceEnergyModel class) will model the energy consumption due to the LrWpan radio device.



Radio state machine:


The node's energy consumption is modeled as a function of the three main states of the radio transceiver:

  • Transceiver disabled (TRX_OFF)
  • Transmitter enabled (TX_ON)
  • Receiver enabled (RX_ON)

For most radios, there is no difference between *_ON and BUSY_* states with respect to the radio transceiver circuitry. Hence, the energy consumed in these states is approximately the same.

The amount of energy consumed by the radio depends on the current draw of the state and the time spent in that state. The current draw for various states can be found in the datasheets of radio transceivers. For example, for CC2420:

  • TRX_OFF (sleep): 426 uA
  • TX_ON (transmit): 17.4 mA @ 0 dBm
  • RX_ON (recv/idle): 18.8 mA

The EnergySource is updated periodically or after each transition, using the formula stateDuration * stateCurrent * supplyVoltage

Note: The transient energy when switching from one mode to another also impacts the total power consumption. Hence, it is important to precisely characterize the transition time between transceiver states. In the Three States Model described, six different transitions are possible:

  • TRX_OFF -> TX_ON and TX_ON -> TRX_OFF
  • TRX_OFF -> RX_ON and RX_ON -> TRX_OFF
  • TX_ON -> RX_ON and RX_ON -> TX_ON

The state transition energy is evaluated by multiplying the transition time by the power in the arrival state.

Weekly Progress

Week 1 (May 25, 2015 - May 31, 2015)

  • Implemented and tested LrWpanRadioEnergyModel with the four basic states.
  • Linked the LrWpanPhy with the LrWpanRadioEnergyModel and tested energy source update after each PHY transition.

Classes added/modified:

  1. LrWpanRadioEnergyModel (extends DeviceEnergyModel and LrWpanPhyListener)
  2. LrWpanPhyListener
  3. LrWpanPhy

Week 2 (June 1, 2015 - June 7, 2015)

  • Modified the Energy model- added the "Transition" state.
  • Implemented precise state transition timings and energy depletion handler.

Week 3 (June 8, 2015 - June 14, 2015)

  • Completed and tested Energy model.
  • Definition of base class for the common MAC functions (partially done).

Week 4 (June 15, 2015 - June 21, 2015)

  • Split the LrWpanMac class in two: separating the parts common to any 802.15.4 MAC and the parts specific to beacon-enabled/nonbeacon-enabled modes of operation.
  • Defined two new classes (extending the LrWpanMac base class):
  1. LrWpanNullMac, for the standard 802.15.4 MAC implementation (beacon-enabled/nonbeacon-enabled modes of operation)
  2. LrWpanContikiMac, for the ContikiMAC implementation
  • Implemented the ContikiMAC sleep schedule and wakeup procedure (successive CCAs followed by packet reception or sleep).

Week 5 (June 22, 2015 - June 28, 2015)

Implemented and tested ContikiMAC basic protocol, includes:

  • Periodic sleep/wake
  • Consecutive CCAs after wake-up to detect packet: Sleep if channel idle, Wait and receive packet if busy
  • Broadcast (Continuous transmission for length of sleep period)
  • Unicast (with and without ACK option)

Midterm Report

Work done until GSoC midterm review:

  • The LR-WPAN Energy model

This model tracks state changes in the LR-WPAN PHY and updates the energy source accordingly.
Note that the LrWpanRadioEnergyModel and the LrWpanPhy need to be linked using the AttachPhy() method provided in the LrWpanRadioEnergyModel class.

Energy model
- lr-wpan-radio-energy-model.h
Modified LrWpanPhy; Implemented LrWpanPhyListener Class
- lr-wpan-phy.h
  • Split the LrWpanMac class, defining two new classes: the base class and another extending the base class
LR-WPAN MAC base class
- lr-wpan-mac.h
802.15.4 MAC class
- lr-wpan-nullmac.h
  • ContikiMAC model, extending the LrWpanMac base class
- lr-wpan-contikimac.h
  • Modified LrWpanNetDevice to use the ContikiMAC model
- lr-wpan-net-device.h
  • Tests

The lr-wpan-phy-test (modified) and lr-wpan-data (modified) example scripts were used to test the working of the energy model.
The lr-wpan-data (modified) example script is being used for testing the ContikiMAC implementation.

Code repository :

  • Post-midterm plans:
    • ContikiMAC fast sleep and phase-lock optimizations
    • Realistic Mac queue size (currently the Mac allows infinite packets to be queued)
    • Test the energy model along with ContikiMAC
    • Modify LrWpanNetDevice to set desired MAC


Week 6 (June 29, 2015 - July 5, 2015)

Week 7 (July 6, 2015 - July 12, 2015)

Week 8 (July 13, 2015 - July 19, 2015)

  • Test for Energy model
  • Max MAC queue size

Week 9 (July 20, 2015 - July 26, 2015)

  • Resolved issues in ContikiMAC code
  • ContikiMAC feature additions

Week 10 (July 27, 2015 - Aug 2, 2015)

  • Completed and tested ContikiMAC phase-lock optimization
  • Code refactoring

Final Review

LrWpan Energy Model:

  • Three States Model (recv/idle, transmit, sleep) with state transitions
  • States corresponds to RX_ON/BUSY_RX, TX_ON/BUSY_TX and TRX_OFF states of radio transceivers
  • LrWpanPhyEnumeration values used to represent states with IEEE_802_15_4_PHY_UNSPECIFIED being used for the TRANSITION state
  • ON/OFF and TX/RX switching time taken into account

ContikiMAC radio duty cycling protocol, including:

  • Periodic sleep/wake
  • Periodic and stable wake-up interval
  • Consecutive CCAs after wake-up to detect packet: Sleep if channel idle, Wait and receive packet if busy
  • Broadcast (Continuous transmission for length of sleep period)
  • Unicast (with and without ACK option)
  • Transmission Phase-Lock


  • Refactored 802.15.4 Mac


  • (Modified to include energy model)

Code review:


  • Part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low-Rate Wireless Personal Area Networks (WPANs) [1]
  • The ContikiMAC Radio Duty Cycling Protocol [2]
  • An Energy Framework for the Network Simulator 3 (ns-3) [3]
  • Energy efficiency of the IEEE 802.15.4 standard in dense wireless microsensor networks: modeling and improvement perspectives [4]
  • Impact of Switching Latency Times in Energy Consumption of IEEE 802.15.4 Radio Transceivers [5]