A Mac Protocol Implementation for Wireless Sensor Network

IEEE 802.15.4 is an important standard for Low Rate Wireless Personal Area Network (LRWPAN). The IEEE 802.15.4 presents a flexible MAC protocol that provides good efficiency for data transmission by adapting its parameters according to characteristics of different applications. In this research work, some restrictions of this standard are explained and an improvement of traffic efficiency by optimizing MAC layer is proposed. Implementation details for several blocks of communication system are carefully modeled.The protocol implementation is done using VHDL language.The analysis gives a full understanding of the behavior of the MAC protocol with regard to backoff delay, data loss probability, congestion probability, slot effectiveness, and traffic distribution for terminals. Two ideas are proposed and tested to improve efficiency of CSMA/CA mechanism for IEEE 802.15.4 MAC Layer. Primarily, we dynamically adjust the backoff exponent (BE) according to queue level of each node. Secondly, we vary the number of consecutive clear channel assessment (CCA) for packet transmission. We demonstrate also that slot compensation provided by the enhanced MAC protocol can greatly avoid unused slots. The results show the significant improvements expected by our approach among the IEEE 802.15.4 MAC standards. Synthesis results show also hardware performances of our proposed architecture.


Introduction
IEEE 802.15.4 standard is in increasing use for a diverse range of embedded wireless sensing and control applications.This standard [1] is uniquely designed to meet the requirements of the Low Rate Wireless Personal Area Network to enable Wireless Sensor Network (WSN) applications.WSNs are adopted in multiple domains for monitoring industrial, medical, or environmental world.In fact, they add capabilities to survey objects and communicate information about them.Sensor networks try to introduce low energy consumption MAC protocols.MAC layer in the sensor nodes presents a number of module consumers of energy.Particularly, to access the channel, the IEEE 802.15.4 MAC protocol employs CSMA/CA algorithm and there is a high probability that collision and retransmission occur.The 802.15.4 beacon enabled mode makes many collisions.If a collision occurs, CSMA/CA algorithm executes retransmission operation.However, in WSNs, transmit operations consume high energy.
Many contributions in the literature have been focused on enhancing the MAC protocol in order to minimize energy consumption and improve the network life time.The research idea proposed in [2] shows that the network lifetime can significantly be prolonged by applying a distributed clustering approach that takes the advantage of load balance.Another approach to reduce the number of data transmissions in order to save energy is presented in [3].The basic idea of the proposed solution is to prevent unnecessary awakenings of the node by making its wakeup time according to information collected from its neighbors.The nodes work/sleep scheduling strategy is also utilized in [4].It exploits the dependencies to reduce the number of nodes required to work for sampling and data transmission and prove that such reduction is bound to save energy.Proposed strategies cited below are based on reducing the number of data transmission.To achieve this aim, supplementary exchanges of signalization packet between nodes are needed.In this paper, we demonstrate the importance of decreasing not only data transmission but also retransmission count caused by the behavior of CSMA/CA procedure.Thus, MAC protocol can guaranty energy saving requirements by minimizing congestion probability, backoff delay, and a number of retransmission.Details of implementation of our proposal solution to enhance a channel access algorithm for IEEE 802.15.4 LRW-PAN are exposed in this paper.The proposed algorithm considers a star network topology where a single central controller, called the PAN coordinator, is within a hop from every node.To access the channel, each node sets defaults value of BE (backoff exponent) and CW (contention window).During traffic transfer these parameters are modified dynamically depending on queue state and rate transmission.So the backoff delay in total networks is decreased significantly.Our primary focus is to propose a VHDL algorithm to develop the IEEE 802.15.4 MAC protocol for data transmission.The developed algorithms are simulated and validated in a star topology where there are multiple transmitters and a single receiver.After that we evaluate performances of MAC protocol under enhanced conditions of CSMA/CA algorithm.
The behavior of the proposed CSMA/CA algorithm is simulated then synthesized and simulated once more using Xilinx ISE.FPGA was adopted due to its parallel architecture and flexibility in implementation.An FPGA is a semiconductor device containing both programmable logic components and programmable interconnects.This aspect provides the advantage of a simple configuration of the hardware structure inside it.It also offers the opportunity to users to form their own structures in an FPGA to handle a specific application with optimal performance.
The structure of the paper is organized as follows: Section 2 describes some characteristics of IEEE 802.15.4.Section 3 explains the MAC protocol specifications.Section 4 gives details of the CSMA/CA algorithm.In Section 5, we present an overview of the related works.This section identifies some problems in the current standard and presents proposed solutions in the literature.Section 6 describes the proposal explanation to improve the MAC protocol of IEEE 802.15.4.In Section 7, we give details of different functional block descriptions and interactions of CSMA/CA algorithm.In Section 8, our simulation results from various scenarios are presented, explained, and evaluated.Hardware results are introduced in Section 9. Finally, Section 10 concludes the paper and gives a vision to the future work.

