RFC 9006
TCP Usage Guidance in the Internet of Things (IoT)
RFC 9006: TCP Usage Guidance in the Internet of Things (IoT) ๐
okay bestie, this is the title block ๐ It's an Informational doc (so NOT a Standards Track spec, just helpful guidance ๐ธ). It was written by C. Gomez (UPC), J. Crowcroft (University of Cambridge), and M. Scharf (Hochschule Esslingen) and published in March 2021. Its ISSN is 2070-1721. It doesn't obsolete or update anything. ๐ซถ
Here's the vibe of the whole thing: TCP gets roasted a LOT for being "unsuitable for IoT," and this doc is like "okay, some of that is true, but a lot of it is not, and here's how to make TCP lightweight so embedded devs can actually use it" โจ
Abstract
okay so the abstract is giving "here's the tea" ๐ This doc is about how to implement and use TCP in Constrained-Node Networks (CNNs), which are a big part of the Internet of Things (IoT) ๐ฆ. These environments need a lightweight TCP, and they may skip the optional stuff ๐ The doc goes through a bunch of known, already-deployed tricks to simplify a TCP stack, plus the trade-offs that come with each one. The goal is to help embedded devs pick which TCP features to use ๐
Status of This Memo
okay this part is boring but iykyk ๐ This is not an Internet Standards Track spec, it's published for info only ๐ It's still an IETF product with IETF community consensus, public review, and IESG approval. Not every IESG-approved doc is a candidate for any Internet Standard level, so check Section 2 of RFC 7841 if you're curious ๐
Errata and feedback live at https://www.rfc-editor.org/info/rfc9006 ๐
Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved ๐ฅ
This doc is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) as they were on the publication date. Please actually read those, bestie, because they explain your rights ๐ซถ Any Code Components pulled out of this doc have to include the Simplified BSD License text (Section 4.e of the Trust Legal Provisions) and come with no warranty, as the Simplified BSD License says ๐
Table of Contents
1. Introduction
2. Characteristics of CNNs Relevant for TCP
2.1. Network and Link Properties
2.2. Usage Scenarios
2.3. Communication and Traffic Patterns
3. TCP Implementation and Configuration in CNNs
3.1. Addressing Path Properties
3.1.1. Maximum Segment Size (MSS)
3.1.2. Explicit Congestion Notification (ECN)
3.1.3. Explicit Loss Notifications
3.2. TCP Guidance for Single-MSS Stacks
3.2.1. Single-MSS Stacks -- Benefits and Issues
3.2.2. TCP Options for Single-MSS Stacks
3.2.3. Delayed Acknowledgments for Single-MSS Stacks
3.2.4. RTO Calculation for Single-MSS Stacks
3.3. General Recommendations for TCP in CNNs
3.3.1. Loss Recovery and Congestion/Flow Control
3.3.1.1. Selective Acknowledgments (SACKs)
3.3.2. Delayed Acknowledgments
3.3.3. Initial Window
4. TCP Usage Recommendations in CNNs
4.1. TCP Connection Initiation
4.2. Number of Concurrent Connections
4.3. TCP Connection Lifetime
5. Security Considerations
6. IANA Considerations
7. References
7.1. Normative References
7.2. Informative References
Appendix A. TCP Implementations for Constrained Devices
A.1. uIP
A.2. lwIP
A.3. RIOT
A.4. TinyOS
A.5. FreeRTOS
A.6. uC/OS
A.7. Summary
Acknowledgments
Authors' Addresses
1. Introduction ๐ธ
okay so the Internet Protocol suite is being used to hook Constrained-Node Networks (CNNs) up to the Internet, which is what we call the Internet of Things (IoT) [RFC7228] ๐ฆ To meet the needs of CNNs, the IETF built a whole set of new protocols made for these environments (see, e.g., [RFC8352]) โจ The new stack bits include the IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs) adaptation layer [RFC4944][RFC6282][RFC6775], the IPv6 Routing Protocol for Low-Power and Lossy Networks (RPL) [RFC6550], and the Constrained Application Protocol (CoAP) [RFC7252] ๐
As of this writing, the main transport-layer protocols in IP-based IoT are UDP and TCP ๐ TCP gets criticized a LOT, and honestly a lot of that is unfair ๐ญ It's true that some TCP stuff, like the relatively long header, not being great for multicast, and always-confirmed delivery, isn't ideal for IoT ๐ But lots of the usual claims (high complexity, the connection-oriented approach not playing well with radio duty-cycling, and spurious congestion control kicking in on wireless links) are not valid, can be solved, or also show up in well-loved IoT end-to-end reliability mechanisms. There's a detailed breakdown in [IntComp] ๐
At the application layer, CoAP was built over UDP [RFC7252]. But getting CoAP deployments to play nice with existing infrastructure is hard, because middleboxes like firewalls can limit or even block UDP traffic ๐ซฃ That's the main reason a CoAP over TCP spec got made [RFC8323] ๐
Other application protocols that weren't designed for CNNs are also being considered for IoT, like HTTP/2 and even HTTP/1.1, which both run over TCP by default [RFC7230] [RFC7540], plus the Extensible Messaging and Presence Protocol (XMPP) [RFC6120] ๐ง TCP is also used by non-IETF app protocols in IoT, like the Message Queuing Telemetry Transport (MQTT) [MQTT] and its lightweight variants ๐
TCP is a sophisticated transport protocol with optional features (like TCP options) that can boost performance in some environments โจ But a lot of the optional TCP extensions need complex logic in the stack and make the code and memory footprint bigger ๐ฉ Plenty of TCP extensions aren't needed for interoperating with other standard-compliant TCP endpoints. So with constrained devices and their tiny resources, picking your optional TCP features carefully can make your implementation way more lightweight ๐
This doc gives guidance on how to implement and configure TCP, plus how apps should use TCP in CNNs ๐ The big goal is simple measures for a lightweight TCP implementation that still works well in these environments ๐ฆ A TCP implementation that follows this guidance is meant to be compatible with a TCP endpoint that follows the TCP standards, maybe with lower performance ๐ That means a TCP client following this guidance can always connect to a standard-compliant TCP server, and a TCP server following it can always connect to a standard-compliant TCP client ๐ซถ
This doc assumes you already know TCP. A full survey of the TCP standards is in RFC 7414 [RFC7414] ๐ There's been similar guidance for TCP in special environments before, like for cellular wireless networks [RFC3481] ๐ธ
2. Characteristics of CNNs Relevant for TCP ๐
2.1. Network and Link Properties ๐ฆ
CNNs are defined in [RFC7228] as networks whose characteristics are shaped by being made up of a big chunk of constrained nodes ๐ Those nodes have real limits on processing, memory, and energy ๐ญ The first two limits constrain how complex and how big the protocols they can run are ๐ Energy means they need tricks to save power, like radio duty-cycling in wireless devices [RFC8352], and minimizing how many messages get sent and received (and how big they are) ๐
[RFC7228] lists typical network constraints in CNNs, like low achievable bitrate/throughput, high packet loss with high variability in that loss, highly asymmetric links, severe penalties for bigger packets, limited reachability over time, and more ๐ CNNs can use wireless or wired tech (e.g., Power Line Communication), and transmission rates are usually low (e.g., below 1 Mbps) ๐
For TCP, one challenge is that not all the tech in a CNN lines up with typical Internet subnetwork design principles [RFC3819] ๐ง For example, constrained nodes often use physical/link-layer techs that have been described as 'lossy', meaning they have a relatively high bit error rate ๐ Dealing with corruption loss is one of the open issues on the Internet [RFC6077] โจ
2.2. Usage Scenarios ๐ธ
There are different deployment and usage scenarios for CNNs ๐ Some follow the star topology, where one or several hosts link to a central device that acts as a router connecting the CNN to the Internet ๐ฆ Others may follow the multihop topology [RFC6606] ๐ซถ
In constrained environments there can be different kinds of devices [RFC7228] ๐ For example, some have a single combined send/receive buffer, some have a separate send and receive buffer, and some have a pool of multiple send/receive buffers ๐ In that last case, the buffers might also be shared with other protocols ๐
One key use case for TCP in CNNs is constrained devices connecting to unconstrained servers on the Internet ๐ But it's also possible for both TCP endpoints to run on constrained devices ๐ In the first case, the communication will possibly go through a middlebox (like a firewall, NAT, etc.) ๐ Figure 1 shows this scenario ๐ฆ Note that the scenario is asymmetric, because the unconstrained device usually won't have the severe constraints of the constrained one ๐ The unconstrained device is expected to be mains-powered, have lots of memory and processing power, and be on a resource-rich network โจ
Assuming most constrained devices are sensor nodes, the data sent by constrained devices (like sensor measurements) is expected to be higher than the data going the other way ๐ Still, constrained devices may receive requests (which they may answer), commands (for configuration, and for constrained devices including actuators), and fairly infrequent firmware/software updates ๐ง
+---------------+
o o <-------- TCP communication -----> | |
o o | |
o o | Unconstrained |
o o +-----------+ | device |
o o o ------ | Middlebox | ------- | |
o o +-----------+ | (e.g., cloud) |
o o o | |
+---------------+
Constrained devices
Figure 1: TCP Communication between a Constrained Device and an
Unconstrained Device, Traversing a Middlebox
okay that's the first chunk, bestie ๐ Part 2 is coming up next with Section 2.3 and the rest of the TCP goodies, so stay tuned ๐ซถโจ
2.3. Communication and Traffic Patterns ๐
okay so IoT apps have a bunch of different ways of talking to each other ๐ซถ this isn't a full list, just some super common vibes:
- Unidirectional transfers: an IoT device (think a sensor ๐ก๏ธ) can keep sending updates to the other endpoint again and again ๐. There isn't always a need for the app to reply back to the IoT device, so it's kinda one-way ๐ฆ
- Request-response patterns: an IoT device gets a request from the other endpoint, and that request triggers a response from the IoT device ๐ฌโจ
- Bulk data transfers: the classic example is a long file transfer, like an IoT device firmware update ๐ฆ๐
The typical pattern is a constrained device chatting with an unconstrained device (see Figure 1 ๐). But constrained devices can totally talk to each other too ๐ฏโโ๏ธ
3. TCP Implementation and Configuration in CNNs โจ
this section is all about how a TCP stack can handle the usual constraints in CNNs ๐ง the advice here is about the TCP implementation itself and how it gets configured ๐ ๏ธ
3.1. Addressing Path Properties ๐ฃ๏ธ
3.1.1. Maximum Segment Size (MSS) ๐
so, assuming IPv6 is being used ๐, and we want the implementation to stay lightweight and easy to run, unless apps actually need to handle big data units (aka an IPv6 datagram bigger than 1280 bytes), it may be desirable to cap the IP datagram size at 1280 bytes ๐ . That way you don't have to support Path MTU Discovery [RFC8201] ๐. Plus, a 1280-byte IP datagram avoids IPv6-layer fragmentation [RFC8900] ๐ฏ
you can keep an IPv6 datagram from going over 1280 bytes by setting the TCP MSS to 1220 bytes or less ๐. Also, it's already a requirement for TCP implementations to use up payload space instead of making the datagram bigger when IP or TCP options get added to a packet being sent [RFC6691] ๐. So it's not required to advertise an MSS smaller than 1220 bytes just to fit TCP options in ๐ซถ
fr, setting the MTU to 1280 bytes is possible for link-layer techs in the CNN space โจ, even though some of them have really tiny data unit payloads (like a few tens or hundreds of bytes) ๐ฃ. For example, the maximum frame size in IEEE 802.15.4 is 127 bytes ๐ญ. 6LoWPAN made an adaptation layer so IPv6 can run over IEEE 802.15.4 networks ๐ฆ. That adaptation layer has a fragmentation mechanism, because IPv6 needs the layer below it to support an MTU of 1280 bytes [RFC8200], and IEEE 802.15.4 doesn't have fragmentation mechanisms of its own ๐. So 6LoWPAN defines an IEEE 802.15.4 link MTU of 1280 bytes [RFC4944] ๐
other techs like Bluetooth low energy [RFC7668], ITU-T G.9959 [RFC7428], and Digital Enhanced Cordless Telecommunications (DECT) Ultra Low Energy (ULE) [RFC8105] also use 6LoWPAN-based adaptation layers to get IPv6 support ๐. These techs do support link-layer fragmentation, and by using that, the adaptation layers that enable IPv6 over them also define an MTU of 1280 bytes ๐งโโ๏ธ
BUT there are other techs in the CNN space, like Master Slave (MS) / Token Passing (TP) [RFC8163], Narrowband IoT (NB-IoT) [RFC8376], or IEEE 802.11ah [6LO-WLANAH], that don't have the same tight frame size limits as the ones above ๐ โโ๏ธ. The MTU for MS/TP is recommended to be 1500 bytes [RFC8163] โญ, the MTU in NB-IoT is 1600 bytes ๐, and the maximum frame payload size for IEEE 802.11ah is 7991 bytes ๐
using a bigger MSS (to a suitable extent) can be really good in some scenarios, especially when you're moving large payloads ๐ฆ, because you need fewer packets (and fewer packet headers) for a given payload ๐. BUT the characteristics of the constrained network need to be considered ๐. Especially in a lossy network where unreliable fragment delivery is used ๐ฉ, the amount of data TCP unnecessarily retransmits because of fragment loss goes up (and throughput goes down) really fast as the MSS grows ๐. That's because losing one fragment means losing the whole fragmented packet that was being sent ๐. Unnecessary retransmissions are especially harmful in CNNs since those environments are so resource-constrained ๐ชซ. Also, while the original 6LoWPAN fragmentation mechanism [RFC4944] doesn't offer reliable fragment delivery, fragment recovery functionality for 6LoWPAN or 6Lo environments has been standardized [RFC8931] ๐
3.1.2. Explicit Congestion Notification (ECN) ๐ฆ
ECN [RFC3168] lets a router signal in the IP header of a packet that congestion is building up, for example when a queue size hits a certain threshold ๐จ. An ECN-enabled TCP receiver echoes that congestion signal back to the TCP sender by setting a flag in its next TCP Acknowledgment (ACK) ๐ช. Then the sender triggers congestion control measures as if a packet loss had happened ๐ฅ
RFC 8087 [RFC8087] lays out the main gains (more throughput, less delay, and other perks) when ECN is used over a network path that includes equipment supporting Congestion Experienced (CE) marking ๐. In CNNs, ECN is a total slay because congestion can be signaled without dropping packets ๐. Dropped packets lead to retransmissions and burn through limited resources like energy and bandwidth ๐
ECN can also cut down on packet losses, since congestion control can kick in earlier [RFC2884] โฐ. Fewer lost packets means fewer retransmitted segments, which is super beneficial in CNNs where energy and bandwidth are usually limited ๐ฟ. It also makes sense to avoid packet drops for transactional workloads with small data sizes, which are typical in CNNs ๐ . With that kind of traffic, it's harder and often impossible to detect packet loss without retransmission timeouts (for example, there may not be three duplicate ACKs ๐). And any retransmission timeout slows the data transfer down a lot ๐. If the constrained device uses power-saving techniques, a retransmission timeout also causes a wake-up action, unlike ACK clock-triggered sending โก. When a TCP sender's congestion window is one segment in size and a TCP ACK with an ECN signal (ECN-Echo (ECE) flag) arrives, the sender resets the retransmit timer, and it can only send a new packet once that timer expires โณ. So at that point the sender drops its sending rate from 1 segment per Round-Trip Time (RTT) to 1 segment per Retransmission Timeout (RTO), and it keeps reducing the rate on each ECN signal in later TCP ACKs ๐. If a later TCP ACK doesn't carry an ECN signal, the sender goes back to normal ACK-clocked segment transmission [RFC3168] ๐ถ
ECN can be deployed incrementally across the Internet ๐. Guidance on configuring and using ECN is in RFC 7567 [RFC7567] ๐. Given the benefits, more and more TCP stacks on the Internet support ECN, so it makes sense to specifically use it in controlled environments like CNNs ๐ก. As of writing, there's ongoing work to extend which TCP packets are ECN capable, including pure ACKs [TCPM-ECN] ๐. That could boost ECN's benefits even more in CNN environments ๐. Just note that supporting ECN does add implementation complexity ๐งฉ
3.1.3. Explicit Loss Notifications ๐
there's been a ton of research on solutions that can explicitly indicate whether a TCP segment loss is due to corruption, so congestion control doesn't get triggered [ETEN] [RFC2757] ๐งช. Those solutions can help a lot, but they haven't been widely deployed and are still experimental ๐ฌ. In fact, as of today, the IETF hasn't standardized any such solution ๐
3.2. TCP Guidance for Single-MSS Stacks ๐งธ
this section covers TCP stacks that can only transfer a single MSS at a time ๐ผ. More general guidance is in Section 3.3 ๐
3.2.1. Single-MSS Stacks -- Benefits and Issues โ๏ธ
a TCP stack can save memory by advertising a TCP window size of 1 MSS and also by sending at most 1 MSS of unacknowledged data ๐พ. In that case, both congestion and flow control are pretty simple to implement ๐ซง. A small receive and send window like that may be enough for simple message exchanges in the CNN space โจ. BUT only using a 1 MSS window can really hurt performance ๐ต. A stop-and-wait operation gives low throughput for transfers longer than 1 MSS, like a firmware download ๐ข. And a single-MSS solution only relies on timer-based loss recovery, so it misses out on the performance gains of Fast Retransmit and Fast Recovery (which need a bigger window size; see Section 3.3.1) ๐
if CoAP is used over TCP with the default setting for NSTART in RFC 7252 [RFC7252] ๐, a CoAP endpoint is not allowed to send a new message to a destination until it has received a response for the previous message sent to that destination ๐ โโ๏ธ. That's equivalent to an application-layer window size of 1 data unit ๐ช. For this use of CoAP, a maximum TCP window of 1 MSS may be enough, as long as the CoAP message size doesn't go over 1 MSS ๐ . The exception in CoAP over TCP is the Capabilities and Settings Message (CSM), which has to be sent at the start of the TCP connection ๐ค. The first application message carrying user data is allowed to go out right after the CSM message โจ. But if the CSM size plus the application message size goes over the MSS, a sender using a single-MSS stack will need to wait for the ACK confirming the CSM before sending the application message ๐ฉ
3.2.2. TCP Options for Single-MSS Stacks ๐
a TCP implementation needs to support, at a minimum, TCP options 2, 1, and 0 ๐. Those are the MSS option, the No-Operation option, and the End Of Option List marker, in that order [RFC0793] ๐งพ. None of these are a big burden to support ๐ช. They're enough for interoperability with a standard-compliant TCP endpoint, though many TCP stacks support extra options and can negotiate their use ๐ค. A TCP implementation is permitted to silently ignore all other TCP options ๐
a TCP implementation for a constrained device that uses a single-MSS TCP receive or transmit window size may not benefit from supporting these TCP options: Window Scale [RFC7323], TCP Timestamps [RFC7323], Selective Acknowledgment (SACK) [RFC2018], and SACK-Permitted [RFC2018] ๐ง. Other TCP options may also not be required on a constrained device with a very lightweight implementation ๐ชถ. As for the Window Scale option, it's only useful if a window size greater than 64 kB is needed ๐
a TCP sender can benefit from the TCP Timestamps option [RFC7323] when detecting spurious RTOs ๐ต๏ธโโ๏ธ. Those are pretty likely to happen in CNN scenarios for a bunch of reasons (like route changes in a multihop scenario, link-layer retries, etc.) ๐. Just make sure the header overhead from the Timestamps option (up to 12 bytes) gets taken into account ๐งฎ
3.2.3. Delayed Acknowledgments for Single-MSS Stacks โจ
okay so TCP Delayed ACKs exist to cut down on how many ACKs get sent in a connection ๐ซถ, which saves network overhead. the catch? the sender may have to wait longer before it gets an ACK ๐ญ. how useful Delayed ACKs are depends HEAVILY on the usage scenario (see Section 3.3.2) ๐ . and yes, they can totally interact with single-MSS stacks ๐.
When traffic is unidirectional, and the sender can send at most 1 MSS of data or the receiver advertises a receive window not greater than the MSS, Delayed ACKs may unnecessarily add delay (up to 500 ms) to the RTT [RFC5681]. that limits throughput and can make data take longer to arrive ๐ข. it's not always possible to turn Delayed ACKs off, fyi ๐ฅบ. one known workaround is to split the data into two smaller segments ๐. a standard-compliant TCP receiver may immediately acknowledge the second MSS of data, which can boost throughput โจ. BUT this "split hack" may not always work, because a TCP receiver is required to acknowledge every second full-sized segment, not two consecutive small segments ๐. and sending two IP packets instead of one is another downside of the "split hack" ๐.
Similar issues can pop up when the sender uses the Nagle algorithm, since the sender may need to wait for an unnecessarily Delayed ACK before it can send a new segment ๐ค. turning the algorithm off won't make a difference if the sender can only handle stop-and-wait operation at the TCP level ๐คทโโ๏ธ.
For request-response traffic, when the receiver uses Delayed ACKs, a response to a data message can piggyback an ACK, as long as that ACK goes out before the Delayed ACK timer expires ๐ฆ. that way you avoid unnecessary ACKs with no payload, which is so efficient. disabling Delayed ACKs at the request sender lets an immediate ACK go out for the data segment carrying the response ๐ง.
3.2.4. RTO Calculation for Single-MSS Stacks
the RTO calculation is one of the fundamental TCP algorithms [RFC6298] ๐. there's a real trade-off here, bestie: a short, aggressive RTO reduces the wait before retransmissions, BUT it also raises the probability of spurious timeouts ๐ฌ. those lead to unnecessary waste of potentially scarce resources in CNNs, like energy and bandwidth ๐. on the flip side, a conservative timeout can mean long error recovery times, which needlessly delays data delivery ๐.
if a TCP sender uses a very small window size, and it can't benefit from Fast Retransmit and Fast Recovery or SACK, the RTO algorithm has a huge impact on performance ๐. in that case, RTO algorithm tuning may be considered, although careful assessment of possible drawbacks is recommended [RFC8961] โ ๏ธ.
as an example, adaptive RTO algorithms defined for CoAP over UDP have been found to perform well in CNN scenarios [Commag] [CORE-FASOR] ๐.
3.3. General Recommendations for TCP in CNNs
this section is a roundup of some widely used techniques to improve TCP, with a focus on how they're used in CNNs ๐. the TCP extensions discussed here are useful in a wide range of network scenarios, CNNs included ๐ธ. it is not comprehensive, though! a full survey of TCP extensions is published in RFC 7414 [RFC7414] ๐.
3.3.1. Loss Recovery and Congestion/Flow Control
okay, so devices with enough memory for a bigger TCP window (more than 3 MSS of data) can use a more efficient loss recovery than the timer-based approach used for a smaller window (see Section 3.2.1) ๐ง โจ. they do it with Fast Retransmit and Fast Recovery [RFC5681], at the cost of slightly more complexity and Transmission Control Block (TCB) size ๐ . assuming Delayed ACKs are used by the receiver, a window size of up to 5 MSS is required for Fast Retransmit and Fast Recovery to work efficiently ๐ฅ. picture a transmission of full-sized segments 1, 2, 3, 4, and 5. if segment 2 gets lost and the ACK for segment 1 is held by the Delayed ACK timer, then the sender should get an ACK for segment 1 when 3 arrives, and duplicate ACKs when segments 4, 5, and 6 arrive ๐ฆ. it will retransmit segment 2 when the third duplicate ACK arrives ๐. to have segments 2, 3, 4, 5, and 6 sent, the window has to be at least 5 MSS. with an MSS of 1220 bytes, a buffer of 5 MSS would need 6100 bytes ๐.
the example in the previous paragraph did not use another TCP improvement, Limited Transmit [RFC3042] ๐ซถ. it may also be useful for any transfer with more than one segment in flight. small transfers tend to benefit more from Limited Transmit, because they're more likely to not receive enough duplicate ACKs ๐ฅน. using the example above, Limited Transmit lets you send 5 MSS with a congestion window (cwnd) of three segments, plus two additional segments for the first two duplicate ACKs โจ. with Limited Transmit, even a cwnd of two segments allows sending 5 MSS, at the expense of extra delay from the Delayed ACK timer for the ACK that confirms segment 1 โณ. it's a trade, babe ๐ .
when a multiple-segment window is used, the receiver will need to manage possibly out-of-order segments, which requires sufficient buffer space ๐ฆ. note that even when a window of 1 MSS is used, out-of-order arrival should also be managed, because the sender may send multiple sub-MSS packets that fit in the window. (on the other hand, the receiver is free to simply drop out-of-order segments, thus forcing retransmissions ๐.)
3.3.1.1. Selective Acknowledgments (SACKs)
if a device with less severe memory and processing constraints can afford to advertise a TCP window size of several MSSs, it makes sense to support the SACK option for better performance ๐. SACK lets a data receiver tell the data sender about non-contiguous data blocks it has received ๐ฌ. so a sender (that previously sent the SACK-Permitted option) can avoid doing unnecessary retransmissions, saving energy and bandwidth, and reducing latency โก. SACK also often allows faster loss recovery when there's more than one lost segment in a window of data, since SACK recovery may complete with fewer RTTs ๐โโ๏ธ. it's especially useful for bulk data transfers ๐ฆ๐.
a receiver supporting SACK will need to keep track of the data blocks that still need to be received ๐๏ธ. the sender also needs to keep track of which data segments must be resent after it learns which data blocks are missing at the receiver ๐งฉ. SACK adds 8*n+2 bytes to the TCP header, where n is the number of data blocks received, up to four blocks ๐. for a low number of out-of-order segments, the header overhead of SACK is made up for by avoiding unnecessary retransmissions ๐. when the sender discovers the data blocks that were already received, it needs to store the state required to avoid unnecessarily retransmitting data segments that have already arrived ๐ง โจ.
3.3.2. Delayed Acknowledgments
for certain traffic patterns, Delayed ACKs may have a detrimental effect, as already noted in Section 3.2.3 ๐ฌ. advanced TCP stacks may use heuristics to figure out the maximum delay for an ACK ๐ค. for CNNs, the recommendation depends on the expected communication patterns ๐ .
when traffic over a CNN is expected to be mostly unidirectional messages with a size typically up to 1 MSS, and the time between two consecutive message transmissions is greater than the Delayed ACK timeout, it may make sense to use a smaller timeout or turn Delayed ACKs off at the receiver ๐. this avoids extra delay, plus the energy the sender burns during that time (it might, e.g., keep its radio interface in receive mode) ๐ก. note that disabling Delayed ACKs may only be possible if the peer device is administered by the same entity managing the constrained device ๐. for request-response traffic, enabling Delayed ACKs is recommended at the server end, so a response can be combined with the ACK into a single segment, which is more efficient ๐ซถ. plus, if a client issues requests infrequently, disabling Delayed ACKs at the client allows an immediate ACK for the data segment carrying the response ๐.
in contrast, Delayed ACKs allow a reduced number of ACKs in bulk transfer types of traffic, e.g., for firmware/software updates or for transferring larger data units containing a batch of sensor readings ๐ฆโจ.
one more thing: in many scenarios, the peer a constrained device talks to is a general purpose system that communicates with both constrained and unconstrained devices ๐ฅ๏ธ. since Delayed ACKs are often configured through system-wide parameters, the behavior of Delayed ACKs at the peer will be the same no matter what kind of endpoint it's talking to ๐. such a peer will typically have Delayed ACKs enabled ๐ .
3.3.3. Initial Window
[RFC5681] specifies a TCP Initial Window (IW) of roughly 4 kB ๐. then RFC 6928 [RFC6928] defines an experimental new value for the IW, which in practice results in an IW of 10 MSS ๐งช. nowadays, that's what many TCP implementations use ๐.
okay, but a 10-MSS IW was recommended for resource-rich environments (e.g., broadband environments), which are really different from CNNs ๐. in CNNs, many application-layer data units are relatively small (e.g., below 1 MSS) ๐ฅฐ. however, larger objects (e.g., large files containing sensor readings, firmware updates, etc.) may also need to be transferred in CNNs ๐. if a large object is transferred in a CNN with an IW of 10 MSS, there's a significant buffer overflow risk, since many CNN devices support network or radio buffers smaller than 10 MSS ๐ฑ. to avoid that, the IW needs to be carefully set in CNNs, based on device and network resource constraints โ ๏ธ. in many cases, a safe IW setting will be smaller than 10 MSS ๐ซง.
4. TCP Usage Recommendations in CNNs โจ
this section discusses how applications built for CNN scenarios can use TCP ๐ง. these remarks are, by and large, independent of how TCP is exactly implemented ๐ .
4.1. TCP Connection Initiation
in the scenario of a constrained device to an unconstrained device illustrated above, a TCP connection is typically initiated by the constrained device ๐. the reason? so the device can support possible sleep periods and save energy ๐๐ค.
4.2. Number of Concurrent Connections โจ
okay so TCP endpoints with a small amount of memory may only support a small number of connections ๐ง bc every TCP connection has to store a bunch of variables in the TCB ๐ . Depending on how the TCP implementation is built, each connection can cause extra memory overhead, and connections can end up competing for scarce resources (like extra memory overhead for send and receive buffers, etc.) ๐ญ
a careful app design may try to keep the number of concurrent connections as small as possible ๐ธ. A client can, for instance, limit the number of simultaneous open connections it maintains to a given server. Multiple connections could, for instance, be used to avoid the "head-of-line blocking" problem in an application transfer ๐ฆ. However, on top of eating up resources, using multiple connections can also cause undesirable side effects in congested networks ๐. For example, the HTTP/1.1 specification encourages clients to be conservative when opening multiple connections [RFC7230]. Furthermore, each new connection starts with a three-way handshake, which means more message overhead ๐.
Being conservative when opening multiple TCP connections is of particular importance in Constrained-Node Networks ๐ซถ no cap.
4.3. TCP Connection Lifetime ๐ฆ
so in order to minimize message overhead, it makes sense to keep a TCP connection open as long as the two TCP endpoints have more data to send ๐. If applications exchange data rather infrequently, i.e., if TCP connections would stay idle for a long time, that idle time can cause problems ๐ฌ. For instance, certain middleboxes such as firewalls or NAT devices are known to delete state records after an inactivity interval. RFC 5382 [RFC5382] specifies a minimum value for such an interval of 124 minutes. Measurement studies have reported that TCP NAT binding timeouts are highly variable across devices, with the median being around 60 minutes, the shortest timeout being around 2 minutes, and more than 50% of the devices having a timeout shorter than the aforementioned minimum timeout of 124 minutes [HomeGateway]. The timeout duration used by a middlebox implementation may not be known to the TCP endpoints ๐คทโโ๏ธ.
In CNNs, such middleboxes may, e.g., be present at the boundary between the CNN and other networks ๐. If the middlebox can be optimized for CNN use cases, it makes sense to increase the initial value for filter state inactivity timers to avoid problems with idle connections โจ. Apart from that, this problem can be dealt with using different connection-handling strategies, each having pros and cons โ๏ธ.
One approach for infrequent data transfer is to use short-lived TCP connections ๐ท. Instead of trying to maintain a TCP connection for a long time, it is possible that short-lived connections can be opened between two endpoints, and then closed if no more data needs to be exchanged. For use cases that can cope with the additional messages and the latency resulting from starting new connections, it is recommended to use a sequence of short-lived connections instead of maintaining a single long-lived connection. ๐
The message and latency overhead that comes from using a sequence of short-lived connections could be reduced by TCP Fast Open (TFO) [RFC7413], which is an experimental TCP extension ๐งช. The catch is that it comes at the expense of increased implementation complexity and increased TCB size ๐ . TFO allows data to be carried in SYN (and SYN-ACK) segments and to be consumed immediately by the receiving endpoint. This reduces the message and latency overhead compared to the traditional three-way handshake used to establish a TCP connection. For security reasons, the connection initiator has to request a TFO cookie from the other endpoint. The cookie, with a size of 4 or 16 bytes, is then included in SYN packets of subsequent connections. The cookie needs to be refreshed (and obtained by the client again) after a certain amount of time โฐ.
Now here's the tea ๐ต: while a given cookie is used for multiple connections between the same two endpoints, those endpoints may become vulnerable to privacy threats ๐. In addition, a valid cookie may be stolen from a compromised host and used to perform SYN flood attacks, as well as amplified reflection attacks against victim hosts (see Section 5 of [RFC7413]) ๐. Nevertheless, TFO is more efficient than frequently opening new TCP connections with the traditional three-way handshake, as long as the cookie can be reused in subsequent connections ๐ . However, as stated in [RFC7413], TFO deviates from standard TCP semantics, since the data in the SYN could be replayed to an application in some rare circumstances ๐ต. Applications should not use TFO unless they can tolerate this issue, e.g., by using TLS [RFC7413]. A comprehensive discussion on TFO can be found in RFC 7413 [RFC7413] ๐.
Another approach is to use long-lived TCP connections with application-layer heartbeat messages ๐. Various application protocols support such heartbeat messages (e.g., CoAP over TCP [RFC8323]). Periodic application-layer heartbeats can prevent early filter state record deletion in middleboxes ๐ก๏ธ. If the TCP binding timeout for a middlebox to be traversed by a given connection is known, middlebox filter state deletion will be avoided if the heartbeat period is lower than the middlebox TCP binding timeout. Otherwise, the implementer needs to take into account that middlebox TCP binding timeouts fall in a wide range of possible values [HomeGateway], and it may be hard to find a proper heartbeat period for application-layer heartbeat messages ๐ฉ.
One specific advantage of heartbeat messages is that they also allow liveness checks at the application level ๐. In general, it makes sense to realize liveness checks at the highest protocol layer possible that is meaningful to the application, in order to maximize the depth of the liveness check ๐. In addition, timely detection of a dead peer may allow savings in terms of TCB memory use ๐ง . However, the transmission of heartbeat messages consumes resources, so this aspect needs to be assessed carefully, considering the characteristics of each specific CNN ๐.
A TCP implementation may also be able to send "keep-alive" segments to test a TCP connection ๐. According to [RFC1122], keep-alives are an optional TCP mechanism that is turned off by default, i.e., an application must explicitly enable it for a TCP connection. The interval between keep-alive messages must be configurable, and it must default to no less than two hours โณ. With this large timeout, TCP keep-alive messages might not always be useful for avoiding deletion of filter state records in some middleboxes ๐. However, sending TCP keep-alive probes more frequently risks draining power on energy-constrained devices ๐ชซ.
5. Security Considerations ๐
Best current practices for securing TCP and TCP-based communication also apply to CNNs ๐ซก. As an example, use of TLS [RFC8446] is strongly recommended if it is applicable. However, note that TLS protects only the contents of the data segments ๐.
There are TCP options that can actually protect the transport layer ๐ก๏ธ. One example is the TCP Authentication Option (TCP-AO) [RFC5925]. However, this option adds overhead and complexity. TCP-AO typically has a size of 16-20 bytes ๐. An implementer needs to assess the trade-off between security and performance when using TCP-AO, considering the characteristics (in terms of energy, bandwidth, and computational power) of the environment where TCP will be used ๐.
For the mechanisms discussed in this document, the corresponding considerations apply. For instance, if TFO is used, the security considerations of RFC 7413 [RFC7413] apply ๐.
Constrained devices are expected to support smaller TCP window sizes than less-limited devices. In such conditions, segment retransmission triggered by RTO expiration is expected to be relatively frequent, due to a lack of (enough) duplicate ACKs, especially when a constrained device uses a single-MSS implementation ๐. For this reason, constrained devices running TCP may appear as particularly appealing victims of the so-called "shrew" Denial-of-Service (DoS) attack [SHREW] ๐จ. In that attack, one or more sources generate a packet spike targeted to coincide with consecutive RTO-expiration-triggered retry attempts of a victim node. Note that the attack may be performed by Internet-connected devices, including constrained devices in the same CNN as the victim, as well as remote ones ๐ฑ. Mitigation techniques include RTO randomization and attack blocking by routers able to detect shrew attacks based on their traffic pattern ๐งฑ.
6. IANA Considerations ๐๏ธ
This document has no IANA actions ๐ธ.
7. References ๐
7.1. Normative References ๐โจ
okay bestie, this is the shelf of normative references ๐ง these are the docs the spec totally leans on. you need them to actually implement this stuff, so they're basically required reading ๐
- [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, RFC 793, DOI 10.17487/RFC0793, September 1981, <https://www.rfc-editor.org/info/rfc793>.
- [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - Communication Layers", STD 3, RFC 1122, DOI 10.17487/RFC1122, October 1989, <https://www.rfc-editor.org/info/rfc1122>.
- [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP Selective Acknowledgment Options", RFC 2018, DOI 10.17487/RFC2018, October 1996, <https://www.rfc-editor.org/info/rfc2018>.
- [RFC3042] Allman, M., Balakrishnan, H., and S. Floyd, "Enhancing TCP's Loss Recovery Using Limited Transmit", RFC 3042, DOI 10.17487/RFC3042, January 2001, <https://www.rfc-editor.org/info/rfc3042>.
- [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition of Explicit Congestion Notification (ECN) to IP", RFC 3168, DOI 10.17487/RFC3168, September 2001, <https://www.rfc-editor.org/info/rfc3168>.
- [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, <https://www.rfc-editor.org/info/rfc5681>.
- [RFC6298] Paxson, V., Allman, M., Chu, J., and M. Sargent, "Computing TCP's Retransmission Timer", RFC 6298, DOI 10.17487/RFC6298, June 2011, <https://www.rfc-editor.org/info/rfc6298>.
- [RFC6691] Borman, D., "TCP Options and Maximum Segment Size (MSS)", RFC 6691, DOI 10.17487/RFC6691, July 2012, <https://www.rfc-editor.org/info/rfc6691>.
- [RFC6928] Chu, J., Dukkipati, N., Cheng, Y., and M. Mathis, "Increasing TCP's Initial Window", RFC 6928, DOI 10.17487/RFC6928, April 2013, <https://www.rfc-editor.org/info/rfc6928>.
- [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for Constrained-Node Networks", RFC 7228, DOI 10.17487/RFC7228, May 2014, <https://www.rfc-editor.org/info/rfc7228>.
- [RFC7323] Borman, D., Braden, B., Jacobson, V., and R. Scheffenegger, Ed., "TCP Extensions for High Performance", RFC 7323, DOI 10.17487/RFC7323, September 2014, <https://www.rfc-editor.org/info/rfc7323>.
- [RFC7413] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, <https://www.rfc-editor.org/info/rfc7413>.
- [RFC7567] Baker, F., Ed. and G. Fairhurst, Ed., "IETF Recommendations Regarding Active Queue Management", BCP 197, RFC 7567, DOI 10.17487/RFC7567, July 2015, <https://www.rfc-editor.org/info/rfc7567>.
- [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 (IPv6) Specification", STD 86, RFC 8200, DOI 10.17487/RFC8200, July 2017, <https://www.rfc-editor.org/info/rfc8200>.
7.2. Informative References ๐โจ
okay bestie, here's the informative reading list ๐ฆ these ones are background and context, not the core spec, but they're lowkey a goldmine if you wanna go deeper ๐
[6LO-WLANAH]Del Carpio Vega, L., Robles, M., and R. Morabito, "IPv6 over 802.11ah", Work in Progress, Internet-Draft, draft-delcarpio-6lo-wlanah-01, 19 October 2015,https://tools.ietf.org/html/draft-delcarpio-6lo-wlanah-01.[Commag]Betzler, A., Gomez, C., Demirkol, I., and J. Paradells, "CoAP Congestion Control for the Internet of Things", IEEE Communications Magazine, Vol. 54, Issue 7, pp. 154-160, DOI 10.1109/MCOM.2016.7509394, July 2016,https://doi.org/10.1109/MCOM.2016.7509394.[CORE-FASOR]Jarvinen, I., Kojo, M., Raitahila, I., and Z. Cao, "Fast-Slow Retransmission Timeout and Congestion Control Algorithm for CoAP", Work in Progress, Internet-Draft, draft-ietf-core-fasor-01, 19 October 2020,https://tools.ietf.org/html/draft-ietf-core-fasor-01.[Dunk]Dunkels, A., "Full TCP/IP for 8-Bit Architectures", MobiSys '03, pp. 85-98, DOI 10.1145/1066116.106611, May 2003,https://doi.org/10.1145/1066116.106611.[ETEN]Krishnan, R., Sterbenz, J., Eddy, W., and C. Partridge, "Explicit transport error notification (ETEN) for error-prone wireless and satellite networks", Computer Networks, DOI 10.1016/j.comnet.2004.06.012, June 2004,https://doi.org/10.1016/j.comnet.2004.06.012.[GNRC]Lenders, M., Kietzmann, P., Hahm, O., Petersen, H., Gรผndoฤa, C., Baccelli, E., Schleiser, K., Schmidt, T., and M. Wรคhlisch, "Connecting the World of Embedded Mobiles: The RIOT Approach to Ubiquitous Networking for the IoT", arXiv:1801.02833v1 [cs.NI], January 2018.[HomeGateway]Haetoenen, S., Nyrhinen, A., Eggert, L., Strowes, S., Sarolahti, P., and M. Kojo, "An Experimental Study of Home Gateway Characteristics", Proceedings of the 10th ACM SIGCOMM conference on Internet measurement, pp. 260-266, DOI 10.1145/1879141.1879174, November 2010,https://doi.org/10.1145/1879141.1879174.[IntComp]Gomez, C., Arcia-Moret, A., and J. Crowcroft, "TCP in the Internet of Things: from Ostracism to Prominence", IEEE Internet Computing, Vol. 22, Issue 1, pp. 29-41, DOI 10.1109/MIC.2018.112102200, January 2018,https://doi.org/10.1109/MIC.2018.112102200.[MQTT]ISO/IEC, "Information technology -- Message Queuing Telemetry Transport (MQTT) v3.1.1", ISO/IEC 20922:2016, June 2016.[RFC2757]Montenegro, G., Dawkins, S., Kojo, M., Magret, V., and N. Vaidya, "Long Thin Networks", RFC 2757, DOI 10.17487/RFC2757, January 2000,https://www.rfc-editor.org/info/rfc2757.[RFC2884]Hadi Salim, J. and U. Ahmed, "Performance Evaluation of Explicit Congestion Notification (ECN) in IP Networks", RFC 2884, DOI 10.17487/RFC2884, July 2000,https://www.rfc-editor.org/info/rfc2884.[RFC3481]Inamura, H., Ed., Montenegro, G., Ed., Ludwig, R., Gurtov, A., and F. Khafizov, "TCP over Second (2.5G) and Third (3G) Generation Wireless Networks", BCP 71, RFC 3481, DOI 10.17487/RFC3481, February 2003,https://www.rfc-editor.org/info/rfc3481.[RFC3819]Karn, P., Ed., Bormann, C., Fairhurst, G., Grossman, D., Ludwig, R., Mahdavi, J., Montenegro, G., Touch, J., and L. Wood, "Advice for Internet Subnetwork Designers", BCP 89, RFC 3819, DOI 10.17487/RFC3819, July 2004,https://www.rfc-editor.org/info/rfc3819.[RFC4944]Montenegro, G., Kushalnagar, N., Hui, J., and D. Culler, "Transmission of IPv6 Packets over IEEE 802.15.4 Networks", RFC 4944, DOI 10.17487/RFC4944, September 2007,https://www.rfc-editor.org/info/rfc4944.[RFC5382]Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, RFC 5382, DOI 10.17487/RFC5382, October 2008,https://www.rfc-editor.org/info/rfc5382.[RFC5925]Touch, J., Mankin, A., and R. Bonica, "The TCP Authentication Option", RFC 5925, DOI 10.17487/RFC5925, June 2010,https://www.rfc-editor.org/info/rfc5925.[RFC6077]Papadimitriou, D., Ed., Welzl, M., Scharf, M., and B. Briscoe, "Open Research Issues in Internet Congestion Control", RFC 6077, DOI 10.17487/RFC6077, February 2011,https://www.rfc-editor.org/info/rfc6077.[RFC6120]Saint-Andre, P., "Extensible Messaging and Presence Protocol (XMPP): Core", RFC 6120, DOI 10.17487/RFC6120, March 2011,https://www.rfc-editor.org/info/rfc6120.[RFC6282]Hui, J., Ed. and P. Thubert, "Compression Format for IPv6 Datagrams over IEEE 802.15.4-Based Networks", RFC 6282, DOI 10.17487/RFC6282, September 2011,https://www.rfc-editor.org/info/rfc6282.[RFC6550]Winter, T., Ed., Thubert, P., Ed., Brandt, A., Hui, J., Kelsey, R., Levis, P., Pister, K., Struik, R., Vasseur, JP., and R. Alexander, "RPL: IPv6 Routing Protocol for Low-Power and Lossy Networks", RFC 6550, DOI 10.17487/RFC6550, March 2012,https://www.rfc-editor.org/info/rfc6550.[RFC6606]Kim, E., Kaspar, D., Gomez, C., and C. Bormann, "Problem Statement and Requirements for IPv6 over Low-Power Wireless Personal Area Network (6LoWPAN) Routing", RFC 6606, DOI 10.17487/RFC6606, May 2012,https://www.rfc-editor.org/info/rfc6606.[RFC6775]Shelby, Z., Ed., Chakrabarti, S., Nordmark, E., and C. Bormann, "Neighbor Discovery Optimization for IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs)", RFC 6775, DOI 10.17487/RFC6775, November 2012,https://www.rfc-editor.org/info/rfc6775.[RFC7230]Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014,https://www.rfc-editor.org/info/rfc7230.[RFC7252]Shelby, Z., Hartke, K., and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, June 2014,https://www.rfc-editor.org/info/rfc7252.[RFC7414]Duke, M., Braden, R., Eddy, W., Blanton, E., and A. Zimmermann, "A Roadmap for Transmission Control Protocol (TCP) Specification Documents", RFC 7414, DOI 10.17487/RFC7414, February 2015,https://www.rfc-editor.org/info/rfc7414.[RFC7428]Brandt, A. and J. Buron, "Transmission of IPv6 Packets over ITU-T G.9959 Networks", RFC 7428, DOI 10.17487/RFC7428, February 2015,https://www.rfc-editor.org/info/rfc7428.[RFC7540]Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext Transfer Protocol Version 2 (HTTP/2)", RFC 7540, DOI 10.17487/RFC7540, May 2015,https://www.rfc-editor.org/info/rfc7540.[RFC7668]Nieminen, J., Savolainen, T., Isomaki, M., Patil, B., Shelby, Z., and C. Gomez, "IPv6 over BLUETOOTH(R) Low Energy", RFC 7668, DOI 10.17487/RFC7668, October 2015,https://www.rfc-editor.org/info/rfc7668.[RFC8087]Fairhurst, G. and M. Welzl, "The Benefits of Using Explicit Congestion Notification (ECN)", RFC 8087, DOI 10.17487/RFC8087, March 2017,https://www.rfc-editor.org/info/rfc8087.[RFC8105]Mariager, P., Petersen, J., Ed., Shelby, Z., Van de Logt, M., and D. Barthel, "Transmission of IPv6 Packets over Digital Enhanced Cordless Telecommunications (DECT) Ultra Low Energy (ULE)", RFC 8105, DOI 10.17487/RFC8105, May 2017,https://www.rfc-editor.org/info/rfc8105.[RFC8163]Lynn, K., Ed., Martocci, J., Neilson, C., and S. Donaldson, "Transmission of IPv6 over Master-Slave/Token-Passing (MS/TP) Networks", RFC 8163, DOI 10.17487/RFC8163, May 2017,https://www.rfc-editor.org/info/rfc8163.[RFC8201]McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., "Path MTU Discovery for IP version 6", STD 87, RFC 8201, DOI 10.17487/RFC8201, July 2017,https://www.rfc-editor.org/info/rfc8201.[RFC8323]Bormann, C., Lemay, S., Tschofenig, H., Hartke, K., Silverajan, B., and B. Raymor, Ed., "CoAP (Constrained Application Protocol) over TCP, TLS, and WebSockets", RFC 8323, DOI 10.17487/RFC8323, February 2018,https://www.rfc-editor.org/info/rfc8323.[RFC8352]Gomez, C., Kovatsch, M., Tian, H., and Z. Cao, Ed., "Energy-Efficient Features of Internet of Things Protocols", RFC 8352, DOI 10.17487/RFC8352, April 2018,https://www.rfc-editor.org/info/rfc8352.[RFC8376]Farrell, S., Ed., "Low-Power Wide Area Network (LPWAN) Overview", RFC 8376, DOI 10.17487/RFC8376, May 2018,https://www.rfc-editor.org/info/rfc8376.[RFC8446]Rescorla, E., "The Transport Layer Security (TLS) Protocol Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,https://www.rfc-editor.org/info/rfc8446.[RFC8900]Bonica, R., Baker, F., Huston, G., Hinden, R., Troan, O., and F. Gont, "IP Fragmentation Considered Fragile", BCP 230, RFC 8900, DOI 10.17487/RFC8900, September 2020,https://www.rfc-editor.org/info/rfc8900.[RFC8931]Thubert, P., Ed., "IPv6 over Low-Power Wireless Personal Area Network (6LoWPAN) Selective Fragment Recovery", RFC 8931, DOI 10.17487/RFC8931, November 2020,https://www.rfc-editor.org/info/rfc8931.[RFC8961]Allman, M., "Requirements for Time-Based Loss Detection", BCP 233, RFC 8961, DOI 10.17487/RFC8961, November 2020,https://www.rfc-editor.org/info/rfc8961.[RIOT]Baccelli, E., Gรผndoฤa, C., Hahm, O., Kietzmann, P., Lenders, M., Petersen, H., Schleiser, K., Schmidt, T., and M. Wรคhlisch, "RIOT: An Open Source Operating System for Low-End Embedded Devices in the IoT", IEEE Internet of Things Journal, Vol. 5, Issue 6, DOI 10.1109/JIOT.2018.2815038, March 2018,https://doi.org/10.1109/JIOT.2018.2815038.[SHREW]Nyrhinen, A. and E. Knightly, "Low-Rate TCP-Targeted Denial of Service Attacks (The Shrew vs. the Mice and Elephants)", SIGCOMM'03, DOI 10.1145/863955.863966, August 2003,https://doi.org/10.1145/863955.863966.[TCPM-ECN]Bagnulo, M. and B. Briscoe, "ECN++: Adding Explicit Congestion Notification (ECN) to TCP Control Packets", Work in Progress, Internet-Draft, draft-ietf-tcpm-generalized-ecn-07, 16 February 2021,https://tools.ietf.org/html/draft-ietf-tcpm-generalized-ecn-07.
Appendix A. TCP Implementations for Constrained Devices ๐ง
okay bestie, this appendix is a tour of the main TCP stacks made for tiny devices ๐ the survey is limited to open-source stacks with a small footprint, and it is not meant to be all-encompassing ๐ for more powerful embedded systems (e.g., with 32-bit processors), there are further stacks that comprehensively implement TCP โจ also, be aware that this Annex is based on info available as of the writing ๐
A.1. uIP
uIP is a TCP/IP stack, targeted for 8- and 16-bit microcontrollers, and it's kind of the OG that pioneered TCP/IP implementations for constrained devices ๐ it has been deployed with Contiki and the Arduino Ethernet shield ๐ฆ a code size of ~5 kB (which comprises checksumming, IPv4, ICMP, and TCP) has been reported for uIP [Dunk]. later versions of uIP implement IPv6 as well ๐
uIP uses the same global buffer for both incoming and outgoing traffic, and that buffer is a size of a single packet ๐ in case of a retransmission, an application must be able to reproduce the same user data that had been transmitted. multiple connections are supported, but they need to share the global buffer ๐ซถ
the MSS is announced via the MSS option on connection establishment, and the receive window size (of 1 MSS) is not modified during a connection. stop-and-wait operation is used for sending data ๐ among other optimizations, this allows for the avoidance of sliding window operations, which use 32-bit arithmetic extensively and are expensive on 8-bit CPUs ๐
Contiki uses the "split hack" technique (see Section 3.2.3) to avoid Delayed ACKs for senders using a single segment ๐ง
the code size of the TCP implementation in Contiki-NG has been measured to be 3.2 kB on CC2538DK, cross-compiling on Linux โจ
A.2. lwIP
lwIP is a TCP/IP stack, targeted for 8- and 16-bit microcontrollers ๐ it has a total code size of ~14 kB to ~22 kB (which comprises memory management, checksumming, network interfaces, IPv4, ICMP, and TCP) and a TCP code size of ~9 kB to ~14 kB [Dunk]. both IPv4 and IPv6 are supported in lwIP since v2.0.0 ๐ธ
ngl, lwIP is a glow-up compared to uIP ๐ฅ it decouples applications from the network stack. lwIP supports a TCP transmission window greater than a single segment, as well as the buffering of incoming and outgoing data. other implemented mechanisms comprise slow start, congestion avoidance, fast retransmit, and fast recovery ๐ SACK and Window Scale support has been recently added to lwIP ๐
A.3. RIOT
the RIOT TCP implementation (called "GNRC TCP") has been designed for Class 1 devices [RFC7228] ๐ท the main target platforms are 8- and 16-bit microcontrollers, with 32-bit platforms also supported. GNRC TCP offers a similar function set as uIP, but it provides and maintains an independent receive buffer for each connection โจ unlike uIP, retransmission is also handled by GNRC TCP. for simplicity, GNRC TCP uses a single-MSS implementation ๐ง the application programmer does not need to know anything about the TCP internals, so GNRC TCP can be seen as a user-friendly uIP TCP implementation ๐ฆ
the MSS is set on connection establishment and cannot be changed during connection lifetime. GNRC TCP allows multiple connections in parallel, but each TCB must be allocated somewhere in the system. by default, there is only enough memory allocated for a single TCP connection, but it can be increased at compile time if the user needs multiple parallel connections ๐งฉ
the RIOT TCP implementation offers an optional Portable Operating System Interface (POSIX) socket wrapper that enables POSIX compliance, if needed ๐
further details on RIOT and GNRC can be found in [RIOT] and [GNRC] ๐
A.4. TinyOS
TinyOS was important as a platform for early constrained devices, so it deserves a shoutout ๐ซก TinyOS has an experimental TCP stack that uses a simple non-blocking library-based implementation of TCP, which provides a subset of the socket interface primitives. the application is responsible for buffering ๐งบ the TCP library does not do any receive-side buffering. instead, it will immediately dispatch new, in-order data to the application or otherwise drop the segment. a send buffer is provided by the application. multiple TCP connections are possible. recently, there has been little work on the stack ๐ฅฒ
A.5. FreeRTOS
FreeRTOS is a real-time operating system kernel for embedded devices that is supported by 16- and 32-bit microprocessors โฑ๏ธ its TCP implementation is based on multiple-segment window size, although a "Tiny-TCP" option, which is a single-MSS variant, can be enabled ๐ซ delayed ACKs are supported, with a 20 ms Delayed ACK timer as a technique intended "to gain performance" โญ
A.6. uC/OS
uC/OS is a real-time operating system kernel for embedded devices, which is maintained by Micrium ๐ uC/OS is intended for 8-, 16-, and 32-bit microprocessors. the uC/OS TCP implementation supports a multiple-segment window size ๐
A.7. Summary
okay, the big recap ๐ none of the implementations considered in this Annex support ECN or TFO ๐
+==========+=====+======+==========+======+========+==========+=====+
| | uIP |lwIP | lwIP 2.1 | RIOT | TinyOS | FreeRTOS |uC/OS|
| | |orig | | | | | |
+==========+=====+======+==========+======+========+==========+=====+
| Code | <5 |~9 to | 38 | <7 | N/A | <9.2 | N/A |
| Size | | ~14 | | | | | |
| (kB) | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Memory | (a) | (T1) | (T4) | (T3) | N/A | (T2) | N/A |
+==========+=====+======+==========+======+========+==========+=====+
| TCP |
| Features |
+==========+=====+======+==========+======+========+==========+=====+
| Single- | Yes | No | No | Yes | No | No | No |
| Segm. | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Slow | No | Yes | Yes | No | Yes | No | Yes |
| start | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Fast | No | Yes | Yes | No | Yes | No | Yes |
| rec/retx | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Keep- | No | No | Yes | No | No | Yes | Yes |
| alive | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Win. | No | No | Yes | No | No | Yes | No |
| Scale | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| TCP | No | No | Yes | No | No | Yes | No |
| timest. | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| SACK | No | No | Yes | No | No | Yes | No |
+----------+-----+------+----------+------+--------+----------+-----+
| Del. | No | Yes | Yes | No | No | Yes | Yes |
| ACKs | | | | | | | |
+----------+-----+------+----------+------+--------+----------+-----+
| Socket | No | No | Optional | (I) | Subset | Yes | Yes |
+----------+-----+------+----------+------+--------+----------+-----+
| Concur. | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Conn. | | | | | | | |
+==========+=====+======+==========+======+========+==========+=====+
| TLS supp | No | No | Yes | Yes | Yes | Yes | Yes |
| orted | | | | | | | |
+==========+=====+======+==========+======+========+==========+=====+
Table 1: Summary of TCP Features for Different Lightweight TCP
Implementations
this table is the whole vibe check ๐ here's the legend so you can read it like a pro:
Legend:
(T1): TCP-only, on x86 and AVR platforms
(T2): TCP-only, on ARM Cortex-M platform
(T3): TCP-only, on ARM Cortex-M0+ platform (NOTE: RAM usage for the
same platform is ~2.5 kB for one TCP connection plus ~1.2 kB
for each additional connection)
(T4): TCP-only, on CC2538DK, cross-compiling on Linux
(a): Includes IP, ICMP, and TCP on x86 and AVR platforms. The
Contiki-NG TCP implementation has a code size of 3.2 kB on
CC2538DK, cross-compiling on Linux
(I): Optional POSIX socket wrapper that enables POSIX compliance
if needed
Mult.: Multiple
N/A: Not Available
Acknowledgments ๐ซถ
the work of Carles Gomez has been funded in part by the Spanish Government (Ministerio de Educacion, Cultura y Deporte) through Jose Castillejo grants CAS15/00336 and CAS18/00170; the European Regional Development Fund (ERDF); the Spanish Government through projects TEC2016-79988-P, PID2019-106808RA-I00, AEI/FEDER, and UE; and the Generalitat de Catalunya Grant 2017 SGR 376. part of his contribution to this work has been carried out during his stays as a visiting scholar at the Computer Laboratory of the University of Cambridge ๐ช๐ธโจ
the authors appreciate the feedback received for this document ๐ the following folks provided comments that helped improve the document: Carsten Bormann, Zhen Cao, Wei Genyu, Ari Kerรคnen, Abhijan Bhattacharyya, Andres Arcia-Moret, Yoshifumi Nishida, Joe Touch, Fred Baker, Nik Sultana, Kerry Lynn, Erik Nordmark, Markku Kojo, Hannes Tschofenig, David Black, Ilpo Jarvinen, Emmanuel Baccelli, Stuart Cheshire, Gorry Fairhurst, Ingemar Johansson, Ted Lemon, and Michael Tรผxen ๐ Simon Brummer provided details and kindly performed Random Access Memory (RAM) and Read-Only Memory (ROM) usage measurements on the RIOT TCP implementation ๐ Xavi Vilajosana provided details on the OpenWSN TCP implementation ๐งก Rahul Jadhav kindly performed code size measurements on the Contiki-NG and lwIP 2.1.2 TCP implementations. he also provided details on the uIP TCP implementation ๐ฅฐ
Authors' Addresses ๐ฎ
Carles Gomez
UPC
C/Esteve Terradas, 7
08860 Castelldefels
Spain
Email: carlesgo@entel.upc.edu
Jon Crowcroft
University of Cambridge
JJ Thomson Avenue
Cambridge
CB3 0FD
United Kingdom
Email: jon.crowcroft@cl.cam.ac.uk
Michael Scharf
Hochschule Esslingen
University of Applied Sciences
Flandernstr. 101
73732 Esslingen am Neckar
Germany
Email: michael.scharf@hs-esslingen.de
and that's a wrap on RFC 9006 ๐๐ you made it, bestie!! ๐ฆโจ
๐ฆ where this page comes from
- ietf: rfc9006 2021-03
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms