## 5 WSN Application Design
### End-to-End Latency  
Some applications are subject to strict delay requirements. In general, applications where vehicles need to obtain some information about the road are more sensitive to the delay. The maximum delay that is allowed is determined by the nature and dynamics of the sensed data, which ranges from slow changing road conditions to very fast vehicles suddenly entering a critical area. The impact of exceeding this maximum delay depends on the purpose of the designed application, being especially critical for safety applications. In order to obtain the actual delay to which information delivery is subject to, it is important to take into account the operation mechanism of the application, since it determines the number of times a packet is forwarded in a multihop network. These mechanisms were classified in Section 2 for safety applications, though the proposed classification can be extended to other applications not intended for traffic safety where vehicles or road deployed devices are the destination of the information gathered by sensor nodes. It considers two different groups of applications, those in which safety information is already deposited in road deployed nodes prior to the arrival of vehicles, and those in which the arrival of vehicles triggers a polling/activation mechanism to subsequent nodes along the road. Mainly, the difference between both types of applications with respect to the delay is that the former are subject to a one-way delay due to the forwarding of messagesfrom the source node to the destination. However, the latter suffer a two-way delay as they require query messages to be transmitted in the forward direction and responses alerting about potentially hazardous situations to be sent back in the opposite direction. Consequently, these applications following a query/response fashion further complicate the design of the system. Apart from the number of times a packet is forwarded, it is also important to consider what the additional delay introduced by each packet forwarding is. The sources of this delay include the time spent by the sender to construct and send the information packet, the time elapsed in gaining access to the radio channel, the propagation time over the air and the time employed by the receiver to process the message. Among these the most important by far is the access to the channel, due to the scheduling of the radio. It prevents nodes from transmitting packets just when they are generated, making them wait until the radio is active and the channel idle. This leads to the introduction of a cumulative delay which increases as each node forwards the packet under consideration in a multihop network. As it will be described in the next paragraphs, this delay is quite dependent on the medium access control mechanism (MAC) in use. In those works taking the delay into account two different approaches have been found, distinguishing between scheduled contention based schemes [75] and TDMA (Time Division Multiple Access) schemes. Contention based schemes such as CSMA (Carrier Sense Multiple Access) do not schedule transmissions but rather make nodes contend for the access to the channel. However, in order to achieve low power consumption, methods based on CSMA are normally used in conjunction with duty-cycling schemes, using a common schedule among different nodes. An advantage of using such a combination is that, despite the fact that transmissions are subject to a relatively long initial delay while waiting for the start of the active period, it is possible that a packet be forwarded through several hops during a single active period if this period is properly dimensioned. In addition, if the application requires two-way communications, the delay may be barely affected by the forwarding of responses, since nodes may remain in the active state until these are transmitted back. This can be seen in [11], where in a single active period a short query packet travels through 16 different nodes in 10 ms.