Overview of IEEE 802.15.4
2.1.Device Types.Two different types of devices are defined in an IEEE 802.15.4 network.A Full Function Device (FFD) supports the protocols of the wireless standard defined for WSN.A Reduced Function Device (RFD) provides limited functionality with the low cost and complexity.It is generally used for the network edge devices with very low power consumption.
When using a star topology, a unique central FFD device is defined and operates as a PAN coordinator.This coordinator will manage the whole network and all data transmitted to any destination have to pass through it.In consequence, it required much more memory and power.This technology operates on the same 2.4 GHz ISM band as WiFi, Bluetooth, and WiMax.Depending on the environment and the power used for transmission, IEEE 802.15.4 compliant wireless devices are expected to transmit in a range of 10 to 75 meters.The ZigBee Alliance is a group of over 400 member companies that maintain and publish technical standards.ZigBee is a registered trademark of ZigBee Alliance.IEEE defines the physical and medium access layers while the ZigBee Alliance defines network and application layers.The group recognizes that the coexistence of different wireless technologies on the same frequencies can have a significant impact on network operations [5].

2.3.
The MAC Layer.The 802.15.4 standard defines data link layer (DLL) and physical layer (PHY) protocols for supporting sensor devices with minimal power consuming and operating in limited area.The two layers provide the reliable communication between the nodes of the network by avoiding the collisions to improve the efficiency [6].The DLL is divided into two sublayers, the medium access control (MAC) and logical link control (LLC) sublayers.The LLC is standardized in IEEE 802.2 and is common among the IEEE 802 standards.The MAC layer provides an interface between upper layers and the PHY layer.It is responsible for frame validation using acknowledged frame delivery.It is also in charge of maintaining nodes synchronization, controlling the association, and choosing the Guaranteed Time Slot mechanism.Moreover, the MAC layer handles channel access employing the CSMA/CA mechanism.The CSMA/CA protocol is an important mechanism for channel access, considering low data rate adopted in 802.15.4.This mechanism evaluates the channel and allows data packets to be transmitted if the condition is suitable (free of activities).Otherwise the algorithm shall back off for certain periods before assessing the channel again.Details of MAC layer characteristics are presented in the following paragraphs.

Overview of the IEEE 802.15.4 MAC Protocol
In the following we will describe the IEEE 802.15.4 MAC sublayer since our proposal is an enhancement of it.type of packet he just received and how the address information is stored.Address field can be left out or consists of up to 20 bytes depending on the 8 type of frame.
(ii) A variable length frame body, which contains information specific to the frame type.
(iii) A frame check sequence (FCS), which contains a Cyclic Redundancy Code (CRC) checksum of the MPDU.
The frame structures have been designed to keep the complexity to a minimum while at the same time making them sufficiently robust for transmission on a noisy channel.Each successive protocol layer adds to the structure with layer specific headers and footers.This standard defines four frame structures.
(i) Beacon frame, used by a coordinator to transmit beacons.
(ii) Data frame, used for all transfers of data.
(iii) Acknowledgment frame, used for confirming successful frame reception.
(iv) MAC command frame, used for handling all MAC peer entity control transfers.

Beacon Frame.
In beacon enabled mode, the beacon is transmitted at the start of slot 0 without the use of CSMA/CA.In fact, the coordinator periodically sends beacons to synchronize all attached devices, identify the PAN, and announce the superframe structure to manage the communication from end devices to the coordinator.The first part of the superframe is slotted and CSMA/CA is used as channel access mechanism, while the second is composed of slots reserved for particular nodes by the network coordinator.Beacon contains the information on the addressing fields, the superframe specification, the GTS fields, the pending address fields, and so forth.In non-beacon enabled mode, no beacon and superframe are transmitted.The channel access is based on unslotted CSMA/CA.Beacon frame format is depicted in Figure 2.  CSMA and GTS (Guaranteed Time Slot) protocols.In GTS scheme, it uses TDMA protocol to reduce the idle listening that decreases energy consumption considerably.When a device wishes to transfer data in a non-beacon enabled mode, it simply transmits its data frame, using unslotted CSMA/CA, to the coordinator.The coordinator acknowledges the successful reception of the data by transmitting an optional acknowledgment frame.The transaction is now complete.

