idnits 2.17.1 draft-arkko-core-sleepy-sensors-00.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (July 4, 2011) is 4679 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Outdated reference: A later version (-18) exists of draft-ietf-core-coap-06 == Outdated reference: A later version (-14) exists of draft-ietf-core-link-format-05 == Outdated reference: A later version (-16) exists of draft-ietf-core-observe-02 ** Obsolete normative reference: RFC 2460 (Obsoleted by RFC 8200) -- Obsolete informational reference (is this intentional?): RFC 4627 (Obsoleted by RFC 7158, RFC 7159) == Outdated reference: A later version (-05) exists of draft-shelby-core-resource-directory-00 == Outdated reference: A later version (-10) exists of draft-jennings-senml-05 Summary: 2 errors (**), 0 flaws (~~), 6 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Arkko 3 Internet-Draft H. Rissanen 4 Intended status: Informational S. Loreto 5 Expires: January 5, 2012 Z. Turanyi 6 O. Novo 7 Ericsson 8 July 4, 2011 10 Implementing Tiny COAP Sensors 11 draft-arkko-core-sleepy-sensors-00 13 Abstract 15 The authors are developing COAP and IPv6-based sensor networks for 16 environments where lightweight implementations, long battery 17 lifetimes, and minimal management burden are important. The memo 18 shows how different communication models supported by COAP affect 19 implementation complexity and energy consumption, far more so than 20 mere changes in message syntax. Our prototype implements a 21 multicast-based IPv6, UDP, COAP, and XML protocol stack in less than 22 50 assembler instructions. While this extremely minimal 23 implementation is suitable only for limited applications and makes a 24 number of assumptions, the general conclusions point to need for 25 further work in developing the COAP multicast and observation 26 frameworks. 28 Status of this Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at http://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on January 5, 2012. 45 Copyright Notice 47 Copyright (c) 2011 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents 52 (http://trustee.ietf.org/license-info) in effect on the date of 53 publication of this document. Please review these documents 54 carefully, as they describe your rights and restrictions with respect 55 to this document. Code Components extracted from this document must 56 include Simplified BSD License text as described in Section 4.e of 57 the Trust Legal Provisions and are provided without warranty as 58 described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 63 2. Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 3. Implementing Tiny COAP-Based Sensors . . . . . . . . . . . . . 5 65 3.1. Sleeping Nodes and Energy Use . . . . . . . . . . . . . . 5 66 3.2. Address Autoconfiguration . . . . . . . . . . . . . . . . 6 67 3.3. Using Multicast . . . . . . . . . . . . . . . . . . . . . 7 68 3.4. Using COAP . . . . . . . . . . . . . . . . . . . . . . . . 8 69 3.5. Power Usage Calculation . . . . . . . . . . . . . . . . . 8 70 3.6. Software Construction . . . . . . . . . . . . . . . . . . 9 71 3.7. UDP Checksums . . . . . . . . . . . . . . . . . . . . . . 10 72 3.8. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . 11 73 4. Choosing a Communication Model . . . . . . . . . . . . . . . . 12 74 4.1. End-to-End Communication and Intermediaries . . . . . . . 13 75 4.2. COAP Messaging . . . . . . . . . . . . . . . . . . . . . . 15 76 4.2.1. Client Model . . . . . . . . . . . . . . . . . . . . . 15 77 4.2.2. Server Model . . . . . . . . . . . . . . . . . . . . . 17 78 4.2.3. Observer Model . . . . . . . . . . . . . . . . . . . . 18 79 4.3. Resources and Data Formats . . . . . . . . . . . . . . . . 20 80 4.4. Configuration . . . . . . . . . . . . . . . . . . . . . . 21 81 5. Security Considerations . . . . . . . . . . . . . . . . . . . 22 82 6. Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . 22 83 7. References . . . . . . . . . . . . . . . . . . . . . . . . . . 23 84 7.1. Normative References . . . . . . . . . . . . . . . . . . . 23 85 7.2. Informative References . . . . . . . . . . . . . . . . . . 23 86 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 25 87 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 25 89 1. Introduction 91 The authors are developing COAP [I-D.ietf-core-coap] and IPv6-based 92 [RFC2460] sensor networks for home, building, and other consumer 93 environments. These environments demand solutions where the sensors 94 are physically small, inexpensive, have long battery lifetimes, and 95 require minimal amount of management effort. Our prototype sensor 96 implementation requires no configuration and runs a multicast-based 97 IPv6, UDP, COAP, and XML protocol stack and an application with 98 implementation size under 50 assembler instructions. 100 Small devices are naturally preferred in most applications, but for 101 some applications small enough size is a critical concern, for 102 instance, to make devices embedded in our clothing practical, to fit 103 within the space available in buildings or everyday objects, or to 104 ensure that the devices do not cause a visual distraction. Another 105 key concern is device and battery lifetime. Sufficient battery 106 lifetime in an application with a large number of devices can be 107 surprisingly long. A home with hundred devices with ten year battery 108 lifetimes will result in a battery change operation every month. 110 The practical challenge is to increase battery lifetimes of small 111 devices by several orders of magnitude, and to enable pinhead size 112 devices connected to the Internet. These are not unattainable goals, 113 as legacy sensor networking technology can in some cases reach these 114 goals. For instance, networked 1-Wire temperature sensors are the 115 size of a packaged transistor. Our aim is to replicate this model or 116 even improve it for IP-based sensors. 118 Another challenge is to ensure that COAP-based networks are 119 interoperable in a multi-vendor environment. For instance, it is 120 important that proxies and servers can perform all the necessary 121 tasks without being programmed to support a sensor node manufactured 122 by a particular vendor, or perhaps even without being programmed to 123 support a particular class of a sensor. 125 This memo describes implementation experiences, open questions that 126 we have encountered, and areas where COAP makes it difficult to make 127 very low power implementations. The memo discusses implementation 128 techniques that are useful in these environments and what is needed 129 for fully interoperable solutions based on COAP. 131 The goals for our work are described in Section 2. Before we can 132 dwell into the high-level networking design choices, we highlight 133 some of the implications of detailed implementation strategies 134 through an example. Section 3 discusses our specific implementation 135 strategies, and describes our experiences with these choices. This 136 example is an extreme case, an attempt to minimize as much as 137 possible for a limited set of applications. However, some general 138 conclusions can still be seen. The more general discussion of the 139 different high-level approaches to communications models can be found 140 in Section 4. Different communication models supported by COAP 141 affect implementation complexity and energy consumption, far more so 142 than mere changes in message syntax. The required configuration 143 effort is also directly affected by the choice of the communications 144 model. Finally, the concluding recommendations point to need for 145 further work in developing COAP and its multicast and observation 146 frameworks [I-D.ietf-core-coap] [I-D.ietf-core-observe], as discussed 147 in Section 6. 149 2. Goals 151 The main focus of this draft is sensors that are deployed in large 152 quantities and have specific physical requirements. There are 153 similar issues with other nodes such as servers and proxies, but in 154 general these nodes have better access to power and other resources, 155 and typically can also be more easily configured by humans. 157 As discussed in the introduction, for sensors the overall 158 requirements revolve around minimizing physical size, cost, 159 management effort and maximizing battery lifetimes. More 160 specifically, we believe the following goals are key in achieving 161 fulfilling these requirements: 163 o Natural support for sleeping nodes. There are many aspects to 164 power usage in small devices, but we believe this one is the most 165 significant one in terms of minimizing power usage. Many of the 166 other aspects are either dictated by the environment (such as 167 choice of radio technology in a given network) or have a 168 relatively small impact (small variations in message size, for 169 instance). 171 o Communication models that fit the problem at hand. It is 172 essential that the small nodes can engage in communication 173 exchanges that suit their needs. Having to employ multiple 174 roundtrips, wait for nodes they have no control over, and so on 175 can have a large negative effect on the amount of power that the 176 node has to spend. 178 o Good design from user perspective. It is obviously undesirable to 179 require a lot of per-device configuration effort when deploying a 180 large set of small devices. In addition, direct configuration 181 efforts with the device itself may be problematic, given that 182 there is no room for any type of a user interface. For instance, 183 some of the legacy sensor devices in existing networks are just a 184 few millimeters across. It is natural that some information needs 185 to be configured, but configuration should be minimized and 186 whatever configuration is necessary should take place in nodes 187 that have the necessary user interfaces and capabilities. 189 3. Implementing Tiny COAP-Based Sensors 191 We have implemented prototypes of small sensors and a sensor gateway 192 to pass the information onwards. The main target of these 193 implementations is temperature, humidity, and other measurements in 194 home environments. Our focus is primarily in sensing. Actuators and 195 other more complex functions are outside the scope of our analysis. 197 Our prototype sensor implementation requires no configuration and 198 simply runs based on its own identity burned in the hardware. The 199 complete functionality requires only a small amount of code. Our 200 prototype platform uses a 32-bit processor architecture and the 201 hardware provides an underlying capability to send a link layer 202 frame. In this platform, our implementation is under 50 assembler 203 instructions. The implementation consists of a Ethernet, IPv6, UDP, 204 COAP, and XML protocol stack and the sensor application. The sensor 205 application is based on values provided by an A/D converter; any 206 analog value can be measured. 208 Even this size of the implementation is not the absolute minimum. 209 One quarter of the code in our implementation relates to specific 210 initializations required for the A/D converter that we used. Another 211 quarter relates to binary to decimal conversions on the chosen XML- 212 based payload. On a different platform and with binary data, 25 213 instructions would be achievable. Of course, with different link 214 layers and platforms an implementation might have to be arbitrarily 215 complex to support the intricacies of the link layer in question. 217 The following subsections outline the design choices that were taken 218 to create the small implementation we have. 220 3.1. Sleeping Nodes and Energy Use 222 As discussed earlier, choosing the right communication model is what 223 drives a good design from a power conservation perspective. 225 In our implementation, we chose to use a send-only model where the 226 device only sends messages, but never receives one. This model can 227 be applied in specialized applications under some assumptions that 228 will be discussed further later in this memo. In our case, the 229 sensor will periodically take a reading and send a COAP message to 230 the network with that reading. In order to eliminate potential 231 waiting periods where the device has to stay on, we needed to 232 eliminate the following: 234 o DHCP request - response process [RFC2131]. 236 o Router Discovery process [RFC4861]. 238 o Duplicate Address Detection process [RFC4862]. 240 o Acting as a COAP server [I-D.ietf-core-coap]. 242 o Waiting for COAP observation subscriptions 243 [I-D.ietf-core-observe]. 245 3.2. Address Autoconfiguration 247 Eliminating DHCP is easy, as we can simply use IPv6 and stateless 248 address autoconfiguration. Eliminating router discovery is harder, 249 however. To avoid having to wait for a Router Advertisement to carry 250 a prefix, we chose to employ a link-local source adress. These 251 addresses can be constructed from the well-known prefix FE80::0 and a 252 link layer hardware address burned to the hardware [RFC4862]. 254 Eliminating Duplicate Address Detection is a matter of choice. We 255 chose to behave as if DupAddrDetectTransmits had been set to zero, in 256 other words not performing any Duplicate Address Detection. It may 257 be debatable whether this is a violation of [RFC4862], but it is 258 certainly against its spirit. This choice seems to be the right 259 technical action, however, on a number of grounds: 261 o As the node is not receiving any packets, nor sending Neighbor 262 Advertisement messages, any effects of possible duplication would 263 be limited to some additional traffic in the network. No other 264 traffic would be impacted. Application-level collection of sensor 265 information can proceed even in this situation. 267 o [RFC4862] requires that upon detecting a duplicated address, 268 "autoconfiguration stops and manual configuration of the interface 269 is required". However, it is obvious that no such action is 270 possible on a small device. The device has no user interface. 271 The only interface that the device has is the network, and if the 272 network cannot be brought up, there's very little that can be 273 done. As a result, the ability to not stop in a duplication case 274 may actually be better than what is recommended by [RFC4862]. 276 o These devices are manufactured with hardware identities that are 277 expected to be unique. There are obviously no guarantees about 278 this succeeding in all cases, but non-unique identifiers would 279 represent a major failure of the manufacturing process. 281 Elimination of Duplicate Address Detection also eliminates the need 282 for the node to implement Multicast Listener Detection (MLD) protocol 283 [RFC2710] [RFC3810]. This is because it now no longer needs to 284 listen for messages to the solicited node multicast address, so there 285 is no need to send out MLD messages. 287 3.3. Using Multicast 289 To further eliminate configuration or protocol exchanges for 290 discovery, we chose to employ a multicast model where the sensor 291 sends COAP POST requests to a well-known multicast address. While 292 the type of sensors targeted here send information very infrequently, 293 one of our goals was to ensure that the architecture would scale to 294 more frequent information distribution and far larger groups of 295 sensors. As a result, it was important to ensure that the multicast 296 messages do not lead to multicast storms or unnecessary waking up 297 many nodes due to frequent messages. 299 We chose to employ an interest-based generated multicast group 300 address. These addresses are similar to those used in IPv6 Neighbor 301 Discovery [RFC4861] for sending messages to solicited node addresses 302 (FF02:0:0:0:0:1:FFXX:XXXX) [RFC4291]. The idea is that some bits 303 from the object of interest are reflected in the multicast address, 304 making it statistically likely that someone interested in a specific 305 object only has to receive packets relating to that object, and not 306 all packets. 308 We employ FF02:0:0:0:1:FEXX:XXXX, where XX:XXXX is a 6-byte value 309 representing the type of sensor. (This address is currently reserved 310 by IANA, but could be allocated for this purpose if needed.) The 311 sensor type represents a classification of different sensor to types. 312 For instance, we could let 00:0001 stand for temperature sensors. 313 Each temperature sensor would send information to the multicast 314 address FF02:0:0:0:1:FE00:0001, and only those devices that are 315 interested in temperature measurements would subscribe to this 316 multicast group. Techniques such as MLD/IGMP snooping can be used in 317 the network to ensure that multicast messages are physically 318 transmitted only in those parts of the network that actually care 319 about those messages [RFC4541]. In practice, this would mean that in 320 a star topology network with a large number of sensors and a few 321 central nodes, none of the sensors would receive any messages from 322 each other. 324 Finally, randomization of actual transmission times for the periodic 325 transmissions ensures that transmissions from different sensors are 326 not synchronized. 328 When sensors send multicast messages with link-local source and 329 destination addresses, all communication is confined to a single 330 network. We expect that there is a node in the network that listens 331 to the multicast messages, collects the data from them, and is 332 capable of relaying the information to other parties. Such a node 333 might store the latest information related to each sensor, and allow 334 other nodes in the Internet to query the latest information on a per- 335 sensor or an aggregate basis. 337 3.4. Using COAP 339 Our implementation uses non-confirmable requests at the messaging 340 layer of COAP, and sends a POST message that carries an XML payload 341 for a well-known URI. The implementation sends a message and does 342 not wait for a message at this layer. We have used a gateway to 343 store the information received from the sensors, making the gateway 344 act as a server, storing everything posted to it. The stored 345 information can be fetched from the gateway, for instance, with a 346 COAP or HTTP GET. 348 Per Section 2.8.2 of [I-D.ietf-core-coap], POST methods normally 349 generate a response at the request/response layer. If the server 350 sends a response, the sensor is already asleep and will not respond 351 to Neighbor Discovery messages or receive the actual message. The 352 message is therefore lost, but it is fine in our case given that the 353 information was already stored in the server. 355 Reliable transmission is achieved through assuming a sufficiently 356 high periodic transmission rate to account for randomly occurring 357 message loss. 359 There are several areas of concern with the above arrangements, 360 discussed further in Section 3.8 and Section 4.2. 362 3.5. Power Usage Calculation 364 Our communication model is now complete. Its effectiveness can be 365 calculated by determining what fraction of time the device would have 366 to be awake. Lets assume periodic messages once per minute, a 10 367 Mbit/s link layer interface, and a CPU running at 1 Mhz. With the 368 given link layer, sending one message takes theoretically 100 369 microseconds. Constructing the message takes 50 instructions and if 370 we for simplicity assume that each instruction takes two clock 371 cycles, the CPU needs to run for an additional 100 microseconds. 372 Since our device is only sending messages, it only has to wake up to 373 send the message. Ratio of sleeping versus being awake is now 200 374 microseconds versus 60 seconds, i.e., 300.000. Even if we assume 375 that it takes an additional 800 microseconds to power the device up 376 and let the A/D converter stabilize, the ratio is still 1000 377 microseconds vs. 60 seconds, i.e., 60.000. 379 We can compare this to some other possible implementations. A node 380 that stays awake and participates in Neighbor Discovery, Duplicate 381 Address Detection, and ARP processes would consume 60.000 times more 382 energy. One could assume that listening is less power consuming than 383 sending, however. On some link layers today this ratio can be as 384 high as listening consuming 2.500 time less power, though practical 385 implementations (talk vs. standby times) seem to be more in the range 386 of a 100-fold difference. If we assume an optimistic 1.000 time 387 difference, our implementation would still consume 60 times less 388 energy than one that stays on all the time. 390 Another possible implementation is that a node stays awake for a 391 short period of time to listen for possible messages. Some COAP 392 implementations do this to enable discovery and observe subscriptions 393 to work. If we assume one second awake time during one minute, then 394 the power consumption difference to our implementation is somewhere 395 between 1.000 and 2 times, depending on whether send/receive power 396 requirements differences are factored in. 398 While these comparisons have produced wildly different numbers, it is 399 clear that our implementation strategy is far superior to the 400 simplistic always-on model. The situation is less clear with the 401 comparison to the periodically listening approach, but even there it 402 is clear that not listening consumes less energy than listening. 403 While the actual numbers depend highly on the characteristics of the 404 link layer, even with the most optimistic assumptions for the 405 alternative approach it uses twice as much energy. This may not 406 sound like a significant difference, but if it means a ten year 407 battery lifetime instead of five year battery lifetime, it can make 408 or break a business case for building some types of sensors. 410 3.6. Software Construction 412 When memory and processing power is at a premium, the detailed 413 software design approach needs to suit the platform that the software 414 runs on. That being said, for simple send-only applications we have 415 found that a packet template-based approach works well. In this 416 approach an image of the message sent by the application is burned 417 into the read-only memory of the device, as a part of the overall 418 software image. When the device powers up, the message image is 419 copied to random access memory, necessary changes are applied, and 420 the underlying link layer hardware or the CPU emits it on the 421 outgoing interface bit by bit. 423 In case of COAP and simple sensors that output a numerical value 424 transmitted in an XML [W3C.REC-xml-19980210] or JSON [RFC4627] 425 payload, only the following changes are applicable: 427 o 16-bit COAP Message ID field (see Section 3.1 in 428 [I-D.ietf-core-coap]). This field should be set to a random 429 value, a rarely repeating value. We have found that using a 430 suitably shifted value of a real-time clock is the most convenient 431 way to generate a good value for this field. On many small 432 platforms, a real-time clock can be kept counting with a very 433 small amount of power. Note that it does not matter what value 434 the real-time clock is initially initialized to; the only thing 435 that matters for the Message ID field is that it keeps changing. 436 If a sensor sends a value every minute, shifting a seconds-from- 437 epoch counter by five bit positions is a good way to generate a 438 unique value. 440 Note that using a different value may not actually be required, 441 though it is certainly helpful for understanding network traces 442 and debugging. According to Section 4.1 of [I-D.ietf-core-coap], 443 Message IDs only have to be unique within RESPONSE_TIMEOUT * 444 RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) or 45 seconds, 445 so a sensor sending messages every minute would be allowed to send 446 them with the same Message ID. 448 o The actual sensor reading. In both XML and JSON, values can be 449 padded with leading zeros or spaces, so the overall size of the 450 packet can be kept the same in all circumstances. This greatly 451 simplifies the construction of the packet. 453 Note that binary or hexadecimal formats would make this even 454 simpler, but the savings are in the order of few instructions; the 455 difference is not big. Of course, a message that carries a text 456 is longer than a pure binary message. However, the format is not 457 so important as is avoiding including a lot of extraneous 458 information. Some XML schemas can be problematic. We advocate 459 simplicity and restraint in XML schema design for sensor data. 461 o 16-bit UDP checksum field. For computing this field, see 462 Section 3.7. 464 Note this small set of changes is only applicable when it can be 465 assumed that both source and destination IP addresses are known 466 beforehand. 468 3.7. UDP Checksums 470 Both IPv4 and IPv6 have some form of mandatory checksums, either in 471 the IP header (IPv4) or as part of upper layer protocols such as UDP 472 (IPv6). Computing the checksum is not difficult, but requires 473 looping through all the 16-bit words in a packet. Fortunately, for a 474 simple application the checksum calculation is actually very simple. 475 Following the algorithm in [RFC1624], there is no need to calculate 476 the checksum for the entire packet. The checksum can be precomputed 477 on the packet template with zero words filled in for the variable 478 parts. Lets call this precomputed checksum value C. Let NC be its 479 negation, i.e., 481 NC = ~C 483 Once the actual values are filled in the packet, the true checksum C' 484 needs to be calculated as follows: 486 T = NC + W1 + W2 + ... + Wn 487 C' = ~(T + (T >> 16)) 489 where T is a temporary variable and Wi, i = 0, 1, ..., n are the 490 words that got changed from the template. Naturally, this approach 491 makes sense only when the number of changed words is small. We have 492 found that suitable placement of spaces and string values in an XML 493 object, for instance, is helpful in aligning the changed parts to 494 word boundaries, and in sensor implementations n = 3. 496 3.8. Evaluation 498 This type of an implementation is obviously an extreme example. This 499 level of optimization may not be needed in all cases. Nevertheless, 500 it is interesting to see that COAP can be used in such small 501 implementations. 503 In general, our implementation satisfies the requirements set for the 504 special environment that it was designed for: power usage is 505 minimized, individual sensor devices do not require configuration, 506 existing legacy networks can migrate to general-purpose IP-based 507 networks, and all the necessary information can be passed in the 508 messages. 510 That being said, there are also some issues with this implementation 511 approach. The first issue is that information delivery frequency is 512 hardwired into the sensors. The chosen frequency may be sufficient 513 for a given application, but the same sensors cannot be used by 514 another application that would require a faster delivery of 515 measurements. 517 Related but more serious concern is that reliability is achieved 518 through randomized message intervals and multiple transmissions; it 519 is considered unlikely that a very large number of messages in 520 sequence are lost from the same sensor. The message transmission 521 frequency needs to be set high enough to accommodate some packet 522 loss. There is no way to actively request retransmission. We 523 believe that this is a small problem in well-designed networks and 524 for most applications that are not real-time critical, such as home, 525 weather, maintenance, and energy monitoring. However, this approach 526 may not be suitable for real-time or safety-critical applications. 528 The third and obvious limitation is that there is an assumption of a 529 network node in the same network that is capable of storing 530 information. We believe that there is little that can be done about 531 this assumption; it is fundamental for the nature of low-power 532 devices that they have to be able to sleep periodically, and there 533 are very few other options beyond implementing a time-shifting device 534 such as a cache. The location of the cache node could be outside the 535 sensor network in some other designs, however. 537 4. Choosing a Communication Model 539 COAP is a specialized web transfer protocol designed to be used in 540 various ways. The communication model of COAP is flexible and the 541 application developer has to decide the best way to use it. This 542 involves 544 o deciding which parties are in server/client roles, 546 o determining whether to use end-to-end communication or employ 547 intermediary nodes, 549 o deciding whether to use base COAP operations or the observation 550 framework, 552 o deciding whether a discovery process is required, 554 o specifying how COAP maps to lower layers, including choice of 555 source and destination addresses, and 557 o agreeing about commonly understood methods, resource identifiers 558 and data representation. 560 Note that the number of these choices alone makes it hard to achieve 561 interoperability, as we should strive for application 562 interoperability at the semantic level [arkko.iab], rather than mere 563 ability to transport correctly formed COAP packets. 565 Nevertheless, the main focus of this memo is to determine the power 566 efficiency implications for the different communications models, and 567 to identify areas where COAP limits this efficiency. The rest of 568 this section is structured as follows. Section 4.1 discusses which 569 nodes are involved. Section 4.2 discusses the specific COAP 570 messaging alternatives. Section 4.3 discusses resources and data 571 formats. Section 4.4 discusses configuration issues. 573 4.1. End-to-End Communication and Intermediaries 575 In most applications, user interactions and information requests can 576 come at any time. Some form of an intermediary that can buffer such 577 requests between a possibly sleeping device and the end user seems 578 therefore useful to provide "time-shifting" capability. Similarly, 579 an intermediary can be useful to reduce the number of transactions 580 that one has to do with the low-power device to a minimum; the 581 intermediary can answer on behalf of the device should a large number 582 of information requests be placed. 584 In its simplest form, the intermediary is a part of the application 585 server. For instance, a web-based application server is capable of 586 serving web clients at any time, but will only place a periodic 587 request to the sensor in order to take a reading. There are 588 virtually no downsides to this arrangement, and it is generally 589 recommended practice. 591 What is perhaps more controversial and interesting is the placement 592 of intermediaries elsewhere, such as requiring an intermediary in the 593 same network as the sensor devices are in. In our example 594 implementation, such an intermediary was used for both time-shifting 595 purposes and to bridge the gap between addressing domains, as the 596 sensor was only capable of sending messages to nearby devices with 597 link-local multicast addressing. For obvious reasons, sending 598 traffic to well-known multicast groups works only on the local scale. 599 Other possible reasons for using a local intermediary include 600 protocol conversion and providing TCP-based congestion control for 601 traffic passing through the Internet. Where mechanisms for dealing 602 with packet loss are limited, such as in the case of our 603 implementation, an intermediary can also shield the sensors from 604 having to deal with networks that have not been engineered for this 605 purpose. 607 There are also downsides to having to place a local intermediary. 608 The obvious downside is that such a device must now exist in the 609 local network. 611 The use of COAP intermediaries is not fully specified, however. Some 612 of the issues we have encountered include: 614 o COAP defines the roles for clients, servers, caches, and proxies, 615 but while the specification allows an intermediary to act as 616 server that stores all information sent to it, it is by no means 617 specified as something that all implementations should do. The 618 desirable behavior from the point of low-power sensors would be 619 that the local server would store the information from every POST 620 sent to it for a period of time specified in the Max-Age option 621 [I-D.ietf-core-coap], and then be able provide access to the 622 information using GET and HTTP/COAP. It would be useful to define 623 such a new server role, along with specifying the necessary 624 security and operational conditions for this practice. 626 o If designed badly, the intermediary may also limit the type of 627 communications it can relay. For instance, a gateway that is only 628 built for a particular types of sensors might only accept very 629 specific COAP messages. In particular, intermediaries need to 630 support any type of resource identifiers and data formats. 631 Further discussion of this can be found in Section 4.3. 633 o In several CoAP applications the user is interested in the latest 634 value of a resource, but historical values are also interesting in 635 several use cases, e.g. tracking the movements of a truck during 636 the day. Thus, the information stored in the cache/gateway should 637 not expire. Even if a new value is received every minute, old 638 values should be accessible and new value should not overwrite the 639 old value. For this kind of cases, schemas for representing also 640 historical values of the sensor would be useful for 641 interoperability. Of course, simple schemas are easy to implement 642 even if there did not exist any standards or recommendations, but 643 again, there will not be interoperability. 645 o If the information is such that it should expire after some time, 646 Max-Age option can be used as defined [I-D.ietf-core-coap]. 647 However, [I-D.ietf-core-coap] discusses Max-Age option only in the 648 context of responses. In the multicast use case (sensor the one 649 sending requests), Max-Age option would be needed to be supported 650 in requests, too. 652 o Multicast requests, particiularly GETs, might be forwarded by 653 several proxies and possibly even to further multicast addresses, 654 causing a storm of messages. The COAP specification does not 655 describe when the forwarding of multicast requests is appropriate 656 and when it is not. 658 4.2. COAP Messaging 660 The interaction model of COAP is similar to the client/server model 661 in HTTP. A sensor can act either as a client that sends requests 662 containing updated measurement information to a server, or as a 663 server that responds to requests from others. If the sensor is a 664 server, it can either employ the basic communication model from 665 [I-D.ietf-core-coap] or use the observation framework 666 [I-D.ietf-core-observe]. This section looks at the energy efficiency 667 implications of these models. 669 It is important to make this analysis not merely based on the data 670 transmission phase, but also based on what discovery actions and 671 related signaling may be necessary. 673 4.2.1. Client Model 675 In this model, a sensor acts as a client that periodically sends POST 676 requests containing updated measurement information to a server. 677 This is the model that we used in our example implementation. 679 User or Sensor 680 Intermediary (Client) 681 (Server) . 682 | . 683 | . 684 | wake-up 685 | | 686 | NON/POST | 687 | content | 688 +<--------------------| 689 | | 690 | power-down 691 | . 692 | NON/RSP . 693 |----------------/ . 694 | . 696 Figure 1. Send-only client model 698 In its simplest form, this model can be reduced to sending a single 699 message per observation period, however this comes at the cost of: 701 o Limited support for reliable transmission. Messages may arrive 702 out of order and they may go missing without notice. While 703 periodic retransmissions do provide a statistical likelihood that 704 the transmission eventually succeeds, they do not guarantee it. 706 o Possible spurious diagnostic or other problems caused by not being 707 able to receive the REST level response to the POST message that 708 the server will send (see Section 3.4). 710 Both of these problems can be addressed by forcing the device to wait 711 for a response, incurring the cost of having to be awake for 1 RTT 712 for each observation period. Using the assumptions from Section 3.5 713 and a 2 ms RTT for a local intermediary to respond, the power usage 714 of this model would be either two times more or 0.2% more, depending, 715 again, on whether the send/receive power differences are factored in. 717 User or Sensor 718 Intermediary (Client) 719 (Server) . 720 | . 721 | . 722 | wake-up 723 | | 724 | CON/POST | 725 | content | 726 +<--------------------| 727 | | 728 | ACK/RSP | 729 |-------------------->| 730 | | 731 | power-down 732 | . 733 | . 735 Figure 2. Send-and-confirm client model 737 (Interestingly, a similar model could be implemented even with HTTP. 738 With TCP, one additional roundtrip and one additional message would 739 be necessary to start the communications. This model would be 740 roughly twice as power hungry as the COAP alternative. Note at least 741 in the implementation strategy that was used in our example 742 implementation, the format differences between COAP and HTTP would 743 make little difference for implementation complexity, as messages are 744 created based on pre-filled packet templates. Supporting TCP would 745 require some complexity, however.) 747 In addition, there is an added factor, having to discover the right 748 peer to send messages to. In our example implementation this was 749 simply a well-known multicast address, in which case no additional 750 power is spent. The downside is that this can easily be done only 751 with local multicast, necessitating the existence of suitable 752 intermediary in the same network. Alternatively, the sensor could 753 run a discovery phase at installation time to find the addresses of 754 the peers wishing to receive the information. This discovery would 755 have to repeated in order to account for changes and new equipment. 756 Nevertheless, if discovery is run once a day and uses the same amount 757 of power as sending one data observation, the increased power 758 requirements are in the order of 0.1%, i.e., negligible. 760 4.2.2. Server Model 762 In the basic server model as defined in [I-D.ietf-core-coap], the 763 sensor waits for requests from a client. The power requirements for 764 this model have been analyzed in Section 3.5 and are substantially 765 higher than in any other model, even if one takes into account that 766 listening is less power intensive than sending. 768 User or Sensor 769 Intermediary (Server) 770 (Client) 771 | | 772 | CON/GET | 773 +-------------------->| 774 | | 775 | ACK/RSP | 776 | content | 777 |<--------------------+ 778 | | 780 Figure 3. Server model. 782 There may be an additional discovery exchange where the sensor 783 responds to requests sent for the well-known resources defined in 784 [I-D.ietf-core-link-format]. However, these additional exchanges do 785 not change power requirements significantly, as the sensor already 786 has to be awake at all times. A more relevant concern is perhaps 787 unwanted or accidental traffic to the sensor or one of the multicast 788 addresses it belongs to (such as all-nodes [RFC4291]). Such traffic 789 may have to be replied to or ICMP error messages may have to be sent, 790 consuming additional energy. 792 The server model is not recommended. Variations of the model may be 793 a little bit more efficient, however. For instance, a local server 794 could send multiple requests in an effort to randomly hit a period 795 when the sensor is powered up. However, such practices would still 796 generate a lot of traffic in the network, which might not be 797 desirable. For instance, if the network involves low-powered RPL 798 routers [I-D.ietf-roll-rpl], extra traffic would be harmful. 800 4.2.3. Observer Model 802 The observer model [I-D.ietf-core-observe] allows clients to decide 803 what information they want and servers to decide when to send that 804 information. The model involves an initial registration, followed by 805 the server sending periodic notifications. These notifications can 806 be timed appropriately, so that the sensor only needs to wake up at 807 suitable times. 809 User or Sensor 810 Intermediary (Server) 811 (Client) 812 | | 813 | NON/GET | 814 | observe registration | 815 +---------------------->| 816 | | 817 | power-down 818 | . 819 | . 820 | . 821 | NON/RSP wake-up 822 | content | 823 |<----------------------+ 824 | | 825 | power-down 826 | . 827 | . 828 | . 829 | NON/RSP wake-up 830 | content | 831 |<----------------------+ 832 | | 833 | power-down 834 | . 835 | . 837 Figure 4. Observer model. 839 On the face of it, this is a very efficient model. Unfortunately, 840 one has to take into account the registration phase. For this model 841 to work, the sensor has to first be able to receive a registration 842 request, and later be able to receive further requests in case there 843 are changes or additional clients that want information. As a 844 result, a straightforward implementation of the observe framework 845 would appear to save no energy at all compared to the server model. 846 The sensor would still have to stay awake all the time. Again, this 847 model is not recommended. 849 Optimizations of the observer model are of course possible. 850 Transmitting multiple registration requests is less damaging than 851 transmitting multiple data requests, as the registration is only a 852 one-time event. Nevertheless, for interoperability, it would be 853 useful to understand what timelines and retransmission counts should 854 be followed by both servers and clients. For instance, a sensor 855 could assume that it has to be up one second out of every minute. 856 This would increase power consumption compared to the send-only model 857 as described in Section 3.5. Users or intermediaries interested in 858 subscribing to the information from the sensor would on the average 859 have to re-transmit registration requests thirty times to randomly 860 hit the period that a particular sensor is awake. 862 Another possible optimization would be the definition of implicit 863 subscriptions where for some application a certain subscription would 864 always be assumed so that a sensor can start sending periodic 865 notifications immediately to a well-known address. With such a model 866 the notifications are carried as responses and an intermediary can 867 act as a COAP cache, avoiding most of the issues from the above 868 paragraphs. 870 In addition, we have found a few more specific issues with the 871 observer model: 873 o There is no well-defined termination period. The consumer of the 874 information can observe that information is still flowing to it as 875 expected. However, when non-confirmable messages are used, the 876 sensor sending the notifications has no knowledge if the receiver 877 is still even in the network. As a result, a simple 878 implementation that keeps sending information until an explicit 879 unsubscription is not desirable, as the sensor may have to send 880 more messages than is necessary. 882 o Section 3.2 of [I-D.ietf-core-observe] specifies that a 883 registration request from the same source address but a different 884 port is considered a new, additional request. This can be 885 problematic if the client reboots and assigns a different port 886 number for its communication with the server. 888 o Section 3.3 of [I-D.ietf-core-observe] makes it optional for a 889 server to terminate the observation request when a GET request is 890 sent without the Observe option. This makes it hard for a client 891 to indicate to the server that it is no longer interested in the 892 resource. 894 o Section 3.3 of [I-D.ietf-core-observe] specifies that a 895 subscription can be terminated using a RST message. This makes it 896 impossible to know if the receiver rejects a confirmable 897 notification because some context was missing or because the 898 receiver wants to terminate the subscription. 900 4.3. Resources and Data Formats 902 The choice of resource identifiers (URIs) and data formats is 903 important to achieve semantic interoperability between a sensor and 904 an application using it. It is not enough to transport some data for 905 some object, the parties involved in the application have to 906 understand that the information comes from, say, a particular 907 temperature sensor and that the information contains a temperature 908 value encoded in a particular way. 910 The choice of URIs is clear as far as COAP transport is concerned in 911 the server model. Here the Link Format [I-D.ietf-core-link-format] 912 can be used by clients to find out what URIs exist. Nevertheless, 913 there are two remaining concerns: 915 o The authors of this memo found it desirable to implement a new URI 916 type to represent device identities, such as MAC addresses or 917 1-wire device identifiers. While UUIDs [RFC4122] can also be used 918 for this purpose, they are more complex for no additional value 919 from the point of view of our application. UUIDs are required to 920 contain a time component, which would cause both additional 921 implementation complexity, as well as make it more difficult to 922 correlate identifiers from a manufacturer's list or printed on the 923 outside of the sensor to the ones actually sent in the network. 924 (Such correlation is often required in order to configure the 925 real-world location of various sensors.). The new URI type is 926 simply of the form "device:ID", where ID is the hardware address 927 associated with the device. Such an URI could have uses not only 928 in sensor networks, but also in cataloging network equipment, etc. 930 o While the Link Format provides a way to determine what resources 931 exist, the semantics of those resources and data formats still 932 require standardization. Some work regarding such standardization 933 is ongoing, e.g. in ZigBee IP Smart Energy 2.0 Profile, but it 934 remains to be seen how much work is needed overall. This problem 935 might become even more real when sensors from particular 936 application areas, such as electrical cars or lightning, are being 937 implemented. Without any common schemas or data models no 938 interoperability can be provided. 940 o It is also important to care about the size and complexity of the 941 data models developed for low-power applications. Even if moving 942 from HTTP to COAP and some form of compression saves some number 943 of bytes, complicated XML models can easily consume the savings 944 and more. The authors have found [I-D.jennings-senml] a workable, 945 simple model. 947 In addition, in the client model it becomes important that the server 948 (local intermediary) is capable of storing information about any 949 resource when it receives a POST request. This is not necessarily 950 the case. First, it is unclear what resource identifiers the client 951 should use, particularly when multicast is used. Our example 952 implementation employed a well-known URI "/publish" and placed the 953 identity of the device sending the request inside the payload part of 954 the request along with the sensor readings. But it is not clear that 955 this is the best approach, and furthermore, such an approach has not 956 been standardized so it may not work with all devices. As an 957 example, in one of the COAP stacks that we tried, it is only possible 958 to generate resources by a user under a root resource called 959 "storage". This requirement makes it incompatible with other 960 implementations we tried. 962 4.4. Configuration 964 One overriding concern in networks with large number of sensors is 965 configuration effort. In addition, the sensors are typically 966 deployed in homes and other environments where the necessary skills 967 for installation and operational tasks cannot be assumed. As a 968 result, it is important that at installation of individual sensors 969 leads to little or no configuration effort. Furthermore, given the 970 small physical size and lack of user interfaces, it is essential that 971 any configuration be doable on other devices on behalf of the 972 sensors. 974 A good model for configuration is that the sensors are fully factory- 975 configured with respect to their identities and capable of operating 976 autonomously in any IP network with suitable network interfaces. 977 Typically, some configuration information is required but this can be 978 provided as additional information associated with a particular 979 sensor identity, and configured in the application server or 980 intermediary. For instance, the physical location of a sensor can be 981 configured in this manner. 983 From the point of view of the COAP protocol and its communication 984 model, this means that the sensors should operate as much as possible 985 based on autoconfigured addresses, well-known destinations and/or 986 resource discovery [I-D.ietf-core-link-format] 987 [I-D.shelby-core-resource-directory]. COAP should also allow 988 configuration and passing of additional information in 989 intermediaries. 991 5. Security Considerations 993 Support for authentication of sensors, integrity of messages sent by 994 sensors, or protection of the data objects carried by the messages 995 would be useful in some environments, while physical security and 996 link-layer protection may be sufficient in others. Mechanisms for 997 these security mechanisms are for further study. 999 6. Conclusions 1001 This memo has analyzed the power requirements for sensor applications 1002 through an example implementation that runs on absolute minimum power 1003 and through an analysis of various different more general 1004 communications models. 1006 The general conclusion is that the chosen communications model and 1007 overall system and network architecture is far more important for low 1008 power usage than details of the message formats. Much of the work in 1009 COAP has focused on the latter rather than the former. Even the 1010 difference between COAP and HTTP transactions is small compared to 1011 the difference between choosing the optimal and worst communications 1012 model. 1014 In particular, we would like to draw attention to system-level 1015 analysis to ensure that nodes can stay asleep for as long as 1016 necessary. This is particularly important when designing power- 1017 efficient data transmission models such as the observe framework. It 1018 is not enough for the data transmission itself to be efficient if the 1019 device needs to stay awake or communicate for other reasons 1020 (Section 4.2.3). Several other more detailed observations about the 1021 COAP specifications were also noted in Section 3.3, Section 4.1, 1022 Section 4.2, Section 4.3, and Section 4.4. 1024 The communication model is also not just about finding the most 1025 efficient sequence of messages. It is very much also an 1026 architectural decision. The authors believe that an information- 1027 centric or delay-tolerant networking model is appropriate for 1028 collecting information from sensor networks. These models allow 1029 communications based on identities, support intermittent 1030 connectivity, focus on data rather than the location of the data, and 1031 have the natural ability for nodes to aggregate, store, and process 1032 data. Some of the tasks for ensuring that such models can be 1033 employed with COAP include 1035 o Definition of URI types suitable to be used in sensor networks. 1037 o Accurate specification of multicast support. 1039 o Specifications for intermediary behavior so that they can store 1040 and process data from sensors. 1042 o Further standardization of data formats and application semantics. 1044 Finally, it should be noted that the conclusions in this memo should 1045 not be interpreted to apply too widely. Actuators and other, non- 1046 sensor low-power device implementations have likely very different 1047 requirements and may require different solutions. 1049 7. References 1051 7.1. Normative References 1053 [I-D.ietf-core-coap] 1054 Shelby, Z., Hartke, K., Bormann, C., and B. Frank, 1055 "Constrained Application Protocol (CoAP)", 1056 draft-ietf-core-coap-06 (work in progress), May 2011. 1058 [I-D.ietf-core-link-format] 1059 Shelby, Z., "CoRE Link Format", 1060 draft-ietf-core-link-format-05 (work in progress), 1061 May 2011. 1063 [I-D.ietf-core-observe] 1064 Hartke, K. and Z. Shelby, "Observing Resources in CoAP", 1065 draft-ietf-core-observe-02 (work in progress), March 2011. 1067 [RFC1624] Rijsinghani, A., "Computation of the Internet Checksum via 1068 Incremental Update", RFC 1624, May 1994. 1070 [RFC2460] Deering, S. and R. Hinden, "Internet Protocol, Version 6 1071 (IPv6) Specification", RFC 2460, December 1998. 1073 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 1074 Architecture", RFC 4291, February 2006. 1076 7.2. Informative References 1078 [RFC2131] Droms, R., "Dynamic Host Configuration Protocol", 1079 RFC 2131, March 1997. 1081 [RFC2710] Deering, S., Fenner, W., and B. Haberman, "Multicast 1082 Listener Discovery (MLD) for IPv6", RFC 2710, 1083 October 1999. 1085 [RFC3810] Vida, R. and L. Costa, "Multicast Listener Discovery 1086 Version 2 (MLDv2) for IPv6", RFC 3810, June 2004. 1088 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1089 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1090 July 2005. 1092 [RFC4541] Christensen, M., Kimball, K., and F. Solensky, 1093 "Considerations for Internet Group Management Protocol 1094 (IGMP) and Multicast Listener Discovery (MLD) Snooping 1095 Switches", RFC 4541, May 2006. 1097 [RFC4627] Crockford, D., "The application/json Media Type for 1098 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 1100 [RFC4861] Narten, T., Nordmark, E., Simpson, W., and H. Soliman, 1101 "Neighbor Discovery for IP version 6 (IPv6)", RFC 4861, 1102 September 2007. 1104 [RFC4862] Thomson, S., Narten, T., and T. Jinmei, "IPv6 Stateless 1105 Address Autoconfiguration", RFC 4862, September 2007. 1107 [W3C.REC-xml-19980210] 1108 Sperberg-McQueen, C., Bray, T., and J. Paoli, "XML 1.0 1109 Recommendation", World Wide Web Consortium 1110 FirstEdition REC-xml-19980210, February 1998, 1111 . 1113 [I-D.shelby-core-resource-directory] 1114 Shelby, Z. and S. Krco, "CoRE Resource Directory", 1115 draft-shelby-core-resource-directory-00 (work in 1116 progress), June 2011. 1118 [I-D.ietf-roll-rpl] 1119 Winter, T., Thubert, P., Brandt, A., Clausen, T., Hui, J., 1120 Kelsey, R., Levis, P., Pister, K., Struik, R., and J. 1121 Vasseur, "RPL: IPv6 Routing Protocol for Low power and 1122 Lossy Networks", draft-ietf-roll-rpl-19 (work in 1123 progress), March 2011. 1125 [I-D.jennings-senml] 1126 Jennings, C., "Media Type for Sensor Markup Language 1127 (SENML)", draft-jennings-senml-05 (work in progress), 1128 March 2011. 1130 [arkko.iab] 1131 Arkko, J., "Interoperability Concerns in the Internet of 1132 Things", Position paper at the IAB workshop on Smart 1133 Objects , March 2011, . 1136 Appendix A. Acknowledgments 1138 The authors would like to thank to Magnus Westerlund, Ari Keranen, 1139 Stig Venaas, Zach Shelby, Cullen Jennings, Vlasios Tsiatsis, Jan 1140 Holler, Anders Eriksson, and Joel Halpern for their help and for 1141 interesting discussions in this problem space. 1143 Authors' Addresses 1145 Jari Arkko 1146 Ericsson 1147 Jorvas 02420 1148 Finland 1150 Email: jari.arkko@piuha.net 1152 Heidi-Maria Rissanen 1153 Ericsson 1154 Jorvas 02420 1155 Finland 1157 Email: heidi-maria.rissanen@ericsson.com 1159 Salvatore Loreto 1160 Ericsson 1161 Jorvas 02420 1162 Finland 1164 Email: salvatore.loreto@ericsson.com 1166 Zoltan Turanyi 1167 Ericsson 1168 Irinyi Jozsef u. 4-20. 1169 Budabest 1170 Hungary 1172 Email: zoltan.turanyi@ericsson.com 1173 Oscar Novo 1174 Ericsson 1175 Jorvas 02420 1176 Finland 1178 Email: oscar.novo@ericsson.com