# Sensor Media Access Control

Sensor Media Access Control(S-MAC) is a network protocol for sensor networks. Sensor networks consist of tiny, wirelessly communicating computers (sensor nodes), which are deployed in large numbers in an area to network independently and as long as monitor their surroundings in group work with sensors, to their energy reserves are depleted. A special form of ad hoc network, they make entirely different demands on a network protocol (for example, the Internet) and therefore require network protocols specially build for them (SMAC). Sensor Media Access Control specifies in detail how the nodes of a sensor network exchange data, controls the Media Access Control (MAC) to access the shared communication medium of the network, regulates the structure of the network topology, and provides a method for synchronizing.
Although today primarily of academic interest, S-MAC was a significant step in sensor network research and inspired many subsequent network protocols. It was introduced in 2001 by Wei Ye, John Heidemann and Deborah Estrin of the University of Southern California and was intended to conserve scarce, non-rechargeable energy resources of sensor nodes. The development was supported financially by the US military agency DARPA under the project Sensor Information Technology (Sensit).

## Protocol Structure

The protocol is based on rendezvous technology, which is also used in other areas of computer science. A network node that wants to send a message first sends a send request (RTS, request to send) to the addressee. If it is ready to receive the message, the addressee responds with a send confirmation (CTS, clear to send). The sender then sends the actual data packet, which the recipient acknowledges with an acknowledgement (ACK). This agreement on data exchange assures the sender that the addressee is really listening and enables the recipient to reject a data transmission without doing anything because he is currently communicating elsewhere.
The rest of the protocol is divided into three task areas: Daily Routine, Communication Interference and Message Transmission.

### Daily Routine

Sensor nodes have the ability to switch to a standby mode in which all components are switched off except for the clock. In this "sleep phase", their energy consumption is minimal, but they are inactive and in particular cannot receive any messages. S-MAC gives the sensor nodes a fixed "daily routine" with regular wake and sleep cycles. As many nodes as possible should follow the same daily routine in order to ensure secure communication during the common waking time.
The daily routines are coordinated via synchronization impulses (SYNCs), short messages with the following content: "It is now ... o'clock. I'm going to sleep in x seconds." After switching on, each sensor node waits for a SYNC message from another node. If it does not receive one, it sends one itself after a random period of time. Whoever receives a SYNC adapts to the daily routine specified in it. If it was the first SYNC received, it determines the time difference d between its current time and the time of the message and sends a new SYNC with the following content: "It is now ... o'clock. I'm going to sleep in x - d seconds." Each node remembers the daily routines of its neighboring nodes in order to establish contact by breaking with its own daily routine if necessary.
As several synchronization pulses can start simultaneously or at different times at different ends of the network, the network can break down into groups that follow different day and night rhythms. Sensor nodes are then located at the boundaries of these groups, which follow the daily routines of all neighboring networks. Although this ensures communication between the node groups, as the border nodes have more waking times than inner nodes, they consume more energy and fail earlier.
Even electronic clocks are never completely synchronized. It is therefore necessary to prevent the clocks from gradually "drifting apart" by means of renewed synchronization pulses. To achieve this, S-MAC divides the waking phase into two sub-phases: The shorter first is intended for sending and receiving synchronization messages, the longer second for the actual data exchange.
Frequently renewed synchronization pulses also make it possible to add new nodes to the network during continuous operation. They receive a SYNC from the existing network and adapt to the daily schedule received.

### Communication Problems

Communication problems in computer networks lead to data loss and energy waste and must therefore be avoided. S-MAC's rendezvous scheme inherently reduces the problem of hidden stations, other components of the protocol to avoid other interference are described below.
Data collisions occur when two nodes transmit simultaneously over the common communication medium: The signals overlap and both messages become unusable. To avoid collisions, S-MAC relies on physical and virtual carrier sense, i.e. the ability to exclude occupancy of the communication medium before transmission. Physical carrier sense refers to the actual brief interception of the medium in order to rule out any other use, while virtual carrier sense refers to the anticipation of other communication based on previously announced transmission requests.
The virtual carrier check also avoids overhearing. With overhearing, a node wastes energy because it listens to data exchange that is not intended for it and that it cannot do anything with. The virtual carrier check is implemented by simultaneously communicating the length of the message to be sent in each send request. Listening nodes can deduce from this how long the communication medium will be occupied after the start of the data transmission and can go to sleep for this time. This is implemented with the help of a network allocation ve ctor (NAV). The NAV is set to the value specified in the transmission request and is gradually counted down using a timer. If the NAV reaches the value 0, the medium is free according to the virtual carrier sense and the node is woken up. After reassurance with the physical carrier sense, the node can then initiate its own data transmission.

### Message transmission

In computer networks, it is common to split large contiguous data units into small packets or fragments. If an error occurs when transmitting a large data unit, all data must be sent again; if a transmission error occurs in a packet, it is sufficient to repeat the individual data fragment. This approach is also followed with S-MAC. Normally, the rendezvous scheme would now be applied at packet level, i.e. each individual packet would be confirmed with a complete set of rendezvous messages RTS, CTS and ACK. This unnecessary overhead is reduced in S-MAC by sending all contiguous packets one after the other, so that only one RTS and CTS are required per complete data unit.
The receiver confirms each packet received with an ACK, and if this is not received, the sender repeats the last fragment. It would also be possible to limit this to a single ACK at the end of the overall message, but the developers have deliberately decided against this in order to provide reinsurance against the Hidden Station communication error: The continuous sending of ACKs prevents nodes in the recipient's environment from starting a communication, even if they are unaware of the communicating parties' RTS-CTS exchange. For a further improvement, S-MAC recommends that the expected remaining duration of the data exchange is also specified in each packet and ACK; newly added or "incorrectly" awakened nodes can thus go back to sleep.