Communication
When a device wishes to transfer data to a coordinator in a beacon enabled mode, it first listens for the network beacon.When the beacon is found, the device synchronizes with the superframe structure.At the appropriate time, the device transmits its data frame, using slotted CSMA/CA, to the coordinator.The coordinator may acknowledge the successful reception of the data by transmitting an optional acknowledgment frame.These sequences are presented in Figure 3.

Non-Beacon Enabled Mode.
In non-beacon enabled mode, the generation of periodic beacon frames is disabled.So, devices simply transmit data frames using unslotted CSMA/CA to the coordinator.The PAN coordinator is responsible for handling only device association/disassociation.The advantage of the non-beacon enabled mode, with regard to WSN application requirements, is that it easily allows scalability and self-organization.However, the non-beacon enabled mode does not provide any guarantee to deliver data frames, specifically within a certain deadline.

Beacon Enabled Mode.
Beacon enabled mode makes the IEEE 802.15.4 protocol sufficiently flexible and able to perform the needs of a large variety of applications.It has the ability to provide guaranteed real time performance to the network.This mode offers the possibility of allocating/deallocating time slots in a superframe, called Guaranteed Time Slots (GTSs), and providing predictable minimum service guarantees.
The beacon enabled mode uses beacons which are periodically sent by the PAN coordinator to identify its PAN and synchronize nodes that are associated with it.The beaconing synchronization mechanism in IEEE 802.15.4 enables networks to work under a controllable duty cycle to achieve better energy efficiency compared to the nonbeacon enabled mode.In the case of beacon enabled mode, a superframe format is considered.The description of the superframe structure is presented in a following paragraph.
Each superframe is delimited by beacon frames.The Beacon Interval (BI) defines the time between two consecutive beacons and includes an active period and, optionally, an inactive period.The superframe is divided into 16 equally sized time slots, during which frame transmissions are allowed.During the inactive period (if it exists), all nodes may enter in a sleep mode, thus saving energy.

Duty Cycle.
When designing a MAC layer for WSN high attention is considered to reducing power consumption since energy presents a critical resource in Wireless Sensor Networks.S-MAC, T-MAC, U-MAC, and OD-MAC are duty cycle based MAC protocols that can specify sleep and wakeup times for network nodes within the frame [7].The IEEE 802.15.4 provides also a mechanism for power saving.This feature is possible only in beacon enabled mode when the BO (macBeaconOrder) is different than the SO (macSuperframeOrder) (SO < BO).It makes a sleep/awake mechanism since nodes in WSN do not need to stay awake all the time.They may operate for a short time to send or receive collected data.This mechanism allows the devices to save power during sleep time.The PAN coordinator is the only device that may have to stay active all the time if it manages many clusters of nodes; in that case it should be mainly powered.
According to the standard, typical applications for IEEE 802.15.4 devices are anticipated to run with a very low duty cycle (under 1%).If the duty cycle is not set correctly (e.g., too short), it may increase the transmission latency.Since during sleep time data may have to wait until the active portion of the next superframe to start the transmission, this time can be computed as the ratio between the Superframe Duration and the Beacon Interval that can be related to BO and SO via the following equation: where macBeaconOrder (BO) gives the value of the interval at which the coordinator must transmit beacon frames.macSuperframeOrder (SO) gives the length of the active portion of the superframe, which includes the beacon frame.The active period is defined as follows: SD = a Base Superframe Duration * 2SO symbols for 0 ≤ SO ≤ BO ≤ 14.
If SO = BO ⇒ SD = BI and then the superframe is always active.If BO = 15, PANs operate in a so-called non-beacon enabled mode without using the superframe structure.In this case, the value of SO is ignored.

The Inactive Portion.
The inactive period duration is determined by SD and BI parameters.In order to save energy, nodes may enter a low power (sleep) mode during the inactive portion.Saving energy may be achieved by imposing large inactivity periods leading, however, to increasing communication latencies.Hence, BO and SO are key parameters for balancing the real time performance and energy savings in IEEE 802.15.4 based networks.The sleep portion is also optional and it is used by networks where nodes do not need to be awake all the time.(1) CAP.In the CAP, data transmission of any device shall follow a successful execution of a slotted CSMA/CA mechanism.Two data transfer models are defined in the CAP, the indirect transmission for downlink data and the direct transmission for uplink data.The Contention Access Period (CAP) length is calculated by the following equation:

