LwIP Working Group W. Chen Internet-Draft Bit-way Corporation Intended status: Informational October 18, 2010 Expires: April 21, 2011 Implementation Techniques of the Lightweight TCP/IP Stack draft-chen-lwip-implementataion-00 Abstract Since small devices such as sensors are often required to be physically small and inexpensive, an implementation of the Internet protocols will have to deal with having limited computing resources and memory. This report describes the design and implementation of a small TCP/IP stack called lwIP that is small enough to be used in minimal systems. Status of this Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on April 21, 2011. Copyright Notice Copyright (c) 2010 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as Chen Expires April 21, 2011 [Page 1] Internet-Draft Implementation Techniques October 2010 described in the Simplified BSD License. Table of Contents 1. Non-layered protocols . . . . . . . . . . . . . . . . . . . . 3 2. Memory Management . . . . . . . . . . . . . . . . . . . . . . 4 3. Application Programming Interfaces . . . . . . . . . . . . . . 5 4. TCP Implementation . . . . . . . . . . . . . . . . . . . . . . 6 5. Protocol Implementations . . . . . . . . . . . . . . . . . . . 7 6. Security Considerations . . . . . . . . . . . . . . . . . . . 8 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 8. Normative References . . . . . . . . . . . . . . . . . . . . . 10 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 11 Chen Expires April 21, 2011 [Page 2] Internet-Draft Implementation Techniques October 2010 1. Non-layered protocols In most common cases, TCP/IP protocols are implemented by modularity and layering. But for the constraint systems, layering will increase the cost so as to affect the overall performance. Moreover, there is no strict barrier between the kernel and application processes, such as TinyOS and Contiki. So there is no strict layer in Lightweight TCP/IP protocols, which are designed to be tight-coupled in order to shorten the codes and save the memory. Non-layered protocols can be implemented by queue method to cache the packages. As long as there is no layer concept, when sending packages, application calls directly to the end. When receiving, protocol stack uses callback functions to get the packages. And all the applications need to register the callback functions in advance. Furthermore, the retransmission should be done by applications. What's more, the TCP should care about the connection states, e.g. three-way handshaking. Chen Expires April 21, 2011 [Page 3] Internet-Draft Implementation Techniques October 2010 2. Memory Management Many TCP/IP protocols use dynamic memory allocation schemes. Unfortunately, constraint devices with several kilo of memory can't survive this kind of schemes. Lightweight TCP/IP Protocols use static memory allocation schemes to pre-allocation memory for each usage. Memory allocation is done when compiling, which is based on the pre-decision of the package size in the network. More attention should be payed to the cache to ensure that it can hold the greatest size package. Chen Expires April 21, 2011 [Page 4] Internet-Draft Implementation Techniques October 2010 3. Application Programming Interfaces Multitasking system imposes a significant overhead for the need for task management, context switching and allocation of stack space. As a result, the constrained systems don't support multitask. Lightweight TCP/IP Protocols are designed to be simple, single-task, and have a reduced event driven API with only the needed functions. For example, there're no socket options which are needed in the integrity socket. Furthermore, there's no need for Receive function, for the protocol stack use callback functions to receive packages, as mentioned before. Chen Expires April 21, 2011 [Page 5] Internet-Draft Implementation Techniques October 2010 4. TCP Implementation Many TCP/IP implementations, realize the sliding window algorithm, which allows the sender to deliver multiple segments continuously, without having to stop and wait for an acknowledgment for each segment. The congestion control algorithm is realized as well, in order to limit the number of simultaneous TCP segments in the network. Furthermore, overtime retransmission mechanism is sufficiently implemented by the stack. Lightweight TCP implementations, only handle a TCP connection at a time, while a TCP connection only allows a TCP segment to be unacknowledged. Due to a TCP connection dealt at a time, there is no need for the sliding window algorithm. Due to no more than one TCP segment per connection, the number of simultaneous TCP segments in the network is rather limited, and there is no need for the congestion control algorithm either. As for the overtime retransmission mechanism, it is up to the stack to decide when to retransmit, but the application to execute the retransmission actually. Moreover, checksum algorithm shall be implemented according to the architecture. Chen Expires April 21, 2011 [Page 6] Internet-Draft Implementation Techniques October 2010 5. Protocol Implementations Lightweight TCP/IP implementations, in resource-constrained devices, shall be fully compliant with the standard TCP/IP and other simplified and limited TCP/IP implementations. They should be able to support ARP, IP, ICMP and TTL time-out estimation. ICMP can merely implement echo request and echo reply. IP options and fragment reassembly can be ignored, as fragment reassembly can be avoided by MTU configuration. Chen Expires April 21, 2011 [Page 7] Internet-Draft Implementation Techniques October 2010 6. Security Considerations TBD. Chen Expires April 21, 2011 [Page 8] Internet-Draft Implementation Techniques October 2010 7. IANA Considerations This document does not require any IANA actions. Chen Expires April 21, 2011 [Page 9] Internet-Draft Implementation Techniques October 2010 8. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. Chen Expires April 21, 2011 [Page 10] Internet-Draft Implementation Techniques October 2010 Author's Address Wenlong Chen Bit-way Corporation Beijing China Email: wenlongchenn@gmail.com Chen Expires April 21, 2011 [Page 11]