## 4 MAC Layer in WMSN
### MAC Layer's Main Functions
It adaptively adjusts the contention window depending on the QoS requirements and wireless channel characteristics and dynamically adjusts its duty cycle based on the major application traffic to preserve the sensor energy without sacrificing QoS provisioning. It updates the contention window to achieve trade-off between the period wasted on the waiting for the back-off counter to expire and the collisions because of the simultaneous transmissions of more than one sensor nodes. Subsequently depending on the traffic class, it differentiates the packets into different types and updates the contention window in different amount; for higher priority traffic classes (like streaming video) the increment step size is set to be smaller than that of the lower priority while the decrement step size is set to be greater than that of the lower priority. In this way, throughput differentiation between different traffic classes can be easily controlled and adjusted by controlling this step size. As an example, authors in [23] consider a network where the mean capacity of the links is 100 Kbps and show how they can move from a scenario where the streaming video traffic achieves a throughput of 50 Kbps followed by the 40 Kbps throughput of lower priority classes, to a scenario in which streaming video achieves a throughput of 75 Kbps at the cost of 15 Kbps throughput for lower priority classes. They also demonstrate the throughput dynamics of different traffic classes in both the presence and absence of highest priority streaming video traffic: when the streaming video is on, it obtains 45 Kbps while leaving 40 Kbps to lower priority traffic classes. When it is switched off, lower priority classes obtain 80 Kbps and when it is switched on again, it quickly re-attains a higher throughput of 50 Kbps, at the cost of the reduction of lower priority traffic classes throughput to 40 Kbps. Similar conclusions are drawn regarding delay: the lower contention window of streaming video traffic gives it the lowest delay of 10 ms, when compared with 30 ms or 70 ms of lower priority traffic classes. For energy conservation, the proposed MAC protocol is trying to save energy by dynamically changing the duty cycle of the idle listening with the current traffic condition. Of course, in such a strategy, there exists a trade-off between energy consumption and delay. Results in [23] show this phenomena: for a pretty low latency of 10 ms the energy consumed by the protocol is close to 30 mWhr, while if a relatively high latency of 20-30 ms is allowed, the energy consumption reduces to less than 15 mWhr. A cross-layer communication approach is presented in [24], between the MAC and physical layers, to provide a better QoS for WMSN applications. It is based on the Time-Hopping Impulse Radio Ultra-Wide-Band (TH-IR-UWB) transmission techniques. While [22] improves protocols like S-MAC and T-MAC but still based on CSMA/CA, [24] takes a totally different approach and discards CSMA/CA (as COM-MAC did). This architecture tries to solve the shortcomings of using CSMA/CA for the MAC layer in WSN such as the variable and uncontrollable access delays from using random timer, idle listening from using carrier sense, and increased energy consumption due to for example hidden node problem with the objective of providing QoS for WMSNs. An evaluation through simulation is performed for a network of 49 nodes, taking into account two different groups of traffic flows with different QoS demands (flows in group 1 require 100 Kbps bandwidth, 100 ms. end-to-end delay, and 0% PER while flows in group 2 have 500 kbit/s bandwidth demand, 100 ms end-to-end delay and can admit 10% PER. Results show that sources in group 1 have a throughput of exactly 100 kbit/s, while sources in group 2 show an average throughput of about 480 kbit/s, as some packets are lost. While flows in group 1 do not lose packets, flows in group 2 lose approximately 4% of the packets, which is still below the application requirement.