The Active
However, a minimum length of the CAP with aMin-CAPLength (440) symbols must be guaranteed and remains for contention based access of other networked devices or new devices wishing to join the network.An exception to this minimum shall be allowed for the accommodation of the temporary increase in the beacon frame length needed to perform GTS maintenance.
(2) CFP.Contention Free Period (CFP) is period where the channel is reserved and can be used exclusively by the reserving node.Since random access is not appropriate for real time periodic traffic, the CFP period is optional and used by low latency applications or applications requiring specific data bandwidth.In fact, it is activated upon request from a node to the PAN coordinator for allocating time slots depending on the node's requirements.Upon receiving this request, the PAN coordinator checks whether there are sufficient resources and, if possible, allocates the requested time slots.These time slots are called Guaranteed Time Slots (GTSs) and constitute the CFP.They are always placed on top of the active superframe starting at a slot boundary just following the CAP.If the available resources are not sufficient, the GTS request fails.The corresponding node then sends its data frames during the CAP.
GTS technique is based on polling that is administered by a centralized point coordinator.Each node can allocate up to two GTSs (one for receive and one for transmit).The PAN coordinator may allocate a maximum of seven GTSs at the same time, and one GTS may occupy more than one superframe slot.The allocated GTSs shall be located within the CFP and occupy contiguous slots.Therefore, the CFP shall grow or shrink dynamically within the active portion depending on the total length of all of the current existing GTSs.TDMA mechanism is applied when using GTS management.

CSMA/CA
The Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) is widely employed in wireless networking due to its simplicity and performance efficiency.It has been adopted as a medium access control protocol by many standards such as the IEEE 802.unstable channel conditions and higher capacity than other random access algorithms [7].
The slotted CSMA/CA shall first initialize the NB, the CW, and the BE.The BE shall be initialized to the value of macMinBE.Then, the slotted CSMA/CA locates the boundary of the next backoff period.It shall delay for a random number of complete backoff periods.Next, it requests that the PHY performs a CCA.This last shall start on a backoff period boundary.In detail, after backoff counter expires (reaches zero), the node must perform two clear channel assessments (CCAs) before trying to transmit.The two CCA operations ensure prevention of potential collisions.Transmission occurs if both CCAs are successful (sense the channel idle).If the channel is assessed to be busy, the MAC sublayer shall increment both the NB and the BE by 1, ensuring that BE shall be no more than macMaxBE.And it shall also reset CW to 2. If the value of the NB is less than or equal to the macMaxC-SMABackoffs, the slotted CSMA/CA algorithm shall back off to Step 2 in Figure 5 (random duration).If the value of NB is greater than macMaxCSMABackoffs, the slotted CSMA/CA algorithm shall terminate with a channel access failure status.If the channel is assessed to be idle, the MAC sublayer in a slotted CSMA/CA system shall ensure that the contention window has expired before commencing transmission.To do this, the MAC sublayer shall first decrement the CW by one and then determine whether it is equal to 0. If it is not equal to 0, the slotted CSMA/CA algorithm shall return to Step 3 in Figure 5.If it is equal to 0, the MAC sublayer shall begin transmission of the frame on the boundary of the next backoff period [8].Table 1 shows range and default value of BE.
Furthermore, in CSMA/CA mode IEEE 802.15.4 supports optional retransmission scheme based on acknowledgements.When retransmissions are enabled, the receiver node must send a positive acknowledgement right after receiving a data frame.If the acknowledgment is not (correctly) received by the sender, a retransmission is started unless the maximum number of retransmissions is reached.In this case, the data frame is dropped.The maximum retransmission retries can be set between 0 and 7 with a default value of 3. If a collision occurs, CSMA/CA algorithm executes retransmission operation.So it is very important to decrease retransmission count.The BP period, called backoff period, is equal to 80 bits or 0.32 ms.The BP must align with the beginning of each superframe.All CSMA/CA operation must align also with BP period.Prior to transmission the node must ensure if there is sufficient time left in the CAP for the transmission and any consecutive acknowledgments packets, if positive feedback option is selected.
For the unslotted CSMA/CA, the algorithm is the same as slotted CSMA/CA with the exception of the absence of CCA step.The work presented in this paper considers only  the slotted CSMA/CA of IEEE 802.15.4.However, the proposed algorithms can be easily used to the case of the unslotted algorithm because their basic operations are similar.

