idnits 2.17.1 draft-ietf-tsvwg-rfc4960-bis-08.txt: -(4): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(5): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(6531): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding 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: ---------------------------------------------------------------------------- == There are 9 instances of lines with non-ascii characters in the document. 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 == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (30 November 2020) is 1243 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'ASSOCIATE' is mentioned on line 2411, but not defined == Missing Reference: 'SHUTDOWN' is mentioned on line 2442, but not defined == Missing Reference: 'ABORT' is mentioned on line 2405, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.V42.1994' ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 2960 (Obsoleted by RFC 4960) -- Obsolete informational reference (is this intentional?): RFC 4460 (Obsoleted by RFC 9260) -- Obsolete informational reference (is this intentional?): RFC 4960 (Obsoleted by RFC 9260) -- Obsolete informational reference (is this intentional?): RFC 7053 (Obsoleted by RFC 9260) -- Obsolete informational reference (is this intentional?): RFC 8540 (Obsoleted by RFC 9260) Summary: 1 error (**), 0 flaws (~~), 6 warnings (==), 8 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group R. R. Stewart 3 Internet-Draft Netflix, Inc. 4 Obsoletes: 4960 (if approved) M. Tüxen 5 Intended status: Standards Track Münster Univ. of Appl. Sciences 6 Expires: 3 June 2021 K. E. E. Nielsen 7 Kamstrup A/S 8 30 November 2020 10 Stream Control Transmission Protocol 11 draft-ietf-tsvwg-rfc4960-bis-08 13 Abstract 15 This document obsoletes RFC 4960, if approved. It describes the 16 Stream Control Transmission Protocol (SCTP). SCTP is designed to 17 transport Public Switched Telephone Network (PSTN) signaling messages 18 over IP networks, but is capable of broader applications. 20 SCTP is a reliable transport protocol operating on top of a 21 connectionless packet network such as IP. It offers the following 22 services to its users: 24 * acknowledged error-free non-duplicated transfer of user data, 26 * data fragmentation to conform to discovered path MTU size, 28 * sequenced delivery of user messages within multiple streams, with 29 an option for order-of-arrival delivery of individual user 30 messages, 32 * optional bundling of multiple user messages into a single SCTP 33 packet, and 35 * network-level fault tolerance through supporting of multi-homing 36 at either or both ends of an association. 38 The design of SCTP includes appropriate congestion avoidance behavior 39 and resistance to flooding and masquerade attacks. 41 Status of This Memo 43 This Internet-Draft is submitted in full conformance with the 44 provisions of BCP 78 and BCP 79. 46 Internet-Drafts are working documents of the Internet Engineering 47 Task Force (IETF). Note that other groups may also distribute 48 working documents as Internet-Drafts. The list of current Internet- 49 Drafts is at https://datatracker.ietf.org/drafts/current/. 51 Internet-Drafts are draft documents valid for a maximum of six months 52 and may be updated, replaced, or obsoleted by other documents at any 53 time. It is inappropriate to use Internet-Drafts as reference 54 material or to cite them other than as "work in progress." 56 This Internet-Draft will expire on 3 June 2021. 58 Copyright Notice 60 Copyright (c) 2020 IETF Trust and the persons identified as the 61 document authors. All rights reserved. 63 This document is subject to BCP 78 and the IETF Trust's Legal 64 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 65 license-info) in effect on the date of publication of this document. 66 Please review these documents carefully, as they describe your rights 67 and restrictions with respect to this document. Code Components 68 extracted from this document must include Simplified BSD License text 69 as described in Section 4.e of the Trust Legal Provisions and are 70 provided without warranty as described in the Simplified BSD License. 72 This document may contain material from IETF Documents or IETF 73 Contributions published or made publicly available before November 74 10, 2008. The person(s) controlling the copyright in some of this 75 material may not have granted the IETF Trust the right to allow 76 modifications of such material outside the IETF Standards Process. 77 Without obtaining an adequate license from the person(s) controlling 78 the copyright in such materials, this document may not be modified 79 outside the IETF Standards Process, and derivative works of it may 80 not be created outside the IETF Standards Process, except to format 81 it for publication as an RFC or to translate it into languages other 82 than English. 84 Table of Contents 86 1. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 6 87 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 88 2.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 6 89 2.2. Architectural View of SCTP . . . . . . . . . . . . . . . 7 90 2.3. Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 8 91 2.4. Abbreviations . . . . . . . . . . . . . . . . . . . . . . 12 92 2.5. Functional View of SCTP . . . . . . . . . . . . . . . . . 12 93 2.5.1. Association Startup and Takedown . . . . . . . . . . 13 94 2.5.2. Sequenced Delivery within Streams . . . . . . . . . . 13 95 2.5.3. User Data Fragmentation . . . . . . . . . . . . . . . 14 96 2.5.4. Acknowledgement and Congestion Avoidance . . . . . . 14 97 2.5.5. Chunk Bundling . . . . . . . . . . . . . . . . . . . 14 98 2.5.6. Packet Validation . . . . . . . . . . . . . . . . . . 15 99 2.5.7. Path Management . . . . . . . . . . . . . . . . . . . 15 100 2.6. Serial Number Arithmetic . . . . . . . . . . . . . . . . 15 101 2.7. Changes from RFC 4960 . . . . . . . . . . . . . . . . . . 16 102 3. SCTP Packet Format . . . . . . . . . . . . . . . . . . . . . 16 103 3.1. SCTP Common Header Field Descriptions . . . . . . . . . . 17 104 3.2. Chunk Field Descriptions . . . . . . . . . . . . . . . . 18 105 3.2.1. Optional/Variable-Length Parameter Format . . . . . . 21 106 3.2.2. Reporting of Unrecognized Parameters . . . . . . . . 23 107 3.3. SCTP Chunk Definitions . . . . . . . . . . . . . . . . . 23 108 3.3.1. Payload Data (DATA) (0) . . . . . . . . . . . . . . . 23 109 3.3.2. Initiation (INIT) (1) . . . . . . . . . . . . . . . . 26 110 3.3.2.1. Optional/Variable-Length Parameters in INIT . . . 29 111 3.3.3. Initiation Acknowledgement (INIT ACK) (2) . . . . . . 32 112 3.3.3.1. Optional or Variable-Length Parameters . . . . . 35 113 3.3.4. Selective Acknowledgement (SACK) (3) . . . . . . . . 36 114 3.3.5. Heartbeat Request (HEARTBEAT) (4) . . . . . . . . . . 39 115 3.3.6. Heartbeat Acknowledgement (HEARTBEAT ACK) (5) . . . . 40 116 3.3.7. Abort Association (ABORT) (6) . . . . . . . . . . . . 41 117 3.3.8. Shutdown Association (SHUTDOWN) (7) . . . . . . . . . 42 118 3.3.9. Shutdown Acknowledgement (SHUTDOWN ACK) (8) . . . . . 43 119 3.3.10. Operation Error (ERROR) (9) . . . . . . . . . . . . . 43 120 3.3.10.1. Invalid Stream Identifier (1) . . . . . . . . . 45 121 3.3.10.2. Missing Mandatory Parameter (2) . . . . . . . . 46 122 3.3.10.3. Stale Cookie Error (3) . . . . . . . . . . . . . 46 123 3.3.10.4. Out of Resource (4) . . . . . . . . . . . . . . 47 124 3.3.10.5. Unresolvable Address (5) . . . . . . . . . . . . 47 125 3.3.10.6. Unrecognized Chunk Type (6) . . . . . . . . . . 47 126 3.3.10.7. Invalid Mandatory Parameter (7) . . . . . . . . 48 127 3.3.10.8. Unrecognized Parameters (8) . . . . . . . . . . 48 128 3.3.10.9. No User Data (9) . . . . . . . . . . . . . . . . 48 129 3.3.10.10. Cookie Received While Shutting Down (10) . . . . 49 130 3.3.10.11. Restart of an Association with New Addresses 131 (11) . . . . . . . . . . . . . . . . . . . . . . . 49 132 3.3.10.12. User-Initiated Abort (12) . . . . . . . . . . . 50 133 3.3.10.13. Protocol Violation (13) . . . . . . . . . . . . 50 134 3.3.11. Cookie Echo (COOKIE ECHO) (10) . . . . . . . . . . . 50 135 3.3.12. Cookie Acknowledgement (COOKIE ACK) (11) . . . . . . 51 136 3.3.13. Shutdown Complete (SHUTDOWN COMPLETE) (14) . . . . . 52 137 4. SCTP Association State Diagram . . . . . . . . . . . . . . . 52 138 5. Association Initialization . . . . . . . . . . . . . . . . . 55 139 5.1. Normal Establishment of an Association . . . . . . . . . 56 140 5.1.1. Handle Stream Parameters . . . . . . . . . . . . . . 58 141 5.1.2. Handle Address Parameters . . . . . . . . . . . . . . 58 142 5.1.3. Generating State Cookie . . . . . . . . . . . . . . . 60 143 5.1.4. State Cookie Processing . . . . . . . . . . . . . . . 61 144 5.1.5. State Cookie Authentication . . . . . . . . . . . . . 61 145 5.1.6. An Example of Normal Association Establishment . . . 62 146 5.2. Handle Duplicate or Unexpected INIT, INIT ACK, COOKIE ECHO, 147 and COOKIE ACK . . . . . . . . . . . . . . . . . . . . . 64 148 5.2.1. INIT Received in COOKIE-WAIT or COOKIE-ECHOED State 149 (Item B) . . . . . . . . . . . . . . . . . . . . . . 64 150 5.2.2. Unexpected INIT in States Other than CLOSED, 151 COOKIE-ECHOED, COOKIE-WAIT, and SHUTDOWN-ACK-SENT . . 65 152 5.2.3. Unexpected INIT ACK . . . . . . . . . . . . . . . . . 66 153 5.2.4. Handle a COOKIE ECHO when a TCB Exists . . . . . . . 66 154 5.2.4.1. An Example of a Association Restart . . . . . . . 69 155 5.2.5. Handle Duplicate COOKIE ACK . . . . . . . . . . . . . 71 156 5.2.6. Handle Stale COOKIE Error . . . . . . . . . . . . . . 71 157 5.3. Other Initialization Issues . . . . . . . . . . . . . . . 71 158 5.3.1. Selection of Tag Value . . . . . . . . . . . . . . . 72 159 5.4. Path Verification . . . . . . . . . . . . . . . . . . . . 72 160 6. User Data Transfer . . . . . . . . . . . . . . . . . . . . . 73 161 6.1. Transmission of DATA Chunks . . . . . . . . . . . . . . . 75 162 6.2. Acknowledgement on Reception of DATA Chunks . . . . . . . 78 163 6.2.1. Processing a Received SACK . . . . . . . . . . . . . 82 164 6.3. Management of Retransmission Timer . . . . . . . . . . . 83 165 6.3.1. RTO Calculation . . . . . . . . . . . . . . . . . . . 83 166 6.3.2. Retransmission Timer Rules . . . . . . . . . . . . . 85 167 6.3.3. Handle T3-rtx Expiration . . . . . . . . . . . . . . 86 168 6.4. Multi-Homed SCTP Endpoints . . . . . . . . . . . . . . . 87 169 6.4.1. Failover from an Inactive Destination Address . . . . 88 170 6.5. Stream Identifier and Stream Sequence Number . . . . . . 89 171 6.6. Ordered and Unordered Delivery . . . . . . . . . . . . . 89 172 6.7. Report Gaps in Received DATA TSNs . . . . . . . . . . . . 90 173 6.8. CRC32c Checksum Calculation . . . . . . . . . . . . . . . 91 174 6.9. Fragmentation and Reassembly . . . . . . . . . . . . . . 92 175 6.10. Bundling . . . . . . . . . . . . . . . . . . . . . . . . 93 176 7. Congestion Control . . . . . . . . . . . . . . . . . . . . . 94 177 7.1. SCTP Differences from TCP Congestion Control . . . . . . 95 178 7.2. SCTP Slow-Start and Congestion Avoidance . . . . . . . . 96 179 7.2.1. Slow-Start . . . . . . . . . . . . . . . . . . . . . 97 180 7.2.2. Congestion Avoidance . . . . . . . . . . . . . . . . 98 181 7.2.3. Congestion Control . . . . . . . . . . . . . . . . . 99 182 7.2.4. Fast Retransmit on Gap Reports . . . . . . . . . . . 99 183 7.2.5. Making Changes to Differentiated Services Code 184 Points . . . . . . . . . . . . . . . . . . . . . . . 101 185 7.3. Path MTU Discovery . . . . . . . . . . . . . . . . . . . 101 186 8. Fault Management . . . . . . . . . . . . . . . . . . . . . . 101 187 8.1. Endpoint Failure Detection . . . . . . . . . . . . . . . 102 188 8.2. Path Failure Detection . . . . . . . . . . . . . . . . . 102 189 8.3. Path Heartbeat . . . . . . . . . . . . . . . . . . . . . 103 190 8.4. Handle "Out of the Blue" Packets . . . . . . . . . . . . 105 191 8.5. Verification Tag . . . . . . . . . . . . . . . . . . . . 106 192 8.5.1. Exceptions in Verification Tag Rules . . . . . . . . 107 193 9. Termination of Association . . . . . . . . . . . . . . . . . 108 194 9.1. Abort of an Association . . . . . . . . . . . . . . . . . 108 195 9.2. Shutdown of an Association . . . . . . . . . . . . . . . 109 196 10. ICMP Handling . . . . . . . . . . . . . . . . . . . . . . . . 111 197 11. Interface with Upper Layer . . . . . . . . . . . . . . . . . 113 198 11.1. ULP-to-SCTP . . . . . . . . . . . . . . . . . . . . . . 113 199 11.1.1. Initialize . . . . . . . . . . . . . . . . . . . . . 113 200 11.1.2. Associate . . . . . . . . . . . . . . . . . . . . . 114 201 11.1.3. Shutdown . . . . . . . . . . . . . . . . . . . . . . 115 202 11.1.4. Abort . . . . . . . . . . . . . . . . . . . . . . . 115 203 11.1.5. Send . . . . . . . . . . . . . . . . . . . . . . . . 116 204 11.1.6. Set Primary . . . . . . . . . . . . . . . . . . . . 117 205 11.1.7. Receive . . . . . . . . . . . . . . . . . . . . . . 118 206 11.1.8. Status . . . . . . . . . . . . . . . . . . . . . . . 119 207 11.1.9. Change Heartbeat . . . . . . . . . . . . . . . . . . 119 208 11.1.10. Request HeartBeat . . . . . . . . . . . . . . . . . 120 209 11.1.11. Get SRTT Report . . . . . . . . . . . . . . . . . . 120 210 11.1.12. Set Failure Threshold . . . . . . . . . . . . . . . 121 211 11.1.13. Set Protocol Parameters . . . . . . . . . . . . . . 121 212 11.1.14. Receive Unsent Message . . . . . . . . . . . . . . . 122 213 11.1.15. Receive Unacknowledged Message . . . . . . . . . . . 122 214 11.1.16. Destroy SCTP Instance . . . . . . . . . . . . . . . 123 215 11.2. SCTP-to-ULP . . . . . . . . . . . . . . . . . . . . . . 123 216 11.2.1. DATA ARRIVE Notification . . . . . . . . . . . . . . 123 217 11.2.2. SEND FAILURE Notification . . . . . . . . . . . . . 124 218 11.2.3. NETWORK STATUS CHANGE Notification . . . . . . . . . 124 219 11.2.4. COMMUNICATION UP Notification . . . . . . . . . . . 124 220 11.2.5. COMMUNICATION LOST Notification . . . . . . . . . . 125 221 11.2.6. COMMUNICATION ERROR Notification . . . . . . . . . . 125 222 11.2.7. RESTART Notification . . . . . . . . . . . . . . . . 126 223 11.2.8. SHUTDOWN COMPLETE Notification . . . . . . . . . . . 126 224 12. Security Considerations . . . . . . . . . . . . . . . . . . . 126 225 12.1. Security Objectives . . . . . . . . . . . . . . . . . . 126 226 12.2. SCTP Responses to Potential Threats . . . . . . . . . . 126 227 12.2.1. Countering Insider Attacks . . . . . . . . . . . . . 127 228 12.2.2. Protecting against Data Corruption in the Network . 127 229 12.2.3. Protecting Confidentiality . . . . . . . . . . . . . 127 230 12.2.4. Protecting against Blind Denial-of-Service 231 Attacks . . . . . . . . . . . . . . . . . . . . . . . 128 232 12.2.4.1. Flooding . . . . . . . . . . . . . . . . . . . . 128 233 12.2.4.2. Blind Masquerade . . . . . . . . . . . . . . . . 129 234 12.2.4.3. Improper Monopolization of Services . . . . . . 130 235 12.3. SCTP Interactions with Firewalls . . . . . . . . . . . . 130 236 12.4. Protection of Non-SCTP-Capable Hosts . . . . . . . . . . 130 237 13. Network Management Considerations . . . . . . . . . . . . . . 131 238 14. Recommended Transmission Control Block (TCB) Parameters . . . 131 239 14.1. Parameters Necessary for the SCTP Instance . . . . . . . 131 240 14.2. Parameters Necessary per Association (i.e., the TCB) . . 132 241 14.3. Per Transport Address Data . . . . . . . . . . . . . . . 133 242 14.4. General Parameters Needed . . . . . . . . . . . . . . . 134 243 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 134 244 15.1. IETF-Defined Chunk Extension . . . . . . . . . . . . . . 134 245 15.2. IETF Chunk Flags Registration . . . . . . . . . . . . . 135 246 15.3. IETF-Defined Chunk Parameter Extension . . . . . . . . . 135 247 15.4. IETF-Defined Additional Error Causes . . . . . . . . . . 136 248 15.5. Payload Protocol Identifiers . . . . . . . . . . . . . . 136 249 15.6. Port Numbers Registry . . . . . . . . . . . . . . . . . 137 250 16. Suggested SCTP Protocol Parameter Values . . . . . . . . . . 139 251 17. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 139 252 18. Normative References . . . . . . . . . . . . . . . . . . . . 141 253 19. Informative References . . . . . . . . . . . . . . . . . . . 143 254 Appendix A. CRC32c Checksum Calculation . . . . . . . . . . . . 144 255 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 151 257 1. Conventions 259 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 260 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 261 "OPTIONAL" in this document are to be interpreted as described in BCP 262 14 [RFC2119] [RFC8174] when, and only when, they appear in all 263 capitals, as shown here. 265 2. Introduction 267 This section explains the reasoning behind the development of the 268 Stream Control Transmission Protocol (SCTP), the services it offers, 269 and the basic concepts needed to understand the detailed description 270 of the protocol. 272 This document obsoletes [RFC4960], if approved. 274 2.1. Motivation 276 TCP [RFC0793] has performed immense service as the primary means of 277 reliable data transfer in IP networks. However, an increasing number 278 of recent applications have found TCP too limiting, and have 279 incorporated their own reliable data transfer protocol on top of UDP 280 [RFC0768]. The limitations that users have wished to bypass include 281 the following: 283 * TCP provides both reliable data transfer and strict order-of- 284 transmission delivery of data. Some applications need reliable 285 transfer without sequence maintenance, while others would be 286 satisfied with partial ordering of the data. In both of these 287 cases, the head-of-line blocking offered by TCP causes unnecessary 288 delay. 290 * The stream-oriented nature of TCP is often an inconvenience. 291 Applications add their own record marking to delineate their 292 messages, and make explicit use of the push facility to ensure 293 that a complete message is transferred in a reasonable time. 295 * The limited scope of TCP sockets complicates the task of providing 296 highly-available data transfer capability using multi-homed hosts. 298 * TCP is relatively vulnerable to denial-of-service attacks, such as 299 SYN attacks. 301 Transport of PSTN signaling across the IP network is an application 302 for which all of these limitations of TCP are relevant. While this 303 application directly motivated the development of SCTP, other 304 applications might find SCTP a good match to their requirements. 306 2.2. Architectural View of SCTP 308 SCTP is viewed as a layer between the SCTP user application ("SCTP 309 user" for short) and a connectionless packet network service such as 310 IP. The remainder of this document assumes SCTP runs on top of IP. 311 The basic service offered by SCTP is the reliable transfer of user 312 messages between peer SCTP users. It performs this service within 313 the context of an association between two SCTP endpoints. Section 11 314 of this document sketches the API that exists at the boundary between 315 the SCTP and the SCTP user layers. 317 SCTP is connection-oriented in nature, but the SCTP association is a 318 broader concept than the TCP connection. SCTP provides the means for 319 each SCTP endpoint (Section 2.3) to provide the other endpoint 320 (during association startup) with a list of transport addresses 321 (i.e., multiple IP addresses in combination with an SCTP port) 322 through which that endpoint can be reached and from which it will 323 originate SCTP packets. The association spans transfers over all of 324 the possible source/destination combinations that can be generated 325 from each endpoint's lists. 327 _____________ _____________ 328 | SCTP User | | SCTP User | 329 | Application | | Application | 330 |-------------| |-------------| 331 | SCTP | | SCTP | 332 | Transport | | Transport | 333 | Service | | Service | 334 |-------------| |-------------| 335 | |One or more ---- One or more| | 336 | IP Network |IP address \/ IP address| IP Network | 337 | Service |appearances /\ appearances| Service | 338 |_____________| ---- |_____________| 340 SCTP Node A |<-------- Network transport ------->| SCTP Node B 342 Figure 1: An SCTP Association 344 2.3. Key Terms 346 Some of the language used to describe SCTP has been introduced in the 347 previous sections. This section provides a consolidated list of the 348 key terms and their definitions. 350 Active destination transport address: A transport address on a peer 351 endpoint that a transmitting endpoint considers available for 352 receiving user messages. 354 Bundling: An optional multiplexing operation, whereby more than one 355 user message might be carried in the same SCTP packet. Each user 356 message occupies its own DATA chunk. 358 Chunk: A unit of information within an SCTP packet, consisting of a 359 chunk header and chunk-specific content. 361 Congestion window (cwnd): An SCTP variable that limits outstanding 362 data, in number of bytes, that a sender can send to a particular 363 destination transport address before receiving an acknowledgement. 365 Cumulative TSN Ack Point: The Transmission Sequence Number (TSN) of 366 the last DATA chunk acknowledged via the Cumulative TSN Ack field 367 of a SACK. 369 Flightsize: The amount of bytes of outstanding data to a particular 370 destination transport address at any given time. 372 Idle destination address: An address that has not had user messages 373 sent to it within some length of time, normally the HEARTBEAT 374 interval or greater. 376 Inactive destination transport address: An address that is 377 considered inactive due to errors and unavailable to transport 378 user messages. 380 Message = user message: Data submitted to SCTP by the Upper Layer 381 Protocol (ULP). 383 Message Authentication Code (MAC): An integrity check mechanism 384 based on cryptographic hash functions using a secret key. 385 Typically, message authentication codes are used between two 386 parties that share a secret key in order to validate information 387 transmitted between these parties. In SCTP, it is used by an 388 endpoint to validate the State Cookie information that is returned 389 from the peer in the COOKIE ECHO chunk. The term "MAC" has 390 different meanings in different contexts. SCTP uses this term 391 with the same meaning as in [RFC2104]. 393 Network Byte Order: Most significant byte first, a.k.a., big endian. 395 Ordered Message: A user message that is delivered in order with 396 respect to all previous user messages sent within the stream on 397 which the message was sent. 399 Outstanding data (or "data outstanding" or "data in flight"): The 400 total amount of the DATA chunks associated with outstanding TSNs. 401 A retransmitted DATA chunk is counted once in outstanding data. A 402 DATA chunk that is classified as lost but that has not yet been 403 retransmitted is not in outstanding data. 405 Outstanding TSN (at an SCTP endpoint): A TSN (and the associated 406 DATA chunk) that has been sent by the endpoint but for which it 407 has not yet received an acknowledgement. 409 Path: The route taken by the SCTP packets sent by one SCTP endpoint 410 to a specific destination transport address of its peer SCTP 411 endpoint. Sending to different destination transport addresses 412 does not necessarily guarantee getting separate paths. 414 Primary Path: The primary path is the destination and source address 415 that will be put into a packet outbound to the peer endpoint by 416 default. The definition includes the source address since an 417 implementation MAY wish to specify both destination and source 418 address to better control the return path taken by reply chunks 419 and on which interface the packet is transmitted when the data 420 sender is multi-homed. 422 Receiver Window (rwnd): An SCTP variable a data sender uses to store 423 the most recently calculated receiver window of its peer, in 424 number of bytes. This gives the sender an indication of the space 425 available in the receiver's inbound buffer. 427 SCTP association: A protocol relationship between SCTP endpoints, 428 composed of the two SCTP endpoints and protocol state information 429 including Verification Tags and the currently active set of 430 Transmission Sequence Numbers (TSNs), etc. An association can be 431 uniquely identified by the transport addresses used by the 432 endpoints in the association. Two SCTP endpoints MUST NOT have 433 more than one SCTP association between them at any given time. 435 SCTP endpoint: The logical sender/receiver of SCTP packets. On a 436 multi-homed host, an SCTP endpoint is represented to its peers as 437 a combination of a set of eligible destination transport addresses 438 to which SCTP packets can be sent and a set of eligible source 439 transport addresses from which SCTP packets can be received. All 440 transport addresses used by an SCTP endpoint MUST use the same 441 port number, but can use multiple IP addresses. A transport 442 address used by an SCTP endpoint MUST NOT be used by another SCTP 443 endpoint. In other words, a transport address is unique to an 444 SCTP endpoint. 446 SCTP packet (or packet): The unit of data delivery across the 447 interface between SCTP and the connectionless packet network 448 (e.g., IP). An SCTP packet includes the common SCTP header, 449 possible SCTP control chunks, and user data encapsulated within 450 SCTP DATA chunks. 452 SCTP user application (SCTP user): The logical higher-layer 453 application entity which uses the services of SCTP, also called 454 the Upper-Layer Protocol (ULP). 456 Slow-Start Threshold (ssthresh): An SCTP variable. This is the 457 threshold that the endpoint will use to determine whether to 458 perform slow start or congestion avoidance on a particular 459 destination transport address. Ssthresh is in number of bytes. 461 Stream: A unidirectional logical channel established from one to 462 another associated SCTP endpoint, within which all user messages 463 are delivered in sequence except for those submitted to the 464 unordered delivery service. 466 Note: The relationship between stream numbers in opposite 467 directions is strictly a matter of how the applications use them. 468 It is the responsibility of the SCTP user to create and manage 469 these correlations if they are so desired. 471 Stream Sequence Number: A 16-bit sequence number used internally by 472 SCTP to ensure sequenced delivery of the user messages within a 473 given stream. One Stream Sequence Number is attached to each user 474 message. 476 Tie-Tags: Two 32-bit random numbers that together make a 64-bit 477 nonce. These tags are used within a State Cookie and TCB so that 478 a newly restarting association can be linked to the original 479 association within the endpoint that did not restart and yet not 480 reveal the true Verification Tags of an existing association. 482 Transmission Control Block (TCB): An internal data structure created 483 by an SCTP endpoint for each of its existing SCTP associations to 484 other SCTP endpoints. TCB contains all the status and operational 485 information for the endpoint to maintain and manage the 486 corresponding association. 488 Transmission Sequence Number (TSN): A 32-bit sequence number used 489 internally by SCTP. One TSN is attached to each chunk containing 490 user data to permit the receiving SCTP endpoint to acknowledge its 491 receipt and detect duplicate deliveries. 493 Transport address: A transport address is traditionally defined by a 494 network-layer address, a transport-layer protocol, and a 495 transport-layer port number. In the case of SCTP running over IP, 496 a transport address is defined by the combination of an IP address 497 and an SCTP port number (where SCTP is the transport protocol). 499 Unacknowledged TSN (at an SCTP endpoint): A TSN (and the associated 500 DATA chunk) that has been received by the endpoint but for which 501 an acknowledgement has not yet been sent. Or in the opposite 502 case, for a packet that has been sent but no acknowledgement has 503 been received. 505 Unordered Message: Unordered messages are "unordered" with respect 506 to any other message; this includes both other unordered messages 507 as well as other ordered messages. An unordered message might be 508 delivered prior to or later than ordered messages sent on the same 509 stream. 511 User message: The unit of data delivery across the interface between 512 SCTP and its user. 514 Verification Tag: A 32-bit unsigned integer that is randomly 515 generated. The Verification Tag provides a key that allows a 516 receiver to verify that the SCTP packet belongs to the current 517 association and is not an old or stale packet from a previous 518 association. 520 2.4. Abbreviations 522 MAC Message Authentication Code [RFC2104] 523 RTO Retransmission Timeout 524 RTT Round-Trip Time 525 RTTVAR Round-Trip Time Variation 526 SCTP Stream Control Transmission Protocol 527 SRTT Smoothed RTT 528 TCB Transmission Control Block 529 TLV Type-Length-Value coding format 530 TSN Transmission Sequence Number 531 ULP Upper-Layer Protocol 533 2.5. Functional View of SCTP 535 The SCTP transport service can be decomposed into a number of 536 functions. These are depicted in Figure 2 and explained in the 537 remainder of this section. 539 SCTP User Application 541 ----------------------------------------------------- 542 _____________ ____________________ 543 | | | Sequenced Delivery | 544 | Association | | within Streams | 545 | | |____________________| 546 | Startup | 547 | | ____________________________ 548 | and | | User Data Fragmentation | 549 | | |____________________________| 550 | Takedown | 551 | | ____________________________ 552 | | | Acknowledgement | 553 | | | and | 554 | | | Congestion Avoidance | 555 | | |____________________________| 556 | | 557 | | ____________________________ 558 | | | Chunk Bundling | 559 | | |____________________________| 560 | | 561 | | ________________________________ 562 | | | Packet Validation | 563 | | |________________________________| 564 | | 565 | | ________________________________ 566 | | | Path Management | 567 |_____________| |________________________________| 569 Figure 2: Functional View of the SCTP Transport Service 571 2.5.1. Association Startup and Takedown 573 An association is initiated by a request from the SCTP user (see the 574 description of the ASSOCIATE (or SEND) primitive in Section 11). 576 A cookie mechanism, similar to one described by Karn and Simpson in 577 [RFC2522], is employed during the initialization to provide 578 protection against synchronization attacks. The cookie mechanism 579 uses a four-way handshake, the last two legs of which are allowed to 580 carry user data for fast setup. The startup sequence is described in 581 Section 5 of this document. 583 SCTP provides for graceful close (i.e., shutdown) of an active 584 association on request from the SCTP user. See the description of 585 the SHUTDOWN primitive in Section 11. SCTP also allows ungraceful 586 close (i.e., abort), either on request from the user (ABORT 587 primitive) or as a result of an error condition detected within the 588 SCTP layer. Section 9 describes both the graceful and the ungraceful 589 close procedures. 591 SCTP does not support a half-open state (like TCP) wherein one side 592 continues sending data while the other end is closed. When either 593 endpoint performs a shutdown, the association on each peer will stop 594 accepting new data from its user and only deliver data in queue at 595 the time of the graceful close (see Section 9). 597 2.5.2. Sequenced Delivery within Streams 599 The term "stream" is used in SCTP to refer to a sequence of user 600 messages that are to be delivered to the upper-layer protocol in 601 order with respect to other messages within the same stream. This is 602 in contrast to its usage in TCP, where it refers to a sequence of 603 bytes (in this document, a byte is assumed to be 8 bits). 605 The SCTP user can specify at association startup time the number of 606 streams to be supported by the association. This number is 607 negotiated with the remote end (see Section 5.1.1). User messages 608 are associated with stream numbers (SEND, RECEIVE primitives, 609 Section 11). Internally, SCTP assigns a Stream Sequence Number to 610 each message passed to it by the SCTP user. On the receiving side, 611 SCTP ensures that messages are delivered to the SCTP user in sequence 612 within a given stream. However, while one stream might be blocked 613 waiting for the next in-sequence user message, delivery from other 614 streams might proceed. 616 SCTP provides a mechanism for bypassing the sequenced delivery 617 service. User messages sent using this mechanism are delivered to 618 the SCTP user as soon as they are received. 620 2.5.3. User Data Fragmentation 622 When needed, SCTP fragments user messages to ensure that the SCTP 623 packet passed to the lower layer conforms to the path MTU. On 624 receipt, fragments are reassembled into complete messages before 625 being passed to the SCTP user. 627 2.5.4. Acknowledgement and Congestion Avoidance 629 SCTP assigns a Transmission Sequence Number (TSN) to each user data 630 fragment or unfragmented message. The TSN is independent of any 631 Stream Sequence Number assigned at the stream level. The receiving 632 end acknowledges all TSNs received, even if there are gaps in the 633 sequence. In this way, reliable delivery is kept functionally 634 separate from sequenced stream delivery. 636 The acknowledgement and congestion avoidance function is responsible 637 for packet retransmission when timely acknowledgement has not been 638 received. Packet retransmission is conditioned by congestion 639 avoidance procedures similar to those used for TCP. See Section 6 640 and Section 7 for a detailed description of the protocol procedures 641 associated with this function. 643 2.5.5. Chunk Bundling 645 As described in Section 3, the SCTP packet as delivered to the lower 646 layer consists of a common header followed by one or more chunks. 647 Each chunk might contain either user data or SCTP control 648 information. The SCTP user has the option to request bundling of 649 more than one user message into a single SCTP packet. The chunk 650 bundling function of SCTP is responsible for assembly of the complete 651 SCTP packet and its disassembly at the receiving end. 653 During times of congestion, an SCTP implementation MAY still perform 654 bundling even if the user has requested that SCTP not bundle. The 655 user's disabling of bundling only affects SCTP implementations that 656 might delay a small period of time before transmission (to attempt to 657 encourage bundling). When the user layer disables bundling, this 658 small delay is prohibited but not bundling that is performed during 659 congestion or retransmission. 661 2.5.6. Packet Validation 663 A mandatory Verification Tag field and a 32-bit checksum field (see 664 Appendix A for a description of the CRC32c checksum) are included in 665 the SCTP common header. The Verification Tag value is chosen by each 666 end of the association during association startup. Packets received 667 without the expected Verification Tag value are discarded, as a 668 protection against blind masquerade attacks and against stale SCTP 669 packets from a previous association. The CRC32c checksum can be set 670 by the sender of each SCTP packet to provide additional protection 671 against data corruption in the network. The receiver of an SCTP 672 packet with an invalid CRC32c checksum silently discards the packet. 674 2.5.7. Path Management 676 The sending SCTP user is able to manipulate the set of transport 677 addresses used as destinations for SCTP packets through the 678 primitives described in Section 11. The SCTP path management 679 function chooses the destination transport address for each outgoing 680 SCTP packet based on the SCTP user's instructions and the currently 681 perceived reachability status of the eligible destination set. The 682 path management function monitors reachability through heartbeats 683 when other packet traffic is inadequate to provide this information 684 and advises the SCTP user when reachability of any far-end transport 685 address changes. The path management function is also responsible 686 for reporting the eligible set of local transport addresses to the 687 far end during association startup, and for reporting the transport 688 addresses returned from the far end to the SCTP user. 690 At association startup, a primary path is defined for each SCTP 691 endpoint, and is used for normal sending of SCTP packets. 693 On the receiving end, the path management is responsible for 694 verifying the existence of a valid SCTP association to which the 695 inbound SCTP packet belongs before passing it for further processing. 697 Note: Path Management and Packet Validation are done at the same 698 time, so although described separately above, in reality they cannot 699 be performed as separate items. 701 2.6. Serial Number Arithmetic 703 It is essential to remember that the actual Transmission Sequence 704 Number space is finite, though very large. This space ranges from 0 705 to 2**32 - 1. Since the space is finite, all arithmetic dealing with 706 Transmission Sequence Numbers MUST be performed modulo 2**32. This 707 unsigned arithmetic preserves the relationship of sequence numbers as 708 they cycle from 2**32 - 1 to 0 again. There are some subtleties to 709 computer modulo arithmetic, so great care has to be taken in 710 programming the comparison of such values. When referring to TSNs, 711 the symbol "=<" means "less than or equal"(modulo 2**32). 713 Comparisons and arithmetic on TSNs in this document SHOULD use Serial 714 Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 32. 716 An endpoint SHOULD NOT transmit a DATA chunk with a TSN that is more 717 than 2**31 - 1 above the beginning TSN of its current send window. 718 Doing so will cause problems in comparing TSNs. 720 Transmission Sequence Numbers wrap around when they reach 2**32 - 1. 721 That is, the next TSN a DATA chunk MUST use after transmitting TSN = 722 2**32 - 1 is TSN = 0. 724 Any arithmetic done on Stream Sequence Numbers SHOULD use Serial 725 Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 16. 726 All other arithmetic and comparisons in this document use normal 727 arithmetic. 729 2.7. Changes from RFC 4960 731 SCTP was originally defined in [RFC4960], which this document 732 obsoletes, if approved. Readers interested in the details of the 733 various changes that this document incorporates are asked to consult 734 [RFC8540]. 736 3. SCTP Packet Format 738 An SCTP packet is composed of a common header and chunks. A chunk 739 contains either control information or user data. 741 The SCTP packet format is shown below: 743 0 1 2 3 744 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 745 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 746 | Common Header | 747 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 748 | Chunk #1 | 749 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 750 | ... | 751 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 752 | Chunk #n | 753 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 755 Multiple chunks can be bundled into one SCTP packet up to the MTU 756 size, except for the INIT, INIT ACK, and SHUTDOWN COMPLETE chunks. 757 These chunks MUST NOT be bundled with any other chunk in a packet. 758 See Section 6.10 for more details on chunk bundling. 760 If a user data message does not fit into one SCTP packet it can be 761 fragmented into multiple chunks using the procedure defined in 762 Section 6.9. 764 All integer fields in an SCTP packet MUST be transmitted in network 765 byte order, unless otherwise stated. 767 3.1. SCTP Common Header Field Descriptions 769 0 1 2 3 770 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 771 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 772 | Source Port Number | Destination Port Number | 773 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 774 | Verification Tag | 775 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 776 | Checksum | 777 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 779 Source Port Number: 16 bits (unsigned integer) 780 This is the SCTP sender's port number. It can be used by the 781 receiver in combination with the source IP address, the SCTP 782 destination port, and possibly the destination IP address to 783 identify the association to which this packet belongs. The source 784 port number 0 MUST NOT be used. 786 Destination Port Number: 16 bits (unsigned integer) 787 This is the SCTP port number to which this packet is destined. 788 The receiving host will use this port number to de-multiplex the 789 SCTP packet to the correct receiving endpoint/application. The 790 destination port number 0 MUST NOT be used. 792 Verification Tag: 32 bits (unsigned integer) 793 The receiver of this packet uses the Verification Tag to validate 794 the sender of this SCTP packet. On transmit, the value of this 795 Verification Tag MUST be set to the value of the Initiate Tag 796 received from the peer endpoint during the association 797 initialization, with the following exceptions: 799 * A packet containing an INIT chunk MUST have a zero Verification 800 Tag. 802 * A packet containing a SHUTDOWN COMPLETE chunk with the T bit 803 set MUST have the Verification Tag copied from the packet with 804 the SHUTDOWN ACK chunk. 806 * A packet containing an ABORT chunk MAY have the verification 807 tag copied from the packet that caused the ABORT to be sent. 808 For details see Section 8.4 and Section 8.5. 810 Checksum: 32 bits (unsigned integer) 811 This field contains the checksum of this SCTP packet. Its 812 calculation is discussed in Section 6.8. SCTP uses the CRC32c 813 algorithm as described in Appendix A for calculating the checksum. 815 3.2. Chunk Field Descriptions 817 The figure below illustrates the field format for the chunks to be 818 transmitted in the SCTP packet. Each chunk is formatted with a Chunk 819 Type field, a chunk-specific Flag field, a Chunk Length field, and a 820 Value field. 822 0 1 2 3 823 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 824 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 825 | Chunk Type | Chunk Flags | Chunk Length | 826 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 827 \ \ 828 / Chunk Value / 829 \ \ 830 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 832 Chunk Type: 8 bits (unsigned integer) 833 This field identifies the type of information contained in the 834 Chunk Value field. It takes a value from 0 to 254. The value of 835 255 is reserved for future use as an extension field. 837 The values of Chunk Types are defined as follows: 839 +==========+===========================================+ 840 | ID Value | Chunk Type | 841 +==========+===========================================+ 842 | 0 | Payload Data (DATA) | 843 +----------+-------------------------------------------+ 844 | 1 | Initiation (INIT) | 845 +----------+-------------------------------------------+ 846 | 2 | Initiation Acknowledgement (INIT ACK) | 847 +----------+-------------------------------------------+ 848 | 3 | Selective Acknowledgement (SACK) | 849 +----------+-------------------------------------------+ 850 | 4 | Heartbeat Request (HEARTBEAT) | 851 +----------+-------------------------------------------+ 852 | 5 | Heartbeat Acknowledgement (HEARTBEAT ACK) | 853 +----------+-------------------------------------------+ 854 | 6 | Abort (ABORT) | 855 +----------+-------------------------------------------+ 856 | 7 | Shutdown (SHUTDOWN) | 857 +----------+-------------------------------------------+ 858 | 8 | Shutdown Acknowledgement (SHUTDOWN ACK) | 859 +----------+-------------------------------------------+ 860 | 9 | Operation Error (ERROR) | 861 +----------+-------------------------------------------+ 862 | 10 | State Cookie (COOKIE ECHO) | 863 +----------+-------------------------------------------+ 864 | 11 | Cookie Acknowledgement (COOKIE ACK) | 865 +----------+-------------------------------------------+ 866 | 12 | Reserved for Explicit Congestion | 867 | | Notification Echo (ECNE) | 868 +----------+-------------------------------------------+ 869 | 13 | Reserved for Congestion Window Reduced | 870 | | (CWR) | 871 +----------+-------------------------------------------+ 872 | 14 | Shutdown Complete (SHUTDOWN COMPLETE) | 873 +----------+-------------------------------------------+ 874 | 15 to 62 | available | 875 +----------+-------------------------------------------+ 876 | 63 | reserved for IETF-defined Chunk | 877 | | Extensions | 878 +----------+-------------------------------------------+ 879 | 64 to | available | 880 | 126 | | 881 +----------+-------------------------------------------+ 882 | 127 | reserved for IETF-defined Chunk | 883 | | Extensions | 884 +----------+-------------------------------------------+ 885 | 128 to | available | 886 | 190 | | 887 +----------+-------------------------------------------+ 888 | 191 | reserved for IETF-defined Chunk | 889 | | Extensions | 890 +----------+-------------------------------------------+ 891 | 192 to | available | 892 | 254 | | 893 +----------+-------------------------------------------+ 894 | 255 | reserved for IETF-defined Chunk | 895 | | Extensions | 896 +----------+-------------------------------------------+ 897 Table 1: Chunk Types 899 Chunk Types are encoded such that the highest-order 2 bits specify 900 the action that is taken if the processing endpoint does not 901 recognize the Chunk Type. 903 +----+---------------------------------------------------------+ 904 | 00 | Stop processing this SCTP packet; discard the | 905 | | unrecognized chunk and all further chunks. | 906 +----+---------------------------------------------------------+ 907 | 01 | Stop processing this SCTP packet, discard the | 908 | | unrecognized chunk and all further chunks, and report | 909 | | the unrecognized chunk in an 'Unrecognized Chunk Type'. | 910 +----+---------------------------------------------------------+ 911 | 10 | Skip this chunk and continue processing. | 912 +----+---------------------------------------------------------+ 913 | 11 | Skip this chunk and continue processing, but report in | 914 | | an ERROR chunk using the 'Unrecognized Chunk Type' | 915 | | cause of error. | 916 +----+---------------------------------------------------------+ 918 Table 2: Processing of Unknown Chunks 920 Note: The ECNE and CWR chunk types are reserved for future use of 921 Explicit Congestion Notification (ECN). 923 Chunk Flags: 8 bits 924 The usage of these bits depends on the Chunk type as given by the 925 Chunk Type field. Unless otherwise specified, they are set to 0 926 on transmit and are ignored on receipt. 928 Chunk Length: 16 bits (unsigned integer) 929 This value represents the size of the chunk in bytes, including 930 the Chunk Type, Chunk Flags, Chunk Length, and Chunk Value fields. 931 Therefore, if the Chunk Value field is zero-length, the Length 932 field will be set to 4. The Chunk Length field does not count any 933 chunk padding. 935 Chunks (including Type, Length, and Value fields) are padded out 936 by the sender with all zero bytes to be a multiple of 4 bytes 937 long. This padding MUST NOT be more than 3 bytes in total. The 938 Chunk Length value does not include terminating padding of the 939 chunk. However, it does include padding of any variable-length 940 parameter except the last parameter in the chunk. The receiver 941 MUST ignore the padding. 943 Note: A robust implementation is expected to accept the chunk 944 whether or not the final padding has been included in the Chunk 945 Length. 947 Chunk Value: variable length 948 The Chunk Value field contains the actual information to be 949 transferred in the chunk. The usage and format of this field is 950 dependent on the Chunk Type. 952 The total length of a chunk (including Type, Length, and Value 953 fields) MUST be a multiple of 4 bytes. If the length of the chunk is 954 not a multiple of 4 bytes, the sender MUST pad the chunk with all 955 zero bytes, and this padding is not included in the Chunk Length 956 field. The sender MUST NOT pad with more than 3 bytes. The receiver 957 MUST ignore the padding bytes. 959 SCTP-defined chunks are described in detail in Section 3.3. The 960 guidelines for IETF-defined chunk extensions can be found in 961 Section 15.1 of this document. 963 3.2.1. Optional/Variable-Length Parameter Format 965 Chunk values of SCTP control chunks consist of a chunk-type-specific 966 header of required fields, followed by zero or more parameters. The 967 optional and variable-length parameters contained in a chunk are 968 defined in a Type-Length-Value format as shown below. 970 0 1 2 3 971 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 972 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 973 | Parameter Type | Parameter Length | 974 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 975 \ \ 976 / Parameter Value / 977 \ \ 978 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 980 Chunk Parameter Type: 16 bits (unsigned integer) 981 The Type field is a 16-bit identifier of the type of parameter. 982 It takes a value of 0 to 65534. 984 The value of 65535 is reserved for IETF-defined extensions. 985 Values other than those defined in specific SCTP chunk 986 descriptions are reserved for use by IETF. 988 Chunk Parameter Length: 16 bits (unsigned integer) 989 The Parameter Length field contains the size of the parameter in 990 bytes, including the Parameter Type, Parameter Length, and 991 Parameter Value fields. Thus, a parameter with a zero-length 992 Parameter Value field would have a Parameter Length field of 4. 993 The Parameter Length does not include any padding bytes. 995 Chunk Parameter Value: variable length 996 The Parameter Value field contains the actual information to be 997 transferred in the parameter. 999 The total length of a parameter (including Type, Parameter Length, 1000 and Value fields) MUST be a multiple of 4 bytes. If the length of 1001 the parameter is not a multiple of 4 bytes, the sender pads the 1002 parameter at the end (i.e., after the Parameter Value field) with all 1003 zero bytes. The length of the padding is not included in the 1004 Parameter Length field. A sender MUST NOT pad with more than 3 1005 bytes. The receiver MUST ignore the padding bytes. 1007 The Parameter Types are encoded such that the highest-order 2 bits 1008 specify the action that is taken if the processing endpoint does not 1009 recognize the Parameter Type. 1011 +----+----------------------------------------------------+ 1012 | 00 | Stop processing this parameter; do not process any | 1013 | | further parameters within this chunk. | 1014 +----+----------------------------------------------------+ 1015 | 01 | Stop processing this parameter, do not process any | 1016 | | further parameters within this chunk, and report | 1017 | | the unrecognized parameter in an 'Unrecognized | 1018 | | Parameter', as described in Section 3.2.2. | 1019 +----+----------------------------------------------------+ 1020 | 10 | Skip this parameter and continue processing. | 1021 +----+----------------------------------------------------+ 1022 | 11 | Skip this parameter and continue processing but | 1023 | | report the unrecognized parameter in an | 1024 | | 'Unrecognized Parameter', as described in | 1025 | | Section 3.2.2. | 1026 +----+----------------------------------------------------+ 1028 Table 3: Processing of Unknown Parameters 1030 Please note that in all four cases, an INIT ACK or COOKIE ECHO chunk 1031 is sent. In the 00 or 01 case, the processing of the parameters 1032 after the unknown parameter is canceled, but no processing already 1033 done is rolled back. 1035 The actual SCTP parameters are defined in the specific SCTP chunk 1036 sections. The rules for IETF-defined parameter extensions are 1037 defined in Section 15.3. Parameter types MUST be unique across all 1038 chunks. For example, the parameter type '5' is used to represent an 1039 IPv4 address (see Section 3.3.2.1). The value '5' then is reserved 1040 across all chunks to represent an IPv4 address and MUST NOT be reused 1041 with a different meaning in any other chunk. 1043 3.2.2. Reporting of Unrecognized Parameters 1045 If the receiver of an INIT chunk detects unrecognized parameters and 1046 has to report them according to Section 3.2.1, it MUST put the 1047 'Unrecognized Parameter' parameter(s) in the INIT ACK chunk sent in 1048 response to the INIT chunk. Note that if the receiver of the INIT 1049 chunk is not going to establish an association (e.g., due to lack of 1050 resources), an 'Unrecognized Parameter' would not be included with 1051 any ABORT being sent to the sender of the INIT. 1053 If the receiver of an INIT ACK chunk detects unrecognized parameters 1054 and has to report them according to Section 3.2.1, it SHOULD bundle 1055 the ERROR chunk containing the 'Unrecognized Parameters' error cause 1056 with the COOKIE ECHO chunk sent in response to the INIT ACK chunk. 1057 If the receiver of the INIT ACK cannot bundle the COOKIE ECHO chunk 1058 with the ERROR chunk, the ERROR chunk MAY be sent separately but not 1059 before the COOKIE ACK has been received. 1061 Any time a COOKIE ECHO is sent in a packet, it MUST be the first 1062 chunk. 1064 3.3. SCTP Chunk Definitions 1066 This section defines the format of the different SCTP chunk types. 1068 3.3.1. Payload Data (DATA) (0) 1070 The following format MUST be used for the DATA chunk: 1072 0 1 2 3 1073 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1074 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1075 | Type = 0 | Res |I|U|B|E| Length | 1076 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1077 | TSN | 1078 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1079 | Stream Identifier S | Stream Sequence Number n | 1080 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1081 | Payload Protocol Identifier | 1082 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1083 \ \ 1084 / User Data (seq n of Stream S) / 1085 \ \ 1086 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1088 Res: 4 bits 1089 Set to all '0's on transmit and ignored on receipt. 1091 I bit: 1 bit 1092 The (I)mmediate bit MAY be set by the sender whenever the sender 1093 of a DATA chunk can benefit from the corresponding SACK chunk 1094 being sent back without delay. See Section 4 of [RFC7053] for a 1095 discussion of the benefits. 1097 U bit: 1 bit 1098 The (U)nordered bit, if set to '1', indicates that this is an 1099 unordered DATA chunk, and there is no Stream Sequence Number 1100 assigned to this DATA chunk. Therefore, the receiver MUST ignore 1101 the Stream Sequence Number field. 1103 After reassembly (if necessary), unordered DATA chunks MUST be 1104 dispatched to the upper layer by the receiver without any attempt 1105 to reorder. 1107 If an unordered user message is fragmented, each fragment of the 1108 message MUST have its U bit set to '1'. 1110 B bit: 1 bit 1111 The (B)eginning fragment bit, if set, indicates the first fragment 1112 of a user message. 1114 E bit: 1 bit 1115 The (E)nding fragment bit, if set, indicates the last fragment of 1116 a user message. 1118 An unfragmented user message MUST have both the B and E bits set to 1119 '1'. Setting both B and E bits to '0' indicates a middle fragment of 1120 a multi-fragment user message, as summarized in the following table: 1122 +---+---+-------------------------------------------+ 1123 | B | E | Description | 1124 +---+---+-------------------------------------------+ 1125 | 1 | 0 | First piece of a fragmented user message | 1126 +---+---+-------------------------------------------+ 1127 | 0 | 0 | Middle piece of a fragmented user message | 1128 +---+---+-------------------------------------------+ 1129 | 0 | 1 | Last piece of a fragmented user message | 1130 +---+---+-------------------------------------------+ 1131 | 1 | 1 | Unfragmented message | 1132 +---+---+-------------------------------------------+ 1134 Table 4: Fragment Description Flags 1136 When a user message is fragmented into multiple chunks, the TSNs are 1137 used by the receiver to reassemble the message. This means that the 1138 TSNs for each fragment of a fragmented user message MUST be strictly 1139 sequential. 1141 Length: 16 bits (unsigned integer) 1142 This field indicates the length of the DATA chunk in bytes from 1143 the beginning of the type field to the end of the User Data field 1144 excluding any padding. A DATA chunk with one byte of user data 1145 will have Length set to 17 (indicating 17 bytes). 1147 A DATA chunk with a User Data field of length L will have the 1148 Length field set to (16 + L) (indicating 16+L bytes) where L MUST 1149 be greater than 0. 1151 TSN: 32 bits (unsigned integer) 1152 This value represents the TSN for this DATA chunk. The valid 1153 range of TSN is from 0 to 4294967295 (2**32 - 1). TSN wraps back 1154 to 0 after reaching 4294967295. 1156 Stream Identifier S: 16 bits (unsigned integer) 1157 Identifies the stream to which the following user data belongs. 1159 Stream Sequence Number n: 16 bits (unsigned integer) 1160 This value represents the Stream Sequence Number of the following 1161 user data within the stream S. Valid range is 0 to 65535. 1163 When a user message is fragmented by SCTP for transport, the same 1164 Stream Sequence Number MUST be carried in each of the fragments of 1165 the message. 1167 Payload Protocol Identifier: 32 bits (unsigned integer) 1168 This value represents an application (or upper layer) specified 1169 protocol identifier. This value is passed to SCTP by its upper 1170 layer and sent to its peer. This identifier is not used by SCTP 1171 but can be used by certain network entities, as well as by the 1172 peer application, to identify the type of information being 1173 carried in this DATA chunk. This field MUST be sent even in 1174 fragmented DATA chunks (to make sure it is available for agents in 1175 the middle of the network). Note that this field is not touched 1176 by an SCTP implementation; therefore, its byte order is not 1177 necessarily big endian. The upper layer is responsible for any 1178 byte order conversions to this field. 1180 The value 0 indicates that no application identifier is specified 1181 by the upper layer for this payload data. 1183 User Data: variable length 1184 This is the payload user data. The implementation MUST pad the 1185 end of the data to a 4-byte boundary with all-zero bytes. Any 1186 padding MUST NOT be included in the Length field. A sender MUST 1187 never add more than 3 bytes of padding. 1189 3.3.2. Initiation (INIT) (1) 1191 This chunk is used to initiate an SCTP association between two 1192 endpoints. The format of the INIT chunk is shown below: 1194 0 1 2 3 1195 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1196 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1197 | Type = 1 | Chunk Flags | Chunk Length | 1198 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1199 | Initiate Tag | 1200 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1201 | Advertised Receiver Window Credit (a_rwnd) | 1202 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1203 | Number of Outbound Streams | Number of Inbound Streams | 1204 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1205 | Initial TSN | 1206 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1207 \ \ 1208 / Optional/Variable-Length Parameters / 1209 \ \ 1210 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1212 The INIT chunk contains the following parameters. Unless otherwise 1213 noted, each parameter MUST only be included once in the INIT chunk. 1215 +-----------------------------------+-----------+ 1216 | Fixed Parameters | Status | 1217 +-----------------------------------+-----------+ 1218 | Initiate Tag | Mandatory | 1219 +-----------------------------------+-----------+ 1220 | Advertised Receiver Window Credit | Mandatory | 1221 +-----------------------------------+-----------+ 1222 | Number of Outbound Streams | Mandatory | 1223 +-----------------------------------+-----------+ 1224 | Number of Inbound Streams | Mandatory | 1225 +-----------------------------------+-----------+ 1226 | Initial TSN | Mandatory | 1227 +-----------------------------------+-----------+ 1229 Table 5: Fixed Length Parameters of INIT Chunks 1231 +-----------------------------------+----------+----------------+ 1232 | Variable Parameters | Status | Type Value | 1233 +-----------------------------------+----------+----------------+ 1234 | IPv4 Address (Note 1) | Optional | 5 | 1235 +-----------------------------------+----------+----------------+ 1236 | IPv6 Address (Note 1) | Optional | 6 | 1237 +-----------------------------------+----------+----------------+ 1238 | Cookie Preservative | Optional | 9 | 1239 +-----------------------------------+----------+----------------+ 1240 | Reserved for ECN Capable (Note 2) | Optional | 32768 (0x8000) | 1241 +-----------------------------------+----------+----------------+ 1242 | Host Name Address | Optional | 11 | 1243 +-----------------------------------+----------+----------------+ 1244 | Supported Address Types (Note 3) | Optional | 12 | 1245 +-----------------------------------+----------+----------------+ 1247 Table 6: Variable Length Parameters of INIT Chunks 1249 An INIT chunk MUST NOT contain the Host Name Address parameter. The 1250 receiver of an INIT chunk containing a Host Name Address parameter 1251 MUST send an ABORT and MAY include an "Unresolvable Address" error 1252 cause. 1254 Note 1: The INIT chunks can contain multiple addresses that can be 1255 IPv4 and/or IPv6 in any combination. 1257 Note 2: The ECN Capable field is reserved for future use of Explicit 1258 Congestion Notification. 1260 Note 3: This parameter, when present, specifies all the address types 1261 the sending endpoint can support. The absence of this parameter 1262 indicates that the sending endpoint can support any address type. 1264 If an INIT chunk is received with known parameters that are not 1265 optional parameters of the INIT chunk, then the receiver SHOULD 1266 process the INIT chunk and send back an INIT ACK. The receiver of 1267 the INIT chunk MAY bundle an ERROR chunk with the COOKIE ACK chunk 1268 later. However, restrictive implementations MAY send back an ABORT 1269 chunk in response to the INIT chunk. 1271 The Chunk Flags field in INIT is reserved, and all bits in it SHOULD 1272 be set to 0 by the sender and ignored by the receiver. The sequence 1273 of parameters within an INIT can be processed in any order. 1275 Initiate Tag: 32 bits (unsigned integer) 1276 The receiver of the INIT (the responding end) records the value of 1277 the Initiate Tag parameter. This value MUST be placed into the 1278 Verification Tag field of every SCTP packet that the receiver of 1279 the INIT transmits within this association. 1281 The Initiate Tag is allowed to have any value except 0. See 1282 Section 5.3.1 for more on the selection of the tag value. 1284 If the value of the Initiate Tag in a received INIT chunk is found 1285 to be 0, the receiver MUST treat it as an error and close the 1286 association by transmitting an ABORT. 1288 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1289 integer) 1290 This value represents the dedicated buffer space, in number of 1291 bytes, the sender of the INIT has reserved in association with 1292 this window. During the life of the association, this buffer 1293 space SHOULD NOT be lessened (i.e., dedicated buffers taken away 1294 from this association); however, an endpoint MAY change the value 1295 of a_rwnd it sends in SACK chunks. 1297 Number of Outbound Streams (OS): 16 bits (unsigned integer) 1298 Defines the number of outbound streams the sender of this INIT 1299 chunk wishes to create in this association. The value of 0 MUST 1300 NOT be used. 1302 A receiver of an INIT with the OS value set to 0 SHOULD abort the 1303 association. 1305 Number of Inbound Streams (MIS): 16 bits (unsigned integer) 1306 Defines the maximum number of streams the sender of this INIT 1307 chunk allows the peer end to create in this association. The 1308 value 0 MUST NOT be used. 1310 Note: There is no negotiation of the actual number of streams but 1311 instead the two endpoints will use the min(requested, offered). 1312 See Section 5.1.1 for details. 1314 A receiver of an INIT with the MIS value of 0 SHOULD abort the 1315 association. 1317 Initial TSN (I-TSN): 32 bits (unsigned integer) 1318 Defines the initial TSN that the sender will use. The valid range 1319 is from 0 to 4294967295. This field MAY be set to the value of 1320 the Initiate Tag field. 1322 3.3.2.1. Optional/Variable-Length Parameters in INIT 1324 The following parameters follow the Type-Length-Value format as 1325 defined in Section 3.2.1. Any Type-Length-Value fields MUST come 1326 after the fixed-length fields defined in the previous section. 1328 3.3.2.1.1. IPv4 Address Parameter (5) 1330 0 1 2 3 1331 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1332 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1333 | Type = 5 | Length = 8 | 1334 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1335 | IPv4 Address | 1336 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1338 IPv4 Address: 32 bits (unsigned integer) 1339 Contains an IPv4 address of the sending endpoint. It is binary 1340 encoded. 1342 3.3.2.1.2. IPv6 Address Parameter (6) 1344 0 1 2 3 1345 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1346 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1347 | Type = 6 | Length = 20 | 1348 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1349 | | 1350 | IPv6 Address | 1351 | | 1352 | | 1353 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1355 IPv6 Address: 128 bits (unsigned integer) 1356 Contains an IPv6 [RFC8200] address of the sending endpoint. It is 1357 binary encoded. 1359 A sender MUST NOT use an IPv4-mapped IPv6 address [RFC4291], but 1360 SHOULD instead use an IPv4 Address parameter for an IPv4 address. 1362 Combined with the Source Port Number in the SCTP common header, the 1363 value passed in an IPv4 or IPv6 Address parameter indicates a 1364 transport address the sender of the INIT will support for the 1365 association being initiated. That is, during the life time of this 1366 association, this IP address can appear in the source address field 1367 of an IP datagram sent from the sender of the INIT, and can be used 1368 as a destination address of an IP datagram sent from the receiver of 1369 the INIT. 1371 More than one IP Address parameter can be included in an INIT chunk 1372 when the INIT sender is multi-homed. Moreover, a multi-homed 1373 endpoint might have access to different types of network; thus, more 1374 than one address type can be present in one INIT chunk, i.e., IPv4 1375 and IPv6 addresses are allowed in the same INIT chunk. 1377 If the INIT contains at least one IP Address parameter, then the 1378 source address of the IP datagram containing the INIT chunk and any 1379 additional address(es) provided within the INIT can be used as 1380 destinations by the endpoint receiving the INIT. If the INIT does 1381 not contain any IP Address parameters, the endpoint receiving the 1382 INIT MUST use the source address associated with the received IP 1383 datagram as its sole destination address for the association. 1385 Note that not using any IP Address parameters in the INIT and INIT 1386 ACK is an alternative to make an association more likely to work 1387 across a NAT box. 1389 3.3.2.1.3. Cookie Preservative (9) 1391 The sender of the INIT SHOULD use this parameter to suggest to the 1392 receiver of the INIT for a longer life-span of the State Cookie. 1394 0 1 2 3 1395 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1396 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1397 | Type = 9 | Length = 8 | 1398 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1399 | Suggested Cookie Life-Span Increment (msec.) | 1400 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1402 Suggested Cookie Life-Span Increment: 32 bits (unsigned integer) 1403 This parameter indicates to the receiver how much increment in 1404 milliseconds the sender wishes the receiver to add to its default 1405 cookie life-span. 1407 This optional parameter MAY be added to the INIT chunk by the 1408 sender when it reattempts establishing an association with a peer 1409 to which its previous attempt of establishing the association 1410 failed due to a stale cookie operation error. The receiver MAY 1411 choose to ignore the suggested cookie life-span increase for its 1412 own security reasons. 1414 3.3.2.1.4. Host Name Address (11) 1416 The sender of an INIT chunk MUST NOT include this parameter. The 1417 usage of the Host Name Address parameter is deprecated. 1419 0 1 2 3 1420 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1421 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1422 | Type = 11 | Length | 1423 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1424 / Host Name / 1425 \ \ 1426 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1428 Host Name: variable length 1429 This field contains a host name in "host name syntax" per RFC 1123 1430 Section 2.1 [RFC1123]. The method for resolving the host name is 1431 out of scope of SCTP. 1433 At least one null terminator is included in the Host Name string 1434 and MUST be included in the length. 1436 3.3.2.1.5. Supported Address Types (12) 1438 The sender of INIT uses this parameter to list all the address types 1439 it can support. 1441 0 1 2 3 1442 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1443 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1444 | Type = 12 | Length | 1445 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1446 | Address Type #1 | Address Type #2 | 1447 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1448 | ...... | 1449 +-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+ 1451 Address Type: 16 bits (unsigned integer) 1452 This is filled with the type value of the corresponding address 1453 TLV (e.g., IPv4 = 5, IPv6 = 6). The value indicating the Host 1454 Name Address parameter (Host name = 11) MUST NOT be used. 1456 3.3.3. Initiation Acknowledgement (INIT ACK) (2) 1458 The INIT ACK chunk is used to acknowledge the initiation of an SCTP 1459 association. 1461 The parameter part of INIT ACK is formatted similarly to the INIT 1462 chunk. It uses two extra variable parameters: The State Cookie and 1463 the Unrecognized Parameter: 1465 The format of the INIT ACK chunk is shown below: 1467 0 1 2 3 1468 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1469 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1470 | Type = 2 | Chunk Flags | Chunk Length | 1471 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1472 | Initiate Tag | 1473 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1474 | Advertised Receiver Window Credit | 1475 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1476 | Number of Outbound Streams | Number of Inbound Streams | 1477 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1478 | Initial TSN | 1479 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1480 \ \ 1481 / Optional/Variable-Length Parameters / 1482 \ \ 1483 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1485 Initiate Tag: 32 bits (unsigned integer) 1486 The receiver of the INIT ACK records the value of the Initiate Tag 1487 parameter. This value MUST be placed into the Verification Tag 1488 field of every SCTP packet that the INIT ACK receiver transmits 1489 within this association. 1491 The Initiate Tag MUST NOT take the value 0. See Section 5.3.1 for 1492 more on the selection of the Initiate Tag value. 1494 If the value of the Initiate Tag in a received INIT ACK chunk is 1495 found to be 0, the receiver MUST destroy the association 1496 discarding its TCB. The receiver MAY send an ABORT for debugging 1497 purpose. 1499 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1500 integer) 1501 This value represents the dedicated buffer space, in number of 1502 bytes, the sender of the INIT ACK has reserved in association with 1503 this window. During the life of the association, this buffer 1504 space SHOULD NOT be lessened (i.e., dedicated buffers taken away 1505 from this association). 1507 Number of Outbound Streams (OS): 16 bits (unsigned integer) 1508 Defines the number of outbound streams the sender of this INIT ACK 1509 chunk wishes to create in this association. The value of 0 MUST 1510 NOT be used, and the value MUST NOT be greater than the MIS value 1511 sent in the INIT chunk. 1513 A receiver of an INIT ACK with the OS value set to 0 SHOULD 1514 destroy the association discarding its TCB. 1516 Number of Inbound Streams (MIS): 16 bits (unsigned integer) 1517 Defines the maximum number of streams the sender of this INIT ACK 1518 chunk allows the peer end to create in this association. The 1519 value 0 MUST NOT be used. 1521 Note: There is no negotiation of the actual number of streams but 1522 instead the two endpoints will use the min(requested, offered). 1523 See Section 5.1.1 for details. 1525 A receiver of an INIT ACK with the MIS value set to 0 SHOULD 1526 destroy the association discarding its TCB. 1528 Initial TSN (I-TSN): 32 bits (unsigned integer) 1529 Defines the initial TSN that the INIT ACK sender will use. The 1530 valid range is from 0 to 4294967295. This field MAY be set to the 1531 value of the Initiate Tag field. 1533 +-----------------------------------+-----------+ 1534 | Fixed Parameters | Status | 1535 +-----------------------------------+-----------+ 1536 | Initiate Tag | Mandatory | 1537 +-----------------------------------+-----------+ 1538 | Advertised Receiver Window Credit | Mandatory | 1539 +-----------------------------------+-----------+ 1540 | Number of Outbound Streams | Mandatory | 1541 +-----------------------------------+-----------+ 1542 | Number of Inbound Streams | Mandatory | 1543 +-----------------------------------+-----------+ 1544 | Initial TSN | Mandatory | 1545 +-----------------------------------+-----------+ 1547 Table 7: Fixed Length Parameters of INIT ACK 1548 Chunks 1550 +-----------------------------------+-----------+----------------+ 1551 | Variable Parameters | Status | Type Value | 1552 +-----------------------------------+-----------+----------------+ 1553 | State Cookie | Mandatory | 7 | 1554 +-----------------------------------+-----------+----------------+ 1555 | IPv4 Address (Note 1) | Optional | 5 | 1556 +-----------------------------------+-----------+----------------+ 1557 | IPv6 Address (Note 1) | Optional | 6 | 1558 +-----------------------------------+-----------+----------------+ 1559 | Unrecognized Parameter | Optional | 8 | 1560 +-----------------------------------+-----------+----------------+ 1561 | Reserved for ECN Capable (Note 2) | Optional | 32768 (0x8000) | 1562 +-----------------------------------+-----------+----------------+ 1563 | Host Name Address (Note 3) | Optional | 11 | 1564 +-----------------------------------+-----------+----------------+ 1566 Table 8: Variable Length Parameters of INIT ACK Chunks 1568 Note 1: The INIT ACK chunks can contain any number of IP address 1569 parameters that can be IPv4 and/or IPv6 in any combination. 1571 Note 2: The ECN Capable field is reserved for future use of Explicit 1572 Congestion Notification. 1574 Note 3: An INIT ACK chunk MUST NOT contain the Host Name Address 1575 parameter. The receiver of INIT ACK chunks containing a Host Name 1576 Address parameter MUST send an ABORT and MAY include an "Unresolvable 1577 Address" error cause. 1579 IMPLEMENTATION NOTE: An implementation MUST be prepared to receive an 1580 INIT ACK that is quite large (more than 1500 bytes) due to the 1581 variable size of the State Cookie AND the variable address list. For 1582 example if a responder to the INIT has 1000 IPv4 addresses it wishes 1583 to send, it would need at least 8,000 bytes to encode this in the 1584 INIT ACK. 1586 If an INIT ACK chunk is received with known parameters that are not 1587 optional parameters of the INIT ACK chunk, then the receiver SHOULD 1588 process the INIT ACK chunk and send back a COOKIE ECHO. The receiver 1589 of the INIT ACK chunk MAY bundle an ERROR chunk with the COOKIE ECHO 1590 chunk. However, restrictive implementations MAY send back an ABORT 1591 chunk in response to the INIT ACK chunk. 1593 In combination with the Source Port carried in the SCTP common 1594 header, each IP Address parameter in the INIT ACK indicates to the 1595 receiver of the INIT ACK a valid transport address supported by the 1596 sender of the INIT ACK for the life time of the association being 1597 initiated. 1599 If the INIT ACK contains at least one IP Address parameter, then the 1600 source address of the IP datagram containing the INIT ACK and any 1601 additional address(es) provided within the INIT ACK MAY be used as 1602 destinations by the receiver of the INIT ACK. If the INIT ACK does 1603 not contain any IP Address parameters, the receiver of the INIT ACK 1604 MUST use the source address associated with the received IP datagram 1605 as its sole destination address for the association. 1607 The State Cookie and Unrecognized Parameters use the Type-Length- 1608 Value format as defined in Section 3.2.1 and are described below. 1609 The other fields are defined the same as their counterparts in the 1610 INIT chunk. 1612 3.3.3.1. Optional or Variable-Length Parameters 1614 3.3.3.1.1. State Cookie (7) 1616 0 1 2 3 1617 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1618 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1619 | Type = 7 | Length | 1620 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1621 / Cookie / 1622 \ \ 1623 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1625 Cookie: variable length 1626 This parameter value MUST contain all the necessary state and 1627 parameter information required for the sender of this INIT ACK to 1628 create the association, along with a Message Authentication Code 1629 (MAC). See Section 5.1.3 for details on State Cookie definition. 1631 3.3.3.1.2. Unrecognized Parameter (8) 1633 This parameter is returned to the originator of the INIT chunk when 1634 the INIT contains an unrecognized parameter that has a value that 1635 indicates it SHOULD be reported to the sender. 1637 0 1 2 3 1638 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1639 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1640 | Type = 8 | Length | 1641 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1642 / Unrecognized Parameter / 1643 \ \ 1644 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1646 Unrecognized Parameter: variable length 1647 The parameter value field will contain an unrecognized parameter 1648 copied from the INIT chunk complete with Parameter Type, Length, 1649 and Value fields. 1651 3.3.4. Selective Acknowledgement (SACK) (3) 1653 This chunk is sent to the peer endpoint to acknowledge received DATA 1654 chunks and to inform the peer endpoint of gaps in the received 1655 subsequences of DATA chunks as represented by their TSNs. 1657 The SACK MUST contain the Cumulative TSN Ack, Advertised Receiver 1658 Window Credit (a_rwnd), Number of Gap Ack Blocks, and Number of 1659 Duplicate TSNs fields. 1661 By definition, the value of the Cumulative TSN Ack parameter is the 1662 last TSN received before a break in the sequence of received TSNs 1663 occurs; the next TSN value following this one has not yet been 1664 received at the endpoint sending the SACK. This parameter therefore 1665 acknowledges receipt of all TSNs less than or equal to its value. 1667 The handling of a_rwnd by the receiver of the SACK is discussed in 1668 detail in Section 6.2.1. 1670 The SACK also contains zero or more Gap Ack Blocks. Each Gap Ack 1671 Block acknowledges a subsequence of TSNs received following a break 1672 in the sequence of received TSNs. The Gap Ack Blocks SHOULD be 1673 isolated. This means that the TSN just before each Gap Ack Block and 1674 the TSN just after each Gap Ack Block have not been received. By 1675 definition, all TSNs acknowledged by Gap Ack Blocks are greater than 1676 the value of the Cumulative TSN Ack. 1678 0 1 2 3 1679 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1680 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1681 | Type = 3 |Chunk Flags | Chunk Length | 1682 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1683 | Cumulative TSN Ack | 1684 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1685 | Advertised Receiver Window Credit (a_rwnd) | 1686 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1687 | Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X | 1688 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1689 | Gap Ack Block #1 Start | Gap Ack Block #1 End | 1690 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1691 / / 1692 \ ... \ 1693 / / 1694 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1695 | Gap Ack Block #N Start | Gap Ack Block #N End | 1696 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1697 | Duplicate TSN 1 | 1698 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1699 / / 1700 \ ... \ 1701 / / 1702 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1703 | Duplicate TSN X | 1704 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1706 Chunk Flags: 8 bits 1707 Set to all '0's on transmit and ignored on receipt. 1709 Cumulative TSN Ack: 32 bits (unsigned integer) 1710 This parameter contains the TSN of the last DATA chunk received in 1711 sequence before a gap. In the case where no DATA chunk has been 1712 received, this value is set to the peer's Initial TSN minus one. 1714 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1715 integer) 1716 This field indicates the updated receive buffer space in bytes of 1717 the sender of this SACK; see Section 6.2.1 for details. 1719 Number of Gap Ack Blocks: 16 bits (unsigned integer) 1720 Indicates the number of Gap Ack Blocks included in this SACK. 1722 Number of Duplicate TSNs: 16 bit 1723 This field contains the number of duplicate TSNs the endpoint has 1724 received. Each duplicate TSN is listed following the Gap Ack 1725 Block list. 1727 Gap Ack Blocks: 1728 These fields contain the Gap Ack Blocks. They are repeated for 1729 each Gap Ack Block up to the number of Gap Ack Blocks defined in 1730 the Number of Gap Ack Blocks field. All DATA chunks with TSNs 1731 greater than or equal to (Cumulative TSN Ack + Gap Ack Block 1732 Start) and less than or equal to (Cumulative TSN Ack + Gap Ack 1733 Block End) of each Gap Ack Block are assumed to have been received 1734 correctly. Gap Ack Blocks SHOULD be isolated. This means that 1735 the DATA chunks with TSNs equal to (Cumulative TSN Ack + Gap Ack 1736 Block Start - 1) and (Cumulative TSN Ack + Gap Ack Block End + 1) 1737 have not been received. 1739 Gap Ack Block Start: 16 bits (unsigned integer) 1740 Indicates the Start offset TSN for this Gap Ack Block. To 1741 calculate the actual TSN number the Cumulative TSN Ack is added to 1742 this offset number. This calculated TSN identifies the first TSN 1743 in this Gap Ack Block that has been received. 1745 Gap Ack Block End: 16 bits (unsigned integer) 1746 Indicates the End offset TSN for this Gap Ack Block. To calculate 1747 the actual TSN number, the Cumulative TSN Ack is added to this 1748 offset number. This calculated TSN identifies the TSN of the last 1749 DATA chunk received in this Gap Ack Block. 1751 For example, assume that the receiver has the following DATA 1752 chunks newly arrived at the time when it decides to send a 1753 Selective ACK, 1755 ---------- 1756 | TSN=17 | 1757 ---------- 1758 | | <- still missing 1759 ---------- 1760 | TSN=15 | 1761 ---------- 1762 | TSN=14 | 1763 ---------- 1764 | | <- still missing 1765 ---------- 1766 | TSN=12 | 1767 ---------- 1768 | TSN=11 | 1769 ---------- 1770 | TSN=10 | 1771 ---------- 1773 then the parameter part of the SACK MUST be constructed as follows 1774 (assuming the new a_rwnd is set to 4660 by the sender): 1776 +--------------------------------+ 1777 | Cumulative TSN Ack = 12 | 1778 +--------------------------------+ 1779 | a_rwnd = 4660 | 1780 +----------------+---------------+ 1781 | num of block=2 | num of dup=0 | 1782 +----------------+---------------+ 1783 |block #1 strt=2 |block #1 end=3 | 1784 +----------------+---------------+ 1785 |block #2 strt=5 |block #2 end=5 | 1786 +----------------+---------------+ 1788 Duplicate TSN: 32 bits (unsigned integer) 1789 Indicates the number of times a TSN was received in duplicate 1790 since the last SACK was sent. Every time a receiver gets a 1791 duplicate TSN (before sending the SACK), it adds it to the list of 1792 duplicates. The duplicate count is reinitialized to zero after 1793 sending each SACK. 1795 For example, if a receiver were to get the TSN 19 three times it 1796 would list 19 twice in the outbound SACK. After sending the SACK, 1797 if it received yet one more TSN 19 it would list 19 as a duplicate 1798 once in the next outgoing SACK. 1800 3.3.5. Heartbeat Request (HEARTBEAT) (4) 1802 An endpoint SHOULD send a HEARTBEAT chunk to its peer endpoint to 1803 probe the reachability of a particular destination transport address 1804 defined in the present association. 1806 The parameter field contains the Heartbeat Information, which is a 1807 variable-length opaque data structure understood only by the sender. 1809 0 1 2 3 1810 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1811 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1812 | Type = 4 | Chunk Flags | Heartbeat Length | 1813 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1814 \ \ 1815 / Heartbeat Information TLV (Variable-Length) / 1816 \ \ 1817 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1819 Chunk Flags: 8 bits 1820 Set to 0 on transmit and ignored on receipt. 1822 Heartbeat Length: 16 bits (unsigned integer) 1823 Set to the size of the chunk in bytes, including the chunk header 1824 and the Heartbeat Information field. 1826 Heartbeat Information: variable length 1827 Defined as a variable-length parameter using the format described 1828 in Section 3.2.1, i.e.: 1830 +---------------------+-----------+------------+ 1831 | Variable Parameters | Status | Type Value | 1832 +---------------------+-----------+------------+ 1833 | Heartbeat Info | Mandatory | 1 | 1834 +---------------------+-----------+------------+ 1836 Table 9: Variable Length Parameters of 1837 HEARTBEAT Chunks 1839 0 1 2 3 1840 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1841 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1842 | Heartbeat Info Type=1 | HB Info Length | 1843 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1844 / Sender-Specific Heartbeat Info / 1845 \ \ 1846 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1848 The Sender-Specific Heartbeat Info field SHOULD include 1849 information about the sender's current time when this HEARTBEAT 1850 chunk is sent and the destination transport address to which this 1851 HEARTBEAT is sent (see Section 8.3). This information is simply 1852 reflected back by the receiver in the HEARTBEAT ACK message (see 1853 Section 3.3.6). Note also that the HEARTBEAT message is both for 1854 reachability checking and for path verification (see Section 5.4). 1855 When a HEARTBEAT chunk is being used for path verification 1856 purposes, it MUST hold a 64-bit random nonce. 1858 3.3.6. Heartbeat Acknowledgement (HEARTBEAT ACK) (5) 1860 An endpoint MUST send this chunk to its peer endpoint as a response 1861 to a HEARTBEAT chunk (see Section 8.3). A HEARTBEAT ACK is always 1862 sent to the source IP address of the IP datagram containing the 1863 HEARTBEAT chunk to which this ack is responding. 1865 The parameter field contains a variable-length opaque data structure. 1867 0 1 2 3 1868 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1869 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1870 | Type = 5 | Chunk Flags | Heartbeat Ack Length | 1871 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1872 \ \ 1873 / Heartbeat Information TLV (Variable-Length) / 1874 \ \ 1875 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1877 Chunk Flags: 8 bits 1878 Set to 0 on transmit and ignored on receipt. 1880 Heartbeat Ack Length: 16 bits (unsigned integer) 1881 Set to the size of the chunk in bytes, including the chunk header 1882 and the Heartbeat Information field. 1884 Heartbeat Information: variable length 1885 This field MUST contain the Heartbeat Information parameter of the 1886 Heartbeat Request to which this Heartbeat Acknowledgement is 1887 responding. 1889 +---------------------+-----------+------------+ 1890 | Variable Parameters | Status | Type Value | 1891 +---------------------+-----------+------------+ 1892 | Heartbeat Info | Mandatory | 1 | 1893 +---------------------+-----------+------------+ 1895 Table 10: Variable Length Parameters of 1896 HEARTBEAT ACK Chunks 1898 3.3.7. Abort Association (ABORT) (6) 1900 The ABORT chunk is sent to the peer of an association to close the 1901 association. The ABORT chunk MAY contain Cause Parameters to inform 1902 the receiver about the reason of the abort. DATA chunks MUST NOT be 1903 bundled with ABORT. Control chunks (except for INIT, INIT ACK, and 1904 SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be 1905 placed before the ABORT in the SCTP packet or they will be ignored by 1906 the receiver. 1908 If an endpoint receives an ABORT with a format error or no TCB is 1909 found, it MUST silently discard it. Moreover, under any 1910 circumstances, an endpoint that receives an ABORT MUST NOT respond to 1911 that ABORT by sending an ABORT of its own. 1913 0 1 2 3 1914 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1915 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1916 | Type = 6 |Reserved |T| Length | 1917 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1918 \ \ 1919 / zero or more Error Causes / 1920 \ \ 1921 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1923 Chunk Flags: 8 bits 1924 Reserved: 7 bits 1925 Set to 0 on transmit and ignored on receipt. 1927 T bit: 1 bit 1928 The T bit is set to 0 if the sender filled in the Verification 1929 Tag expected by the peer. If the Verification Tag is 1930 reflected, the T bit MUST be set to 1. Reflecting means that 1931 the sent Verification Tag is the same as the received one. 1933 Length: 16 bits (unsigned integer) 1934 Set to the size of the chunk in bytes, including the chunk header 1935 and all the Error Cause fields present. 1937 See Section 3.3.10 for Error Cause definitions. 1939 Note: Special rules apply to this chunk for verification; please see 1940 Section 8.5.1 for details. 1942 3.3.8. Shutdown Association (SHUTDOWN) (7) 1944 An endpoint in an association MUST use this chunk to initiate a 1945 graceful close of the association with its peer. This chunk has the 1946 following format. 1948 0 1 2 3 1949 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1950 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1951 | Type = 7 | Chunk Flags | Length = 8 | 1952 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1953 | Cumulative TSN Ack | 1954 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1956 Chunk Flags: 8 bits 1957 Set to 0 on transmit and ignored on receipt. 1959 Length: 16 bits (unsigned integer) 1960 Indicates the length of the parameter. Set to 8. 1962 Cumulative TSN Ack: 32 bits (unsigned integer) 1963 This parameter contains the TSN of the last chunk received in 1964 sequence before any gaps. 1966 Note: Since the SHUTDOWN message does not contain Gap Ack Blocks, it 1967 cannot be used to acknowledge TSNs received out of order. In a SACK, 1968 lack of Gap Ack Blocks that were previously included indicates that 1969 the data receiver reneged on the associated DATA chunks. 1971 Since SHUTDOWN does not contain Gap Ack Blocks, the receiver of the 1972 SHUTDOWN MUST NOT interpret the lack of a Gap Ack Block as a renege. 1973 (See Section 6.2 for information on reneging.) 1975 3.3.9. Shutdown Acknowledgement (SHUTDOWN ACK) (8) 1977 This chunk MUST be used to acknowledge the receipt of the SHUTDOWN 1978 chunk at the completion of the shutdown process; see Section 9.2 for 1979 details. 1981 The SHUTDOWN ACK chunk has no parameters. 1983 0 1 2 3 1984 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1985 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1986 | Type = 8 |Chunk Flags | Length = 4 | 1987 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1989 Chunk Flags: 8 bits 1990 Set to 0 on transmit and ignored on receipt. 1992 3.3.10. Operation Error (ERROR) (9) 1994 An endpoint sends this chunk to its peer endpoint to notify it of 1995 certain error conditions. It contains one or more error causes. An 1996 Operation Error is not considered fatal in and of itself, but MAY be 1997 used with an ABORT chunk to report a fatal condition. It has the 1998 following parameters: 2000 0 1 2 3 2001 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2002 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2003 | Type = 9 | Chunk Flags | Length | 2004 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2005 \ \ 2006 / one or more Error Causes / 2007 \ \ 2008 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2010 Chunk Flags: 8 bits 2011 Set to 0 on transmit and ignored on receipt. 2013 Length: 16 bits (unsigned integer) 2014 Set to the size of the chunk in bytes, including the chunk header 2015 and all the Error Cause fields present. 2017 Error causes are defined as variable-length parameters using the 2018 format described in Section 3.2.1, that is: 2020 0 1 2 3 2021 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2022 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2023 | Cause Code | Cause Length | 2024 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2025 / Cause-Specific Information / 2026 \ \ 2027 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2029 Cause Code: 16 bits (unsigned integer) 2030 Defines the type of error conditions being reported. 2032 +-------+----------------------------------------------+ 2033 | Value | Cause Code | 2034 +-------+----------------------------------------------+ 2035 | 1 | Invalid Stream Identifier | 2036 +-------+----------------------------------------------+ 2037 | 2 | Missing Mandatory Parameter | 2038 +-------+----------------------------------------------+ 2039 | 3 | Stale Cookie Error | 2040 +-------+----------------------------------------------+ 2041 | 4 | Out of Resource | 2042 +-------+----------------------------------------------+ 2043 | 5 | Unresolvable Address | 2044 +-------+----------------------------------------------+ 2045 | 6 | Unrecognized Chunk Type | 2046 +-------+----------------------------------------------+ 2047 | 7 | Invalid Mandatory Parameter | 2048 +-------+----------------------------------------------+ 2049 | 8 | Unrecognized Parameters | 2050 +-------+----------------------------------------------+ 2051 | 9 | No User Data | 2052 +-------+----------------------------------------------+ 2053 | 10 | Cookie Received While Shutting Down | 2054 +-------+----------------------------------------------+ 2055 | 11 | Restart of an Association with New Addresses | 2056 +-------+----------------------------------------------+ 2057 | 12 | User Initiated Abort | 2058 +-------+----------------------------------------------+ 2059 | 13 | Protocol Violation | 2060 +-------+----------------------------------------------+ 2062 Table 11: Cause Code 2064 Cause Length: 16 bits (unsigned integer) 2065 Set to the size of the parameter in bytes, including the Cause 2066 Code, Cause Length, and Cause-Specific Information fields. 2068 Cause-Specific Information: variable length 2069 This field carries the details of the error condition. 2071 Section 3.3.10.1 - Section 3.3.10.13 define error causes for SCTP. 2072 Guidelines for the IETF to define new error cause values are 2073 discussed in Section 15.4. 2075 3.3.10.1. Invalid Stream Identifier (1) 2077 Invalid Stream Identifier: Indicates endpoint received a DATA chunk 2078 sent to a nonexistent stream. 2080 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2081 | Cause Code=1 | Cause Length=8 | 2082 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2083 | Stream Identifier | (Reserved) | 2084 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2086 Stream Identifier: 16 bits (unsigned integer) 2087 Contains the Stream Identifier of the DATA chunk received in 2088 error. 2090 Reserved: 16 bits 2091 This field is reserved. It is set to all 0's on transmit and 2092 ignored on receipt. 2094 3.3.10.2. Missing Mandatory Parameter (2) 2096 Missing Mandatory Parameter: Indicates that one or more mandatory TLV 2097 parameters are missing in a received INIT or INIT ACK. 2099 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2100 | Cause Code=2 | Cause Length=8+N*2 | 2101 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2102 | Number of missing params=N | 2103 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2104 | Missing Param Type #1 | Missing Param Type #2 | 2105 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2106 | Missing Param Type #N-1 | Missing Param Type #N | 2107 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2109 Number of Missing params: 32 bits (unsigned integer) 2110 This field contains the number of parameters contained in the 2111 Cause-Specific Information field. 2113 Missing Param Type: 16 bits (unsigned integer) 2114 Each field will contain the missing mandatory parameter number. 2116 3.3.10.3. Stale Cookie Error (3) 2118 Stale Cookie Error: Indicates the receipt of a valid State Cookie 2119 that has expired. 2121 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2122 | Cause Code=3 | Cause Length=8 | 2123 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2124 | Measure of Staleness (usec.) | 2125 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2127 Measure of Staleness: 32 bits (unsigned integer) 2128 This field contains the difference, in microseconds, between the 2129 current time and the time the State Cookie expired. 2131 The sender of this error cause MAY choose to report how long past 2132 expiration the State Cookie is by including a non-zero value in 2133 the Measure of Staleness field. If the sender does not wish to 2134 provide the Measure of Staleness, it SHOULD set this field to the 2135 value of zero. 2137 3.3.10.4. Out of Resource (4) 2139 Out of Resource: Indicates that the sender is out of resource. This 2140 is usually sent in combination with or within an ABORT. 2142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2143 | Cause Code=4 | Cause Length=4 | 2144 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2146 3.3.10.5. Unresolvable Address (5) 2148 Unresolvable Address: Indicates that the sender is not able to 2149 resolve the specified address parameter (e.g., type of address is not 2150 supported by the sender). This is usually sent in combination with 2151 or within an ABORT. 2153 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2154 | Cause Code=5 | Cause Length | 2155 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2156 / Unresolvable Address / 2157 \ \ 2158 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2160 Unresolvable Address: variable length 2161 The Unresolvable Address field contains the complete Type, Length, 2162 and Value of the address parameter (or Host Name parameter) that 2163 contains the unresolvable address or host name. 2165 3.3.10.6. Unrecognized Chunk Type (6) 2167 Unrecognized Chunk Type: This error cause is returned to the 2168 originator of the chunk if the receiver does not understand the chunk 2169 and the upper bits of the 'Chunk Type' are set to 01 or 11. 2171 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2172 | Cause Code=6 | Cause Length | 2173 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2174 / Unrecognized Chunk / 2175 \ \ 2176 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2178 Unrecognized Chunk: variable length 2179 The Unrecognized Chunk field contains the unrecognized chunk from 2180 the SCTP packet complete with Chunk Type, Chunk Flags, and Chunk 2181 Length. 2183 3.3.10.7. Invalid Mandatory Parameter (7) 2185 Invalid Mandatory Parameter: This error cause is returned to the 2186 originator of an INIT or INIT ACK chunk when one of the mandatory 2187 parameters is set to an invalid value. 2189 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2190 | Cause Code=7 | Cause Length=4 | 2191 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2193 3.3.10.8. Unrecognized Parameters (8) 2195 Unrecognized Parameters: This error cause is returned to the 2196 originator of the INIT ACK chunk if the receiver does not recognize 2197 one or more Optional TLV parameters in the INIT ACK chunk. 2199 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2200 | Cause Code=8 | Cause Length | 2201 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2202 / Unrecognized Parameters / 2203 \ \ 2204 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2206 Unrecognized Parameters: variable length 2207 The Unrecognized Parameters field contains the unrecognized 2208 parameters copied from the INIT ACK chunk complete with TLV. This 2209 error cause is normally contained in an ERROR chunk bundled with 2210 the COOKIE ECHO chunk when responding to the INIT ACK, when the 2211 sender of the COOKIE ECHO chunk wishes to report unrecognized 2212 parameters. 2214 3.3.10.9. No User Data (9) 2216 No User Data: This error cause is returned to the originator of a 2217 DATA chunk if a received DATA chunk has no user data. 2219 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2220 | Cause Code=9 | Cause Length=8 | 2221 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2222 / TSN value / 2223 \ \ 2224 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2226 TSN value: 32 bits (unsigned integer) 2227 The TSN value field contains the TSN of the DATA chunk received 2228 with no user data field. 2230 This cause code is normally returned in an ABORT chunk (see 2231 Section 6.2). 2233 3.3.10.10. Cookie Received While Shutting Down (10) 2235 Cookie Received While Shutting Down: A COOKIE ECHO was received while 2236 the endpoint was in the SHUTDOWN-ACK-SENT state. This error is 2237 usually returned in an ERROR chunk bundled with the retransmitted 2238 SHUTDOWN ACK. 2240 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2241 | Cause Code=10 | Cause Length=4 | 2242 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2244 3.3.10.11. Restart of an Association with New Addresses (11) 2246 Restart of an association with new addresses: An INIT was received on 2247 an existing association. But the INIT added addresses to the 2248 association that were previously not part of the association. The 2249 new addresses are listed in the error code. This ERROR is normally 2250 sent as part of an ABORT refusing the INIT (see Section 5.2). 2252 0 1 2 3 2253 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2254 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2255 | Cause Code=11 | Cause Length=Variable | 2256 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2257 / New Address TLVs / 2258 \ \ 2259 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2261 Note: Each New Address TLV is an exact copy of the TLV that was found 2262 in the INIT chunk that was new, including the Parameter Type and the 2263 Parameter Length. 2265 3.3.10.12. User-Initiated Abort (12) 2267 This error cause MAY be included in ABORT chunks that are sent 2268 because of an upper-layer request. The upper layer can specify an 2269 Upper Layer Abort Reason that is transported by SCTP transparently 2270 and MAY be delivered to the upper-layer protocol at the peer. 2272 0 1 2 3 2273 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2274 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2275 | Cause Code=12 | Cause Length=Variable | 2276 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2277 / Upper Layer Abort Reason / 2278 \ \ 2279 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2281 3.3.10.13. Protocol Violation (13) 2283 This error cause MAY be included in ABORT chunks that are sent 2284 because an SCTP endpoint detects a protocol violation of the peer 2285 that is not covered by the error causes described in Section 3.3.10.1 2286 to Section 3.3.10.12. An implementation MAY provide additional 2287 information specifying what kind of protocol violation has been 2288 detected. 2290 0 1 2 3 2291 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2292 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2293 | Cause Code=13 | Cause Length=Variable | 2294 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2295 / Additional Information / 2296 \ \ 2297 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2299 3.3.11. Cookie Echo (COOKIE ECHO) (10) 2301 This chunk is used only during the initialization of an association. 2302 It is sent by the initiator of an association to its peer to complete 2303 the initialization process. This chunk MUST precede any DATA chunk 2304 sent within the association, but MAY be bundled with one or more DATA 2305 chunks in the same packet. 2307 0 1 2 3 2308 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2309 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2310 | Type = 10 |Chunk Flags | Length | 2311 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2312 / Cookie / 2313 \ \ 2314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2316 Chunk Flags: 8 bits 2317 Set to 0 on transmit and ignored on receipt. 2319 Length: 16 bits (unsigned integer) 2320 Set to the size of the chunk in bytes, including the 4 bytes of 2321 the chunk header and the size of the cookie. 2323 Cookie: variable size 2324 This field MUST contain the exact cookie received in the State 2325 Cookie parameter from the previous INIT ACK. 2327 An implementation SHOULD make the cookie as small as possible to 2328 ensure interoperability. 2330 Note: A Cookie Echo does not contain a State Cookie parameter; 2331 instead, the data within the State Cookie's Parameter Value 2332 becomes the data within the Cookie Echo's Chunk Value. This 2333 allows an implementation to change only the first 2 bytes of the 2334 State Cookie parameter to become a COOKIE ECHO chunk. 2336 3.3.12. Cookie Acknowledgement (COOKIE ACK) (11) 2338 This chunk is used only during the initialization of an association. 2339 It is used to acknowledge the receipt of a COOKIE ECHO chunk. This 2340 chunk MUST precede any DATA or SACK chunk sent within the 2341 association, but MAY be bundled with one or more DATA chunks or SACK 2342 chunk's in the same SCTP packet. 2344 0 1 2 3 2345 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2346 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2347 | Type = 11 |Chunk Flags | Length = 4 | 2348 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2350 Chunk Flags: 8 bits 2351 Set to 0 on transmit and ignored on receipt. 2353 3.3.13. Shutdown Complete (SHUTDOWN COMPLETE) (14) 2355 This chunk MUST be used to acknowledge the receipt of the SHUTDOWN 2356 ACK chunk at the completion of the shutdown process; see Section 9.2 2357 for details. 2359 The SHUTDOWN COMPLETE chunk has no parameters. 2361 0 1 2 3 2362 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2363 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2364 | Type = 14 |Reserved |T| Length = 4 | 2365 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2367 Chunk Flags: 8 bits 2368 Reserved: 7 bits 2369 Set to 0 on transmit and ignored on receipt. 2371 T bit: 1 bit 2372 The T bit is set to 0 if the sender filled in the Verification 2373 Tag expected by the peer. If the Verification Tag is 2374 reflected, the T bit MUST be set to 1. Reflecting means that 2375 the sent Verification Tag is the same as the received one. 2377 Note: Special rules apply to this chunk for verification, please see 2378 Section 8.5.1 for details. 2380 4. SCTP Association State Diagram 2382 During the life time of an SCTP association, the SCTP endpoint's 2383 association progresses from one state to another in response to 2384 various events. The events that might potentially advance an 2385 association's state include: 2387 * SCTP user primitive calls, e.g., [ASSOCIATE], [SHUTDOWN], [ABORT], 2389 * Reception of INIT, COOKIE ECHO, ABORT, SHUTDOWN, etc., control 2390 chunks, or 2392 * Some timeout events. 2394 The state diagram in the figures below illustrates state changes, 2395 together with the causing events and resulting actions. Note that 2396 some of the error conditions are not shown in the state diagram. 2397 Full descriptions of all special cases are found in the text. 2399 Note: Chunk names are given in all capital letters, while parameter 2400 names have the first letter capitalized, e.g., COOKIE ECHO chunk type 2401 vs. State Cookie parameter. If more than one event/message can occur 2402 that causes a state transition, it is labeled (A), (B), etc. 2404 ----- -------- (from any state) 2405 / \ / rcv ABORT [ABORT] 2406 rcv INIT | | | ---------- or ---------- 2407 --------------- | v v delete TCB snd ABORT 2408 generate Cookie \ +---------+ delete TCB 2409 snd INIT ACK ---| CLOSED | 2410 +---------+ 2411 / \ [ASSOCIATE] 2412 / \ --------------- 2413 | | create TCB 2414 | | snd INIT 2415 | | strt init timer 2416 rcv valid | | 2417 COOKIE ECHO | v 2418 (1) ---------------- | +------------+ 2419 create TCB | | COOKIE-WAIT| (2) 2420 snd COOKIE ACK | +------------+ 2421 | | 2422 | | rcv INIT ACK 2423 | | ----------------- 2424 | | snd COOKIE ECHO 2425 | | stop init timer 2426 | | strt cookie timer 2427 | v 2428 | +--------------+ 2429 | | COOKIE-ECHOED| (3) 2430 | +--------------+ 2431 | | 2432 | | rcv COOKIE ACK 2433 | | ----------------- 2434 | | stop cookie timer 2435 v v 2436 +---------------+ 2437 | ESTABLISHED | 2438 +---------------+ 2439 | 2440 | 2441 /----+------------\ 2442 [SHUTDOWN] / \ 2443 -------------------| | 2444 check outstanding | | 2445 DATA chunks | | 2446 v | 2448 +---------+ | 2449 |SHUTDOWN-| | rcv SHUTDOWN 2450 |PENDING | |------------------ 2451 +---------+ | check outstanding 2452 | | DATA chunks 2453 No more outstanding | | 2454 ---------------------| | 2455 snd SHUTDOWN | | 2456 strt shutdown timer | | 2457 v v 2458 +---------+ +-----------+ 2459 (4) |SHUTDOWN-| | SHUTDOWN- | (5,6) 2460 |SENT | | RECEIVED | 2461 +---------+ +-----------+ 2462 | \ | 2463 (A) rcv SHUTDOWN ACK | \ | 2464 ----------------------| \ | 2465 stop shutdown timer | \rcv:SHUTDOWN | 2466 send SHUTDOWN COMPLETE| \ (B) | 2467 delete TCB | \ | 2468 | \ | No more outstanding 2469 | \ |----------------- 2470 | \ | send SHUTDOWN ACK 2471 (B)rcv SHUTDOWN | \ | strt shutdown timer 2472 ----------------------| \ | 2473 send SHUTDOWN ACK | \ | 2474 start shutdown timer | \ | 2475 move to SHUTDOWN- | \ | 2476 ACK-SENT | | | 2477 | v | 2478 | +-----------+ 2479 | | SHUTDOWN- | (7) 2480 | | ACK-SENT | 2481 | +----------+- 2482 | | (C)rcv SHUTDOWN COMPLETE 2483 | |----------------- 2484 | | stop shutdown timer 2485 | | delete TCB 2486 | | 2487 | | (D)rcv SHUTDOWN ACK 2488 | |-------------- 2489 | | stop shutdown timer 2490 | | send SHUTDOWN COMPLETE 2491 | | delete TCB 2492 | | 2493 \ +---------+ / 2494 \-->| CLOSED |<--/ 2495 +---------+ 2497 Figure 3: State Transition Diagram of SCTP 2499 The following applies: 2501 1) If the State Cookie in the received COOKIE ECHO is invalid (i.e., 2502 failed to pass the integrity check), the receiver MUST silently 2503 discard the packet. Or, if the received State Cookie is expired 2504 (see Section 5.1.5), the receiver MUST send back an ERROR chunk. 2505 In either case, the receiver stays in the CLOSED state. 2507 2) If the T1-init timer expires, the endpoint MUST retransmit INIT 2508 and restart the T1-init timer without changing state. This MUST 2509 be repeated up to 'Max.Init.Retransmits' times. After that, the 2510 endpoint MUST abort the initialization process and report the 2511 error to the SCTP user. 2513 3) If the T1-cookie timer expires, the endpoint MUST retransmit 2514 COOKIE ECHO and restart the T1-cookie timer without changing 2515 state. This MUST be repeated up to 'Max.Init.Retransmits' times. 2516 After that, the endpoint MUST abort the initialization process 2517 and report the error to the SCTP user. 2519 4) In the SHUTDOWN-SENT state, the endpoint MUST acknowledge any 2520 received DATA chunks without delay. 2522 5) In the SHUTDOWN-RECEIVED state, the endpoint MUST NOT accept any 2523 new send requests from its SCTP user. 2525 6) In the SHUTDOWN-RECEIVED state, the endpoint MUST transmit or 2526 retransmit data and leave this state when all data in queue is 2527 transmitted. 2529 7) In the SHUTDOWN-ACK-SENT state, the endpoint MUST NOT accept any 2530 new send requests from its SCTP user. 2532 The CLOSED state is used to indicate that an association is not 2533 created (i.e., does not exist). 2535 5. Association Initialization 2537 Before the first data transmission can take place from one SCTP 2538 endpoint ("A") to another SCTP endpoint ("Z"), the two endpoints MUST 2539 complete an initialization process in order to set up an SCTP 2540 association between them. 2542 The SCTP user at an endpoint can use the ASSOCIATE primitive to 2543 initialize an SCTP association to another SCTP endpoint. 2545 IMPLEMENTATION NOTE: From an SCTP user's point of view, an 2546 association might be implicitly opened, without an ASSOCIATE 2547 primitive (see Section 11.1.2) being invoked, by the initiating 2548 endpoint's sending of the first user data to the destination 2549 endpoint. The initiating SCTP will assume default values for all 2550 mandatory and optional parameters for the INIT/INIT ACK. 2552 Once the association is established, unidirectional streams are open 2553 for data transfer on both ends (see Section 5.1.1). 2555 5.1. Normal Establishment of an Association 2557 The initialization process consists of the following steps (assuming 2558 that SCTP endpoint "A" tries to set up an association with SCTP 2559 endpoint "Z" and "Z" accepts the new association): 2561 A) "A" first sends an INIT chunk to "Z". In the INIT, "A" MUST 2562 provide its Verification Tag (Tag_A) in the Initiate Tag field. 2563 Tag_A SHOULD be a random number in the range of 1 to 4294967295 2564 (see Section 5.3.1 for Tag value selection). After sending the 2565 INIT, "A" starts the T1-init timer and enters the COOKIE-WAIT 2566 state. 2568 B) "Z" responds immediately with an INIT ACK chunk. The destination 2569 IP address of the INIT ACK MUST be set to the source IP address 2570 of the INIT to which this INIT ACK is responding. In the 2571 response, besides filling in other parameters, "Z" MUST set the 2572 Verification Tag field to Tag_A, and also provide its own 2573 Verification Tag (Tag_Z) in the Initiate Tag field. 2575 Moreover, "Z" MUST generate and send along with the INIT ACK a 2576 State Cookie. See Section 5.1.3 for State Cookie generation. 2578 After sending out INIT ACK with the State Cookie parameter, "Z" 2579 MUST NOT allocate any resources or keep any states for the new 2580 association. Otherwise, "Z" will be vulnerable to resource 2581 attacks. 2583 C) Upon reception of the INIT ACK from "Z", "A" stops the T1-init 2584 timer and leaves the COOKIE-WAIT state. "A" then sends the State 2585 Cookie received in the INIT ACK chunk in a COOKIE ECHO chunk, 2586 starts the T1-cookie timer, and enters the COOKIE-ECHOED state. 2588 The COOKIE ECHO chunk MAY be bundled with any pending outbound 2589 DATA chunks, but it MUST be the first chunk in the packet and 2590 until the COOKIE ACK is returned the sender MUST NOT send any 2591 other packets to the peer. 2593 D) Upon reception of the COOKIE ECHO chunk, endpoint "Z" replies 2594 with a COOKIE ACK chunk after building a TCB and moving to the 2595 ESTABLISHED state. A COOKIE ACK chunk MAY be bundled with any 2596 pending DATA chunks (and/or SACK chunks), but the COOKIE ACK 2597 chunk MUST be the first chunk in the packet. 2599 IMPLEMENTATION NOTE: An implementation can choose to send the 2600 Communication Up notification to the SCTP user upon reception of 2601 a valid COOKIE ECHO chunk. 2603 E) Upon reception of the COOKIE ACK, endpoint "A" moves from the 2604 COOKIE-ECHOED state to the ESTABLISHED state, stopping the 2605 T1-cookie timer. It can also notify its ULP about the successful 2606 establishment of the association with a Communication Up 2607 notification (see Section 11). 2609 An INIT or INIT ACK chunk MUST NOT be bundled with any other chunk. 2610 They MUST be the only chunks present in the SCTP packets that carry 2611 them. 2613 An endpoint MUST send the INIT ACK to the IP address from which it 2614 received the INIT. 2616 T1-init timer and T1-cookie timer SHOULD follow the same rules given 2617 in Section 6.3. If the application provided multiple IP addresses of 2618 the peer, there SHOULD be a T1-init and T1-cookie timer for each 2619 address of the peer. Retransmissions of INIT chunks and COOKIE ECHO 2620 chunks SHOULD use all addresses of the peer similar to 2621 retransmissions of DATA chunks. 2623 If an endpoint receives an INIT, INIT ACK, or COOKIE ECHO chunk but 2624 decides not to establish the new association due to missing mandatory 2625 parameters in the received INIT or INIT ACK, invalid parameter 2626 values, or lack of local resources, it SHOULD respond with an ABORT 2627 chunk. It SHOULD also specify the cause of abort, such as the type 2628 of the missing mandatory parameters, etc., by including the error 2629 cause parameters with the ABORT chunk. The Verification Tag field in 2630 the common header of the outbound SCTP packet containing the ABORT 2631 chunk MUST be set to the Initiate Tag value of the peer. 2633 Note that a COOKIE ECHO chunk that does not pass the integrity check 2634 is not considered an 'invalid parameter' and requires special 2635 handling; see Section 5.1.5. 2637 After the reception of the first DATA chunk in an association the 2638 endpoint MUST immediately respond with a SACK to acknowledge the DATA 2639 chunk. Subsequent acknowledgements SHOULD be done as described in 2640 Section 6.2. 2642 When the TCB is created, each endpoint MUST set its internal 2643 Cumulative TSN Ack Point to the value of its transmitted Initial TSN 2644 minus one. 2646 IMPLEMENTATION NOTE: The IP addresses and SCTP port are generally 2647 used as the key to find the TCB within an SCTP instance. 2649 5.1.1. Handle Stream Parameters 2651 In the INIT and INIT ACK chunks, the sender of the chunk MUST 2652 indicate the number of outbound streams (OSs) it wishes to have in 2653 the association, as well as the maximum inbound streams (MISs) it 2654 will accept from the other endpoint. 2656 After receiving the stream configuration information from the other 2657 side, each endpoint MUST perform the following check: If the peer's 2658 MIS is less than the endpoint's OS, meaning that the peer is 2659 incapable of supporting all the outbound streams the endpoint wants 2660 to configure, the endpoint MUST use MIS outbound streams and MAY 2661 report any shortage to the upper layer. The upper layer can then 2662 choose to abort the association if the resource shortage is 2663 unacceptable. 2665 After the association is initialized, the valid outbound stream 2666 identifier range for either endpoint MUST be 0 to min(local OS, 2667 remote MIS)-1. 2669 5.1.2. Handle Address Parameters 2671 During the association initialization, an endpoint uses the following 2672 rules to discover and collect the destination transport address(es) 2673 of its peer. 2675 A) If there are no address parameters present in the received INIT 2676 or INIT ACK chunk, the endpoint MUST take the source IP address 2677 from which the chunk arrives and record it, in combination with 2678 the SCTP source port number, as the only destination transport 2679 address for this peer. 2681 B) If there is a Host Name Address parameter present in the received 2682 INIT or INIT ACK chunk, the endpoint MUST immediately send an 2683 ABORT and MAY include an "Unresolvable Address" error cause to 2684 its peer. The ABORT SHOULD be sent to the source IP address from 2685 which the last peer packet was received. 2687 C) If there are only IPv4/IPv6 addresses present in the received 2688 INIT or INIT ACK chunk, the receiver MUST derive and record all 2689 the transport addresses from the received chunk AND the source IP 2690 address that sent the INIT or INIT ACK. The transport addresses 2691 are derived by the combination of SCTP source port (from the 2692 common header) and the IP Address parameter(s) carried in the 2693 INIT or INIT ACK chunk and the source IP address of the IP 2694 datagram. The receiver SHOULD use only these transport addresses 2695 as destination transport addresses when sending subsequent 2696 packets to its peer. 2698 D) An INIT or INIT ACK chunk MUST be treated as belonging to an 2699 already established association (or one in the process of being 2700 established) if the use of any of the valid address parameters 2701 contained within the chunk would identify an existing TCB. 2703 IMPLEMENTATION NOTE: In some cases (e.g., when the implementation 2704 does not control the source IP address that is used for 2705 transmitting), an endpoint might need to include in its INIT or INIT 2706 ACK all possible IP addresses from which packets to the peer could be 2707 transmitted. 2709 After all transport addresses are derived from the INIT or INIT ACK 2710 chunk using the above rules, the endpoint selects one of the 2711 transport addresses as the initial primary path. 2713 The INIT ACK MUST be sent to the source address of the INIT. 2715 The sender of INIT chunks MAY include a 'Supported Address Types' 2716 parameter in the INIT to indicate what types of addresses are 2717 acceptable. 2719 IMPLEMENTATION NOTE: In the case that the receiver of an INIT ACK 2720 fails to resolve the address parameter due to an unsupported type, it 2721 can abort the initiation process and then attempt a reinitiation by 2722 using a 'Supported Address Types' parameter in the new INIT to 2723 indicate what types of address it prefers. 2725 If an SCTP endpoint that only supports either IPv4 or IPv6 receives 2726 IPv4 and IPv6 addresses in an INIT or INIT ACK chunk from its peer, 2727 it MUST use all the addresses belonging to the supported address 2728 family. The other addresses MAY be ignored. The endpoint SHOULD NOT 2729 respond with any kind of error indication. 2731 If an SCTP endpoint lists in the 'Supported Address Types' parameter 2732 either IPv4 or IPv6, but uses the other family for sending the packet 2733 containing the INIT chunk, or if it also lists addresses of the other 2734 family in the INIT chunk, then the address family that is not listed 2735 in the 'Supported Address Types' parameter SHOULD also be considered 2736 as supported by the receiver of the INIT chunk. The receiver of the 2737 INIT chunk SHOULD NOT respond with any kind of error indication. 2739 5.1.3. Generating State Cookie 2741 When sending an INIT ACK as a response to an INIT chunk, the sender 2742 of INIT ACK creates a State Cookie and sends it in the State Cookie 2743 parameter of the INIT ACK. Inside this State Cookie, the sender can 2744 include a MAC (see [RFC2104] for an example), a timestamp on when the 2745 State Cookie is created, and the lifespan of the State Cookie, along 2746 with all the information necessary for it to establish the 2747 association. 2749 The following steps SHOULD be taken to generate the State Cookie: 2751 1) Create an association TCB using information from both the 2752 received INIT and the outgoing INIT ACK chunk, 2754 2) In the TCB, set the creation time to the current time of day, and 2755 the lifespan to the protocol parameter 'Valid.Cookie.Life' (see 2756 Section 16), 2758 3) From the TCB, identify and collect the minimal subset of 2759 information needed to re-create the TCB, and generate a MAC using 2760 this subset of information and a secret key (see [RFC2104] for an 2761 example of generating a MAC), and 2763 4) Generate the State Cookie by combining this subset of information 2764 and the resultant MAC. 2766 After sending the INIT ACK with the State Cookie parameter, the 2767 sender SHOULD delete the TCB and any other local resource related to 2768 the new association, so as to prevent resource attacks. 2770 The hashing method used to generate the MAC is strictly a private 2771 matter for the receiver of the INIT chunk. The use of a MAC is 2772 mandatory to prevent denial-of-service attacks. The secret key 2773 SHOULD be random ([RFC4086] provides some information on randomness 2774 guidelines); it SHOULD be changed reasonably frequently, and the 2775 timestamp in the State Cookie MAY be used to determine which key is 2776 used to verify the MAC. 2778 An implementation SHOULD make the cookie as small as possible to 2779 ensure interoperability. 2781 5.1.4. State Cookie Processing 2783 When an endpoint (in the COOKIE-WAIT state) receives an INIT ACK 2784 chunk with a State Cookie parameter, it MUST immediately send a 2785 COOKIE ECHO chunk to its peer with the received State Cookie. The 2786 sender MAY also add any pending DATA chunks to the packet after the 2787 COOKIE ECHO chunk. 2789 The endpoint MUST also start the T1-cookie timer after sending out 2790 the COOKIE ECHO chunk. If the timer expires, the endpoint MUST 2791 retransmit the COOKIE ECHO chunk and restart the T1-cookie timer. 2792 This is repeated until either a COOKIE ACK is received or 2793 'Max.Init.Retransmits' (see Section 16) is reached causing the peer 2794 endpoint to be marked unreachable (and thus the association enters 2795 the CLOSED state). 2797 5.1.5. State Cookie Authentication 2799 When an endpoint receives a COOKIE ECHO chunk from another endpoint 2800 with which it has no association, it takes the following actions: 2802 1) Compute a MAC using the TCB data carried in the State Cookie and 2803 the secret key (note the timestamp in the State Cookie MAY be 2804 used to determine which secret key to use). [RFC2104] can be 2805 used as a guideline for generating the MAC, 2807 2) Authenticate the State Cookie as one that it previously generated 2808 by comparing the computed MAC against the one carried in the 2809 State Cookie. If this comparison fails, the SCTP packet, 2810 including the COOKIE ECHO and any DATA chunks, SHOULD be silently 2811 discarded, 2813 3) Compare the port numbers and the Verification Tag contained 2814 within the COOKIE ECHO chunk to the actual port numbers and the 2815 Verification Tag within the SCTP common header of the received 2816 packet. If these values do not match, the packet MUST be 2817 silently discarded. 2819 4) Compare the creation timestamp in the State Cookie to the current 2820 local time. If the elapsed time is longer than the lifespan 2821 carried in the State Cookie, then the packet, including the 2822 COOKIE ECHO and any attached DATA chunks, SHOULD be discarded, 2823 and the endpoint MUST transmit an ERROR chunk with a "Stale 2824 Cookie" error cause to the peer endpoint. 2826 5) If the State Cookie is valid, create an association to the sender 2827 of the COOKIE ECHO chunk with the information in the TCB data 2828 carried in the COOKIE ECHO and enter the ESTABLISHED state. 2830 6) Send a COOKIE ACK chunk to the peer acknowledging receipt of the 2831 COOKIE ECHO. The COOKIE ACK MAY be bundled with an outbound DATA 2832 chunk or SACK chunk; however, the COOKIE ACK MUST be the first 2833 chunk in the SCTP packet. 2835 7) Immediately acknowledge any DATA chunk bundled with the COOKIE 2836 ECHO with a SACK (subsequent DATA chunk acknowledgement SHOULD 2837 follow the rules defined in Section 6.2). As mentioned in step 2838 6, if the SACK is bundled with the COOKIE ACK, the COOKIE ACK 2839 MUST appear first in the SCTP packet. 2841 If a COOKIE ECHO is received from an endpoint with which the receiver 2842 of the COOKIE ECHO has an existing association, the procedures in 2843 Section 5.2 SHOULD be followed. 2845 5.1.6. An Example of Normal Association Establishment 2847 In the following example, "A" initiates the association and then 2848 sends a user message to "Z", then "Z" sends two user messages to "A" 2849 later (assuming no bundling or fragmentation occurs): 2851 Endpoint A Endpoint Z 2852 {app sets association with Z} 2853 (build TCB) 2854 INIT [I-Tag=Tag_A 2855 & other info] ------\ 2856 (Start T1-init timer) \ 2857 (Enter COOKIE-WAIT state) \---> (compose temp TCB and Cookie_Z) 2858 /-- INIT ACK [Veri Tag=Tag_A, 2859 / I-Tag=Tag_Z, 2860 (Cancel T1-init timer) <------/ Cookie_Z, & other info] 2861 (destroy temp TCB) 2862 COOKIE ECHO [Cookie_Z] ------\ 2863 (Start T1-cookie timer) \ 2864 (Enter COOKIE-ECHOED state) \---> (build TCB, enter ESTABLISHED 2865 state) 2866 /---- COOKIE ACK 2867 / 2868 (Cancel T1-cookie timer, <---/ 2869 enter ESTABLISHED state) 2870 {app sends 1st user data; strm 0} 2871 DATA [TSN=initial TSN_A 2872 Strm=0,Seq=0 & user data]--\ 2873 (Start T3-rtx timer) \ 2874 \-> 2875 /----- SACK [TSN Ack=init 2876 / TSN_A,Block=0] 2877 (Cancel T3-rtx timer) <------/ 2878 ... 2879 {app sends 2 messages;strm 0} 2880 /---- DATA 2881 / [TSN=init TSN_Z 2882 <--/ Strm=0,Seq=0 & user data 1] 2883 SACK [TSN Ack=init TSN_Z, /---- DATA 2884 Block=0] --------\ / [TSN=init TSN_Z +1, 2885 \/ Strm=0,Seq=1 & user data 2] 2886 <------/\ 2887 \ 2888 \------> 2890 Figure 4: INITIATION Example 2892 If the T1-init timer expires at "A" after the INIT or COOKIE ECHO 2893 chunks are sent, the same INIT or COOKIE ECHO chunk with the same 2894 Initiate Tag (i.e., Tag_A) or State Cookie is retransmitted and the 2895 timer restarted. This is repeated 'Max.Init.Retransmits' times 2896 before "A" considers "Z" unreachable and reports the failure to its 2897 upper layer (and thus the association enters the CLOSED state). 2899 When retransmitting the INIT, the endpoint MUST follow the rules 2900 defined in Section 6.3 to determine the proper timer value. 2902 5.2. Handle Duplicate or Unexpected INIT, INIT ACK, COOKIE ECHO, and 2903 COOKIE ACK 2905 During the life time of an association (in one of the possible 2906 states), an endpoint can receive from its peer endpoint one of the 2907 setup chunks (INIT, INIT ACK, COOKIE ECHO, and COOKIE ACK). The 2908 receiver treats such a setup chunk as a duplicate and process it as 2909 described in this section. 2911 Note: An endpoint will not receive the chunk unless the chunk was 2912 sent to an SCTP transport address and is from an SCTP transport 2913 address associated with this endpoint. Therefore, the endpoint 2914 processes such a chunk as part of its current association. 2916 The following scenarios can cause duplicated or unexpected chunks: 2918 A) The peer has crashed without being detected, restarted itself, 2919 and sent out a new INIT chunk trying to restore the association, 2921 B) Both sides are trying to initialize the association at about the 2922 same time, 2924 C) The chunk is from a stale packet that was used to establish the 2925 present association or a past association that is no longer in 2926 existence, 2928 D) The chunk is a false packet generated by an attacker, or 2930 E) The peer never received the COOKIE ACK and is retransmitting its 2931 COOKIE ECHO. 2933 The rules in the following sections are applied in order to identify 2934 and correctly handle these cases. 2936 5.2.1. INIT Received in COOKIE-WAIT or COOKIE-ECHOED State (Item B) 2938 This usually indicates an initialization collision, i.e., each 2939 endpoint is attempting, at about the same time, to establish an 2940 association with the other endpoint. 2942 Upon receipt of an INIT in the COOKIE-WAIT state, an endpoint MUST 2943 respond with an INIT ACK using the same parameters it sent in its 2944 original INIT chunk (including its Initiate Tag, unchanged). When 2945 responding, the following rules MUST be applied: 2947 1) The INIT ACK MUST only be sent to an address passed by the upper 2948 layer in the request to initialize the association. 2950 2) The INIT ACK MUST only be sent to an address reported in the 2951 incoming INIT. 2953 3) The INIT ACK SHOULD be sent to the source address of the received 2954 INIT. 2956 Upon receipt of an INIT in the COOKIE-ECHOED state, an endpoint MUST 2957 respond with an INIT ACK using the same parameters it sent in its 2958 original INIT chunk (including its Initiate Tag, unchanged), provided 2959 that no NEW address has been added to the forming association. If 2960 the INIT message indicates that a new address has been added to the 2961 association, then the entire INIT MUST be discarded, and SHOULD NOT 2962 do any changes to the existing association. An ABORT SHOULD be sent 2963 in response that MAY include the error 'Restart of an association 2964 with new addresses'. The error SHOULD list the addresses that were 2965 added to the restarting association. 2967 When responding in either state (COOKIE-WAIT or COOKIE-ECHOED) with 2968 an INIT ACK, the original parameters are combined with those from the 2969 newly received INIT chunk. The endpoint MUST also generate a State 2970 Cookie with the INIT ACK. The endpoint uses the parameters sent in 2971 its INIT to calculate the State Cookie. 2973 After that, the endpoint MUST NOT change its state, the T1-init timer 2974 MUST be left running, and the corresponding TCB MUST NOT be 2975 destroyed. The normal procedures for handling State Cookies when a 2976 TCB exists will resolve the duplicate INITs to a single association. 2978 For an endpoint that is in the COOKIE-ECHOED state, it MUST populate 2979 its Tie-Tags within both the association TCB and inside the State 2980 Cookie (see Section 5.2.2 for a description of the Tie-Tags). 2982 5.2.2. Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, 2983 COOKIE-WAIT, and SHUTDOWN-ACK-SENT 2985 Unless otherwise stated, upon receipt of an unexpected INIT for this 2986 association, the endpoint MUST generate an INIT ACK with a State 2987 Cookie. Before responding, the endpoint MUST check to see if the 2988 unexpected INIT adds new addresses to the association. If new 2989 addresses are added to the association, the endpoint MUST respond 2990 with an ABORT, copying the 'Initiate Tag' of the unexpected INIT into 2991 the 'Verification Tag' of the outbound packet carrying the ABORT. In 2992 the ABORT response, the cause of error MAY be set to 'restart of an 2993 association with new addresses'. The error SHOULD list the addresses 2994 that were added to the restarting association. If no new addresses 2995 are added, when responding to the INIT in the outbound INIT ACK, the 2996 endpoint MUST copy its current Tie-Tags to a reserved place within 2997 the State Cookie and the association's TCB. We refer to these 2998 locations inside the cookie as the Peer's-Tie-Tag and the Local-Tie- 2999 Tag. We will refer to the copy within an association's TCB as the 3000 Local Tag and Peer's Tag. The outbound SCTP packet containing this 3001 INIT ACK MUST carry a Verification Tag value equal to the Initiate 3002 Tag found in the unexpected INIT. And the INIT ACK MUST contain a 3003 new Initiate Tag (randomly generated; see Section 5.3.1). Other 3004 parameters for the endpoint SHOULD be copied from the existing 3005 parameters of the association (e.g., number of outbound streams) into 3006 the INIT ACK and cookie. 3008 After sending out the INIT ACK or ABORT, the endpoint MUST take no 3009 further actions; i.e., the existing association, including its 3010 current state, and the corresponding TCB MUST NOT be changed. 3012 Only when a TCB exists and the association is not in a COOKIE-WAIT or 3013 SHUTDOWN-ACK-SENT state are the Tie-Tags populated with a value other 3014 than 0. For a normal association INIT (i.e., the endpoint is in the 3015 CLOSED state), the Tie-Tags MUST be set to 0 (indicating that no 3016 previous TCB existed). 3018 5.2.3. Unexpected INIT ACK 3020 If an INIT ACK is received by an endpoint in any state other than the 3021 COOKIE-WAIT state, the endpoint SHOULD discard the INIT ACK chunk. 3022 An unexpected INIT ACK usually indicates the processing of an old or 3023 duplicated INIT chunk. 3025 5.2.4. Handle a COOKIE ECHO when a TCB Exists 3027 When a COOKIE ECHO chunk is received by an endpoint in any state for 3028 an existing association (i.e., not in the CLOSED state) the following 3029 rules are applied: 3031 1) Compute a MAC as described in step 1 of Section 5.1.5, 3033 2) Authenticate the State Cookie as described in step 2 of 3034 Section 5.1.5 (this is case C or D above). 3036 3) Compare the timestamp in the State Cookie to the current time. 3037 If the State Cookie is older than the lifespan carried in the 3038 State Cookie and the Verification Tags contained in the State 3039 Cookie do not match the current association's Verification Tags, 3040 the packet, including the COOKIE ECHO and any DATA chunks, SHOULD 3041 be discarded. The endpoint also MUST transmit an ERROR chunk 3042 with a "Stale Cookie" error cause to the peer endpoint (this is 3043 case C or D in Section 5.2). 3045 If both Verification Tags in the State Cookie match the 3046 Verification Tags of the current association, consider the State 3047 Cookie valid (this is case E in Section 5.2) even if the lifespan 3048 is exceeded. 3050 4) If the State Cookie proves to be valid, unpack the TCB into a 3051 temporary TCB. 3053 5) Refer to Table 12 to determine the correct action to be taken. 3055 +-----------+------------+---------------+----------------+--------+ 3056 | Local Tag | Peer's Tag | Local-Tie-Tag | Peer's-Tie-Tag | Action | 3057 +-----------+------------+---------------+----------------+--------+ 3058 | X | X | M | M | (A) | 3059 +-----------+------------+---------------+----------------+--------+ 3060 | M | X | A | A | (B) | 3061 +-----------+------------+---------------+----------------+--------+ 3062 | M | 0 | A | A | (B) | 3063 +-----------+------------+---------------+----------------+--------+ 3064 | X | M | 0 | 0 | (C) | 3065 +-----------+------------+---------------+----------------+--------+ 3066 | M | M | A | A | (D) | 3067 +-----------+------------+---------------+----------------+--------+ 3069 Table 12: Handling of a COOKIE ECHO when a TCB Exists 3071 Legend: 3073 X - Tag does not match the existing TCB. 3074 M - Tag matches the existing TCB. 3075 0 - No Tie-Tag in cookie (unknown). 3076 A - All cases, i.e., M, X, or 0. 3078 For any case not shown in Table 12, the cookie SHOULD be silently 3079 discarded. 3081 Action 3082 A) In this case, the peer might have restarted. When the endpoint 3083 recognizes this potential 'restart', the existing session is 3084 treated the same as if it received an ABORT followed by a new 3085 COOKIE ECHO with the following exceptions: 3087 * Any SCTP DATA chunks MAY be retained (this is an 3088 implementation-specific option). 3090 * A notification of RESTART SHOULD be sent to the ULP instead of 3091 a "COMMUNICATION LOST" notification. 3093 All the congestion control parameters (e.g., cwnd, ssthresh) 3094 related to this peer MUST be reset to their initial values (see 3095 Section 6.2.1). 3097 After this, the endpoint enters the ESTABLISHED state. 3099 If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes 3100 that the peer has restarted (Action A), it MUST NOT set up a new 3101 association but instead resend the SHUTDOWN ACK and send an ERROR 3102 chunk with a "Cookie Received While Shutting Down" error cause to 3103 its peer. 3105 B) In this case, both sides might be attempting to start an 3106 association at about the same time, but the peer endpoint started 3107 its INIT after responding to the local endpoint's INIT. Thus, it 3108 might have picked a new Verification Tag, not being aware of the 3109 previous tag it had sent this endpoint. The endpoint SHOULD stay 3110 in or enter the ESTABLISHED state, but it MUST update its peer's 3111 Verification Tag from the State Cookie, stop any init or cookie 3112 timers that might be running, and send a COOKIE ACK. 3114 C) In this case, the local endpoint's cookie has arrived late. 3115 Before it arrived, the local endpoint sent an INIT and received 3116 an INIT ACK and finally sent a COOKIE ECHO with the peer's same 3117 tag but a new tag of its own. The cookie SHOULD be silently 3118 discarded. The endpoint SHOULD NOT change states and SHOULD 3119 leave any timers running. 3121 D) When both local and remote tags match, the endpoint SHOULD enter 3122 the ESTABLISHED state, if it is in the COOKIE-ECHOED state. It 3123 SHOULD stop any cookie timer that is running and send a COOKIE 3124 ACK. 3126 Note: The "peer's Verification Tag" is the tag received in the 3127 Initiate Tag field of the INIT or INIT ACK chunk. 3129 5.2.4.1. An Example of a Association Restart 3131 In the following example, "A" initiates the association after a 3132 restart has occurred. Endpoint "Z" had no knowledge of the restart 3133 until the exchange (i.e., Heartbeats had not yet detected the failure 3134 of "A") (assuming no bundling or fragmentation occurs): 3136 Endpoint A Endpoint Z 3137 <-------------- Association is established----------------------> 3138 Tag=Tag_A Tag=Tag_Z 3139 <---------------------------------------------------------------> 3140 {A crashes and restarts} 3141 {app sets up a association with Z} 3142 (build TCB) 3143 INIT [I-Tag=Tag_A' 3144 & other info] --------\ 3145 (Start T1-init timer) \ 3146 (Enter COOKIE-WAIT state) \---> (find an existing TCB 3147 compose temp TCB and Cookie_Z 3148 with Tie-Tags to previous 3149 association) 3150 /--- INIT ACK [Veri Tag=Tag_A', 3151 / I-Tag=Tag_Z', 3152 (Cancel T1-init timer) <------/ Cookie_Z[TieTags= 3153 Tag_A,Tag_Z 3154 & other info] 3155 (destroy temp TCB,leave original 3156 in place) 3157 COOKIE ECHO [Veri=Tag_Z', 3158 Cookie_Z 3159 Tie=Tag_A, 3160 Tag_Z]----------\ 3161 (Start T1-init timer) \ 3162 (Enter COOKIE-ECHOED state) \---> (Find existing association, 3163 Tie-Tags match old tags, 3164 Tags do not match, i.e., 3165 case X X M M above, 3166 Announce Restart to ULP 3167 and reset association). 3168 /---- COOKIE ACK 3169 (Cancel T1-init timer, <------/ 3170 Enter ESTABLISHED state) 3171 {app sends 1st user data; strm 0} 3172 DATA [TSN=initial TSN_A 3173 Strm=0,Seq=0 & user data]--\ 3174 (Start T3-rtx timer) \ 3175 \-> 3176 /--- SACK [TSN Ack=init TSN_A,Block=0] 3177 (Cancel T3-rtx timer) <------/ 3179 Figure 5: A Restart Example 3181 5.2.5. Handle Duplicate COOKIE ACK 3183 At any state other than COOKIE-ECHOED, an endpoint SHOULD silently 3184 discard a received COOKIE ACK chunk. 3186 5.2.6. Handle Stale COOKIE Error 3188 Receipt of an ERROR chunk with a "Stale Cookie" error cause indicates 3189 one of a number of possible events: 3191 A) The association failed to completely setup before the State 3192 Cookie issued by the sender was processed. 3194 B) An old State Cookie was processed after setup completed. 3196 C) An old State Cookie is received from someone that the receiver is 3197 not interested in having an association with and the ABORT chunk 3198 was lost. 3200 When processing an ERROR chunk with a "Stale Cookie" error cause an 3201 endpoint SHOULD first examine if an association is in the process of 3202 being set up, i.e., the association is in the COOKIE-ECHOED state. 3203 In all cases, if the association is not in the COOKIE-ECHOED state, 3204 the ERROR chunk SHOULD be silently discarded. 3206 If the association is in the COOKIE-ECHOED state, the endpoint MAY 3207 elect one of the following three alternatives. 3209 1) Send a new INIT chunk to the endpoint to generate a new State 3210 Cookie and reattempt the setup procedure. 3212 2) Discard the TCB and report to the upper layer the inability to 3213 set up the association. 3215 3) Send a new INIT chunk to the endpoint, adding a Cookie 3216 Preservative parameter requesting an extension to the life time 3217 of the State Cookie. When calculating the time extension, an 3218 implementation SHOULD use the RTT information measured based on 3219 the previous COOKIE ECHO / ERROR exchange, and SHOULD add no more 3220 than 1 second beyond the measured RTT, due to long State Cookie 3221 life times making the endpoint more subject to a replay attack. 3223 5.3. Other Initialization Issues 3224 5.3.1. Selection of Tag Value 3226 Initiate Tag values SHOULD be selected from the range of 1 to 2**32 - 3227 1. It is very important that the Initiate Tag value be randomized to 3228 help protect against "man in the middle" and "sequence number" 3229 attacks. The methods described in [RFC4086] can be used for the 3230 Initiate Tag randomization. Careful selection of Initiate Tags is 3231 also necessary to prevent old duplicate packets from previous 3232 associations being mistakenly processed as belonging to the current 3233 association. 3235 Moreover, the Verification Tag value used by either endpoint in a 3236 given association MUST NOT change during the life time of an 3237 association. A new Verification Tag value MUST be used each time the 3238 endpoint tears down and then reestablishes an association to the same 3239 peer. 3241 5.4. Path Verification 3243 During association establishment, the two peers exchange a list of 3244 addresses. In the predominant case, these lists accurately represent 3245 the addresses owned by each peer. However, it is possible that a 3246 misbehaving peer might supply addresses that it does not own. To 3247 prevent this, the following rules are applied to all addresses of the 3248 new association: 3250 1) Any addresses passed to the sender of the INIT by its upper layer 3251 in the request to initialize an association are automatically 3252 considered to be CONFIRMED. 3254 2) For the receiver of the COOKIE ECHO, the only CONFIRMED address 3255 is the address to which the INIT ACK was sent. 3257 3) All other addresses not covered by rules 1 and 2 are considered 3258 UNCONFIRMED and are subject to probing for verification. 3260 To probe an address for verification, an endpoint will send 3261 HEARTBEATs including a 64-bit random nonce and a path indicator (to 3262 identify the address that the HEARTBEAT is sent to) within the 3263 HEARTBEAT parameter. 3265 Upon receipt of the HEARTBEAT ACK, a verification is made that the 3266 nonce included in the HEARTBEAT parameter is the one sent to the 3267 address indicated inside the HEARTBEAT parameter. When this match 3268 occurs, the address that the original HEARTBEAT was sent to is now 3269 considered CONFIRMED and available for normal data transfer. 3271 These probing procedures are started when an association moves to the 3272 ESTABLISHED state and are ended when all paths are confirmed. 3274 In each RTO, a probe MAY be sent on an active UNCONFIRMED path in an 3275 attempt to move it to the CONFIRMED state. If during this probing 3276 the path becomes inactive, this rate is lowered to the normal 3277 HEARTBEAT rate. At the expiration of the RTO timer, the error 3278 counter of any path that was probed but not CONFIRMED is incremented 3279 by one and subjected to path failure detection, as defined in 3280 Section 8.2. When probing UNCONFIRMED addresses, however, the 3281 association overall error count is not incremented. 3283 The number of HEARTBEATS sent at each RTO SHOULD be limited by the 3284 'HB.Max.Burst' parameter. It is an implementation decision as to how 3285 to distribute HEARTBEATS to the peer's addresses for path 3286 verification. 3288 Whenever a path is confirmed, an indication MAY be given to the upper 3289 layer. 3291 An endpoint MUST NOT send any chunks to an UNCONFIRMED address, with 3292 the following exceptions: 3294 * A HEARTBEAT including a nonce MAY be sent to an UNCONFIRMED 3295 address. 3297 * A HEARTBEAT ACK MAY be sent to an UNCONFIRMED address. 3299 * A COOKIE ACK MAY be sent to an UNCONFIRMED address, but it MUST be 3300 bundled with a HEARTBEAT including a nonce. An implementation 3301 that does not support bundling MUST NOT send a COOKIE ACK to an 3302 UNCONFIRMED address. 3304 * A COOKIE ECHO MAY be sent to an UNCONFIRMED address, but it MUST 3305 be bundled with a HEARTBEAT including a nonce, and the packet MUST 3306 NOT exceed the path MTU. If the implementation does not support 3307 bundling or if the bundled COOKIE ECHO plus HEARTBEAT (including 3308 nonce) would exceed the path MTU, then the implementation MUST NOT 3309 send a COOKIE ECHO to an UNCONFIRMED address. 3311 6. User Data Transfer 3313 Data transmission MUST only happen in the ESTABLISHED, SHUTDOWN- 3314 PENDING, and SHUTDOWN-RECEIVED states. The only exception to this is 3315 that DATA chunks are allowed to be bundled with an outbound COOKIE 3316 ECHO chunk when in the COOKIE-WAIT state. 3318 DATA chunks MUST only be received according to the rules below in 3319 ESTABLISHED, SHUTDOWN-PENDING, and SHUTDOWN-SENT. A DATA chunk 3320 received in CLOSED is out of the blue and SHOULD be handled per 3321 Section 8.4. A DATA chunk received in any other state SHOULD be 3322 discarded. 3324 A SACK MUST be processed in ESTABLISHED, SHUTDOWN-PENDING, and 3325 SHUTDOWN-RECEIVED. An incoming SACK MAY be processed in COOKIE- 3326 ECHOED. A SACK in the CLOSED state is out of the blue and SHOULD be 3327 processed according to the rules in Section 8.4. A SACK chunk 3328 received in any other state SHOULD be discarded. 3330 An SCTP receiver MUST be able to receive a minimum of 1500 bytes in 3331 one SCTP packet. This means that an SCTP endpoint MUST NOT indicate 3332 less than 1500 bytes in its initial a_rwnd sent in the INIT or INIT 3333 ACK. 3335 For transmission efficiency, SCTP defines mechanisms for bundling of 3336 small user messages and fragmentation of large user messages. The 3337 following diagram depicts the flow of user messages through SCTP. 3339 In this section, the term "data sender" refers to the endpoint that 3340 transmits a DATA chunk and the term "data receiver" refers to the 3341 endpoint that receives a DATA chunk. A data receiver will transmit 3342 SACK chunks. 3344 +--------------------------+ 3345 | User Messages | 3346 +--------------------------+ 3347 SCTP user ^ | 3348 ==================|==|======================================= 3349 | v (1) 3350 +------------------+ +--------------------+ 3351 | SCTP DATA Chunks | |SCTP Control Chunks | 3352 +------------------+ +--------------------+ 3353 ^ | ^ | 3354 | v (2) | v (2) 3355 +--------------------------+ 3356 | SCTP packets | 3357 +--------------------------+ 3358 SCTP ^ | 3359 ===========================|==|=========================== 3360 | v 3361 Connectionless Packet Transfer Service (e.g., IP) 3363 Figure 6: Illustration of User Data Transfer 3365 The following applies: 3367 1) When converting user messages into DATA chunks, an endpoint will 3368 fragment user messages larger than the current association path 3369 MTU into multiple DATA chunks. The data receiver will normally 3370 reassemble the fragmented message from DATA chunks before 3371 delivery to the user (see Section 6.9 for details). 3373 2) Multiple DATA and control chunks MAY be bundled by the sender 3374 into a single SCTP packet for transmission, as long as the final 3375 size of the packet does not exceed the current path MTU. The 3376 receiver will unbundle the packet back into the original chunks. 3377 Control chunks MUST come before DATA chunks in the packet. 3379 The fragmentation and bundling mechanisms, as detailed in Section 6.9 3380 and Section 6.10, are OPTIONAL to implement by the data sender, but 3381 they MUST be implemented by the data receiver, i.e., an endpoint MUST 3382 properly receive and process bundled or fragmented data. 3384 6.1. Transmission of DATA Chunks 3386 This document is specified as if there is a single retransmission 3387 timer per destination transport address, but implementations MAY have 3388 a retransmission timer for each DATA chunk. 3390 The following general rules MUST be applied by the data sender for 3391 transmission and/or retransmission of outbound DATA chunks: 3393 A) At any given time, the data sender MUST NOT transmit new data to 3394 any destination transport address if its peer's rwnd indicates 3395 that the peer has no buffer space (i.e., rwnd is smaller than the 3396 size of the next DATA chunk; see Section 6.2.1). 3398 When the receiver has no buffer space, this probe is called a 3399 zero window probe. A zero window probe SHOULD only be sent when 3400 all outstanding DATA chunks have been cumulatively acknowledged 3401 and no DATA chunks are in flight. Zero window probing MUST be 3402 supported. 3404 If the sender continues to receive SACKs from the peer while 3405 doing zero window probing, the unacknowledged window probes 3406 SHOULD NOT increment the error counter for the association or any 3407 destination transport address. This is because the receiver 3408 could keep its window closed for an indefinite time. Section 6.2 3409 describes the receiver behavior when it advertises a zero window. 3410 The sender SHOULD send the first zero window probe after 1 RTO 3411 when it detects that the receiver has closed its window and 3412 SHOULD increase the probe interval exponentially afterwards. 3413 Also note that the cwnd SHOULD be adjusted according to 3414 Section 7.2.1. Zero window probing does not affect the 3415 calculation of cwnd. 3417 The sender MUST also have an algorithm for sending new DATA 3418 chunks to avoid silly window syndrome (SWS) as described in 3419 [RFC1122]. The algorithm can be similar to the one described in 3420 Section 4.2.3.4 of [RFC1122]. 3422 However, regardless of the value of rwnd (including if it is 0), 3423 the data sender can always have one DATA chunk in flight to the 3424 receiver if allowed by cwnd (see rule B below). This rule allows 3425 the sender to probe for a change in rwnd that the sender missed 3426 due to the SACK having been lost in transit from the data 3427 receiver to the data sender. 3429 B) At any given time, the sender MUST NOT transmit new data to a 3430 given transport address if it has cwnd + (PMTU - 1) or more bytes 3431 of data outstanding to that transport address. If data is 3432 available, the sender SHOULD exceed cwnd by up to (PMTU - 1) 3433 bytes on a new data transmission if the flightsize does not 3434 currently reach cwnd. The breach of cwnd MUST constitute one 3435 packet only. 3437 C) When the time comes for the sender to transmit, before sending 3438 new DATA chunks, the sender MUST first transmit any DATA chunks 3439 that are marked for retransmission (limited by the current cwnd). 3441 D) When the time comes for the sender to transmit new DATA chunks, 3442 the protocol parameter 'Max.Burst' SHOULD be used to limit the 3443 number of packets sent. The limit MAY be applied by adjusting 3444 cwnd temporarily, as follows: 3446 if ((flightsize + Max.Burst * MTU) < cwnd) 3447 cwnd = flightsize + Max.Burst * MTU; 3449 Or, it MAY be applied by strictly limiting the number of packets 3450 emitted by the output routine. When calculating the number of 3451 packets to transmit, and particularly when using the formula 3452 above, cwnd SHOULD NOT be changed permanently. 3454 E) Then, the sender can send out as many new DATA chunks as rule A 3455 and rule B allow. 3457 Multiple DATA chunks committed for transmission MAY be bundled in a 3458 single packet. Furthermore, DATA chunks being retransmitted MAY be 3459 bundled with new DATA chunks, as long as the resulting packet size 3460 does not exceed the path MTU. A ULP can request that no bundling is 3461 performed, but this only turns off any delays that an SCTP 3462 implementation might be using to increase bundling efficiency. It 3463 does not in itself stop all bundling from occurring (i.e., in case of 3464 congestion or retransmission). 3466 Before an endpoint transmits a DATA chunk, if any received DATA 3467 chunks have not been acknowledged (e.g., due to delayed ack), the 3468 sender SHOULD create a SACK and bundle it with the outbound DATA 3469 chunk, as long as the size of the final SCTP packet does not exceed 3470 the current MTU. See Section 6.2. 3472 When the window is full (i.e., transmission is disallowed by rule A 3473 and/or rule B), the sender MAY still accept send requests from its 3474 upper layer, but MUST transmit no more DATA chunks until some or all 3475 of the outstanding DATA chunks are acknowledged and transmission is 3476 allowed by rule A and rule B again. 3478 Whenever a transmission or retransmission is made to any address, if 3479 the T3-rtx timer of that address is not currently running, the sender 3480 MUST start that timer. If the timer for that address is already 3481 running, the sender MUST restart the timer if the earliest (i.e., 3482 lowest TSN) outstanding DATA chunk sent to that address is being 3483 retransmitted. Otherwise, the data sender MUST NOT restart the 3484 timer. 3486 When starting or restarting the T3-rtx timer, the timer value SHOULD 3487 be adjusted according to the timer rules defined in Section 6.3.2 and 3488 Section 6.3.3. 3490 The data sender SHOULD NOT use a TSN that is more than 2**31 - 1 3491 above the beginning TSN of the current send window. 3493 For each stream, the data sender SHOULD NOT have more than 2**16 - 1 3494 ordered user messages in the current send window. 3496 Whenever the sender of a DATA chunk can benefit from the 3497 corresponding SACK chunk being sent back without delay, the sender 3498 MAY set the I bit in the DATA chunk header. Please note that why the 3499 sender has set the I bit is irrelevant to the receiver. 3501 Reasons for setting the I bit include, but are not limited to, the 3502 following (see Section 4 of [RFC7053] for a discussion of the 3503 benefits): 3505 * The application requests that the I bit of the last DATA chunk of 3506 a user message be set when providing the user message to the SCTP 3507 implementation (see Section 11.1). 3509 * The sender is in the SHUTDOWN-PENDING state. 3511 * The sending of a DATA chunk fills the congestion or receiver 3512 window. 3514 6.2. Acknowledgement on Reception of DATA Chunks 3516 The SCTP endpoint MUST always acknowledge the reception of each valid 3517 DATA chunk when the DATA chunk received is inside its receive window. 3519 When the receiver's advertised window is 0, the receiver MUST drop 3520 any new incoming DATA chunk with a TSN larger than the largest TSN 3521 received so far. If the new incoming DATA chunk holds a TSN value 3522 less than the largest TSN received so far, then the receiver SHOULD 3523 drop the largest TSN held for reordering and accept the new incoming 3524 DATA chunk. In either case, if such a DATA chunk is dropped, the 3525 receiver MUST immediately send back a SACK with the current receive 3526 window showing only DATA chunks received and accepted so far. The 3527 dropped DATA chunk(s) MUST NOT be included in the SACK, as they were 3528 not accepted. The receiver MUST also have an algorithm for 3529 advertising its receive window to avoid receiver silly window 3530 syndrome (SWS), as described in [RFC1122]. The algorithm can be 3531 similar to the one described in Section 4.2.3.3 of [RFC1122]. 3533 The guidelines on delayed acknowledgement algorithm specified in 3534 Section 4.2 of [RFC5681] SHOULD be followed. Specifically, an 3535 acknowledgement SHOULD be generated for at least every second packet 3536 (not every second DATA chunk) received, and SHOULD be generated 3537 within 200 ms of the arrival of any unacknowledged DATA chunk. In 3538 some situations, it might be beneficial for an SCTP transmitter to be 3539 more conservative than the algorithms detailed in this document 3540 allow. However, an SCTP transmitter MUST NOT be more aggressive than 3541 the following algorithms allow. 3543 An SCTP receiver MUST NOT generate more than one SACK for every 3544 incoming packet, other than to update the offered window as the 3545 receiving application consumes new data. When the window opens up, 3546 an SCTP receiver SHOULD send additional SACK chunks to update the 3547 window even if no new data is received. The receiver MUST avoid 3548 sending a large number of window updates -- in particular, large 3549 bursts of them. One way to achieve this is to send a window update 3550 only if the window can be increased by at least a quarter of the 3551 receive buffer size of the association. 3553 IMPLEMENTATION NOTE: The maximum delay for generating an 3554 acknowledgement MAY be configured by the SCTP administrator, either 3555 statically or dynamically, in order to meet the specific timing 3556 requirement of the protocol being carried. 3558 An implementation MUST NOT allow the maximum delay (protocol 3559 parameter 'SACK.Delay') to be configured to be more than 500 ms. In 3560 other words, an implementation MAY lower the value of 'SACK.Delay' 3561 below 500 ms but MUST NOT raise it above 500 ms. 3563 Acknowledgements MUST be sent in SACK chunks unless shutdown was 3564 requested by the ULP, in which case an endpoint MAY send an 3565 acknowledgement in the SHUTDOWN chunk. A SACK chunk can acknowledge 3566 the reception of multiple DATA chunks. See Section 3.3.4 for SACK 3567 chunk format. In particular, the SCTP endpoint MUST fill in the 3568 Cumulative TSN Ack field to indicate the latest sequential TSN (of a 3569 valid DATA chunk) it has received. Any received DATA chunks with TSN 3570 greater than the value in the Cumulative TSN Ack field are reported 3571 in the Gap Ack Block fields. The SCTP endpoint MUST report as many 3572 Gap Ack Blocks as can fit in a single SACK chunk limited by the 3573 current path MTU. 3575 The SHUTDOWN chunk does not contain Gap Ack Block fields. Therefore, 3576 the endpoint SHOULD use a SACK instead of the SHUTDOWN chunk to 3577 acknowledge DATA chunks received out of order. 3579 Upon receipt of an SCTP packet containing a DATA chunk with the I bit 3580 set, the receiver SHOULD NOT delay the sending of the corresponding 3581 SACK chunk, i.e., the receiver SHOULD immediately respond with the 3582 corresponding SACK chunk. 3584 When a packet arrives with duplicate DATA chunk(s) and with no new 3585 DATA chunk(s), the endpoint MUST immediately send a SACK with no 3586 delay. If a packet arrives with duplicate DATA chunk(s) bundled with 3587 new DATA chunks, the endpoint MAY immediately send a SACK. Normally, 3588 receipt of duplicate DATA chunks will occur when the original SACK 3589 chunk was lost and the peer's RTO has expired. The duplicate TSN 3590 number(s) SHOULD be reported in the SACK as duplicate. 3592 When an endpoint receives a SACK, it MAY use the duplicate TSN 3593 information to determine if SACK loss is occurring. Further use of 3594 this data is for future study. 3596 The data receiver is responsible for maintaining its receive buffers. 3597 The data receiver SHOULD notify the data sender in a timely manner of 3598 changes in its ability to receive data. How an implementation 3599 manages its receive buffers is dependent on many factors (e.g., 3600 operating system, memory management system, amount of memory, etc.). 3601 However, the data sender strategy defined in Section 6.2.1 is based 3602 on the assumption of receiver operation similar to the following: 3604 A) At initialization of the association, the endpoint tells the peer 3605 how much receive buffer space it has allocated to the association 3606 in the INIT or INIT ACK. The endpoint sets a_rwnd to this value. 3608 B) As DATA chunks are received and buffered, decrement a_rwnd by the 3609 number of bytes received and buffered. This is, in effect, 3610 closing rwnd at the data sender and restricting the amount of 3611 data it can transmit. 3613 C) As DATA chunks are delivered to the ULP and released from the 3614 receive buffers, increment a_rwnd by the number of bytes 3615 delivered to the upper layer. This is, in effect, opening up 3616 rwnd on the data sender and allowing it to send more data. The 3617 data receiver SHOULD NOT increment a_rwnd unless it has released 3618 bytes from its receive buffer. For example, if the receiver is 3619 holding fragmented DATA chunks in a reassembly queue, it SHOULD 3620 NOT increment a_rwnd. 3622 D) When sending a SACK, the data receiver SHOULD place the current 3623 value of a_rwnd into the a_rwnd field. The data receiver SHOULD 3624 take into account that the data sender will not retransmit DATA 3625 chunks that are acked via the Cumulative TSN Ack (i.e., will drop 3626 from its retransmit queue). 3628 Under certain circumstances, the data receiver MAY drop DATA chunks 3629 that it has received but has not released from its receive buffers 3630 (i.e., delivered to the ULP). These DATA chunks might have been 3631 acked in Gap Ack Blocks. For example, the data receiver might be 3632 holding data in its receive buffers while reassembling a fragmented 3633 user message from its peer when it runs out of receive buffer space. 3634 It MAY drop these DATA chunks even though it has acknowledged them in 3635 Gap Ack Blocks. If a data receiver drops DATA chunks, it MUST NOT 3636 include them in Gap Ack Blocks in subsequent SACKs until they are 3637 received again via retransmission. In addition, the endpoint SHOULD 3638 take into account the dropped data when calculating its a_rwnd. 3640 An endpoint SHOULD NOT revoke a SACK and discard data. Only in 3641 extreme circumstances might an endpoint use this procedure (such as 3642 out of buffer space). The data receiver SHOULD take into account 3643 that dropping data that has been acked in Gap Ack Blocks can result 3644 in suboptimal retransmission strategies in the data sender and thus 3645 in suboptimal performance. 3647 The following example illustrates the use of delayed 3648 acknowledgements: 3650 Endpoint A Endpoint Z 3652 {App sends 3 messages; strm 0} 3653 DATA [TSN=7,Strm=0,Seq=3] ------------> (ack delayed) 3654 (Start T3-rtx timer) 3656 DATA [TSN=8,Strm=0,Seq=4] ------------> (send ack) 3657 /------- SACK [TSN Ack=8,block=0] 3658 (cancel T3-rtx timer) <-----/ 3660 DATA [TSN=9,Strm=0,Seq=5] ------------> (ack delayed) 3661 (Start T3-rtx timer) 3662 ... 3663 {App sends 1 message; strm 1} 3664 (bundle SACK with DATA) 3665 /----- SACK [TSN Ack=9,block=0] \ 3666 / DATA [TSN=6,Strm=1,Seq=2] 3667 (cancel T3-rtx timer) <------/ (Start T3-rtx timer) 3669 (ack delayed) 3670 (send ack) 3671 SACK [TSN Ack=6,block=0] -------------> (cancel T3-rtx timer) 3673 Figure 7: Delayed Acknowledgement Example 3675 If an endpoint receives a DATA chunk with no user data (i.e., the 3676 Length field is set to 16), it MUST send an ABORT with error cause 3677 set to "No User Data". 3679 An endpoint SHOULD NOT send a DATA chunk with no user data part. 3680 This avoids the need to be able to return a zero-length user message 3681 in the API, especially in the socket API as specified in [RFC6458] 3682 for details. 3684 6.2.1. Processing a Received SACK 3686 Each SACK an endpoint receives contains an a_rwnd value. This value 3687 represents the amount of buffer space the data receiver, at the time 3688 of transmitting the SACK, has left of its total receive buffer space 3689 (as specified in the INIT/INIT ACK). Using a_rwnd, Cumulative TSN 3690 Ack, and Gap Ack Blocks, the data sender can develop a representation 3691 of the peer's receive buffer space. 3693 One of the problems the data sender takes into account when 3694 processing a SACK is that a SACK can be received out of order. That 3695 is, a SACK sent by the data receiver can pass an earlier SACK and be 3696 received first by the data sender. If a SACK is received out of 3697 order, the data sender can develop an incorrect view of the peer's 3698 receive buffer space. 3700 Since there is no explicit identifier that can be used to detect out- 3701 of-order SACKs, the data sender uses heuristics to determine if a 3702 SACK is new. 3704 An endpoint SHOULD use the following rules to calculate the rwnd, 3705 using the a_rwnd value, the Cumulative TSN Ack, and Gap Ack Blocks in 3706 a received SACK. 3708 A) At the establishment of the association, the endpoint initializes 3709 the rwnd to the Advertised Receiver Window Credit (a_rwnd) the 3710 peer specified in the INIT or INIT ACK. 3712 B) Any time a DATA chunk is transmitted (or retransmitted) to a 3713 peer, the endpoint subtracts the data size of the chunk from the 3714 rwnd of that peer. 3716 C) Any time a DATA chunk is marked for retransmission, either via 3717 T3-rtx timer expiration (Section 6.3.3) or via Fast Retransmit 3718 (Section 7.2.4), add the data size of those chunks to the rwnd. 3720 Note: If the implementation is maintaining a timer on each DATA 3721 chunk, then only DATA chunks whose timer expired would be marked 3722 for retransmission. 3724 D) Any time a SACK arrives, the endpoint performs the following: 3726 i) If Cumulative TSN Ack is less than the Cumulative TSN Ack 3727 Point, then drop the SACK. Since Cumulative TSN Ack is 3728 monotonically increasing, a SACK whose Cumulative TSN Ack 3729 is less than the Cumulative TSN Ack Point indicates an out- 3730 of-order SACK. 3732 ii) Set rwnd equal to the newly received a_rwnd minus the 3733 number of bytes still outstanding after processing the 3734 Cumulative TSN Ack and the Gap Ack Blocks. 3736 iii) If the SACK is missing a TSN that was previously 3737 acknowledged via a Gap Ack Block (e.g., the data receiver 3738 reneged on the data), then consider the corresponding DATA 3739 that might be possibly missing: Count one miss indication 3740 towards Fast Retransmit as described in Section 7.2.4, and 3741 if no retransmit timer is running for the destination 3742 address to which the DATA chunk was originally transmitted, 3743 then T3-rtx is started for that destination address. 3745 iv) If the Cumulative TSN Ack matches or exceeds the Fast 3746 Recovery exitpoint (Section 7.2.4), Fast Recovery is 3747 exited. 3749 6.3. Management of Retransmission Timer 3751 An SCTP endpoint uses a retransmission timer T3-rtx to ensure data 3752 delivery in the absence of any feedback from its peer. The duration 3753 of this timer is referred to as RTO (retransmission timeout). 3755 When an endpoint's peer is multi-homed, the endpoint will calculate a 3756 separate RTO for each different destination transport address of its 3757 peer endpoint. 3759 The computation and management of RTO in SCTP follow closely how TCP 3760 manages its retransmission timer. To compute the current RTO, an 3761 endpoint maintains two state variables per destination transport 3762 address: SRTT (smoothed round-trip time) and RTTVAR (round-trip time 3763 variation). 3765 6.3.1. RTO Calculation 3767 The rules governing the computation of SRTT, RTTVAR, and RTO are as 3768 follows: 3770 C1) Until an RTT measurement has been made for a packet sent to the 3771 given destination transport address, set RTO to the protocol 3772 parameter 'RTO.Initial'. 3774 C2) When the first RTT measurement R is made, set 3776 SRTT <- R, 3777 RTTVAR <- R/2, and 3778 RTO <- SRTT + 4 * RTTVAR. 3780 C3) When a new RTT measurement R' is made, set: 3782 RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| 3783 SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' 3785 Note: The value of SRTT used in the update to RTTVAR is its 3786 value before updating SRTT itself using the second assignment. 3788 After the computation, update 3790 RTO <- SRTT + 4 * RTTVAR. 3792 C4) When data is in flight and when allowed by rule C5 below, a new 3793 RTT measurement MUST be made each round trip. Furthermore, new 3794 RTT measurements SHOULD be made no more than once per round trip 3795 for a given destination transport address. There are two 3796 reasons for this recommendation: First, it appears that 3797 measuring more frequently often does not in practice yield any 3798 significant benefit [ALLMAN99]; second, if measurements are made 3799 more often, then the values of 'RTO.Alpha' and 'RTO.Beta' in 3800 rule C3 above SHOULD be adjusted so that SRTT and RTTVAR still 3801 adjust to changes at roughly the same rate (in terms of how many 3802 round trips it takes them to reflect new values) as they would 3803 if making only one measurement per round-trip and using 3804 'RTO.Alpha' and 'RTO.Beta' as given in rule C3. However, the 3805 exact nature of these adjustments remains a research issue. 3807 C5) Karn's algorithm: RTT measurements MUST NOT be made using 3808 packets that were retransmitted (and thus for which it is 3809 ambiguous whether the reply was for the first instance of the 3810 chunk or for a later instance). 3812 RTT measurements SHOULD only be made using a chunk with TSN r if 3813 no chunk with TSN less than or equal to r is retransmitted since 3814 r is first sent. 3816 C6) Whenever RTO is computed, if it is less than 'RTO.Min' seconds 3817 then it is rounded up to 'RTO.Min' seconds. The reason for this 3818 rule is that RTOs that do not have a high minimum value are 3819 susceptible to unnecessary timeouts [ALLMAN99]. 3821 C7) A maximum value MAY be placed on RTO provided it is at least 3822 'RTO.max' seconds. 3824 There is no requirement for the clock granularity G used for 3825 computing RTT measurements and the different state variables, other 3826 than: 3828 G1) Whenever RTTVAR is computed, if RTTVAR = 0, then adjust RTTVAR 3829 <- G. 3831 Experience [ALLMAN99] has shown that finer clock granularities (<= 3832 100 msec) perform somewhat better than more coarse granularities. 3834 6.3.2. Retransmission Timer Rules 3836 The rules for managing the retransmission timer are as follows: 3838 R1) Every time a DATA chunk is sent to any address (including a 3839 retransmission), if the T3-rtx timer of that address is not 3840 running, start it running so that it will expire after the RTO 3841 of that address. The RTO used here is that obtained after any 3842 doubling due to previous T3-rtx timer expirations on the 3843 corresponding destination address as discussed in rule E2 below. 3845 R2) Whenever all outstanding data sent to an address have been 3846 acknowledged, turn off the T3-rtx timer of that address. 3848 R3) Whenever a SACK is received that acknowledges the DATA chunk 3849 with the earliest outstanding TSN for that address, restart the 3850 T3-rtx timer for that address with its current RTO (if there is 3851 still outstanding data on that address). 3853 R4) Whenever a SACK is received missing a TSN that was previously 3854 acknowledged via a Gap Ack Block, start the T3-rtx for the 3855 destination address to which the DATA chunk was originally 3856 transmitted if it is not already running. 3858 The following example shows the use of various timer rules (assuming 3859 that the receiver uses delayed acks). 3861 Endpoint A Endpoint Z 3862 {App begins to send} 3863 Data [TSN=7,Strm=0,Seq=3] ------------> (ack delayed) 3864 (Start T3-rtx timer) 3865 {App sends 1 message; strm 1} 3866 (bundle ack with data) 3867 DATA [TSN=8,Strm=0,Seq=4] ----\ /-- SACK [TSN Ack=7,Block=0] 3868 \ / DATA [TSN=6,Strm=1,Seq=2] 3869 \ / (Start T3-rtx timer) 3870 \ 3871 / \ 3872 (Restart T3-rtx timer) <------/ \--> (ack delayed) 3873 (ack delayed) 3874 {send ack} 3875 SACK [TSN Ack=6,Block=0] --------------> (Cancel T3-rtx timer) 3876 .. 3877 (send ack) 3878 (Cancel T3-rtx timer) <-------------- SACK [TSN Ack=8,Block=0] 3880 Figure 8: Timer Rule Examples 3882 6.3.3. Handle T3-rtx Expiration 3884 Whenever the retransmission timer T3-rtx expires for a destination 3885 address, do the following: 3887 E1) For the destination address for which the timer expires, adjust 3888 its ssthresh with rules defined in Section 7.2.3 and set the 3889 cwnd <- MTU. 3891 E2) For the destination address for which the timer expires, set RTO 3892 <- RTO * 2 ("back off the timer"). The maximum value discussed 3893 in rule C7 above ('RTO.max') MAY be used to provide an upper 3894 bound to this doubling operation. 3896 E3) Determine how many of the earliest (i.e., lowest TSN) 3897 outstanding DATA chunks for the address for which the T3-rtx has 3898 expired will fit into a single packet, subject to the MTU 3899 constraint for the path corresponding to the destination 3900 transport address to which the retransmission is being sent 3901 (this might be different from the address for which the timer 3902 expires; see Section 6.4). Call this value K. Bundle and 3903 retransmit those K DATA chunks in a single packet to the 3904 destination endpoint. 3906 E4) Start the retransmission timer T3-rtx on the destination address 3907 to which the retransmission is sent, if rule R1 above indicates 3908 to do so. The RTO to be used for starting T3-rtx SHOULD be the 3909 one for the destination address to which the retransmission is 3910 sent, which, when the receiver is multi-homed, might be 3911 different from the destination address for which the timer 3912 expired (see Section 6.4 below). 3914 After retransmitting, once a new RTT measurement is obtained (which 3915 can happen only when new data has been sent and acknowledged, per 3916 rule C5, or for a measurement made from a HEARTBEAT; see 3917 Section 8.3), the computation in rule C3 is performed, including the 3918 computation of RTO, which might result in "collapsing" RTO back down 3919 after it has been subject to doubling (rule E2). 3921 Any DATA chunks that were sent to the address for which the T3-rtx 3922 timer expired but did not fit in one MTU (rule E3 above) SHOULD be 3923 marked for retransmission and sent as soon as cwnd allows (normally, 3924 when a SACK arrives). 3926 The final rule for managing the retransmission timer concerns 3927 failover (see Section 6.4.1): 3929 F1) Whenever an endpoint switches from the current destination 3930 transport address to a different one, the current retransmission 3931 timers are left running. As soon as the endpoint transmits a 3932 packet containing DATA chunk(s) to the new transport address, 3933 start the timer on that transport address, using the RTO value 3934 of the destination address to which the data is being sent, if 3935 rule R1 indicates to do so. 3937 6.4. Multi-Homed SCTP Endpoints 3939 An SCTP endpoint is considered multi-homed if there are more than one 3940 transport address that can be used as a destination address to reach 3941 that endpoint. 3943 Moreover, the ULP of an endpoint selects one of the multiple 3944 destination addresses of a multi-homed peer endpoint as the primary 3945 path (see Section 5.1.2 and Section 11.1 for details). 3947 By default, an endpoint SHOULD always transmit to the primary path, 3948 unless the SCTP user explicitly specifies the destination transport 3949 address (and possibly source transport address) to use. 3951 An endpoint SHOULD transmit reply chunks (e.g., INIT ACK, COOKIE ACK, 3952 HEARTBEAT ACK) in response to control chunks to the same destination 3953 transport address from which it received the control chunk to which 3954 it is replying. 3956 The selection of the destination transport address for packets 3957 containing SACK chunks is implementation dependent. However, an 3958 endpoint SHOULD NOT vary the destination transport address of a SACK 3959 when it receives DATA chunks coming from the same source address. 3961 When acknowledging multiple DATA chunks received in packets from 3962 different source addresses in a single SACK, the SACK chunk MAY be 3963 transmitted to one of the destination transport addresses from which 3964 the DATA or control chunks being acknowledged were received. 3966 When a receiver of a duplicate DATA chunk sends a SACK to a multi- 3967 homed endpoint, it MAY be beneficial to vary the destination address 3968 and not use the source address of the DATA chunk. The reason is that 3969 receiving a duplicate from a multi-homed endpoint might indicate that 3970 the return path (as specified in the source address of the DATA 3971 chunk) for the SACK is broken. 3973 Furthermore, when its peer is multi-homed, an endpoint SHOULD try to 3974 retransmit a chunk that timed out to an active destination transport 3975 address that is different from the last destination address to which 3976 the chunk was sent. 3978 When its peer is multi-homed, an endpoint SHOULD send fast 3979 retransmissions to the same destination transport address to which 3980 the original data was sent. If the primary path has been changed and 3981 the original data was sent to the old primary path before the Fast 3982 Retransmit, the implementation MAY send it to the new primary path. 3984 Retransmissions do not affect the total outstanding data count. 3985 However, if the DATA chunk is retransmitted onto a different 3986 destination address, both the outstanding data counts on the new 3987 destination address and the old destination address to which the data 3988 chunk was last sent is adjusted accordingly. 3990 6.4.1. Failover from an Inactive Destination Address 3992 Some of the transport addresses of a multi-homed SCTP endpoint might 3993 become inactive due to either the occurrence of certain error 3994 conditions (see Section 8.2) or adjustments from the SCTP user. 3996 When there is outbound data to send and the primary path becomes 3997 inactive (e.g., due to failures), or where the SCTP user explicitly 3998 requests to send data to an inactive destination transport address, 3999 before reporting an error to its ULP, the SCTP endpoint SHOULD try to 4000 send the data to an alternate active destination transport address if 4001 one exists. 4003 When retransmitting data that timed out, if the endpoint is multi- 4004 homed, it needs to consider each source-destination address pair in 4005 its retransmission selection policy. When retransmitting timed-out 4006 data, the endpoint SHOULD attempt to pick the most divergent source- 4007 destination pair from the original source-destination pair to which 4008 the packet was transmitted. 4010 Note: Rules for picking the most divergent source-destination pair 4011 are an implementation decision and are not specified within this 4012 document. 4014 6.5. Stream Identifier and Stream Sequence Number 4016 Every DATA chunk MUST carry a valid stream identifier. If an 4017 endpoint receives a DATA chunk with an invalid stream identifier, it 4018 SHOULD acknowledge the reception of the DATA chunk following the 4019 normal procedure, immediately send an ERROR chunk with cause set to 4020 "Invalid Stream Identifier" (see Section 3.3.10), and discard the 4021 DATA chunk. The endpoint MAY bundle the ERROR chunk and the SACK 4022 chunk in the same packet. 4024 The Stream Sequence Number in all the streams MUST start from 0 when 4025 the association is established. Also, when the Stream Sequence 4026 Number reaches the value 65535 the next Stream Sequence Number MUST 4027 be set to 0. 4029 6.6. Ordered and Unordered Delivery 4031 Within a stream, an endpoint MUST deliver DATA chunks received with 4032 the U flag set to 0 to the upper layer according to the order of 4033 their Stream Sequence Number. If DATA chunks arrive out of order of 4034 their Stream Sequence Number, the endpoint MUST hold the received 4035 DATA chunks from delivery to the ULP until they are reordered. 4037 However, an SCTP endpoint can indicate that no ordered delivery is 4038 required for a particular DATA chunk transmitted within the stream by 4039 setting the U flag of the DATA chunk to 1. 4041 When an endpoint receives a DATA chunk with the U flag set to 1, it 4042 bypasses the ordering mechanism and immediately deliver the data to 4043 the upper layer (after reassembly if the user data is fragmented by 4044 the data sender). 4046 This provides an effective way of transmitting "out-of-band" data in 4047 a given stream. Also, a stream can be used as an "unordered" stream 4048 by simply setting the U flag to 1 in all DATA chunks sent through 4049 that stream. 4051 IMPLEMENTATION NOTE: When sending an unordered DATA chunk, an 4052 implementation MAY choose to place the DATA chunk in an outbound 4053 packet that is at the head of the outbound transmission queue if 4054 possible. 4056 The 'Stream Sequence Number' field in a DATA chunk with U flag set to 4057 1 has no significance. The sender can fill the 'Stream Sequence 4058 Number' with arbitrary value, but the receiver MUST ignore the field. 4060 Note: When transmitting ordered and unordered data, an endpoint does 4061 not increment its Stream Sequence Number when transmitting a DATA 4062 chunk with U flag set to 1. 4064 6.7. Report Gaps in Received DATA TSNs 4066 Upon the reception of a new DATA chunk, an endpoint examines the 4067 continuity of the TSNs received. If the endpoint detects a gap in 4068 the received DATA chunk sequence, it SHOULD send a SACK with Gap Ack 4069 Blocks immediately. The data receiver continues sending a SACK after 4070 receipt of each SCTP packet that does not fill the gap. 4072 Based on the Gap Ack Block from the received SACK, the endpoint can 4073 calculate the missing DATA chunks and make decisions on whether to 4074 retransmit them (see Section 6.2.1 for details). 4076 Multiple gaps can be reported in one single SACK (see Section 3.3.4). 4078 When its peer is multi-homed, the SCTP endpoint SHOULD always try to 4079 send the SACK to the same destination address from which the last 4080 DATA chunk was received. 4082 Upon the reception of a SACK, the endpoint MUST remove all DATA 4083 chunks that have been acknowledged by the SACK's Cumulative TSN Ack 4084 from its transmit queue. All DATA chunks with TSNs not included in 4085 the Gap Ack Blocks reported by a SACK MUST be treated as "missing" by 4086 the sending endpoint. The number of "missing" reports for each 4087 outstanding DATA chunk MUST be recorded by the data sender to make 4088 retransmission decisions. See Section 7.2.4 for details. 4090 The following example shows the use of SACK to report a gap. 4092 Endpoint A Endpoint Z 4093 {App sends 3 messages; strm 0} 4094 DATA [TSN=6,Strm=0,Seq=2] ---------------> (ack delayed) 4095 (Start T3-rtx timer) 4097 DATA [TSN=7,Strm=0,Seq=3] --------> X (lost) 4099 DATA [TSN=8,Strm=0,Seq=4] ---------------> (gap detected, 4100 immediately send ack) 4101 /----- SACK [TSN Ack=6,Block=1, 4102 / Start=2,End=2] 4103 <-----/ 4104 (remove 6 from out-queue, 4105 and mark 7 as "1" missing report) 4107 Figure 9: Reporting a Gap using SACK 4109 The maximum number of Gap Ack Blocks that can be reported within a 4110 single SACK chunk is limited by the current path MTU. When a single 4111 SACK cannot cover all the Gap Ack Blocks needed to be reported due to 4112 the MTU limitation, the endpoint MUST send only one SACK. This 4113 single SACK MUST report the Gap Ack Blocks from the lowest to highest 4114 TSNs, within the size limit set by the MTU, and leave the remaining 4115 highest TSN numbers unacknowledged. 4117 6.8. CRC32c Checksum Calculation 4119 When sending an SCTP packet, the endpoint MUST strengthen the data 4120 integrity of the transmission by including the CRC32c checksum value 4121 calculated on the packet, as described below. 4123 After the packet is constructed (containing the SCTP common header 4124 and one or more control or DATA chunks), the transmitter MUST 4126 1) fill in the proper Verification Tag in the SCTP common header and 4127 initialize the checksum field to '0's, 4129 2) calculate the CRC32c checksum of the whole packet, including the 4130 SCTP common header and all the chunks (refer to Appendix A for 4131 details of the CRC32c algorithm); and 4133 3) put the resultant value into the checksum field in the common 4134 header, and leave the rest of the bits unchanged. 4136 When an SCTP packet is received, the receiver MUST first check the 4137 CRC32c checksum as follows: 4139 1) Store the received CRC32c checksum value aside. 4141 2) Replace the 32 bits of the checksum field in the received SCTP 4142 packet with all '0's and calculate a CRC32c checksum value of the 4143 whole received packet. 4145 3) Verify that the calculated CRC32c checksum is the same as the 4146 received CRC32c checksum. If it is not, the receiver MUST treat 4147 the packet as an invalid SCTP packet. 4149 The default procedure for handling invalid SCTP packets is to 4150 silently discard them. 4152 Any hardware implementation SHOULD permit alternative verification of 4153 the CRC in software. 4155 6.9. Fragmentation and Reassembly 4157 An endpoint MAY support fragmentation when sending DATA chunks, but 4158 it MUST support reassembly when receiving DATA chunks. If an 4159 endpoint supports fragmentation, it MUST fragment a user message if 4160 the size of the user message to be sent causes the outbound SCTP 4161 packet size to exceed the current MTU. An endpoint that does not 4162 support fragmentation and is requested to send a user message such 4163 that the outbound SCTP packet size would exceed the current MTU MUST 4164 return an error to its upper layer and MUST NOT attempt to send the 4165 user message. 4167 If an implementation that supports fragmentation makes available to 4168 its upper layer a mechanism to turn off fragmentation, it might do 4169 so. An implementation that disables fragmentation MUST react just 4170 like an implementation that does NOT support fragmentation, i.e., it 4171 MUST reject sends that exceed the current Path MTU (PMTU). 4173 IMPLEMENTATION NOTE: In this error case, the SEND primitive discussed 4174 in Section 11.1 would need to return an error to the upper layer. 4176 If its peer is multi-homed, the endpoint SHOULD choose a size no 4177 larger than the association Path MTU. The association Path MTU is 4178 defined as the smallest Path MTU of all destination addresses. 4180 Once a user message is fragmented, it cannot be re-fragmented. 4181 Instead, if the PMTU has been reduced, then IP fragmentation MUST be 4182 used. Please see Section 7.3 for details of PMTU discovery. 4184 When determining when to fragment, the SCTP implementation MUST take 4185 into account the SCTP packet header as well as the DATA chunk 4186 header(s). The implementation MUST also take into account the space 4187 required for a SACK chunk if bundling a SACK chunk with the DATA 4188 chunk. 4190 Fragmentation takes the following steps: 4192 1) The data sender MUST break the user message into a series of DATA 4193 chunks such that each chunk plus SCTP overhead fits into an IP 4194 datagram smaller than or equal to the association Path MTU. 4196 2) The transmitter MUST then assign, in sequence, a separate TSN to 4197 each of the DATA chunks in the series. The transmitter assigns 4198 the same SSN to each of the DATA chunks. If the user indicates 4199 that the user message is to be delivered using unordered 4200 delivery, then the U flag of each DATA chunk of the user message 4201 MUST be set to 1. 4203 3) The transmitter MUST also set the B/E bits of the first DATA 4204 chunk in the series to '10', the B/E bits of the last DATA chunk 4205 in the series to '01', and the B/E bits of all other DATA chunks 4206 in the series to '00'. 4208 An endpoint MUST recognize fragmented DATA chunks by examining the B/ 4209 E bits in each of the received DATA chunks, and queue the fragmented 4210 DATA chunks for reassembly. Once the user message is reassembled, 4211 SCTP passes the reassembled user message to the specific stream for 4212 possible reordering and final dispatching. 4214 If the data receiver runs out of buffer space while still waiting for 4215 more fragments to complete the reassembly of the message, it SHOULD 4216 dispatch part of its inbound message through a partial delivery API 4217 (see Section 11), freeing some of its receive buffer space so that 4218 the rest of the message can be received. 4220 6.10. Bundling 4222 An endpoint bundles chunks by simply including multiple chunks in one 4223 outbound SCTP packet. The total size of the resultant IP datagram, 4224 including the SCTP packet and IP headers, MUST be less that or equal 4225 to the current Path MTU. 4227 If its peer endpoint is multi-homed, the sending endpoint SHOULD 4228 choose a size no larger than the latest MTU of the current primary 4229 path. 4231 When bundling control chunks with DATA chunks, an endpoint MUST place 4232 control chunks first in the outbound SCTP packet. The transmitter 4233 MUST transmit DATA chunks within an SCTP packet in increasing order 4234 of TSN. 4236 Note: Since control chunks are placed first in a packet and since 4237 DATA chunks are transmitted before SHUTDOWN or SHUTDOWN ACK chunks, 4238 DATA chunks cannot be bundled with SHUTDOWN or SHUTDOWN ACK chunks. 4240 Partial chunks MUST NOT be placed in an SCTP packet. A partial chunk 4241 is a chunk that is not completely contained in the SCTP packet; i.e., 4242 the SCTP packet is too short to contain all the bytes of the chunk as 4243 indicated by the chunk length. 4245 An endpoint MUST process received chunks in their order in the 4246 packet. The receiver uses the Chunk Length field to determine the 4247 end of a chunk and beginning of the next chunk taking account of the 4248 fact that all chunks end on a 4-byte boundary. If the receiver 4249 detects a partial chunk, it MUST drop the chunk. 4251 An endpoint MUST NOT bundle INIT, INIT ACK, or SHUTDOWN COMPLETE with 4252 any other chunks. 4254 7. Congestion Control 4256 Congestion control is one of the basic functions in SCTP. For some 4257 applications, it might be likely that adequate resources will be 4258 allocated to SCTP traffic to ensure prompt delivery of time-critical 4259 data -- thus, it would appear to be unlikely, during normal 4260 operations, that transmissions encounter severe congestion 4261 conditions. However, SCTP operates under adverse operational 4262 conditions, which can develop upon partial network failures or 4263 unexpected traffic surges. In such situations, SCTP follows correct 4264 congestion control steps to recover from congestion quickly in order 4265 to get data delivered as soon as possible. In the absence of network 4266 congestion, these preventive congestion control algorithms are 4267 expected to show no impact on the protocol performance. 4269 IMPLEMENTATION NOTE: As far as its specific performance requirements 4270 are met, an implementation is always allowed to adopt a more 4271 conservative congestion control algorithm than the one defined below. 4273 The congestion control algorithms used by SCTP are based on 4274 [RFC5681]. This section describes how the algorithms defined in 4275 [RFC5681] are adapted for use in SCTP. We first list differences in 4276 protocol designs between TCP and SCTP, and then describe SCTP's 4277 congestion control scheme. The description will use the same 4278 terminology as in TCP congestion control whenever appropriate. 4280 SCTP congestion control is always applied to the entire association, 4281 and not to individual streams. 4283 7.1. SCTP Differences from TCP Congestion Control 4285 Gap Ack Blocks in the SCTP SACK carry the same semantic meaning as 4286 the TCP SACK. TCP considers the information carried in the SACK as 4287 advisory information only. SCTP considers the information carried in 4288 the Gap Ack Blocks in the SACK chunk as advisory. In SCTP, any DATA 4289 chunk that has been acknowledged by SACK, including DATA that arrived 4290 at the receiving end out of order, is not considered fully delivered 4291 until the Cumulative TSN Ack Point passes the TSN of the DATA chunk 4292 (i.e., the DATA chunk has been acknowledged by the Cumulative TSN Ack 4293 field in the SACK). Consequently, the value of cwnd controls the 4294 amount of outstanding data, rather than (as in the case of non-SACK 4295 TCP) the upper bound between the highest acknowledged sequence number 4296 and the latest DATA chunk that can be sent within the congestion 4297 window. SCTP SACK leads to different implementations of Fast 4298 Retransmit and Fast Recovery than non-SACK TCP. As an example, see 4299 [FALL96]. 4301 The biggest difference between SCTP and TCP, however, is multi- 4302 homing. SCTP is designed to establish robust communication 4303 associations between two endpoints each of which might be reachable 4304 by more than one transport address. Potentially different addresses 4305 might lead to different data paths between the two endpoints; thus, 4306 ideally one needs a separate set of congestion control parameters for 4307 each of the paths. The treatment here of congestion control for 4308 multi-homed receivers is new with SCTP and might require refinement 4309 in the future. The current algorithms make the following 4310 assumptions: 4312 * The sender usually uses the same destination address until being 4313 instructed by the upper layer to do otherwise; however, SCTP MAY 4314 change to an alternate destination in the event an address is 4315 marked inactive (see Section 8.2). Also, SCTP MAY retransmit to a 4316 different transport address than the original transmission. 4318 * The sender keeps a separate congestion control parameter set for 4319 each of the destination addresses it can send to (not each source- 4320 destination pair but for each destination). The parameters SHOULD 4321 decay if the address is not used for a long enough time period. 4322 [RFC5681] specifies this long enough time as a retransmission 4323 timeout. 4325 * For each of the destination addresses, an endpoint does slow start 4326 upon the first transmission to that address. 4328 Note: TCP guarantees in-sequence delivery of data to its upper-layer 4329 protocol within a single TCP session. This means that when TCP 4330 notices a gap in the received sequence number, it waits until the gap 4331 is filled before delivering the data that was received with sequence 4332 numbers higher than that of the missing data. On the other hand, 4333 SCTP can deliver data to its upper-layer protocol even if there is a 4334 gap in TSN if the Stream Sequence Numbers are in sequence for a 4335 particular stream (i.e., the missing DATA chunks are for a different 4336 stream) or if unordered delivery is indicated. Although this does 4337 not affect cwnd, it might affect rwnd calculation. 4339 7.2. SCTP Slow-Start and Congestion Avoidance 4341 The slow-start and congestion avoidance algorithms MUST be used by an 4342 endpoint to control the amount of data being injected into the 4343 network. The congestion control in SCTP is employed in regard to the 4344 association, not to an individual stream. In some situations, it 4345 might be beneficial for an SCTP sender to be more conservative than 4346 the algorithms allow; however, an SCTP sender MUST NOT be more 4347 aggressive than the following algorithms allow. 4349 Like TCP, an SCTP endpoint uses the following three control variables 4350 to regulate its transmission rate. 4352 * Receiver advertised window size (rwnd, in bytes), which is set by 4353 the receiver based on its available buffer space for incoming 4354 packets. 4356 Note: This variable is kept on the entire association. 4358 * Congestion control window (cwnd, in bytes), which is adjusted by 4359 the sender based on observed network conditions. 4361 Note: This variable is maintained on a per-destination-address 4362 basis. 4364 * Slow-start threshold (ssthresh, in bytes), which is used by the 4365 sender to distinguish slow-start and congestion avoidance phases. 4367 Note: This variable is maintained on a per-destination-address 4368 basis. 4370 SCTP also requires one additional control variable, 4371 partial_bytes_acked, which is used during congestion avoidance phase 4372 to facilitate cwnd adjustment. 4374 Unlike TCP, an SCTP sender MUST keep a set of these control variables 4375 cwnd, ssthresh, and partial_bytes_acked for EACH destination address 4376 of its peer (when its peer is multi-homed). Only one rwnd is kept 4377 for the whole association (no matter if the peer is multi-homed or 4378 has a single address). 4380 7.2.1. Slow-Start 4382 Beginning data transmission into a network with unknown conditions or 4383 after a sufficiently long idle period requires SCTP to probe the 4384 network to determine the available capacity. The slow-start 4385 algorithm is used for this purpose at the beginning of a transfer, or 4386 after repairing loss detected by the retransmission timer. 4388 * The initial cwnd before data transmission MUST be set to 4389 min(4*MTU, max (2*MTU, 4380 bytes)). 4391 * The initial cwnd after a retransmission timeout MUST be no more 4392 than 1*MTU, and only one packet is allowed to be in flight until 4393 successful acknowledgement. 4395 * The initial value of ssthresh SHOULD be arbitrarily high (e.g., 4396 the size of the largest possible advertised window). 4398 * Whenever cwnd is greater than zero, the endpoint is allowed to 4399 have cwnd bytes of data outstanding on that transport address. A 4400 limited overbooking as described in Section 6.1 B) SHOULD be 4401 supported. 4403 * When cwnd is less than or equal to ssthresh, an SCTP endpoint MUST 4404 use the slow-start algorithm to increase cwnd only if the current 4405 congestion window is being fully utilized, an incoming SACK 4406 advances the Cumulative TSN Ack Point, and the data sender is not 4407 in Fast Recovery. Only when these three conditions are met can 4408 the cwnd be increased; otherwise, the cwnd MUST NOT be increased. 4409 If these conditions are met, then cwnd MUST be increased by, at 4410 most, the lesser of 1) the total size of the previously 4411 outstanding DATA chunk(s) acknowledged, and 2) the destination's 4412 path MTU. This upper bound protects against the ACK-Splitting 4413 attack outlined in [SAVAGE99]. 4415 In instances where its peer endpoint is multi-homed, if an endpoint 4416 receives a SACK that advances its Cumulative TSN Ack Point, then it 4417 SHOULD update its cwnd (or cwnds) apportioned to the destination 4418 addresses to which it transmitted the acknowledged data. However, if 4419 the received SACK does not advance the Cumulative TSN Ack Point, the 4420 endpoint MUST NOT adjust the cwnd of any of the destination 4421 addresses. 4423 Because an endpoint's cwnd is not tied to its Cumulative TSN Ack 4424 Point, as duplicate SACKs come in, even though they might not advance 4425 the Cumulative TSN Ack Point an endpoint can still use them to clock 4426 out new data. That is, the data newly acknowledged by the SACK 4427 diminishes the amount of data now in flight to less than cwnd, and so 4428 the current, unchanged value of cwnd now allows new data to be sent. 4429 On the other hand, the increase of cwnd MUST be tied to the 4430 Cumulative TSN Ack Point advancement as specified above. Otherwise, 4431 the duplicate SACKs will not only clock out new data, but also will 4432 adversely clock out more new data than what has just left the 4433 network, during a time of possible congestion. 4435 * While the endpoint does not transmit data on a given transport 4436 address, the cwnd of the transport address SHOULD be adjusted to 4437 max(cwnd/2, 4*MTU) once per RTO. Before the first cwnd 4438 adjustment, the ssthresh of the transport address SHOULD be set to 4439 the cwnd. 4441 7.2.2. Congestion Avoidance 4443 When cwnd is greater than ssthresh, cwnd SHOULD be incremented by 4444 1*MTU per RTT if the sender has cwnd or more bytes of data 4445 outstanding for the corresponding transport address. The basic 4446 recommendations for incrementing cwnd during congestion avoidance are 4447 as follows: 4449 * SCTP MAY increment cwnd by 1*MTU. 4451 * SCTP SHOULD increment cwnd by 1*MTU once per RTT when the sender 4452 has cwnd or more bytes of data outstanding for the corresponding 4453 transport address. 4455 * SCTP MUST NOT increment cwnd by more than 1*MTU per RTT. 4457 In practice, an implementation can achieve this goal in the following 4458 way: 4460 * partial_bytes_acked is initialized to 0. 4462 * Whenever cwnd is greater than ssthresh, upon each SACK arrival, 4463 increase partial_bytes_acked by the total number of bytes of all 4464 new chunks acknowledged in that SACK, including chunks 4465 acknowledged by the new Cumulative TSN Ack, by Gap Ack Blocks, and 4466 by the number of bytes of duplicated chunks reported in Duplicate 4467 TSNs. 4469 * (1) when partial_bytes_acked is greater than cwnd and (2) before 4470 the arrival of the SACK the sender had less than cwnd bytes of 4471 data outstanding (i.e., before the arrival of the SACK, flightsize 4472 was less than cwnd), reset partial_bytes_acked to cwnd. 4474 * (1) when partial_bytes_acked is equal to or greater than cwnd and 4475 (2) before the arrival of the SACK the sender had cwnd or more 4476 bytes of data outstanding (i.e., before the arrival of the SACK, 4477 flightsize was greater than or equal to cwnd), partial_bytes_acked 4478 is reset to (partial_bytes_acked - cwnd). Next, cwnd is increased 4479 by 1*MTU. 4481 * Same as in the slow start, when the sender does not transmit DATA 4482 on a given transport address, the cwnd of the transport address 4483 SHOULD be adjusted to max(cwnd / 2, 4*MTU) per RTO. 4485 * When all of the data transmitted by the sender has been 4486 acknowledged by the receiver, partial_bytes_acked is initialized 4487 to 0. 4489 7.2.3. Congestion Control 4491 Upon detection of packet losses from SACK (see Section 7.2.4), an 4492 endpoint SHOULD do the following: 4494 ssthresh = max(cwnd/2, 4*MTU) 4495 cwnd = ssthresh 4496 partial_bytes_acked = 0 4498 Basically, a packet loss causes cwnd to be cut in half. 4500 When the T3-rtx timer expires on an address, SCTP SHOULD perform slow 4501 start by: 4503 ssthresh = max(cwnd/2, 4*MTU) 4504 cwnd = 1*MTU 4505 partial_bytes_acked = 0 4507 and ensure that no more than one SCTP packet will be in flight for 4508 that address until the endpoint receives acknowledgement for 4509 successful delivery of data to that address. 4511 7.2.4. Fast Retransmit on Gap Reports 4513 In the absence of data loss, an endpoint performs delayed 4514 acknowledgement. However, whenever an endpoint notices a hole in the 4515 arriving TSN sequence, it SHOULD start sending a SACK back every time 4516 a packet arrives carrying data until the hole is filled. 4518 Whenever an endpoint receives a SACK that indicates that some TSNs 4519 are missing, it SHOULD wait for two further miss indications (via 4520 subsequent SACKs for a total of three missing reports) on the same 4521 TSNs before taking action with regard to Fast Retransmit. 4523 Miss indications SHOULD follow the HTNA (Highest TSN Newly 4524 Acknowledged) algorithm. For each incoming SACK, miss indications 4525 are incremented only for missing TSNs prior to the highest TSN newly 4526 acknowledged in the SACK. A newly acknowledged DATA chunk is one not 4527 previously acknowledged in a SACK. If an endpoint is in Fast 4528 Recovery and a SACK arrives that advances the Cumulative TSN Ack 4529 Point, the miss indications are incremented for all TSNs reported 4530 missing in the SACK. 4532 When the third consecutive miss indication is received for a TSN(s), 4533 the data sender does the following: 4535 1) Mark the DATA chunk(s) with three miss indications for 4536 retransmission. 4538 2) If not in Fast Recovery, adjust the ssthresh and cwnd of the 4539 destination address(es) to which the missing DATA chunks were 4540 last sent, according to the formula described in Section 7.2.3. 4542 3) If not in Fast Recovery, determine how many of the earliest 4543 (i.e., lowest TSN) DATA chunks marked for retransmission will fit 4544 into a single packet, subject to constraint of the PMTU of the 4545 destination transport address to which the packet is being sent. 4546 Call this value K. Retransmit those K DATA chunks in a single 4547 packet. When a Fast Retransmit is being performed, the sender 4548 SHOULD ignore the value of cwnd and SHOULD NOT delay 4549 retransmission for this single packet. 4551 4) Restart the T3-rtx timer only if the last SACK acknowledged the 4552 lowest outstanding TSN number sent to that address, or the 4553 endpoint is retransmitting the first outstanding DATA chunk sent 4554 to that address. 4556 5) Mark the DATA chunk(s) as being fast retransmitted and thus 4557 ineligible for a subsequent Fast Retransmit. Those TSNs marked 4558 for retransmission due to the Fast-Retransmit algorithm that did 4559 not fit in the sent datagram carrying K other TSNs are also 4560 marked as ineligible for a subsequent Fast Retransmit. However, 4561 as they are marked for retransmission they will be retransmitted 4562 later on as soon as cwnd allows. 4564 6) If not in Fast Recovery, enter Fast Recovery and mark the highest 4565 outstanding TSN as the Fast Recovery exit point. When a SACK 4566 acknowledges all TSNs up to and including this exit point, Fast 4567 Recovery is exited. While in Fast Recovery, the ssthresh and 4568 cwnd SHOULD NOT change for any destinations due to a subsequent 4569 Fast Recovery event (i.e., one SHOULD NOT reduce the cwnd further 4570 due to a subsequent Fast Retransmit). 4572 Note: Before the above adjustments, if the received SACK also 4573 acknowledges new DATA chunks and advances the Cumulative TSN Ack 4574 Point, the cwnd adjustment rules defined in Section 7.2.1 and 4575 Section 7.2.2 MUST be applied first. 4577 7.2.5. Making Changes to Differentiated Services Code Points 4579 SCTP implementations MAY allow an application to configure the 4580 Differentiated Services Code Point (DSCP) used for sending packets. 4581 If a DSCP change might result in outgoing packets being queued in 4582 different queues, the congestion control parameters for all affected 4583 destination addresses MUST be reset to their initial values. 4585 7.3. Path MTU Discovery 4587 [RFC8899], [RFC8201], and [RFC1191] specify "Packetization Layer Path 4588 MTU Discovery", whereby an endpoint maintains an estimate of the 4589 maximum transmission unit (MTU) along a given Internet path and 4590 refrains from sending packets along that path that exceed the MTU, 4591 other than occasional attempts to probe for a change in the Path MTU 4592 (PMTU). [RFC8899] is thorough in its discussion of the MTU discovery 4593 mechanism and strategies for determining the current end-to-end MTU 4594 setting as well as detecting changes in this value. 4596 An endpoint SHOULD apply these techniques, and SHOULD do so on a per- 4597 destination-address basis. 4599 There are two important SCTP-specific points regarding Path MTU 4600 discovery: 4602 1) SCTP associations can span multiple addresses. An endpoint MUST 4603 maintain separate PMTU estimates for each destination address of 4604 its peer. 4606 2) The sender SHOULD track an association PMTU that will be the 4607 smallest PMTU discovered for all of the peer's destination 4608 addresses. When fragmenting messages into multiple parts this 4609 association PMTU SHOULD be used to calculate the size of each 4610 fragment. This will allow retransmissions to be seamlessly sent 4611 to an alternate address without encountering IP fragmentation. 4613 8. Fault Management 4614 8.1. Endpoint Failure Detection 4616 An endpoint SHOULD keep a counter on the total number of consecutive 4617 retransmissions to its peer (this includes data retransmissions to 4618 all the destination transport addresses of the peer if it is multi- 4619 homed), including the number of unacknowledged HEARTBEAT chunks 4620 observed on the path that is currently used for data transfer. 4621 Unacknowledged HEARTBEAT chunks observed on paths different from the 4622 path currently used for data transfer SHOULD NOT increment the 4623 association error counter, as this could lead to association closure 4624 even if the path that is currently used for data transfer is 4625 available (but idle). If the value of this counter exceeds the limit 4626 indicated in the protocol parameter 'Association.Max.Retrans', the 4627 endpoint SHOULD consider the peer endpoint unreachable and SHALL stop 4628 transmitting any more data to it (and thus the association enters the 4629 CLOSED state). In addition, the endpoint SHOULD report the failure 4630 to the upper layer and optionally report back all outstanding user 4631 data remaining in its outbound queue. The association is 4632 automatically closed when the peer endpoint becomes unreachable. 4634 The counter used for endpoint failure detection MUST be reset each 4635 time a DATA chunk sent to that peer endpoint is acknowledged (by the 4636 reception of a SACK). When a HEARTBEAT ACK is received from the peer 4637 endpoint, the counter SHOULD also be reset. The receiver of the 4638 HEARTBEAT ACK MAY choose not to clear the counter if there is 4639 outstanding data on the association. This allows for handling the 4640 possible difference in reachability based on DATA chunks and 4641 HEARTBEAT chunks. 4643 8.2. Path Failure Detection 4645 When its peer endpoint is multi-homed, an endpoint SHOULD keep an 4646 error counter for each of the destination transport addresses of the 4647 peer endpoint. 4649 Each time the T3-rtx timer expires on any address, or when a 4650 HEARTBEAT sent to an idle address is not acknowledged within an RTO, 4651 the error counter of that destination address will be incremented. 4652 When the value in the error counter exceeds the protocol parameter 4653 'Path.Max.Retrans' of that destination address, the endpoint SHOULD 4654 mark the destination transport address as inactive, and a 4655 notification SHOULD be sent to the upper layer. 4657 When an outstanding TSN is acknowledged or a HEARTBEAT sent to that 4658 address is acknowledged with a HEARTBEAT ACK, the endpoint SHOULD 4659 clear the error counter of the destination transport address to which 4660 the DATA chunk was last sent (or HEARTBEAT was sent) and SHOULD also 4661 report to the upper layer when an inactive destination address is 4662 marked as active. When the peer endpoint is multi-homed and the last 4663 chunk sent to it was a retransmission to an alternate address, there 4664 exists an ambiguity as to whether or not the acknowledgement could be 4665 credited to the address of the last chunk sent. However, this 4666 ambiguity does not seem to have significant consequences for SCTP 4667 behavior. If this ambiguity is undesirable, the transmitter MAY 4668 choose not to clear the error counter if the last chunk sent was a 4669 retransmission. 4671 Note: When configuring the SCTP endpoint, the user ought avoid having 4672 the value of 'Association.Max.Retrans' larger than the summation of 4673 the 'Path.Max.Retrans' of all the destination addresses for the 4674 remote endpoint. Otherwise, all the destination addresses might 4675 become inactive while the endpoint still considers the peer endpoint 4676 reachable. When this condition occurs, how SCTP chooses to function 4677 is implementation specific. 4679 When the primary path is marked inactive (due to excessive 4680 retransmissions, for instance), the sender MAY automatically transmit 4681 new packets to an alternate destination address if one exists and is 4682 active. If more than one alternate address is active when the 4683 primary path is marked inactive, only ONE transport address SHOULD be 4684 chosen and used as the new destination transport address. 4686 8.3. Path Heartbeat 4688 By default, an SCTP endpoint SHOULD monitor the reachability of the 4689 idle destination transport address(es) of its peer by sending a 4690 HEARTBEAT chunk periodically to the destination transport 4691 address(es). HEARTBEAT sending MAY begin upon reaching the 4692 ESTABLISHED state and is discontinued after sending either SHUTDOWN 4693 or SHUTDOWN ACK. A receiver of a HEARTBEAT MUST respond to a 4694 HEARTBEAT with a HEARTBEAT ACK after entering the COOKIE-ECHOED state 4695 (INIT sender) or the ESTABLISHED state (INIT receiver), up until 4696 reaching the SHUTDOWN-SENT state (SHUTDOWN sender) or the SHUTDOWN- 4697 ACK-SENT state (SHUTDOWN receiver). 4699 A destination transport address is considered "idle" if no new chunk 4700 that can be used for updating path RTT (usually including first 4701 transmission DATA, INIT, COOKIE ECHO, HEARTBEAT, etc.) and no 4702 HEARTBEAT has been sent to it within the current heartbeat period of 4703 that address. This applies to both active and inactive destination 4704 addresses. 4706 The upper layer can optionally initiate the following functions: 4708 A) Disable heartbeat on a specific destination transport address of 4709 a given association, 4711 B) Change the 'HB.interval', 4713 C) Re-enable heartbeat on a specific destination transport address 4714 of a given association, and 4716 D) Request an on-demand HEARTBEAT on a specific destination 4717 transport address of a given association. 4719 The endpoint SHOULD increment the respective error counter of the 4720 destination transport address each time a HEARTBEAT is sent to that 4721 address and not acknowledged within one RTO. 4723 When the value of this counter exceeds the protocol parameter 4724 'Path.Max.Retrans', the endpoint SHOULD mark the corresponding 4725 destination address as inactive if it is not so marked and SHOULD 4726 also report to the upper layer the change in reachability of this 4727 destination address. After this, the endpoint SHOULD continue 4728 HEARTBEAT on this destination address but SHOULD stop increasing the 4729 counter. 4731 The sender of the HEARTBEAT chunk SHOULD include in the Heartbeat 4732 Information field of the chunk the current time when the packet is 4733 sent out and the destination address to which the packet is sent. 4735 IMPLEMENTATION NOTE: An alternative implementation of the heartbeat 4736 mechanism that can be used is to increment the error counter variable 4737 every time a HEARTBEAT is sent to a destination. Whenever a 4738 HEARTBEAT ACK arrives, the sender SHOULD clear the error counter of 4739 the destination that the HEARTBEAT was sent to. This in effect would 4740 clear the previously stroked error (and any other error counts as 4741 well). 4743 The receiver of the HEARTBEAT SHOULD immediately respond with a 4744 HEARTBEAT ACK that contains the Heartbeat Information TLV, together 4745 with any other received TLVs, copied unchanged from the received 4746 HEARTBEAT chunk. 4748 Upon the receipt of the HEARTBEAT ACK, the sender of the HEARTBEAT 4749 SHOULD clear the error counter of the destination transport address 4750 to which the HEARTBEAT was sent and mark the destination transport 4751 address as active if it is not so marked. The endpoint SHOULD report 4752 to the upper layer when an inactive destination address is marked as 4753 active due to the reception of the latest HEARTBEAT ACK. The 4754 receiver of the HEARTBEAT ACK SHOULD also clear the association 4755 overall error count (as defined in Section 8.1). 4757 The receiver of the HEARTBEAT ACK SHOULD also perform an RTT 4758 measurement for that destination transport address using the time 4759 value carried in the HEARTBEAT ACK chunk. 4761 On an idle destination address that is allowed to heartbeat, it is 4762 RECOMMENDED that a HEARTBEAT chunk is sent once per RTO of that 4763 destination address plus the protocol parameter 'HB.interval', with 4764 jittering of +/- 50% of the RTO value, and exponential backoff of the 4765 RTO if the previous HEARTBEAT is unanswered. 4767 A primitive is provided for the SCTP user to change the 'HB.interval' 4768 and turn on or off the heartbeat on a given destination address. The 4769 heartbeat interval set by the SCTP user is added to the RTO of that 4770 destination (including any exponential backoff). Only one heartbeat 4771 SHOULD be sent each time the heartbeat timer expires (if multiple 4772 destinations are idle). It is an implementation decision on how to 4773 choose which of the candidate idle destinations to heartbeat to (if 4774 more than one destination is idle). 4776 When tuning the heartbeat interval, there is a side effect that 4777 SHOULD be taken into account. When this value is increased, i.e., 4778 the HEARTBEAT takes longer, the detection of lost ABORT messages 4779 takes longer as well. If a peer endpoint ABORTs the association for 4780 any reason and the ABORT chunk is lost, the local endpoint will only 4781 discover the lost ABORT by sending a DATA chunk or HEARTBEAT chunk 4782 (thus causing the peer to send another ABORT). This is to be 4783 considered when tuning the HEARTBEAT timer. If the HEARTBEAT is 4784 disabled, only sending DATA to the association will discover a lost 4785 ABORT from the peer. 4787 8.4. Handle "Out of the Blue" Packets 4789 An SCTP packet is called an "out of the blue" (OOTB) packet if it is 4790 correctly formed (i.e., passed the receiver's CRC32c check; see 4791 Section 6.8), but the receiver is not able to identify the 4792 association to which this packet belongs. 4794 The receiver of an OOTB packet does the following: 4796 1) If the OOTB packet is to or from a non-unicast address, a 4797 receiver SHOULD silently discard the packet. Otherwise, 4799 2) If the OOTB packet contains an ABORT chunk, the receiver MUST 4800 silently discard the OOTB packet and take no further action. 4801 Otherwise, 4803 3) If the packet contains an INIT chunk with a Verification Tag set 4804 to '0', it SHOULD be processed as described in Section 5.1. If, 4805 for whatever reason, the INIT cannot be processed normally and an 4806 ABORT has to be sent in response, the Verification Tag of the 4807 packet containing the ABORT chunk MUST be the Initiate Tag of the 4808 received INIT chunk, and the T bit of the ABORT chunk has to be 4809 set to 0, indicating that the Verification Tag is not reflected. 4811 4) If the packet contains a COOKIE ECHO in the first chunk, process 4812 it MUST be processed as described in Section 5.1. Otherwise, 4814 5) If the packet contains a SHUTDOWN ACK chunk, the receiver SHOULD 4815 respond to the sender of the OOTB packet with a SHUTDOWN 4816 COMPLETE. When sending the SHUTDOWN COMPLETE, the receiver of 4817 the OOTB packet MUST fill in the Verification Tag field of the 4818 outbound packet with the Verification Tag received in the 4819 SHUTDOWN ACK and set the T bit in the Chunk Flags to indicate 4820 that the Verification Tag is reflected. Otherwise, 4822 6) If the packet contains a SHUTDOWN COMPLETE chunk, the receiver 4823 SHOULD silently discard the packet and take no further action. 4824 Otherwise, 4826 7) If the packet contains a "Stale Cookie" ERROR or a COOKIE ACK, 4827 the SCTP packet SHOULD be silently discarded. Otherwise, 4829 8) The receiver SHOULD respond to the sender of the OOTB packet with 4830 an ABORT. When sending the ABORT, the receiver of the OOTB 4831 packet MUST fill in the Verification Tag field of the outbound 4832 packet with the value found in the Verification Tag field of the 4833 OOTB packet and set the T bit in the Chunk Flags to indicate that 4834 the Verification Tag is reflected. After sending this ABORT, the 4835 receiver of the OOTB packet MUST discard the OOTB packet and MUST 4836 NOT take any further action. 4838 8.5. Verification Tag 4840 The Verification Tag rules defined in this section apply when sending 4841 or receiving SCTP packets that do not contain an INIT, SHUTDOWN 4842 COMPLETE, COOKIE ECHO (see Section 5.1), ABORT, or SHUTDOWN ACK 4843 chunk. The rules for sending and receiving SCTP packets containing 4844 one of these chunk types are discussed separately in Section 8.5.1. 4846 When sending an SCTP packet, the endpoint MUST fill in the 4847 Verification Tag field of the outbound packet with the tag value in 4848 the Initiate Tag parameter of the INIT or INIT ACK received from its 4849 peer. 4851 When receiving an SCTP packet, the endpoint MUST ensure that the 4852 value in the Verification Tag field of the received SCTP packet 4853 matches its own tag. If the received Verification Tag value does not 4854 match the receiver's own tag value, the receiver MUST silently 4855 discard the packet and MUST NOT process it any further except for 4856 those cases listed in Section 8.5.1 below. 4858 8.5.1. Exceptions in Verification Tag Rules 4860 A) Rules for packet carrying INIT: 4861 * The sender MUST set the Verification Tag of the packet to 0. 4863 * When an endpoint receives an SCTP packet with the Verification 4864 Tag set to 0, it SHOULD verify that the packet contains only an 4865 INIT chunk. Otherwise, the receiver MUST silently discard the 4866 packet. 4868 B) Rules for packet carrying ABORT: 4869 * The endpoint MUST always fill in the Verification Tag field of 4870 the outbound packet with the destination endpoint's tag value, 4871 if it is known. 4873 * If the ABORT is sent in response to an OOTB packet, the 4874 endpoint MUST follow the procedure described in Section 8.4. 4876 * The receiver of an ABORT MUST accept the packet if the 4877 Verification Tag field of the packet matches its own tag and 4878 the T bit is not set OR if it is set to its peer's tag and the 4879 T bit is set in the Chunk Flags. Otherwise, the receiver MUST 4880 silently discard the packet and take no further action. 4882 C) Rules for packet carrying SHUTDOWN COMPLETE: 4883 * When sending a SHUTDOWN COMPLETE, if the receiver of the 4884 SHUTDOWN ACK has a TCB, then the destination endpoint's tag 4885 MUST be used, and the T bit MUST NOT be set. Only where no TCB 4886 exists SHOULD the sender use the Verification Tag from the 4887 SHUTDOWN ACK, and MUST set the T bit. 4889 * The receiver of a SHUTDOWN COMPLETE accepts the packet if the 4890 Verification Tag field of the packet matches its own tag and 4891 the T bit is not set OR if it is set to its peer's tag and the 4892 T bit is set in the Chunk Flags. Otherwise, the receiver MUST 4893 silently discard the packet and take no further action. An 4894 endpoint MUST ignore the SHUTDOWN COMPLETE if it is not in the 4895 SHUTDOWN-ACK-SENT state. 4897 D) Rules for packet carrying a COOKIE ECHO: 4899 * When sending a COOKIE ECHO, the endpoint MUST use the value of 4900 the Initiate Tag received in the INIT ACK. 4902 * The receiver of a COOKIE ECHO follows the procedures in 4903 Section 5. 4905 E) Rules for packet carrying a SHUTDOWN ACK: 4906 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the 4907 procedures in Section 8.4 SHOULD be followed; in other words, 4908 it is treated as an Out Of The Blue packet. 4910 9. Termination of Association 4912 An endpoint SHOULD terminate its association when it exits from 4913 service. An association can be terminated by either abort or 4914 shutdown. An abort of an association is abortive by definition in 4915 that any data pending on either end of the association is discarded 4916 and not delivered to the peer. A shutdown of an association is 4917 considered a graceful close where all data in queue by either 4918 endpoint is delivered to the respective peers. However, in the case 4919 of a shutdown, SCTP does not support a half-open state (like TCP) 4920 wherein one side might continue sending data while the other end is 4921 closed. When either endpoint performs a shutdown, the association on 4922 each peer will stop accepting new data from its user and only deliver 4923 data in queue at the time of sending or receiving the SHUTDOWN chunk. 4925 9.1. Abort of an Association 4927 When an endpoint decides to abort an existing association, it MUST 4928 send an ABORT chunk to its peer endpoint. The sender MUST fill in 4929 the peer's Verification Tag in the outbound packet and MUST NOT 4930 bundle any DATA chunk with the ABORT. If the association is aborted 4931 on request of the upper layer, a User-Initiated Abort error cause 4932 (see Section 3.3.10.12) SHOULD be present in the ABORT chunk. 4934 An endpoint MUST NOT respond to any received packet that contains an 4935 ABORT chunk (also see Section 8.4). 4937 An endpoint receiving an ABORT MUST apply the special Verification 4938 Tag check rules described in Section 8.5.1. 4940 After checking the Verification Tag, the receiving endpoint MUST 4941 remove the association from its record and SHOULD report the 4942 termination to its upper layer. If a User-Initiated Abort error 4943 cause is present in the ABORT chunk, the Upper Layer Abort Reason 4944 SHOULD be made available to the upper layer. 4946 9.2. Shutdown of an Association 4948 Using the SHUTDOWN primitive (see Section 11.1), the upper layer of 4949 an endpoint in an association can gracefully close the association. 4950 This will allow all outstanding DATA chunks from the peer of the 4951 shutdown initiator to be delivered before the association terminates. 4953 Upon receipt of the SHUTDOWN primitive from its upper layer, the 4954 endpoint enters the SHUTDOWN-PENDING state and remains there until 4955 all outstanding data has been acknowledged by its peer. The endpoint 4956 accepts no new data from its upper layer, but retransmits data to the 4957 far end if necessary to fill gaps. 4959 Once all its outstanding data has been acknowledged, the endpoint 4960 sends a SHUTDOWN chunk to its peer including in the Cumulative TSN 4961 Ack field the last sequential TSN it has received from the peer. It 4962 SHOULD then start the T2-shutdown timer and enter the SHUTDOWN-SENT 4963 state. If the timer expires, the endpoint MUST resend the SHUTDOWN 4964 with the updated last sequential TSN received from its peer. 4966 The rules in Section 6.3 MUST be followed to determine the proper 4967 timer value for T2-shutdown. To indicate any gaps in TSN, the 4968 endpoint MAY also bundle a SACK with the SHUTDOWN chunk in the same 4969 SCTP packet. 4971 An endpoint SHOULD limit the number of retransmissions of the 4972 SHUTDOWN chunk to the protocol parameter 'Association.Max.Retrans'. 4973 If this threshold is exceeded, the endpoint SHOULD destroy the TCB 4974 and SHOULD report the peer endpoint unreachable to the upper layer 4975 (and thus the association enters the CLOSED state). The reception of 4976 any packet from its peer (i.e., as the peer sends all of its queued 4977 DATA chunks) SHOULD clear the endpoint's retransmission count and 4978 restart the T2-shutdown timer, giving its peer ample opportunity to 4979 transmit all of its queued DATA chunks that have not yet been sent. 4981 Upon reception of the SHUTDOWN, the peer endpoint does the following: 4983 * enter the SHUTDOWN-RECEIVED state, 4985 * stop accepting new data from its SCTP user, and 4987 * verify, by checking the Cumulative TSN Ack field of the chunk, 4988 that all its outstanding DATA chunks have been received by the 4989 SHUTDOWN sender. 4991 Once an endpoint has reached the SHUTDOWN-RECEIVED state, it MUST 4992 ignore ULP shutdown requests but MUST continue responding to SHUTDOWN 4993 chunks from its peer. 4995 If there are still outstanding DATA chunks left, the SHUTDOWN 4996 receiver MUST continue to follow normal data transmission procedures 4997 defined in Section 6, until all outstanding DATA chunks are 4998 acknowledged; however, the SHUTDOWN receiver MUST NOT accept new data 4999 from its SCTP user. 5001 While in the SHUTDOWN-SENT state, the SHUTDOWN sender MUST 5002 immediately respond to each received packet containing one or more 5003 DATA chunks with a SHUTDOWN chunk and restart the T2-shutdown timer. 5004 If a SHUTDOWN chunk by itself cannot acknowledge all of the received 5005 DATA chunks (i.e., there are TSNs that can be acknowledged that are 5006 larger than the cumulative TSN, and thus gaps exist in the TSN 5007 sequence), or if duplicate TSNs have been received, then a SACK chunk 5008 MUST also be sent. 5010 The sender of the SHUTDOWN MAY also start an overall guard timer 'T5- 5011 shutdown-guard' to bound the overall time for the shutdown sequence. 5012 At the expiration of this timer, the sender SHOULD abort the 5013 association by sending an ABORT chunk. If the 'T5-shutdown-guard' 5014 timer is used, it SHOULD be set to the RECOMMENDED value of 5 times 5015 'RTO.Max'. 5017 If the receiver of the SHUTDOWN has no more outstanding DATA chunks, 5018 the SHUTDOWN receiver MUST send a SHUTDOWN ACK and start a 5019 T2-shutdown timer of its own, entering the SHUTDOWN-ACK-SENT state. 5020 If the timer expires, the endpoint MUST resend the SHUTDOWN ACK. 5022 The sender of the SHUTDOWN ACK SHOULD limit the number of 5023 retransmissions of the SHUTDOWN ACK chunk to the protocol parameter 5024 'Association.Max.Retrans'. If this threshold is exceeded, the 5025 endpoint SHOULD destroy the TCB and SHOULD report the peer endpoint 5026 unreachable to the upper layer (and thus the association enters the 5027 CLOSED state). 5029 Upon the receipt of the SHUTDOWN ACK, the SHUTDOWN sender MUST stop 5030 the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its peer, 5031 and remove all record of the association. 5033 Upon reception of the SHUTDOWN COMPLETE chunk, the endpoint verifies 5034 that it is in the SHUTDOWN-ACK-SENT state; if it is not, the chunk 5035 SHOULD be discarded. If the endpoint is in the SHUTDOWN-ACK-SENT 5036 state, the endpoint SHOULD stop the T2-shutdown timer and remove all 5037 knowledge of the association (and thus the association enters the 5038 CLOSED state). 5040 An endpoint SHOULD ensure that all its outstanding DATA chunks have 5041 been acknowledged before initiating the shutdown procedure. 5043 An endpoint SHOULD reject any new data request from its upper layer 5044 if it is in the SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED, 5045 or SHUTDOWN-ACK-SENT state. 5047 If an endpoint is in the SHUTDOWN-ACK-SENT state and receives an INIT 5048 chunk (e.g., if the SHUTDOWN COMPLETE was lost) with source and 5049 destination transport addresses (either in the IP addresses or in the 5050 INIT chunk) that belong to this association, it SHOULD discard the 5051 INIT chunk and retransmit the SHUTDOWN ACK chunk. 5053 Note: Receipt of an INIT with the same source and destination IP 5054 addresses as used in transport addresses assigned to an endpoint but 5055 with a different port number indicates the initialization of a 5056 separate association. 5058 The sender of the INIT or COOKIE ECHO SHOULD respond to the receipt 5059 of a SHUTDOWN ACK with a stand-alone SHUTDOWN COMPLETE in an SCTP 5060 packet with the Verification Tag field of its common header set to 5061 the same tag that was received in the SHUTDOWN ACK packet. This is 5062 considered an Out of the Blue packet as defined in Section 8.4. The 5063 sender of the INIT lets T1-init continue running and remains in the 5064 COOKIE-WAIT or COOKIE-ECHOED state. Normal T1-init timer expiration 5065 will cause the INIT or COOKIE chunk to be retransmitted and thus 5066 start a new association. 5068 If a SHUTDOWN is received in the COOKIE-WAIT or COOKIE ECHOED state, 5069 the SHUTDOWN chunk SHOULD be silently discarded. 5071 If an endpoint is in the SHUTDOWN-SENT state and receives a SHUTDOWN 5072 chunk from its peer, the endpoint SHOULD respond immediately with a 5073 SHUTDOWN ACK to its peer, and move into the SHUTDOWN-ACK-SENT state 5074 restarting its T2-shutdown timer. 5076 If an endpoint is in the SHUTDOWN-ACK-SENT state and receives a 5077 SHUTDOWN ACK, it MUST stop the T2-shutdown timer, send a SHUTDOWN 5078 COMPLETE chunk to its peer, and remove all record of the association. 5080 10. ICMP Handling 5082 Whenever an ICMP message is received by an SCTP endpoint, the 5083 following procedures MUST be followed to ensure proper utilization of 5084 the information being provided by layer 3. 5086 ICMP1) An implementation MAY ignore all ICMPv4 messages where the 5087 type field is not set to "Destination Unreachable". 5089 ICMP2) An implementation MAY ignore all ICMPv6 messages where the 5090 type field is not "Destination Unreachable", "Parameter 5091 Problem", or "Packet Too Big". 5093 ICMP3) An implementation SHOULD ignore any ICMP messages where the 5094 code indicates "Port Unreachable". 5096 ICMP4) An implementation MAY ignore all ICMPv6 messages of type 5097 "Parameter Problem" if the code is not "Unrecognized Next 5098 Header Type Encountered". 5100 ICMP5) An implementation MUST use the payload of the ICMP message 5101 (v4 or v6) to locate the association that sent the message to 5102 which ICMP is responding. If the association cannot be 5103 found, an implementation SHOULD ignore the ICMP message. 5105 ICMP6) An implementation MUST validate that the Verification Tag 5106 contained in the ICMP message matches the Verification Tag of 5107 the peer. If the Verification Tag is not 0 and does not 5108 match, discard the ICMP message. If it is 0 and the ICMP 5109 message contains enough bytes to verify that the chunk type 5110 is an INIT chunk and that the Initiate Tag matches the tag of 5111 the peer, continue with ICMP7. If the ICMP message is too 5112 short or the chunk type or the Initiate Tag does not match, 5113 silently discard the packet. 5115 ICMP7) If the ICMP message is either a v6 "Packet Too Big" or a v4 5116 "Fragmentation Needed", an implementation MAY process this 5117 information as defined for PMTU discovery. 5119 ICMP8) If the ICMP code is an "Unrecognized Next Header Type 5120 Encountered" or a "Protocol Unreachable", an implementation 5121 MUST treat this message as an abort with the T bit set if it 5122 does not contain an INIT chunk. If it does contain an INIT 5123 chunk and the association is in the COOKIE-WAIT state, handle 5124 the ICMP message like an ABORT. 5126 ICMP9) If the ICMP type is "Destination Unreachable", the 5127 implementation MAY move the destination to the unreachable 5128 state or, alternatively, increment the path error counter. 5129 SCTP MAY provide information to the upper layer indicating 5130 the reception of ICMP messages when reporting a network 5131 status change. 5133 These procedures differ from [RFC1122] and from its requirements for 5134 processing of port-unreachable messages and the requirements that an 5135 implementation MUST abort associations in response to a "protocol 5136 unreachable" message. Port-unreachable messages are not processed, 5137 since an implementation will send an ABORT, not a port unreachable. 5138 The stricter handling of the "protocol unreachable" message is due to 5139 security concerns for hosts that do not support SCTP. 5141 11. Interface with Upper Layer 5143 The Upper Layer Protocols (ULPs) request services by passing 5144 primitives to SCTP and receive notifications from SCTP for various 5145 events. 5147 The primitives and notifications described in this section can be 5148 used as a guideline for implementing SCTP. The following functional 5149 description of ULP interface primitives is shown for illustrative 5150 purposes. Different SCTP implementations can have different ULP 5151 interfaces. However, all SCTPs aer expected to provide a certain 5152 minimum set of services to guarantee that all SCTP implementations 5153 can support the same protocol hierarchy. 5155 Please note that this section is informational only. 5157 [RFC6458] and the Socket API Considerations section of [RFC7053] 5158 define an extension of the socket API for SCTP as described in this 5159 document. 5161 11.1. ULP-to-SCTP 5163 The following sections functionally characterize a ULP/SCTP 5164 interface. The notation used is similar to most procedure or 5165 function calls in high-level languages. 5167 The ULP primitives described below specify the basic functions that 5168 SCTP performs to support inter-process communication. Individual 5169 implementations define their own exact format, and provide 5170 combinations or subsets of the basic functions in single calls. 5172 11.1.1. Initialize 5174 INITIALIZE ([local port],[local eligible address list]) 5175 -> local SCTP instance name 5177 This primitive allows SCTP to initialize its internal data structures 5178 and allocate necessary resources for setting up its operation 5179 environment. Once SCTP is initialized, ULP can communicate directly 5180 with other endpoints without re-invoking this primitive. 5182 SCTP will return a local SCTP instance name to the ULP. 5184 Mandatory attributes: 5186 None. 5188 Optional attributes: 5189 local port: SCTP port number, if ULP wants it to be specified. 5191 local eligible address list: an address list that the local SCTP 5192 endpoint binds. By default, if an address list is not 5193 included, all IP addresses assigned to the host are used by the 5194 local endpoint. 5196 IMPLEMENTATION NOTE: If this optional attribute is supported by an 5197 implementation, it will be the responsibility of the implementation 5198 to enforce that the IP source address field of any SCTP packets sent 5199 out by this endpoint contains one of the IP addresses indicated in 5200 the local eligible address list. 5202 11.1.2. Associate 5204 ASSOCIATE(local SCTP instance name, 5205 initial destination transport addr list, outbound stream count) 5206 -> association id [,destination transport addr list] 5207 [,outbound stream count] 5209 This primitive allows the upper layer to initiate an association to a 5210 specific peer endpoint. 5212 The peer endpoint is specified by one or more of the transport 5213 addresses that defines the endpoint (see Section 2.3). If the local 5214 SCTP instance has not been initialized, the ASSOCIATE is considered 5215 an error. 5217 An association id, which is a local handle to the SCTP association, 5218 will be returned on successful establishment of the association. If 5219 SCTP is not able to open an SCTP association with the peer endpoint, 5220 an error is returned. 5222 Other association parameters can be returned, including the complete 5223 destination transport addresses of the peer as well as the outbound 5224 stream count of the local endpoint. One of the transport addresses 5225 from the returned destination addresses will be selected by the local 5226 endpoint as default primary path for sending SCTP packets to this 5227 peer. The returned "destination transport addr list" can be used by 5228 the ULP to change the default primary path or to force sending a 5229 packet to a specific transport address. 5231 IMPLEMENTATION NOTE: If ASSOCIATE primitive is implemented as a 5232 blocking function call, the ASSOCIATE primitive can return 5233 association parameters in addition to the association id upon 5234 successful establishment. If ASSOCIATE primitive is implemented as a 5235 non-blocking call, only the association id is returned and 5236 association parameters are passed using the COMMUNICATION UP 5237 notification. 5239 Mandatory attributes: 5240 local SCTP instance name: obtained from the INITIALIZE operation. 5242 initial destination transport addr list: a non-empty list of 5243 transport addresses of the peer endpoint with which the 5244 association is to be established. 5246 outbound stream count: the number of outbound streams the ULP 5247 would like to open towards this peer endpoint. 5249 Optional attributes: 5250 None. 5252 11.1.3. Shutdown 5254 SHUTDOWN(association id) -> result 5256 Gracefully closes an association. Any locally queued user data will 5257 be delivered to the peer. The association will be terminated only 5258 after the peer acknowledges all the SCTP packets sent. A success 5259 code will be returned on successful termination of the association. 5260 If attempting to terminate the association results in a failure, an 5261 error code is returned. 5263 Mandatory attributes: 5264 association id: local handle to the SCTP association. 5266 Optional attributes: 5267 None. 5269 11.1.4. Abort 5271 ABORT(association id [, Upper Layer Abort Reason]) -> result 5273 Ungracefully closes an association. Any locally queued user data 5274 will be discarded, and an ABORT chunk is sent to the peer. A success 5275 code will be returned on successful abort of the association. If 5276 attempting to abort the association results in a failure, an error 5277 code is returned. 5279 Mandatory attributes: 5280 association id: local handle to the SCTP association. 5282 Optional attributes: 5283 Upper Layer Abort Reason: reason of the abort to be passed to the 5284 peer. 5286 11.1.5. Send 5288 SEND(association id, buffer address, byte count [,context] 5289 [,stream id] [,life time] [,destination transport address] 5290 [,unordered flag] [,no-bundle flag] [,payload protocol-id] 5291 [,sack-immediately flag]) -> result 5293 This is the main method to send user data via SCTP. 5295 Mandatory attributes: 5296 association id: local handle to the SCTP association. 5298 buffer address: the location where the user message to be 5299 transmitted is stored. 5301 byte count: the size of the user data in number of bytes. 5303 Optional attributes: 5304 context: an optional 32-bit integer that will be carried in the 5305 sending failure notification to the ULP if the transportation 5306 of this user message fails. 5308 stream id: to indicate which stream to send the data on. If not 5309 specified, stream 0 will be used. 5311 life time: specifies the life time of the user data. The user 5312 data will not be sent by SCTP after the life time expires. 5313 This parameter can be used to avoid efforts to transmit stale 5314 user messages. SCTP notifies the ULP if the data cannot be 5315 initiated to transport (i.e., sent to the destination via 5316 SCTP's SEND primitive) within the life time variable. However, 5317 the user data will be transmitted if SCTP has attempted to 5318 transmit a chunk before the life time expired. 5320 IMPLEMENTATION NOTE: In order to better support the data life 5321 time option, the transmitter can hold back the assigning of the 5322 TSN number to an outbound DATA chunk to the last moment. And, 5323 for implementation simplicity, once a TSN number has been 5324 assigned the sender considers the send of this DATA chunk as 5325 committed, overriding any life time option attached to the DATA 5326 chunk. 5328 destination transport address: specified as one of the 5329 destination transport addresses of the peer endpoint to which 5330 this packet is sent. Whenever possible, SCTP uses this 5331 destination transport address for sending the packets, instead 5332 of the current primary path. 5334 unordered flag: this flag, if present, indicates that the user 5335 would like the data delivered in an unordered fashion to the 5336 peer (i.e., the U flag is set to 1 on all DATA chunks carrying 5337 this message). 5339 no-bundle flag: instructs SCTP not to bundle this user data with 5340 other outbound DATA chunks. When faced with network 5341 congestion, SCTP might still bundle the data, even when this 5342 flag is present. 5344 payload protocol-id: a 32-bit unsigned integer that is to be 5345 passed to the peer indicating the type of payload protocol data 5346 being transmitted. This value is passed as opaque data by 5347 SCTP. 5349 sack-immediately flag: set the I bit on the last DATA chunk used 5350 for the user message to be transmitted. 5352 11.1.6. Set Primary 5354 SETPRIMARY(association id, destination transport address, 5355 [source transport address]) -> result 5357 Instructs the local SCTP to use the specified destination transport 5358 address as the primary path for sending packets. 5360 The result of attempting this operation is returned. If the 5361 specified destination transport address is not present in the 5362 "destination transport address list" returned earlier in an associate 5363 command or communication up notification, an error is returned. 5365 Mandatory attributes: 5366 association id: local handle to the SCTP association. 5368 destination transport address: specified as one of the transport 5369 addresses of the peer endpoint, which is used as the primary 5370 address for sending packets. This overrides the current 5371 primary address information maintained by the local SCTP 5372 endpoint. 5374 Optional attributes: 5375 source transport address: optionally, some implementations can 5376 allow you to set the default source address placed in all 5377 outgoing IP datagrams. 5379 11.1.7. Receive 5381 RECEIVE(association id, buffer address, buffer size [,stream id]) 5382 -> byte count [,transport address] [,stream id] 5383 [,stream sequence number] [,partial flag] [,payload protocol-id] 5385 This primitive reads the first user message in the SCTP in-queue into 5386 the buffer specified by ULP, if there is one available. The size of 5387 the message read, in bytes, will be returned. It might, depending on 5388 the specific implementation, also return other information such as 5389 the sender's address, the stream id on which it is received, whether 5390 there are more messages available for retrieval, etc. For ordered 5391 messages, their Stream Sequence Number might also be returned. 5393 Depending upon the implementation, if this primitive is invoked when 5394 no message is available the implementation returns an indication of 5395 this condition or blocks the invoking process until data does become 5396 available. 5398 Mandatory attributes: 5399 association id: local handle to the SCTP association 5401 buffer address: the memory location indicated by the ULP to store 5402 the received message. 5404 buffer size: the maximum size of data to be received, in bytes. 5406 Optional attributes: 5407 stream id: to indicate which stream to receive the data on. 5409 stream sequence number: the Stream Sequence Number assigned by 5410 the sending SCTP peer. 5412 partial flag: if this returned flag is set to 1, then this 5413 primitive contains a partial delivery of the whole message. 5414 When this flag is set, the stream id and stream sequence number 5415 accompanies this primitive. When this flag is set to 0, it 5416 indicates that no more deliveries will be received for this 5417 stream sequence number. 5419 payload protocol-id: a 32-bit unsigned integer that is received 5420 from the peer indicating the type of payload protocol of the 5421 received data. This value is passed as opaque data by SCTP. 5423 11.1.8. Status 5425 STATUS(association id) -> status data 5427 This primitive returns a data block containing the following 5428 information: 5430 * association connection state, 5432 * destination transport address list, 5434 * destination transport address reachability states, 5436 * current receiver window size, 5438 * current congestion window sizes, 5440 * number of unacknowledged DATA chunks, 5442 * number of DATA chunks pending receipt, 5444 * primary path, 5446 * most recent SRTT on primary path, 5448 * RTO on primary path, 5450 * SRTT and RTO on other destination addresses, etc. 5452 Mandatory attributes: 5453 association id: local handle to the SCTP association. 5455 Optional attributes: 5456 None. 5458 11.1.9. Change Heartbeat 5460 CHANGE HEARTBEAT(association id, destination transport address, 5461 new state [,interval]) -> result 5463 Instructs the local endpoint to enable or disable heartbeat on the 5464 specified destination transport address. 5466 The result of attempting this operation is returned. 5468 Note: Even when enabled, heartbeat will not take place if the 5469 destination transport address is not idle. 5471 Mandatory attributes: 5472 association id: local handle to the SCTP association. 5474 destination transport address: specified as one of the transport 5475 addresses of the peer endpoint. 5477 new state: the new state of heartbeat for this destination 5478 transport address (either enabled or disabled). 5480 Optional attributes: 5481 interval: if present, indicates the frequency of the heartbeat if 5482 this is to enable heartbeat on a destination transport address. 5483 This value is added to the RTO of the destination transport 5484 address. This value, if present, affects all destinations. 5486 11.1.10. Request HeartBeat 5488 REQUESTHEARTBEAT(association id, destination transport address) 5489 -> result 5491 Instructs the local endpoint to perform a HeartBeat on the specified 5492 destination transport address of the given association. The returned 5493 result indicates whether the transmission of the HEARTBEAT chunk to 5494 the destination address is successful. 5496 Mandatory attributes: 5497 association id: local handle to the SCTP association. 5499 destination transport address: the transport address of the 5500 association on which a heartbeat is issued. 5502 Optional attributes: 5503 None. 5505 11.1.11. Get SRTT Report 5507 GETSRTTREPORT(association id, destination transport address) 5508 -> srtt result 5510 Instructs the local SCTP to report the current SRTT measurement on 5511 the specified destination transport address of the given association. 5512 The returned result can be an integer containing the most recent SRTT 5513 in milliseconds. 5515 Mandatory attributes: 5516 association id: local handle to the SCTP association. 5518 destination transport address: the transport address of the 5519 association on which the SRTT measurement is to be reported. 5521 Optional attributes: 5522 None. 5524 11.1.12. Set Failure Threshold 5526 SETFAILURETHRESHOLD(association id, destination transport address, 5527 failure threshold) -> result 5529 This primitive allows the local SCTP to customize the reachability 5530 failure detection threshold 'Path.Max.Retrans' for the specified 5531 destination address. 5533 Mandatory attributes: 5534 association id: local handle to the SCTP association. 5536 destination transport address: the transport address of the 5537 association on which the failure detection threshold is to be 5538 set. 5540 failure threshold: the new value of 'Path.Max.Retrans' for the 5541 destination address. 5543 Optional attributes: 5544 None. 5546 11.1.13. Set Protocol Parameters 5548 SETPROTOCOLPARAMETERS(association id, 5549 [destination transport address,] protocol parameter list) 5550 -> result 5552 This primitive allows the local SCTP to customize the protocol 5553 parameters. 5555 Mandatory attributes: 5556 association id: local handle to the SCTP association. 5558 protocol parameter list: the specific names and values of the 5559 protocol parameters (e.g., 'Association.Max.Retrans' (see 5560 Section 16), or other parameters like the DSCP) that the SCTP 5561 user wishes to customize. 5563 Optional attributes: 5564 destination transport address: some of the protocol parameters 5565 might be set on a per destination transport address basis. 5567 11.1.14. Receive Unsent Message 5569 RECEIVE_UNSENT(data retrieval id, buffer address, buffer size 5570 [,stream id] [, stream sequence number] [,partial flag] 5571 [,payload protocol-id]) 5573 Mandatory attributes: 5574 data retrieval id: the identification passed to the ULP in the 5575 failure notification. 5577 buffer address: the memory location indicated by the ULP to store 5578 the received message. 5580 buffer size: the maximum size of data to be received, in bytes. 5582 Optional attributes: 5583 stream id: this is a return value that is set to indicate which 5584 stream the data was sent to. 5586 stream sequence number: this value is returned indicating the 5587 Stream Sequence Number that was associated with the message. 5589 partial flag: if this returned flag is set to 1, then this 5590 message is a partial delivery of the whole message. When this 5591 flag is set, the stream id and stream sequence number 5592 accompanies this primitive. When this flag is set to 0, it 5593 indicates that no more deliveries will be received for this 5594 stream sequence number. 5596 payload protocol-id: The 32 bit unsigned integer that was sent to 5597 be sent to the peer indicating the type of payload protocol of 5598 the received data. 5600 11.1.15. Receive Unacknowledged Message 5602 RECEIVE_UNACKED(data retrieval id, buffer address, buffer size, 5603 [,stream id] [,stream sequence number] [,partial flag] 5604 [,payload protocol-id]) 5606 Mandatory attributes: 5607 data retrieval id: the identification passed to the ULP in the 5608 failure notification. 5610 buffer address: the memory location indicated by the ULP to store 5611 the received message. 5613 buffer size: the maximum size of data to be received, in bytes. 5615 Optional attributes: 5616 stream id: this is a return value that is set to indicate which 5617 stream the data was sent to. 5619 stream sequence number: this value is returned indicating the 5620 Stream Sequence Number that was associated with the message. 5622 partial flag: if this returned flag is set to 1, then this 5623 message is a partial delivery of the whole message. When this 5624 flag is set, the stream id and stream sequence number 5625 accompanies this primitive. When this flag is set to 0, it 5626 indicates that no more deliveries will be received for this 5627 stream sequence number. 5629 payload protocol-id: the 32-bit unsigned integer that was sent to 5630 the peer indicating the type of payload protocol of the 5631 received data. 5633 11.1.16. Destroy SCTP Instance 5635 DESTROY(local SCTP instance name) 5637 Mandatory attributes: 5638 local SCTP instance name: this is the value that was passed to 5639 the application in the initialize primitive and it indicates 5640 which SCTP instance is to be destroyed. 5642 Optional attributes: 5643 None. 5645 11.2. SCTP-to-ULP 5647 It is assumed that the operating system or application environment 5648 provides a means for the SCTP to asynchronously signal the ULP 5649 process. When SCTP does signal a ULP process, certain information is 5650 passed to the ULP. 5652 IMPLEMENTATION NOTE: In some cases, this might be done through a 5653 separate socket or error channel. 5655 11.2.1. DATA ARRIVE Notification 5657 SCTP invokes this notification on the ULP when a user message is 5658 successfully received and ready for retrieval. 5660 The following might optionally be passed with the notification: 5662 association id: local handle to the SCTP association. 5664 stream id: to indicate which stream the data is received on. 5666 11.2.2. SEND FAILURE Notification 5668 If a message cannot be delivered, SCTP invokes this notification on 5669 the ULP. 5671 The following might optionally be passed with the notification: 5673 association id: local handle to the SCTP association. 5675 data retrieval id: an identification used to retrieve unsent and 5676 unacknowledged data. 5678 cause code: indicating the reason of the failure, e.g., size too 5679 large, message life time expiration, etc. 5681 context: optional information associated with this message (see 5682 Section 11.1.5). 5684 11.2.3. NETWORK STATUS CHANGE Notification 5686 When a destination transport address is marked inactive (e.g., when 5687 SCTP detects a failure) or marked active (e.g., when SCTP detects a 5688 recovery), SCTP invokes this notification on the ULP. 5690 The following is passed with the notification: 5692 association id: local handle to the SCTP association. 5694 destination transport address: this indicates the destination 5695 transport address of the peer endpoint affected by the change. 5697 new-status: this indicates the new status. 5699 11.2.4. COMMUNICATION UP Notification 5701 This notification is used when SCTP becomes ready to send or receive 5702 user messages, or when a lost communication to an endpoint is 5703 restored. 5705 IMPLEMENTATION NOTE: If the ASSOCIATE primitive is implemented as a 5706 blocking function call, the association parameters are returned as a 5707 result of the ASSOCIATE primitive itself. In that case, 5708 COMMUNICATION UP notification is optional at the association 5709 initiator's side. 5711 The following is passed with the notification: 5713 association id: local handle to the SCTP association. 5715 status: This indicates what type of event has occurred. 5717 destination transport address list: the complete set of transport 5718 addresses of the peer. 5720 outbound stream count: the maximum number of streams allowed to be 5721 used in this association by the ULP. 5723 inbound stream count: the number of streams the peer endpoint has 5724 requested with this association (this might not be the same number 5725 as 'outbound stream count'). 5727 11.2.5. COMMUNICATION LOST Notification 5729 When SCTP loses communication to an endpoint completely (e.g., via 5730 Heartbeats) or detects that the endpoint has performed an abort 5731 operation, it invokes this notification on the ULP. 5733 The following is passed with the notification: 5735 association id: local handle to the SCTP association. 5737 status: this indicates what type of event has occurred; the status 5738 might indicate that a failure OR a normal termination event 5739 occurred in response to a shutdown or abort request. 5741 The following might be passed with the notification: 5743 data retrieval id: an identification used to retrieve unsent and 5744 unacknowledged data. 5746 last-acked: the TSN last acked by that peer endpoint. 5748 last-sent: the TSN last sent to that peer endpoint. 5750 Upper Layer Abort Reason: the abort reason specified in case of a 5751 user-initiated abort. 5753 11.2.6. COMMUNICATION ERROR Notification 5755 When SCTP receives an ERROR chunk from its peer and decides to notify 5756 its ULP, it can invoke this notification on the ULP. 5758 The following can be passed with the notification: 5760 association id: local handle to the SCTP association. 5762 error info: this indicates the type of error and optionally some 5763 additional information received through the ERROR chunk. 5765 11.2.7. RESTART Notification 5767 When SCTP detects that the peer has restarted, it might send this 5768 notification to its ULP. 5770 The following can be passed with the notification: 5772 association id: local handle to the SCTP association. 5774 11.2.8. SHUTDOWN COMPLETE Notification 5776 When SCTP completes the shutdown procedures (Section 9.2), this 5777 notification is passed to the upper layer. 5779 The following can be passed with the notification: 5781 association id: local handle to the SCTP association. 5783 12. Security Considerations 5785 12.1. Security Objectives 5787 As a common transport protocol designed to reliably carry time- 5788 sensitive user messages, such as billing or signaling messages for 5789 telephony services, between two networked endpoints, SCTP has the 5790 following security objectives. 5792 * availability of reliable and timely data transport services 5794 * integrity of the user-to-user information carried by SCTP 5796 12.2. SCTP Responses to Potential Threats 5798 SCTP could potentially be used in a wide variety of risk situations. 5799 It is important for operators of systems running SCTP to analyze 5800 their particular situations and decide on the appropriate counter- 5801 measures. 5803 Operators of systems running SCTP might consult [RFC2196] for 5804 guidance in securing their site. 5806 12.2.1. Countering Insider Attacks 5808 The principles of [RFC2196] might be applied to minimize the risk of 5809 theft of information or sabotage by insiders. Such procedures 5810 include publication of security policies, control of access at the 5811 physical, software, and network levels, and separation of services. 5813 12.2.2. Protecting against Data Corruption in the Network 5815 Where the risk of undetected errors in datagrams delivered by the 5816 lower-layer transport services is considered to be too great, 5817 additional integrity protection is required. If this additional 5818 protection were provided in the application layer, the SCTP header 5819 would remain vulnerable to deliberate integrity attacks. While the 5820 existing SCTP mechanisms for detection of packet replays are 5821 considered sufficient for normal operation, stronger protections are 5822 needed to protect SCTP when the operating environment contains 5823 significant risk of deliberate attacks from a sophisticated 5824 adversary. 5826 The SCTP Authentication extension SCTP-AUTH [RFC4895] MAY be used 5827 when the threat environment requires stronger integrity protections, 5828 but does not require confidentiality. 5830 12.2.3. Protecting Confidentiality 5832 In most cases, the risk of breach of confidentiality applies to the 5833 signaling data payload, not to the SCTP or lower-layer protocol 5834 overheads. If that is true, encryption of the SCTP user data only 5835 might be considered. As with the supplementary checksum service, 5836 user data encryption MAY be performed by the SCTP user application. 5837 Alternately, the user application MAY use an implementation-specific 5838 API to request that the IP Encapsulating Security Payload (ESP) 5839 [RFC4303] be used to provide confidentiality and integrity. 5841 Particularly for mobile users, the requirement for confidentiality 5842 might include the masking of IP addresses and ports. In this case, 5843 ESP SHOULD be used instead of application-level confidentiality. If 5844 ESP is used to protect confidentiality of SCTP traffic, an ESP 5845 cryptographic transform that includes cryptographic integrity 5846 protection MUST be used, because if there is a confidentiality threat 5847 there will also be a strong integrity threat. 5849 Whenever ESP is in use, application-level encryption is not generally 5850 required. 5852 Regardless of where confidentiality is provided, the Internet Key 5853 Exchange Protocol version 2 (IKEv2) [RFC7296] SHOULD be used for key 5854 management. 5856 Operators might consult [RFC4301] for more information on the 5857 security services available at and immediately above the Internet 5858 Protocol layer. 5860 12.2.4. Protecting against Blind Denial-of-Service Attacks 5862 A blind attack is one where the attacker is unable to intercept or 5863 otherwise see the content of data flows passing to and from the 5864 target SCTP node. Blind denial-of-service attacks can take the form 5865 of flooding, masquerade, or improper monopolization of services. 5867 12.2.4.1. Flooding 5869 The objective of flooding is to cause loss of service and incorrect 5870 behavior at target systems through resource exhaustion, interference 5871 with legitimate transactions, and exploitation of buffer-related 5872 software bugs. Flooding can be directed either at the SCTP node or 5873 at resources in the intervening IP Access Links or the Internet. 5874 Where the latter entities are the target, flooding will manifest 5875 itself as loss of network services, including potentially the breach 5876 of any firewalls in place. 5878 In general, protection against flooding begins at the equipment 5879 design level, where it includes measures such as: 5881 * avoiding commitment of limited resources before determining that 5882 the request for service is legitimate. 5884 * giving priority to completion of processing in progress over the 5885 acceptance of new work. 5887 * identification and removal of duplicate or stale queued requests 5888 for service. 5890 * not responding to unexpected packets sent to non-unicast 5891 addresses. 5893 Network equipment is expected to be capable of generating an alarm 5894 and log if a suspicious increase in traffic occurs. The log provides 5895 information such as the identity of the incoming link and source 5896 address(es) used, which will help the network or SCTP system operator 5897 to take protective measures. Procedures are expected to be in place 5898 for the operator to act on such alarms if a clear pattern of abuse 5899 emerges. 5901 The design of SCTP is resistant to flooding attacks, particularly in 5902 its use of a four-way startup handshake, its use of a cookie to defer 5903 commitment of resources at the responding SCTP node until the 5904 handshake is completed, and its use of a Verification Tag to prevent 5905 insertion of extraneous packets into the flow of an established 5906 association. 5908 The IP Authentication Header and Encapsulating Security Payload might 5909 be useful in reducing the risk of certain kinds of denial-of-service 5910 attacks. 5912 Support for the Host Name Address parameter has been removed from the 5913 protocol. Endpoints receiving INIT or INIT ACK chunks containing the 5914 Host Name Address parameter MUST send an ABORT chunk in response and 5915 MAY include an "Unresolvable Address" error cause. 5917 12.2.4.2. Blind Masquerade 5919 Masquerade can be used to deny service in several ways: 5921 * by tying up resources at the target SCTP node to which the 5922 impersonated node has limited access. For example, the target 5923 node can by policy permit a maximum of one SCTP association with 5924 the impersonated SCTP node. The masquerading attacker can attempt 5925 to establish an association purporting to come from the 5926 impersonated node so that the latter cannot do so when it requires 5927 it. 5929 * by deliberately allowing the impersonation to be detected, thereby 5930 provoking counter-measures that cause the impersonated node to be 5931 locked out of the target SCTP node. 5933 * by interfering with an established association by inserting 5934 extraneous content such as a SHUTDOWN request. 5936 SCTP reduces the risk of blind masquerade attacks through IP spoofing 5937 by use of the four-way startup handshake. Because the initial 5938 exchange is memory-less, no lockout mechanism is triggered by blind 5939 masquerade attacks. In addition, the INIT ACK containing the State 5940 Cookie is transmitted back to the IP address from which it received 5941 the INIT. Thus, the attacker would not receive the INIT ACK 5942 containing the State Cookie. SCTP protects against insertion of 5943 extraneous packets into the flow of an established association by use 5944 of the Verification Tag. 5946 Logging of received INIT requests and abnormalities such as 5947 unexpected INIT ACKs might be considered as a way to detect patterns 5948 of hostile activity. However, the potential usefulness of such 5949 logging has to be weighed against the increased SCTP startup 5950 processing it implies, rendering the SCTP node more vulnerable to 5951 flooding attacks. Logging is pointless without the establishment of 5952 operating procedures to review and analyze the logs on a routine 5953 basis. 5955 12.2.4.3. Improper Monopolization of Services 5957 Attacks under this heading are performed openly and legitimately by 5958 the attacker. They are directed against fellow users of the target 5959 SCTP node or of the shared resources between the attacker and the 5960 target node. Possible attacks include the opening of a large number 5961 of associations between the attacker's node and the target, or 5962 transfer of large volumes of information within a legitimately 5963 established association. 5965 Policy limits are expected to be placed on the number of associations 5966 per adjoining SCTP node. SCTP user applications are expected to be 5967 capable of detecting large volumes of illegitimate or "no-op" 5968 messages within a given association and either logging or terminating 5969 the association as a result, based on local policy. 5971 12.3. SCTP Interactions with Firewalls 5973 It is helpful for some firewalls if they can inspect just the first 5974 fragment of a fragmented SCTP packet and unambiguously determine 5975 whether it corresponds to an INIT chunk (for further information, 5976 please refer to [RFC1858]). Accordingly, we stress the requirements, 5977 as stated in Section 3.1, that (1) an INIT chunk MUST NOT be bundled 5978 with any other chunk in a packet and (2) a packet containing an INIT 5979 chunk MUST have a zero Verification Tag. The receiver of an INIT 5980 chunk MUST silently discard the INIT chunk and all further chunks if 5981 the INIT chunk is bundled with other chunks or the packet has a non- 5982 zero Verification Tag. 5984 12.4. Protection of Non-SCTP-Capable Hosts 5986 To provide a non-SCTP-capable host with the same level of protection 5987 against attacks as for SCTP-capable ones, all SCTP stacks MUST 5988 implement the ICMP handling described in Section 10. 5990 When an SCTP stack receives a packet containing multiple control or 5991 DATA chunks and the processing of the packet requires the sending of 5992 multiple chunks in response, the sender of the response chunk(s) MUST 5993 NOT send more than one packet. If bundling is supported, multiple 5994 response chunks that fit into a single packet MAY be bundled together 5995 into one single response packet. If bundling is not supported, then 5996 the sender MUST NOT send more than one response chunk and MUST 5997 discard all other responses. Note that this rule does not apply to a 5998 SACK chunk, since a SACK chunk is, in itself, a response to DATA and 5999 a SACK does not require a response of more DATA. 6001 An SCTP implementation SHOULD abort the association if it receives a 6002 SACK acknowledging a TSN that has not been sent. 6004 An SCTP implementation that receives an INIT that would require a 6005 large packet in response, due to the inclusion of multiple ERROR 6006 parameters, MAY (at its discretion) elect to omit some or all of the 6007 ERROR parameters to reduce the size of the INIT ACK. Due to a 6008 combination of the size of the COOKIE parameter and the number of 6009 addresses a receiver of an INIT indicates to a peer, it is always 6010 possible that the INIT ACK will be larger than the original INIT. An 6011 SCTP implementation SHOULD attempt to make the INIT ACK as small as 6012 possible to reduce the possibility of byte amplification attacks. 6014 13. Network Management Considerations 6016 The MIB module for SCTP defined in [RFC3873] applies for the version 6017 of the protocol specified in this document. 6019 14. Recommended Transmission Control Block (TCB) Parameters 6021 This section details a set of parameters that are expected to be 6022 contained within the TCB for an implementation. This section is for 6023 illustrative purposes and is not considered to be requirements on an 6024 implementation or as an exhaustive list of all parameters inside an 6025 SCTP TCB. Each implementation might need its own additional 6026 parameters for optimization. 6028 14.1. Parameters Necessary for the SCTP Instance 6030 Associations: A list of current associations and mappings to the 6031 data consumers for each association. This might be in the form of 6032 a hash table or other implementation-dependent structure. The 6033 data consumers might be process identification information such as 6034 file descriptors, named pipe pointer, or table pointers dependent 6035 on how SCTP is implemented. 6037 Secret Key: A secret key used by this endpoint to compute the MAC. 6038 This SHOULD be a cryptographic quality random number with a 6039 sufficient length. Discussion in [RFC4086] can be helpful in 6040 selection of the key. 6042 Address List: The list of IP addresses that this instance has bound. 6043 This information is passed to one's peer(s) in INIT and INIT ACK 6044 chunks. 6046 SCTP Port: The local SCTP port number to which the endpoint is 6047 bound. 6049 14.2. Parameters Necessary per Association (i.e., the TCB) 6051 Peer Verification Tag: Tag value to be sent in every packet and is 6052 received in the INIT or INIT ACK chunk. 6054 My Verification Tag: Tag expected in every inbound packet and sent 6055 in the INIT or INIT ACK chunk. 6057 State: COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING, 6058 SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT. 6060 Note: No "CLOSED" state is illustrated since if a association is 6061 "CLOSED" its TCB SHOULD be removed. 6063 Peer Transport Address List: A list of SCTP transport addresses to 6064 which the peer is bound. This information is derived from the 6065 INIT or INIT ACK and is used to associate an inbound packet with a 6066 given association. Normally, this information is hashed or keyed 6067 for quick lookup and access of the TCB. 6069 Primary Path: This is the current primary destination transport 6070 address of the peer endpoint. It might also specify a source 6071 transport address on this endpoint. 6073 Overall Error Count: The overall association error count. 6075 Overall Error Threshold: The threshold for this association that if 6076 the Overall Error Count reaches will cause this association to be 6077 torn down. 6079 Peer Rwnd: Current calculated value of the peer's rwnd. 6081 Next TSN: The next TSN number to be assigned to a new DATA chunk. 6082 This is sent in the INIT or INIT ACK chunk to the peer and 6083 incremented each time a DATA chunk is assigned a TSN (normally 6084 just prior to transmit or during fragmentation). 6086 Last Rcvd TSN: This is the last TSN received in sequence. This 6087 value is set initially by taking the peer's initial TSN, received 6088 in the INIT or INIT ACK chunk, and subtracting one from it. 6090 Mapping Array: An array of bits or bytes indicating which out-of- 6091 order TSNs have been received (relative to the Last Rcvd TSN). If 6092 no gaps exist, i.e., no out-of- order packets have been received, 6093 this array will be set to all zero. This structure might be in 6094 the form of a circular buffer or bit array. 6096 Ack State: This flag indicates if the next received packet is to be 6097 responded to with a SACK. This is initialized to 0. When a 6098 packet is received it is incremented. If this value reaches 2 or 6099 more, a SACK is sent and the value is reset to 0. Note: This is 6100 used only when no DATA chunks are received out of order. When 6101 DATA chunks are out of order, SACKs are not delayed (see 6102 Section 6). 6104 Inbound Streams: An array of structures to track the inbound 6105 streams, normally including the next sequence number expected and 6106 possibly the stream number. 6108 Outbound Streams: An array of structures to track the outbound 6109 streams, normally including the next sequence number to be sent on 6110 the stream. 6112 Reasm Queue: A reassembly queue. 6114 Local Transport Address List: The list of local IP addresses bound 6115 in to this association. 6117 Association PMTU: The smallest PMTU discovered for all of the peer's 6118 transport addresses. 6120 14.3. Per Transport Address Data 6122 For each destination transport address in the peer's address list 6123 derived from the INIT or INIT ACK chunk, a number of data elements 6124 need to be maintained including: 6126 Error Count: The current error count for this destination. 6128 Error Threshold: Current error threshold for this destination, i.e., 6129 what value marks the destination down if error count reaches this 6130 value. 6132 cwnd: The current congestion window. 6134 ssthresh: The current ssthresh value. 6136 RTO: The current retransmission timeout value. 6138 SRTT: The current smoothed round-trip time. 6140 RTTVAR: The current RTT variation. 6142 partial bytes acked: The tracking method for increase of cwnd when 6143 in congestion avoidance mode (see Section 7.2.2). 6145 state: The current state of this destination, i.e., DOWN, UP, ALLOW- 6146 HB, NO-HEARTBEAT, etc. 6148 PMTU: The current known path MTU. 6150 Per Destination Timer: A timer used by each destination. 6152 RTO-Pending: A flag used to track if one of the DATA chunks sent to 6153 this address is currently being used to compute an RTT. If this 6154 flag is 0, the next DATA chunk sent to this destination is 6155 expected to be used to compute an RTT and this flag is expected to 6156 be set. Every time the RTT calculation completes (i.e., the DATA 6157 chunk is SACK'd), clear this flag. 6159 last-time: The time to which this destination was last sent. This 6160 can be to determine if a HEARTBEAT is needed. 6162 14.4. General Parameters Needed 6164 Out Queue: A queue of outbound DATA chunks. 6166 In Queue: A queue of inbound DATA chunks. 6168 15. IANA Considerations 6170 SCTP defines three registries that IANA maintains: 6172 * through definition of additional chunk types, 6174 * through definition of additional parameter types, or 6176 * through definition of additional cause codes within ERROR chunks. 6178 SCTP requires that the IANA Port Numbers registry be opened for SCTP 6179 port registrations, Section 15.6 describes how. An IESG-appointed 6180 Expert Reviewer supports IANA in evaluating SCTP port allocation 6181 requests. 6183 15.1. IETF-Defined Chunk Extension 6185 The assignment of new chunk type codes is done through an IETF Review 6186 action, as defined in [RFC8126]. Documentation for a new chunk MUST 6187 contain the following information: 6189 a) A long and short name for the new chunk type. 6191 b) A detailed description of the structure of the chunk, which MUST 6192 conform to the basic structure defined in Section 3.2. 6194 c) A detailed definition and description of intended use of each 6195 field within the chunk, including the chunk flags if any. 6196 Defined chunk flags will be used as initial entries in the chunk 6197 flags table for the new chunk type. 6199 d) A detailed procedural description of the use of the new chunk 6200 type within the operation of the protocol. 6202 The last chunk type (255) is reserved for future extension if 6203 necessary. 6205 For each new chunk type, IANA creates a registration table for the 6206 chunk flags of that type. The procedure for registering particular 6207 chunk flags is described in Section 15.2. 6209 15.2. IETF Chunk Flags Registration 6211 The assignment of new chunk flags is done through an RFC Required 6212 action, as defined in [RFC8126]. Documentation for the chunk flags 6213 MUST contain the following information: 6215 a) A name for the new chunk flag. 6217 b) A detailed procedural description of the use of the new chunk 6218 flag within the operation of the protocol. It MUST be considered 6219 that implementations not supporting the flag will send '0' on 6220 transmit and just ignore it on receipt. 6222 IANA selects a chunk flags value. This MUST be one of 0x01, 0x02, 6223 0x04, 0x08, 0x10, 0x20, 0x40, or 0x80, which MUST be unique within 6224 the chunk flag values for the specific chunk type. 6226 15.3. IETF-Defined Chunk Parameter Extension 6228 The assignment of new chunk parameter type codes is done through an 6229 IETF Review action as defined in [RFC8126]. Documentation of the 6230 chunk parameter MUST contain the following information: 6232 a) Name of the parameter type. 6234 b) Detailed description of the structure of the parameter field. 6235 This structure MUST conform to the general Type-Length-Value 6236 format described in Section 3.2.1. 6238 c) Detailed definition of each component of the parameter value. 6240 d) Detailed description of the intended use of this parameter type, 6241 and an indication of whether and under what circumstances 6242 multiple instances of this parameter type can be found within the 6243 same chunk. 6245 e) Each parameter type MUST be unique across all chunks. 6247 15.4. IETF-Defined Additional Error Causes 6249 Additional cause codes can be allocated in the range 11 to 65535 6250 through a Specification Required action as defined in [RFC8126]. 6251 Provided documentation MUST include the following information: 6253 a) Name of the error condition. 6255 b) Detailed description of the conditions under which an SCTP 6256 endpoint issues an ERROR (or ABORT) with this cause code. 6258 c) Expected action by the SCTP endpoint that receives an ERROR (or 6259 ABORT) chunk containing this cause code. 6261 d) Detailed description of the structure and content of data fields 6262 that accompany this cause code. 6264 The initial word (32 bits) of a cause code parameter MUST conform to 6265 the format shown in Section 3.3.10, i.e.: 6267 * first 2 bytes contain the cause code value 6269 * last 2 bytes contain the length of the cause parameter. 6271 15.5. Payload Protocol Identifiers 6273 Except for value 0, which is reserved by SCTP to indicate an 6274 unspecified payload protocol identifier in a DATA chunk, SCTP will 6275 not be responsible for standardizing or verifying any payload 6276 protocol identifiers; SCTP simply receives the identifier from the 6277 upper layer and carries it with the corresponding payload data. 6279 The upper layer, i.e., the SCTP user, SHOULD standardize any specific 6280 protocol identifier with IANA if it is so desired. The use of any 6281 specific payload protocol identifier is out of the scope of SCTP. 6283 15.6. Port Numbers Registry 6285 SCTP services can use contact port numbers to provide service to 6286 unknown callers, as in TCP and UDP. IANA is therefore requested to 6287 open the existing "Service Name and Transport Protocol Port Number 6288 Registry" for SCTP using the following rules, which we intend to mesh 6289 well with existing port-number registration procedures. An IESG- 6290 appointed expert reviewer supports IANA in evaluating SCTP port 6291 allocation requests, according to the procedure defined in [RFC8126]. 6292 The details of this process are defined in [RFC6335]. 6294 This document registers the following ports. (These registrations 6295 are to be considered models to follow for future allocation 6296 requests.) 6297 discard 9/sctp Discard # IETF TSVWG 6298 # Randall Stewart 6299 # [RFC4960] 6301 The discard service, which accepts SCTP connections on port 6302 9, discards all incoming application data and sends no data 6303 in response. Thus, SCTP's discard port is analogous to 6304 TCP's discard port, and might be used to check the health 6305 of an SCTP stack. 6307 ftp-data 20/sctp FTP # IETF TSVWG 6308 # Randall Stewart 6309 # [RFC4960] 6311 ftp 21/sctp FTP # IETF TSVWG 6312 # Randall Stewart 6313 # [RFC4960] 6315 File Transfer Protocol (FTP) data (20) and control ports 6316 (21). 6318 ssh 22/sctp SSH # IETF TSVWG 6319 # Randall Stewart 6320 # [RFC4960] 6322 The Secure Shell (SSH) remote login service, which allows 6323 secure shell logins to a host. 6325 http 80/sctp HTTP # IETF TSVWG 6326 # Randall Stewart 6327 # [RFC4960] 6329 World Wide Web HTTP over SCTP. 6331 bgp 179/sctp BGP # IETF TSVWG 6332 # Randall Stewart 6333 # [RFC4960] 6335 Border Gateway Protocol over SCTP. 6337 https 443/sctp HTTPS # IETF TSVWG 6338 # Randall Stewart 6339 # [RFC4960] 6341 World Wide Web HTTP over TLS/SSL over SCTP. 6343 16. Suggested SCTP Protocol Parameter Values 6345 The following protocol parameters are RECOMMENDED: 6347 RTO.Initial: 1 second 6349 RTO.Min: 1 second 6351 RTO.Max: 60 seconds 6353 Max.Burst: 4 6355 RTO.Alpha: 1/8 6357 RTO.Beta: 1/4 6359 Valid.Cookie.Life: 60 seconds 6361 Association.Max.Retrans: 10 attempts 6363 Path.Max.Retrans: 5 attempts (per destination address) 6365 Max.Init.Retransmits: 8 attempts 6367 HB.interval: 30 seconds 6369 HB.Max.Burst: 1 6371 SACK.Delay: 200 milliseconds 6373 IMPLEMENTATION NOTE: The SCTP implementation can allow ULP to 6374 customize some of these protocol parameters (see Section 11). 6376 'RTO.Min' SHOULD be set as described above in this section. 6378 17. Acknowledgements 6380 An undertaking represented by this updated document is not a small 6381 feat and represents the summation of the initial co-authors of 6382 [RFC2960]: Q. Xie, K. Morneault, C. Sharp, H. Schwarzbauer, 6383 T. Taylor, I. Rytina, M. Kalla, L. Zhang, and V. Paxson. 6385 Add to that, the comments from everyone who contributed to [RFC2960]: 6386 Mark Allman, R. J. Atkinson, Richard Band, Scott Bradner, Steve 6387 Bellovin, Peter Butler, Ram Dantu, R. Ezhirpavai, Mike Fisk, Sally 6388 Floyd, Atsushi Fukumoto, Matt Holdrege, Henry Houh, Christian 6389 Huitema, Gary Lehecka, Jonathan Lee, David Lehmann, John Loughney, 6390 Daniel Luan, Barry Nagelberg, Thomas Narten, Erik Nordmark, Lyndon 6391 Ong, Shyamal Prasad, Kelvin Porter, Heinz Prantner, Jarno Rajahalme, 6392 Raymond E. Reeves, Renee Revis, Ivan Arias Rodriguez, A. Sankar, Greg 6393 Sidebottom, Brian Wyld, La Monte Yarroll, and many others for their 6394 invaluable comments. 6396 Then, add the co-authors of [RFC4460]: I. Arias-Rodriguez, K. Poon, 6397 and A. Caro. 6399 Then add to these the efforts of all the subsequent seven SCTP 6400 interoperability tests and those who commented on [RFC4460] as shown 6401 in its acknowledgements: Barry Zuckerman, La Monte Yarroll, Qiaobing 6402 Xie, Wang Xiaopeng, Jonathan Wood, Jeff Waskow, Mike Turner, John 6403 Townsend, Sabina Torrente, Cliff Thomas, Yuji Suzuki, Manoj Solanki, 6404 Sverre Slotte, Keyur Shah, Jan Rovins, Ben Robinson, Renee Revis, Ian 6405 Periam, RC Monee, Sanjay Rao, Sujith Radhakrishnan, Heinz Prantner, 6406 Biren Patel, Nathalie Mouellic, Mitch Miers, Bernward Meyknecht, Stan 6407 McClellan, Oliver Mayor, Tomas Orti Martin, Sandeep Mahajan, David 6408 Lehmann, Jonathan Lee, Philippe Langlois, Karl Knutson, Joe Keller, 6409 Gareth Keily, Andreas Jungmaier, Janardhan Iyengar, Mutsuya Irie, 6410 John Hebert, Kausar Hassan, Fred Hasle, Dan Harrison, Jon Grim, 6411 Laurent Glaude, Steven Furniss, Atsushi Fukumoto, Ken Fujita, Steve 6412 Dimig, Thomas Curran, Serkan Cil, Melissa Campbell, Peter Butler, Rob 6413 Brennan, Harsh Bhondwe, Brian Bidulock, Caitlin Bestler, Jon Berger, 6414 Robby Benedyk, Stephen Baucke, Sandeep Balani, and Ronnie Sellar. 6416 A special thanks to Mark Allman, who should actually be a co-author 6417 for his work on the max-burst, but managed to wiggle out due to a 6418 technicality. 6420 Also, we would like to acknowledge Lyndon Ong and Phil Conrad for 6421 their valuable input and many contributions. 6423 Furthermore, you have [RFC4960], and those who have commented upon 6424 that including Alfred Hönes and Ronnie Sellars. 6426 Then, add the co-author of [RFC8540]: Maksim Proshin. 6428 And people who have commented on [RFC8540]: Pontus Andersson, Eric 6429 W. Biederman, Cedric Bonnet, Spencer Dawkins, Gorry Fairhurst, 6430 Benjamin Kaduk, Mirja Kühlewind, Peter Lei, Gyula Marosi, Lionel 6431 Morand, Jeff Morriss, Tom Petch, Kacheong Poon, Julien Pourtet, Irene 6432 Rüngeler, Michael Welzl, and Qiaobing Xie. 6434 And finally the people who have provided comments for this document 6435 including Maksim Proshin and Gorry Fairhurst. 6437 Our thanks cannot be adequately expressed to all of you who have 6438 participated in the coding, testing, and updating process of this 6439 document. All we can say is, Thank You! 6441 18. Normative References 6443 [ITU.V42.1994] 6444 International Telecommunications Union, "Error-correcting 6445 Procedures for DCEs Using Asynchronous-to-Synchronous 6446 Conversion", ITU-T Recommendation V.42, 1994. 6448 [RFC0768] Postel, J., "User Datagram Protocol", STD 6, RFC 768, 6449 DOI 10.17487/RFC0768, August 1980, 6450 . 6452 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 6453 RFC 793, DOI 10.17487/RFC0793, September 1981, 6454 . 6456 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 6457 Communication Layers", STD 3, RFC 1122, 6458 DOI 10.17487/RFC1122, October 1989, 6459 . 6461 [RFC1123] Braden, R., Ed., "Requirements for Internet Hosts - 6462 Application and Support", STD 3, RFC 1123, 6463 DOI 10.17487/RFC1123, October 1989, 6464 . 6466 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 6467 DOI 10.17487/RFC1191, November 1990, 6468 . 6470 [RFC1982] Elz, R. and R. Bush, "Serial Number Arithmetic", RFC 1982, 6471 DOI 10.17487/RFC1982, August 1996, 6472 . 6474 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6475 Requirement Levels", BCP 14, RFC 2119, 6476 DOI 10.17487/RFC2119, March 1997, 6477 . 6479 [RFC3873] Pastor, J. and M. Belinchon, "Stream Control Transmission 6480 Protocol (SCTP) Management Information Base (MIB)", 6481 RFC 3873, DOI 10.17487/RFC3873, September 2004, 6482 . 6484 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 6485 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 6486 2006, . 6488 [RFC4301] Kent, S. and K. Seo, "Security Architecture for the 6489 Internet Protocol", RFC 4301, DOI 10.17487/RFC4301, 6490 December 2005, . 6492 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 6493 RFC 4303, DOI 10.17487/RFC4303, December 2005, 6494 . 6496 [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 6497 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 6498 . 6500 [RFC6335] Cotton, M., Eggert, L., Touch, J., Westerlund, M., and S. 6501 Cheshire, "Internet Assigned Numbers Authority (IANA) 6502 Procedures for the Management of the Service Name and 6503 Transport Protocol Port Number Registry", BCP 165, 6504 RFC 6335, DOI 10.17487/RFC6335, August 2011, 6505 . 6507 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 6508 Kivinen, "Internet Key Exchange Protocol Version 2 6509 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 6510 2014, . 6512 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 6513 Writing an IANA Considerations Section in RFCs", BCP 26, 6514 RFC 8126, DOI 10.17487/RFC8126, June 2017, 6515 . 6517 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6518 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6519 May 2017, . 6521 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 6522 (IPv6) Specification", STD 86, RFC 8200, 6523 DOI 10.17487/RFC8200, July 2017, 6524 . 6526 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 6527 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 6528 DOI 10.17487/RFC8201, July 2017, 6529 . 6531 [RFC8899] Fairhurst, G., Jones, T., Tüxen, M., Rüngeler, I., and T. 6532 Völker, "Packetization Layer Path MTU Discovery for 6533 Datagram Transports", RFC 8899, DOI 10.17487/RFC8899, 6534 September 2020, . 6536 19. Informative References 6538 [FALL96] Fall, K. and S. Floyd, "Simulation-based Comparisons of 6539 Tahoe, Reno, and SACK TCP", SIGCOM 99, V. 26, N. 3, 6540 pp 5-21, July 1996. 6542 [SAVAGE99] Savage, S., Cardwell, N., Wetherall, D., and T. Anderson, 6543 "TCP Congestion Control with a Misbehaving Receiver", ACM 6544 Computer Communications Review 29(5), October 1999. 6546 [ALLMAN99] Allman, M. and V. Paxson, "On Estimating End-to-End 6547 Network Path Properties", SIGCOM 99, 1999. 6549 [WILLIAMS93] 6550 Williams, R., "A PAINLESS GUIDE TO CRC ERROR DETECTION 6551 ALGORITHMS", SIGCOM 99, August 1993, 6552 . 6555 [RFC1858] Ziemba, G., Reed, D., and P. Traina, "Security 6556 Considerations for IP Fragment Filtering", RFC 1858, 6557 DOI 10.17487/RFC1858, October 1995, 6558 . 6560 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 6561 Hashing for Message Authentication", RFC 2104, 6562 DOI 10.17487/RFC2104, February 1997, 6563 . 6565 [RFC2196] Fraser, B., "Site Security Handbook", FYI 8, RFC 2196, 6566 DOI 10.17487/RFC2196, September 1997, 6567 . 6569 [RFC2522] Karn, P. and W. Simpson, "Photuris: Session-Key Management 6570 Protocol", RFC 2522, DOI 10.17487/RFC2522, March 1999, 6571 . 6573 [RFC2960] Stewart, R., Xie, Q., Morneault, K., Sharp, C., 6574 Schwarzbauer, H., Taylor, T., Rytina, I., Kalla, M., 6575 Zhang, L., and V. Paxson, "Stream Control Transmission 6576 Protocol", RFC 2960, DOI 10.17487/RFC2960, October 2000, 6577 . 6579 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 6580 "Randomness Requirements for Security", BCP 106, RFC 4086, 6581 DOI 10.17487/RFC4086, June 2005, 6582 . 6584 [RFC4460] Stewart, R., Arias-Rodriguez, I., Poon, K., Caro, A., and 6585 M. Tuexen, "Stream Control Transmission Protocol (SCTP) 6586 Specification Errata and Issues", RFC 4460, 6587 DOI 10.17487/RFC4460, April 2006, 6588 . 6590 [RFC4895] Tuexen, M., Stewart, R., Lei, P., and E. Rescorla, 6591 "Authenticated Chunks for the Stream Control Transmission 6592 Protocol (SCTP)", RFC 4895, DOI 10.17487/RFC4895, August 6593 2007, . 6595 [RFC4960] Stewart, R., Ed., "Stream Control Transmission Protocol", 6596 RFC 4960, DOI 10.17487/RFC4960, September 2007, 6597 . 6599 [RFC6458] Stewart, R., Tuexen, M., Poon, K., Lei, P., and V. 6600 Yasevich, "Sockets API Extensions for the Stream Control 6601 Transmission Protocol (SCTP)", RFC 6458, 6602 DOI 10.17487/RFC6458, December 2011, 6603 . 6605 [RFC7053] Tuexen, M., Ruengeler, I., and R. Stewart, "SACK- 6606 IMMEDIATELY Extension for the Stream Control Transmission 6607 Protocol", RFC 7053, DOI 10.17487/RFC7053, November 2013, 6608 . 6610 [RFC8540] Stewart, R., Tuexen, M., and M. Proshin, "Stream Control 6611 Transmission Protocol: Errata and Issues in RFC 4960", 6612 RFC 8540, DOI 10.17487/RFC8540, February 2019, 6613 . 6615 Appendix A. CRC32c Checksum Calculation 6617 We define a 'reflected value' as one that is the opposite of the 6618 normal bit order of the machine. The 32-bit CRC (Cyclic Redundancy 6619 Check) is calculated as described for CRC32c and uses the polynomial 6620 code 0x11EDC6F41 (Castagnoli93) or 6621 x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+ 6622 x^14+x^13+x^11+x^10+x^9+x^8+x^6+x^0. The CRC is computed using a 6623 procedure similar to ETHERNET CRC [ITU.V42.1994], modified to reflect 6624 transport-level usage. 6626 CRC computation uses polynomial division. A message bit-string M is 6627 transformed to a polynomial, M(X), and the CRC is calculated from 6628 M(X) using polynomial arithmetic. 6630 When CRCs are used at the link layer, the polynomial is derived from 6631 on-the-wire bit ordering: the first bit 'on the wire' is the high- 6632 order coefficient. Since SCTP is a transport-level protocol, it 6633 cannot know the actual serial-media bit ordering. Moreover, 6634 different links in the path between SCTP endpoints can use different 6635 link-level bit orders. 6637 A convention therefore is established for mapping SCTP transport 6638 messages to polynomials for purposes of CRC computation. The bit- 6639 ordering for mapping SCTP messages to polynomials is that bytes are 6640 taken most-significant first, but within each byte, bits are taken 6641 least-significant first. The first byte of the message provides the 6642 eight highest coefficients. Within each byte, the least-significant 6643 SCTP bit gives the most-significant polynomial coefficient within 6644 that byte, and the most-significant SCTP bit is the least-significant 6645 polynomial coefficient in that byte. (This bit ordering is sometimes 6646 called 'mirrored' or 'reflected' [WILLIAMS93].) CRC polynomials are 6647 to be transformed back into SCTP transport-level byte values, using a 6648 consistent mapping. 6650 The SCTP transport-level CRC value can be calculated as follows: 6652 * CRC input data are assigned to a byte stream, numbered from 0 to 6653 N-1. 6655 * The transport-level byte stream is mapped to a polynomial value. 6656 An N-byte PDU with j bytes numbered 0 to N-1 is considered as 6657 coefficients of a polynomial M(x) of order 8N-1, with bit 0 of 6658 byte j being coefficient x^(8(N-j)-8), and bit 7 of byte j being 6659 coefficient x^(8(N-j)-1). 6661 * The CRC remainder register is initialized with all 1s and the CRC 6662 is computed with an algorithm that simultaneously multiplies by 6663 x^32 and divides by the CRC polynomial. 6665 * The polynomial is multiplied by x^32 and divided by G(x), the 6666 generator polynomial, producing a remainder R(x) of degree less 6667 than or equal to 31. 6669 * The coefficients of R(x) are considered a 32-bit sequence. 6671 * The bit sequence is complemented. The result is the CRC 6672 polynomial. 6674 * The CRC polynomial is mapped back into SCTP transport-level bytes. 6675 The coefficient of x^31 gives the value of bit 7 of SCTP byte 0, 6676 and the coefficient of x^24 gives the value of bit 0 of byte 0. 6677 The coefficient of x^7 gives bit 7 of byte 3, and the coefficient 6678 of x^0 gives bit 0 of byte 3. The resulting 4-byte transport- 6679 level sequence is the 32-bit SCTP checksum value. 6681 IMPLEMENTATION NOTE: Standards documents, textbooks, and vendor 6682 literature on CRCs often follow an alternative formulation, in which 6683 the register used to hold the remainder of the long-division 6684 algorithm is initialized to zero rather than all-1s, and instead the 6685 first 32 bits of the message are complemented. The long-division 6686 algorithm used in our formulation is specified such that the initial 6687 multiplication by 2^32 and the long-division are combined into one 6688 simultaneous operation. For such algorithms, and for messages longer 6689 than 64 bits, the two specifications are precisely equivalent. That 6690 equivalence is the intent of this document. 6692 Implementors of SCTP are warned that both specifications are to be 6693 found in the literature, sometimes with no restriction on the long- 6694 division algorithm. The choice of formulation in this document is to 6695 permit non-SCTP usage, where the same CRC algorithm can be used to 6696 protect messages shorter than 64 bits. 6698 There can be a computational advantage in validating the association 6699 against the Verification Tag, prior to performing a checksum, as 6700 invalid tags will result in the same action as a bad checksum in most 6701 cases. The exceptions for this technique would be INIT and some 6702 SHUTDOWN-COMPLETE exchanges, as well as a stale COOKIE ECHO. These 6703 special-case exchanges represent small packets and will minimize the 6704 effect of the checksum calculation. 6706 The following non-normative sample code is taken from an open-source 6707 CRC generator [WILLIAMS93], using the "mirroring" technique and 6708 yielding a lookup table for SCTP CRC32c with 256 entries, each 32 6709 bits wide. While neither especially slow nor especially fast, as 6710 software table-lookup CRCs go, it has the advantage of working on 6711 both big-endian and little-endian CPUs, using the same (host-order) 6712 lookup tables, and using only the predefined ntohl() and htonl() 6713 operations. The code is somewhat modified from [WILLIAMS93], to 6714 ensure portability between big-endian and little-endian 6715 architectures. (Note that if the byte endian-ness of the target 6716 architecture is known to be little-endian, the final bit-reversal and 6717 byte-reversal steps can be folded into a single operation.) 6718 6719 /****************************************************************/ 6720 /* Note: The definitions for Ross Williams's table generator */ 6721 /* would be TB_WIDTH=4, TB_POLY=0x1EDC6F41, TB_REVER=TRUE. */ 6722 /* For Mr. Williams's direct calculation code, use the settings */ 6723 /* cm_width=32, cm_poly=0x1EDC6F41, cm_init=0xFFFFFFFF, */ 6724 /* cm_refin=TRUE, cm_refot=TRUE, cm_xorot=0x00000000. */ 6725 /****************************************************************/ 6727 /* Example of the crc table file */ 6728 #ifndef __crc32cr_h__ 6729 #define __crc32cr_h__ 6731 #define CRC32C_POLY 0x1EDC6F41UL 6732 #define CRC32C(c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF]) 6734 uint32_t crc_c[256] = { 6735 0x00000000UL, 0xF26B8303UL, 0xE13B70F7UL, 0x1350F3F4UL, 6736 0xC79A971FUL, 0x35F1141CUL, 0x26A1E7E8UL, 0xD4CA64EBUL, 6737 0x8AD958CFUL, 0x78B2DBCCUL, 0x6BE22838UL, 0x9989AB3BUL, 6738 0x4D43CFD0UL, 0xBF284CD3UL, 0xAC78BF27UL, 0x5E133C24UL, 6739 0x105EC76FUL, 0xE235446CUL, 0xF165B798UL, 0x030E349BUL, 6740 0xD7C45070UL, 0x25AFD373UL, 0x36FF2087UL, 0xC494A384UL, 6741 0x9A879FA0UL, 0x68EC1CA3UL, 0x7BBCEF57UL, 0x89D76C54UL, 6742 0x5D1D08BFUL, 0xAF768BBCUL, 0xBC267848UL, 0x4E4DFB4BUL, 6743 0x20BD8EDEUL, 0xD2D60DDDUL, 0xC186FE29UL, 0x33ED7D2AUL, 6744 0xE72719C1UL, 0x154C9AC2UL, 0x061C6936UL, 0xF477EA35UL, 6745 0xAA64D611UL, 0x580F5512UL, 0x4B5FA6E6UL, 0xB93425E5UL, 6746 0x6DFE410EUL, 0x9F95C20DUL, 0x8CC531F9UL, 0x7EAEB2FAUL, 6747 0x30E349B1UL, 0xC288CAB2UL, 0xD1D83946UL, 0x23B3BA45UL, 6748 0xF779DEAEUL, 0x05125DADUL, 0x1642AE59UL, 0xE4292D5AUL, 6749 0xBA3A117EUL, 0x4851927DUL, 0x5B016189UL, 0xA96AE28AUL, 6750 0x7DA08661UL, 0x8FCB0562UL, 0x9C9BF696UL, 0x6EF07595UL, 6751 0x417B1DBCUL, 0xB3109EBFUL, 0xA0406D4BUL, 0x522BEE48UL, 6752 0x86E18AA3UL, 0x748A09A0UL, 0x67DAFA54UL, 0x95B17957UL, 6753 0xCBA24573UL, 0x39C9C670UL, 0x2A993584UL, 0xD8F2B687UL, 6754 0x0C38D26CUL, 0xFE53516FUL, 0xED03A29BUL, 0x1F682198UL, 6755 0x5125DAD3UL, 0xA34E59D0UL, 0xB01EAA24UL, 0x42752927UL, 6756 0x96BF4DCCUL, 0x64D4CECFUL, 0x77843D3BUL, 0x85EFBE38UL, 6757 0xDBFC821CUL, 0x2997011FUL, 0x3AC7F2EBUL, 0xC8AC71E8UL, 6758 0x1C661503UL, 0xEE0D9600UL, 0xFD5D65F4UL, 0x0F36E6F7UL, 6759 0x61C69362UL, 0x93AD1061UL, 0x80FDE395UL, 0x72966096UL, 6760 0xA65C047DUL, 0x5437877EUL, 0x4767748AUL, 0xB50CF789UL, 6761 0xEB1FCBADUL, 0x197448AEUL, 0x0A24BB5AUL, 0xF84F3859UL, 6762 0x2C855CB2UL, 0xDEEEDFB1UL, 0xCDBE2C45UL, 0x3FD5AF46UL, 6763 0x7198540DUL, 0x83F3D70EUL, 0x90A324FAUL, 0x62C8A7F9UL, 6764 0xB602C312UL, 0x44694011UL, 0x5739B3E5UL, 0xA55230E6UL, 6765 0xFB410CC2UL, 0x092A8FC1UL, 0x1A7A7C35UL, 0xE811FF36UL, 6766 0x3CDB9BDDUL, 0xCEB018DEUL, 0xDDE0EB2AUL, 0x2F8B6829UL, 6767 0x82F63B78UL, 0x709DB87BUL, 0x63CD4B8FUL, 0x91A6C88CUL, 6768 0x456CAC67UL, 0xB7072F64UL, 0xA457DC90UL, 0x563C5F93UL, 6769 0x082F63B7UL, 0xFA44E0B4UL, 0xE9141340UL, 0x1B7F9043UL, 6770 0xCFB5F4A8UL, 0x3DDE77ABUL, 0x2E8E845FUL, 0xDCE5075CUL, 6771 0x92A8FC17UL, 0x60C37F14UL, 0x73938CE0UL, 0x81F80FE3UL, 6772 0x55326B08UL, 0xA759E80BUL, 0xB4091BFFUL, 0x466298FCUL, 6773 0x1871A4D8UL, 0xEA1A27DBUL, 0xF94AD42FUL, 0x0B21572CUL, 6774 0xDFEB33C7UL, 0x2D80B0C4UL, 0x3ED04330UL, 0xCCBBC033UL, 6775 0xA24BB5A6UL, 0x502036A5UL, 0x4370C551UL, 0xB11B4652UL, 6776 0x65D122B9UL, 0x97BAA1BAUL, 0x84EA524EUL, 0x7681D14DUL, 6777 0x2892ED69UL, 0xDAF96E6AUL, 0xC9A99D9EUL, 0x3BC21E9DUL, 6778 0xEF087A76UL, 0x1D63F975UL, 0x0E330A81UL, 0xFC588982UL, 6779 0xB21572C9UL, 0x407EF1CAUL, 0x532E023EUL, 0xA145813DUL, 6780 0x758FE5D6UL, 0x87E466D5UL, 0x94B49521UL, 0x66DF1622UL, 6781 0x38CC2A06UL, 0xCAA7A905UL, 0xD9F75AF1UL, 0x2B9CD9F2UL, 6782 0xFF56BD19UL, 0x0D3D3E1AUL, 0x1E6DCDEEUL, 0xEC064EEDUL, 6783 0xC38D26C4UL, 0x31E6A5C7UL, 0x22B65633UL, 0xD0DDD530UL, 6784 0x0417B1DBUL, 0xF67C32D8UL, 0xE52CC12CUL, 0x1747422FUL, 6785 0x49547E0BUL, 0xBB3FFD08UL, 0xA86F0EFCUL, 0x5A048DFFUL, 6786 0x8ECEE914UL, 0x7CA56A17UL, 0x6FF599E3UL, 0x9D9E1AE0UL, 6787 0xD3D3E1ABUL, 0x21B862A8UL, 0x32E8915CUL, 0xC083125FUL, 6788 0x144976B4UL, 0xE622F5B7UL, 0xF5720643UL, 0x07198540UL, 6789 0x590AB964UL, 0xAB613A67UL, 0xB831C993UL, 0x4A5A4A90UL, 6790 0x9E902E7BUL, 0x6CFBAD78UL, 0x7FAB5E8CUL, 0x8DC0DD8FUL, 6791 0xE330A81AUL, 0x115B2B19UL, 0x020BD8EDUL, 0xF0605BEEUL, 6792 0x24AA3F05UL, 0xD6C1BC06UL, 0xC5914FF2UL, 0x37FACCF1UL, 6793 0x69E9F0D5UL, 0x9B8273D6UL, 0x88D28022UL, 0x7AB90321UL, 6794 0xAE7367CAUL, 0x5C18E4C9UL, 0x4F48173DUL, 0xBD23943EUL, 6795 0xF36E6F75UL, 0x0105EC76UL, 0x12551F82UL, 0xE03E9C81UL, 6796 0x34F4F86AUL, 0xC69F7B69UL, 0xD5CF889DUL, 0x27A40B9EUL, 6797 0x79B737BAUL, 0x8BDCB4B9UL, 0x988C474DUL, 0x6AE7C44EUL, 6798 0xBE2DA0A5UL, 0x4C4623A6UL, 0x5F16D052UL, 0xAD7D5351UL, 6799 }; 6801 #endif 6803 /* Example of table build routine */ 6805 #include 6806 #include 6808 #define OUTPUT_FILE "crc32cr.h" 6809 #define CRC32C_POLY 0x1EDC6F41UL 6811 static FILE *tf; 6812 static uint32_t 6813 reflect_32(uint32_t b) 6814 { 6815 int i; 6816 uint32_t rw = 0UL; 6818 for (i = 0; i < 32; i++) { 6819 if (b & 1) 6820 rw |= 1 << (31 - i); 6821 b >>= 1; 6822 } 6823 return (rw); 6824 } 6826 static uint32_t 6827 build_crc_table (int index) 6828 { 6829 int i; 6830 uint32_t rb; 6832 rb = reflect_32(index); 6834 for (i = 0; i < 8; i++) { 6835 if (rb & 0x80000000UL) 6836 rb = (rb << 1) ^ (uint32_t)CRC32C_POLY; 6837 else 6838 rb <<= 1; 6839 } 6840 return (reflect_32(rb)); 6841 } 6843 int 6844 main (void) 6845 { 6846 int i; 6848 printf("\nGenerating CRC32c table file <%s>.\n", 6849 OUTPUT_FILE); 6850 if ((tf = fopen(OUTPUT_FILE, "w")) == NULL) { 6851 printf("Unable to open %s.\n", OUTPUT_FILE); 6852 exit (1); 6853 } 6854 fprintf(tf, "#ifndef __crc32cr_h__\n"); 6855 fprintf(tf, "#define __crc32cr_h__\n\n"); 6856 fprintf(tf, "#define CRC32C_POLY 0x%08XUL\n", 6857 (uint32_t)CRC32C_POLY); 6858 fprintf(tf, 6859 "#define CRC32C(c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF])\n"); 6861 fprintf(tf, "\nuint32_t crc_c[256] =\n{\n"); 6862 for (i = 0; i < 256; i++) { 6863 fprintf(tf, "0x%08XUL,", build_crc_table (i)); 6864 if ((i & 3) == 3) 6865 fprintf(tf, "\n"); 6866 else 6867 fprintf(tf, " "); 6868 } 6869 fprintf(tf, "};\n\n#endif\n"); 6871 if (fclose(tf) != 0) 6872 printf("Unable to close <%s>.\n", OUTPUT_FILE); 6873 else 6874 printf("\nThe CRC32c table has been written to <%s>.\n", 6875 OUTPUT_FILE); 6876 return (0); 6877 } 6879 /* Example of crc insertion */ 6881 #include "crc32cr.h" 6883 uint32_t 6884 generate_crc32c(unsigned char *buffer, unsigned int length) 6885 { 6886 unsigned int i; 6887 uint32_t crc32 = 0xffffffffUL; 6888 uint32_t result; 6889 uint8_t byte0, byte1, byte2, byte3; 6891 for (i = 0; i < length; i++) { 6892 CRC32C(crc32, buffer[i]); 6893 } 6895 result = ~crc32; 6897 /* result now holds the negated polynomial remainder, 6898 * since the table and algorithm are "reflected" [williams95]. 6899 * That is, result has the same value as if we mapped the message 6900 * to a polynomial, computed the host-bit-order polynomial 6901 * remainder, performed final negation, and then did an 6902 * end-for-end bit-reversal. 6903 * Note that a 32-bit bit-reversal is identical to four in-place 6904 * 8-bit bit-reversals followed by an end-for-end byteswap. 6905 * In other words, the bits of each byte are in the right order, 6906 * but the bytes have been byteswapped. So, we now do an explicit 6907 * byteswap. On a little-endian machine, this byteswap and 6908 * the final ntohl cancel out and could be elided. 6910 */ 6912 byte0 = result & 0xff; 6913 byte1 = (result>>8) & 0xff; 6914 byte2 = (result>>16) & 0xff; 6915 byte3 = (result>>24) & 0xff; 6916 crc32 = ((byte0 << 24) | 6917 (byte1 << 16) | 6918 (byte2 << 8) | 6919 byte3); 6920 return (crc32); 6921 } 6923 int 6924 insert_crc32(unsigned char *buffer, unsigned int length) 6925 { 6926 SCTP_message *message; 6927 uint32_t crc32; 6928 message = (SCTP_message *) buffer; 6929 message->common_header.checksum = 0UL; 6930 crc32 = generate_crc32c(buffer,length); 6931 /* and insert it into the message */ 6932 message->common_header.checksum = htonl(crc32); 6933 return (1); 6934 } 6936 int 6937 validate_crc32(unsigned char *buffer, unsigned int length) 6938 { 6939 SCTP_message *message; 6940 unsigned int i; 6941 uint32_t original_crc32; 6942 uint32_t crc32; 6944 /* save and zero checksum */ 6945 message = (SCTP_message *)buffer; 6946 original_crc32 = ntohl(message->common_header.checksum); 6947 message->common_header.checksum = 0L; 6948 crc32 = generate_crc32c(buffer, length); 6949 return ((original_crc32 == crc32) ? 1 : -1); 6950 } 6951 6953 Authors' Addresses 6955 Randall R. Stewart 6956 Netflix, Inc. 6957 2455 Heritage Green Ave 6958 Davenport, FL 33837 6959 United States 6961 Email: randall@lakerest.net 6963 Michael Tüxen 6964 Münster University of Applied Sciences 6965 Stegerwaldstrasse 39 6966 48565 Steinfurt 6967 Germany 6969 Email: tuexen@fh-muenster.de 6971 Karen E. E. Nielsen 6972 Kamstrup A/S 6973 Industrivej 28 6974 DK-8660 Skanderborg 6975 Denmark 6977 Email: kee@kamstrup.com