idnits 2.17.1 draft-ietf-lwig-guidance-01.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 : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1106 has weird spacing: '...Counter lowp...' == Line 1107 has weird spacing: '...Counter lowp...' == Line 1108 has weird spacing: '...Counter ipv6...' -- The document date (July 16, 2012) is 4273 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'RFC2873' is mentioned on line 511, but not defined ** Obsolete undefined reference: RFC 2873 (Obsoleted by RFC 9293) == Missing Reference: 'RFC2581' is mentioned on line 522, but not defined ** Obsolete undefined reference: RFC 2581 (Obsoleted by RFC 5681) == Missing Reference: 'Jac88' is mentioned on line 524, but not defined == Missing Reference: 'RFC1323' is mentioned on line 549, but not defined ** Obsolete undefined reference: RFC 1323 (Obsoleted by RFC 7323) == Missing Reference: 'RFC3390' is mentioned on line 573, but not defined == Missing Reference: 'RFC3782' is mentioned on line 580, but not defined ** Obsolete undefined reference: RFC 3782 (Obsoleted by RFC 6582) == Missing Reference: 'RFC2018' is mentioned on line 590, but not defined == Missing Reference: 'RFC2883' is mentioned on line 596, but not defined == Missing Reference: 'RFC2923' is mentioned on line 624, but not defined == Missing Reference: '0x02' is mentioned on line 1136, but not defined == Missing Reference: '0x01' is mentioned on line 1136, but not defined == Missing Reference: '0x00' is mentioned on line 1136, but not defined == Missing Reference: 'AVPs' is mentioned on line 1359, but not defined == Missing Reference: 'PRF-Algorithm' is mentioned on line 1307, but not defined == Missing Reference: 'Integrity-Algorithm' is mentioned on line 1307, but not defined == Missing Reference: 'Nonce' is mentioned on line 1366, but not defined == Missing Reference: 'EAP-Payload' is mentioned on line 1368, but not defined == Missing Reference: 'Key-Id' is mentioned on line 1372, but not defined == Missing Reference: 'AUTH' is mentioned on line 1372, but not defined == Outdated reference: A later version (-18) exists of draft-ietf-core-coap-10 == Outdated reference: A later version (-01) exists of draft-kivinen-ipsecme-ikev2-minimal-00 -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 4614 (Obsoleted by RFC 7414) Summary: 4 errors (**), 0 flaws (~~), 25 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 LWIG Working Group C. Bormann, Ed. 3 Internet-Draft Universitaet Bremen TZI 4 Intended status: Informational July 16, 2012 5 Expires: January 17, 2013 7 Guidance for Light-Weight Implementations of the Internet Protocol Suite 8 draft-ietf-lwig-guidance-01 10 Abstract 12 Implementation of Internet protocols on small devices benefits from 13 light-weight implementation techniques, which are often not 14 documented in an accessible way. 16 This document provides a first outline of and some initial content 17 for the Light-Weight Implementation Guidance document planned by the 18 IETF working group LWIG. 20 Status of this Memo 22 This Internet-Draft is submitted in full conformance with the 23 provisions of BCP 78 and BCP 79. 25 Internet-Drafts are working documents of the Internet Engineering 26 Task Force (IETF). Note that other groups may also distribute 27 working documents as Internet-Drafts. The list of current Internet- 28 Drafts is at http://datatracker.ietf.org/drafts/current/. 30 Internet-Drafts are draft documents valid for a maximum of six months 31 and may be updated, replaced, or obsoleted by other documents at any 32 time. It is inappropriate to use Internet-Drafts as reference 33 material or to cite them other than as "work in progress." 35 This Internet-Draft will expire on January 17, 2013. 37 Copyright Notice 39 Copyright (c) 2012 IETF Trust and the persons identified as the 40 document authors. All rights reserved. 42 This document is subject to BCP 78 and the IETF Trust's Legal 43 Provisions Relating to IETF Documents 44 (http://trustee.ietf.org/license-info) in effect on the date of 45 publication of this document. Please review these documents 46 carefully, as they describe your rights and restrictions with respect 47 to this document. Code Components extracted from this document must 48 include Simplified BSD License text as described in Section 4.e of 49 the Trust Legal Provisions and are provided without warranty as 50 described in the Simplified BSD License. 52 Table of Contents 54 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 55 1.1. Objectives . . . . . . . . . . . . . . . . . . . . . . . . 4 56 1.2. Call for contributions . . . . . . . . . . . . . . . . . . 6 57 1.3. Terminology . . . . . . . . . . . . . . . . . . . . . . . 6 58 2. Drawing the Landscape . . . . . . . . . . . . . . . . . . . . 7 59 2.1. Classes of Devices . . . . . . . . . . . . . . . . . . . . 7 60 2.2. Design Objectives . . . . . . . . . . . . . . . . . . . . 7 61 2.3. Implementation Styles . . . . . . . . . . . . . . . . . . 8 62 2.4. Roles of nodes . . . . . . . . . . . . . . . . . . . . . . 9 63 2.5. Overview over the document . . . . . . . . . . . . . . . . 9 64 3. Data Plane Protocols . . . . . . . . . . . . . . . . . . . . . 10 65 3.1. Link Adaptation Layer . . . . . . . . . . . . . . . . . . 10 66 3.1.1. Fragmentation in a 6LoWPAN Route-Over Configuration . 10 67 3.1.1.1. Implementation Considerations for 68 Not-So-Constrained Nodes . . . . . . . . . . . . . 11 69 3.2. Network Layer . . . . . . . . . . . . . . . . . . . . . . 11 70 3.3. Transport Layer . . . . . . . . . . . . . . . . . . . . . 11 71 3.3.1. TCP . . . . . . . . . . . . . . . . . . . . . . . . . 12 72 3.3.1.1. Absolutely required TCP behaviors for proper 73 functioning and interoperability . . . . . . . . . 12 74 3.3.1.2. Strongly encouraged, but non-essential, 75 behaviors of TCP . . . . . . . . . . . . . . . . . 13 76 3.3.1.3. Experimental extensions that are not yet 77 standard practices . . . . . . . . . . . . . . . . 15 78 3.3.1.4. Others . . . . . . . . . . . . . . . . . . . . . . 15 79 3.4. Application Layer . . . . . . . . . . . . . . . . . . . . 15 80 3.4.1. General considerations about Application 81 Programming Interfaces (APIs) . . . . . . . . . . . . 15 82 3.4.2. Constrained Application Protocol (CoAP) . . . . . . . 16 83 3.4.2.1. Message Layer Processing . . . . . . . . . . . . . 17 84 3.4.2.2. Message Parsing . . . . . . . . . . . . . . . . . 18 85 3.4.2.3. Storing Used Message IDs . . . . . . . . . . . . . 19 86 3.4.3. (Other Application Protocols...) . . . . . . . . . . . 22 87 4. Control Plane Protocols . . . . . . . . . . . . . . . . . . . 23 88 4.1. Link Layer Support . . . . . . . . . . . . . . . . . . . . 23 89 4.2. Network Layer . . . . . . . . . . . . . . . . . . . . . . 23 90 4.3. Routing . . . . . . . . . . . . . . . . . . . . . . . . . 23 91 4.4. Host Configuration and Lookup Services . . . . . . . . . . 23 92 4.5. Network Management . . . . . . . . . . . . . . . . . . . . 23 93 4.5.1. SNMP . . . . . . . . . . . . . . . . . . . . . . . . . 23 94 4.5.1.1. Background . . . . . . . . . . . . . . . . . . . . 24 95 4.5.1.2. Revisiting SNMP implementation for resource 96 constrained devices . . . . . . . . . . . . . . . 24 97 4.5.1.3. Proposed approach for building an memory 98 efficient SNMP agent . . . . . . . . . . . . . . . 25 99 4.5.1.4. Example . . . . . . . . . . . . . . . . . . . . . 25 100 4.5.1.5. Further improvements . . . . . . . . . . . . . . . 28 101 4.5.1.6. Conclusion . . . . . . . . . . . . . . . . . . . . 28 102 5. Security protocols . . . . . . . . . . . . . . . . . . . . . . 29 103 5.1. Cryptography for Constrained Devices . . . . . . . . . . . 29 104 5.2. Transport Layer Security . . . . . . . . . . . . . . . . . 29 105 5.3. Network Layer Security . . . . . . . . . . . . . . . . . . 29 106 5.4. Network Access Control . . . . . . . . . . . . . . . . . . 29 107 5.4.1. PANA . . . . . . . . . . . . . . . . . . . . . . . . . 29 108 5.4.1.1. PANA AVPs . . . . . . . . . . . . . . . . . . . . 29 109 5.4.1.2. PANA Phases . . . . . . . . . . . . . . . . . . . 30 110 5.4.1.3. PANA session state parameters . . . . . . . . . . 32 111 6. Wire-Visible Constraints . . . . . . . . . . . . . . . . . . . 35 112 7. Wire-Invisible Constraints . . . . . . . . . . . . . . . . . . 36 113 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 37 114 9. Security Considerations . . . . . . . . . . . . . . . . . . . 38 115 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 39 116 10.1. Contributors . . . . . . . . . . . . . . . . . . . . . . . 39 117 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 40 118 11.1. Normative References . . . . . . . . . . . . . . . . . . . 40 119 11.2. Informative References . . . . . . . . . . . . . . . . . . 40 120 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 42 122 1. Introduction 124 Today's Internet is experienced by users as a set of applications, 125 such as email, instant messaging, and social networks. There are 126 substantial differences in performance between the various end 127 devices with these applications, but in general end devices 128 participating in the Internet today are considered to have relatively 129 high performance. 131 More and more communications technology is being embedded into our 132 environment. Different types of devices in our buildings, vehicles, 133 equipment and other objects have a need to communicate. It is 134 expected that most of these devices will employ the Internet Protocol 135 suite. The term "Internet of Things" denotes a trend where a large 136 number of devices directly benefit from communication services that 137 use Internet protocols. Many of these devices are not primarily 138 computing devices operated by humans, but exist as components in 139 buildings, vehicles, and the environment. There will be a lot of 140 variation in the computing power, available memory, communications 141 bandwidth, and other capabilities between different types of these 142 devices. With many low-cost, low-power and otherwise constrained 143 devices, it is not always easy to embed all the necessary features. 145 Historically, there has been a trend to invent special "light-weight" 146 _protocols_ to connect the most constrained devices. However, much 147 of this development can simply run on existing Internet protocols, 148 provided some attention is given to achieving light-weight 149 _implementations_. In some cases the new, constrained environments 150 can indeed benefit from protocol optimizations and additional 151 protocols that help optimize Internet communications and lower the 152 computational requirements. Examples of IETF standardization efforts 153 targeted for these environments include the "IPv6 over Low power WPAN 154 (6LoWPAN)", "Routing Over Low power and Lossy networks (ROLL)", and 155 "Constrained RESTful Environments (CoRE)" working groups. More 156 generally, however, techniques are required to implement both these 157 optimized protocols as well as the other protocols of the Internet 158 protocol suite in a way that makes them applicable to a wider range 159 of devices. 161 1.1. Objectives 163 The present document, a product of the IETF Light-Weight 164 Implementation Guidance (LWIG) Working Group, focuses on helping the 165 implementers of the smallest devices. The goal is to be able to 166 build minimal yet interoperable IP-capable devices for the most 167 constrained environments. 169 Building a small implementation does not have to be hard. Many small 170 devices use stripped down versions of general purpose operating 171 systems and their TCP/IP stacks. However, there are implementations 172 that go even further in minimization and can exist in as few as a 173 couple of kilobytes of code, as on some devices this level of 174 optimization is necessary. Technical and cost considerations may 175 limit the computing power, battery capacity, available memory, or 176 communications bandwidth that can be provided. To overcome these 177 limitations the implementers have to employ the right hardware and 178 software mechanisms. For instance, certain types of memory 179 management or even fixed memory allocation may be required. It is 180 also useful to understand what is necessary from the point of view of 181 the communications protocols and the application employing them. For 182 instance, a device that only acts as a client or only requires one 183 connection can simplify its TCP implementation considerably. 185 The purpose of this document is to collect experiences from 186 implementers of IP stacks in constrained devices. The focus is on 187 techniques that have been used in actual implementations and do not 188 impact interoperability with other devices. The techniques shall 189 also not affect conformance to the relevant specifications. We 190 describe implementation techniques for reducing complexity, memory 191 footprint, or power usage. 193 The topics for this working group will be chosen from Internet 194 protocols that are in wide use today, such as IPv4 and IPv6; UDP and 195 TCP; ICMPv4/v6, MLD/IGMP and ND; DNS and DHCPv4/v6; TLS, DTLS and 196 IPsec; as well as from the optimized protocols that result from the 197 work of the 6LoWPAN, RPL, and CoRE working groups. This document 198 will be helpful for the implementers of new devices or for the 199 implementers of new general-purpose small IP stacks. It is also 200 expected that the document will increase our knowledge of what 201 existing small implementations do, and will help in the further 202 optimization of the existing implementations. In areas where the 203 considerations for small implementations have already been documented 204 in an accessible way, we will refer to those documents instead of 205 duplicating the material here. 207 Generic hardware design advice and software implementation techniques 208 are outside the scope of this document. Protocol implementation 209 experience, however, is the focus. There is no intention to describe 210 any new protocols or protocol behavior modifications beyond what is 211 already allowed by existing RFCs, because it is important to ensure 212 that different types of devices can work together. For example, 213 implementation techniques relating to security mechanisms are within 214 scope, but mere removal of security functionality from a protocol is 215 rarely an acceptable approach. 217 1.2. Call for contributions 219 The present draft of the document is an outline that will grow with 220 the contributions received, which are expressly invited. As this 221 document focuses on experience from existing implementations, this 222 requires implementer input; in particular, participation is required 223 from the implementers of existing small IP stacks. "Small" here is 224 intended to be applicable approximately to what is described in 225 Section 2 -- where it is more important that the technique described 226 is grounded in actual experience than that the experience is actually 227 from a (very) constrained system. 229 Only a few subsections are fleshed out in this initial draft; 230 additional subsections will quickly be integrated from additional 231 contributors. 233 1.3. Terminology 235 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 236 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 237 document are to be interpreted as described in RFC 2119. As this is 238 an informational document, the [RFC2119] keywords will only be used 239 to underscore requirements where similar key words apply in the 240 context of the specifications the light-weight implementation of 241 which is being discussed. 243 The term "byte" is used in its now customary sense as a synonym for 244 "octet". 246 2. Drawing the Landscape 248 There is not a single kind of constrained, Internet-connected device. 249 To the contrary, the trend is towards much more functional variety of 250 such devices than is customary today in the Internet. This section 251 introduces a number of terms that will be used to locate some of the 252 technique described in the following sections within certain areas of 253 applications. 255 2.1. Classes of Devices 257 Despite the overwhelming variety of Internet-connected devices that 258 can be envisioned, it may, be worthwhile to have some succinct 259 terminology for different classes of constrained devices. In this 260 document, the following class designations may be used as rough 261 indications of device capabilities: 263 +---------+-----------------------+-------------------------+ 264 | Name | data size (e.g., RAM) | code size (e.g., Flash) | 265 +---------+-----------------------+-------------------------+ 266 | Class 1 | ~ 10 KiB | ~ 100 KiB | 267 | | | | 268 | Class 2 | ~ 50 KiB | ~ 250 KiB | 269 +---------+-----------------------+-------------------------+ 271 As of the writing of this document, these characteristics correspond 272 to distinguishable sets of commercially available chips and design 273 cores for constrained devices. While it is expected that the 274 boundaries of these classes will move over time, Moore's law tends to 275 be less effective in the embedded space than in personal computing 276 devices: Gains made available by increases in transistor count and 277 density are more likely to be invested in reductions of cost and 278 power requirements than into continual increases in computing power. 280 2.2. Design Objectives 282 o Consideration for design or implementation approaches for 283 implementation of IP stacks for constrained devices will be 284 impacted by the RAM usage for these designs. Here the 285 consideration is what is the best approach to minimize overhead. 287 o In addition, the impact on throughput in terms of IP protocol 288 implementation must take into consideration the methods that 289 minimize overhead but balance performance requirements for the 290 light-weight constrained devices. 292 o Protocol implementation must consider its impact on CPU 293 utilization. Here guidance will be provided on how to minimize 294 tasks that require additional CPU execution time. 296 How does the implementation of the IP stack effect the application 297 both in terms of performance but also of those same attributes and 298 requirements (RAM, CPU usage, etc.) that we are examining for the IP 299 protocol stack? 301 From performing a synthesis of implementation experiences we will be 302 able to understand and document the benefits and consequences of 303 varied approaches. Scaling code and selected approaches in terms of 304 scaling from, say, a 8-bit micro to a 16-bit micro. Such scaling for 305 the approach will aid in the development of single code base when 306 possible. 308 2.3. Implementation Styles 310 Compared to personal computing devices, constrained devices tend to 311 make use of quite different classes of operating systems, if that 312 term is even applicable. 314 ... 316 o Single-threaded/giant mainloop 318 o Event-driven vs. threaded/blocking 320 * The usual multi-threaded model blocks a thread on primitives 321 such as connect(), accept() or read() until an external event 322 takes place. This model is often thought to consume too much 323 RAM and CPU processing. 325 * The event driven model uses a non-blocking approach: E.g., when 326 an application interface sends a message, the routine would 327 return immediately (before the message is sent). A call-back 328 facility notifies the application or calling code when the 329 desired processing is completed. Here the benefit is that no 330 thread context needs to be preserved for long periods of time. 332 o Single/multiple processing elements 334 o E.g., separate radio/network processor 336 Introduce these briefly: Some techniques may be applicable only to 337 some of these styles! 339 2.4. Roles of nodes 341 Constrained nodes are by necessity more specialized than general 342 purpose computing devices; they may have a quite specific role. Some 343 implementation techniques may also 345 o Constrained nodes 347 o Nodes talking to constrained nodes 349 o Gateways/Proxies 351 In all these cases, constrained nodes that are "sleepy" pose 352 additional considerations. (Explain sleepy...) E.g., a node talking 353 to a sleepy node may need to make special arrangements; this is even 354 more true where a gateway or proxy interfaces the general Internet 356 o Bandwidth/latency considerations 358 2.5. Overview over the document 360 The following sections will first go through a number of specific 361 protocol layers, starting from layers of the data plane (link 362 adaptation, network, transport, application), followed by control 363 plane protocol layers (link layer support, network layer and routing, 364 host configuration and lookup services). We then look at security 365 protocols (general cryptography considerations, transport layer 366 security, network layer security, network access control). Finally, 367 we discuss some specific, cross-layer concerns, some "wire-visible", 368 some of concern within a specific implementation. Clearly, many 369 topics could be discussed in more than one place in this structure. 370 The objective is not to have something for each of the potential 371 topics, but to document the most valuable experience that may be 372 available. 374 3. Data Plane Protocols 376 3.1. Link Adaptation Layer 378 6LoWPAN 380 3.1.1. Fragmentation in a 6LoWPAN Route-Over Configuration 382 Author: Carsten Bormann 384 6LoWPAN [RFC4944] is an adaptation layer that maps IPv6 with its 385 minimum MTU of 1280 bytes to IEEE 802.15.4, which has a physical 386 layer MTU of only 127 bytes (some of which are taken by MAC layer and 387 adaptation layer headers). Therefore, the adaptation layer provides 388 a fragmentation and reassembly scheme that can fragment a single IPv6 389 packet of up to 1280 bytes into multiple adaptation layer fragments 390 of up to 127 bytes each (including MAC and adaptation layer 391 overhead). 393 In a route-over configuration, implementing this adaptation layer 394 fragmentation scheme straightforwardly means that reassembly and then 395 fragmentation are performed at each forwarding hop. As fragments 396 from several packets may be arriving interleaved with each other, 397 this approach requires buffer space for multiple MTU-size IPv6 398 packets. 400 In a mesh-under configuration, adaptation layer fragments can be 401 forwarded independently of each other. It would be preferable if 402 something similar were possible for route-over. Complete 403 independence in forwarding of adaptation layer fragments is not 404 possible for route-over, however, as the layer-3 addresses needed for 405 forwarding are in the initial bytes of the IPv6 header, which is 406 present only in the first fragment of a larger packet. 408 Instead of performing a full reassembly, implementations may be able 409 to optimize this process by not keeping a full reassembly buffer, but 410 just a runt buffer (called "virtual reassembly buffer" in [WEI]) for 411 each IP packet. This buffer caches only the datagram_tag field (as 412 usual combined with the sender's link layer address, the 413 destination's link layer address and the datagram_size field) and the 414 IPv6 header including the relevant addresses. Initial fragments are 415 then forwarded independently (after header decompression/compression) 416 and create a runt reassembly buffer. Non-initial fragments (which 417 don't require header decompression/compression in 6LoWPAN) are 418 matched against the runt buffers by datagram_tag etc. and forwarded 419 if an IPv6 address is available. (This simple scheme may be 420 complicated a bit if header decompression/compression of the initial 421 fragment causes an overflow of the physical MTU; in this case some 422 overflow data may need to be stored in the runt buffers to be 423 combined with further fragments or may simply be forwarded as a 424 separate additional fragment.) 426 If non-initial fragments arrive out of order before the initial 427 fragment, a route-over router may want to keep the contents of the 428 non-initial fragments until the initial fragment is available, which 429 does need some buffer space. If that is not available, a more 430 constrained route-over router may simply discard out-of order non- 431 initial fragments, possibly taking note that there is no point in 432 forwarding any more fragments with the same combination of 6LoWPAN 433 datagram_tag field, L2 addresses and datagram_size. 435 Runt buffers should time out like full reassembly buffers, and may 436 either keep a map of fragments forwarded or they may simply be 437 removed upon forwarding the final fragment, assuming that no out-of- 438 order fragments will follow. 440 3.1.1.1. Implementation Considerations for Not-So-Constrained Nodes 442 [RFC4944] makes no explicit mandates about the order in which 443 fragments should be sent. Because it is heavily favored by the above 444 implementation techniques, it is highly advisable for all 445 implementations to always send adaptation layer fragments in natural 446 order, i.e., starting with the initial fragment, continuing with 447 increasing datagram_offset. 449 3.2. Network Layer 451 IPv4 and IPv6 453 3.3. Transport Layer 455 TCP and UDP 457 Both TCP and UDP employ 16-bit one's-complement checksums to protect 458 against transmission errors. A number of RFCs discuss efficient 459 implementation techniques for computing and updating Internet 460 Checksums [RFC1071] [RFC1141] [RFC1624]. (Updating the Internet 461 Checksum, as opposed to computing it from scratch, may be of interest 462 where a pre-computed packet is provided, e.g., in Flash ROM, and a 463 copy is made in RAM and updated with some current values, or when the 464 actual transmitted packet is composed from pre-defined parts in ROM 465 and new parts in RAM.) 467 3.3.1. TCP 469 Ed. Note: 471 The following outline of a section is an attempt to provide 472 substructure for a future discussion of TCP-related issues based on 473 the TCP Roadmap, [RFC4614]. The indented text, as well as the RFC 474 citations, are copied (and redacted) from there; this certainly needs 475 to be refined in a future version. (Some additional adaptation of 476 the material may also be required as RFC 2581 was since obsoleted by 477 RFC 5681, and RFC 3782 was obsoleted by RFC 6582.) 479 Author: Yuanchen Ma 481 In [RFC4614], the TCP related RFCs are summarized. Some RFCs 482 describe absolutely required TCP behaviors for proper functioning and 483 interoperability. Further RFCs describe strongly encouraged, but 484 non-essential, behaviors. There are also experimental extensions 485 that are not yet standard practices, but that potentially could be in 486 the future. 488 In this subsection, the influence of resource constrained nodes on 489 TCP implementations are summarized according to the lists of 490 [RFC4614]. 492 3.3.1.1. Absolutely required TCP behaviors for proper functioning and 493 interoperability 495 RFC 793 S: "Transmission Control Protocol", STD 7 (September 1981) 497 In RFC793, the TCP state machine and event processing, and TCP's 498 semantics for data transmission, reliability, flow control, 499 multiplexing, and acknowledgment. For this part, the constraint of 500 memory will limit the multiplexing capability of TCP. /_text needed 501 for RFC793_/ 503 RFC 1122 S: "Requirements for Internet Hosts - Communication Layers" 504 (October 1989) 506 RFC 2460 S: "Internet Protocol, Version 6 (IPv6) Specification 507 (December 1998) 509 RFC 2873 S: "TCP Processing of the IPv4 Precedence Field" (June 2000) 511 This document [RFC2873] removes from the TCP specification all 512 processing of the precedence bits of the TOS byte of the IP 513 header. 515 These three RFCs mandate the support for IPv6 and TOS in IP header, 516 which are a must for resource constrained node to implement. 518 RFC 2581 S: "TCP Congestion Control" (April 1999) 520 Although RFC 793 did not contain any congestion control 521 mechanisms, today congestion control is a required component of 522 TCP implementations. This document [RFC2581] defines the current 523 versions of Van Jacobson's congestion avoidance and control 524 mechanisms for TCP, based on his 1988 SIGCOMM paper [Jac88]. RFC 525 2001 was a conceptual precursor that was obsoleted by RFC 2581. 527 A number of behaviors that together constitute what the community 528 refers to as "Reno TCP" are described in RFC 2581. 530 RFC 1122 mandates the implementation of a congestion control 531 mechanism, and RFC 2581 details the currently accepted mechanism. 532 RFC 2581 differs slightly from the other documents listed in this 533 section, as it does not affect the ability of two TCP endpoints to 534 communicate; however, congestion control remains a critical 535 component of any widely deployed TCP implementation and is 536 required for the avoidance of congestion collapse and to ensure 537 fairness among competing flows. 539 RFC 2988 S: "Computing TCP's Retransmission Timer" (November 2000) 541 Abstract: "This document defines the standard algorithm that 542 Transmission Control Protocol (TCP) senders are required to use to 543 compute and manage their retransmission timer. 545 3.3.1.2. Strongly encouraged, but non-essential, behaviors of TCP 547 RFC 1323 S: "TCP Extensions for High Performance" (May 1992) 549 This document [RFC1323] defines TCP extensions for window scaling, 550 timestamps, and protection against wrapped sequence numbers, for 551 efficient and safe operation over paths with large bandwidth-delay 552 products. 554 RFC 2675 S: "IPv6 Jumbograms" (August 1999) 556 IPv6 supports longer datagrams than were allowed in IPv4. 558 RFC 3168 S: "The Addition of Explicit Congestion Notification (ECN) 559 to IP" (September 2001) 561 3.3.1.2.1. Congestion Control and Loss Recovery Extensions 563 RFC 3042 S: "Enhancing TCP's Loss Recovery Using Limited Transmit" 564 (January 2001) 566 Abstract: "This document proposes Limited Transmit, a new 567 Transmission Control Protocol (TCP) mechanism that can be used to 568 more effectively recover lost segments when a connection's 569 congestion window is small 571 RFC 3390 S: "Increasing TCP's Initial Window" (October 2002) 573 This document [RFC3390] updates RFC 2581 to permit an initial TCP 574 window of three or four segments during the slow-start phase, 575 depending on the segment size. 577 RFC 3782 S: "The NewReno Modification to TCP's Fast Recovery 578 Algorithm" (April 2004) 580 This document [RFC3782] specifies a modification to the standard 581 Reno fast recovery algorithm, whereby a TCP sender can use partial 582 acknowledgments to make inferences determining the next segment to 583 send in situations where SACK would be helpful but isn't 584 available. 586 3.3.1.2.2. SACK-Based Loss Recovery and Congestion Control 588 RFC 2018 S: "TCP Selective Acknowledgment Options" (October 1996) 590 This document [RFC2018] defines the basic selective acknowledgment 591 (SACK) mechanism for TCP. 593 RFC 2883 S: "An Extension to the Selective Acknowledgement (SACK) 594 Option for TCP" (July 2000) 596 This document [RFC2883] extends RFC 2018 to cover the case of 597 acknowledging duplicate segments. 599 RFC 3517 S: "A Conservative Selective Acknowledgment (SACK)-based 600 Loss Recovery Algorithm for TCP" (April 2003) 602 3.3.1.2.3. Dealing with Forged Segments 604 RFC 1948 I: "Defending Against Sequence Number Attacks" (May 1996) 606 RFC 2385 S: "Protection of BGP Sessions via the TCP MD5 Signature 607 Option" (August 1998) 609 3.3.1.3. Experimental extensions that are not yet standard practices 611 The experimental extensions are not mature yet. The contents need to 612 be validated to be safe and logical behavior. It is not recommended 613 for the resource constrained node to implement. 615 3.3.1.4. Others 617 RFC 2923 I: "TCP Problems with Path MTU Discovery" (September 2000) 619 From abstract: "This memo catalogs several known Transmission 620 Control Protocol (TCP) implementation problems dealing with Path 621 Maximum Transmission Unit Discovery (PMTUD), including the long- 622 standing black hole problem, stretch acknowlegements (ACKs) due to 623 confusion between Maximum Segment Size (MSS) and segment size, and 624 MSS advertisement based on PMTU." [RFC2923] 626 3.4. Application Layer 628 3.4.1. General considerations about Application Programming Interfaces 629 (APIs) 631 Author: Carl Williams 633 Constrained devices are not necessarily in a position to use APIs 634 that would be considered "standard" for less constrained environments 635 (e.g., Berkeley sockets or those defined by POSIX). 637 When an API implements a protocol, this can be based on proxy methods 638 for remote invocations that underneath rely on the communication 639 protocol. One of the roles of the API can be exactly to hide the 640 detail of the transport protocol. 642 Changes to the lower layers will be made to implement light-weight 643 stacks so this impacts that implementation and inter-workings with 644 the API. Similar considerations such as RAM, CPU utilization and 645 performance requirements apply to the API and its use of the lower 646 layer resources (i.e., buffers). 648 Considerations for the proper approach for a developer to request 649 services from an application program need to be explored and 650 documented. Such considerations will allow the progression of a 651 common consistent networking paradigm without inventing a new way of 652 programming these devices. 654 In addition, such considerations will take into account the inter- 655 working of the API with the protocols. Protocols are more complex to 656 use as they are less direct and take a lot of serializing, de- 657 serializing and dispatching type logic. 659 So the connection of the API and the protocols on a constrained 660 device becomes even more important to balance the requirements of 661 RAM, CPU and performance. 663 _** Here we will proceed to collect and document ... insert 664 experiences from existing API on constrained devices (TBD) **_ 666 3.4.2. Constrained Application Protocol (CoAP) 668 Author: Olaf Bergmann 670 The Constrained Application Protocol [I-D.ietf-core-coap] has been 671 designed specifically for machine-to-machine communication in 672 networks with very constrained nodes. Typical application scenarios 673 therefore include building automation and the Internet of Things. 674 The major design objectives have been set on small protocol overhead, 675 robustness against packet loss, and high latency induced by small 676 bandwidth shares or slow request processing in end nodes. To 677 leverage integration of constrained nodes with the world-wide 678 Internet, the protocol design was led by the architectural style that 679 accounts for the scalability and robustness of the Hypertext Transfer 680 Protocol [RFC2616]. 682 Lightweight implementations benefit from this design in many 683 respects: First, the use of Uniform Resource Identifiers (URIs) for 684 naming resources and the transparent forwarding of their 685 representations in a server-stateless request/response protocol make 686 protocol-translation to HTTP a straightforward task. Second, the set 687 of protocol elements that are inevitable for the core protocol and 688 thus must be implemented on every node has been kept very small to 689 avoid unnecessary accumulation of optional features. Options that -- 690 when present -- are critical for message processing are explicitly 691 marked as such to force immediate rejection of messages with unknown 692 critical options. Third, the syntax of protocol data units is easy 693 to parse and is carefully defined to avoid creation of state in 694 servers where possible. 696 Although these features enable lightweight implementations of the 697 Constrained Application Protocol, there is still a trade-off between 698 robustness and latency of constrained nodes on one hand and resource 699 demands (such as battery consumption, dynamic memory needs and static 700 code-size) on the other. This section gives some guidance on 701 possible strategies to solve this trade-off for very constrained 702 nodes (Class 1 in Section 2.1). The main focus is on servers as this 703 is deemed the predominant case where CoAP applications are faced with 704 tight resource constraints. 706 Additional considerations for the implementation of CoAP on tiny 707 sensors are given in [I-D.arkko-core-sleepy-sensors]. 709 3.4.2.1. Message Layer Processing 711 For constrained nodes of Class 1 or even Class 2, limiting factors 712 for (wireless) network communication usually are RAM size and battery 713 lifetime. Most applications therefore try to avoid dealing with 714 fragmented packets on the network layer and minimize internal buffer 715 space for both transmit and receive operations. One of the most 716 expensive operations hence is the retransmission of messages as it 717 implies additional energy consumption for the (radio) network 718 interface and occupied RAM storage for the send buffer. 720 Where multi-threading is not an option at all because no full-fledged 721 operating system is present, all operations are triggered by a big 722 main loop in a send-receive-dispatch cycle. To implement the packet 723 retransmission, CoAP implementations at least need a separate send 724 buffer and a decent notion of time, e.g. as a strictly monotonic 725 increasing tick counter. For platforms that disable clock tick 726 interrupts in sleep states, the application must take into 727 consideration the clock deviation that occurs during sleep (or ensure 728 to remain in idle state until the message has been acknowledged or 729 the maximum number of retransmissions is reached). Since CoAP allows 730 up to four retransmissions with a binary exponential back-off it 731 could take up to 45 seconds until the send operation is complete. 732 Even in idle state, this means substantial energy consumption for 733 low-power nodes. Implementers therefore might choose a two-step 734 strategy: First, do one or two retransmissions and then, in the later 735 phases of back-off, go to sleep until the next retransmission is due. 736 In the meantime, the node could check for new messages including the 737 acknowledgement for any confirmable message to send. 739 A similar strategy holds for confirmable messages with separate 740 responses. This concept entitles CoAP servers to return an empty 741 acknowledgement to indicate that a confirmable request has been 742 understood and is being processed. Once a proper response has been 743 generate to fulfill the request, it is sent back as a confirmable 744 message as well. The server implementation in this case must be able 745 to map retransmissions of the original request to the ongoing 746 operation and provide the client-selected Token to map between 747 original request and the separate response. 749 Depending on the number of requests that can be handled in parallel, 750 an implementation might create a stub response filled with any option 751 that has to be copied from the original request to the separate 752 response, especially the Token option. The drawback of this 753 technique is that the server must be prepared to receive 754 retransmissions of the previous (confirmable) request to which a new 755 acknowledgement must be generated. If memory is an issue, a single 756 buffer can be used for both tasks: Only the message type and code 757 must be updated, changing the message id is optional. Once the 758 resource representation is known, it is added as new payload at the 759 end of the stub response. Acknowledgements still can be sent as 760 described before as long as no additional options are required to 761 describe the payload. 763 3.4.2.2. Message Parsing 765 Both CoAP clients and servers must construct outgoing CoAP PDUs and 766 parse incoming messages. The basic message header consists of only 767 four octets and thus can be mapped easily to an internal data 768 structure, considering the actual byte order of the host. Once the 769 message is accepted for further processing, the set of options 770 contained in the received message must be decoded to check for 771 unknown critical options. To avoid multiple passes through the 772 option list, the option parser might maintain a bit-vector where each 773 bit represents an option number that is present in the received 774 request. The delta-encoded option number indicates the number of 775 left-shift operations to apply on a bit mask to set the corresponding 776 bit. 778 In addition, the byte index of every option is added to a sparse list 779 (e.g. a one-dimensional array) for fast retrieval. This particularly 780 enables efficient reduced-function handling of options that might 781 occur more than once such as Uri-Path. In this implementation 782 strategy, the delta is zero for any subsequent path segment, hence 783 the stored byte index for option 9 (Uri-Path) will be overwritten to 784 hold a pointer to the last occurrence of that option, i.e., only the 785 last path component actually matters. (Of course, this requires 786 choosing resource names where the combination of (final Uri-Path 787 component, final Uri-Query component) is server-wide unique. 789 Note: Where skipping all but the last path segment is not feasible 790 for some reason, resource identification could be ensured by some 791 hash value calculated over the path segments. For each segment 792 encountered, the stored hash value is updated by the current 793 option value. This works if a cheap _perfect hashing_ scheme can 794 be found for the resource names. 796 Once the option list has been processed at least up to the highest 797 option number that is supported by the application, any known 798 critical option and all elective options can be masked out to 799 determine if any unknown critical option was present. If this is the 800 case, this information can be used to create a 4.02 response 801 accordingly. (Note that the remaining options also must be processed 802 to add further critical options included in the original request.) 804 3.4.2.3. Storing Used Message IDs 806 If CoAP is used directly on top of UDP (i.e., in NoSec mode), it 807 needs to cope with the fact that the UDP datagram transport can 808 reorder and duplicate messages. (In contrast to UDP, DTLS has its 809 own duplicate detection.) CoAP has been designed with protocol 810 functionality such that rejection of duplicate messages is always 811 possible. It is at the discretion of the receiver if it actually 812 wants to make use of this functionality. Processing of duplicate 813 messages comes at a cost, but so does the management of the state 814 associated with duplicate rejection. Hence, a receiver may have good 815 reasons to decide not to do the duplicate rejection. If duplicate 816 rejection is indeed necessary, e.g., for non-idempotent requests, it 817 is important to control the amount of state that needs to be stored. 819 Author: Esko Dijk 821 CoAP's duplicate rejection functionality can be straightforwardly 822 implemented in a CoAP end-point by storing, for each remote CoAP end- 823 point ("peer") that it communicates with, a list of recently received 824 CoAP Message IDs (MIDs) along with some timing information. A CoAP 825 message from a peer with a MID that is in the list for that peer can 826 simply be discarded. 828 The timing information in the list can then be used to time out 829 entries that are older than the _expected extent of the re-ordering_, 830 an upper bound for which can be estimated by adding the _potential 831 retransmission window_ ([I-D.ietf-core-coap] section "Reliable 832 Messages") and the time packets can stay alive in the network. 834 Such a straightforward implementation is suitable in case other CoAP 835 end-points generate random MIDs. However, this storage method may 836 consume substantial RAM in specific cases, such as: 838 o many clients are making periodic, non-idempotent requests to a 839 single CoAP server; 841 o one client makes periodic requests to a large number of CoAP 842 servers and/or requests a large number of resources; where servers 843 happen to mostly generate separate CoAP responses (not piggy- 844 backed); 846 For example, consider the first case where the expected extent of re- 847 ordering is 50 seconds, and N clients are sending periodic POST 848 requests to a single CoAP server during a period of high system 849 activity, each on average sending one client request per second. The 850 server would need 100 * N bytes of RAM to store the MIDs only. This 851 amount of RAM may be significant on a RAM-constrained platform. On a 852 number of platforms, it may be easier to allocate some extra program 853 memory (e.g. Flash or ROM) to the CoAP protocol handler process than 854 to allocate extra RAM. Therefore, one may try to reduce RAM usage of 855 a CoAP implementation at the cost of some additional program memory 856 usage and implementation complexity. 858 Some CoAP clients generate MID values by a using a Message ID 859 variable [I-D.ietf-core-coap] that is incremented by one each time a 860 new MID needs to be generated. (After the maximum value 65535 it 861 wraps back to 0.) We call this behavior "sequential" MIDs. One 862 approach to reduce RAM use exploits the redundancy in sequential MIDs 863 for a more efficient MID storage in CoAP servers. 865 Naturally such an approach requires, in order to actually reduce RAM 866 usage in an implementation, that a large part of the peers follow the 867 sequential MID behavior. To realize this optimization, the authors 868 therefore RECOMMEND that CoAP end-point implementers employ the 869 "sequential MID" scheme if there are no reasons to prefer another 870 scheme, such as randomly generated MID values. 872 Security considerations might call for a choice for 873 (pseudo)randomized MIDs. Note however that with truly randomly 874 generated MIDs the probability of MID collision is rather high in use 875 cases as mentioned before, following from the Birthday Paradox. For 876 example, in a sequence of 52 randomly drawn 16-bit values the 877 probability of finding at least two identical values is about 2 878 percent. 880 From here on we consider efficient storage implementations for MIDs 881 in CoAP end-points, that are optimized to store "sequential" MIDs. 882 Because CoAP messages may be lost or arrive out-of-order, a solution 883 has to take into account that received MIDs of CoAP messages are not 884 actually arriving in a sequential fashion, due to lost or reordered 885 messages. Also a peer might reset and lose its MID counter(s) state. 886 In addition, a peer may have a single Message ID variable used in 887 messages to many CoAP end-points it communicates with, which partly 888 breaks sequentiality from the receiving CoAP end-point's perspective. 889 Finally, some peers might use a randomly generated MID values 890 approach. Due to these specific conditions, existing sliding window 891 bitfield implementations for storing received sequence numbers are 892 typically not directly suitable for efficiently storing MIDs. 894 Table 1 shows one example for a per-peer MID storage design: a table 895 with a bitfield of a defined length _K_ per entry to store received 896 MIDs (one per bit) that have a value in the range [MID_i + 1 , MID_i 897 + K]. 899 +----------+----------------+-----------------+ 900 | MID base | K-bit bitfield | base time value | 901 +----------+----------------+-----------------+ 902 | MID_0 | 010010101001 | t_0 | 903 | | | | 904 | MID_1 | 111101110111 | t_1 | 905 | | | | 906 | ... etc. | | | 907 +----------+----------------+-----------------+ 909 Table 1: A per-peer table for storing MIDs based on MID\\_i 911 The presence of a table row with base MID_i (regardless of the 912 bitfield values) indicates that a value MID_i has been received at a 913 time t_i. Subsequently, each bitfield bit k (0...K-1) in a row i 914 corresponds to a received MID value of MID_i + k + 1. If a bit k is 915 0, it means a message with corresponding MID has not yet been 916 received. A bit 1 indicates such a message has been received already 917 at approximately time t_i. This storage structure allows e.g. with 918 k=64 to store in best case up to 130 MID values using 20 bytes, as 919 opposed to 260 bytes that would be needed for a non-sequential 920 storage scheme. 922 The time values t_i are used for removing rows from the table after a 923 preset timeout period, to keep the MID store small in size and enable 924 these MIDs to be safely re-used in future communications. (Note that 925 the table only stores one time value per row, which therefore needs 926 to be updated on receipt of another MID that is stored as a single 927 bit in this row. As a consequence of only storing one time value per 928 row, older MID entries typically time out later than with a simple 929 per-MID time value storage scheme. The end-point therefore needs to 930 ensure that this additional delay before MID entries are removed from 931 the table is much smaller than the time period after which a peer 932 starts to re-use MID values due to wrap-around of a peer's MID 933 variable. One solution is to check that a value t_i in a table row 934 is still recent enough, before using the row and updating the value 935 t_i to current time. If not recent enough, e.g. older than N 936 seconds, a new row with an empty bitfield is created.) [Clearly, 937 these optimizations would benefit if the peer were much more 938 conservative about re-using MIDs than currently required in the 939 protocol specification.] 941 The optimization described is less efficient for storing randomized 942 MIDs that a CoAP end-point may encounter from certain peers. To 943 solve this, a storage algorithm may start in a simple MID storage 944 mode, first assuming that the peer produces non-sequential MIDs. 945 While storing MIDs, a heuristic is then applied based on monitoring 946 some "hit rate", for example, the number of MIDs received that have a 947 Most Significant Byte equal to that of the previous MID divided by 948 the total number of MIDs received. If the hit rate tends towards 1 949 over a period of time, the MID store may decide that this particular 950 CoAP end-point uses sequential MIDs and in response improve 951 efficiency by switching its mode to the bitfield based storage. 953 3.4.3. (Other Application Protocols...) 954 4. Control Plane Protocols 956 4.1. Link Layer Support 958 ARP, ND; 6LoWPAN-ND 960 4.2. Network Layer 962 ICMP, ICMPv6, IGMP/MLD 964 4.3. Routing 966 RPL, AODV/DYMO, OLSRv2 968 4.4. Host Configuration and Lookup Services 970 DNS, DHCPv4, DHCPv6 972 4.5. Network Management 974 SNMP, netconf? 976 4.5.1. SNMP 978 Author: Brinda M C 980 This section describes an approach for developing a light-weight SNMP 981 agent for resource constrained devices running the 6LoWPAN/RPL 982 protocol stack. The motivation for the work is driven by two major 983 factors: 985 o SNMP plays a vital role in monitoring and managing any operational 986 network; 6LoWPAN based WSN is no exception to this. 988 o There is a need for building a light-weight SNMP agent which 989 consumes less memory and less computational resources. 991 The following subsections are organized as follows: 993 o Section 4.5.1.1 provides some background. 995 o In Section 4.5.1.2, we revisit existing SNMP implementation in the 996 context of memory constrained devices. 998 o In Section 4.5.1.3, we present our approach for building a memory 999 efficient SNMP agent. 1001 o Using a realistic example, in Section 4.5.1.4, we illustrate how 1002 the proposed method can be implemented. 1004 o In Section 4.5.1.5, we explore a few ideas which can further help 1005 in improving the memory utilization. 1007 4.5.1.1. Background 1009 Our initial SNMP agent implementation was completely based on Net- 1010 SNMP, well-known open-source network monitoring and management 1011 software. After porting the agent on to the TelosB mote, we observed 1012 that it occupies a text program memory of more than 8 KiB on TinyOS 1013 and Contiki OS platforms. (Note that both these platforms already 1014 use compiler optimizations to minimize the memory footprint.) 8 KiB 1015 is already non-negligible given the 48 KiB program memory limit of 1016 TelosB. Added to this, the memory taken up by 6LoWPAN and the 1017 related protocol stacks are ever growing, causing serious memory 1018 crunch in the resource constrained devices. We reached a situation 1019 where we could not build an image on the TinyOS/Contiki OS platforms 1020 with our SNMP agent. 1022 We came across SNMPv1 agent implementations elsewhere in the 1023 literature which also report similar memory consumption. This 1024 motivated us to have a re-look at the existing SNMP agent 1025 implementation, and explore the possibility of an alternate 1026 implementation using altogether a different approach. 1028 4.5.1.2. Revisiting SNMP implementation for resource constrained 1029 devices 1031 If we look at a typical SNMP agent implementation, we can see that 1032 much of the memory consuming code is pertaining to ASN.1 related SNMP 1033 PDU parsing and SNMP PDU build operations. The SNMP parsing mainly 1034 recovers various fields from the incoming PDU, such as the OIDs, 1035 whereas the SNMP PDU build is the reverse operation of building the 1036 response PDU from the OIDs. 1038 The key observation is that, for a given MIB definition, an OID of 1039 interest contained in the incoming SNMP PDU is already available, 1040 albeit in an encoded form. This enables identifying the OID from the 1041 packet in its "raw" form, simplifying parser operation. 1043 We also can make use of this observation while building the response 1044 SNMP PDU. For a given MIB definition, we can think of statically 1045 having a pre-composed ASN.1 encoded version of OIDs, and use them 1046 while constructing the response SNMP PDU. 1048 4.5.1.3. Proposed approach for building an memory efficient SNMP agent 1050 As noted in the previous section, since an SNMP OID is already 1051 _contained_ in the incoming network PDU, we came up with a simple OID 1052 signature identification method performed directly on the network PDU 1053 through simple memory comparisons and table look-ups. Once the OID 1054 has been identified from the packet "in situ", the corresponding per- 1055 OID processing is carried out. Through this scheme we completely 1056 eliminated expensive SNMP parse operations. 1058 For the SNMP PDU build, we use _pre-encoded_ OID variables which can 1059 simply be plugged into the network SNMP response packet directly 1060 depending on the request OID. Now that the expensive build operation 1061 is taken care, what remains is the construction of the overall SNMP 1062 pdu which can be built through simple logic. Through this scheme we 1063 completely eliminated expensive SNMP build operations. 1065 Based on these ideas, we have re-architected our original SNMP agent 1066 implementation and with our new implementation we were able to bring 1067 down its text memory usage all the way down to 4 KiB from the native 1068 SNMP agent implementation which occupied 8 KiB. 1070 4.5.1.3.1. Discussion on memory usage 1072 With respect to the memory usage, while we have achieved major 1073 reduction in terms of text program memory, which occupies a major 1074 chunk of memory, a question might come to mind with regard to the 1075 static memory allocation for maintaining the tables. We found that 1076 this is not very significant to start with. Through an efficient 1077 table representation, we further optimized the memory consumption. 1078 We could do so because a typical OID description is mainly dominated 1079 by a fixed part of the hierarchy. This enables us to define few 1080 static prefixes, each corresponding to a particular hierarchy level 1081 of the OID. In the context of 6LoWPAN, it can be expected that the 1082 number of hierarchy levels will be small. 1084 4.5.1.4. Example 1086 This section illustrates the simplicity and practicality of our 1087 approach with an example. Let us consider the fragment of a 1088 representative MIB definition depicted in Figure 1 1089 iso 1090 | 1091 org 1092 | 1093 dod 1094 | 1095 internet 1096 | 1097 mgmt.mib-2 1098 | 1099 lowpanMIB 1100 | 1101 +--lowpanPrimaryStatistics(10) 1102 | 1103 +--PrimeStatsEntry(1) 1104 | 1105 +-- -R-- INTEGER lowpanMoteBatteryVoltageP(1) 1106 +-- -R-- Counter lowpanFramesReceivedP(2) 1107 +-- -R-- Counter lowpanFramesSentP(3) 1108 +-- -R-- Counter ipv6ForwardedMsgP(4) 1109 +-- -R-- Counter OUTSolicitationP(5) 1110 +-- -R-- Counter OUTAdvertisementP(6) 1112 Figure 1: A fragment of a MIB hierarchy 1114 4.5.1.4.1. Optimized SNMP Parsing 1116 Let us consider a GET request for the OIDs lowpanMoteBatteryVoltageP 1117 and lowpanFramesSentP. Corresponding to these OIDs, a C array dump 1118 of the network PDU of SNMP packet with two OIDs in a variable binding 1119 would look as in Figure 2. 1121 char snmp_get_req_pkt[] = { 1122 0x30, 0x81, 0x3d, 0x02, 0x01, 0x00, 0x04, 0x06, 1123 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0xa0, 0x30, 1124 0x02, 0x04, 0x28, 0x29, 0xe4, 0x5d, 0x02, 0x01, 1125 0x00, 0x02, 0x01, 0x00, 0x30, 0x22, 0x30, 0x0f, 1126 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x83, 1127 0x90, 0x12, 0x0a, 0x01, 0x01, 0x05, 0x00, 0x30, 1128 0x0f, 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 0x01, 1129 0x83, 0x90, 0x12, 0x0a, 0x01, 0x03, 0x05, 0x00 }; 1131 Figure 2: An SNMP packet, represented in C 1133 Inspecting the above packet, we see that the main components of the 1134 PDU are: 1136 1. Version (SNMPv1): [0x02, 0x01, 0x00] 1138 2. Community Name ("public"): [0x04, 0x06, 0x70, 0x75, 0x62, 0x6c, 1139 0x69, 0x63] 1141 3. ASN.1 encoded OIDs for lowpanMoteBatteryVoltageP, and 1142 lowpanFramesReceivedP: 1144 * [0x30, 0x0f, 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x83, 1145 0x90, 0x12, 0x0a, 0x01, 0x01, 0x05, 0x00] 1147 * [0x30, 0x0f, 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x83, 1148 0x90, 0x12, 0x0a, 0x01, 0x03, 0x05, 0x00] 1150 There is a significant overlap between the two OIDs, which can be 1151 used to simplify the parsing process. We can, for instance, define 1152 one statically initialized array containing elements common between 1153 these OIDs. Using this notion of common prefix idea, we can come up 1154 with an optimized table and the OID identification then boils down to 1155 simple memory comparisons within this table. The optimized table 1156 construction will also result in scalability. 1158 4.5.1.4.2. Optimized SNMP Build 1160 Extending the same approach as described above, we can build the GET 1161 response by plugging in pre-encoded OIDs into the response packets. 1162 So, corresponding to the GET request for the OIDs as given in section 1163 4.1, we can define C arrays containing pre-encoded OIDs which can go 1164 into the response packet as in Figure 3. 1166 pdu_batt_volt[] = { 1167 0x30, 0x11, 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 1168 0x01, 0x83, 0x90, 0x12, 0x0a, 0x01, 0x01, 0x02, 1169 0x02, 0x00, 0x00 }; 1171 pdu_frames_sent[] = { 1172 0x30, 0x11, 0x06, 0x0b, 0x2b, 0x06, 0x01, 0x02, 1173 0x01, 0x83, 0x90, 0x12, 0x0a, 0x01, 0x03, 0x41, 1174 0x02, 0x00, 0x00 }; 1176 Figure 3: Pre-encoded OIDs 1178 Since the ASN.1 basic encoding rules are in TLV format, the offset 1179 within the encoded OID where the value needs to be filled-in can be 1180 obtained from the length field. 1182 The table size optimization discussed in the previous section can be 1183 applied here, too. 1185 Note: Though we have taken a simple example to illustrate the 1186 efficacy of the proposed approach, the ideas presented here can 1187 easily be extended to other scenarios as well. 1189 4.5.1.5. Further improvements 1191 A few simple methods can reduce the code size as well as generate 1192 computationally inexpensive code. These methods might sound obvious 1193 and trivial but are important for constrained devices. 1195 o If possible, avoid using memory consuming data types such as 1196 floating point while representing a monitored variable when an 1197 equivalent representation of the same that occupies less memory is 1198 adequate. For example, while a battery voltage indication could 1199 take a fractional value between 0 and 3 V, opt for an 8-bit 1200 quantized value. 1202 o Using meta data in the MIB definition instead of absolute numbers 1203 can bring down the memory and processing significantly and can 1204 improve scalability too especially for a large scale WSN 1205 deployments. Using the same example of battery voltage, one might 1206 think of an OID which represents fewer levels of the battery 1207 voltage signifying high, medium, low, very low. 1209 o While a multi-level hierarchy for MIB definition might improve OID 1210 segregation the flip side is that it increases the overall length 1211 of the OID and results in extra memory and processing overhead. 1212 One may have to make a judicious choice while coming up with the 1213 MIB. 1215 4.5.1.6. Conclusion 1217 This subsection proposes a simple SNMP packet processing based 1218 approach for building a light-weight SNMP agent. While there is 1219 scope for further improvement, we believe that the proposed method 1220 can be a reasonably good starting point for resource constrained 1221 6LoWPAN based networks. 1223 5. Security protocols 1225 5.1. Cryptography for Constrained Devices 1227 5.2. Transport Layer Security 1229 TLS, DTLS, ciphersuites, certificates 1231 5.3. Network Layer Security 1233 IPsec, IKEv2, transforms 1235 Advice for a minimal implementation of IKEv2 can be found in 1236 [I-D.kivinen-ipsecme-ikev2-minimal]. 1238 5.4. Network Access Control 1240 (PANA, EAP, EAP methods) 1242 5.4.1. PANA 1244 Author: Mitsuru Kanda 1246 PANA [RFC5191] provides network access authentication between clients 1247 and access networks. The PANA protocol runs between a PANA Client 1248 (PaC) and a PANA Authentication Agent (PAA). PANA carries UDP 1249 encapsulated EAP [RFC3748] and includes various operational options. 1250 From the point of view of minimal implementation, some of these are 1251 not necessary for constrained devices. This section describes a 1252 minimal PANA implementation for these devices. 1254 The minimization objective for this implementation mainly targets 1255 PaCs because constrained devices often are installed as network 1256 clients, such as sensors, metering devices, etc. 1258 5.4.1.1. PANA AVPs 1260 Each PANA message can carry zero or more AVPs (Attribute-Value Pairs) 1261 within its payload. [RFC5191] specifies nine types of AVPs (AUTH, 1262 EAP-Payload, Integrity-Algorithm, Key-Id, Nonce, PRF-Algorithm, 1263 Result-Code, Session-Lifetime, and Termination-Cause). All of them 1264 are required by all minimal implementations. But there are some 1265 notes. 1267 Integrity-Algorithm AVP and PRF-Algorithm AVP: 1269 All PANA implementations MUST support AUTH_HMAC_SHA1_160 for PANA 1270 message integrity protection and PRF_HMAC_SHA1 for pseudo-random 1271 function (PRF) specified in [RFC5191]. Both of these are based on 1272 SHA-1, which therefore needs to be implemented in a minimal 1273 implementation. 1275 Nonce AVP: 1277 As the basic hash function is SHA-1, including a nonce of 20 bytes in 1278 the Nonce AVP is appropriate ([RFC5191], section 8.5). 1280 5.4.1.2. PANA Phases 1282 A PANA session consists of four phases -- Authentication and 1283 authorization phase, Access phase, Re-Authentication phase, and 1284 Termination phase. 1286 Authentication and authorization phase: 1288 There are two types of PANA session initiation, PaC-initiated session 1289 and PAA-initiated session. The minimal implementation must support 1290 PaC-initiated session and does not need to support PAA-initiated 1291 session. Because a PaC (a constrained device) which may be a 1292 sleeping device, can not receive an unsolicited PANA-Auth-Request 1293 message from a PAA (PAA-initiated session). 1295 EAP messages can be carried in PANA-Auth-Request and PANA-Auth-Answer 1296 messages. In order to reduce the number of messages, "Piggybacking 1297 EAP" is useful. Both the PaC and PAA should include EAP-Payload AVP 1298 in each of PANA-Auth-Request and PANA-Auth-Answer messages as much as 1299 possible. Figure 4 shows an example "Piggybacking EAP" sequence of 1300 the Authentication and authorization phase. 1302 PaC PAA Message(sequence number)[AVPs] 1303 --------------------------------------------------------------------- 1304 -----> PANA-Client-Initiation(0) 1305 <----- PANA-Auth-Request(x)[PRF-Algorithm,Integrity-Algorithm] 1306 // The 'S' (Start) bit set 1307 -----> PANA-Auth-Answer(x)[PRF-Algorithm, Integrity-Algorithm] 1308 // The 'S' (Start) bit set 1309 <----- PANA-Auth-Request(x+1)[Nonce, EAP-Payload] 1310 -----> PANA-Auth-Answer(x+1)[Nonce, EAP-Payload] 1311 <----- PANA-Auth-Request(x+2)[EAP-Payload] 1312 -----> PANA-Auth-Answer(x+2)[EAP-Payload] 1313 <----- PANA-Auth-Request(x+3)[Result-Code, EAP-Payload, 1314 Key-Id, Session-Lifetime, AUTH] 1315 // The 'C' (Complete) bit set 1316 -----> PANA-Auth-Answer(x+3)[Key-Id, AUTH] 1317 // The 'C' (Complete) bit set 1319 Figure 4: Example sequence of the Authentication and authorization 1320 phase for a PaC-initiated session (using "Piggybacking EAP") 1322 Note: It is possible to include an EAP-Payload in both the PANA-Auth- 1323 Request and PANA-Auth-Answer messages with the 'S' bit set. But the 1324 PAA should not include an EAP-Payload in the PANA-Auth-Request 1325 message with the 'S' bit set in order to stay stateless in response 1326 to a PANA-Client-Initiation message. 1328 Access phase: 1330 After Authentication and authorization phase completion, the PaC and 1331 PAA share a PANA Security Association (SA) and move Access phase. 1332 During Access phase, [RFC5191] describes both the PaC and PAA can 1333 send a PANA-Notification-Request message with the 'P' (Ping) bit set 1334 for the peer's PANA session liveness check (a.k.a "PANA ping"). From 1335 the minimal implementation point of view, the PAA should not send a 1336 PANA-Notification-Request message with the 'P' (Ping) bit set to 1337 initiate PANA ping since the PaC may be sleeping. The PaC does not 1338 need to send a PANA-Notification-Request message with the 'P' (Ping) 1339 bit set for PANA ping to the PAA periodically and may omit the PANA 1340 ping feature itself if the PaC can detect the PANA session failure by 1341 other methods, for example, network communication failure. In 1342 conclusion, the PaC does not need to implement the periodic liveness 1343 check feature sending PANA ping but a PaC that is awake should 1344 respond to a incoming PANA-Notification-Request message with the 'P' 1345 (Ping) bit set for PANA ping as possible. 1347 Re-Authentication phase: 1349 Before PANA session lifetime expiration, the PaC and PAA MUST re- 1350 negotiate to keep the PANA session. This means that the PaC and PAA 1351 enter Re-Authentication phase. Also in the Authentication and 1352 authorization phase, there are two types of re-authentication. The 1353 minimal implementation must support PaC-initiated re-authentication 1354 and does not need to support PAA-initiated re-authentication (again 1355 because the PaC may be a sleeping device). "Piggybacking EAP" is 1356 also useful here and should be used as well. Figure 5 shows an 1357 example "Piggybacking EAP" sequence of the Re-Authentication phase. 1359 PaC PAA Message(sequence number)[AVPs] 1360 --------------------------------------------------------------------- 1361 -----> PANA-Notification-Request(q)[AUTH] 1362 // The 'A' (re-Authentication) bit set 1363 <----- PANA-Notification-Answer(q)[AUTH] 1364 // The 'A' (re-Authentication) bit set 1365 <----- PANA-Auth-Request(p)[EAP-Payload, Nonce, AUTH] 1366 -----> PANA-Auth-Answer(p)[EAP-Payload, Nonce, AUTH] 1367 <----- PANA-Auth-Request(p+1)[EAP-Payload, AUTH] 1368 -----> PANA-Auth-Answer(p+1)[EAP-Payload, AUTH] 1369 <----- PANA-Auth-Request(p+2)[Result-Code, EAP-Payload, 1370 Key-Id, Session-Lifetime, AUTH] 1371 // The 'C' (Complete) bit set 1372 -----> PANA-Auth-Answer(p+2)[Key-Id, AUTH] 1373 // The 'C' (Complete) bit set 1375 Figure 5: Example sequence of the Re-Authentication phase for a PaC- 1376 initiated session (using "Piggybacking EAP") 1378 Termination Phase: 1380 The PaC and PAA should not send a PANA-Termination-Request message 1381 except for explicitly terminating a PANA session within the lifetime. 1382 Both the PaC and PAA know their own PANA session lifetime expiration. 1383 This means the PaC and PAA should not send a PANA-Termination-Request 1384 message when the PANA session lifetime expired because of reducing 1385 message processing cost. 1387 5.4.1.3. PANA session state parameters 1389 All PANA implementations internally keep PANA session state 1390 information for each peer. At least, all minimal implementations 1391 need to keep PANA session state parameters below (in the second 1392 column storage sizes are given in bytes): 1394 +------------------+----------+-------------------------------------+ 1395 | State Parameter | Size | Comment | 1396 +------------------+----------+-------------------------------------+ 1397 | PANA Phase | 1 | Used for recording the current PANA | 1398 | Information | | phase. | 1399 | | | | 1400 | PANA Session | 4 | | 1401 | Identifier | | | 1402 | | | | 1403 | PaC's IP address | 6 or 18 | IP Address length (4 bytes for IPv4 | 1404 | and UDP port | | and 16 bytes for IPv6) plus 2 bytes | 1405 | number | | for UDP port number. | 1406 | | | | 1407 | PAA's IP address | 6 or 18 | IP Address length (4 bytes for IPv4 | 1408 | and UDP port | | and 16 bytes for IPv6) plus 2 bytes | 1409 | number | | for UDP port number. | 1410 | | | | 1411 | Outgoing message | 4 | Next outgoing request message | 1412 | sequence number | | sequence number. | 1413 | | | | 1414 | Incoming message | 4 | Next expected incoming request | 1415 | sequence number | | message sequence number. | 1416 | | | | 1417 | A copy of the | variable | Necessary to be able to retransmit | 1418 | last sent | | the message (unless it can be | 1419 | message payload | | reconstructed on the fly). | 1420 | | | | 1421 | Retransmission | 4 | | 1422 | interval | | | 1423 | | | | 1424 | PANA Session | 4 | | 1425 | lifetime | | | 1426 | | | | 1427 | PaC nonce | 20 | Generated by PaC and carried in the | 1428 | | | Nonce AVP. | 1429 | | | | 1430 | PAA nonce | 20 | Generated by PAA and carried in the | 1431 | | | Nonce AVP. | 1432 | | | | 1433 | EAP MSK | 4 | | 1434 | Identifier | | | 1435 | | | | 1436 | EAP MSK value | *) | Generated by EAP method and used | 1437 | | | for generating PANA_AUTH_KEY. | 1438 | | | | 1439 | PANA_AUTH_KEY | 20 | Necessary for PANA message | 1440 | | | protection. | 1441 | | | | 1442 | PANA PRF | 4 | Used for generating PANA_AUTH_KEY. | 1443 | algorithm number | | | 1444 | | | | 1445 | PANA Integrity | 4 | Necessary for PANA message | 1446 | algorithm number | | protection. | 1447 +------------------+----------+-------------------------------------+ 1449 *) (Storage size depends on the key derivation algorithm.) 1451 Note: EAP parameters except for MSK have not been listed here. These 1452 EAP parameters are not used by PANA and depend on what EAP method you 1453 choose. 1455 6. Wire-Visible Constraints 1457 o Checksum 1459 o MTU 1461 o Fragmentation and reassembly 1463 o Options -- implications of leaving some out 1465 o Simplified TCP optimized for LLNs 1467 o Out-of-order packets 1469 7. Wire-Invisible Constraints 1471 o Buffering 1473 o Memory management 1475 o Timers 1477 o Energy efficiency 1479 o API 1481 o Data structures 1483 o Table sizes (somewhat wire-visible) 1485 o Improved error handling due to resource overconsumption 1487 8. IANA Considerations 1489 This document makes no requirements on IANA. (This section to be 1490 removed by RFC editor.) 1492 9. Security Considerations 1494 (TBD.) 1496 10. Acknowledgements 1498 Much of the text of the introduction is taken from the charter of the 1499 LWIG working group and the invitation to the IAB workshop on 1500 Interconnecting Smart Objects with the Internet. Thanks to the 1501 numerous contributors. Angelo Castellani provided comments that led 1502 to improved text. 1504 10.1. Contributors 1506 The RFC guidelines no longer allow RFCs to be published with a large 1507 number of authors. As there are many authors that have contributed 1508 to the sections of this document, their names are listed in the 1509 individual section headings as well as alphabetically listed with 1510 their affiliations below. 1512 +-------------+-----------------------+-----------------------------+ 1513 | Name | Affiliation | Contact | 1514 +-------------+-----------------------+-----------------------------+ 1515 | Brinda M C | Indian Institute of | brinda@ece.iisc.ernet.in | 1516 | | Science | | 1517 | | | | 1518 | Carl | MCSR Labs | carlw@mcsr-labs.org | 1519 | Williams | | | 1520 | | | | 1521 | Carsten | Universitaet Bremen | cabo@tzi.org | 1522 | Bormann | TZI | | 1523 | | | | 1524 | Esko Dijk | Philips Research | esko.dijk@philips.com | 1525 | | | | 1526 | Mitsuru | Toshiba | mitsuru.kanda@toshiba.co.jp | 1527 | Kanda | | | 1528 | | | | 1529 | Olaf | Universitaet Bremen | bergmann@tzi.org | 1530 | Bergmann | TZI | | 1531 | | | | 1532 | Yuanchen Ma | Hitachi (China) R&D | ycma@hitachi.cn | 1533 | | Corporation | | 1534 | | | | 1535 | ... | ... | | 1536 +-------------+-----------------------+-----------------------------+ 1538 11. References 1540 11.1. Normative References 1542 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1543 Requirement Levels", BCP 14, RFC 2119, March 1997. 1545 [RFC4944] Montenegro, G., Kushalnagar, N., Hui, J., and D. Culler, 1546 "Transmission of IPv6 Packets over IEEE 802.15.4 1547 Networks", RFC 4944, September 2007. 1549 11.2. Informative References 1551 [I-D.arkko-core-sleepy-sensors] 1552 Arkko, J., Rissanen, H., Loreto, S., Turanyi, Z., and O. 1553 Novo, "Implementing Tiny COAP Sensors", 1554 draft-arkko-core-sleepy-sensors-01 (work in progress), 1555 July 2011. 1557 [I-D.ietf-core-coap] 1558 Shelby, Z., Hartke, K., Bormann, C., and B. Frank, 1559 "Constrained Application Protocol (CoAP)", 1560 draft-ietf-core-coap-10 (work in progress), June 2012. 1562 [I-D.kivinen-ipsecme-ikev2-minimal] 1563 Kivinen, T., "Minimal IKEv2", 1564 draft-kivinen-ipsecme-ikev2-minimal-00 (work in progress), 1565 February 2011. 1567 [RFC1071] Braden, R., Borman, D., Partridge, C., and W. Plummer, 1568 "Computing the Internet checksum", RFC 1071, 1569 September 1988. 1571 [RFC1141] Mallory, T. and A. Kullberg, "Incremental updating of the 1572 Internet checksum", RFC 1141, January 1990. 1574 [RFC1624] Rijsinghani, A., "Computation of the Internet Checksum via 1575 Incremental Update", RFC 1624, May 1994. 1577 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 1578 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 1579 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 1581 [RFC3748] Aboba, B., Blunk, L., Vollbrecht, J., Carlson, J., and H. 1582 Levkowetz, "Extensible Authentication Protocol (EAP)", 1583 RFC 3748, June 2004. 1585 [RFC4614] Duke, M., Braden, R., Eddy, W., and E. Blanton, "A Roadmap 1586 for Transmission Control Protocol (TCP) Specification 1587 Documents", RFC 4614, September 2006. 1589 [RFC5191] Forsberg, D., Ohba, Y., Patil, B., Tschofenig, H., and A. 1590 Yegin, "Protocol for Carrying Authentication for Network 1591 Access (PANA)", RFC 5191, May 2008. 1593 [WEI] Shelby, Z. and C. Bormann, "6LoWPAN: the Wireless Embedded 1594 Internet", ISBN 9780470747995, 2009. 1596 Author's Address 1598 Carsten Bormann (editor) 1599 Universitaet Bremen TZI 1600 Postfach 330440 1601 Bremen D-28359 1602 Germany 1604 Phone: +49-421-218-63921 1605 Email: cabo@tzi.org