Related Work
Nowadays 802.15.4 is a key technology for the development of Wireless Sensor Networks (WSNs).Consequently, many researches in this field have emerged.Performances are generally verified by simulation behavior.Many of these researches have studied the performance of CSMA/CA mechanism and proposed different backoff algorithms.Some of work done by given authors is overviewed and related summary of their propositions is given in the following paragraphs.
In most research works, the performance of improved IEEE 802.15.4 MAC protocol was evaluated and compared with existing protocol using simulation tools such as NS2, OPNET, or OMNET.Paper [9] presents an intensive survey of the works findings done by various researchers on IEEE 802.15.4/ZigBee standards, and many of the works pointed out that the limitation of such networks is the MAC unreliability problem.Authors of this paper explain the root causes for the unreliability problem and found that they originated from the CSMA/CA MAC protocol, which is unable to efficiently manage contentions for channel access.They have listed the possible solutions that can alleviate the unreliability problem such as predefined parameter settings and adaptive mechanisms.As well, the work presented in [10] aimed to compare three different algorithms for deriving the optimal settings of 802.15.4 sensor networks so as to guarantee the reliability requirements of the application with minimum energy consumption.The considered algorithms take different approaches, namely, offline computation, modelbased adaptation, and measurement-based adaptation.In paper [11] a study of the backoff exponent (BE) management in CSMA/CA for 802.15.4 is conducted.This study shows the following: the BEs determine the number of backoff periods the device shall wait before accessing the channel.The power consumption requirements make CSMA/CA use fewer BEs which increase the probability of choosing identical BEs by some devices.As a result, waiting for the same number of backoff periods can be happen.This inefficiency degrades system performance at congestion scenarios by bringing in more collisions.Then, it is important to be cautious when modifying BE parameter setting.Work presented in [12] has studied the impact of various parameters on the network throughput.It has shown that high superframe orders provide better network throughput than low superframe orders.On the other hand, low SO and BO values result in lower average delays in case of high offered loads.Also, increasing macMinBE will lead to relatively lower network throughput but to significantly higher success probability thanks to more efficient collision avoidance.Moreover, an algorithm called EBA-802.15.4MAC that enhances the performance of slotted CSMA/CA algorithm is proposed in [13].The goal of this proposition is to resolve the problem of access.In fact, the nodes do not choose backoff exponent randomly as mentioned in the standard but they select values which can be 10-50% of the actual backoff delay selected by the node randomly.By applying this idea, the level of collision is minimized since the probability of two nodes selecting the same backoff period will be low.Moreover, Koubaa et al. [8] performed a simulation based evaluation of the impact of different configuration parameters, including macMinBE/macMaxBE, on the performance of beacon mode operation of IEEE 802.15.4 MAC and observed that the packet loss rate in a beacon enabled network can be reduced at the cost of increasing the packet latency by increasing the macMinBE/macMaxBE values.Furthermore, Bhat [14] observed that, under saturated conditions in beacon enabled networks of more than 4 nodes, increase in macMinBE/macMaxBE values from 3/5 to 4/6, respectively, improves the network throughput.
In [15] By computing the steady-state distribution probability of the Markov chain, an evaluation formula for throughput, energy consumption, and access latency is obtained.Further study of the parameters that influence performance including packet arrival rate, initial backoff exponent, and maximum backoff number is explained.An extension to nonsaturated traffic conditions can be found in [16].Their analysis probes that, for saturated networks, it is preferable to choose a large exponential delay backoff in order to reduce the required energy per useful bit.On the other hand, for unsaturated networks, a very small energy saving can be achieved by setting smaller backoff values.In [17], authors have proposed a simple procedure for the dynamic adaptation of several key parameters of IEEE 802.15.4 networks.Under this procedure, the 802.15.4 parameters are modified as a function of the existing traffic conditions.This paper has investigated the dynamic optimization of two key IEEE 802.15.4 MAC sublayer parameters, the superframe order and the backoff exponent.The standard defines the superframe order parameter but does not mention how to determine it.Furthermore, SO is defined as a dynamic adaptation to the network conditions, particularly to the traffic load.In this regard, a technique has been proposed, implemented, and simulated.It adjusts the size of the Contention Access Period according to the actual traffic load by reconfiguring the SO.They have also studied the collisions and access congestion problem and presented a policy to avoid them.Work in [18] suggests modifications of the coordinator function that allows the network to handle higher traffic loads and thus offers much improved performance to its clients.In this work, authors have considered the 802.15.4 network operating in beacon enabled mode with slotted CSMA/CA.Simulations presented in this paper demonstrate that considerable performance improvements can be achieved by simple changes to the operating parameters of the network.
The works studied above highlighted the problem due to the default MAC parameter settings suggested by the standard itself.Different solutions have come up to improve the performances of channel access mechanism, particularly setting a dynamic value for parameters of this mechanism.The majority of ideas are implemented by NS simulator (NS2) or other similar environments.In our work, we propose modulating a channel access algorithm CSMA/CA for IEEE 802.15.4 LRWPAN using VHDL language in order to decrease transmission delay, dropped packet, and congestion probability.Then, the verification of our proposal is made to verify the performances of improved mechanism by simulation of various scenarios but also hardware performances are given by synthesis of developed algorithms.

