## 4 SENSED-SG Design and Protocols
### Sensed-Sg MAC Layer
When this occurs, the sender assumes the receiver is in the ON phase of its duty cycle--otherwise the receiver would not have heard and acknowledged the message. From that moment on, the sender will be able to predict when the receiver is going to enter in its ON phase before dispatching any message to it. It is worth noting that the duty-cycling mechanism only affects the radio receiving patterns, _i.e._, a node can issue a transmission during its OFF phase if required by turning the radio ON previously and without affecting its duty cycle. The reason for this is that decoupling the transmission and receiving phases helps avoid messages collisions and unnecessary delays (only during its ON phase a node is expected to receive messages; therefore, that moment should be reserved for listening to other nodes). The complete phase-lock mechanism is depicted in Figure 3.  
Despite its suitability, Contikimac imposes three major constraints:  
1. Firstly, senders have to be able to predict the receiver's future ON periods. To this aim, senders must know two aspects: (i) the precise time when the receiver entered in a previous ON period, which must be obtained at run-time by means of ACKs and (ii), the periodicity of receiver's duty cycle, _i.e._, how long its phases are. The problem with this second aspect is that the sender does not have any knowledge of this information at run-time and therefore, it must be hardcoded in nodes' program memory. This is an important disadvantage because Contikimac leaves no room for adaptive duty-cycling algorithms in which changing the duty cycle parameters is the key element. 2. The second constraint comes from the assumption that nodes can only receive messages when they are in their ON duty cycle period. This may sound obvious; however, the following example proves the existence of a gap in this reasoning: if a node (identified as A) in its sleep phase turned its radio ON to send some data (to node B), while waiting for the acknowledgement from that node (B); node A could receive a data message from another node (from node C). The acknowledgement that A would send to node C as a response could lead to a miss-synchronization between these two nodes (C would think A is in its ON phase but it just overheard the message while trying to send its own). This constraint results in discarding messages received during an OFF/sleeping period of the duty-cycle that otherwise would have been taken into account. 3. The phase-lock mechanism only works in one way. After sending the ACK, the sender knows when the receiver will enter in future ON periods, but the opposite case is not true. When roles are inverted, and the receiver becomes the sender (and similarly the sender becomes the receiver), this new sender will have to flood the receiver with preambles until it receives an ACK to synchronize with it. Therefore, we can say that this mechanism is susceptible to improvement. To overcome these three limitations and attain maximum network performance, substantial modifications to the current Contikimac are introduced. Basically, the idea is to include in the original  
Figure 3: Contikimac. message a small piece of additional information referred to the duty-cycle configuration when an ACK or a data message is transmitted. This extra information can be of two different types:  
1. Information regarding the remaining time until the next ON period. This allows receivers to accept and acknowledge messages received out of their ON period by simply letting the sender learn about the duty cycle configuration of the receiver. Furthermore, adding duty-cycle information in data messages provides the receivers the ability to synchronize with the senders - and not only the senders with the receivers as occurs in WiseMac or the current Contikimac implementation. This is especially important in a Smart Grid context, where information flows in both ways. Furthermore, with a minimum cost of one message exchange (and an ACK), a pair of nodes, regardless of their role (sender/receiver), can get synchronized. 2.