Proposal Explanation
A WSN is composed of sensor nodes which are placed to monitor physical phenomena.Each node defines a wireless device having sensing, communication, and computation capabilities.
Since WSN nodes are powered by nonrechargeable battery, network life time is limited.In order to improve energy saving and to enhance lifetime of the network, it is necessary to ameliorate functions such as communication protocol, access channel mechanism, and routing.In particular, the slotted CSMA/CA mechanism in beacon enabled mode is improved to overcome a number of issues which may cause serious performance degradation.Degradation factors are related to network and traffic parameters, as might be expected, and in some cases these parameters pose severe limitations on the throughput and packet delays in such networks.The goal of this work is to analyze those issues and their impact and to suggest modifications of the CSMA/CA algorithm that offer much improved traffic performances.
In this paper, we present an original work that is based on implementing the modified MAC protocol on VHDL environment.Our work is focused particularly on studying the adaptive backoff exponent (BE) management of CSMA/CA for 802.15.4.The reduced value of BEs may lead to the choice of identical BEs for different nodes.In consequence these nodes may wait for the same number of backoff slots.This often leads to degradation of system performance at congestion scenarios, due to higher number of collisions.This paper addresses the problem by proposing an adaptive mechanism to the current implementation of the backoff exponent management, based on a queue length criterion.Hence, when a queue size of a node increases over a fixed queue level, the parameter BE will be decreased to obtain a shorter backoff period.So, a queue size is checked before each transmission and BE value is adapted according to it as explained in Pseudocode 1.
As a result of the implementation, backoff delay is decreased and potential packet collisions are reduced.The result indicates the improvement in network traffic performances and shows hardware performances.
In this work, we adopt a star topology.We note that our algorithms can be exploited in any other topology by adding some supplementary functionality such as routing

VHDL Modeling of CSMA/CA Protocol
The VHDL (Very High Speed Hardware Description Language) is defined in IEEE as a tool of creation of electronics system because it supports the development, verification, synthesis and testing of hardware design, the communication of hardware design data, and the maintenance, modification, and procurement of hardware.It is a common language used for electronics design and development prototyping.After simulation analysis, hardware characteristics can be extracted from synthesis operation.
To make things easier a modeling phase is first handled before developing algorithm describing system functionalities.Modeling is an abstract representation of a physical reality.System models are created to be able to reason about certain properties of the system's behavior and to serve as a specification for the design process that will lead to a physical implementation of the system, which is compliant with the model.
In our work, the CSMA/CA is the main module that holds the behaviors of the CSMA/CA protocol.CSMA/CA module needs a waiting state when executing the protocol.It uses counters in various times for channel access control.Particularly, a node has to wait for random backoff duration before attempting carrier sensing and it has to wait for contention window slots for clear channel assessment (CCA).The functionality of counter is then implemented in this system.The waiting time is counted with respect to the clock speed used.CSMA/CA module interacts with a number of functional modules.Firstly, CSMA/CA module is a model of a protocol interactively related with the physical layer of the wireless devices.Thus, the CSMA/CA block is connected to an extra physique block in order to provide proper physique response related to the request.This extended module is useful to control the channel state.Secondly, the CSMA/CA system needs a Random Generator module.The Random Generator delivers to the CSMA/CA module a random value of integer from the range of 0 to 255.This random value is used in backoff in Step 2 of CSMA/CA algorithm.To overcome the issue of clock synchronization between various modules, the clock adapter has to be implemented in the main design.Particularly, the transmission block must have a clock speed equal to half of read and write function manager.The block diagram in Figure 6 gives a general overview of CSMA/CA model with different blocks matched.

Simulations and Results
We contribute to the better understanding of the protocol behavior by presenting a set of results of simulation experiments.Our results outline the capabilities of this protocol in the selected scenarios but also the limitations.
In particular, we investigate the dependency of the protocol on protocol parameters such as the BE and CCA.We examine also the enhancement of MAC protocol based on slots compensations.Our results can be used for planning and deploying IEEE 802.15.4 based sensor networks with specific performance demands.
ModelSim design software is used for the simulation analysis.We have conducted, for our simulations test, a variety of scenarios to show the impact of varying the macMinBE value on different performance metrics as the backoff delay, congestion, and drop probability.In these simulations, other CSMA/CA parameters are maintained at their default values as mentioned in Table 2. Obtained results show that the increase in macMinBE can significantly reduce the packet loss probability and the congestion probability (Figure 7).However, when the traffic load increases, the backoff delay becomes high.In consequence, the number of unexploited slot becomes important.Figure 8 presents backoff delay function of macMinBE parameter variation.Delay is considered a typical performance metric that can be considered.It can be estimated by the number of clock  cycles that synchronize process instructions.According to clock period, time of simulation can be provided.
The drop probability, congestion probability, and backoff delay are also studied under CCA number variation.Figure 9 shows that the increase of drop probability is remarkable when CCA number is high.However, a low drop probability is observed when CCA number is small.Packet drop can be caused by diverse factors such as macMaxCSMABackoffs and macMaxFrameRetries.At various values of CCA, the congestion probability is variable as seen in Figure 9.This is because it depends on random number of backoff technique.We note that for this figure the values of macminBE and macmaxBE are maintained, respectively, to 3 and 5.
Figure 10 demonstrates that backoff delay is decreasing when using low CCA number.It is still important to test if we obtain an enhancement behavior of traffic conditions when considering a dynamic configuration of CCA number.
In this work, we have implemented a dynamic variation for BE parameter based on traffic conditions.BE parameter is reduced to macMinBE in the case a node has a queue length exceeding a fixed level and it obtained a high number by random stage.We have considered, in the verification phase, different scenarios for data transfer.Simulations show that best results are obtained for cases having throughput stability.When there is very variable traffic, it becomes more difficult to make decision in order to reduce BE parameter; also congestion probability can increase enormously.Figure 11 proves the improvement obtained for our dynamic variation of BE parameter over the static settings of this parameter for application with stable traffic.The improvement as can be seen in Figure 11 is significant and shows the importance of a dynamic configuration of MAC parameter value.Simulations made show that drop probability along simulation decreases about 15%.The simulation results under the modified proposal show the improvement of performance of our dynamic BE variation algorithm over the standard default settings as exposed in Figure 12.The performance curves for the modified scheme are labeled with prefix dynamic BE.The modification indeed leads to lower latencies than the standard scheme for various traffic loads.
As backoff mechanism is based on random technique, nodes that have data frame to transmit have to wait for undetermined time depending on the random number obtained  and on other concurrent nodes.In consequence, vacant slots can appear in a superframe although there are nodes waiting to transmit their data.In this way, we proposed a slot compensation scheme in order to enhance the transmission efficiency in dynamic traffic conditions.The idea is to avoid the existence of unused slot by monitoring the exploit of every slot.When the channel is still idle and the remaining time is only sufficient to transmit data frame and to execute CCA phase, nodes with FIFO (First In First Out) length greater than a fixed limit pass directly to CCA phase.Several traffic scenarios are tested to verify this proposal.Simulation shows that the implementation of this idea provides a higher delivery ratio and so better performance in priority traffic processing.Figure 13 represents backoff delay behind and after slots compensation.It depicts the improvement of backoff delay and then traffic rate.However, an increase in congestion probability is inevitable in this case and it is the only defect of compensation proposal.Note that the congestion probability increase is by average of 1% (Figure 14).Compared to the advantage obtained by the proposed idea, this percentage can be acceptable and can be avoided with the improvement of the proposal in the future.The number of exploited slots is increasing by 24%.Moreover, avoiding the FIFO (First In First Out) saturation and distributing traffic in equal way to different nodes represents a great gain obtained by considering this proposal.

Performance on Hardware
For hardware implementations, a number of results can be found: an estimate of the achievable clock frequency can be obtained by finding critical paths, that is, the longest paths from a register output to the next register input.The energy consumption can be obtained by determining the time required for an operation and multiplying with the estimated power consumption.Furthermore, assumptions can be made based on the number of transistors or gates in the design.Therefore, to estimate the system hardware complexity we can show the logic layout [19].CSMA/CA model could support an operation frequency up to 200 MHz since 5 ns clock period is used for the simulation.This operation frequency is much higher than the channel bit rate.The CSMA/CA module uses 3% of the total logical element that is supported in Virtex7.This percentage shows the opportunity of integration of this module and the possibility to add other functionalities of MAC protocols.Table 3 summarizes the obtained specifications.
Simulation conducted after synthesis operation permits to verify the module functionality.The CSMA/CA was  stimulated with respect to the IEEE 802.15.4 standard.Figure 15 presents a full view of the obtained chronograms after synthesis for one scenario test.The execution of CSMA/CA module spends duration of 371.166 ns that includes the backoff delay.The duration behind synthesis operation (RTL level) is less.This result is explicated by the influence of the timing constraint in Xilinx ISE.For example, the signal "transmission" that alerts the transmission block to begin packet transmission takes its value ("1") after a delay of 0.553 ns compared to clock signal, item that cannot be seen at RTL level.We remark also, for this scenario test, that random component takes a duration of 4.136 ns.Note that the random component is implemented in generic way to extend the width of random number as required by the backoff interval.So, its execution can make more time if width is higher.The signal "pres d" is used to indicate if there are data waiting to be transmitted in buffer.The "star csma" signal indicates the beginning of CSMA/CA procedure.This procedure can be launched only at the frontier of a slot of the superframe.If node executes successfully the CSMA/CA mechanism a signal "transmission" designates the beginning of packet transfer.

Conclusion
In the next few years, it is expected that Low Rate Wireless Personal Area Networks (LRWPANs) will be used in a wide variety of embedded applications [14], including home automation, industrial sensing and control, and environmental monitoring and sensing.Characteristics of WSN as topologies and MAC protocol configuration depend on application specificity.Consequently, it is very difficult to provide a generic solution for all types of applications.In this paper, we have proposed and implemented a MAC access algorithm for IEEE 802.15.4 LRWPAN based on CSMA/CA protocol.
The proposed algorithm focuses on reducing backoff delay, the probability of collision, and retransmission in total networks.The idea is based on dynamically modifying value of BE and CW parameters according to traffic state.We have also exploited unused slot time of superframe to increase the efficiency rate.
This work implements a CSMA/CA algorithm of the IEEE 802.15.4 MAC protocol to guaranty an enhancement of information transmission.The implemented protocol respects the majority of 802.15.4 MAC accommodating details and adds some modification in order to ameliorate traffic condition.IEEE 802.15.4 protocol implementation is done using VHDL language.The developed algorithm can be useful for future development in the field of IEEE 802.15.4 wireless data transmission protocol.Code implementation is developed in generic manner so that it allows modification to suit any other change requirements.
In order to evaluate the performance of proposed algorithm, we have tested a variation of some traffic parameters like transmission delay, congestion probability, dropped packet, and so forth.The proposed algorithm shows a greater amelioration than the IEEE 802.15.4.Thus, the dynamic change of CSMA/CA parameters proves that our enhanced IEEE 802.15.4 MAC protocol performs significantly better than the original IEEE 802.15.4 MAC.
For future work, we focus on implementing more efficient power saving algorithm by considering fuzzy logic method.This work can also be used to compare performance of new hardware design for wireless data transmission.

Figure 3 :
Figure 3: Data transfers in non-beacon enabled and beacon enabled transmission.

3. 3 .
Superframe Structure.Superframe structure is shown in Figure4.The superframe is bounded by two beacon transmissions.It consists of two parts, an active portion and an inactive portion.The active portion of the superframe shall be divided into 16 equally spaced slots, which are called superframe slots.The lengths of the Beacon Interval (BI) and the Superframe Duration (SD) are determined by the two MAC attributes BO and SO.The Beacon Interval defining the length of the whole superframe is defined as follows: BI = a Base Superframe Duration * 2BO symbols for 0 ≤ BO ≤ 14.
Portion.The IEEE 802.15.4 standard fixes this duration to 960 symbols (a symbol corresponds to 4 bits).This value corresponds to 15.36 ms, assuming a 250 kbps in the 2.4 GHz frequency band.The active portion of the superframe consists of Contention Access Period (CAP) and Contention Free Period (CFP).

Figure 7 :
Figure 7: Drop and congestion probability function of macMinBE.

Figure 9 :Figure 10 :
Figure 9: Drop and congestion probability function of CCA variation.
2.2.IEEE 802.15.4 and ZigBee Relationship.IEEE 802.15.4 is part of the IEEE family of standards for physical and MAC layers for Wireless Personal Area Networks (WPANs).The focus area of IEEE 802.15.4 is that of low data rate WPANs, with low complexity and stringent power consumption requirements.The standard is designed to be cost effective, low-power, and low-interference technology.

Table 1 :
11 Wireless Local Area Networks (WLANs), IEEE 802.15.3, and IEEE 802.15.4 Wireless Personal Area Networks (WPANs).The CSMACA variants employed in these standards provide robustness against Range and default value of BE.
, IEEE 802.15.4 protocol is proposed to meet the low latency and energy consumption needs in low rate wireless applications.To evaluate the IEEE 802.15.4 slotted CSMA/CA channel access mechanism, a practical and accurate discrete Markov chain model, which can dynamically represent different network loads is proposed.

Table 2 :
Specification of simulation parameters.Four sensor nodes are taken for analysis of MAC protocols.A network coordinator is connected to other three nodes through wireless channels at 2.4 GHz.Other sensor nodes collect information and send it to network coordinator.The general ZigBee specifications considered in our work are shown in

Table 3 :
Hardware specification of CSMA/CA module.