idnits 2.17.1 draft-ietf-tsvwg-rfc4960-bis-11.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 -(6569): 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 10 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 (18 April 2021) is 1094 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 2428, but not defined == Missing Reference: 'SHUTDOWN' is mentioned on line 2458, but not defined == Missing Reference: 'ABORT' is mentioned on line 2421, 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: 20 October 2021 K. E. E. Nielsen 7 Kamstrup A/S 8 18 April 2021 10 Stream Control Transmission Protocol 11 draft-ietf-tsvwg-rfc4960-bis-11 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 maximum 27 transmission unit (PMTU) size, 29 * sequenced delivery of user messages within multiple streams, with 30 an option for order-of-arrival delivery of individual user 31 messages, 33 * optional bundling of multiple user messages into a single SCTP 34 packet, and 36 * network-level fault tolerance through supporting of multi-homing 37 at either or both ends of an association. 39 The design of SCTP includes appropriate congestion avoidance behavior 40 and resistance to flooding and masquerade attacks. 42 Status of This Memo 44 This Internet-Draft is submitted in full conformance with the 45 provisions of BCP 78 and BCP 79. 47 Internet-Drafts are working documents of the Internet Engineering 48 Task Force (IETF). Note that other groups may also distribute 49 working documents as Internet-Drafts. The list of current Internet- 50 Drafts is at https://datatracker.ietf.org/drafts/current/. 52 Internet-Drafts are draft documents valid for a maximum of six months 53 and may be updated, replaced, or obsoleted by other documents at any 54 time. It is inappropriate to use Internet-Drafts as reference 55 material or to cite them other than as "work in progress." 57 This Internet-Draft will expire on 20 October 2021. 59 Copyright Notice 61 Copyright (c) 2021 IETF Trust and the persons identified as the 62 document authors. All rights reserved. 64 This document is subject to BCP 78 and the IETF Trust's Legal 65 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 66 license-info) in effect on the date of publication of this document. 67 Please review these documents carefully, as they describe your rights 68 and restrictions with respect to this document. Code Components 69 extracted from this document must include Simplified BSD License text 70 as described in Section 4.e of the Trust Legal Provisions and are 71 provided without warranty as described in the Simplified BSD License. 73 This document may contain material from IETF Documents or IETF 74 Contributions published or made publicly available before November 75 10, 2008. The person(s) controlling the copyright in some of this 76 material may not have granted the IETF Trust the right to allow 77 modifications of such material outside the IETF Standards Process. 78 Without obtaining an adequate license from the person(s) controlling 79 the copyright in such materials, this document may not be modified 80 outside the IETF Standards Process, and derivative works of it may 81 not be created outside the IETF Standards Process, except to format 82 it for publication as an RFC or to translate it into languages other 83 than English. 85 Table of Contents 87 1. Conventions . . . . . . . . . . . . . . . . . . . . . . . . . 6 88 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 89 2.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 6 90 2.2. Architectural View of SCTP . . . . . . . . . . . . . . . 7 91 2.3. Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 8 92 2.4. Abbreviations . . . . . . . . . . . . . . . . . . . . . . 12 93 2.5. Functional View of SCTP . . . . . . . . . . . . . . . . . 12 94 2.5.1. Association Startup and Takedown . . . . . . . . . . 13 95 2.5.2. Sequenced Delivery within Streams . . . . . . . . . . 14 96 2.5.3. User Data Fragmentation . . . . . . . . . . . . . . . 14 97 2.5.4. Acknowledgement and Congestion Avoidance . . . . . . 14 98 2.5.5. Chunk Bundling . . . . . . . . . . . . . . . . . . . 15 99 2.5.6. Packet Validation . . . . . . . . . . . . . . . . . . 15 100 2.5.7. Path Management . . . . . . . . . . . . . . . . . . . 15 101 2.6. Serial Number Arithmetic . . . . . . . . . . . . . . . . 16 102 2.7. Changes from RFC 4960 . . . . . . . . . . . . . . . . . . 17 103 3. SCTP Packet Format . . . . . . . . . . . . . . . . . . . . . 17 104 3.1. SCTP Common Header Field Descriptions . . . . . . . . . . 17 105 3.2. Chunk Field Descriptions . . . . . . . . . . . . . . . . 19 106 3.2.1. Optional/Variable-Length Parameter Format . . . . . . 22 107 3.2.2. Reporting of Unrecognized Parameters . . . . . . . . 23 108 3.3. SCTP Chunk Definitions . . . . . . . . . . . . . . . . . 24 109 3.3.1. Payload Data (DATA) (0) . . . . . . . . . . . . . . . 24 110 3.3.2. Initiation (INIT) (1) . . . . . . . . . . . . . . . . 26 111 3.3.2.1. Optional/Variable-Length Parameters in INIT . . . 30 112 3.3.3. Initiation Acknowledgement (INIT ACK) (2) . . . . . . 32 113 3.3.3.1. Optional or Variable-Length Parameters . . . . . 36 114 3.3.4. Selective Acknowledgement (SACK) (3) . . . . . . . . 37 115 3.3.5. Heartbeat Request (HEARTBEAT) (4) . . . . . . . . . . 40 116 3.3.6. Heartbeat Acknowledgement (HEARTBEAT ACK) (5) . . . . 41 117 3.3.7. Abort Association (ABORT) (6) . . . . . . . . . . . . 42 118 3.3.8. Shutdown Association (SHUTDOWN) (7) . . . . . . . . . 43 119 3.3.9. Shutdown Acknowledgement (SHUTDOWN ACK) (8) . . . . . 44 120 3.3.10. Operation Error (ERROR) (9) . . . . . . . . . . . . . 44 121 3.3.10.1. Invalid Stream Identifier (1) . . . . . . . . . 46 122 3.3.10.2. Missing Mandatory Parameter (2) . . . . . . . . 47 123 3.3.10.3. Stale Cookie Error (3) . . . . . . . . . . . . . 47 124 3.3.10.4. Out of Resource (4) . . . . . . . . . . . . . . 48 125 3.3.10.5. Unresolvable Address (5) . . . . . . . . . . . . 48 126 3.3.10.6. Unrecognized Chunk Type (6) . . . . . . . . . . 48 127 3.3.10.7. Invalid Mandatory Parameter (7) . . . . . . . . 49 128 3.3.10.8. Unrecognized Parameters (8) . . . . . . . . . . 49 129 3.3.10.9. No User Data (9) . . . . . . . . . . . . . . . . 49 130 3.3.10.10. Cookie Received While Shutting Down (10) . . . . 50 131 3.3.10.11. Restart of an Association with New Addresses 132 (11) . . . . . . . . . . . . . . . . . . . . . . . 50 133 3.3.10.12. User-Initiated Abort (12) . . . . . . . . . . . 51 134 3.3.10.13. Protocol Violation (13) . . . . . . . . . . . . 51 135 3.3.11. Cookie Echo (COOKIE ECHO) (10) . . . . . . . . . . . 51 136 3.3.12. Cookie Acknowledgement (COOKIE ACK) (11) . . . . . . 52 137 3.3.13. Shutdown Complete (SHUTDOWN COMPLETE) (14) . . . . . 53 138 4. SCTP Association State Diagram . . . . . . . . . . . . . . . 53 139 5. Association Initialization . . . . . . . . . . . . . . . . . 56 140 5.1. Normal Establishment of an Association . . . . . . . . . 57 141 5.1.1. Handle Stream Parameters . . . . . . . . . . . . . . 59 142 5.1.2. Handle Address Parameters . . . . . . . . . . . . . . 59 143 5.1.3. Generating State Cookie . . . . . . . . . . . . . . . 61 144 5.1.4. State Cookie Processing . . . . . . . . . . . . . . . 62 145 5.1.5. State Cookie Authentication . . . . . . . . . . . . . 62 146 5.1.6. An Example of Normal Association Establishment . . . 63 147 5.2. Handle Duplicate or Unexpected INIT, INIT ACK, COOKIE ECHO, 148 and COOKIE ACK . . . . . . . . . . . . . . . . . . . . . 65 149 5.2.1. INIT Received in COOKIE-WAIT or COOKIE-ECHOED State 150 (Item B) . . . . . . . . . . . . . . . . . . . . . . 65 151 5.2.2. Unexpected INIT in States Other than CLOSED, 152 COOKIE-ECHOED, COOKIE-WAIT, and SHUTDOWN-ACK-SENT . . 66 153 5.2.3. Unexpected INIT ACK . . . . . . . . . . . . . . . . . 67 154 5.2.4. Handle a COOKIE ECHO when a TCB Exists . . . . . . . 67 155 5.2.4.1. An Example of a Association Restart . . . . . . . 70 156 5.2.5. Handle Duplicate COOKIE ACK . . . . . . . . . . . . . 72 157 5.2.6. Handle Stale COOKIE Error . . . . . . . . . . . . . . 72 158 5.3. Other Initialization Issues . . . . . . . . . . . . . . . 72 159 5.3.1. Selection of Tag Value . . . . . . . . . . . . . . . 73 160 5.4. Path Verification . . . . . . . . . . . . . . . . . . . . 73 161 6. User Data Transfer . . . . . . . . . . . . . . . . . . . . . 74 162 6.1. Transmission of DATA Chunks . . . . . . . . . . . . . . . 76 163 6.2. Acknowledgement on Reception of DATA Chunks . . . . . . . 79 164 6.2.1. Processing a Received SACK . . . . . . . . . . . . . 82 165 6.3. Management of Retransmission Timer . . . . . . . . . . . 84 166 6.3.1. RTO Calculation . . . . . . . . . . . . . . . . . . . 84 167 6.3.2. Retransmission Timer Rules . . . . . . . . . . . . . 85 168 6.3.3. Handle T3-rtx Expiration . . . . . . . . . . . . . . 86 169 6.4. Multi-Homed SCTP Endpoints . . . . . . . . . . . . . . . 88 170 6.4.1. Failover from an Inactive Destination Address . . . . 89 171 6.5. Stream Identifier and Stream Sequence Number . . . . . . 89 172 6.6. Ordered and Unordered Delivery . . . . . . . . . . . . . 90 173 6.7. Report Gaps in Received DATA TSNs . . . . . . . . . . . . 90 174 6.8. CRC32c Checksum Calculation . . . . . . . . . . . . . . . 92 175 6.9. Fragmentation and Reassembly . . . . . . . . . . . . . . 93 176 6.10. Bundling . . . . . . . . . . . . . . . . . . . . . . . . 94 177 7. Congestion Control . . . . . . . . . . . . . . . . . . . . . 95 178 7.1. SCTP Differences from TCP Congestion Control . . . . . . 95 179 7.2. SCTP Slow-Start and Congestion Avoidance . . . . . . . . 96 180 7.2.1. Slow-Start . . . . . . . . . . . . . . . . . . . . . 97 181 7.2.2. Congestion Avoidance . . . . . . . . . . . . . . . . 99 182 7.2.3. Congestion Control . . . . . . . . . . . . . . . . . 100 183 7.2.4. Fast Retransmit on Gap Reports . . . . . . . . . . . 100 184 7.2.5. Making Changes to Differentiated Services Code 185 Points . . . . . . . . . . . . . . . . . . . . . . . 102 186 7.3. PMTU Discovery . . . . . . . . . . . . . . . . . . . . . 102 187 8. Fault Management . . . . . . . . . . . . . . . . . . . . . . 102 188 8.1. Endpoint Failure Detection . . . . . . . . . . . . . . . 103 189 8.2. Path Failure Detection . . . . . . . . . . . . . . . . . 103 190 8.3. Path Heartbeat . . . . . . . . . . . . . . . . . . . . . 104 191 8.4. Handle "Out of the Blue" Packets . . . . . . . . . . . . 106 192 8.5. Verification Tag . . . . . . . . . . . . . . . . . . . . 107 193 8.5.1. Exceptions in Verification Tag Rules . . . . . . . . 108 194 9. Termination of Association . . . . . . . . . . . . . . . . . 109 195 9.1. Abort of an Association . . . . . . . . . . . . . . . . . 109 196 9.2. Shutdown of an Association . . . . . . . . . . . . . . . 110 197 10. ICMP Handling . . . . . . . . . . . . . . . . . . . . . . . . 112 198 11. Interface with Upper Layer . . . . . . . . . . . . . . . . . 114 199 11.1. ULP-to-SCTP . . . . . . . . . . . . . . . . . . . . . . 114 200 11.1.1. Initialize . . . . . . . . . . . . . . . . . . . . . 114 201 11.1.2. Associate . . . . . . . . . . . . . . . . . . . . . 115 202 11.1.3. Shutdown . . . . . . . . . . . . . . . . . . . . . . 116 203 11.1.4. Abort . . . . . . . . . . . . . . . . . . . . . . . 116 204 11.1.5. Send . . . . . . . . . . . . . . . . . . . . . . . . 117 205 11.1.6. Set Primary . . . . . . . . . . . . . . . . . . . . 118 206 11.1.7. Receive . . . . . . . . . . . . . . . . . . . . . . 119 207 11.1.8. Status . . . . . . . . . . . . . . . . . . . . . . . 120 208 11.1.9. Change Heartbeat . . . . . . . . . . . . . . . . . . 120 209 11.1.10. Request Heartbeat . . . . . . . . . . . . . . . . . 121 210 11.1.11. Get SRTT Report . . . . . . . . . . . . . . . . . . 121 211 11.1.12. Set Failure Threshold . . . . . . . . . . . . . . . 122 212 11.1.13. Set Protocol Parameters . . . . . . . . . . . . . . 122 213 11.1.14. Receive Unsent Message . . . . . . . . . . . . . . . 123 214 11.1.15. Receive Unacknowledged Message . . . . . . . . . . . 123 215 11.1.16. Destroy SCTP Instance . . . . . . . . . . . . . . . 124 216 11.2. SCTP-to-ULP . . . . . . . . . . . . . . . . . . . . . . 124 217 11.2.1. DATA ARRIVE Notification . . . . . . . . . . . . . . 125 218 11.2.2. SEND FAILURE Notification . . . . . . . . . . . . . 125 219 11.2.3. NETWORK STATUS CHANGE Notification . . . . . . . . . 125 220 11.2.4. COMMUNICATION UP Notification . . . . . . . . . . . 126 221 11.2.5. COMMUNICATION LOST Notification . . . . . . . . . . 126 222 11.2.6. COMMUNICATION ERROR Notification . . . . . . . . . . 127 223 11.2.7. RESTART Notification . . . . . . . . . . . . . . . . 127 224 11.2.8. SHUTDOWN COMPLETE Notification . . . . . . . . . . . 127 225 12. Security Considerations . . . . . . . . . . . . . . . . . . . 127 226 12.1. Security Objectives . . . . . . . . . . . . . . . . . . 127 227 12.2. SCTP Responses to Potential Threats . . . . . . . . . . 128 228 12.2.1. Countering Insider Attacks . . . . . . . . . . . . . 128 229 12.2.2. Protecting against Data Corruption in the Network . 128 230 12.2.3. Protecting Confidentiality . . . . . . . . . . . . . 128 231 12.2.4. Protecting against Blind Denial-of-Service 232 Attacks . . . . . . . . . . . . . . . . . . . . . . . 129 233 12.2.4.1. Flooding . . . . . . . . . . . . . . . . . . . . 129 234 12.2.4.2. Blind Masquerade . . . . . . . . . . . . . . . . 130 235 12.2.4.3. Improper Monopolization of Services . . . . . . 131 236 12.3. SCTP Interactions with Firewalls . . . . . . . . . . . . 131 237 12.4. Protection of Non-SCTP-Capable Hosts . . . . . . . . . . 131 238 13. Network Management Considerations . . . . . . . . . . . . . . 132 239 14. Recommended Transmission Control Block (TCB) Parameters . . . 132 240 14.1. Parameters Necessary for the SCTP Instance . . . . . . . 132 241 14.2. Parameters Necessary per Association (i.e., the TCB) . . 133 242 14.3. Per Transport Address Data . . . . . . . . . . . . . . . 134 243 14.4. General Parameters Needed . . . . . . . . . . . . . . . 135 244 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 135 245 15.1. IETF-Defined Chunk Extension . . . . . . . . . . . . . . 136 246 15.2. IETF Chunk Flags Registration . . . . . . . . . . . . . 136 247 15.3. IETF-Defined Chunk Parameter Extension . . . . . . . . . 137 248 15.4. IETF-Defined Additional Error Causes . . . . . . . . . . 137 249 15.5. Payload Protocol Identifiers . . . . . . . . . . . . . . 138 250 15.6. Port Numbers Registry . . . . . . . . . . . . . . . . . 138 251 16. Suggested SCTP Protocol Parameter Values . . . . . . . . . . 140 252 17. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 140 253 18. Normative References . . . . . . . . . . . . . . . . . . . . 142 254 19. Informative References . . . . . . . . . . . . . . . . . . . 144 255 Appendix A. CRC32c Checksum Calculation . . . . . . . . . . . . 145 256 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 152 258 1. Conventions 260 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 261 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 262 "OPTIONAL" in this document are to be interpreted as described in BCP 263 14 [RFC2119] [RFC8174] when, and only when, they appear in all 264 capitals, as shown here. 266 2. Introduction 268 This section explains the reasoning behind the development of the 269 Stream Control Transmission Protocol (SCTP), the services it offers, 270 and the basic concepts needed to understand the detailed description 271 of the protocol. 273 This document obsoletes [RFC4960], if approved. 275 2.1. Motivation 277 TCP [RFC0793] has performed immense service as the primary means of 278 reliable data transfer in IP networks. However, an increasing number 279 of recent applications have found TCP too limiting, and have 280 incorporated their own reliable data transfer protocol on top of UDP 281 [RFC0768]. The limitations that users have wished to bypass include 282 the following: 284 * TCP provides both reliable data transfer and strict order-of- 285 transmission delivery of data. Some applications need reliable 286 transfer without sequence maintenance, while others would be 287 satisfied with partial ordering of the data. In both of these 288 cases, the head-of-line blocking offered by TCP causes unnecessary 289 delay. 291 * The stream-oriented nature of TCP is often an inconvenience. 292 Applications add their own record marking to delineate their 293 messages, and make explicit use of the push facility to ensure 294 that a complete message is transferred in a reasonable time. 296 * The limited scope of TCP sockets complicates the task of providing 297 highly-available data transfer capability using multi-homed hosts. 299 * TCP is relatively vulnerable to denial-of-service attacks, such as 300 SYN attacks. 302 Transport of PSTN signaling across the IP network is an application 303 for which all of these limitations of TCP are relevant. While this 304 application directly motivated the development of SCTP, other 305 applications might find SCTP a good match to their requirements. 307 2.2. Architectural View of SCTP 309 SCTP is viewed as a layer between the SCTP user application ("SCTP 310 user" for short) and a connectionless packet network service such as 311 IP. The remainder of this document assumes SCTP runs on top of IP. 312 The basic service offered by SCTP is the reliable transfer of user 313 messages between peer SCTP users. It performs this service within 314 the context of an association between two SCTP endpoints. Section 11 315 of this document sketches the API that exists at the boundary between 316 the SCTP and the SCTP user layers. 318 SCTP is connection-oriented in nature, but the SCTP association is a 319 broader concept than the TCP connection. SCTP provides the means for 320 each SCTP endpoint (Section 2.3) to provide the other endpoint 321 (during association startup) with a list of transport addresses 322 (i.e., multiple IP addresses in combination with an SCTP port) 323 through which that endpoint can be reached and from which it will 324 originate SCTP packets. The association spans transfers over all of 325 the possible source/destination combinations that can be generated 326 from each endpoint's lists. 328 _____________ _____________ 329 | SCTP User | | SCTP User | 330 | Application | | Application | 331 |-------------| |-------------| 332 | SCTP | | SCTP | 333 | Transport | | Transport | 334 | Service | | Service | 335 |-------------| |-------------| 336 | |One or more ---- One or more| | 337 | IP Network |IP address \/ IP address| IP Network | 338 | Service |appearances /\ appearances| Service | 339 |_____________| ---- |_____________| 341 SCTP Node A |<-------- Network transport ------->| SCTP Node B 343 Figure 1: An SCTP Association 345 2.3. Key Terms 347 Some of the language used to describe SCTP has been introduced in the 348 previous sections. This section provides a consolidated list of the 349 key terms and their definitions. 351 Active destination transport address: A transport address on a peer 352 endpoint that a transmitting endpoint considers available for 353 receiving user messages. 355 Association Maximum DATA Chunk Size (AMDCS): The smallest Path 356 Maximum DATA Chunk Size (PMDCS) of all destination addresses. 358 Bundling: An optional multiplexing operation, whereby more than one 359 user message might be carried in the same SCTP packet. Each user 360 message occupies its own DATA chunk. 362 Chunk: A unit of information within an SCTP packet, consisting of a 363 chunk header and chunk-specific content. 365 Congestion window (cwnd): An SCTP variable that limits outstanding 366 data, in number of bytes, that a sender can send to a particular 367 destination transport address before receiving an acknowledgement. 369 Control chunk: A chunk not being used for transmitting user data, 370 i.e. every chunk which is not a DATA chunk. 372 Cumulative TSN Ack Point: The Transmission Sequence Number (TSN) of 373 the last DATA chunk acknowledged via the Cumulative TSN Ack field 374 of a SACK. 376 Flightsize: The amount of bytes of outstanding data to a particular 377 destination transport address at any given time. 379 Idle destination address: An address that has not had user messages 380 sent to it within some length of time, normally the HEARTBEAT 381 interval or greater. 383 Inactive destination transport address: An address that is 384 considered inactive due to errors and unavailable to transport 385 user messages. 387 Message (or user message): Data submitted to SCTP by the Upper Layer 388 Protocol (ULP). 390 Message Authentication Code (MAC): An integrity check mechanism 391 based on cryptographic hash functions using a secret key. 392 Typically, message authentication codes are used between two 393 parties that share a secret key in order to validate information 394 transmitted between these parties. In SCTP, it is used by an 395 endpoint to validate the State Cookie information that is returned 396 from the peer in the COOKIE ECHO chunk. The term "MAC" has 397 different meanings in different contexts. SCTP uses this term 398 with the same meaning as in [RFC2104]. 400 Network Byte Order: Most significant byte first, a.k.a., big endian. 402 Ordered Message: A user message that is delivered in order with 403 respect to all previous user messages sent within the stream on 404 which the message was sent. 406 Outstanding data (or "data outstanding" or "data in flight"): The 407 total amount of the DATA chunks associated with outstanding TSNs. 408 A retransmitted DATA chunk is counted once in outstanding data. A 409 DATA chunk that is classified as lost but that has not yet been 410 retransmitted is not in outstanding data. 412 Outstanding TSN (at an SCTP endpoint): A TSN (and the associated 413 DATA chunk) that has been sent by the endpoint but for which it 414 has not yet received an acknowledgement. 416 Path: The route taken by the SCTP packets sent by one SCTP endpoint 417 to a specific destination transport address of its peer SCTP 418 endpoint. Sending to different destination transport addresses 419 does not necessarily guarantee getting separate paths. 421 Path Maximum DATA Chunk Size (PMDCS): The maximum size (including 422 the DATA chunk header) of a DATA chunk which fits into an SCTP 423 packet not exceeding the PMTU of a particular destination address. 425 Path Maximum Transmission Unit (PMTU): The maximum size (including 426 the SCTP common header and all chunks including their paddings) of 427 an SCTP packet which can be sent to a particular destination 428 address without using IP level fragmentation. 430 Primary Path: The primary path is the destination and source address 431 that will be put into a packet outbound to the peer endpoint by 432 default. The definition includes the source address since an 433 implementation MAY wish to specify both destination and source 434 address to better control the return path taken by reply chunks 435 and on which interface the packet is transmitted when the data 436 sender is multi-homed. 438 Receiver Window (rwnd): An SCTP variable a data sender uses to store 439 the most recently calculated receiver window of its peer, in 440 number of bytes. This gives the sender an indication of the space 441 available in the receiver's inbound buffer. 443 SCTP association: A protocol relationship between SCTP endpoints, 444 composed of the two SCTP endpoints and protocol state information 445 including Verification Tags and the currently active set of 446 Transmission Sequence Numbers (TSNs), etc. An association can be 447 uniquely identified by the transport addresses used by the 448 endpoints in the association. Two SCTP endpoints MUST NOT have 449 more than one SCTP association between them at any given time. 451 SCTP endpoint: The logical sender/receiver of SCTP packets. On a 452 multi-homed host, an SCTP endpoint is represented to its peers as 453 a combination of a set of eligible destination transport addresses 454 to which SCTP packets can be sent and a set of eligible source 455 transport addresses from which SCTP packets can be received. All 456 transport addresses used by an SCTP endpoint MUST use the same 457 port number, but can use multiple IP addresses. A transport 458 address used by an SCTP endpoint MUST NOT be used by another SCTP 459 endpoint. In other words, a transport address is unique to an 460 SCTP endpoint. 462 SCTP packet (or packet): The unit of data delivery across the 463 interface between SCTP and the connectionless packet network 464 (e.g., IP). An SCTP packet includes the common SCTP header, 465 possible SCTP control chunks, and user data encapsulated within 466 SCTP DATA chunks. 468 SCTP user application (SCTP user): The logical higher-layer 469 application entity which uses the services of SCTP, also called 470 the Upper-Layer Protocol (ULP). 472 Slow-Start Threshold (ssthresh): An SCTP variable. This is the 473 threshold that the endpoint will use to determine whether to 474 perform slow start or congestion avoidance on a particular 475 destination transport address. Ssthresh is in number of bytes. 477 Stream: A unidirectional logical channel established from one to 478 another associated SCTP endpoint, within which all user messages 479 are delivered in sequence except for those submitted to the 480 unordered delivery service. 482 Note: The relationship between stream numbers in opposite 483 directions is strictly a matter of how the applications use them. 484 It is the responsibility of the SCTP user to create and manage 485 these correlations if they are so desired. 487 Stream Sequence Number: A 16-bit sequence number used internally by 488 SCTP to ensure sequenced delivery of the user messages within a 489 given stream. One Stream Sequence Number is attached to each user 490 message. 492 Tie-Tags: Two 32-bit random numbers that together make a 64-bit 493 nonce. These tags are used within a State Cookie and TCB so that 494 a newly restarting association can be linked to the original 495 association within the endpoint that did not restart and yet not 496 reveal the true Verification Tags of an existing association. 498 Transmission Control Block (TCB): An internal data structure created 499 by an SCTP endpoint for each of its existing SCTP associations to 500 other SCTP endpoints. TCB contains all the status and operational 501 information for the endpoint to maintain and manage the 502 corresponding association. 504 Transmission Sequence Number (TSN): A 32-bit sequence number used 505 internally by SCTP. One TSN is attached to each chunk containing 506 user data to permit the receiving SCTP endpoint to acknowledge its 507 receipt and detect duplicate deliveries. 509 Transport address: A transport address is traditionally defined by a 510 network-layer address, a transport-layer protocol, and a 511 transport-layer port number. In the case of SCTP running over IP, 512 a transport address is defined by the combination of an IP address 513 and an SCTP port number (where SCTP is the transport protocol). 515 Unacknowledged TSN (at an SCTP endpoint): A TSN (and the associated 516 DATA chunk) that has been received by the endpoint but for which 517 an acknowledgement has not yet been sent. Or in the opposite 518 case, for a packet that has been sent but no acknowledgement has 519 been received. 521 Unordered Message: Unordered messages are "unordered" with respect 522 to any other message; this includes both other unordered messages 523 as well as other ordered messages. An unordered message might be 524 delivered prior to or later than ordered messages sent on the same 525 stream. 527 User message: The unit of data delivery across the interface between 528 SCTP and its user. 530 Verification Tag: A 32-bit unsigned integer that is randomly 531 generated. The Verification Tag provides a key that allows a 532 receiver to verify that the SCTP packet belongs to the current 533 association and is not an old or stale packet from a previous 534 association. 536 2.4. Abbreviations 538 MAC Message Authentication Code [RFC2104] 539 RTO Retransmission Timeout 540 RTT Round-Trip Time 541 RTTVAR Round-Trip Time Variation 542 SCTP Stream Control Transmission Protocol 543 SRTT Smoothed RTT 544 TCB Transmission Control Block 545 TLV Type-Length-Value coding format 546 TSN Transmission Sequence Number 547 ULP Upper-Layer Protocol 549 2.5. Functional View of SCTP 551 The SCTP transport service can be decomposed into a number of 552 functions. These are depicted in Figure 2 and explained in the 553 remainder of this section. 555 SCTP User Application 557 ----------------------------------------------------- 558 _____________ ____________________ 559 | | | Sequenced Delivery | 560 | Association | | within Streams | 561 | | |____________________| 562 | Startup | 563 | | ____________________________ 564 | and | | User Data Fragmentation | 565 | | |____________________________| 566 | Takedown | 567 | | ____________________________ 568 | | | Acknowledgement | 569 | | | and | 570 | | | Congestion Avoidance | 571 | | |____________________________| 572 | | 573 | | ____________________________ 574 | | | Chunk Bundling | 575 | | |____________________________| 576 | | 577 | | ________________________________ 578 | | | Packet Validation | 579 | | |________________________________| 580 | | 581 | | ________________________________ 582 | | | Path Management | 583 |_____________| |________________________________| 585 Figure 2: Functional View of the SCTP Transport Service 587 2.5.1. Association Startup and Takedown 589 An association is initiated by a request from the SCTP user (see the 590 description of the ASSOCIATE (or SEND) primitive in Section 11). 592 A cookie mechanism, similar to one described by Karn and Simpson in 593 [RFC2522], is employed during the initialization to provide 594 protection against synchronization attacks. The cookie mechanism 595 uses a four-way handshake, the last two legs of which are allowed to 596 carry user data for fast setup. The startup sequence is described in 597 Section 5 of this document. 599 SCTP provides for graceful close (i.e., shutdown) of an active 600 association on request from the SCTP user. See the description of 601 the SHUTDOWN primitive in Section 11. SCTP also allows ungraceful 602 close (i.e., abort), either on request from the user (ABORT 603 primitive) or as a result of an error condition detected within the 604 SCTP layer. Section 9 describes both the graceful and the ungraceful 605 close procedures. 607 SCTP does not support a half-open state (like TCP) wherein one side 608 continues sending data while the other end is closed. When either 609 endpoint performs a shutdown, the association on each peer will stop 610 accepting new data from its user and only deliver data in queue at 611 the time of the graceful close (see Section 9). 613 2.5.2. Sequenced Delivery within Streams 615 The term "stream" is used in SCTP to refer to a sequence of user 616 messages that are to be delivered to the upper-layer protocol in 617 order with respect to other messages within the same stream. This is 618 in contrast to its usage in TCP, where it refers to a sequence of 619 bytes (in this document, a byte is assumed to be 8 bits). 621 The SCTP user can specify at association startup time the number of 622 streams to be supported by the association. This number is 623 negotiated with the remote end (see Section 5.1.1). User messages 624 are associated with stream numbers (SEND, RECEIVE primitives, 625 Section 11). Internally, SCTP assigns a Stream Sequence Number to 626 each message passed to it by the SCTP user. On the receiving side, 627 SCTP ensures that messages are delivered to the SCTP user in sequence 628 within a given stream. However, while one stream might be blocked 629 waiting for the next in-sequence user message, delivery from other 630 streams might proceed. 632 SCTP provides a mechanism for bypassing the sequenced delivery 633 service. User messages sent using this mechanism are delivered to 634 the SCTP user as soon as they are received. 636 2.5.3. User Data Fragmentation 638 When needed, SCTP fragments user messages to ensure that the size of 639 the SCTP packet passed to the lower layer does not exceed the PMTU. 640 On receipt, fragments are reassembled into complete messages before 641 being passed to the SCTP user. 643 2.5.4. Acknowledgement and Congestion Avoidance 645 SCTP assigns a Transmission Sequence Number (TSN) to each user data 646 fragment or unfragmented message. The TSN is independent of any 647 Stream Sequence Number assigned at the stream level. The receiving 648 end acknowledges all TSNs received, even if there are gaps in the 649 sequence. In this way, reliable delivery is kept functionally 650 separate from sequenced stream delivery. 652 The acknowledgement and congestion avoidance function is responsible 653 for packet retransmission when timely acknowledgement has not been 654 received. Packet retransmission is conditioned by congestion 655 avoidance procedures similar to those used for TCP. See Section 6 656 and Section 7 for a detailed description of the protocol procedures 657 associated with this function. 659 2.5.5. Chunk Bundling 661 As described in Section 3, the SCTP packet as delivered to the lower 662 layer consists of a common header followed by one or more chunks. 663 Each chunk might contain either user data or SCTP control 664 information. The SCTP user has the option to request bundling of 665 more than one user message into a single SCTP packet. The chunk 666 bundling function of SCTP is responsible for assembly of the complete 667 SCTP packet and its disassembly at the receiving end. 669 During times of congestion, an SCTP implementation MAY still perform 670 bundling even if the user has requested that SCTP not bundle. The 671 user's disabling of bundling only affects SCTP implementations that 672 might delay a small period of time before transmission (to attempt to 673 encourage bundling). When the user layer disables bundling, this 674 small delay is prohibited but not bundling that is performed during 675 congestion or retransmission. 677 2.5.6. Packet Validation 679 A mandatory Verification Tag field and a 32-bit checksum field (see 680 Appendix A for a description of the CRC32c checksum) are included in 681 the SCTP common header. The Verification Tag value is chosen by each 682 end of the association during association startup. Packets received 683 without the expected Verification Tag value are discarded, as a 684 protection against blind masquerade attacks and against stale SCTP 685 packets from a previous association. The CRC32c checksum can be set 686 by the sender of each SCTP packet to provide additional protection 687 against data corruption in the network. The receiver of an SCTP 688 packet with an invalid CRC32c checksum silently discards the packet. 690 2.5.7. Path Management 692 The sending SCTP user is able to manipulate the set of transport 693 addresses used as destinations for SCTP packets through the 694 primitives described in Section 11. The SCTP path management 695 function chooses the destination transport address for each outgoing 696 SCTP packet based on the SCTP user's instructions and the currently 697 perceived reachability status of the eligible destination set. The 698 path management function monitors reachability through heartbeats 699 when other packet traffic is inadequate to provide this information 700 and advises the SCTP user when reachability of any transport address 701 of the peer endpoint changes. The path management function is also 702 responsible for reporting the eligible set of local transport 703 addresses to the peer endpoint during association startup, and for 704 reporting the transport addresses returned from the peer endpoint to 705 the SCTP user. 707 At association startup, a primary path is defined for each SCTP 708 endpoint, and is used for normal sending of SCTP packets. 710 On the receiving end, the path management is responsible for 711 verifying the existence of a valid SCTP association to which the 712 inbound SCTP packet belongs before passing it for further processing. 714 Note: Path Management and Packet Validation are done at the same 715 time, so although described separately above, in reality they cannot 716 be performed as separate items. 718 2.6. Serial Number Arithmetic 720 It is essential to remember that the actual Transmission Sequence 721 Number space is finite, though very large. This space ranges from 0 722 to 2**32 - 1. Since the space is finite, all arithmetic dealing with 723 Transmission Sequence Numbers MUST be performed modulo 2**32. This 724 unsigned arithmetic preserves the relationship of sequence numbers as 725 they cycle from 2**32 - 1 to 0 again. There are some subtleties to 726 computer modulo arithmetic, so great care has to be taken in 727 programming the comparison of such values. When referring to TSNs, 728 the symbol "=<" means "less than or equal"(modulo 2**32). 730 Comparisons and arithmetic on TSNs in this document SHOULD use Serial 731 Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 32. 733 An endpoint SHOULD NOT transmit a DATA chunk with a TSN that is more 734 than 2**31 - 1 above the beginning TSN of its current send window. 735 Doing so will cause problems in comparing TSNs. 737 Transmission Sequence Numbers wrap around when they reach 2**32 - 1. 738 That is, the next TSN a DATA chunk MUST use after transmitting TSN = 739 2**32 - 1 is TSN = 0. 741 Any arithmetic done on Stream Sequence Numbers SHOULD use Serial 742 Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 16. 743 All other arithmetic and comparisons in this document use normal 744 arithmetic. 746 2.7. Changes from RFC 4960 748 SCTP was originally defined in [RFC4960], which this document 749 obsoletes, if approved. Readers interested in the details of the 750 various changes that this document incorporates are asked to consult 751 [RFC8540]. 753 3. SCTP Packet Format 755 An SCTP packet is composed of a common header and chunks. A chunk 756 contains either control information or user data. 758 The SCTP packet format is shown below: 760 0 1 2 3 761 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 762 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 763 | Common Header | 764 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 765 | Chunk #1 | 766 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 767 | ... | 768 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 769 | Chunk #n | 770 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 772 Multiple chunks can be bundled into one SCTP packet as long as the 773 size of the SCTP packet does not exceed the PMTU, except for the 774 INIT, INIT ACK, and SHUTDOWN COMPLETE chunks. These chunks MUST NOT 775 be bundled with any other chunk in a packet. See Section 6.10 for 776 more details on chunk bundling. 778 If a user data message does not fit into one SCTP packet it can be 779 fragmented into multiple chunks using the procedure defined in 780 Section 6.9. 782 All integer fields in an SCTP packet MUST be transmitted in network 783 byte order, unless otherwise stated. 785 3.1. SCTP Common Header Field Descriptions 786 0 1 2 3 787 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 788 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 789 | Source Port Number | Destination Port Number | 790 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 791 | Verification Tag | 792 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 793 | Checksum | 794 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 796 Source Port Number: 16 bits (unsigned integer) 797 This is the SCTP sender's port number. It can be used by the 798 receiver in combination with the source IP address, the SCTP 799 destination port, and possibly the destination IP address to 800 identify the association to which this packet belongs. The source 801 port number 0 MUST NOT be used. 803 Destination Port Number: 16 bits (unsigned integer) 804 This is the SCTP port number to which this packet is destined. 805 The receiving host will use this port number to de-multiplex the 806 SCTP packet to the correct receiving endpoint/application. The 807 destination port number 0 MUST NOT be used. 809 Verification Tag: 32 bits (unsigned integer) 810 The receiver of an SCTP packet uses the Verification Tag to 811 validate the sender of this packet. On transmit, the value of the 812 Verification Tag MUST be set to the value of the Initiate Tag 813 received from the peer endpoint during the association 814 initialization, with the following exceptions: 816 * A packet containing an INIT chunk MUST have a zero Verification 817 Tag. 819 * A packet containing a SHUTDOWN COMPLETE chunk with the T bit 820 set MUST have the Verification Tag copied from the packet with 821 the SHUTDOWN ACK chunk. 823 * A packet containing an ABORT chunk MAY have the verification 824 tag copied from the packet that caused the ABORT to be sent. 825 For details see Section 8.4 and Section 8.5. 827 Checksum: 32 bits (unsigned integer) 828 This field contains the checksum of the SCTP packet. Its 829 calculation is discussed in Section 6.8. SCTP uses the CRC32c 830 algorithm as described in Appendix A for calculating the checksum. 832 3.2. Chunk Field Descriptions 834 The figure below illustrates the field format for the chunks to be 835 transmitted in the SCTP packet. Each chunk is formatted with a Chunk 836 Type field, a chunk-specific Flag field, a Chunk Length field, and a 837 Value field. 839 0 1 2 3 840 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 841 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 842 | Chunk Type | Chunk Flags | Chunk Length | 843 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 844 \ \ 845 / Chunk Value / 846 \ \ 847 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 849 Chunk Type: 8 bits (unsigned integer) 850 This field identifies the type of information contained in the 851 Chunk Value field. It takes a value from 0 to 254. The value of 852 255 is reserved for future use as an extension field. 854 The values of Chunk Types are defined as follows: 856 +==========+===========================================+ 857 | ID Value | Chunk Type | 858 +==========+===========================================+ 859 | 0 | Payload Data (DATA) | 860 +----------+-------------------------------------------+ 861 | 1 | Initiation (INIT) | 862 +----------+-------------------------------------------+ 863 | 2 | Initiation Acknowledgement (INIT ACK) | 864 +----------+-------------------------------------------+ 865 | 3 | Selective Acknowledgement (SACK) | 866 +----------+-------------------------------------------+ 867 | 4 | Heartbeat Request (HEARTBEAT) | 868 +----------+-------------------------------------------+ 869 | 5 | Heartbeat Acknowledgement (HEARTBEAT ACK) | 870 +----------+-------------------------------------------+ 871 | 6 | Abort (ABORT) | 872 +----------+-------------------------------------------+ 873 | 7 | Shutdown (SHUTDOWN) | 874 +----------+-------------------------------------------+ 875 | 8 | Shutdown Acknowledgement (SHUTDOWN ACK) | 876 +----------+-------------------------------------------+ 877 | 9 | Operation Error (ERROR) | 878 +----------+-------------------------------------------+ 879 | 10 | State Cookie (COOKIE ECHO) | 880 +----------+-------------------------------------------+ 881 | 11 | Cookie Acknowledgement (COOKIE ACK) | 882 +----------+-------------------------------------------+ 883 | 12 | Reserved for Explicit Congestion | 884 | | Notification Echo (ECNE) | 885 +----------+-------------------------------------------+ 886 | 13 | Reserved for Congestion Window Reduced | 887 | | (CWR) | 888 +----------+-------------------------------------------+ 889 | 14 | Shutdown Complete (SHUTDOWN COMPLETE) | 890 +----------+-------------------------------------------+ 891 | 15 to 62 | available | 892 +----------+-------------------------------------------+ 893 | 63 | reserved for IETF-defined Chunk | 894 | | Extensions | 895 +----------+-------------------------------------------+ 896 | 64 to | available | 897 | 126 | | 898 +----------+-------------------------------------------+ 899 | 127 | reserved for IETF-defined Chunk | 900 | | Extensions | 901 +----------+-------------------------------------------+ 902 | 128 to | available | 903 | 190 | | 904 +----------+-------------------------------------------+ 905 | 191 | reserved for IETF-defined Chunk | 906 | | Extensions | 907 +----------+-------------------------------------------+ 908 | 192 to | available | 909 | 254 | | 910 +----------+-------------------------------------------+ 911 | 255 | reserved for IETF-defined Chunk | 912 | | Extensions | 913 +----------+-------------------------------------------+ 915 Table 1: Chunk Types 917 Note: The ECNE and CWR chunk types are reserved for future use of 918 Explicit Congestion Notification (ECN). 920 Chunk Types are encoded such that the highest-order 2 bits specify 921 the action that is taken if the processing endpoint does not 922 recognize the Chunk Type. 924 +----+--------------------------------------------------+ 925 | 00 | Stop processing this SCTP packet; discard the | 926 | | unrecognized chunk and all further chunks. | 927 +----+--------------------------------------------------+ 928 | 01 | Stop processing this SCTP packet, discard the | 929 | | unrecognized chunk and all further chunks, and | 930 | | report the unrecognized chunk in an ERROR chunk | 931 | | using the 'Unrecognized Chunk Type' error cause. | 932 +----+--------------------------------------------------+ 933 | 10 | Skip this chunk and continue processing. | 934 +----+--------------------------------------------------+ 935 | 11 | Skip this chunk and continue processing, but | 936 | | report it in an ERROR chunk using the | 937 | | 'Unrecognized Chunk Type' error cause. | 938 +----+--------------------------------------------------+ 940 Table 2: Processing of Unknown Chunks 942 Chunk Flags: 8 bits 943 The usage of these bits depends on the Chunk type as given by the 944 Chunk Type field. Unless otherwise specified, they are set to 0 945 on transmit and are ignored on receipt. 947 Chunk Length: 16 bits (unsigned integer) 948 This value represents the size of the chunk in bytes, including 949 the Chunk Type, Chunk Flags, Chunk Length, and Chunk Value fields. 950 Therefore, if the Chunk Value field is zero-length, the Length 951 field will be set to 4. The Chunk Length field does not count any 952 chunk padding. However, it does include padding of any variable- 953 length parameter except the last parameter in the chunk. 955 Note: A robust implementation is expected to accept the chunk 956 whether or not the final padding has been included in the Chunk 957 Length. 959 Chunk Value: variable length 960 The Chunk Value field contains the actual information to be 961 transferred in the chunk. The usage and format of this field is 962 dependent on the Chunk Type. 964 The total length of a chunk (including Type, Length, and Value 965 fields) MUST be a multiple of 4 bytes. If the length of the chunk is 966 not a multiple of 4 bytes, the sender MUST pad the chunk with all 967 zero bytes, and this padding is not included in the Chunk Length 968 field. The sender MUST NOT pad with more than 3 bytes. The receiver 969 MUST ignore the padding bytes. 971 SCTP-defined chunks are described in detail in Section 3.3. The 972 guidelines for IETF-defined chunk extensions can be found in 973 Section 15.1 of this document. 975 3.2.1. Optional/Variable-Length Parameter Format 977 Chunk values of SCTP control chunks consist of a chunk-type-specific 978 header of required fields, followed by zero or more parameters. The 979 optional and variable-length parameters contained in a chunk are 980 defined in a Type-Length-Value format as shown below. 982 0 1 2 3 983 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 984 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 985 | Parameter Type | Parameter Length | 986 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 987 \ \ 988 / Parameter Value / 989 \ \ 990 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 992 Chunk Parameter Type: 16 bits (unsigned integer) 993 The Type field is a 16-bit identifier of the type of parameter. 994 It takes a value of 0 to 65534. 996 The value of 65535 is reserved for IETF-defined extensions. 997 Values other than those defined in specific SCTP chunk 998 descriptions are reserved for use by IETF. 1000 Chunk Parameter Length: 16 bits (unsigned integer) 1001 The Parameter Length field contains the size of the parameter in 1002 bytes, including the Parameter Type, Parameter Length, and 1003 Parameter Value fields. Thus, a parameter with a zero-length 1004 Parameter Value field would have a Parameter Length field of 4. 1005 The Parameter Length does not include any padding bytes. 1007 Chunk Parameter Value: variable length 1008 The Parameter Value field contains the actual information to be 1009 transferred in the parameter. 1011 The total length of a parameter (including Parameter Type, Parameter 1012 Length, and Parameter Value fields) MUST be a multiple of 4 bytes. 1013 If the length of the parameter is not a multiple of 4 bytes, the 1014 sender pads the parameter at the end (i.e., after the Parameter Value 1015 field) with all zero bytes. The length of the padding is not 1016 included in the Parameter Length field. A sender MUST NOT pad with 1017 more than 3 bytes. The receiver MUST ignore the padding bytes. 1019 The Parameter Types are encoded such that the highest-order 2 bits 1020 specify the action that is taken if the processing endpoint does not 1021 recognize the Parameter Type. 1023 +----+-------------------------------------------------------+ 1024 | 00 | Stop processing this parameter; do not process any | 1025 | | further parameters within this chunk. | 1026 +----+-------------------------------------------------------+ 1027 | 01 | Stop processing this parameter, do not process any | 1028 | | further parameters within this chunk, and report the | 1029 | | unrecognized parameter as described in Section 3.2.2. | 1030 +----+-------------------------------------------------------+ 1031 | 10 | Skip this parameter and continue processing. | 1032 +----+-------------------------------------------------------+ 1033 | 11 | Skip this parameter and continue processing but | 1034 | | report the unrecognized parameter as described in | 1035 | | Section 3.2.2. | 1036 +----+-------------------------------------------------------+ 1038 Table 3: Processing of Unknown Parameters 1040 Please note that, when an INIT or INIT ACK chunk is received, in all 1041 four cases, an INIT ACK or COOKIE ECHO chunk is sent in response, 1042 respectively. In the 00 or 01 case, the processing of the parameters 1043 after the unknown parameter is canceled, but no processing already 1044 done is rolled back. 1046 The actual SCTP parameters are defined in the specific SCTP chunk 1047 sections. The rules for IETF-defined parameter extensions are 1048 defined in Section 15.3. Parameter types MUST be unique across all 1049 chunks. For example, the parameter type '5' is used to represent an 1050 IPv4 address (see Section 3.3.2.1). The value '5' then is reserved 1051 across all chunks to represent an IPv4 address and MUST NOT be reused 1052 with a different meaning in any other chunk. 1054 3.2.2. Reporting of Unrecognized Parameters 1056 If the receiver of an INIT chunk detects unrecognized parameters and 1057 has to report them according to Section 3.2.1, it MUST put the 1058 "Unrecognized Parameter" parameter(s) in the INIT ACK chunk sent in 1059 response to the INIT chunk. Note that if the receiver of the INIT 1060 chunk is not going to establish an association (e.g., due to lack of 1061 resources), an "Unrecognized Parameter" error cause would not be 1062 included with any ABORT chunk being sent to the sender of the INIT 1063 chunk. 1065 If the receiver of any other chunk (e.g., INIT ACK) detects 1066 unrecognized parameters and has to report them according to 1067 Section 3.2.1, it SHOULD bundle the ERROR chunk containing the 1068 "Unrecognized Parameters" error cause with the chunk sent in response 1069 (e.g., COOKIE ECHO). If the receiver of the INIT ACK chunk cannot 1070 bundle the COOKIE ECHO chunk with the ERROR chunk, the ERROR chunk 1071 MAY be sent separately but not before the COOKIE ACK chunk has been 1072 received. 1074 Any time a COOKIE ECHO chunk is sent in a packet, it MUST be the 1075 first chunk. 1077 3.3. SCTP Chunk Definitions 1079 This section defines the format of the different SCTP chunk types. 1081 3.3.1. Payload Data (DATA) (0) 1083 The following format MUST be used for the DATA chunk: 1085 0 1 2 3 1086 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 1087 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1088 | Type = 0 | Res |I|U|B|E| Length | 1089 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1090 | TSN | 1091 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1092 | Stream Identifier S | Stream Sequence Number n | 1093 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1094 | Payload Protocol Identifier | 1095 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1096 \ \ 1097 / User Data (seq n of Stream S) / 1098 \ \ 1099 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1101 Res: 4 bits 1102 Set to all '0's on transmit and ignored on receipt. 1104 I bit: 1 bit 1105 The (I)mmediate bit MAY be set by the sender whenever the sender 1106 of a DATA chunk can benefit from the corresponding SACK chunk 1107 being sent back without delay. See Section 4 of [RFC7053] for a 1108 discussion of the benefits. 1110 U bit: 1 bit 1111 The (U)nordered bit, if set to '1', indicates that this is an 1112 unordered DATA chunk, and there is no Stream Sequence Number 1113 assigned to this DATA chunk. Therefore, the receiver MUST ignore 1114 the Stream Sequence Number field. 1116 After reassembly (if necessary), unordered DATA chunks MUST be 1117 dispatched to the upper layer by the receiver without any attempt 1118 to reorder. 1120 If an unordered user message is fragmented, each fragment of the 1121 message MUST have its U bit set to '1'. 1123 B bit: 1 bit 1124 The (B)eginning fragment bit, if set, indicates the first fragment 1125 of a user message. 1127 E bit: 1 bit 1128 The (E)nding fragment bit, if set, indicates the last fragment of 1129 a user message. 1131 An unfragmented user message MUST have both the B and E bits set to 1132 '1'. Setting both B and E bits to '0' indicates a middle fragment of 1133 a multi-fragment user message, as summarized in the following table: 1135 +---+---+-------------------------------------------+ 1136 | B | E | Description | 1137 +---+---+-------------------------------------------+ 1138 | 1 | 0 | First piece of a fragmented user message | 1139 +---+---+-------------------------------------------+ 1140 | 0 | 0 | Middle piece of a fragmented user message | 1141 +---+---+-------------------------------------------+ 1142 | 0 | 1 | Last piece of a fragmented user message | 1143 +---+---+-------------------------------------------+ 1144 | 1 | 1 | Unfragmented message | 1145 +---+---+-------------------------------------------+ 1147 Table 4: Fragment Description Flags 1149 When a user message is fragmented into multiple chunks, the TSNs are 1150 used by the receiver to reassemble the message. This means that the 1151 TSNs for each fragment of a fragmented user message MUST be strictly 1152 sequential. 1154 Length: 16 bits (unsigned integer) 1155 This field indicates the length of the DATA chunk in bytes from 1156 the beginning of the type field to the end of the User Data field 1157 excluding any padding. A DATA chunk with one byte of user data 1158 will have Length set to 17 (indicating 17 bytes). 1160 A DATA chunk with a User Data field of length L will have the 1161 Length field set to (16 + L) (indicating 16+L bytes) where L MUST 1162 be greater than 0. 1164 TSN: 32 bits (unsigned integer) 1165 This value represents the TSN for this DATA chunk. The valid 1166 range of TSN is from 0 to 4294967295 (2**32 - 1). TSN wraps back 1167 to 0 after reaching 4294967295. 1169 Stream Identifier S: 16 bits (unsigned integer) 1170 Identifies the stream to which the following user data belongs. 1172 Stream Sequence Number n: 16 bits (unsigned integer) 1173 This value represents the Stream Sequence Number of the following 1174 user data within the stream S. Valid range is 0 to 65535. 1176 When a user message is fragmented by SCTP for transport, the same 1177 Stream Sequence Number MUST be carried in each of the fragments of 1178 the message. 1180 Payload Protocol Identifier: 32 bits (unsigned integer) 1181 This value represents an application (or upper layer) specified 1182 protocol identifier. This value is passed to SCTP by its upper 1183 layer and sent to its peer. This identifier is not used by SCTP 1184 but can be used by certain network entities, as well as by the 1185 peer application, to identify the type of information being 1186 carried in this DATA chunk. This field MUST be sent even in 1187 fragmented DATA chunks (to make sure it is available for agents in 1188 the middle of the network). Note that this field is not touched 1189 by an SCTP implementation; therefore, its byte order is not 1190 necessarily big endian. The upper layer is responsible for any 1191 byte order conversions to this field. 1193 The value 0 indicates that no application identifier is specified 1194 by the upper layer for this payload data. 1196 User Data: variable length 1197 This is the payload user data. The implementation MUST pad the 1198 end of the data to a 4-byte boundary with all-zero bytes. Any 1199 padding MUST NOT be included in the Length field. A sender MUST 1200 never add more than 3 bytes of padding. 1202 3.3.2. Initiation (INIT) (1) 1204 This chunk is used to initiate an SCTP association between two 1205 endpoints. The format of the INIT chunk is shown below: 1207 0 1 2 3 1208 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 1209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1210 | Type = 1 | Chunk Flags | Chunk Length | 1211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1212 | Initiate Tag | 1213 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1214 | Advertised Receiver Window Credit (a_rwnd) | 1215 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1216 | Number of Outbound Streams | Number of Inbound Streams | 1217 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1218 | Initial TSN | 1219 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1220 \ \ 1221 / Optional/Variable-Length Parameters / 1222 \ \ 1223 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1225 The following parameters are specified for the INIT chunk. Unless 1226 otherwise noted, each parameter MUST only be included once in the 1227 INIT chunk. 1229 +-----------------------------------+-----------+ 1230 | Fixed Length Parameter | Status | 1231 +-----------------------------------+-----------+ 1232 | Initiate Tag | Mandatory | 1233 +-----------------------------------+-----------+ 1234 | Advertised Receiver Window Credit | Mandatory | 1235 +-----------------------------------+-----------+ 1236 | Number of Outbound Streams | Mandatory | 1237 +-----------------------------------+-----------+ 1238 | Number of Inbound Streams | Mandatory | 1239 +-----------------------------------+-----------+ 1240 | Initial TSN | Mandatory | 1241 +-----------------------------------+-----------+ 1243 Table 5: Fixed Length Parameters of INIT Chunks 1245 +-----------------------------------+------------+----------------+ 1246 | Variable Length Parameter | Status | Type Value | 1247 +-----------------------------------+------------+----------------+ 1248 | IPv4 Address (Note 1) | Optional | 5 | 1249 +-----------------------------------+------------+----------------+ 1250 | IPv6 Address (Note 1) | Optional | 6 | 1251 +-----------------------------------+------------+----------------+ 1252 | Cookie Preservative | Optional | 9 | 1253 +-----------------------------------+------------+----------------+ 1254 | Reserved for ECN Capable (Note 2) | Optional | 32768 (0x8000) | 1255 +-----------------------------------+------------+----------------+ 1256 | Host Name Address (Note 3) | Deprecated | 11 | 1257 +-----------------------------------+------------+----------------+ 1258 | Supported Address Types (Note 4) | Optional | 12 | 1259 +-----------------------------------+------------+----------------+ 1261 Table 6: Variable Length Parameters of INIT Chunks 1263 Note 1: The INIT chunks can contain multiple addresses that can be 1264 IPv4 and/or IPv6 in any combination. 1266 Note 2: The ECN Capable field is reserved for future use of Explicit 1267 Congestion Notification. 1269 Note 3: An INIT chunk MUST NOT contain the Host Name Address 1270 parameter. The receiver of an INIT chunk containing a Host Name 1271 Address parameter MUST send an ABORT and MAY include an "Unresolvable 1272 Address" error cause. 1274 Note 4: This parameter, when present, specifies all the address types 1275 the sending endpoint can support. The absence of this parameter 1276 indicates that the sending endpoint can support any address type. 1278 If an INIT chunk is received with all mandatory parameters that are 1279 specified for the INIT chunk, then the receiver SHOULD process the 1280 INIT chunk and send back an INIT ACK. The receiver of the INIT chunk 1281 MAY bundle an ERROR chunk with the COOKIE ACK chunk later. However, 1282 restrictive implementations MAY send back an ABORT chunk in response 1283 to the INIT chunk. 1285 The Chunk Flags field in INIT is reserved, and all bits in it SHOULD 1286 be set to 0 by the sender and ignored by the receiver. The sequence 1287 of parameters within an INIT can be processed in any order. 1289 Initiate Tag: 32 bits (unsigned integer) 1290 The receiver of the INIT (the responding end) records the value of 1291 the Initiate Tag parameter. This value MUST be placed into the 1292 Verification Tag field of every SCTP packet that the receiver of 1293 the INIT transmits within this association. 1295 The Initiate Tag is allowed to have any value except 0. See 1296 Section 5.3.1 for more on the selection of the tag value. 1298 If the value of the Initiate Tag in a received INIT chunk is found 1299 to be 0, the receiver MUST treat it as an error and close the 1300 association by transmitting an ABORT. 1302 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1303 integer) 1304 This value represents the dedicated buffer space, in number of 1305 bytes, the sender of the INIT has reserved in association with 1306 this window. During the life of the association, this buffer 1307 space SHOULD NOT be reduced (i.e., dedicated buffers ought not to 1308 be taken away from this association); however, an endpoint MAY 1309 change the value of a_rwnd it sends in SACK chunks. 1311 Number of Outbound Streams (OS): 16 bits (unsigned integer) 1312 Defines the number of outbound streams the sender of this INIT 1313 chunk wishes to create in this association. The value of 0 MUST 1314 NOT be used. 1316 A receiver of an INIT with the OS value set to 0 SHOULD abort the 1317 association. 1319 Number of Inbound Streams (MIS): 16 bits (unsigned integer) 1320 Defines the maximum number of streams the sender of this INIT 1321 chunk allows the peer end to create in this association. The 1322 value 0 MUST NOT be used. 1324 Note: There is no negotiation of the actual number of streams but 1325 instead the two endpoints will use the min(requested, offered). 1326 See Section 5.1.1 for details. 1328 A receiver of an INIT with the MIS value of 0 SHOULD abort the 1329 association. 1331 Initial TSN (I-TSN): 32 bits (unsigned integer) 1332 Defines the initial TSN that the sender will use. The valid range 1333 is from 0 to 4294967295. This field MAY be set to the value of 1334 the Initiate Tag field. 1336 3.3.2.1. Optional/Variable-Length Parameters in INIT 1338 The following parameters follow the Type-Length-Value format as 1339 defined in Section 3.2.1. Any Type-Length-Value fields MUST come 1340 after the fixed-length fields defined in the previous section. 1342 3.3.2.1.1. IPv4 Address Parameter (5) 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 = 5 | Length = 8 | 1348 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1349 | IPv4 Address | 1350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1352 IPv4 Address: 32 bits (unsigned integer) 1353 Contains an IPv4 address of the sending endpoint. It is binary 1354 encoded. 1356 3.3.2.1.2. IPv6 Address Parameter (6) 1358 0 1 2 3 1359 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 1360 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1361 | Type = 6 | Length = 20 | 1362 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1363 | | 1364 | IPv6 Address | 1365 | | 1366 | | 1367 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1369 IPv6 Address: 128 bits (unsigned integer) 1370 Contains an IPv6 [RFC8200] address of the sending endpoint. It is 1371 binary encoded. 1373 A sender MUST NOT use an IPv4-mapped IPv6 address [RFC4291], but 1374 SHOULD instead use an IPv4 Address parameter for an IPv4 address. 1376 Combined with the Source Port Number in the SCTP common header, the 1377 value passed in an IPv4 or IPv6 Address parameter indicates a 1378 transport address the sender of the INIT will support for the 1379 association being initiated. That is, during the life time of this 1380 association, this IP address can appear in the source address field 1381 of an IP datagram sent from the sender of the INIT, and can be used 1382 as a destination address of an IP datagram sent from the receiver of 1383 the INIT. 1385 More than one IP Address parameter can be included in an INIT chunk 1386 when the INIT sender is multi-homed. Moreover, a multi-homed 1387 endpoint might have access to different types of network; thus, more 1388 than one address type can be present in one INIT chunk, i.e., IPv4 1389 and IPv6 addresses are allowed in the same INIT chunk. 1391 If the INIT contains at least one IP Address parameter, then the 1392 source address of the IP datagram containing the INIT chunk and any 1393 additional address(es) provided within the INIT can be used as 1394 destinations by the endpoint receiving the INIT. If the INIT does 1395 not contain any IP Address parameters, the endpoint receiving the 1396 INIT MUST use the source address associated with the received IP 1397 datagram as its sole destination address for the association. 1399 Note that not using any IP Address parameters in the INIT and INIT 1400 ACK is an alternative to make an association more likely to work 1401 across a NAT box. 1403 3.3.2.1.3. Cookie Preservative (9) 1405 The sender of the INIT SHOULD use this parameter to suggest to the 1406 receiver of the INIT for a longer life-span of the State Cookie. 1408 0 1 2 3 1409 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 1410 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1411 | Type = 9 | Length = 8 | 1412 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1413 | Suggested Cookie Life-Span Increment (msec.) | 1414 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1416 Suggested Cookie Life-Span Increment: 32 bits (unsigned integer) 1417 This parameter indicates to the receiver how much increment in 1418 milliseconds the sender wishes the receiver to add to its default 1419 cookie life-span. 1421 This optional parameter MAY be added to the INIT chunk by the 1422 sender when it reattempts establishing an association with a peer 1423 to which its previous attempt of establishing the association 1424 failed due to a stale cookie operation error. The receiver MAY 1425 choose to ignore the suggested cookie life-span increase for its 1426 own security reasons. 1428 3.3.2.1.4. Host Name Address (11) 1430 The sender of an INIT chunk MUST NOT include this parameter. The 1431 usage of the Host Name Address parameter is deprecated. 1433 0 1 2 3 1434 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 1435 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1436 | Type = 11 | Length | 1437 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1438 / Host Name / 1439 \ \ 1440 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1442 Host Name: variable length 1443 This field contains a host name in "host name syntax" per RFC 1123 1444 Section 2.1 [RFC1123]. The method for resolving the host name is 1445 out of scope of SCTP. 1447 At least one null terminator is included in the Host Name string 1448 and MUST be included in the length. 1450 3.3.2.1.5. Supported Address Types (12) 1452 The sender of INIT uses this parameter to list all the address types 1453 it can support. 1455 0 1 2 3 1456 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 1457 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1458 | Type = 12 | Length | 1459 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1460 | Address Type #1 | Address Type #2 | 1461 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1462 | ...... | 1463 +-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+ 1465 Address Type: 16 bits (unsigned integer) 1466 This is filled with the type value of the corresponding address 1467 TLV (e.g., IPv4 = 5, IPv6 = 6). The value indicating the Host 1468 Name Address parameter (Host name = 11) MUST NOT be used. 1470 3.3.3. Initiation Acknowledgement (INIT ACK) (2) 1472 The INIT ACK chunk is used to acknowledge the initiation of an SCTP 1473 association. The format of the INIT ACK chunk is shown below: 1475 0 1 2 3 1476 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 1477 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1478 | Type = 2 | Chunk Flags | Chunk Length | 1479 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1480 | Initiate Tag | 1481 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1482 | Advertised Receiver Window Credit | 1483 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1484 | Number of Outbound Streams | Number of Inbound Streams | 1485 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1486 | Initial TSN | 1487 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1488 \ \ 1489 / Optional/Variable-Length Parameters / 1490 \ \ 1491 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1493 The parameter part of INIT ACK is formatted similarly to the INIT 1494 chunk. The following parameters are specified for the INIT ACK 1495 chunk: 1497 +-----------------------------------+-----------+ 1498 | Fixed Length Parameter | Status | 1499 +-----------------------------------+-----------+ 1500 | Initiate Tag | Mandatory | 1501 +-----------------------------------+-----------+ 1502 | Advertised Receiver Window Credit | Mandatory | 1503 +-----------------------------------+-----------+ 1504 | Number of Outbound Streams | Mandatory | 1505 +-----------------------------------+-----------+ 1506 | Number of Inbound Streams | Mandatory | 1507 +-----------------------------------+-----------+ 1508 | Initial TSN | Mandatory | 1509 +-----------------------------------+-----------+ 1511 Table 7: Fixed Length Parameters of INIT ACK 1512 Chunks 1514 It uses two extra variable parameters: The State Cookie and the 1515 Unrecognized Parameter: 1517 +-----------------------------------+------------+----------------+ 1518 | Variable Length Parameter | Status | Type Value | 1519 +-----------------------------------+------------+----------------+ 1520 | State Cookie | Mandatory | 7 | 1521 +-----------------------------------+------------+----------------+ 1522 | IPv4 Address (Note 1) | Optional | 5 | 1523 +-----------------------------------+------------+----------------+ 1524 | IPv6 Address (Note 1) | Optional | 6 | 1525 +-----------------------------------+------------+----------------+ 1526 | Unrecognized Parameter | Optional | 8 | 1527 +-----------------------------------+------------+----------------+ 1528 | Reserved for ECN Capable (Note 2) | Optional | 32768 (0x8000) | 1529 +-----------------------------------+------------+----------------+ 1530 | Host Name Address (Note 3) | Deprecated | 11 | 1531 +-----------------------------------+------------+----------------+ 1533 Table 8: Variable Length Parameters of INIT ACK Chunks 1535 Note 1: The INIT ACK chunks can contain any number of IP address 1536 parameters that can be IPv4 and/or IPv6 in any combination. 1538 Note 2: The ECN Capable field is reserved for future use of Explicit 1539 Congestion Notification. 1541 Note 3: An INIT ACK chunk MUST NOT contain the Host Name Address 1542 parameter. The receiver of INIT ACK chunks containing a Host Name 1543 Address parameter MUST send an ABORT and MAY include an "Unresolvable 1544 Address" error cause. 1546 Initiate Tag: 32 bits (unsigned integer) 1547 The receiver of the INIT ACK records the value of the Initiate Tag 1548 parameter. This value MUST be placed into the Verification Tag 1549 field of every SCTP packet that the INIT ACK receiver transmits 1550 within this association. 1552 The Initiate Tag MUST NOT take the value 0. See Section 5.3.1 for 1553 more on the selection of the Initiate Tag value. 1555 If the value of the Initiate Tag in a received INIT ACK chunk is 1556 found to be 0, the receiver MUST destroy the association 1557 discarding its TCB. The receiver MAY send an ABORT for debugging 1558 purpose. 1560 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1561 integer) 1562 This value represents the dedicated buffer space, in number of 1563 bytes, the sender of the INIT ACK has reserved in association with 1564 this window. During the life of the association, this buffer 1565 space SHOULD NOT be reduced (i.e., dedicated buffers ought not to 1566 be taken away from this association); however, an endpoint MAY 1567 change the value of a_rwnd it sends in SACK chunks. 1569 Number of Outbound Streams (OS): 16 bits (unsigned integer) 1570 Defines the number of outbound streams the sender of this INIT ACK 1571 chunk wishes to create in this association. The value of 0 MUST 1572 NOT be used, and the value MUST NOT be greater than the MIS value 1573 sent in the INIT chunk. 1575 A receiver of an INIT ACK with the OS value set to 0 SHOULD 1576 destroy the association discarding its TCB. 1578 Number of Inbound Streams (MIS): 16 bits (unsigned integer) 1579 Defines the maximum number of streams the sender of this INIT ACK 1580 chunk allows the peer end to create in this association. The 1581 value 0 MUST NOT be used. 1583 Note: There is no negotiation of the actual number of streams but 1584 instead the two endpoints will use the min(requested, offered). 1585 See Section 5.1.1 for details. 1587 A receiver of an INIT ACK with the MIS value set to 0 SHOULD 1588 destroy the association discarding its TCB. 1590 Initial TSN (I-TSN): 32 bits (unsigned integer) 1591 Defines the initial TSN that the INIT ACK sender will use. The 1592 valid range is from 0 to 4294967295. This field MAY be set to the 1593 value of the Initiate Tag field. 1595 IMPLEMENTATION NOTE: An implementation MUST be prepared to receive an 1596 INIT ACK that is quite large (more than 1500 bytes) due to the 1597 variable size of the State Cookie AND the variable address list. For 1598 example if a responder to the INIT has 1000 IPv4 addresses it wishes 1599 to send, it would need at least 8,000 bytes to encode this in the 1600 INIT ACK. 1602 If an INIT ACK chunk is received with all mandatory parameters that 1603 are specified for the INIT ACK chunk, then the receiver SHOULD 1604 process the INIT ACK chunk and send back a COOKIE ECHO chunk. The 1605 receiver of the INIT ACK chunk MAY bundle an ERROR chunk with the 1606 COOKIE ECHO chunk. However, restrictive implementations MAY send 1607 back an ABORT chunk in response to the INIT ACK chunk. 1609 In combination with the Source Port carried in the SCTP common 1610 header, each IP Address parameter in the INIT ACK indicates to the 1611 receiver of the INIT ACK a valid transport address supported by the 1612 sender of the INIT ACK for the life time of the association being 1613 initiated. 1615 If the INIT ACK contains at least one IP Address parameter, then the 1616 source address of the IP datagram containing the INIT ACK and any 1617 additional address(es) provided within the INIT ACK MAY be used as 1618 destinations by the receiver of the INIT ACK. If the INIT ACK does 1619 not contain any IP Address parameters, the receiver of the INIT ACK 1620 MUST use the source address associated with the received IP datagram 1621 as its sole destination address for the association. 1623 The State Cookie and Unrecognized Parameters use the Type-Length- 1624 Value format as defined in Section 3.2.1 and are described below. 1625 The other fields are defined the same as their counterparts in the 1626 INIT chunk. 1628 3.3.3.1. Optional or Variable-Length Parameters 1630 3.3.3.1.1. State Cookie (7) 1632 0 1 2 3 1633 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 1634 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1635 | Type = 7 | Length | 1636 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1637 / Cookie / 1638 \ \ 1639 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1641 Cookie: variable length 1642 This parameter value MUST contain all the necessary state and 1643 parameter information required for the sender of this INIT ACK to 1644 create the association, along with a Message Authentication Code 1645 (MAC). See Section 5.1.3 for details on State Cookie definition. 1647 3.3.3.1.2. Unrecognized Parameter (8) 1649 This parameter is returned to the originator of the INIT chunk when 1650 the INIT chunk contains an unrecognized parameter that has a type 1651 that indicates it SHOULD be reported to the sender. 1653 0 1 2 3 1654 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 1655 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1656 | Type = 8 | Length | 1657 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1658 / Unrecognized Parameter / 1659 \ \ 1660 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1662 Unrecognized Parameter: variable length 1663 The parameter value field will contain an unrecognized parameter 1664 copied from the INIT chunk complete with Parameter Type, Length, 1665 and Value fields. 1667 3.3.4. Selective Acknowledgement (SACK) (3) 1669 This chunk is sent to the peer endpoint to acknowledge received DATA 1670 chunks and to inform the peer endpoint of gaps in the received 1671 subsequences of DATA chunks as represented by their TSNs. 1673 The SACK MUST contain the Cumulative TSN Ack, Advertised Receiver 1674 Window Credit (a_rwnd), Number of Gap Ack Blocks, and Number of 1675 Duplicate TSNs fields. 1677 By definition, the value of the Cumulative TSN Ack parameter is the 1678 last TSN received before a break in the sequence of received TSNs 1679 occurs; the next TSN value following this one has not yet been 1680 received at the endpoint sending the SACK. This parameter therefore 1681 acknowledges receipt of all TSNs less than or equal to its value. 1683 The handling of a_rwnd by the receiver of the SACK is discussed in 1684 detail in Section 6.2.1. 1686 The SACK also contains zero or more Gap Ack Blocks. Each Gap Ack 1687 Block acknowledges a subsequence of TSNs received following a break 1688 in the sequence of received TSNs. The Gap Ack Blocks SHOULD be 1689 isolated. This means that the TSN just before each Gap Ack Block and 1690 the TSN just after each Gap Ack Block have not been received. By 1691 definition, all TSNs acknowledged by Gap Ack Blocks are greater than 1692 the value of the Cumulative TSN Ack. 1694 0 1 2 3 1695 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 1696 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1697 | Type = 3 |Chunk Flags | Chunk Length | 1698 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1699 | Cumulative TSN Ack | 1700 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1701 | Advertised Receiver Window Credit (a_rwnd) | 1702 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1703 | Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X | 1704 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1705 | Gap Ack Block #1 Start | Gap Ack Block #1 End | 1706 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1707 / / 1708 \ ... \ 1709 / / 1710 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1711 | Gap Ack Block #N Start | Gap Ack Block #N End | 1712 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1713 | Duplicate TSN 1 | 1714 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1715 / / 1716 \ ... \ 1717 / / 1718 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1719 | Duplicate TSN X | 1720 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1722 Chunk Flags: 8 bits 1723 Set to all '0's on transmit and ignored on receipt. 1725 Cumulative TSN Ack: 32 bits (unsigned integer) 1726 This parameter contains the TSN of the last DATA chunk received in 1727 sequence before a gap. In the case where no DATA chunk has been 1728 received, this value is set to the peer's Initial TSN minus one. 1730 Advertised Receiver Window Credit (a_rwnd): 32 bits (unsigned 1731 integer) 1732 This field indicates the updated receive buffer space in bytes of 1733 the sender of this SACK; see Section 6.2.1 for details. 1735 Number of Gap Ack Blocks: 16 bits (unsigned integer) 1736 Indicates the number of Gap Ack Blocks included in this SACK. 1738 Number of Duplicate TSNs: 16 bit 1739 This field contains the number of duplicate TSNs the endpoint has 1740 received. Each duplicate TSN is listed following the Gap Ack 1741 Block list. 1743 Gap Ack Blocks: 1744 These fields contain the Gap Ack Blocks. They are repeated for 1745 each Gap Ack Block up to the number of Gap Ack Blocks defined in 1746 the Number of Gap Ack Blocks field. All DATA chunks with TSNs 1747 greater than or equal to (Cumulative TSN Ack + Gap Ack Block 1748 Start) and less than or equal to (Cumulative TSN Ack + Gap Ack 1749 Block End) of each Gap Ack Block are assumed to have been received 1750 correctly. Gap Ack Blocks SHOULD be isolated. This means that 1751 the DATA chunks with TSNs equal to (Cumulative TSN Ack + Gap Ack 1752 Block Start - 1) and (Cumulative TSN Ack + Gap Ack Block End + 1) 1753 have not been received. 1755 Gap Ack Block Start: 16 bits (unsigned integer) 1756 Indicates the Start offset TSN for this Gap Ack Block. To 1757 calculate the actual TSN number the Cumulative TSN Ack is added to 1758 this offset number. This calculated TSN identifies the first TSN 1759 in this Gap Ack Block that has been received. 1761 Gap Ack Block End: 16 bits (unsigned integer) 1762 Indicates the End offset TSN for this Gap Ack Block. To calculate 1763 the actual TSN number, the Cumulative TSN Ack is added to this 1764 offset number. This calculated TSN identifies the TSN of the last 1765 DATA chunk received in this Gap Ack Block. 1767 For example, assume that the receiver has the following DATA 1768 chunks newly arrived at the time when it decides to send a 1769 Selective ACK, 1771 ---------- 1772 | TSN=17 | 1773 ---------- 1774 | | <- still missing 1775 ---------- 1776 | TSN=15 | 1777 ---------- 1778 | TSN=14 | 1779 ---------- 1780 | | <- still missing 1781 ---------- 1782 | TSN=12 | 1783 ---------- 1784 | TSN=11 | 1785 ---------- 1786 | TSN=10 | 1787 ---------- 1789 then the parameter part of the SACK MUST be constructed as follows 1790 (assuming the new a_rwnd is set to 4660 by the sender): 1792 +--------------------------------+ 1793 | Cumulative TSN Ack = 12 | 1794 +--------------------------------+ 1795 | a_rwnd = 4660 | 1796 +----------------+---------------+ 1797 | num of block=2 | num of dup=0 | 1798 +----------------+---------------+ 1799 |block #1 strt=2 |block #1 end=3 | 1800 +----------------+---------------+ 1801 |block #2 strt=5 |block #2 end=5 | 1802 +----------------+---------------+ 1804 Duplicate TSN: 32 bits (unsigned integer) 1805 Indicates the number of times a TSN was received in duplicate 1806 since the last SACK was sent. Every time a receiver gets a 1807 duplicate TSN (before sending the SACK), it adds it to the list of 1808 duplicates. The duplicate count is reinitialized to zero after 1809 sending each SACK. 1811 For example, if a receiver were to get the TSN 19 three times it 1812 would list 19 twice in the outbound SACK. After sending the SACK, 1813 if it received yet one more TSN 19 it would list 19 as a duplicate 1814 once in the next outgoing SACK. 1816 3.3.5. Heartbeat Request (HEARTBEAT) (4) 1818 An endpoint SHOULD send a HEARTBEAT chunk to its peer endpoint to 1819 probe the reachability of a particular destination transport address 1820 defined in the present association. 1822 The parameter field contains the Heartbeat Information, which is a 1823 variable-length opaque data structure understood only by the sender. 1825 0 1 2 3 1826 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 1827 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1828 | Type = 4 | Chunk Flags | Heartbeat Length | 1829 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1830 \ \ 1831 / Heartbeat Information TLV (Variable-Length) / 1832 \ \ 1833 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1835 Chunk Flags: 8 bits 1836 Set to 0 on transmit and ignored on receipt. 1838 Heartbeat Length: 16 bits (unsigned integer) 1839 Set to the size of the chunk in bytes, including the chunk header 1840 and the Heartbeat Information field. 1842 Heartbeat Information: variable length 1843 Defined as a variable-length parameter using the format described 1844 in Section 3.2.1, i.e.: 1846 +---------------------+-----------+------------+ 1847 | Variable Parameters | Status | Type Value | 1848 +---------------------+-----------+------------+ 1849 | Heartbeat Info | Mandatory | 1 | 1850 +---------------------+-----------+------------+ 1852 Table 9: Variable Length Parameters of 1853 HEARTBEAT Chunks 1855 0 1 2 3 1856 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 1857 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1858 | Heartbeat Info Type=1 | HB Info Length | 1859 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1860 / Sender-Specific Heartbeat Info / 1861 \ \ 1862 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1864 The Sender-Specific Heartbeat Info field SHOULD include 1865 information about the sender's current time when this HEARTBEAT 1866 chunk is sent and the destination transport address to which this 1867 HEARTBEAT is sent (see Section 8.3). This information is simply 1868 reflected back by the receiver in the HEARTBEAT ACK message (see 1869 Section 3.3.6). Note also that the HEARTBEAT message is both for 1870 reachability checking and for path verification (see Section 5.4). 1871 When a HEARTBEAT chunk is being used for path verification 1872 purposes, it MUST hold a 64-bit random nonce. 1874 3.3.6. Heartbeat Acknowledgement (HEARTBEAT ACK) (5) 1876 An endpoint MUST send this chunk to its peer endpoint as a response 1877 to a HEARTBEAT chunk (see Section 8.3). A HEARTBEAT ACK is always 1878 sent to the source IP address of the IP datagram containing the 1879 HEARTBEAT chunk to which this ack is responding. 1881 The parameter field contains a variable-length opaque data structure. 1883 0 1 2 3 1884 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 1885 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1886 | Type = 5 | Chunk Flags | Heartbeat Ack Length | 1887 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1888 \ \ 1889 / Heartbeat Information TLV (Variable-Length) / 1890 \ \ 1891 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1893 Chunk Flags: 8 bits 1894 Set to 0 on transmit and ignored on receipt. 1896 Heartbeat Ack Length: 16 bits (unsigned integer) 1897 Set to the size of the chunk in bytes, including the chunk header 1898 and the Heartbeat Information field. 1900 Heartbeat Information: variable length 1901 This field MUST contain the Heartbeat Information parameter of the 1902 Heartbeat Request to which this Heartbeat Acknowledgement is 1903 responding. 1905 +---------------------+-----------+------------+ 1906 | Variable Parameters | Status | Type Value | 1907 +---------------------+-----------+------------+ 1908 | Heartbeat Info | Mandatory | 1 | 1909 +---------------------+-----------+------------+ 1911 Table 10: Variable Length Parameters of 1912 HEARTBEAT ACK Chunks 1914 3.3.7. Abort Association (ABORT) (6) 1916 The ABORT chunk is sent to the peer of an association to close the 1917 association. The ABORT chunk MAY contain Cause Parameters to inform 1918 the receiver about the reason of the abort. DATA chunks MUST NOT be 1919 bundled with ABORT. Control chunks (except for INIT, INIT ACK, and 1920 SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be 1921 placed before the ABORT in the SCTP packet, otherwise they will be 1922 ignored by the receiver. 1924 If an endpoint receives an ABORT with a format error or no TCB is 1925 found, it MUST silently discard it. Moreover, under any 1926 circumstances, an endpoint that receives an ABORT MUST NOT respond to 1927 that ABORT by sending an ABORT of its own. 1929 0 1 2 3 1930 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 1931 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1932 | Type = 6 |Reserved |T| Length | 1933 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1934 \ \ 1935 / zero or more Error Causes / 1936 \ \ 1937 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1939 Chunk Flags: 8 bits 1940 Reserved: 7 bits 1941 Set to 0 on transmit and ignored on receipt. 1943 T bit: 1 bit 1944 The T bit is set to 0 if the sender filled in the Verification 1945 Tag expected by the peer. If the Verification Tag is 1946 reflected, the T bit MUST be set to 1. Reflecting means that 1947 the sent Verification Tag is the same as the received one. 1949 Length: 16 bits (unsigned integer) 1950 Set to the size of the chunk in bytes, including the chunk header 1951 and all the Error Cause fields present. 1953 See Section 3.3.10 for Error Cause definitions. 1955 Note: Special rules apply to this chunk for verification; please see 1956 Section 8.5.1 for details. 1958 3.3.8. Shutdown Association (SHUTDOWN) (7) 1960 An endpoint in an association MUST use this chunk to initiate a 1961 graceful close of the association with its peer. This chunk has the 1962 following format. 1964 0 1 2 3 1965 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 1966 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1967 | Type = 7 | Chunk Flags | Length = 8 | 1968 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1969 | Cumulative TSN Ack | 1970 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1972 Chunk Flags: 8 bits 1973 Set to 0 on transmit and ignored on receipt. 1975 Length: 16 bits (unsigned integer) 1976 Indicates the length of the parameter. Set to 8. 1978 Cumulative TSN Ack: 32 bits (unsigned integer) 1979 This parameter contains the TSN of the last chunk received in 1980 sequence before any gaps. 1982 Note: Since the SHUTDOWN message does not contain Gap Ack Blocks, it 1983 cannot be used to acknowledge TSNs received out of order. In a SACK, 1984 lack of Gap Ack Blocks that were previously included indicates that 1985 the data receiver reneged on the associated DATA chunks. 1987 Since SHUTDOWN does not contain Gap Ack Blocks, the receiver of the 1988 SHUTDOWN MUST NOT interpret the lack of a Gap Ack Block as a renege. 1989 (See Section 6.2 for information on reneging.) 1991 3.3.9. Shutdown Acknowledgement (SHUTDOWN ACK) (8) 1993 This chunk MUST be used to acknowledge the receipt of the SHUTDOWN 1994 chunk at the completion of the shutdown process; see Section 9.2 for 1995 details. 1997 The SHUTDOWN ACK chunk has no parameters. 1999 0 1 2 3 2000 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 2001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2002 | Type = 8 |Chunk Flags | Length = 4 | 2003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2005 Chunk Flags: 8 bits 2006 Set to 0 on transmit and ignored on receipt. 2008 3.3.10. Operation Error (ERROR) (9) 2010 An endpoint sends this chunk to its peer endpoint to notify it of 2011 certain error conditions. It contains one or more error causes. An 2012 Operation Error is not considered fatal in and of itself, but MAY be 2013 used with an ABORT chunk to report a fatal condition. It has the 2014 following parameters: 2016 0 1 2 3 2017 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 2018 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2019 | Type = 9 | Chunk Flags | Length | 2020 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2021 \ \ 2022 / one or more Error Causes / 2023 \ \ 2024 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2026 Chunk Flags: 8 bits 2027 Set to 0 on transmit and ignored on receipt. 2029 Length: 16 bits (unsigned integer) 2030 Set to the size of the chunk in bytes, including the chunk header 2031 and all the Error Cause fields present. 2033 Error causes are defined as variable-length parameters using the 2034 format described in Section 3.2.1, that is: 2036 0 1 2 3 2037 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 2038 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2039 | Cause Code | Cause Length | 2040 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2041 / Cause-Specific Information / 2042 \ \ 2043 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2045 Cause Code: 16 bits (unsigned integer) 2046 Defines the type of error conditions being reported. 2048 +-------+----------------------------------------------+ 2049 | Value | Cause Code | 2050 +-------+----------------------------------------------+ 2051 | 1 | Invalid Stream Identifier | 2052 +-------+----------------------------------------------+ 2053 | 2 | Missing Mandatory Parameter | 2054 +-------+----------------------------------------------+ 2055 | 3 | Stale Cookie Error | 2056 +-------+----------------------------------------------+ 2057 | 4 | Out of Resource | 2058 +-------+----------------------------------------------+ 2059 | 5 | Unresolvable Address | 2060 +-------+----------------------------------------------+ 2061 | 6 | Unrecognized Chunk Type | 2062 +-------+----------------------------------------------+ 2063 | 7 | Invalid Mandatory Parameter | 2064 +-------+----------------------------------------------+ 2065 | 8 | Unrecognized Parameters | 2066 +-------+----------------------------------------------+ 2067 | 9 | No User Data | 2068 +-------+----------------------------------------------+ 2069 | 10 | Cookie Received While Shutting Down | 2070 +-------+----------------------------------------------+ 2071 | 11 | Restart of an Association with New Addresses | 2072 +-------+----------------------------------------------+ 2073 | 12 | User Initiated Abort | 2074 +-------+----------------------------------------------+ 2075 | 13 | Protocol Violation | 2076 +-------+----------------------------------------------+ 2078 Table 11: Cause Code 2080 Cause Length: 16 bits (unsigned integer) 2081 Set to the size of the parameter in bytes, including the Cause 2082 Code, Cause Length, and Cause-Specific Information fields. 2084 Cause-Specific Information: variable length 2085 This field carries the details of the error condition. 2087 Section 3.3.10.1 - Section 3.3.10.13 define error causes for SCTP. 2088 Guidelines for the IETF to define new error cause values are 2089 discussed in Section 15.4. 2091 3.3.10.1. Invalid Stream Identifier (1) 2093 Invalid Stream Identifier: Indicates endpoint received a DATA chunk 2094 sent to a nonexistent stream. 2096 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2097 | Cause Code=1 | Cause Length=8 | 2098 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2099 | Stream Identifier | (Reserved) | 2100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2102 Stream Identifier: 16 bits (unsigned integer) 2103 Contains the Stream Identifier of the DATA chunk received in 2104 error. 2106 Reserved: 16 bits 2107 This field is reserved. It is set to all 0's on transmit and 2108 ignored on receipt. 2110 3.3.10.2. Missing Mandatory Parameter (2) 2112 Missing Mandatory Parameter: Indicates that one or more mandatory TLV 2113 parameters are missing in a received INIT or INIT ACK. 2115 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2116 | Cause Code=2 | Cause Length=8+N*2 | 2117 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2118 | Number of missing params=N | 2119 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2120 | Missing Param Type #1 | Missing Param Type #2 | 2121 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2122 | Missing Param Type #N-1 | Missing Param Type #N | 2123 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2125 Number of Missing params: 32 bits (unsigned integer) 2126 This field contains the number of parameters contained in the 2127 Cause-Specific Information field. 2129 Missing Param Type: 16 bits (unsigned integer) 2130 Each field will contain the missing mandatory parameter number. 2132 3.3.10.3. Stale Cookie Error (3) 2134 Stale Cookie Error: Indicates the receipt of a valid State Cookie 2135 that has expired. 2137 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2138 | Cause Code=3 | Cause Length=8 | 2139 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2140 | Measure of Staleness (usec.) | 2141 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2143 Measure of Staleness: 32 bits (unsigned integer) 2144 This field contains the difference, in microseconds, between the 2145 current time and the time the State Cookie expired. 2147 The sender of this error cause MAY choose to report how long past 2148 expiration the State Cookie is by including a non-zero value in 2149 the Measure of Staleness field. If the sender does not wish to 2150 provide the Measure of Staleness, it SHOULD set this field to the 2151 value of zero. 2153 3.3.10.4. Out of Resource (4) 2155 Out of Resource: Indicates that the sender is out of resource. This 2156 is usually sent in combination with or within an ABORT. 2158 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2159 | Cause Code=4 | Cause Length=4 | 2160 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2162 3.3.10.5. Unresolvable Address (5) 2164 Unresolvable Address: Indicates that the sender is not able to 2165 resolve the specified address parameter (e.g., type of address is not 2166 supported by the sender). This is usually sent in combination with 2167 or within an ABORT. 2169 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2170 | Cause Code=5 | Cause Length | 2171 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2172 / Unresolvable Address / 2173 \ \ 2174 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2176 Unresolvable Address: variable length 2177 The Unresolvable Address field contains the complete Type, Length, 2178 and Value of the address parameter (or Host Name parameter) that 2179 contains the unresolvable address or host name. 2181 3.3.10.6. Unrecognized Chunk Type (6) 2183 Unrecognized Chunk Type: This error cause is returned to the 2184 originator of the chunk if the receiver does not understand the chunk 2185 and the upper bits of the 'Chunk Type' are set to 01 or 11. 2187 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2188 | Cause Code=6 | Cause Length | 2189 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2190 / Unrecognized Chunk / 2191 \ \ 2192 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2194 Unrecognized Chunk: variable length 2195 The Unrecognized Chunk field contains the unrecognized chunk from 2196 the SCTP packet complete with Chunk Type, Chunk Flags, and Chunk 2197 Length. 2199 3.3.10.7. Invalid Mandatory Parameter (7) 2201 Invalid Mandatory Parameter: This error cause is returned to the 2202 originator of an INIT or INIT ACK chunk when one of the mandatory 2203 parameters is set to an invalid value. 2205 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2206 | Cause Code=7 | Cause Length=4 | 2207 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2209 3.3.10.8. Unrecognized Parameters (8) 2211 Unrecognized Parameters: This error cause is returned to the 2212 originator of the INIT ACK chunk if the receiver does not recognize 2213 one or more Optional TLV parameters in the INIT ACK chunk. 2215 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2216 | Cause Code=8 | Cause Length | 2217 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2218 / Unrecognized Parameters / 2219 \ \ 2220 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2222 Unrecognized Parameters: variable length 2223 The Unrecognized Parameters field contains the unrecognized 2224 parameters copied from the INIT ACK chunk complete with TLV. This 2225 error cause is normally contained in an ERROR chunk bundled with 2226 the COOKIE ECHO chunk when responding to the INIT ACK, when the 2227 sender of the COOKIE ECHO chunk wishes to report unrecognized 2228 parameters. 2230 3.3.10.9. No User Data (9) 2232 No User Data: This error cause is returned to the originator of a 2233 DATA chunk if a received DATA chunk has no user data. 2235 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2236 | Cause Code=9 | Cause Length=8 | 2237 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2238 / TSN value / 2239 \ \ 2240 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2242 TSN value: 32 bits (unsigned integer) 2243 The TSN value field contains the TSN of the DATA chunk received 2244 with no user data field. 2246 This cause code is normally returned in an ABORT chunk (see 2247 Section 6.2). 2249 3.3.10.10. Cookie Received While Shutting Down (10) 2251 Cookie Received While Shutting Down: A COOKIE ECHO was received while 2252 the endpoint was in the SHUTDOWN-ACK-SENT state. This error is 2253 usually returned in an ERROR chunk bundled with the retransmitted 2254 SHUTDOWN ACK. 2256 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2257 | Cause Code=10 | Cause Length=4 | 2258 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2260 3.3.10.11. Restart of an Association with New Addresses (11) 2262 Restart of an association with new addresses: An INIT was received on 2263 an existing association. But the INIT added addresses to the 2264 association that were previously not part of the association. The 2265 new addresses are listed in the error code. This ERROR is normally 2266 sent as part of an ABORT refusing the INIT (see Section 5.2). 2268 0 1 2 3 2269 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 2270 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2271 | Cause Code=11 | Cause Length=Variable | 2272 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2273 / New Address TLVs / 2274 \ \ 2275 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2277 Note: Each New Address TLV is an exact copy of the TLV that was found 2278 in the INIT chunk that was new, including the Parameter Type and the 2279 Parameter Length. 2281 3.3.10.12. User-Initiated Abort (12) 2283 This error cause MAY be included in ABORT chunks that are sent 2284 because of an upper-layer request. The upper layer can specify an 2285 Upper Layer Abort Reason that is transported by SCTP transparently 2286 and MAY be delivered to the upper-layer protocol at the peer. 2288 0 1 2 3 2289 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 2290 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2291 | Cause Code=12 | Cause Length=Variable | 2292 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2293 / Upper Layer Abort Reason / 2294 \ \ 2295 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2297 3.3.10.13. Protocol Violation (13) 2299 This error cause MAY be included in ABORT chunks that are sent 2300 because an SCTP endpoint detects a protocol violation of the peer 2301 that is not covered by the error causes described in Section 3.3.10.1 2302 to Section 3.3.10.12. An implementation MAY provide additional 2303 information specifying what kind of protocol violation has been 2304 detected. 2306 0 1 2 3 2307 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 2308 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2309 | Cause Code=13 | Cause Length=Variable | 2310 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2311 / Additional Information / 2312 \ \ 2313 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2315 3.3.11. Cookie Echo (COOKIE ECHO) (10) 2317 This chunk is used only during the initialization of an association. 2318 It is sent by the initiator of an association to its peer to complete 2319 the initialization process. This chunk MUST precede any DATA chunk 2320 sent within the association, but MAY be bundled with one or more DATA 2321 chunks in the same packet. 2323 0 1 2 3 2324 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 2325 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2326 | Type = 10 |Chunk Flags | Length | 2327 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2328 / Cookie / 2329 \ \ 2330 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2332 Chunk Flags: 8 bits 2333 Set to 0 on transmit and ignored on receipt. 2335 Length: 16 bits (unsigned integer) 2336 Set to the size of the chunk in bytes, including the 4 bytes of 2337 the chunk header and the size of the cookie. 2339 Cookie: variable size 2340 This field MUST contain the exact cookie received in the State 2341 Cookie parameter from the previous INIT ACK. 2343 An implementation SHOULD make the cookie as small as possible to 2344 ensure interoperability. 2346 Note: A Cookie Echo does not contain a State Cookie parameter; 2347 instead, the data within the State Cookie's Parameter Value 2348 becomes the data within the Cookie Echo's Chunk Value. This 2349 allows an implementation to change only the first 2 bytes of the 2350 State Cookie parameter to become a COOKIE ECHO chunk. 2352 3.3.12. Cookie Acknowledgement (COOKIE ACK) (11) 2354 This chunk is used only during the initialization of an association. 2355 It is used to acknowledge the receipt of a COOKIE ECHO chunk. This 2356 chunk MUST precede any DATA or SACK chunk sent within the 2357 association, but MAY be bundled with one or more DATA chunks or SACK 2358 chunk's in the same SCTP packet. 2360 0 1 2 3 2361 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 2362 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2363 | Type = 11 |Chunk Flags | Length = 4 | 2364 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2366 Chunk Flags: 8 bits 2367 Set to 0 on transmit and ignored on receipt. 2369 3.3.13. Shutdown Complete (SHUTDOWN COMPLETE) (14) 2371 This chunk MUST be used to acknowledge the receipt of the SHUTDOWN 2372 ACK chunk at the completion of the shutdown process; see Section 9.2 2373 for details. 2375 The SHUTDOWN COMPLETE chunk has no parameters. 2377 0 1 2 3 2378 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 2379 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2380 | Type = 14 |Reserved |T| Length = 4 | 2381 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2383 Chunk Flags: 8 bits 2384 Reserved: 7 bits 2385 Set to 0 on transmit and ignored on receipt. 2387 T bit: 1 bit 2388 The T bit is set to 0 if the sender filled in the Verification 2389 Tag expected by the peer. If the Verification Tag is 2390 reflected, the T bit MUST be set to 1. Reflecting means that 2391 the sent Verification Tag is the same as the received one. 2393 Note: Special rules apply to this chunk for verification, please see 2394 Section 8.5.1 for details. 2396 4. SCTP Association State Diagram 2398 During the life time of an SCTP association, the SCTP endpoint's 2399 association progresses from one state to another in response to 2400 various events. The events that might potentially advance an 2401 association's state include: 2403 * SCTP user primitive calls, e.g., [ASSOCIATE], [SHUTDOWN], [ABORT], 2405 * Reception of INIT, COOKIE ECHO, ABORT, SHUTDOWN, etc., control 2406 chunks, or 2408 * Some timeout events. 2410 The state diagram in the figures below illustrates state changes, 2411 together with the causing events and resulting actions. Note that 2412 some of the error conditions are not shown in the state diagram. 2413 Full descriptions of all special cases are found in the text. 2415 Note: Chunk names are given in all capital letters, while parameter 2416 names have the first letter capitalized, e.g., COOKIE ECHO chunk type 2417 vs. State Cookie parameter. If more than one event/message can occur 2418 that causes a state transition, it is labeled (A), (B). 2420 ----- -------- (from any state) 2421 / \ /receive ABORT [ABORT] 2422 receive INIT | | |-------------- or ---------- 2423 ----------------| v v delete TCB send ABORT 2424 generate Cookie \ +---------+ delete TCB 2425 send INIT ACK ---| CLOSED | 2426 +---------+ 2427 / \ 2428 / \ [ASSOCIATE] 2429 | |----------------- 2430 | | create TCB 2431 | | send INIT 2432 receive valid | | start init timer 2433 COOKIE ECHO | v 2434 (1) -----------------| +------------+ 2435 create TCB | | COOKIE-WAIT| (2) 2436 send COOKIE ACK | +------------+ 2437 | | 2438 | | receive INIT ACK 2439 | |------------------- 2440 | | send COOKIE ECHO 2441 | | stop init timer 2442 | | start cookie timer 2443 | v 2444 | +--------------+ 2445 | | COOKIE-ECHOED| (3) 2446 | +--------------+ 2447 | | 2448 | | receive COOKIE ACK 2449 | |------------------- 2450 | | stop cookie timer 2451 v v 2452 +---------------+ 2453 | ESTABLISHED | 2454 +---------------+ 2455 | 2456 | 2457 /----+------------\ 2458 [SHUTDOWN] / \ 2459 -------------------| | 2460 check outstanding | | 2461 DATA chunks | | 2462 v | 2464 +---------+ | 2465 |SHUTDOWN-| | receive SHUTDOWN 2466 |PENDING | |------------------ 2467 +---------+ | check outstanding 2468 | | DATA chunks 2469 No more outstanding | | 2470 ---------------------| | 2471 send SHUTDOWN | | 2472 start shutdown timer | | 2473 v v 2474 +---------+ +-----------+ 2475 (4) |SHUTDOWN-| | SHUTDOWN- | (5,6) 2476 |SENT | | RECEIVED | 2477 +---------+ +-----------+ 2478 | \ | 2479 receive SHUTDOWN ACK | \ | 2480 ----------------------| \ | 2481 stop shutdown timer | \ | 2482 send SHUTDOWN COMPLETE| \ | 2483 delete TCB | \ | 2484 | \ | No more outstanding 2485 | \ |--------------------- 2486 | \ | send SHUTDOWN ACK 2487 receive SHUTDOWN -|- \ | start shutdown timer 2488 --------------------/ | \----------\ | 2489 send SHUTDOWN ACK | \ | 2490 start shutdown timer | \ | 2491 | \ | 2492 | | | 2493 | v v 2494 | +-----------+ 2495 | | SHUTDOWN- | (7) 2496 | | ACK-SENT | 2497 | +----------+- 2498 | | (A) 2499 | | receive SHUTDOWN COMPLETE 2500 | |-------------------------- 2501 | | stop shutdown timer 2502 | | delete TCB 2503 | | 2504 | | (B) 2505 | | receive SHUTDOWN ACK 2506 | |----------------------- 2507 | | stop shutdown timer 2508 | | send SHUTDOWN COMPLETE 2509 | | delete TCB 2510 | | 2511 \ +---------+ / 2512 \-->| CLOSED |<--/ 2513 +---------+ 2515 Figure 3: State Transition Diagram of SCTP 2517 The following applies: 2519 1) If the State Cookie in the received COOKIE ECHO is invalid (i.e., 2520 failed to pass the integrity check), the receiver MUST silently 2521 discard the packet. Or, if the received State Cookie is expired 2522 (see Section 5.1.5), the receiver MUST send back an ERROR chunk. 2523 In either case, the receiver stays in the CLOSED state. 2525 2) If the T1-init timer expires, the endpoint MUST retransmit INIT 2526 and restart the T1-init timer without changing state. This MUST 2527 be repeated up to 'Max.Init.Retransmits' times. After that, the 2528 endpoint MUST abort the initialization process and report the 2529 error to the SCTP user. 2531 3) If the T1-cookie timer expires, the endpoint MUST retransmit 2532 COOKIE ECHO and restart the T1-cookie timer without changing 2533 state. This MUST be repeated up to 'Max.Init.Retransmits' times. 2534 After that, the endpoint MUST abort the initialization process 2535 and report the error to the SCTP user. 2537 4) In the SHUTDOWN-SENT state, the endpoint MUST acknowledge any 2538 received DATA chunks without delay. 2540 5) In the SHUTDOWN-RECEIVED state, the endpoint MUST NOT accept any 2541 new send requests from its SCTP user. 2543 6) In the SHUTDOWN-RECEIVED state, the endpoint MUST transmit or 2544 retransmit data and leave this state when all data in queue is 2545 transmitted. 2547 7) In the SHUTDOWN-ACK-SENT state, the endpoint MUST NOT accept any 2548 new send requests from its SCTP user. 2550 The CLOSED state is used to indicate that an association is not 2551 created (i.e., does not exist). 2553 5. Association Initialization 2555 Before the first data transmission can take place from one SCTP 2556 endpoint ("A") to another SCTP endpoint ("Z"), the two endpoints MUST 2557 complete an initialization process in order to set up an SCTP 2558 association between them. 2560 The SCTP user at an endpoint can use the ASSOCIATE primitive to 2561 initialize an SCTP association to another SCTP endpoint. 2563 IMPLEMENTATION NOTE: From an SCTP user's point of view, an 2564 association might be implicitly opened, without an ASSOCIATE 2565 primitive (see Section 11.1.2) being invoked, by the initiating 2566 endpoint's sending of the first user data to the destination 2567 endpoint. The initiating SCTP will assume default values for all 2568 mandatory and optional parameters for the INIT/INIT ACK. 2570 Once the association is established, unidirectional streams are open 2571 for data transfer on both ends (see Section 5.1.1). 2573 5.1. Normal Establishment of an Association 2575 The initialization process consists of the following steps (assuming 2576 that SCTP endpoint "A" tries to set up an association with SCTP 2577 endpoint "Z" and "Z" accepts the new association): 2579 A) "A" first sends an INIT chunk to "Z". In the INIT, "A" MUST 2580 provide its Verification Tag (Tag_A) in the Initiate Tag field. 2581 Tag_A SHOULD be a random number in the range of 1 to 4294967295 2582 (see Section 5.3.1 for Tag value selection). After sending the 2583 INIT, "A" starts the T1-init timer and enters the COOKIE-WAIT 2584 state. 2586 B) "Z" responds immediately with an INIT ACK chunk. The destination 2587 IP address of the INIT ACK MUST be set to the source IP address 2588 of the INIT to which this INIT ACK is responding. In the 2589 response, besides filling in other parameters, "Z" MUST set the 2590 Verification Tag field to Tag_A, and also provide its own 2591 Verification Tag (Tag_Z) in the Initiate Tag field. 2593 Moreover, "Z" MUST generate and send along with the INIT ACK a 2594 State Cookie. See Section 5.1.3 for State Cookie generation. 2596 After sending out INIT ACK with the State Cookie parameter, "Z" 2597 MUST NOT allocate any resources or keep any states for the new 2598 association. Otherwise, "Z" will be vulnerable to resource 2599 attacks. 2601 C) Upon reception of the INIT ACK from "Z", "A" stops the T1-init 2602 timer and leaves the COOKIE-WAIT state. "A" then sends the State 2603 Cookie received in the INIT ACK chunk in a COOKIE ECHO chunk, 2604 starts the T1-cookie timer, and enters the COOKIE-ECHOED state. 2606 The COOKIE ECHO chunk MAY be bundled with any pending outbound 2607 DATA chunks, but it MUST be the first chunk in the packet and 2608 until the COOKIE ACK is returned the sender MUST NOT send any 2609 other packets to the peer. 2611 D) Upon reception of the COOKIE ECHO chunk, endpoint "Z" replies 2612 with a COOKIE ACK chunk after building a TCB and moving to the 2613 ESTABLISHED state. A COOKIE ACK chunk MAY be bundled with any 2614 pending DATA chunks (and/or SACK chunks), but the COOKIE ACK 2615 chunk MUST be the first chunk in the packet. 2617 IMPLEMENTATION NOTE: An implementation can choose to send the 2618 Communication Up notification to the SCTP user upon reception of 2619 a valid COOKIE ECHO chunk. 2621 E) Upon reception of the COOKIE ACK, endpoint "A" moves from the 2622 COOKIE-ECHOED state to the ESTABLISHED state, stopping the 2623 T1-cookie timer. It can also notify its ULP about the successful 2624 establishment of the association with a Communication Up 2625 notification (see Section 11). 2627 An INIT or INIT ACK chunk MUST NOT be bundled with any other chunk. 2628 They MUST be the only chunks present in the SCTP packets that carry 2629 them. 2631 An endpoint MUST send the INIT ACK to the IP address from which it 2632 received the INIT. 2634 T1-init timer and T1-cookie timer SHOULD follow the same rules given 2635 in Section 6.3. If the application provided multiple IP addresses of 2636 the peer, there SHOULD be a T1-init and T1-cookie timer for each 2637 address of the peer. Retransmissions of INIT chunks and COOKIE ECHO 2638 chunks SHOULD use all addresses of the peer similar to 2639 retransmissions of DATA chunks. 2641 If an endpoint receives an INIT, INIT ACK, or COOKIE ECHO chunk but 2642 decides not to establish the new association due to missing mandatory 2643 parameters in the received INIT or INIT ACK, invalid parameter 2644 values, or lack of local resources, it SHOULD respond with an ABORT 2645 chunk. It SHOULD also specify the cause of abort, such as the type 2646 of the missing mandatory parameters, etc., by including the error 2647 cause parameters with the ABORT chunk. The Verification Tag field in 2648 the common header of the outbound SCTP packet containing the ABORT 2649 chunk MUST be set to the Initiate Tag value of the peer. 2651 Note that a COOKIE ECHO chunk that does not pass the integrity check 2652 is not considered an 'invalid parameter' and requires special 2653 handling; see Section 5.1.5. 2655 After the reception of the first DATA chunk in an association the 2656 endpoint MUST immediately respond with a SACK to acknowledge the DATA 2657 chunk. Subsequent acknowledgements SHOULD be done as described in 2658 Section 6.2. 2660 When the TCB is created, each endpoint MUST set its internal 2661 Cumulative TSN Ack Point to the value of its transmitted Initial TSN 2662 minus one. 2664 IMPLEMENTATION NOTE: The IP addresses and SCTP port are generally 2665 used as the key to find the TCB within an SCTP instance. 2667 5.1.1. Handle Stream Parameters 2669 In the INIT and INIT ACK chunks, the sender of the chunk MUST 2670 indicate the number of outbound streams (OSs) it wishes to have in 2671 the association, as well as the maximum inbound streams (MISs) it 2672 will accept from the other endpoint. 2674 After receiving the stream configuration information from the other 2675 side, each endpoint MUST perform the following check: If the peer's 2676 MIS is less than the endpoint's OS, meaning that the peer is 2677 incapable of supporting all the outbound streams the endpoint wants 2678 to configure, the endpoint MUST use MIS outbound streams and MAY 2679 report any shortage to the upper layer. The upper layer can then 2680 choose to abort the association if the resource shortage is 2681 unacceptable. 2683 After the association is initialized, the valid outbound stream 2684 identifier range for either endpoint MUST be 0 to min(local OS, 2685 remote MIS) - 1. 2687 5.1.2. Handle Address Parameters 2689 During the association initialization, an endpoint uses the following 2690 rules to discover and collect the destination transport address(es) 2691 of its peer. 2693 A) If there are no address parameters present in the received INIT 2694 or INIT ACK chunk, the endpoint MUST take the source IP address 2695 from which the chunk arrives and record it, in combination with 2696 the SCTP source port number, as the only destination transport 2697 address for this peer. 2699 B) If there is a Host Name Address parameter present in the received 2700 INIT or INIT ACK chunk, the endpoint MUST immediately send an 2701 ABORT and MAY include an "Unresolvable Address" error cause to 2702 its peer. The ABORT SHOULD be sent to the source IP address from 2703 which the last peer packet was received. 2705 C) If there are only IPv4/IPv6 addresses present in the received 2706 INIT or INIT ACK chunk, the receiver MUST derive and record all 2707 the transport addresses from the received chunk AND the source IP 2708 address that sent the INIT or INIT ACK. The transport addresses 2709 are derived by the combination of SCTP source port (from the 2710 common header) and the IP Address parameter(s) carried in the 2711 INIT or INIT ACK chunk and the source IP address of the IP 2712 datagram. The receiver SHOULD use only these transport addresses 2713 as destination transport addresses when sending subsequent 2714 packets to its peer. 2716 D) An INIT or INIT ACK chunk MUST be treated as belonging to an 2717 already established association (or one in the process of being 2718 established) if the use of any of the valid address parameters 2719 contained within the chunk would identify an existing TCB. 2721 IMPLEMENTATION NOTE: In some cases (e.g., when the implementation 2722 does not control the source IP address that is used for 2723 transmitting), an endpoint might need to include in its INIT or INIT 2724 ACK all possible IP addresses from which packets to the peer could be 2725 transmitted. 2727 After all transport addresses are derived from the INIT or INIT ACK 2728 chunk using the above rules, the endpoint selects one of the 2729 transport addresses as the initial primary path. 2731 The INIT ACK MUST be sent to the source address of the INIT. 2733 The sender of INIT chunks MAY include a 'Supported Address Types' 2734 parameter in the INIT to indicate what types of addresses are 2735 acceptable. 2737 IMPLEMENTATION NOTE: In the case that the receiver of an INIT ACK 2738 fails to resolve the address parameter due to an unsupported type, it 2739 can abort the initiation process and then attempt a reinitiation by 2740 using a 'Supported Address Types' parameter in the new INIT to 2741 indicate what types of address it prefers. 2743 If an SCTP endpoint that only supports either IPv4 or IPv6 receives 2744 IPv4 and IPv6 addresses in an INIT or INIT ACK chunk from its peer, 2745 it MUST use all the addresses belonging to the supported address 2746 family. The other addresses MAY be ignored. The endpoint SHOULD NOT 2747 respond with any kind of error indication. 2749 If an SCTP endpoint lists in the 'Supported Address Types' parameter 2750 either IPv4 or IPv6, but uses the other family for sending the packet 2751 containing the INIT chunk, or if it also lists addresses of the other 2752 family in the INIT chunk, then the address family that is not listed 2753 in the 'Supported Address Types' parameter SHOULD also be considered 2754 as supported by the receiver of the INIT chunk. The receiver of the 2755 INIT chunk SHOULD NOT respond with any kind of error indication. 2757 5.1.3. Generating State Cookie 2759 When sending an INIT ACK as a response to an INIT chunk, the sender 2760 of INIT ACK creates a State Cookie and sends it in the State Cookie 2761 parameter of the INIT ACK. Inside this State Cookie, the sender can 2762 include a MAC (see [RFC2104] for an example), a timestamp on when the 2763 State Cookie is created, and the lifespan of the State Cookie, along 2764 with all the information necessary for it to establish the 2765 association. 2767 The following steps SHOULD be taken to generate the State Cookie: 2769 1) Create an association TCB using information from both the 2770 received INIT and the outgoing INIT ACK chunk, 2772 2) In the TCB, set the creation time to the current time of day, and 2773 the lifespan to the protocol parameter 'Valid.Cookie.Life' (see 2774 Section 16), 2776 3) From the TCB, identify and collect the minimal subset of 2777 information needed to re-create the TCB, and generate a MAC using 2778 this subset of information and a secret key (see [RFC2104] for an 2779 example of generating a MAC), and 2781 4) Generate the State Cookie by combining this subset of information 2782 and the resultant MAC. 2784 After sending the INIT ACK with the State Cookie parameter, the 2785 sender SHOULD delete the TCB and any other local resource related to 2786 the new association, so as to prevent resource attacks. 2788 The hashing method used to generate the MAC is strictly a private 2789 matter for the receiver of the INIT chunk. The use of a MAC is 2790 mandatory to prevent denial-of-service attacks. The secret key 2791 SHOULD be random ([RFC4086] provides some information on randomness 2792 guidelines); it SHOULD be changed reasonably frequently, and the 2793 timestamp in the State Cookie MAY be used to determine which key is 2794 used to verify the MAC. 2796 An implementation SHOULD make the cookie as small as possible to 2797 ensure interoperability. 2799 5.1.4. State Cookie Processing 2801 When an endpoint (in the COOKIE-WAIT state) receives an INIT ACK 2802 chunk with a State Cookie parameter, it MUST immediately send a 2803 COOKIE ECHO chunk to its peer with the received State Cookie. The 2804 sender MAY also add any pending DATA chunks to the packet after the 2805 COOKIE ECHO chunk. 2807 The endpoint MUST also start the T1-cookie timer after sending out 2808 the COOKIE ECHO chunk. If the timer expires, the endpoint MUST 2809 retransmit the COOKIE ECHO chunk and restart the T1-cookie timer. 2810 This is repeated until either a COOKIE ACK is received or 2811 'Max.Init.Retransmits' (see Section 16) is reached causing the peer 2812 endpoint to be marked unreachable (and thus the association enters 2813 the CLOSED state). 2815 5.1.5. State Cookie Authentication 2817 When an endpoint receives a COOKIE ECHO chunk from another endpoint 2818 with which it has no association, it takes the following actions: 2820 1) Compute a MAC using the TCB data carried in the State Cookie and 2821 the secret key (note the timestamp in the State Cookie MAY be 2822 used to determine which secret key to use). [RFC2104] can be 2823 used as a guideline for generating the MAC, 2825 2) Authenticate the State Cookie as one that it previously generated 2826 by comparing the computed MAC against the one carried in the 2827 State Cookie. If this comparison fails, the SCTP packet, 2828 including the COOKIE ECHO and any DATA chunks, SHOULD be silently 2829 discarded, 2831 3) Compare the port numbers and the Verification Tag contained 2832 within the COOKIE ECHO chunk to the actual port numbers and the 2833 Verification Tag within the SCTP common header of the received 2834 packet. If these values do not match, the packet MUST be 2835 silently discarded. 2837 4) Compare the creation timestamp in the State Cookie to the current 2838 local time. If the elapsed time is longer than the lifespan 2839 carried in the State Cookie, then the packet, including the 2840 COOKIE ECHO and any attached DATA chunks, SHOULD be discarded, 2841 and the endpoint MUST transmit an ERROR chunk with a "Stale 2842 Cookie" error cause to the peer endpoint. 2844 5) If the State Cookie is valid, create an association to the sender 2845 of the COOKIE ECHO chunk with the information in the TCB data 2846 carried in the COOKIE ECHO and enter the ESTABLISHED state. 2848 6) Send a COOKIE ACK chunk to the peer acknowledging receipt of the 2849 COOKIE ECHO. The COOKIE ACK MAY be bundled with an outbound DATA 2850 chunk or SACK chunk; however, the COOKIE ACK MUST be the first 2851 chunk in the SCTP packet. 2853 7) Immediately acknowledge any DATA chunk bundled with the COOKIE 2854 ECHO with a SACK (subsequent DATA chunk acknowledgement SHOULD 2855 follow the rules defined in Section 6.2). As mentioned in step 2856 6, if the SACK is bundled with the COOKIE ACK, the COOKIE ACK 2857 MUST appear first in the SCTP packet. 2859 If a COOKIE ECHO is received from an endpoint with which the receiver 2860 of the COOKIE ECHO has an existing association, the procedures in 2861 Section 5.2 SHOULD be followed. 2863 5.1.6. An Example of Normal Association Establishment 2865 In the following example, "A" initiates the association and then 2866 sends a user message to "Z", then "Z" sends two user messages to "A" 2867 later (assuming no bundling or fragmentation occurs): 2869 Endpoint A Endpoint Z 2870 {app sets association with Z} 2871 (build TCB) 2872 INIT [I-Tag=Tag_A 2873 & other info] ------\ 2874 (Start T1-init timer) \ 2875 (Enter COOKIE-WAIT state) \---> (compose temp TCB and Cookie_Z) 2876 /-- INIT ACK [Veri Tag=Tag_A, 2877 / I-Tag=Tag_Z, 2878 (Cancel T1-init timer) <------/ Cookie_Z, & other info] 2879 (destroy temp TCB) 2880 COOKIE ECHO [Cookie_Z] ------\ 2881 (Start T1-cookie timer) \ 2882 (Enter COOKIE-ECHOED state) \---> (build TCB, enter ESTABLISHED 2883 state) 2884 /---- COOKIE ACK 2885 / 2886 (Cancel T1-cookie timer, <---/ 2887 enter ESTABLISHED state) 2888 {app sends 1st user data; strm 0} 2889 DATA [TSN=init TSN_A 2890 Strm=0,Seq=0 & user data]--\ 2891 (Start T3-rtx timer) \ 2892 \-> 2893 /----- SACK [TSN Ack=init TSN_A, 2894 Block=0] 2895 (Cancel T3-rtx timer) <------/ 2896 ... 2897 {app sends 2 messages;strm 0} 2898 /---- DATA 2899 / [TSN=init TSN_Z, 2900 <--/ Strm=0,Seq=0 & user data 1] 2901 SACK [TSN Ack=init TSN_Z, /---- DATA 2902 Block=0] --------\ / [TSN=init TSN_Z +1, 2903 \/ Strm=0,Seq=1 & user data 2] 2904 <------/\ 2905 \ 2906 \------> 2908 Figure 4: INITIATION Example 2910 If the T1-init timer expires at "A" after the INIT or COOKIE ECHO 2911 chunks are sent, the same INIT or COOKIE ECHO chunk with the same 2912 Initiate Tag (i.e., Tag_A) or State Cookie is retransmitted and the 2913 timer restarted. This is repeated 'Max.Init.Retransmits' times 2914 before "A" considers "Z" unreachable and reports the failure to its 2915 upper layer (and thus the association enters the CLOSED state). 2917 When retransmitting the INIT, the endpoint MUST follow the rules 2918 defined in Section 6.3 to determine the proper timer value. 2920 5.2. Handle Duplicate or Unexpected INIT, INIT ACK, COOKIE ECHO, and 2921 COOKIE ACK 2923 During the life time of an association (in one of the possible 2924 states), an endpoint can receive from its peer endpoint one of the 2925 setup chunks (INIT, INIT ACK, COOKIE ECHO, and COOKIE ACK). The 2926 receiver treats such a setup chunk as a duplicate and process it as 2927 described in this section. 2929 Note: An endpoint will not receive the chunk unless the chunk was 2930 sent to an SCTP transport address and is from an SCTP transport 2931 address associated with this endpoint. Therefore, the endpoint 2932 processes such a chunk as part of its current association. 2934 The following scenarios can cause duplicated or unexpected chunks: 2936 A) The peer has crashed without being detected, restarted itself, 2937 and sent out a new INIT chunk trying to restore the association, 2939 B) Both sides are trying to initialize the association at about the 2940 same time, 2942 C) The chunk is from a stale packet that was used to establish the 2943 present association or a past association that is no longer in 2944 existence, 2946 D) The chunk is a false packet generated by an attacker, or 2948 E) The peer never received the COOKIE ACK and is retransmitting its 2949 COOKIE ECHO. 2951 The rules in the following sections are applied in order to identify 2952 and correctly handle these cases. 2954 5.2.1. INIT Received in COOKIE-WAIT or COOKIE-ECHOED State (Item B) 2956 This usually indicates an initialization collision, i.e., each 2957 endpoint is attempting, at about the same time, to establish an 2958 association with the other endpoint. 2960 Upon receipt of an INIT in the COOKIE-WAIT state, an endpoint MUST 2961 respond with an INIT ACK using the same parameters it sent in its 2962 original INIT chunk (including its Initiate Tag, unchanged). When 2963 responding, the following rules MUST be applied: 2965 1) The INIT ACK MUST only be sent to an address passed by the upper 2966 layer in the request to initialize the association. 2968 2) The INIT ACK MUST only be sent to an address reported in the 2969 incoming INIT. 2971 3) The INIT ACK SHOULD be sent to the source address of the received 2972 INIT. 2974 Upon receipt of an INIT in the COOKIE-ECHOED state, an endpoint MUST 2975 respond with an INIT ACK using the same parameters it sent in its 2976 original INIT chunk (including its Initiate Tag, unchanged), provided 2977 that no NEW address has been added to the forming association. If 2978 the INIT message indicates that a new address has been added to the 2979 association, then the entire INIT MUST be discarded, and SHOULD NOT 2980 do any changes to the existing association. An ABORT SHOULD be sent 2981 in response that MAY include the error 'Restart of an association 2982 with new addresses'. The error SHOULD list the addresses that were 2983 added to the restarting association. 2985 When responding in either state (COOKIE-WAIT or COOKIE-ECHOED) with 2986 an INIT ACK, the original parameters are combined with those from the 2987 newly received INIT chunk. The endpoint MUST also generate a State 2988 Cookie with the INIT ACK. The endpoint uses the parameters sent in 2989 its INIT to calculate the State Cookie. 2991 After that, the endpoint MUST NOT change its state, the T1-init timer 2992 MUST be left running, and the corresponding TCB MUST NOT be 2993 destroyed. The normal procedures for handling State Cookies when a 2994 TCB exists will resolve the duplicate INITs to a single association. 2996 For an endpoint that is in the COOKIE-ECHOED state, it MUST populate 2997 its Tie-Tags within both the association TCB and inside the State 2998 Cookie (see Section 5.2.2 for a description of the Tie-Tags). 3000 5.2.2. Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, 3001 COOKIE-WAIT, and SHUTDOWN-ACK-SENT 3003 Unless otherwise stated, upon receipt of an unexpected INIT for this 3004 association, the endpoint MUST generate an INIT ACK with a State 3005 Cookie. Before responding, the endpoint MUST check to see if the 3006 unexpected INIT adds new addresses to the association. If new 3007 addresses are added to the association, the endpoint MUST respond 3008 with an ABORT, copying the 'Initiate Tag' of the unexpected INIT into 3009 the 'Verification Tag' of the outbound packet carrying the ABORT. In 3010 the ABORT response, the cause of error MAY be set to 'restart of an 3011 association with new addresses'. The error SHOULD list the addresses 3012 that were added to the restarting association. If no new addresses 3013 are added, when responding to the INIT in the outbound INIT ACK, the 3014 endpoint MUST copy its current Tie-Tags to a reserved place within 3015 the State Cookie and the association's TCB. We refer to these 3016 locations inside the cookie as the Peer's-Tie-Tag and the Local-Tie- 3017 Tag. We will refer to the copy within an association's TCB as the 3018 Local Tag and Peer's Tag. The outbound SCTP packet containing this 3019 INIT ACK MUST carry a Verification Tag value equal to the Initiate 3020 Tag found in the unexpected INIT. And the INIT ACK MUST contain a 3021 new Initiate Tag (randomly generated; see Section 5.3.1). Other 3022 parameters for the endpoint SHOULD be copied from the existing 3023 parameters of the association (e.g., number of outbound streams) into 3024 the INIT ACK and cookie. 3026 After sending out the INIT ACK or ABORT, the endpoint MUST take no 3027 further actions; i.e., the existing association, including its 3028 current state, and the corresponding TCB MUST NOT be changed. 3030 Only when a TCB exists and the association is not in a COOKIE-WAIT or 3031 SHUTDOWN-ACK-SENT state are the Tie-Tags populated with a value other 3032 than 0. For a normal association INIT (i.e., the endpoint is in the 3033 CLOSED state), the Tie-Tags MUST be set to 0 (indicating that no 3034 previous TCB existed). 3036 5.2.3. Unexpected INIT ACK 3038 If an INIT ACK is received by an endpoint in any state other than the 3039 COOKIE-WAIT state, the endpoint SHOULD discard the INIT ACK chunk. 3040 An unexpected INIT ACK usually indicates the processing of an old or 3041 duplicated INIT chunk. 3043 5.2.4. Handle a COOKIE ECHO when a TCB Exists 3045 When a COOKIE ECHO chunk is received by an endpoint in any state for 3046 an existing association (i.e., not in the CLOSED state) the following 3047 rules are applied: 3049 1) Compute a MAC as described in step 1 of Section 5.1.5, 3051 2) Authenticate the State Cookie as described in step 2 of 3052 Section 5.1.5 (this is case C or D above). 3054 3) Compare the timestamp in the State Cookie to the current time. 3055 If the State Cookie is older than the lifespan carried in the 3056 State Cookie and the Verification Tags contained in the State 3057 Cookie do not match the current association's Verification Tags, 3058 the packet, including the COOKIE ECHO and any DATA chunks, SHOULD 3059 be discarded. The endpoint also MUST transmit an ERROR chunk 3060 with a "Stale Cookie" error cause to the peer endpoint (this is 3061 case C or D in Section 5.2). 3063 If both Verification Tags in the State Cookie match the 3064 Verification Tags of the current association, consider the State 3065 Cookie valid (this is case E in Section 5.2) even if the lifespan 3066 is exceeded. 3068 4) If the State Cookie proves to be valid, unpack the TCB into a 3069 temporary TCB. 3071 5) Refer to Table 12 to determine the correct action to be taken. 3073 +-----------+------------+---------------+----------------+--------+ 3074 | Local Tag | Peer's Tag | Local-Tie-Tag | Peer's-Tie-Tag | Action | 3075 +-----------+------------+---------------+----------------+--------+ 3076 | X | X | M | M | (A) | 3077 +-----------+------------+---------------+----------------+--------+ 3078 | M | X | A | A | (B) | 3079 +-----------+------------+---------------+----------------+--------+ 3080 | M | 0 | A | A | (B) | 3081 +-----------+------------+---------------+----------------+--------+ 3082 | X | M | 0 | 0 | (C) | 3083 +-----------+------------+---------------+----------------+--------+ 3084 | M | M | A | A | (D) | 3085 +-----------+------------+---------------+----------------+--------+ 3087 Table 12: Handling of a COOKIE ECHO when a TCB Exists 3089 Legend: 3091 X - Tag does not match the existing TCB. 3092 M - Tag matches the existing TCB. 3093 0 - No Tie-Tag in cookie (unknown). 3094 A - All cases, i.e., M, X, or 0. 3096 For any case not shown in Table 12, the cookie SHOULD be silently 3097 discarded. 3099 Action 3100 A) In this case, the peer might have restarted. When the endpoint 3101 recognizes this potential 'restart', the existing session is 3102 treated the same as if it received an ABORT followed by a new 3103 COOKIE ECHO with the following exceptions: 3105 * Any SCTP DATA chunks MAY be retained (this is an 3106 implementation-specific option). 3108 * A notification of RESTART SHOULD be sent to the ULP instead of 3109 a "COMMUNICATION LOST" notification. 3111 All the congestion control parameters (e.g., cwnd, ssthresh) 3112 related to this peer MUST be reset to their initial values (see 3113 Section 6.2.1). 3115 After this, the endpoint enters the ESTABLISHED state. 3117 If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes 3118 that the peer has restarted (Action A), it MUST NOT set up a new 3119 association but instead resend the SHUTDOWN ACK and send an ERROR 3120 chunk with a "Cookie Received While Shutting Down" error cause to 3121 its peer. 3123 B) In this case, both sides might be attempting to start an 3124 association at about the same time, but the peer endpoint started 3125 its INIT after responding to the local endpoint's INIT. Thus, it 3126 might have picked a new Verification Tag, not being aware of the 3127 previous tag it had sent this endpoint. The endpoint SHOULD stay 3128 in or enter the ESTABLISHED state, but it MUST update its peer's 3129 Verification Tag from the State Cookie, stop any init or cookie 3130 timers that might be running, and send a COOKIE ACK. 3132 C) In this case, the local endpoint's cookie has arrived late. 3133 Before it arrived, the local endpoint sent an INIT and received 3134 an INIT ACK and finally sent a COOKIE ECHO with the peer's same 3135 tag but a new tag of its own. The cookie SHOULD be silently 3136 discarded. The endpoint SHOULD NOT change states and SHOULD 3137 leave any timers running. 3139 D) When both local and remote tags match, the endpoint SHOULD enter 3140 the ESTABLISHED state, if it is in the COOKIE-ECHOED state. It 3141 SHOULD stop any cookie timer that is running and send a COOKIE 3142 ACK. 3144 Note: The "peer's Verification Tag" is the tag received in the 3145 Initiate Tag field of the INIT or INIT ACK chunk. 3147 5.2.4.1. An Example of a Association Restart 3149 In the following example, "A" initiates the association after a 3150 restart has occurred. Endpoint "Z" had no knowledge of the restart 3151 until the exchange (i.e., Heartbeats had not yet detected the failure 3152 of "A") (assuming no bundling or fragmentation occurs): 3154 Endpoint A Endpoint Z 3155 <-------------- Association is established----------------------> 3156 Tag=Tag_A Tag=Tag_Z 3157 <---------------------------------------------------------------> 3158 {A crashes and restarts} 3159 {app sets up a association with Z} 3160 (build TCB) 3161 INIT [I-Tag=Tag_A' 3162 & other info] --------\ 3163 (Start T1-init timer) \ 3164 (Enter COOKIE-WAIT state) \---> (find an existing TCB 3165 compose temp TCB and Cookie_Z 3166 with Tie-Tags to previous 3167 association) 3168 /--- INIT ACK [Veri Tag=Tag_A', 3169 / I-Tag=Tag_Z', 3170 (Cancel T1-init timer) <------/ Cookie_Z[TieTags= 3171 Tag_A,Tag_Z 3172 & other info] 3173 (destroy temp TCB,leave original 3174 in place) 3175 COOKIE ECHO [Veri=Tag_Z', 3176 Cookie_Z 3177 Tie=Tag_A, 3178 Tag_Z]----------\ 3179 (Start T1-init timer) \ 3180 (Enter COOKIE-ECHOED state) \---> (Find existing association, 3181 Tie-Tags match old tags, 3182 Tags do not match, i.e., 3183 case X X M M above, 3184 Announce Restart to ULP 3185 and reset association). 3186 /---- COOKIE ACK 3187 (Cancel T1-init timer, <------/ 3188 Enter ESTABLISHED state) 3189 {app sends 1st user data; strm 0} 3190 DATA [TSN=initial TSN_A 3191 Strm=0,Seq=0 & user data]--\ 3192 (Start T3-rtx timer) \ 3193 \-> 3194 /--- SACK [TSN Ack=init TSN_A,Block=0] 3195 (Cancel T3-rtx timer) <------/ 3197 Figure 5: A Restart Example 3199 5.2.5. Handle Duplicate COOKIE ACK 3201 At any state other than COOKIE-ECHOED, an endpoint SHOULD silently 3202 discard a received COOKIE ACK chunk. 3204 5.2.6. Handle Stale COOKIE Error 3206 Receipt of an ERROR chunk with a "Stale Cookie" error cause indicates 3207 one of a number of possible events: 3209 A) The association failed to completely setup before the State 3210 Cookie issued by the sender was processed. 3212 B) An old State Cookie was processed after setup completed. 3214 C) An old State Cookie is received from someone that the receiver is 3215 not interested in having an association with and the ABORT chunk 3216 was lost. 3218 When processing an ERROR chunk with a "Stale Cookie" error cause an 3219 endpoint SHOULD first examine if an association is in the process of 3220 being set up, i.e., the association is in the COOKIE-ECHOED state. 3221 In all cases, if the association is not in the COOKIE-ECHOED state, 3222 the ERROR chunk SHOULD be silently discarded. 3224 If the association is in the COOKIE-ECHOED state, the endpoint MAY 3225 elect one of the following three alternatives. 3227 1) Send a new INIT chunk to the endpoint to generate a new State 3228 Cookie and reattempt the setup procedure. 3230 2) Discard the TCB and report to the upper layer the inability to 3231 set up the association. 3233 3) Send a new INIT chunk to the endpoint, adding a Cookie 3234 Preservative parameter requesting an extension to the life time 3235 of the State Cookie. When calculating the time extension, an 3236 implementation SHOULD use the RTT information measured based on 3237 the previous COOKIE ECHO / ERROR exchange, and SHOULD add no more 3238 than 1 second beyond the measured RTT, due to long State Cookie 3239 life times making the endpoint more subject to a replay attack. 3241 5.3. Other Initialization Issues 3242 5.3.1. Selection of Tag Value 3244 Initiate Tag values SHOULD be selected from the range of 1 to 2**32 - 3245 1. It is very important that the Initiate Tag value be randomized to 3246 help protect against "man in the middle" and "sequence number" 3247 attacks. The methods described in [RFC4086] can be used for the 3248 Initiate Tag randomization. Careful selection of Initiate Tags is 3249 also necessary to prevent old duplicate packets from previous 3250 associations being mistakenly processed as belonging to the current 3251 association. 3253 Moreover, the Verification Tag value used by either endpoint in a 3254 given association MUST NOT change during the life time of an 3255 association. A new Verification Tag value MUST be used each time the 3256 endpoint tears down and then reestablishes an association to the same 3257 peer. 3259 5.4. Path Verification 3261 During association establishment, the two peers exchange a list of 3262 addresses. In the predominant case, these lists accurately represent 3263 the addresses owned by each peer. However, it is possible that a 3264 misbehaving peer might supply addresses that it does not own. To 3265 prevent this, the following rules are applied to all addresses of the 3266 new association: 3268 1) Any addresses passed to the sender of the INIT by its upper layer 3269 in the request to initialize an association are automatically 3270 considered to be CONFIRMED. 3272 2) For the receiver of the COOKIE ECHO, the only CONFIRMED address 3273 is the address to which the INIT ACK was sent. 3275 3) All other addresses not covered by rules 1 and 2 are considered 3276 UNCONFIRMED and are subject to probing for verification. 3278 To probe an address for verification, an endpoint will send 3279 HEARTBEATs including a 64-bit random nonce and a path indicator (to 3280 identify the address that the HEARTBEAT is sent to) within the 3281 HEARTBEAT parameter. 3283 Upon receipt of the HEARTBEAT ACK, a verification is made that the 3284 nonce included in the HEARTBEAT parameter is the one sent to the 3285 address indicated inside the HEARTBEAT parameter. When this match 3286 occurs, the address that the original HEARTBEAT was sent to is now 3287 considered CONFIRMED and available for normal data transfer. 3289 These probing procedures are started when an association moves to the 3290 ESTABLISHED state and are ended when all paths are confirmed. 3292 In each RTO, a probe MAY be sent on an active UNCONFIRMED path in an 3293 attempt to move it to the CONFIRMED state. If during this probing 3294 the path becomes inactive, this rate is lowered to the normal 3295 HEARTBEAT rate. At the expiration of the RTO timer, the error 3296 counter of any path that was probed but not CONFIRMED is incremented 3297 by one and subjected to path failure detection, as defined in 3298 Section 8.2. When probing UNCONFIRMED addresses, however, the 3299 association overall error count is not incremented. 3301 The number of HEARTBEATS sent at each RTO SHOULD be limited by the 3302 'HB.Max.Burst' parameter. It is an implementation decision as to how 3303 to distribute HEARTBEATS to the peer's addresses for path 3304 verification. 3306 Whenever a path is confirmed, an indication MAY be given to the upper 3307 layer. 3309 An endpoint MUST NOT send any chunks to an UNCONFIRMED address, with 3310 the following exceptions: 3312 * A HEARTBEAT including a nonce MAY be sent to an UNCONFIRMED 3313 address. 3315 * A HEARTBEAT ACK MAY be sent to an UNCONFIRMED address. 3317 * A COOKIE ACK MAY be sent to an UNCONFIRMED address, but it MUST be 3318 bundled with a HEARTBEAT including a nonce. An implementation 3319 that does not support bundling MUST NOT send a COOKIE ACK to an 3320 UNCONFIRMED address. 3322 * A COOKIE ECHO MAY be sent to an UNCONFIRMED address, but it MUST 3323 be bundled with a HEARTBEAT including a nonce, and the size of the 3324 SCTP packet MUST NOT exceed the PMTU. If the implementation does 3325 not support bundling or if the bundled COOKIE ECHO plus HEARTBEAT 3326 (including nonce) would result in an SCTP packet larger than the 3327 PMTU, then the implementation MUST NOT send a COOKIE ECHO to an 3328 UNCONFIRMED address. 3330 6. User Data Transfer 3332 Data transmission MUST only happen in the ESTABLISHED, SHUTDOWN- 3333 PENDING, and SHUTDOWN-RECEIVED states. The only exception to this is 3334 that DATA chunks are allowed to be bundled with an outbound COOKIE 3335 ECHO chunk when in the COOKIE-WAIT state. 3337 DATA chunks MUST only be received according to the rules below in 3338 ESTABLISHED, SHUTDOWN-PENDING, and SHUTDOWN-SENT. A DATA chunk 3339 received in CLOSED is out of the blue and SHOULD be handled per 3340 Section 8.4. A DATA chunk received in any other state SHOULD be 3341 discarded. 3343 A SACK MUST be processed in ESTABLISHED, SHUTDOWN-PENDING, and 3344 SHUTDOWN-RECEIVED. An incoming SACK MAY be processed in COOKIE- 3345 ECHOED. A SACK in the CLOSED state is out of the blue and SHOULD be 3346 processed according to the rules in Section 8.4. A SACK chunk 3347 received in any other state SHOULD be discarded. 3349 An SCTP receiver MUST be able to receive a minimum of 1500 bytes in 3350 one SCTP packet. This means that an SCTP endpoint MUST NOT indicate 3351 less than 1500 bytes in its initial a_rwnd sent in the INIT or INIT 3352 ACK. 3354 For transmission efficiency, SCTP defines mechanisms for bundling of 3355 small user messages and fragmentation of large user messages. The 3356 following diagram depicts the flow of user messages through SCTP. 3358 In this section, the term "data sender" refers to the endpoint that 3359 transmits a DATA chunk and the term "data receiver" refers to the 3360 endpoint that receives a DATA chunk. A data receiver will transmit 3361 SACK chunks. 3363 +--------------------------+ 3364 | User Messages | 3365 +--------------------------+ 3366 SCTP user ^ | 3367 ==================|==|======================================= 3368 | v (1) 3369 +------------------+ +--------------------+ 3370 | SCTP DATA Chunks | |SCTP Control Chunks | 3371 +------------------+ +--------------------+ 3372 ^ | ^ | 3373 | v (2) | v (2) 3374 +--------------------------+ 3375 | SCTP packets | 3376 +--------------------------+ 3377 SCTP ^ | 3378 ===========================|==|=========================== 3379 | v 3380 Connectionless Packet Transfer Service (e.g., IP) 3382 Figure 6: Illustration of User Data Transfer 3384 The following applies: 3386 1) When converting user messages into DATA chunks, an endpoint MUST 3387 fragment user messages into multiple DATA chunks. The size of 3388 each DATA chunk SHOULD be smaller than or equal to the 3389 Association Maximum DATA Chunk Size (AMDCS). The data receiver 3390 will normally reassemble the fragmented message from DATA chunks 3391 before delivery to the user (see Section 6.9 for details). 3393 2) Multiple DATA and control chunks MAY be bundled by the sender 3394 into a single SCTP packet for transmission, as long as the final 3395 size of the packet does not exceed the current PMTU. The 3396 receiver will unbundle the packet back into the original chunks. 3397 Control chunks MUST come before DATA chunks in the packet. 3399 The fragmentation and bundling mechanisms, as detailed in Section 6.9 3400 and Section 6.10, are OPTIONAL to implement by the data sender, but 3401 they MUST be implemented by the data receiver, i.e., an endpoint MUST 3402 properly receive and process bundled or fragmented data. 3404 6.1. Transmission of DATA Chunks 3406 This document is specified as if there is a single retransmission 3407 timer per destination transport address, but implementations MAY have 3408 a retransmission timer for each DATA chunk. 3410 The following general rules MUST be applied by the data sender for 3411 transmission and/or retransmission of outbound DATA chunks: 3413 A) At any given time, the data sender MUST NOT transmit new data to 3414 any destination transport address if its peer's rwnd indicates 3415 that the peer has no buffer space (i.e., rwnd is smaller than the 3416 size of the next DATA chunk; see Section 6.2.1), except stated 3417 otherwise. 3419 When the receiver has no buffer space, a probe being sent is 3420 called a zero window probe. A zero window probe SHOULD only be 3421 sent when all outstanding DATA chunks have been cumulatively 3422 acknowledged and no DATA chunks are in flight. Zero window 3423 probing MUST be supported. 3425 If the sender continues to receive SACKs from the peer while 3426 doing zero window probing, the unacknowledged window probes 3427 SHOULD NOT increment the error counter for the association or any 3428 destination transport address. This is because the receiver 3429 could keep its window closed for an indefinite time. Section 6.2 3430 describes the receiver behavior when it advertises a zero window. 3431 The sender SHOULD send the first zero window probe after 1 RTO 3432 when it detects that the receiver has closed its window and 3433 SHOULD increase the probe interval exponentially afterwards. 3435 Also note that the cwnd SHOULD be adjusted according to 3436 Section 7.2.1. Zero window probing does not affect the 3437 calculation of cwnd. 3439 The sender MUST also have an algorithm for sending new DATA 3440 chunks to avoid silly window syndrome (SWS) as described in 3441 [RFC1122]. The algorithm can be similar to the one described in 3442 Section 4.2.3.4 of [RFC1122]. 3444 However, regardless of the value of rwnd (including if it is 0), 3445 the data sender can always have one DATA chunk in flight to the 3446 receiver if allowed by cwnd (see rule B below). This rule allows 3447 the sender to probe for a change in rwnd that the sender missed 3448 due to the SACK having been lost in transit from the data 3449 receiver to the data sender. 3451 B) At any given time, the sender MUST NOT transmit new data to a 3452 given transport address if it has cwnd + (PMDCS - 1) or more 3453 bytes of data outstanding to that transport address. If data is 3454 available, the sender SHOULD exceed cwnd by up to (PMDCS - 1) 3455 bytes on a new data transmission if the flightsize does not 3456 currently reach cwnd. The breach of cwnd MUST constitute one 3457 packet only. 3459 C) When the time comes for the sender to transmit, before sending 3460 new DATA chunks, the sender MUST first transmit any DATA chunks 3461 that are marked for retransmission (limited by the current cwnd). 3463 D) When the time comes for the sender to transmit new DATA chunks, 3464 the protocol parameter 'Max.Burst' SHOULD be used to limit the 3465 number of packets sent. The limit MAY be applied by adjusting 3466 cwnd temporarily, as follows: 3468 if ((flightsize + Max.Burst * PMDCS) < cwnd) 3469 cwnd = flightsize + Max.Burst * PMDCS; 3471 Or, it MAY be applied by strictly limiting the number of packets 3472 emitted by the output routine. When calculating the number of 3473 packets to transmit, and particularly when using the formula 3474 above, cwnd SHOULD NOT be changed permanently. 3476 E) Then, the sender can send out as many new DATA chunks as rule A 3477 and rule B allow. 3479 Multiple DATA chunks committed for transmission MAY be bundled in a 3480 single packet. Furthermore, DATA chunks being retransmitted MAY be 3481 bundled with new DATA chunks, as long as the resulting packet size 3482 does not exceed the PMTU. A ULP can request that no bundling is 3483 performed, but this only turns off any delays that an SCTP 3484 implementation might be using to increase bundling efficiency. It 3485 does not in itself stop all bundling from occurring (i.e., in case of 3486 congestion or retransmission). 3488 Before an endpoint transmits a DATA chunk, if any received DATA 3489 chunks have not been acknowledged (e.g., due to delayed ack), the 3490 sender SHOULD create a SACK and bundle it with the outbound DATA 3491 chunk, as long as the size of the final SCTP packet does not exceed 3492 the current PMTU. See Section 6.2. 3494 When the window is full (i.e., transmission is disallowed by rule A 3495 and/or rule B), the sender MAY still accept send requests from its 3496 upper layer, but MUST transmit no more DATA chunks until some or all 3497 of the outstanding DATA chunks are acknowledged and transmission is 3498 allowed by rule A and rule B again. 3500 Whenever a transmission or retransmission is made to any address, if 3501 the T3-rtx timer of that address is not currently running, the sender 3502 MUST start that timer. If the timer for that address is already 3503 running, the sender MUST restart the timer if the earliest (i.e., 3504 lowest TSN) outstanding DATA chunk sent to that address is being 3505 retransmitted. Otherwise, the data sender MUST NOT restart the 3506 timer. 3508 When starting or restarting the T3-rtx timer, the timer value SHOULD 3509 be adjusted according to the timer rules defined in Section 6.3.2 and 3510 Section 6.3.3. 3512 The data sender SHOULD NOT use a TSN that is more than 2**31 - 1 3513 above the beginning TSN of the current send window. 3515 For each stream, the data sender SHOULD NOT have more than 2**16 - 1 3516 ordered user messages in the current send window. 3518 Whenever the sender of a DATA chunk can benefit from the 3519 corresponding SACK chunk being sent back without delay, the sender 3520 MAY set the I bit in the DATA chunk header. Please note that why the 3521 sender has set the I bit is irrelevant to the receiver. 3523 Reasons for setting the I bit include, but are not limited to, the 3524 following (see Section 4 of [RFC7053] for a discussion of the 3525 benefits): 3527 * The application requests that the I bit of the last DATA chunk of 3528 a user message be set when providing the user message to the SCTP 3529 implementation (see Section 11.1). 3531 * The sender is in the SHUTDOWN-PENDING state. 3533 * The sending of a DATA chunk fills the congestion or receiver 3534 window. 3536 6.2. Acknowledgement on Reception of DATA Chunks 3538 The SCTP endpoint MUST always acknowledge the reception of each valid 3539 DATA chunk when the DATA chunk received is inside its receive window. 3541 When the receiver's advertised window is 0, the receiver MUST drop 3542 any new incoming DATA chunk with a TSN larger than the largest TSN 3543 received so far. If the new incoming DATA chunk holds a TSN value 3544 less than the largest TSN received so far, then the receiver SHOULD 3545 drop the largest TSN held for reordering and accept the new incoming 3546 DATA chunk. In either case, if such a DATA chunk is dropped, the 3547 receiver MUST immediately send back a SACK with the current receive 3548 window showing only DATA chunks received and accepted so far. The 3549 dropped DATA chunk(s) MUST NOT be included in the SACK, as they were 3550 not accepted. The receiver MUST also have an algorithm for 3551 advertising its receive window to avoid receiver silly window 3552 syndrome (SWS), as described in [RFC1122]. The algorithm can be 3553 similar to the one described in Section 4.2.3.3 of [RFC1122]. 3555 The guidelines on delayed acknowledgement algorithm specified in 3556 Section 4.2 of [RFC5681] SHOULD be followed. Specifically, an 3557 acknowledgement SHOULD be generated for at least every second packet 3558 (not every second DATA chunk) received, and SHOULD be generated 3559 within 200 ms of the arrival of any unacknowledged DATA chunk. In 3560 some situations, it might be beneficial for an SCTP transmitter to be 3561 more conservative than the algorithms detailed in this document 3562 allow. However, an SCTP transmitter MUST NOT be more aggressive than 3563 the following algorithms allow. 3565 An SCTP receiver MUST NOT generate more than one SACK for every 3566 incoming packet, other than to update the offered window as the 3567 receiving application consumes new data. When the window opens up, 3568 an SCTP receiver SHOULD send additional SACK chunks to update the 3569 window even if no new data is received. The receiver MUST avoid 3570 sending a large number of window updates -- in particular, large 3571 bursts of them. One way to achieve this is to send a window update 3572 only if the window can be increased by at least a quarter of the 3573 receive buffer size of the association. 3575 IMPLEMENTATION NOTE: The maximum delay for generating an 3576 acknowledgement MAY be configured by the SCTP administrator, either 3577 statically or dynamically, in order to meet the specific timing 3578 requirement of the protocol being carried. 3580 An implementation MUST NOT allow the maximum delay (protocol 3581 parameter 'SACK.Delay') to be configured to be more than 500 ms. In 3582 other words, an implementation MAY lower the value of 'SACK.Delay' 3583 below 500 ms but MUST NOT raise it above 500 ms. 3585 Acknowledgements MUST be sent in SACK chunks unless shutdown was 3586 requested by the ULP, in which case an endpoint MAY send an 3587 acknowledgement in the SHUTDOWN chunk. A SACK chunk can acknowledge 3588 the reception of multiple DATA chunks. See Section 3.3.4 for SACK 3589 chunk format. In particular, the SCTP endpoint MUST fill in the 3590 Cumulative TSN Ack field to indicate the latest sequential TSN (of a 3591 valid DATA chunk) it has received. Any received DATA chunks with TSN 3592 greater than the value in the Cumulative TSN Ack field are reported 3593 in the Gap Ack Block fields. The SCTP endpoint MUST report as many 3594 Gap Ack Blocks as can fit in a single SACK chunk such that the size 3595 of the SCTP packet does not exceed the current PMTU. 3597 The SHUTDOWN chunk does not contain Gap Ack Block fields. Therefore, 3598 the endpoint SHOULD use a SACK instead of the SHUTDOWN chunk to 3599 acknowledge DATA chunks received out of order. 3601 Upon receipt of an SCTP packet containing a DATA chunk with the I bit 3602 set, the receiver SHOULD NOT delay the sending of the corresponding 3603 SACK chunk, i.e., the receiver SHOULD immediately respond with the 3604 corresponding SACK chunk. 3606 When a packet arrives with duplicate DATA chunk(s) and with no new 3607 DATA chunk(s), the endpoint MUST immediately send a SACK with no 3608 delay. If a packet arrives with duplicate DATA chunk(s) bundled with 3609 new DATA chunks, the endpoint MAY immediately send a SACK. Normally, 3610 receipt of duplicate DATA chunks will occur when the original SACK 3611 chunk was lost and the peer's RTO has expired. The duplicate TSN 3612 number(s) SHOULD be reported in the SACK as duplicate. 3614 When an endpoint receives a SACK, it MAY use the duplicate TSN 3615 information to determine if SACK loss is occurring. Further use of 3616 this data is for future study. 3618 The data receiver is responsible for maintaining its receive buffers. 3619 The data receiver SHOULD notify the data sender in a timely manner of 3620 changes in its ability to receive data. How an implementation 3621 manages its receive buffers is dependent on many factors (e.g., 3622 operating system, memory management system, amount of memory, etc.). 3623 However, the data sender strategy defined in Section 6.2.1 is based 3624 on the assumption of receiver operation similar to the following: 3626 A) At initialization of the association, the endpoint tells the peer 3627 how much receive buffer space it has allocated to the association 3628 in the INIT or INIT ACK. The endpoint sets a_rwnd to this value. 3630 B) As DATA chunks are received and buffered, decrement a_rwnd by the 3631 number of bytes received and buffered. This is, in effect, 3632 closing rwnd at the data sender and restricting the amount of 3633 data it can transmit. 3635 C) As DATA chunks are delivered to the ULP and released from the 3636 receive buffers, increment a_rwnd by the number of bytes 3637 delivered to the upper layer. This is, in effect, opening up 3638 rwnd on the data sender and allowing it to send more data. The 3639 data receiver SHOULD NOT increment a_rwnd unless it has released 3640 bytes from its receive buffer. For example, if the receiver is 3641 holding fragmented DATA chunks in a reassembly queue, it SHOULD 3642 NOT increment a_rwnd. 3644 D) When sending a SACK, the data receiver SHOULD place the current 3645 value of a_rwnd into the a_rwnd field. The data receiver SHOULD 3646 take into account that the data sender will not retransmit DATA 3647 chunks that are acked via the Cumulative TSN Ack (i.e., will drop 3648 from its retransmit queue). 3650 Under certain circumstances, the data receiver MAY drop DATA chunks 3651 that it has received but has not released from its receive buffers 3652 (i.e., delivered to the ULP). These DATA chunks might have been 3653 acked in Gap Ack Blocks. For example, the data receiver might be 3654 holding data in its receive buffers while reassembling a fragmented 3655 user message from its peer when it runs out of receive buffer space. 3656 It MAY drop these DATA chunks even though it has acknowledged them in 3657 Gap Ack Blocks. If a data receiver drops DATA chunks, it MUST NOT 3658 include them in Gap Ack Blocks in subsequent SACKs until they are 3659 received again via retransmission. In addition, the endpoint SHOULD 3660 take into account the dropped data when calculating its a_rwnd. 3662 An endpoint SHOULD NOT revoke a SACK and discard data. Only in 3663 extreme circumstances might an endpoint use this procedure (such as 3664 out of buffer space). The data receiver SHOULD take into account 3665 that dropping data that has been acked in Gap Ack Blocks can result 3666 in suboptimal retransmission strategies in the data sender and thus 3667 in suboptimal performance. 3669 The following example illustrates the use of delayed 3670 acknowledgements: 3672 Endpoint A Endpoint Z 3674 {App sends 3 messages; strm 0} 3675 DATA [TSN=7,Strm=0,Seq=3] ------------> (ack delayed) 3676 (Start T3-rtx timer) 3678 DATA [TSN=8,Strm=0,Seq=4] ------------> (send ack) 3679 /------- SACK [TSN Ack=8,block=0] 3680 (cancel T3-rtx timer) <-----/ 3682 DATA [TSN=9,Strm=0,Seq=5] ------------> (ack delayed) 3683 (Start T3-rtx timer) 3684 ... 3685 {App sends 1 message; strm 1} 3686 (bundle SACK with DATA) 3687 /----- SACK [TSN Ack=9,block=0] \ 3688 / DATA [TSN=6,Strm=1,Seq=2] 3689 (cancel T3-rtx timer) <------/ (Start T3-rtx timer) 3691 (ack delayed) 3692 (send ack) 3693 SACK [TSN Ack=6,block=0] -------------> (cancel T3-rtx timer) 3695 Figure 7: Delayed Acknowledgement Example 3697 If an endpoint receives a DATA chunk with no user data (i.e., the 3698 Length field is set to 16), it MUST send an ABORT with a "No User 3699 Data" error cause. 3701 An endpoint SHOULD NOT send a DATA chunk with no user data part. 3702 This avoids the need to be able to return a zero-length user message 3703 in the API, especially in the socket API as specified in [RFC6458] 3704 for details. 3706 6.2.1. Processing a Received SACK 3708 Each SACK an endpoint receives contains an a_rwnd value. This value 3709 represents the amount of buffer space the data receiver, at the time 3710 of transmitting the SACK, has left of its total receive buffer space 3711 (as specified in the INIT/INIT ACK). Using a_rwnd, Cumulative TSN 3712 Ack, and Gap Ack Blocks, the data sender can develop a representation 3713 of the peer's receive buffer space. 3715 One of the problems the data sender takes into account when 3716 processing a SACK is that a SACK can be received out of order. That 3717 is, a SACK sent by the data receiver can pass an earlier SACK and be 3718 received first by the data sender. If a SACK is received out of 3719 order, the data sender can develop an incorrect view of the peer's 3720 receive buffer space. 3722 Since there is no explicit identifier that can be used to detect out- 3723 of-order SACKs, the data sender uses heuristics to determine if a 3724 SACK is new. 3726 An endpoint SHOULD use the following rules to calculate the rwnd, 3727 using the a_rwnd value, the Cumulative TSN Ack, and Gap Ack Blocks in 3728 a received SACK. 3730 A) At the establishment of the association, the endpoint initializes 3731 the rwnd to the Advertised Receiver Window Credit (a_rwnd) the 3732 peer specified in the INIT or INIT ACK. 3734 B) Any time a DATA chunk is transmitted (or retransmitted) to a 3735 peer, the endpoint subtracts the data size of the chunk from the 3736 rwnd of that peer. 3738 C) Any time a DATA chunk is marked for retransmission, either via 3739 T3-rtx timer expiration (Section 6.3.3) or via Fast Retransmit 3740 (Section 7.2.4), add the data size of those chunks to the rwnd. 3742 D) Any time a SACK arrives, the endpoint performs the following: 3744 i) If Cumulative TSN Ack is less than the Cumulative TSN Ack 3745 Point, then drop the SACK. Since Cumulative TSN Ack is 3746 monotonically increasing, a SACK whose Cumulative TSN Ack 3747 is less than the Cumulative TSN Ack Point indicates an out- 3748 of-order SACK. 3750 ii) Set rwnd equal to the newly received a_rwnd minus the 3751 number of bytes still outstanding after processing the 3752 Cumulative TSN Ack and the Gap Ack Blocks. 3754 iii) If the SACK is missing a TSN that was previously 3755 acknowledged via a Gap Ack Block (e.g., the data receiver 3756 reneged on the data), then consider the corresponding DATA 3757 that might be possibly missing: Count one miss indication 3758 towards Fast Retransmit as described in Section 7.2.4, and 3759 if no retransmit timer is running for the destination 3760 address to which the DATA chunk was originally transmitted, 3761 then T3-rtx is started for that destination address. 3763 iv) If the Cumulative TSN Ack matches or exceeds the Fast 3764 Recovery exitpoint (Section 7.2.4), Fast Recovery is 3765 exited. 3767 6.3. Management of Retransmission Timer 3769 An SCTP endpoint uses a retransmission timer T3-rtx to ensure data 3770 delivery in the absence of any feedback from its peer. The duration 3771 of this timer is referred to as RTO (retransmission timeout). 3773 When an endpoint's peer is multi-homed, the endpoint will calculate a 3774 separate RTO for each different destination transport address of its 3775 peer endpoint. 3777 The computation and management of RTO in SCTP follow closely how TCP 3778 manages its retransmission timer. To compute the current RTO, an 3779 endpoint maintains two state variables per destination transport 3780 address: SRTT (smoothed round-trip time) and RTTVAR (round-trip time 3781 variation). 3783 6.3.1. RTO Calculation 3785 The rules governing the computation of SRTT, RTTVAR, and RTO are as 3786 follows: 3788 C1) Until an RTT measurement has been made for a packet sent to the 3789 given destination transport address, set RTO to the protocol 3790 parameter 'RTO.Initial'. 3792 C2) When the first RTT measurement R is made, perform 3794 SRTT = R; 3795 RTTVAR = R/2; 3796 RTO = SRTT + 4 * RTTVAR; 3798 C3) When a new RTT measurement R' is made, perform: 3800 RTTVAR = (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'|; 3801 SRTT = (1 - RTO.Alpha) * SRTT + RTO.Alpha * R'; 3803 Note: The value of SRTT used in the update to RTTVAR is its 3804 value before updating SRTT itself using the second assignment. 3806 After the computation, update 3808 RTO = SRTT + 4 * RTTVAR; 3810 C4) When data is in flight and when allowed by rule C5 below, a new 3811 RTT measurement MUST be made each round trip. Furthermore, new 3812 RTT measurements SHOULD be made no more than once per round trip 3813 for a given destination transport address. There are two 3814 reasons for this recommendation: First, it appears that 3815 measuring more frequently often does not in practice yield any 3816 significant benefit [ALLMAN99]; second, if measurements are made 3817 more often, then the values of 'RTO.Alpha' and 'RTO.Beta' in 3818 rule C3 above SHOULD be adjusted so that SRTT and RTTVAR still 3819 adjust to changes at roughly the same rate (in terms of how many 3820 round trips it takes them to reflect new values) as they would 3821 if making only one measurement per round-trip and using 3822 'RTO.Alpha' and 'RTO.Beta' as given in rule C3. However, the 3823 exact nature of these adjustments remains a research issue. 3825 C5) Karn's algorithm: RTT measurements MUST NOT be made using 3826 packets that were retransmitted (and thus for which it is 3827 ambiguous whether the reply was for the first instance of the 3828 chunk or for a later instance). 3830 RTT measurements SHOULD only be made using a chunk with TSN r if 3831 no chunk with TSN less than or equal to r is retransmitted since 3832 r is first sent. 3834 C6) Whenever RTO is computed, if it is less than 'RTO.Min' seconds 3835 then it is rounded up to 'RTO.Min' seconds. The reason for this 3836 rule is that RTOs that do not have a high minimum value are 3837 susceptible to unnecessary timeouts [ALLMAN99]. 3839 C7) A maximum value MAY be placed on RTO provided it is at least 3840 'RTO.max' seconds. 3842 There is no requirement for the clock granularity G used for 3843 computing RTT measurements and the different state variables, other 3844 than: 3846 G1) Whenever RTTVAR is computed, if RTTVAR == 0, then adjust RTTVAR 3847 = G. 3849 Experience [ALLMAN99] has shown that finer clock granularities (less 3850 than 100 msec) perform somewhat better than more coarse 3851 granularities. 3853 6.3.2. Retransmission Timer Rules 3855 The rules for managing the retransmission timer are as follows: 3857 R1) Every time a DATA chunk is sent to any address (including a 3858 retransmission), if the T3-rtx timer of that address is not 3859 running, start it running so that it will expire after the RTO 3860 of that address. The RTO used here is that obtained after any 3861 doubling due to previous T3-rtx timer expirations on the 3862 corresponding destination address as discussed in rule E2 below. 3864 R2) Whenever all outstanding data sent to an address have been 3865 acknowledged, turn off the T3-rtx timer of that address. 3867 R3) Whenever a SACK is received that acknowledges the DATA chunk 3868 with the earliest outstanding TSN for that address, restart the 3869 T3-rtx timer for that address with its current RTO (if there is 3870 still outstanding data on that address). 3872 R4) Whenever a SACK is received missing a TSN that was previously 3873 acknowledged via a Gap Ack Block, start the T3-rtx for the 3874 destination address to which the DATA chunk was originally 3875 transmitted if it is not already running. 3877 The following example shows the use of various timer rules (assuming 3878 that the receiver uses delayed acks). 3880 Endpoint A Endpoint Z 3881 {App begins to send} 3882 Data [TSN=7,Strm=0,Seq=3] ------------> (ack delayed) 3883 (Start T3-rtx timer) 3884 {App sends 1 message; strm 1} 3885 (bundle ack with data) 3886 DATA [TSN=8,Strm=0,Seq=4] ----\ /-- SACK [TSN Ack=7,Block=0] 3887 \ / DATA [TSN=6,Strm=1,Seq=2] 3888 \ / (Start T3-rtx timer) 3889 \ 3890 / \ 3891 (Restart T3-rtx timer) <------/ \--> (ack delayed) 3892 (ack delayed) 3893 {send ack} 3894 SACK [TSN Ack=6,Block=0] --------------> (Cancel T3-rtx timer) 3895 .. 3896 (send ack) 3897 (Cancel T3-rtx timer) <-------------- SACK [TSN Ack=8,Block=0] 3899 Figure 8: Timer Rule Examples 3901 6.3.3. Handle T3-rtx Expiration 3903 Whenever the retransmission timer T3-rtx expires for a destination 3904 address, do the following: 3906 E1) For the destination address for which the timer expires, adjust 3907 its ssthresh with rules defined in Section 7.2.3 and set the 3908 cwnd = PMDCS. 3910 E2) For the destination address for which the timer expires, set RTO 3911 = RTO * 2 ("back off the timer"). The maximum value discussed 3912 in rule C7 above ('RTO.max') MAY be used to provide an upper 3913 bound to this doubling operation. 3915 E3) Determine how many of the earliest (i.e., lowest TSN) 3916 outstanding DATA chunks for the address for which the T3-rtx has 3917 expired will fit into a single packet, subject to the PMTU 3918 corresponding to the destination transport address to which the 3919 retransmission is being sent (this might be different from the 3920 address for which the timer expires; see Section 6.4). Call 3921 this value K. Bundle and retransmit those K DATA chunks in a 3922 single packet to the destination endpoint. 3924 E4) Start the retransmission timer T3-rtx on the destination address 3925 to which the retransmission is sent, if rule R1 above indicates 3926 to do so. The RTO to be used for starting T3-rtx SHOULD be the 3927 one for the destination address to which the retransmission is 3928 sent, which, when the receiver is multi-homed, might be 3929 different from the destination address for which the timer 3930 expired (see Section 6.4 below). 3932 After retransmitting, once a new RTT measurement is obtained (which 3933 can happen only when new data has been sent and acknowledged, per 3934 rule C5, or for a measurement made from a HEARTBEAT; see 3935 Section 8.3), the computation in rule C3 is performed, including the 3936 computation of RTO, which might result in "collapsing" RTO back down 3937 after it has been subject to doubling (rule E2). 3939 Any DATA chunks that were sent to the address for which the T3-rtx 3940 timer expired but did not fit in an SCTP packet of size smaller than 3941 or equal to the PMTU (rule E3 above) SHOULD be marked for 3942 retransmission and sent as soon as cwnd allows (normally, when a SACK 3943 arrives). 3945 The final rule for managing the retransmission timer concerns 3946 failover (see Section 6.4.1): 3948 F1) Whenever an endpoint switches from the current destination 3949 transport address to a different one, the current retransmission 3950 timers are left running. As soon as the endpoint transmits a 3951 packet containing DATA chunk(s) to the new transport address, 3952 start the timer on that transport address, using the RTO value 3953 of the destination address to which the data is being sent, if 3954 rule R1 indicates to do so. 3956 6.4. Multi-Homed SCTP Endpoints 3958 An SCTP endpoint is considered multi-homed if there are more than one 3959 transport address that can be used as a destination address to reach 3960 that endpoint. 3962 Moreover, the ULP of an endpoint selects one of the multiple 3963 destination addresses of a multi-homed peer endpoint as the primary 3964 path (see Section 5.1.2 and Section 11.1 for details). 3966 By default, an endpoint SHOULD always transmit to the primary path, 3967 unless the SCTP user explicitly specifies the destination transport 3968 address (and possibly source transport address) to use. 3970 An endpoint SHOULD transmit reply chunks (e.g., INIT ACK, COOKIE ACK, 3971 HEARTBEAT ACK) in response to control chunks to the same destination 3972 transport address from which it received the control chunk to which 3973 it is replying. 3975 The selection of the destination transport address for packets 3976 containing SACK chunks is implementation dependent. However, an 3977 endpoint SHOULD NOT vary the destination transport address of a SACK 3978 when it receives DATA chunks coming from the same source address. 3980 When acknowledging multiple DATA chunks received in packets from 3981 different source addresses in a single SACK, the SACK chunk MAY be 3982 transmitted to one of the destination transport addresses from which 3983 the DATA or control chunks being acknowledged were received. 3985 When a receiver of a duplicate DATA chunk sends a SACK to a multi- 3986 homed endpoint, it MAY be beneficial to vary the destination address 3987 and not use the source address of the DATA chunk. The reason is that 3988 receiving a duplicate from a multi-homed endpoint might indicate that 3989 the return path (as specified in the source address of the DATA 3990 chunk) for the SACK is broken. 3992 Furthermore, when its peer is multi-homed, an endpoint SHOULD try to 3993 retransmit a chunk that timed out to an active destination transport 3994 address that is different from the last destination address to which 3995 the chunk was sent. 3997 When its peer is multi-homed, an endpoint SHOULD send fast 3998 retransmissions to the same destination transport address to which 3999 the original data was sent. If the primary path has been changed and 4000 the original data was sent to the old primary path before the Fast 4001 Retransmit, the implementation MAY send it to the new primary path. 4003 Retransmissions do not affect the total outstanding data count. 4004 However, if the DATA chunk is retransmitted onto a different 4005 destination address, both the outstanding data counts on the new 4006 destination address and the old destination address to which the data 4007 chunk was last sent is adjusted accordingly. 4009 6.4.1. Failover from an Inactive Destination Address 4011 Some of the transport addresses of a multi-homed SCTP endpoint might 4012 become inactive due to either the occurrence of certain error 4013 conditions (see Section 8.2) or adjustments from the SCTP user. 4015 When there is outbound data to send and the primary path becomes 4016 inactive (e.g., due to failures), or where the SCTP user explicitly 4017 requests to send data to an inactive destination transport address, 4018 before reporting an error to its ULP, the SCTP endpoint SHOULD try to 4019 send the data to an alternate active destination transport address if 4020 one exists. 4022 When retransmitting data that timed out, if the endpoint is multi- 4023 homed, it needs to consider each source-destination address pair in 4024 its retransmission selection policy. When retransmitting timed-out 4025 data, the endpoint SHOULD attempt to pick the most divergent source- 4026 destination pair from the original source-destination pair to which 4027 the packet was transmitted. 4029 Note: Rules for picking the most divergent source-destination pair 4030 are an implementation decision and are not specified within this 4031 document. 4033 6.5. Stream Identifier and Stream Sequence Number 4035 Every DATA chunk MUST carry a valid stream identifier. If an 4036 endpoint receives a DATA chunk with an invalid stream identifier, it 4037 SHOULD acknowledge the reception of the DATA chunk following the 4038 normal procedure, immediately send an ERROR chunk with cause set to 4039 "Invalid Stream Identifier" (see Section 3.3.10), and discard the 4040 DATA chunk. The endpoint MAY bundle the ERROR chunk and the SACK 4041 chunk in the same packet. 4043 The Stream Sequence Number in all the streams MUST start from 0 when 4044 the association is established. Also, when the Stream Sequence 4045 Number reaches the value 65535 the next Stream Sequence Number MUST 4046 be set to 0. 4048 6.6. Ordered and Unordered Delivery 4050 Within a stream, an endpoint MUST deliver DATA chunks received with 4051 the U flag set to 0 to the upper layer according to the order of 4052 their Stream Sequence Number. If DATA chunks arrive out of order of 4053 their Stream Sequence Number, the endpoint MUST hold the received 4054 DATA chunks from delivery to the ULP until they are reordered. 4056 However, an SCTP endpoint can indicate that no ordered delivery is 4057 required for a particular DATA chunk transmitted within the stream by 4058 setting the U flag of the DATA chunk to 1. 4060 When an endpoint receives a DATA chunk with the U flag set to 1, it 4061 bypasses the ordering mechanism and immediately deliver the data to 4062 the upper layer (after reassembly if the user data is fragmented by 4063 the data sender). 4065 This provides an effective way of transmitting "out-of-band" data in 4066 a given stream. Also, a stream can be used as an "unordered" stream 4067 by simply setting the U flag to 1 in all DATA chunks sent through 4068 that stream. 4070 IMPLEMENTATION NOTE: When sending an unordered DATA chunk, an 4071 implementation MAY choose to place the DATA chunk in an outbound 4072 packet that is at the head of the outbound transmission queue if 4073 possible. 4075 The 'Stream Sequence Number' field in a DATA chunk with U flag set to 4076 1 has no significance. The sender can fill the 'Stream Sequence 4077 Number' with arbitrary value, but the receiver MUST ignore the field. 4079 Note: When transmitting ordered and unordered data, an endpoint does 4080 not increment its Stream Sequence Number when transmitting a DATA 4081 chunk with U flag set to 1. 4083 6.7. Report Gaps in Received DATA TSNs 4085 Upon the reception of a new DATA chunk, an endpoint examines the 4086 continuity of the TSNs received. If the endpoint detects a gap in 4087 the received DATA chunk sequence, it SHOULD send a SACK with Gap Ack 4088 Blocks immediately. The data receiver continues sending a SACK after 4089 receipt of each SCTP packet that does not fill the gap. 4091 Based on the Gap Ack Block from the received SACK, the endpoint can 4092 calculate the missing DATA chunks and make decisions on whether to 4093 retransmit them (see Section 6.2.1 for details). 4095 Multiple gaps can be reported in one single SACK (see Section 3.3.4). 4097 When its peer is multi-homed, the SCTP endpoint SHOULD always try to 4098 send the SACK to the same destination address from which the last 4099 DATA chunk was received. 4101 Upon the reception of a SACK, the endpoint MUST remove all DATA 4102 chunks that have been acknowledged by the SACK's Cumulative TSN Ack 4103 from its transmit queue. All DATA chunks with TSNs not included in 4104 the Gap Ack Blocks that are smaller than the highest acknowledged TSN 4105 reported in the SACK chunk MUST be treated as "missing" by the 4106 sending endpoint. The number of "missing" reports for each 4107 outstanding DATA chunk MUST be recorded by the data sender to make 4108 retransmission decisions. See Section 7.2.4 for details. 4110 The following example shows the use of SACK to report a gap. 4112 Endpoint A Endpoint Z 4113 {App sends 3 messages; strm 0} 4114 DATA [TSN=6,Strm=0,Seq=2] ---------------> (ack delayed) 4115 (Start T3-rtx timer) 4117 DATA [TSN=7,Strm=0,Seq=3] --------> X (lost) 4119 DATA [TSN=8,Strm=0,Seq=4] ---------------> (gap detected, 4120 immediately send ack) 4121 /----- SACK [TSN Ack=6,Block=1, 4122 / Start=2,End=2] 4123 <-----/ 4124 (remove 6 from out-queue, 4125 and mark 7 as "1" missing report) 4127 Figure 9: Reporting a Gap using SACK 4129 The maximum number of Gap Ack Blocks that can be reported within a 4130 single SACK chunk is limited by the current PMTU. When a single SACK 4131 cannot cover all the Gap Ack Blocks needed to be reported due to the 4132 PMTU limitation, the endpoint MUST send only one SACK. This single 4133 SACK MUST report the Gap Ack Blocks from the lowest to highest TSNs, 4134 within the size limit set by the PMTU, and leave the remaining 4135 highest TSN numbers unacknowledged. 4137 6.8. CRC32c Checksum Calculation 4139 When sending an SCTP packet, the endpoint MUST strengthen the data 4140 integrity of the transmission by including the CRC32c checksum value 4141 calculated on the packet, as described below. 4143 After the packet is constructed (containing the SCTP common header 4144 and one or more control or DATA chunks), the transmitter MUST 4146 1) fill in the proper Verification Tag in the SCTP common header and 4147 initialize the checksum field to '0's, 4149 2) calculate the CRC32c checksum of the whole packet, including the 4150 SCTP common header and all the chunks (refer to Appendix A for 4151 details of the CRC32c algorithm); and 4153 3) put the resultant value into the checksum field in the common 4154 header, and leave the rest of the bits unchanged. 4156 When an SCTP packet is received, the receiver MUST first check the 4157 CRC32c checksum as follows: 4159 1) Store the received CRC32c checksum value aside. 4161 2) Replace the 32 bits of the checksum field in the received SCTP 4162 packet with all '0's and calculate a CRC32c checksum value of the 4163 whole received packet. 4165 3) Verify that the calculated CRC32c checksum is the same as the 4166 received CRC32c checksum. If it is not, the receiver MUST treat 4167 the packet as an invalid SCTP packet. 4169 The default procedure for handling invalid SCTP packets is to 4170 silently discard them. 4172 Any hardware implementation SHOULD permit alternative verification of 4173 the CRC in software. 4175 6.9. Fragmentation and Reassembly 4177 An endpoint MAY support fragmentation when sending DATA chunks, but 4178 it MUST support reassembly when receiving DATA chunks. If an 4179 endpoint supports fragmentation, it MUST fragment a user message if 4180 the size of the user message to be sent causes the outbound SCTP 4181 packet size to exceed the current PMTU. An endpoint that does not 4182 support fragmentation and is requested to send a user message such 4183 that the outbound SCTP packet size would exceed the current PMTU MUST 4184 return an error to its upper layer and MUST NOT attempt to send the 4185 user message. 4187 If an implementation that supports fragmentation makes available to 4188 its upper layer a mechanism to turn off fragmentation, it might do 4189 so. An implementation that disables fragmentation MUST react just 4190 like an implementation that does NOT support fragmentation, i.e., it 4191 MUST reject send calls that would result in sending SCTP packets that 4192 exceed the current PMTU. 4194 IMPLEMENTATION NOTE: In this error case, the SEND primitive discussed 4195 in Section 11.1 would need to return an error to the upper layer. 4197 If its peer is multi-homed, the endpoint SHOULD choose a DATA chunk 4198 size smaller than or equal to the AMDCS. 4200 Once a user message is fragmented, it cannot be re-fragmented. 4201 Instead, if the PMTU has been reduced, then IP fragmentation MUST be 4202 used. Please see Section 7.3 for details of PMTU discovery. 4204 When determining when to fragment, the SCTP implementation MUST take 4205 into account the SCTP packet header as well as the DATA chunk 4206 header(s). The implementation MUST also take into account the space 4207 required for a SACK chunk if bundling a SACK chunk with the DATA 4208 chunk. 4210 Fragmentation takes the following steps: 4212 1) The data sender MUST break the user message into a series of DATA 4213 chunks. The sender SHOULD choose the size of the DATA chunks is 4214 smaller than or equal to the AMDCS. 4216 2) The transmitter MUST then assign, in sequence, a separate TSN to 4217 each of the DATA chunks in the series. The transmitter assigns 4218 the same SSN to each of the DATA chunks. If the user indicates 4219 that the user message is to be delivered using unordered 4220 delivery, then the U flag of each DATA chunk of the user message 4221 MUST be set to 1. 4223 3) The transmitter MUST also set the B/E bits of the first DATA 4224 chunk in the series to '10', the B/E bits of the last DATA chunk 4225 in the series to '01', and the B/E bits of all other DATA chunks 4226 in the series to '00'. 4228 An endpoint MUST recognize fragmented DATA chunks by examining the B/ 4229 E bits in each of the received DATA chunks, and queue the fragmented 4230 DATA chunks for reassembly. Once the user message is reassembled, 4231 SCTP passes the reassembled user message to the specific stream for 4232 possible reordering and final dispatching. 4234 If the data receiver runs out of buffer space while still waiting for 4235 more fragments to complete the reassembly of the message, it SHOULD 4236 dispatch part of its inbound message through a partial delivery API 4237 (see Section 11), freeing some of its receive buffer space so that 4238 the rest of the message can be received. 4240 6.10. Bundling 4242 An endpoint bundles chunks by simply including multiple chunks in one 4243 outbound SCTP packet. The total size of the resultant SCTP packet 4244 MUST be less that or equal to the current PMTU. 4246 If its peer endpoint is multi-homed, the sending endpoint SHOULD 4247 choose a size no larger than the PMTU of the current primary path. 4249 When bundling control chunks with DATA chunks, an endpoint MUST place 4250 control chunks first in the outbound SCTP packet. The transmitter 4251 MUST transmit DATA chunks within an SCTP packet in increasing order 4252 of TSN. 4254 Note: Since control chunks are placed first in a packet and since 4255 DATA chunks are transmitted before SHUTDOWN or SHUTDOWN ACK chunks, 4256 DATA chunks cannot be bundled with SHUTDOWN or SHUTDOWN ACK chunks. 4258 Partial chunks MUST NOT be placed in an SCTP packet. A partial chunk 4259 is a chunk that is not completely contained in the SCTP packet; i.e., 4260 the SCTP packet is too short to contain all the bytes of the chunk as 4261 indicated by the chunk length. 4263 An endpoint MUST process received chunks in their order in the 4264 packet. The receiver uses the Chunk Length field to determine the 4265 end of a chunk and beginning of the next chunk taking account of the 4266 fact that all chunks end on a 4-byte boundary. If the receiver 4267 detects a partial chunk, it MUST drop the chunk. 4269 An endpoint MUST NOT bundle INIT, INIT ACK, or SHUTDOWN COMPLETE with 4270 any other chunks. 4272 7. Congestion Control 4274 Congestion control is one of the basic functions in SCTP. For some 4275 applications, it might be likely that adequate resources will be 4276 allocated to SCTP traffic to ensure prompt delivery of time-critical 4277 data -- thus, it would appear to be unlikely, during normal 4278 operations, that transmissions encounter severe congestion 4279 conditions. However, SCTP operates under adverse operational 4280 conditions, which can develop upon partial network failures or 4281 unexpected traffic surges. In such situations, SCTP follows correct 4282 congestion control steps to recover from congestion quickly in order 4283 to get data delivered as soon as possible. In the absence of network 4284 congestion, these preventive congestion control algorithms are 4285 expected to show no impact on the protocol performance. 4287 IMPLEMENTATION NOTE: As far as its specific performance requirements 4288 are met, an implementation is always allowed to adopt a more 4289 conservative congestion control algorithm than the one defined below. 4291 The congestion control algorithms used by SCTP are based on 4292 [RFC5681]. This section describes how the algorithms defined in 4293 [RFC5681] are adapted for use in SCTP. We first list differences in 4294 protocol designs between TCP and SCTP, and then describe SCTP's 4295 congestion control scheme. The description will use the same 4296 terminology as in TCP congestion control whenever appropriate. 4298 SCTP congestion control is always applied to the entire association, 4299 and not to individual streams. 4301 7.1. SCTP Differences from TCP Congestion Control 4303 Gap Ack Blocks in the SCTP SACK carry the same semantic meaning as 4304 the TCP SACK. TCP considers the information carried in the SACK as 4305 advisory information only. SCTP considers the information carried in 4306 the Gap Ack Blocks in the SACK chunk as advisory. In SCTP, any DATA 4307 chunk that has been acknowledged by SACK, including DATA that arrived 4308 at the receiving end out of order, is not considered fully delivered 4309 until the Cumulative TSN Ack Point passes the TSN of the DATA chunk 4310 (i.e., the DATA chunk has been acknowledged by the Cumulative TSN Ack 4311 field in the SACK). Consequently, the value of cwnd controls the 4312 amount of outstanding data, rather than (as in the case of non-SACK 4313 TCP) the upper bound between the highest acknowledged sequence number 4314 and the latest DATA chunk that can be sent within the congestion 4315 window. SCTP SACK leads to different implementations of Fast 4316 Retransmit and Fast Recovery than non-SACK TCP. As an example, see 4317 [FALL96]. 4319 The biggest difference between SCTP and TCP, however, is multi- 4320 homing. SCTP is designed to establish robust communication 4321 associations between two endpoints each of which might be reachable 4322 by more than one transport address. Potentially different addresses 4323 might lead to different data paths between the two endpoints; thus, 4324 ideally one needs a separate set of congestion control parameters for 4325 each of the paths. The treatment here of congestion control for 4326 multi-homed receivers is new with SCTP and might require refinement 4327 in the future. The current algorithms make the following 4328 assumptions: 4330 * The sender usually uses the same destination address until being 4331 instructed by the upper layer to do otherwise; however, SCTP MAY 4332 change to an alternate destination in the event an address is 4333 marked inactive (see Section 8.2). Also, SCTP MAY retransmit to a 4334 different transport address than the original transmission. 4336 * The sender keeps a separate congestion control parameter set for 4337 each of the destination addresses it can send to (not each source- 4338 destination pair but for each destination). The parameters SHOULD 4339 decay if the address is not used for a long enough time period. 4340 [RFC5681] specifies this long enough time as a retransmission 4341 timeout. 4343 * For each of the destination addresses, an endpoint does slow start 4344 upon the first transmission to that address. 4346 Note: TCP guarantees in-sequence delivery of data to its upper-layer 4347 protocol within a single TCP session. This means that when TCP 4348 notices a gap in the received sequence number, it waits until the gap 4349 is filled before delivering the data that was received with sequence 4350 numbers higher than that of the missing data. On the other hand, 4351 SCTP can deliver data to its upper-layer protocol even if there is a 4352 gap in TSN if the Stream Sequence Numbers are in sequence for a 4353 particular stream (i.e., the missing DATA chunks are for a different 4354 stream) or if unordered delivery is indicated. Although this does 4355 not affect cwnd, it might affect rwnd calculation. 4357 7.2. SCTP Slow-Start and Congestion Avoidance 4359 The slow-start and congestion avoidance algorithms MUST be used by an 4360 endpoint to control the amount of data being injected into the 4361 network. The congestion control in SCTP is employed in regard to the 4362 association, not to an individual stream. In some situations, it 4363 might be beneficial for an SCTP sender to be more conservative than 4364 the algorithms allow; however, an SCTP sender MUST NOT be more 4365 aggressive than the following algorithms allow. 4367 Like TCP, an SCTP endpoint uses the following three control variables 4368 to regulate its transmission rate. 4370 * Receiver advertised window size (rwnd, in bytes), which is set by 4371 the receiver based on its available buffer space for incoming 4372 packets. 4374 Note: This variable is kept on the entire association. 4376 * Congestion control window (cwnd, in bytes), which is adjusted by 4377 the sender based on observed network conditions. 4379 Note: This variable is maintained on a per-destination-address 4380 basis. 4382 * Slow-start threshold (ssthresh, in bytes), which is used by the 4383 sender to distinguish slow-start and congestion avoidance phases. 4385 Note: This variable is maintained on a per-destination-address 4386 basis. 4388 SCTP also requires one additional control variable, 4389 partial_bytes_acked, which is used during congestion avoidance phase 4390 to facilitate cwnd adjustment. 4392 Unlike TCP, an SCTP sender MUST keep a set of these control variables 4393 cwnd, ssthresh, and partial_bytes_acked for EACH destination address 4394 of its peer (when its peer is multi-homed). When doing accounting 4395 for a DATA chunk related to one of these variables, the length of the 4396 DATA chunk including the padding SHOULD be used. 4398 Only one rwnd is kept for the whole association (no matter if the 4399 peer is multi-homed or has a single address). 4401 7.2.1. Slow-Start 4403 Beginning data transmission into a network with unknown conditions or 4404 after a sufficiently long idle period requires SCTP to probe the 4405 network to determine the available capacity. The slow-start 4406 algorithm is used for this purpose at the beginning of a transfer, or 4407 after repairing loss detected by the retransmission timer. 4409 * The initial cwnd before data transmission MUST be set to min(4 * 4410 PMDCS, max(2 * PMDCS, 4404)) bytes if the peer address is an IPv4 4411 address and to min(4 * PMDCS, max(2 * PMDCS, 4344)) bytes if the 4412 peer address is an IPv6 address. 4414 * The initial cwnd after a retransmission timeout MUST be no more 4415 than PMDCS, and only one packet is allowed to be in flight until 4416 successful acknowledgement. 4418 * The initial value of ssthresh SHOULD be arbitrarily high (e.g., 4419 the size of the largest possible advertised window). 4421 * Whenever cwnd is greater than zero, the endpoint is allowed to 4422 have cwnd bytes of data outstanding on that transport address. A 4423 limited overbooking as described in Section 6.1 B) SHOULD be 4424 supported. 4426 * When cwnd is less than or equal to ssthresh, an SCTP endpoint MUST 4427 use the slow-start algorithm to increase cwnd only if the current 4428 congestion window is being fully utilized, an incoming SACK 4429 advances the Cumulative TSN Ack Point, and the data sender is not 4430 in Fast Recovery. Only when these three conditions are met can 4431 the cwnd be increased; otherwise, the cwnd MUST NOT be increased. 4432 If these conditions are met, then cwnd MUST be increased by, at 4433 most, the lesser of 1) the total size of the previously 4434 outstanding DATA chunk(s) acknowledged, and 2) the destination's 4435 PMDCS. This upper bound protects against the ACK-Splitting attack 4436 outlined in [SAVAGE99]. 4438 In instances where its peer endpoint is multi-homed, if an endpoint 4439 receives a SACK that advances its Cumulative TSN Ack Point, then it 4440 SHOULD update its cwnd (or cwnds) apportioned to the destination 4441 addresses to which it transmitted the acknowledged data. However, if 4442 the received SACK does not advance the Cumulative TSN Ack Point, the 4443 endpoint MUST NOT adjust the cwnd of any of the destination 4444 addresses. 4446 Because an endpoint's cwnd is not tied to its Cumulative TSN Ack 4447 Point, as duplicate SACKs come in, even though they might not advance 4448 the Cumulative TSN Ack Point an endpoint can still use them to clock 4449 out new data. That is, the data newly acknowledged by the SACK 4450 diminishes the amount of data now in flight to less than cwnd, and so 4451 the current, unchanged value of cwnd now allows new data to be sent. 4452 On the other hand, the increase of cwnd MUST be tied to the 4453 Cumulative TSN Ack Point advancement as specified above. Otherwise, 4454 the duplicate SACKs will not only clock out new data, but also will 4455 adversely clock out more new data than what has just left the 4456 network, during a time of possible congestion. 4458 * While the endpoint does not transmit data on a given transport 4459 address, the cwnd of the transport address SHOULD be adjusted to 4460 max(cwnd / 2, 4 * PMDCS) once per RTO. Before the first cwnd 4461 adjustment, the ssthresh of the transport address SHOULD be set to 4462 the cwnd. 4464 7.2.2. Congestion Avoidance 4466 When cwnd is greater than ssthresh, cwnd SHOULD be incremented by 4467 PMDCS per RTT if the sender has cwnd or more bytes of data 4468 outstanding for the corresponding transport address. The basic 4469 recommendations for incrementing cwnd during congestion avoidance are 4470 as follows: 4472 * SCTP MAY increment cwnd by PMDCS. 4474 * SCTP SHOULD increment cwnd by PMDCS once per RTT when the sender 4475 has cwnd or more bytes of data outstanding for the corresponding 4476 transport address. 4478 * SCTP MUST NOT increment cwnd by more than PMDCS per RTT. 4480 In practice, an implementation can achieve this goal in the following 4481 way: 4483 * partial_bytes_acked is initialized to 0. 4485 * Whenever cwnd is greater than ssthresh, upon each SACK arrival, 4486 increase partial_bytes_acked by the total number of bytes 4487 (including the chunk header and the padding) of all new DATA 4488 chunks acknowledged in that SACK, including chunks acknowledged by 4489 the new Cumulative TSN Ack, by Gap Ack Blocks, and by the number 4490 of bytes of duplicated chunks reported in Duplicate TSNs. 4492 * (1) when partial_bytes_acked is greater than cwnd and (2) before 4493 the arrival of the SACK the sender had less than cwnd bytes of 4494 data outstanding (i.e., before the arrival of the SACK, flightsize 4495 was less than cwnd), reset partial_bytes_acked to cwnd. 4497 * (1) when partial_bytes_acked is equal to or greater than cwnd and 4498 (2) before the arrival of the SACK the sender had cwnd or more 4499 bytes of data outstanding (i.e., before the arrival of the SACK, 4500 flightsize was greater than or equal to cwnd), partial_bytes_acked 4501 is reset to (partial_bytes_acked - cwnd). Next, cwnd is increased 4502 by PMDCS. 4504 * Same as in the slow start, when the sender does not transmit DATA 4505 on a given transport address, the cwnd of the transport address 4506 SHOULD be adjusted to max(cwnd / 2, 4 * PMDCS) per RTO. 4508 * When all of the data transmitted by the sender has been 4509 acknowledged by the receiver, partial_bytes_acked is initialized 4510 to 0. 4512 7.2.3. Congestion Control 4514 Upon detection of packet losses from SACK (see Section 7.2.4), an 4515 endpoint SHOULD do the following: 4517 ssthresh = max(cwnd / 2, 4 * PMDCS) 4518 cwnd = ssthresh 4519 partial_bytes_acked = 0 4521 Basically, a packet loss causes cwnd to be cut in half. 4523 When the T3-rtx timer expires on an address, SCTP SHOULD perform slow 4524 start by: 4526 ssthresh = max(cwnd / 2, 4 * PMDCS) 4527 cwnd = PMDCS 4528 partial_bytes_acked = 0 4530 and ensure that no more than one SCTP packet will be in flight for 4531 that address until the endpoint receives acknowledgement for 4532 successful delivery of data to that address. 4534 7.2.4. Fast Retransmit on Gap Reports 4536 In the absence of data loss, an endpoint performs delayed 4537 acknowledgement. However, whenever an endpoint notices a hole in the 4538 arriving TSN sequence, it SHOULD start sending a SACK back every time 4539 a packet arrives carrying data until the hole is filled. 4541 Whenever an endpoint receives a SACK that indicates that some TSNs 4542 are missing, it SHOULD wait for two further miss indications (via 4543 subsequent SACKs for a total of three missing reports) on the same 4544 TSNs before taking action with regard to Fast Retransmit. 4546 Miss indications SHOULD follow the HTNA (Highest TSN Newly 4547 Acknowledged) algorithm. For each incoming SACK, miss indications 4548 are incremented only for missing TSNs prior to the highest TSN newly 4549 acknowledged in the SACK. A newly acknowledged DATA chunk is one not 4550 previously acknowledged in a SACK. If an endpoint is in Fast 4551 Recovery and a SACK arrives that advances the Cumulative TSN Ack 4552 Point, the miss indications are incremented for all TSNs reported 4553 missing in the SACK. 4555 When the third consecutive miss indication is received for a TSN(s), 4556 the data sender does the following: 4558 1) Mark the DATA chunk(s) with three miss indications for 4559 retransmission. 4561 2) If not in Fast Recovery, adjust the ssthresh and cwnd of the 4562 destination address(es) to which the missing DATA chunks were 4563 last sent, according to the formula described in Section 7.2.3. 4565 3) If not in Fast Recovery, determine how many of the earliest 4566 (i.e., lowest TSN) DATA chunks marked for retransmission will fit 4567 into a single packet, subject to constraint of the PMTU of the 4568 destination transport address to which the packet is being sent. 4569 Call this value K. Retransmit those K DATA chunks in a single 4570 packet. When a Fast Retransmit is being performed, the sender 4571 SHOULD ignore the value of cwnd and SHOULD NOT delay 4572 retransmission for this single packet. 4574 4) Restart the T3-rtx timer only if the last SACK acknowledged the 4575 lowest outstanding TSN number sent to that address, or the 4576 endpoint is retransmitting the first outstanding DATA chunk sent 4577 to that address. 4579 5) Mark the DATA chunk(s) as being fast retransmitted and thus 4580 ineligible for a subsequent Fast Retransmit. Those TSNs marked 4581 for retransmission due to the Fast-Retransmit algorithm that did 4582 not fit in the sent datagram carrying K other TSNs are also 4583 marked as ineligible for a subsequent Fast Retransmit. However, 4584 as they are marked for retransmission they will be retransmitted 4585 later on as soon as cwnd allows. 4587 6) If not in Fast Recovery, enter Fast Recovery and mark the highest 4588 outstanding TSN as the Fast Recovery exit point. When a SACK 4589 acknowledges all TSNs up to and including this exit point, Fast 4590 Recovery is exited. While in Fast Recovery, the ssthresh and 4591 cwnd SHOULD NOT change for any destinations due to a subsequent 4592 Fast Recovery event (i.e., one SHOULD NOT reduce the cwnd further 4593 due to a subsequent Fast Retransmit). 4595 Note: Before the above adjustments, if the received SACK also 4596 acknowledges new DATA chunks and advances the Cumulative TSN Ack 4597 Point, the cwnd adjustment rules defined in Section 7.2.1 and 4598 Section 7.2.2 MUST be applied first. 4600 7.2.5. Making Changes to Differentiated Services Code Points 4602 SCTP implementations MAY allow an application to configure the 4603 Differentiated Services Code Point (DSCP) used for sending packets. 4604 If a DSCP change might result in outgoing packets being queued in 4605 different queues, the congestion control parameters for all affected 4606 destination addresses MUST be reset to their initial values. 4608 7.3. PMTU Discovery 4610 [RFC8899], [RFC8201], and [RFC1191] specify "Packetization Layer Path 4611 MTU Discovery", whereby an endpoint maintains an estimate of PMTU 4612 along a given Internet path and refrains from sending packets along 4613 that path that exceed the PMTU, other than occasional attempts to 4614 probe for a change in the PMTU. [RFC8899] is thorough in its 4615 discussion of the PMTU discovery mechanism and strategies for 4616 determining the current end-to-end PMTU setting as well as detecting 4617 changes in this value. 4619 An endpoint SHOULD apply these techniques, and SHOULD do so on a per- 4620 destination-address basis. 4622 There are two important SCTP-specific points regarding PMTU 4623 discovery: 4625 1) SCTP associations can span multiple addresses. An endpoint MUST 4626 maintain separate PMTU estimates for each destination address of 4627 its peer. 4629 2) The sender SHOULD track an AMDCS that will be the smallest PMDCS 4630 discovered for all of the peer's destination addresses. When 4631 fragmenting messages into multiple parts this AMDCS SHOULD be 4632 used to calculate the size of each DATA chunk. This will allow 4633 retransmissions to be seamlessly sent to an alternate address 4634 without encountering IP fragmentation. 4636 8. Fault Management 4637 8.1. Endpoint Failure Detection 4639 An endpoint SHOULD keep a counter on the total number of consecutive 4640 retransmissions to its peer (this includes data retransmissions to 4641 all the destination transport addresses of the peer if it is multi- 4642 homed), including the number of unacknowledged HEARTBEAT chunks 4643 observed on the path that is currently used for data transfer. 4644 Unacknowledged HEARTBEAT chunks observed on paths different from the 4645 path currently used for data transfer SHOULD NOT increment the 4646 association error counter, as this could lead to association closure 4647 even if the path that is currently used for data transfer is 4648 available (but idle). If the value of this counter exceeds the limit 4649 indicated in the protocol parameter 'Association.Max.Retrans', the 4650 endpoint SHOULD consider the peer endpoint unreachable and SHALL stop 4651 transmitting any more data to it (and thus the association enters the 4652 CLOSED state). In addition, the endpoint SHOULD report the failure 4653 to the upper layer and optionally report back all outstanding user 4654 data remaining in its outbound queue. The association is 4655 automatically closed when the peer endpoint becomes unreachable. 4657 The counter used for endpoint failure detection MUST be reset each 4658 time a DATA chunk sent to that peer endpoint is acknowledged (by the 4659 reception of a SACK). When a HEARTBEAT ACK is received from the peer 4660 endpoint, the counter SHOULD also be reset. The receiver of the 4661 HEARTBEAT ACK MAY choose not to clear the counter if there is 4662 outstanding data on the association. This allows for handling the 4663 possible difference in reachability based on DATA chunks and 4664 HEARTBEAT chunks. 4666 8.2. Path Failure Detection 4668 When its peer endpoint is multi-homed, an endpoint SHOULD keep an 4669 error counter for each of the destination transport addresses of the 4670 peer endpoint. 4672 Each time the T3-rtx timer expires on any address, or when a 4673 HEARTBEAT sent to an idle address is not acknowledged within an RTO, 4674 the error counter of that destination address will be incremented. 4675 When the value in the error counter exceeds the protocol parameter 4676 'Path.Max.Retrans' of that destination address, the endpoint SHOULD 4677 mark the destination transport address as inactive, and a 4678 notification SHOULD be sent to the upper layer. 4680 When an outstanding TSN is acknowledged or a HEARTBEAT sent to that 4681 address is acknowledged with a HEARTBEAT ACK, the endpoint SHOULD 4682 clear the error counter of the destination transport address to which 4683 the DATA chunk was last sent (or HEARTBEAT was sent) and SHOULD also 4684 report to the upper layer when an inactive destination address is 4685 marked as active. When the peer endpoint is multi-homed and the last 4686 chunk sent to it was a retransmission to an alternate address, there 4687 exists an ambiguity as to whether or not the acknowledgement could be 4688 credited to the address of the last chunk sent. However, this 4689 ambiguity does not seem to have significant consequences for SCTP 4690 behavior. If this ambiguity is undesirable, the transmitter MAY 4691 choose not to clear the error counter if the last chunk sent was a 4692 retransmission. 4694 Note: When configuring the SCTP endpoint, the user ought avoid having 4695 the value of 'Association.Max.Retrans' larger than the summation of 4696 the 'Path.Max.Retrans' of all the destination addresses for the 4697 remote endpoint. Otherwise, all the destination addresses might 4698 become inactive while the endpoint still considers the peer endpoint 4699 reachable. When this condition occurs, how SCTP chooses to function 4700 is implementation specific. 4702 When the primary path is marked inactive (due to excessive 4703 retransmissions, for instance), the sender MAY automatically transmit 4704 new packets to an alternate destination address if one exists and is 4705 active. If more than one alternate address is active when the 4706 primary path is marked inactive, only ONE transport address SHOULD be 4707 chosen and used as the new destination transport address. 4709 8.3. Path Heartbeat 4711 By default, an SCTP endpoint SHOULD monitor the reachability of the 4712 idle destination transport address(es) of its peer by sending a 4713 HEARTBEAT chunk periodically to the destination transport 4714 address(es). HEARTBEAT sending MAY begin upon reaching the 4715 ESTABLISHED state and is discontinued after sending either SHUTDOWN 4716 or SHUTDOWN ACK. A receiver of a HEARTBEAT MUST respond to a 4717 HEARTBEAT with a HEARTBEAT ACK after entering the COOKIE-ECHOED state 4718 (INIT sender) or the ESTABLISHED state (INIT receiver), up until 4719 reaching the SHUTDOWN-SENT state (SHUTDOWN sender) or the SHUTDOWN- 4720 ACK-SENT state (SHUTDOWN receiver). 4722 A destination transport address is considered "idle" if no new chunk 4723 that can be used for updating path RTT (usually including first 4724 transmission DATA, INIT, COOKIE ECHO, HEARTBEAT, etc.) and no 4725 HEARTBEAT has been sent to it within the current heartbeat period of 4726 that address. This applies to both active and inactive destination 4727 addresses. 4729 The upper layer can optionally initiate the following functions: 4731 A) Disable heartbeat on a specific destination transport address of 4732 a given association, 4734 B) Change the 'HB.interval', 4736 C) Re-enable heartbeat on a specific destination transport address 4737 of a given association, and 4739 D) Request an on-demand HEARTBEAT on a specific destination 4740 transport address of a given association. 4742 The endpoint SHOULD increment the respective error counter of the 4743 destination transport address each time a HEARTBEAT is sent to that 4744 address and not acknowledged within one RTO. 4746 When the value of this counter exceeds the protocol parameter 4747 'Path.Max.Retrans', the endpoint SHOULD mark the corresponding 4748 destination address as inactive if it is not so marked and SHOULD 4749 also report to the upper layer the change in reachability of this 4750 destination address. After this, the endpoint SHOULD continue 4751 HEARTBEAT on this destination address but SHOULD stop increasing the 4752 counter. 4754 The sender of the HEARTBEAT chunk SHOULD include in the Heartbeat 4755 Information field of the chunk the current time when the packet is 4756 sent out and the destination address to which the packet is sent. 4758 IMPLEMENTATION NOTE: An alternative implementation of the heartbeat 4759 mechanism that can be used is to increment the error counter variable 4760 every time a HEARTBEAT is sent to a destination. Whenever a 4761 HEARTBEAT ACK arrives, the sender SHOULD clear the error counter of 4762 the destination that the HEARTBEAT was sent to. This in effect would 4763 clear the previously stroked error (and any other error counts as 4764 well). 4766 The receiver of the HEARTBEAT SHOULD immediately respond with a 4767 HEARTBEAT ACK that contains the Heartbeat Information TLV, together 4768 with any other received TLVs, copied unchanged from the received 4769 HEARTBEAT chunk. 4771 Upon the receipt of the HEARTBEAT ACK, the sender of the HEARTBEAT 4772 SHOULD clear the error counter of the destination transport address 4773 to which the HEARTBEAT was sent and mark the destination transport 4774 address as active if it is not so marked. The endpoint SHOULD report 4775 to the upper layer when an inactive destination address is marked as 4776 active due to the reception of the latest HEARTBEAT ACK. The 4777 receiver of the HEARTBEAT ACK SHOULD also clear the association 4778 overall error count (as defined in Section 8.1). 4780 The receiver of the HEARTBEAT ACK SHOULD also perform an RTT 4781 measurement for that destination transport address using the time 4782 value carried in the HEARTBEAT ACK chunk. 4784 On an idle destination address that is allowed to heartbeat, it is 4785 RECOMMENDED that a HEARTBEAT chunk is sent once per RTO of that 4786 destination address plus the protocol parameter 'HB.interval', with 4787 jittering of +/- 50% of the RTO value, and exponential backoff of the 4788 RTO if the previous HEARTBEAT is unanswered. 4790 A primitive is provided for the SCTP user to change the 'HB.interval' 4791 and turn on or off the heartbeat on a given destination address. The 4792 heartbeat interval set by the SCTP user is added to the RTO of that 4793 destination (including any exponential backoff). Only one heartbeat 4794 SHOULD be sent each time the heartbeat timer expires (if multiple 4795 destinations are idle). It is an implementation decision on how to 4796 choose which of the candidate idle destinations to heartbeat to (if 4797 more than one destination is idle). 4799 When tuning the heartbeat interval, there is a side effect that 4800 SHOULD be taken into account. When this value is increased, i.e., 4801 the HEARTBEAT takes longer, the detection of lost ABORT messages 4802 takes longer as well. If a peer endpoint ABORTs the association for 4803 any reason and the ABORT chunk is lost, the local endpoint will only 4804 discover the lost ABORT by sending a DATA chunk or HEARTBEAT chunk 4805 (thus causing the peer to send another ABORT). This is to be 4806 considered when tuning the HEARTBEAT timer. If the HEARTBEAT is 4807 disabled, only sending DATA to the association will discover a lost 4808 ABORT from the peer. 4810 8.4. Handle "Out of the Blue" Packets 4812 An SCTP packet is called an "out of the blue" (OOTB) packet if it is 4813 correctly formed (i.e., passed the receiver's CRC32c check; see 4814 Section 6.8), but the receiver is not able to identify the 4815 association to which this packet belongs. 4817 The receiver of an OOTB packet does the following: 4819 1) If the OOTB packet is to or from a non-unicast address, a 4820 receiver SHOULD silently discard the packet. Otherwise, 4822 2) If the OOTB packet contains an ABORT chunk, the receiver MUST 4823 silently discard the OOTB packet and take no further action. 4824 Otherwise, 4826 3) If the packet contains an INIT chunk with a Verification Tag set 4827 to '0', it SHOULD be processed as described in Section 5.1. If, 4828 for whatever reason, the INIT cannot be processed normally and an 4829 ABORT has to be sent in response, the Verification Tag of the 4830 packet containing the ABORT chunk MUST be the Initiate Tag of the 4831 received INIT chunk, and the T bit of the ABORT chunk has to be 4832 set to 0, indicating that the Verification Tag is not reflected. 4833 Otherwise, 4835 4) If the packet contains a COOKIE ECHO in the first chunk, it MUST 4836 be processed as described in Section 5.1. Otherwise, 4838 5) If the packet contains a SHUTDOWN ACK chunk, the receiver SHOULD 4839 respond to the sender of the OOTB packet with a SHUTDOWN 4840 COMPLETE. When sending the SHUTDOWN COMPLETE, the receiver of 4841 the OOTB packet MUST fill in the Verification Tag field of the 4842 outbound packet with the Verification Tag received in the 4843 SHUTDOWN ACK and set the T bit in the Chunk Flags to indicate 4844 that the Verification Tag is reflected. Otherwise, 4846 6) If the packet contains a SHUTDOWN COMPLETE chunk, the receiver 4847 SHOULD silently discard the packet and take no further action. 4848 Otherwise, 4850 7) If the packet contains a "Stale Cookie" ERROR or a COOKIE ACK, 4851 the SCTP packet SHOULD be silently discarded. Otherwise, 4853 8) The receiver SHOULD respond to the sender of the OOTB packet with 4854 an ABORT. When sending the ABORT, the receiver of the OOTB 4855 packet MUST fill in the Verification Tag field of the outbound 4856 packet with the value found in the Verification Tag field of the 4857 OOTB packet and set the T bit in the Chunk Flags to indicate that 4858 the Verification Tag is reflected. After sending this ABORT, the 4859 receiver of the OOTB packet MUST discard the OOTB packet and MUST 4860 NOT take any further action. 4862 8.5. Verification Tag 4864 The Verification Tag rules defined in this section apply when sending 4865 or receiving SCTP packets that do not contain an INIT, SHUTDOWN 4866 COMPLETE, COOKIE ECHO (see Section 5.1), ABORT, or SHUTDOWN ACK 4867 chunk. The rules for sending and receiving SCTP packets containing 4868 one of these chunk types are discussed separately in Section 8.5.1. 4870 When sending an SCTP packet, the endpoint MUST fill in the 4871 Verification Tag field of the outbound packet with the tag value in 4872 the Initiate Tag parameter of the INIT or INIT ACK received from its 4873 peer. 4875 When receiving an SCTP packet, the endpoint MUST ensure that the 4876 value in the Verification Tag field of the received SCTP packet 4877 matches its own tag. If the received Verification Tag value does not 4878 match the receiver's own tag value, the receiver MUST silently 4879 discard the packet and MUST NOT process it any further except for 4880 those cases listed in Section 8.5.1 below. 4882 8.5.1. Exceptions in Verification Tag Rules 4884 A) Rules for packet carrying INIT: 4885 * The sender MUST set the Verification Tag of the packet to 0. 4887 * When an endpoint receives an SCTP packet with the Verification 4888 Tag set to 0, it SHOULD verify that the packet contains only an 4889 INIT chunk. Otherwise, the receiver MUST silently discard the 4890 packet. 4892 B) Rules for packet carrying ABORT: 4893 * The endpoint MUST always fill in the Verification Tag field of 4894 the outbound packet with the destination endpoint's tag value, 4895 if it is known. 4897 * If the ABORT is sent in response to an OOTB packet, the 4898 endpoint MUST follow the procedure described in Section 8.4. 4900 * The receiver of an ABORT MUST accept the packet if the 4901 Verification Tag field of the packet matches its own tag and 4902 the T bit is not set OR if it is set to its peer's tag and the 4903 T bit is set in the Chunk Flags. Otherwise, the receiver MUST 4904 silently discard the packet and take no further action. 4906 C) Rules for packet carrying SHUTDOWN COMPLETE: 4907 * When sending a SHUTDOWN COMPLETE, if the receiver of the 4908 SHUTDOWN ACK has a TCB, then the destination endpoint's tag 4909 MUST be used, and the T bit MUST NOT be set. Only where no TCB 4910 exists SHOULD the sender use the Verification Tag from the 4911 SHUTDOWN ACK, and MUST set the T bit. 4913 * The receiver of a SHUTDOWN COMPLETE accepts the packet if the 4914 Verification Tag field of the packet matches its own tag and 4915 the T bit is not set OR if it is set to its peer's tag and the 4916 T bit is set in the Chunk Flags. Otherwise, the receiver MUST 4917 silently discard the packet and take no further action. An 4918 endpoint MUST ignore the SHUTDOWN COMPLETE if it is not in the 4919 SHUTDOWN-ACK-SENT state. 4921 D) Rules for packet carrying a COOKIE ECHO: 4923 * When sending a COOKIE ECHO, the endpoint MUST use the value of 4924 the Initiate Tag received in the INIT ACK. 4926 * The receiver of a COOKIE ECHO follows the procedures in 4927 Section 5. 4929 E) Rules for packet carrying a SHUTDOWN ACK: 4930 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the 4931 procedures in Section 8.4 SHOULD be followed; in other words, 4932 it is treated as an Out Of The Blue packet. 4934 9. Termination of Association 4936 An endpoint SHOULD terminate its association when it exits from 4937 service. An association can be terminated by either abort or 4938 shutdown. An abort of an association is abortive by definition in 4939 that any data pending on either end of the association is discarded 4940 and not delivered to the peer. A shutdown of an association is 4941 considered a graceful close where all data in queue by either 4942 endpoint is delivered to the respective peers. However, in the case 4943 of a shutdown, SCTP does not support a half-open state (like TCP) 4944 wherein one side might continue sending data while the other end is 4945 closed. When either endpoint performs a shutdown, the association on 4946 each peer will stop accepting new data from its user and only deliver 4947 data in queue at the time of sending or receiving the SHUTDOWN chunk. 4949 9.1. Abort of an Association 4951 When an endpoint decides to abort an existing association, it MUST 4952 send an ABORT chunk to its peer endpoint. The sender MUST fill in 4953 the peer's Verification Tag in the outbound packet and MUST NOT 4954 bundle any DATA chunk with the ABORT. If the association is aborted 4955 on request of the upper layer, a "User-Initiated Abort" error cause 4956 (see Section 3.3.10.12) SHOULD be present in the ABORT chunk. 4958 An endpoint MUST NOT respond to any received packet that contains an 4959 ABORT chunk (also see Section 8.4). 4961 An endpoint receiving an ABORT MUST apply the special Verification 4962 Tag check rules described in Section 8.5.1. 4964 After checking the Verification Tag, the receiving endpoint MUST 4965 remove the association from its record and SHOULD report the 4966 termination to its upper layer. If a "User-Initiated Abort" error 4967 cause is present in the ABORT chunk, the Upper Layer Abort Reason 4968 SHOULD be made available to the upper layer. 4970 9.2. Shutdown of an Association 4972 Using the SHUTDOWN primitive (see Section 11.1), the upper layer of 4973 an endpoint in an association can gracefully close the association. 4974 This will allow all outstanding DATA chunks from the peer of the 4975 shutdown initiator to be delivered before the association terminates. 4977 Upon receipt of the SHUTDOWN primitive from its upper layer, the 4978 endpoint enters the SHUTDOWN-PENDING state and remains there until 4979 all outstanding data has been acknowledged by its peer. The endpoint 4980 accepts no new data from its upper layer, but retransmits data to the 4981 peer endpoint if necessary to fill gaps. 4983 Once all its outstanding data has been acknowledged, the endpoint 4984 sends a SHUTDOWN chunk to its peer including in the Cumulative TSN 4985 Ack field the last sequential TSN it has received from the peer. It 4986 SHOULD then start the T2-shutdown timer and enter the SHUTDOWN-SENT 4987 state. If the timer expires, the endpoint MUST resend the SHUTDOWN 4988 with the updated last sequential TSN received from its peer. 4990 The rules in Section 6.3 MUST be followed to determine the proper 4991 timer value for T2-shutdown. To indicate any gaps in TSN, the 4992 endpoint MAY also bundle a SACK with the SHUTDOWN chunk in the same 4993 SCTP packet. 4995 An endpoint SHOULD limit the number of retransmissions of the 4996 SHUTDOWN chunk to the protocol parameter 'Association.Max.Retrans'. 4997 If this threshold is exceeded, the endpoint SHOULD destroy the TCB 4998 and SHOULD report the peer endpoint unreachable to the upper layer 4999 (and thus the association enters the CLOSED state). The reception of 5000 any packet from its peer (i.e., as the peer sends all of its queued 5001 DATA chunks) SHOULD clear the endpoint's retransmission count and 5002 restart the T2-shutdown timer, giving its peer ample opportunity to 5003 transmit all of its queued DATA chunks that have not yet been sent. 5005 Upon reception of the SHUTDOWN, the peer endpoint does the following: 5007 * enter the SHUTDOWN-RECEIVED state, 5009 * stop accepting new data from its SCTP user, and 5011 * verify, by checking the Cumulative TSN Ack field of the chunk, 5012 that all its outstanding DATA chunks have been received by the 5013 SHUTDOWN sender. 5015 Once an endpoint has reached the SHUTDOWN-RECEIVED state, it MUST 5016 ignore ULP shutdown requests but MUST continue responding to SHUTDOWN 5017 chunks from its peer. 5019 If there are still outstanding DATA chunks left, the SHUTDOWN 5020 receiver MUST continue to follow normal data transmission procedures 5021 defined in Section 6, until all outstanding DATA chunks are 5022 acknowledged; however, the SHUTDOWN receiver MUST NOT accept new data 5023 from its SCTP user. 5025 While in the SHUTDOWN-SENT state, the SHUTDOWN sender MUST 5026 immediately respond to each received packet containing one or more 5027 DATA chunks with a SHUTDOWN chunk and restart the T2-shutdown timer. 5028 If a SHUTDOWN chunk by itself cannot acknowledge all of the received 5029 DATA chunks (i.e., there are TSNs that can be acknowledged that are 5030 larger than the cumulative TSN, and thus gaps exist in the TSN 5031 sequence), or if duplicate TSNs have been received, then a SACK chunk 5032 MUST also be sent. 5034 The sender of the SHUTDOWN MAY also start an overall guard timer 'T5- 5035 shutdown-guard' to bound the overall time for the shutdown sequence. 5036 At the expiration of this timer, the sender SHOULD abort the 5037 association by sending an ABORT chunk. If the 'T5-shutdown-guard' 5038 timer is used, it SHOULD be set to the RECOMMENDED value of 5 times 5039 'RTO.Max'. 5041 If the receiver of the SHUTDOWN has no more outstanding DATA chunks, 5042 the SHUTDOWN receiver MUST send a SHUTDOWN ACK and start a 5043 T2-shutdown timer of its own, entering the SHUTDOWN-ACK-SENT state. 5044 If the timer expires, the endpoint MUST resend the SHUTDOWN ACK. 5046 The sender of the SHUTDOWN ACK SHOULD limit the number of 5047 retransmissions of the SHUTDOWN ACK chunk to the protocol parameter 5048 'Association.Max.Retrans'. If this threshold is exceeded, the 5049 endpoint SHOULD destroy the TCB and SHOULD report the peer endpoint 5050 unreachable to the upper layer (and thus the association enters the 5051 CLOSED state). 5053 Upon the receipt of the SHUTDOWN ACK, the SHUTDOWN sender MUST stop 5054 the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its peer, 5055 and remove all record of the association. 5057 Upon reception of the SHUTDOWN COMPLETE chunk, the endpoint verifies 5058 that it is in the SHUTDOWN-ACK-SENT state; if it is not, the chunk 5059 SHOULD be discarded. If the endpoint is in the SHUTDOWN-ACK-SENT 5060 state, the endpoint SHOULD stop the T2-shutdown timer and remove all 5061 knowledge of the association (and thus the association enters the 5062 CLOSED state). 5064 An endpoint SHOULD ensure that all its outstanding DATA chunks have 5065 been acknowledged before initiating the shutdown procedure. 5067 An endpoint SHOULD reject any new data request from its upper layer 5068 if it is in the SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED, 5069 or SHUTDOWN-ACK-SENT state. 5071 If an endpoint is in the SHUTDOWN-ACK-SENT state and receives an INIT 5072 chunk (e.g., if the SHUTDOWN COMPLETE was lost) with source and 5073 destination transport addresses (either in the IP addresses or in the 5074 INIT chunk) that belong to this association, it SHOULD discard the 5075 INIT chunk and retransmit the SHUTDOWN ACK chunk. 5077 Note: Receipt of an INIT with the same source and destination IP 5078 addresses as used in transport addresses assigned to an endpoint but 5079 with a different port number indicates the initialization of a 5080 separate association. 5082 The sender of the INIT or COOKIE ECHO SHOULD respond to the receipt 5083 of a SHUTDOWN ACK with a stand-alone SHUTDOWN COMPLETE in an SCTP 5084 packet with the Verification Tag field of its common header set to 5085 the same tag that was received in the SHUTDOWN ACK packet. This is 5086 considered an Out of the Blue packet as defined in Section 8.4. The 5087 sender of the INIT lets T1-init continue running and remains in the 5088 COOKIE-WAIT or COOKIE-ECHOED state. Normal T1-init timer expiration 5089 will cause the INIT or COOKIE chunk to be retransmitted and thus 5090 start a new association. 5092 If a SHUTDOWN is received in the COOKIE-WAIT or COOKIE ECHOED state, 5093 the SHUTDOWN chunk SHOULD be silently discarded. 5095 If an endpoint is in the SHUTDOWN-SENT state and receives a SHUTDOWN 5096 chunk from its peer, the endpoint SHOULD respond immediately with a 5097 SHUTDOWN ACK to its peer, and move into the SHUTDOWN-ACK-SENT state 5098 restarting its T2-shutdown timer. 5100 If an endpoint is in the SHUTDOWN-ACK-SENT state and receives a 5101 SHUTDOWN ACK, it MUST stop the T2-shutdown timer, send a SHUTDOWN 5102 COMPLETE chunk to its peer, and remove all record of the association. 5104 10. ICMP Handling 5106 Whenever an ICMP message is received by an SCTP endpoint, the 5107 following procedures MUST be followed to ensure proper utilization of 5108 the information being provided by layer 3. 5110 ICMP1) An implementation MAY ignore all ICMPv4 messages where the 5111 type field is not set to "Destination Unreachable". 5113 ICMP2) An implementation MAY ignore all ICMPv6 messages where the 5114 type field is not "Destination Unreachable", "Parameter 5115 Problem", or "Packet Too Big". 5117 ICMP3) An implementation SHOULD ignore any ICMP messages where the 5118 code indicates "Port Unreachable". 5120 ICMP4) An implementation MAY ignore all ICMPv6 messages of type 5121 "Parameter Problem" if the code is not "Unrecognized Next 5122 Header Type Encountered". 5124 ICMP5) An implementation MUST use the payload of the ICMP message 5125 (v4 or v6) to locate the association that sent the message to 5126 which ICMP is responding. If the association cannot be 5127 found, an implementation SHOULD ignore the ICMP message. 5129 ICMP6) An implementation MUST validate that the Verification Tag 5130 contained in the ICMP message matches the Verification Tag of 5131 the peer. If the Verification Tag is not 0 and does not 5132 match, discard the ICMP message. If it is 0 and the ICMP 5133 message contains enough bytes to verify that the chunk type 5134 is an INIT chunk and that the Initiate Tag matches the tag of 5135 the peer, continue with ICMP7. If the ICMP message is too 5136 short or the chunk type or the Initiate Tag does not match, 5137 silently discard the packet. 5139 ICMP7) If the ICMP message is either a v6 "Packet Too Big" or a v4 5140 "Fragmentation Needed", an implementation MAY process this 5141 information as defined for PMTU discovery. 5143 ICMP8) If the ICMP code is an "Unrecognized Next Header Type 5144 Encountered" or a "Protocol Unreachable", an implementation 5145 MUST treat this message as an abort with the T bit set if it 5146 does not contain an INIT chunk. If it does contain an INIT 5147 chunk and the association is in the COOKIE-WAIT state, handle 5148 the ICMP message like an ABORT. 5150 ICMP9) If the ICMP type is "Destination Unreachable", the 5151 implementation MAY move the destination to the unreachable 5152 state or, alternatively, increment the path error counter. 5153 SCTP MAY provide information to the upper layer indicating 5154 the reception of ICMP messages when reporting a network 5155 status change. 5157 These procedures differ from [RFC1122] and from its requirements for 5158 processing of port-unreachable messages and the requirements that an 5159 implementation MUST abort associations in response to a "protocol 5160 unreachable" message. Port-unreachable messages are not processed, 5161 since an implementation will send an ABORT, not a port unreachable. 5162 The stricter handling of the "protocol unreachable" message is due to 5163 security concerns for hosts that do not support SCTP. 5165 11. Interface with Upper Layer 5167 The Upper Layer Protocols (ULPs) request services by passing 5168 primitives to SCTP and receive notifications from SCTP for various 5169 events. 5171 The primitives and notifications described in this section can be 5172 used as a guideline for implementing SCTP. The following functional 5173 description of ULP interface primitives is shown for illustrative 5174 purposes. Different SCTP implementations can have different ULP 5175 interfaces. However, all SCTP implementations are expected to 5176 provide a certain minimum set of services to guarantee that all SCTP 5177 implementations can support the same protocol hierarchy. 5179 Please note that this section is informational only. 5181 [RFC6458] and the Socket API Considerations section of [RFC7053] 5182 define an extension of the socket API for SCTP as described in this 5183 document. 5185 11.1. ULP-to-SCTP 5187 The following sections functionally characterize a ULP/SCTP 5188 interface. The notation used is similar to most procedure or 5189 function calls in high-level languages. 5191 The ULP primitives described below specify the basic functions that 5192 SCTP performs to support inter-process communication. Individual 5193 implementations define their own exact format, and provide 5194 combinations or subsets of the basic functions in single calls. 5196 11.1.1. Initialize 5198 INITIALIZE ([local port],[local eligible address list]) 5199 -> local SCTP instance name 5201 This primitive allows SCTP to initialize its internal data structures 5202 and allocate necessary resources for setting up its operation 5203 environment. Once SCTP is initialized, ULP can communicate directly 5204 with other endpoints without re-invoking this primitive. 5206 SCTP will return a local SCTP instance name to the ULP. 5208 Mandatory attributes: 5210 None. 5212 Optional attributes: 5213 local port: SCTP port number, if ULP wants it to be specified. 5215 local eligible address list: an address list that the local SCTP 5216 endpoint binds. By default, if an address list is not 5217 included, all IP addresses assigned to the host are used by the 5218 local endpoint. 5220 IMPLEMENTATION NOTE: If this optional attribute is supported by an 5221 implementation, it will be the responsibility of the implementation 5222 to enforce that the IP source address field of any SCTP packets sent 5223 out by this endpoint contains one of the IP addresses indicated in 5224 the local eligible address list. 5226 11.1.2. Associate 5228 ASSOCIATE(local SCTP instance name, 5229 initial destination transport addr list, outbound stream count) 5230 -> association id [,destination transport addr list] 5231 [,outbound stream count] 5233 This primitive allows the upper layer to initiate an association to a 5234 specific peer endpoint. 5236 The peer endpoint is specified by one or more of the transport 5237 addresses that defines the endpoint (see Section 2.3). If the local 5238 SCTP instance has not been initialized, the ASSOCIATE is considered 5239 an error. 5241 An association id, which is a local handle to the SCTP association, 5242 will be returned on successful establishment of the association. If 5243 SCTP is not able to open an SCTP association with the peer endpoint, 5244 an error is returned. 5246 Other association parameters can be returned, including the complete 5247 destination transport addresses of the peer as well as the outbound 5248 stream count of the local endpoint. One of the transport addresses 5249 from the returned destination addresses will be selected by the local 5250 endpoint as default primary path for sending SCTP packets to this 5251 peer. The returned "destination transport addr list" can be used by 5252 the ULP to change the default primary path or to force sending a 5253 packet to a specific transport address. 5255 IMPLEMENTATION NOTE: If ASSOCIATE primitive is implemented as a 5256 blocking function call, the ASSOCIATE primitive can return 5257 association parameters in addition to the association id upon 5258 successful establishment. If ASSOCIATE primitive is implemented as a 5259 non-blocking call, only the association id is returned and 5260 association parameters are passed using the COMMUNICATION UP 5261 notification. 5263 Mandatory attributes: 5264 local SCTP instance name: obtained from the INITIALIZE operation. 5266 initial destination transport addr list: a non-empty list of 5267 transport addresses of the peer endpoint with which the 5268 association is to be established. 5270 outbound stream count: the number of outbound streams the ULP 5271 would like to open towards this peer endpoint. 5273 Optional attributes: 5274 None. 5276 11.1.3. Shutdown 5278 SHUTDOWN(association id) -> result 5280 Gracefully closes an association. Any locally queued user data will 5281 be delivered to the peer. The association will be terminated only 5282 after the peer acknowledges all the SCTP packets sent. A success 5283 code will be returned on successful termination of the association. 5284 If attempting to terminate the association results in a failure, an 5285 error code is returned. 5287 Mandatory attributes: 5288 association id: local handle to the SCTP association. 5290 Optional attributes: 5291 None. 5293 11.1.4. Abort 5295 ABORT(association id [, Upper Layer Abort Reason]) -> result 5297 Ungracefully closes an association. Any locally queued user data 5298 will be discarded, and an ABORT chunk is sent to the peer. A success 5299 code will be returned on successful abort of the association. If 5300 attempting to abort the association results in a failure, an error 5301 code is returned. 5303 Mandatory attributes: 5304 association id: local handle to the SCTP association. 5306 Optional attributes: 5307 Upper Layer Abort Reason: reason of the abort to be passed to the 5308 peer. 5310 11.1.5. Send 5312 SEND(association id, buffer address, byte count [,context] 5313 [,stream id] [,life time] [,destination transport address] 5314 [,unordered flag] [,no-bundle flag] [,payload protocol-id] 5315 [,sack-immediately flag]) -> result 5317 This is the main method to send user data via SCTP. 5319 Mandatory attributes: 5320 association id: local handle to the SCTP association. 5322 buffer address: the location where the user message to be 5323 transmitted is stored. 5325 byte count: the size of the user data in number of bytes. 5327 Optional attributes: 5328 context: an optional 32-bit integer that will be carried in the 5329 sending failure notification to the ULP if the transportation 5330 of this user message fails. 5332 stream id: to indicate which stream to send the data on. If not 5333 specified, stream 0 will be used. 5335 life time: specifies the life time of the user data. The user 5336 data will not be sent by SCTP after the life time expires. 5337 This parameter can be used to avoid efforts to transmit stale 5338 user messages. SCTP notifies the ULP if the data cannot be 5339 initiated to transport (i.e., sent to the destination via 5340 SCTP's SEND primitive) within the life time variable. However, 5341 the user data will be transmitted if SCTP has attempted to 5342 transmit a chunk before the life time expired. 5344 IMPLEMENTATION NOTE: In order to better support the data life 5345 time option, the transmitter can hold back the assigning of the 5346 TSN number to an outbound DATA chunk to the last moment. And, 5347 for implementation simplicity, once a TSN number has been 5348 assigned the sender considers the send of this DATA chunk as 5349 committed, overriding any life time option attached to the DATA 5350 chunk. 5352 destination transport address: specified as one of the 5353 destination transport addresses of the peer endpoint to which 5354 this packet is sent. Whenever possible, SCTP uses this 5355 destination transport address for sending the packets, instead 5356 of the current primary path. 5358 unordered flag: this flag, if present, indicates that the user 5359 would like the data delivered in an unordered fashion to the 5360 peer (i.e., the U flag is set to 1 on all DATA chunks carrying 5361 this message). 5363 no-bundle flag: instructs SCTP not to delay the sending of DATA 5364 chunks for this user data just to allow it to be bundled with 5365 other outbound DATA chunks. When faced with network 5366 congestion, SCTP might still bundle the data, even when this 5367 flag is present. 5369 payload protocol-id: a 32-bit unsigned integer that is to be 5370 passed to the peer indicating the type of payload protocol data 5371 being transmitted. This value is passed as opaque data by 5372 SCTP. 5374 sack-immediately flag: set the I bit on the last DATA chunk used 5375 for the user message to be transmitted. 5377 11.1.6. Set Primary 5379 SETPRIMARY(association id, destination transport address, 5380 [source transport address]) -> result 5382 Instructs the local SCTP to use the specified destination transport 5383 address as the primary path for sending packets. 5385 The result of attempting this operation is returned. If the 5386 specified destination transport address is not present in the 5387 "destination transport address list" returned earlier in an associate 5388 command or communication up notification, an error is returned. 5390 Mandatory attributes: 5391 association id: local handle to the SCTP association. 5393 destination transport address: specified as one of the transport 5394 addresses of the peer endpoint, which is used as the primary 5395 address for sending packets. This overrides the current 5396 primary address information maintained by the local SCTP 5397 endpoint. 5399 Optional attributes: 5400 source transport address: optionally, some implementations can 5401 allow you to set the default source address placed in all 5402 outgoing IP datagrams. 5404 11.1.7. Receive 5406 RECEIVE(association id, buffer address, buffer size [,stream id]) 5407 -> byte count [,transport address] [,stream id] 5408 [,stream sequence number] [,partial flag] [,payload protocol-id] 5410 This primitive reads the first user message in the SCTP in-queue into 5411 the buffer specified by ULP, if there is one available. The size of 5412 the message read, in bytes, will be returned. It might, depending on 5413 the specific implementation, also return other information such as 5414 the sender's address, the stream id on which it is received, whether 5415 there are more messages available for retrieval, etc. For ordered 5416 messages, their Stream Sequence Number might also be returned. 5418 Depending upon the implementation, if this primitive is invoked when 5419 no message is available the implementation returns an indication of 5420 this condition or blocks the invoking process until data does become 5421 available. 5423 Mandatory attributes: 5424 association id: local handle to the SCTP association 5426 buffer address: the memory location indicated by the ULP to store 5427 the received message. 5429 buffer size: the maximum size of data to be received, in bytes. 5431 Optional attributes: 5432 stream id: to indicate which stream to receive the data on. 5434 stream sequence number: the Stream Sequence Number assigned by 5435 the sending SCTP peer. 5437 partial flag: if this returned flag is set to 1, then this 5438 primitive contains a partial delivery of the whole message. 5439 When this flag is set, the stream id and stream sequence number 5440 accompanies this primitive. When this flag is set to 0, it 5441 indicates that no more deliveries will be received for this 5442 stream sequence number. 5444 payload protocol-id: a 32-bit unsigned integer that is received 5445 from the peer indicating the type of payload protocol of the 5446 received data. This value is passed as opaque data by SCTP. 5448 11.1.8. Status 5450 STATUS(association id) -> status data 5452 This primitive returns a data block containing the following 5453 information: 5455 * association connection state, 5457 * destination transport address list, 5459 * destination transport address reachability states, 5461 * current receiver window size, 5463 * current congestion window sizes, 5465 * number of unacknowledged DATA chunks, 5467 * number of DATA chunks pending receipt, 5469 * primary path, 5471 * most recent SRTT on primary path, 5473 * RTO on primary path, 5475 * SRTT and RTO on other destination addresses, etc. 5477 Mandatory attributes: 5478 association id: local handle to the SCTP association. 5480 Optional attributes: 5481 None. 5483 11.1.9. Change Heartbeat 5485 CHANGE HEARTBEAT(association id, destination transport address, 5486 new state [,interval]) -> result 5488 Instructs the local endpoint to enable or disable heartbeat on the 5489 specified destination transport address. 5491 The result of attempting this operation is returned. 5493 Note: Even when enabled, heartbeat will not take place if the 5494 destination transport address is not idle. 5496 Mandatory attributes: 5497 association id: local handle to the SCTP association. 5499 destination transport address: specified as one of the transport 5500 addresses of the peer endpoint. 5502 new state: the new state of heartbeat for this destination 5503 transport address (either enabled or disabled). 5505 Optional attributes: 5506 interval: if present, indicates the frequency of the heartbeat if 5507 this is to enable heartbeat on a destination transport address. 5508 This value is added to the RTO of the destination transport 5509 address. This value, if present, affects all destinations. 5511 11.1.10. Request Heartbeat 5513 REQUESTHEARTBEAT(association id, destination transport address) 5514 -> result 5516 Instructs the local endpoint to perform a heartbeat on the specified 5517 destination transport address of the given association. The returned 5518 result indicates whether the transmission of the HEARTBEAT chunk to 5519 the destination address is successful. 5521 Mandatory attributes: 5522 association id: local handle to the SCTP association. 5524 destination transport address: the transport address of the 5525 association on which a heartbeat is issued. 5527 Optional attributes: 5528 None. 5530 11.1.11. Get SRTT Report 5532 GETSRTTREPORT(association id, destination transport address) 5533 -> srtt result 5535 Instructs the local SCTP to report the current SRTT measurement on 5536 the specified destination transport address of the given association. 5537 The returned result can be an integer containing the most recent SRTT 5538 in milliseconds. 5540 Mandatory attributes: 5541 association id: local handle to the SCTP association. 5543 destination transport address: the transport address of the 5544 association on which the SRTT measurement is to be reported. 5546 Optional attributes: 5547 None. 5549 11.1.12. Set Failure Threshold 5551 SETFAILURETHRESHOLD(association id, destination transport address, 5552 failure threshold) -> result 5554 This primitive allows the local SCTP to customize the reachability 5555 failure detection threshold 'Path.Max.Retrans' for the specified 5556 destination address. 5558 Mandatory attributes: 5559 association id: local handle to the SCTP association. 5561 destination transport address: the transport address of the 5562 association on which the failure detection threshold is to be 5563 set. 5565 failure threshold: the new value of 'Path.Max.Retrans' for the 5566 destination address. 5568 Optional attributes: 5569 None. 5571 11.1.13. Set Protocol Parameters 5573 SETPROTOCOLPARAMETERS(association id, 5574 [destination transport address,] protocol parameter list) 5575 -> result 5577 This primitive allows the local SCTP to customize the protocol 5578 parameters. 5580 Mandatory attributes: 5581 association id: local handle to the SCTP association. 5583 protocol parameter list: the specific names and values of the 5584 protocol parameters (e.g., 'Association.Max.Retrans' (see 5585 Section 16), or other parameters like the DSCP) that the SCTP 5586 user wishes to customize. 5588 Optional attributes: 5589 destination transport address: some of the protocol parameters 5590 might be set on a per destination transport address basis. 5592 11.1.14. Receive Unsent Message 5594 RECEIVE_UNSENT(data retrieval id, buffer address, buffer size 5595 [,stream id] [, stream sequence number] [,partial flag] 5596 [,payload protocol-id]) 5598 This primitive reads a user message, which has never been sent, into 5599 the buffer specified by ULP. 5601 Mandatory attributes: 5602 data retrieval id: the identification passed to the ULP in the 5603 failure notification. 5605 buffer address: the memory location indicated by the ULP to store 5606 the received message. 5608 buffer size: the maximum size of data to be received, in bytes. 5610 Optional attributes: 5611 stream id: this is a return value that is set to indicate which 5612 stream the data was sent to. 5614 stream sequence number: this value is returned indicating the 5615 Stream Sequence Number that was associated with the message. 5617 partial flag: if this returned flag is set to 1, then this 5618 message is a partial delivery of the whole message. When this 5619 flag is set, the stream id and stream sequence number 5620 accompanies this primitive. When this flag is set to 0, it 5621 indicates that no more deliveries will be received for this 5622 stream sequence number. 5624 payload protocol-id: The 32 bit unsigned integer that was set to 5625 be sent to the peer indicating the type of payload protocol of 5626 the received data. 5628 11.1.15. Receive Unacknowledged Message 5630 RECEIVE_UNACKED(data retrieval id, buffer address, buffer size, 5631 [,stream id] [,stream sequence number] [,partial flag] 5632 [,payload protocol-id]) 5634 This primitive reads a user message, which has been sent and has not 5635 been acknowledged by the peer, into the buffer specified by ULP. 5637 Mandatory attributes: 5638 data retrieval id: the identification passed to the ULP in the 5639 failure notification. 5641 buffer address: the memory location indicated by the ULP to store 5642 the received message. 5644 buffer size: the maximum size of data to be received, in bytes. 5646 Optional attributes: 5647 stream id: this is a return value that is set to indicate which 5648 stream the data was sent to. 5650 stream sequence number: this value is returned indicating the 5651 Stream Sequence Number that was associated with the message. 5653 partial flag: if this returned flag is set to 1, then this 5654 message is a partial delivery of the whole message. When this 5655 flag is set, the stream id and stream sequence number 5656 accompanies this primitive. When this flag is set to 0, it 5657 indicates that no more deliveries will be received for this 5658 stream sequence number. 5660 payload protocol-id: the 32-bit unsigned integer that was sent to 5661 the peer indicating the type of payload protocol of the 5662 received data. 5664 11.1.16. Destroy SCTP Instance 5666 DESTROY(local SCTP instance name) 5668 Mandatory attributes: 5669 local SCTP instance name: this is the value that was passed to 5670 the application in the initialize primitive and it indicates 5671 which SCTP instance is to be destroyed. 5673 Optional attributes: 5674 None. 5676 11.2. SCTP-to-ULP 5678 It is assumed that the operating system or application environment 5679 provides a means for the SCTP to asynchronously signal the ULP 5680 process. When SCTP does signal a ULP process, certain information is 5681 passed to the ULP. 5683 IMPLEMENTATION NOTE: In some cases, this might be done through a 5684 separate socket or error channel. 5686 11.2.1. DATA ARRIVE Notification 5688 SCTP invokes this notification on the ULP when a user message is 5689 successfully received and ready for retrieval. 5691 The following might optionally be passed with the notification: 5693 association id: local handle to the SCTP association. 5695 stream id: to indicate which stream the data is received on. 5697 11.2.2. SEND FAILURE Notification 5699 If a message cannot be delivered, SCTP invokes this notification on 5700 the ULP. 5702 The following might optionally be passed with the notification: 5704 association id: local handle to the SCTP association. 5706 data retrieval id: an identification used to retrieve unsent and 5707 unacknowledged data. 5709 cause code: indicating the reason of the failure, e.g., size too 5710 large, message life time expiration, etc. 5712 context: optional information associated with this message (see 5713 Section 11.1.5). 5715 11.2.3. NETWORK STATUS CHANGE Notification 5717 When a destination transport address is marked inactive (e.g., when 5718 SCTP detects a failure) or marked active (e.g., when SCTP detects a 5719 recovery), SCTP invokes this notification on the ULP. 5721 The following is passed with the notification: 5723 association id: local handle to the SCTP association. 5725 destination transport address: this indicates the destination 5726 transport address of the peer endpoint affected by the change. 5728 new-status: this indicates the new status. 5730 11.2.4. COMMUNICATION UP Notification 5732 This notification is used when SCTP becomes ready to send or receive 5733 user messages, or when a lost communication to an endpoint is 5734 restored. 5736 IMPLEMENTATION NOTE: If the ASSOCIATE primitive is implemented as a 5737 blocking function call, the association parameters are returned as a 5738 result of the ASSOCIATE primitive itself. In that case, 5739 COMMUNICATION UP notification is optional at the association 5740 initiator's side. 5742 The following is passed with the notification: 5744 association id: local handle to the SCTP association. 5746 status: This indicates what type of event has occurred. 5748 destination transport address list: the complete set of transport 5749 addresses of the peer. 5751 outbound stream count: the maximum number of streams allowed to be 5752 used in this association by the ULP. 5754 inbound stream count: the number of streams the peer endpoint has 5755 requested with this association (this might not be the same number 5756 as 'outbound stream count'). 5758 11.2.5. COMMUNICATION LOST Notification 5760 When SCTP loses communication to an endpoint completely (e.g., via 5761 Heartbeats) or detects that the endpoint has performed an abort 5762 operation, it invokes this notification on the ULP. 5764 The following is passed with the notification: 5766 association id: local handle to the SCTP association. 5768 status: this indicates what type of event has occurred; the status 5769 might indicate that a failure OR a normal termination event 5770 occurred in response to a shutdown or abort request. 5772 The following might be passed with the notification: 5774 data retrieval id: an identification used to retrieve unsent and 5775 unacknowledged data. 5777 last-acked: the TSN last acked by that peer endpoint. 5779 last-sent: the TSN last sent to that peer endpoint. 5781 Upper Layer Abort Reason: the abort reason specified in case of a 5782 user-initiated abort. 5784 11.2.6. COMMUNICATION ERROR Notification 5786 When SCTP receives an ERROR chunk from its peer and decides to notify 5787 its ULP, it can invoke this notification on the ULP. 5789 The following can be passed with the notification: 5791 association id: local handle to the SCTP association. 5793 error info: this indicates the type of error and optionally some 5794 additional information received through the ERROR chunk. 5796 11.2.7. RESTART Notification 5798 When SCTP detects that the peer has restarted, it might send this 5799 notification to its ULP. 5801 The following can be passed with the notification: 5803 association id: local handle to the SCTP association. 5805 11.2.8. SHUTDOWN COMPLETE Notification 5807 When SCTP completes the shutdown procedures (Section 9.2), this 5808 notification is passed to the upper layer. 5810 The following can be passed with the notification: 5812 association id: local handle to the SCTP association. 5814 12. Security Considerations 5816 12.1. Security Objectives 5818 As a common transport protocol designed to reliably carry time- 5819 sensitive user messages, such as billing or signaling messages for 5820 telephony services, between two networked endpoints, SCTP has the 5821 following security objectives. 5823 * availability of reliable and timely data transport services 5825 * integrity of the user-to-user information carried by SCTP 5827 12.2. SCTP Responses to Potential Threats 5829 SCTP could potentially be used in a wide variety of risk situations. 5830 It is important for operators of systems running SCTP to analyze 5831 their particular situations and decide on the appropriate counter- 5832 measures. 5834 Operators of systems running SCTP might consult [RFC2196] for 5835 guidance in securing their site. 5837 12.2.1. Countering Insider Attacks 5839 The principles of [RFC2196] might be applied to minimize the risk of 5840 theft of information or sabotage by insiders. Such procedures 5841 include publication of security policies, control of access at the 5842 physical, software, and network levels, and separation of services. 5844 12.2.2. Protecting against Data Corruption in the Network 5846 Where the risk of undetected errors in datagrams delivered by the 5847 lower-layer transport services is considered to be too great, 5848 additional integrity protection is required. If this additional 5849 protection were provided in the application layer, the SCTP header 5850 would remain vulnerable to deliberate integrity attacks. While the 5851 existing SCTP mechanisms for detection of packet replays are 5852 considered sufficient for normal operation, stronger protections are 5853 needed to protect SCTP when the operating environment contains 5854 significant risk of deliberate attacks from a sophisticated 5855 adversary. 5857 The SCTP Authentication extension SCTP-AUTH [RFC4895] MAY be used 5858 when the threat environment requires stronger integrity protections, 5859 but does not require confidentiality. 5861 12.2.3. Protecting Confidentiality 5863 In most cases, the risk of breach of confidentiality applies to the 5864 signaling data payload, not to the SCTP or lower-layer protocol 5865 overheads. If that is true, encryption of the SCTP user data only 5866 might be considered. As with the supplementary checksum service, 5867 user data encryption MAY be performed by the SCTP user application. 5868 Alternately, the user application MAY use an implementation-specific 5869 API to request that the IP Encapsulating Security Payload (ESP) 5870 [RFC4303] be used to provide confidentiality and integrity. 5872 Particularly for mobile users, the requirement for confidentiality 5873 might include the masking of IP addresses and ports. In this case, 5874 ESP SHOULD be used instead of application-level confidentiality. If 5875 ESP is used to protect confidentiality of SCTP traffic, an ESP 5876 cryptographic transform that includes cryptographic integrity 5877 protection MUST be used, because if there is a confidentiality threat 5878 there will also be a strong integrity threat. 5880 Whenever ESP is in use, application-level encryption is not generally 5881 required. 5883 Regardless of where confidentiality is provided, the Internet Key 5884 Exchange Protocol version 2 (IKEv2) [RFC7296] SHOULD be used for key 5885 management. 5887 Operators might consult [RFC4301] for more information on the 5888 security services available at and immediately above the Internet 5889 Protocol layer. 5891 12.2.4. Protecting against Blind Denial-of-Service Attacks 5893 A blind attack is one where the attacker is unable to intercept or 5894 otherwise see the content of data flows passing to and from the 5895 target SCTP node. Blind denial-of-service attacks can take the form 5896 of flooding, masquerade, or improper monopolization of services. 5898 12.2.4.1. Flooding 5900 The objective of flooding is to cause loss of service and incorrect 5901 behavior at target systems through resource exhaustion, interference 5902 with legitimate transactions, and exploitation of buffer-related 5903 software bugs. Flooding can be directed either at the SCTP node or 5904 at resources in the intervening IP Access Links or the Internet. 5905 Where the latter entities are the target, flooding will manifest 5906 itself as loss of network services, including potentially the breach 5907 of any firewalls in place. 5909 In general, protection against flooding begins at the equipment 5910 design level, where it includes measures such as: 5912 * avoiding commitment of limited resources before determining that 5913 the request for service is legitimate. 5915 * giving priority to completion of processing in progress over the 5916 acceptance of new work. 5918 * identification and removal of duplicate or stale queued requests 5919 for service. 5921 * not responding to unexpected packets sent to non-unicast 5922 addresses. 5924 Network equipment is expected to be capable of generating an alarm 5925 and log if a suspicious increase in traffic occurs. The log provides 5926 information such as the identity of the incoming link and source 5927 address(es) used, which will help the network or SCTP system operator 5928 to take protective measures. Procedures are expected to be in place 5929 for the operator to act on such alarms if a clear pattern of abuse 5930 emerges. 5932 The design of SCTP is resistant to flooding attacks, particularly in 5933 its use of a four-way startup handshake, its use of a cookie to defer 5934 commitment of resources at the responding SCTP node until the 5935 handshake is completed, and its use of a Verification Tag to prevent 5936 insertion of extraneous packets into the flow of an established 5937 association. 5939 The IP Authentication Header and Encapsulating Security Payload might 5940 be useful in reducing the risk of certain kinds of denial-of-service 5941 attacks. 5943 Support for the Host Name Address parameter has been removed from the 5944 protocol. Endpoints receiving INIT or INIT ACK chunks containing the 5945 Host Name Address parameter MUST send an ABORT chunk in response and 5946 MAY include an "Unresolvable Address" error cause. 5948 12.2.4.2. Blind Masquerade 5950 Masquerade can be used to deny service in several ways: 5952 * by tying up resources at the target SCTP node to which the 5953 impersonated node has limited access. For example, the target 5954 node can by policy permit a maximum of one SCTP association with 5955 the impersonated SCTP node. The masquerading attacker can attempt 5956 to establish an association purporting to come from the 5957 impersonated node so that the latter cannot do so when it requires 5958 it. 5960 * by deliberately allowing the impersonation to be detected, thereby 5961 provoking counter-measures that cause the impersonated node to be 5962 locked out of the target SCTP node. 5964 * by interfering with an established association by inserting 5965 extraneous content such as a SHUTDOWN request. 5967 SCTP reduces the risk of blind masquerade attacks through IP spoofing 5968 by use of the four-way startup handshake. Because the initial 5969 exchange is memory-less, no lockout mechanism is triggered by blind 5970 masquerade attacks. In addition, the INIT ACK containing the State 5971 Cookie is transmitted back to the IP address from which it received 5972 the INIT. Thus, the attacker would not receive the INIT ACK 5973 containing the State Cookie. SCTP protects against insertion of 5974 extraneous packets into the flow of an established association by use 5975 of the Verification Tag. 5977 Logging of received INIT requests and abnormalities such as 5978 unexpected INIT ACKs might be considered as a way to detect patterns 5979 of hostile activity. However, the potential usefulness of such 5980 logging has to be weighed against the increased SCTP startup 5981 processing it implies, rendering the SCTP node more vulnerable to 5982 flooding attacks. Logging is pointless without the establishment of 5983 operating procedures to review and analyze the logs on a routine 5984 basis. 5986 12.2.4.3. Improper Monopolization of Services 5988 Attacks under this heading are performed openly and legitimately by 5989 the attacker. They are directed against fellow users of the target 5990 SCTP node or of the shared resources between the attacker and the 5991 target node. Possible attacks include the opening of a large number 5992 of associations between the attacker's node and the target, or 5993 transfer of large volumes of information within a legitimately 5994 established association. 5996 Policy limits are expected to be placed on the number of associations 5997 per adjoining SCTP node. SCTP user applications are expected to be 5998 capable of detecting large volumes of illegitimate or "no-op" 5999 messages within a given association and either logging or terminating 6000 the association as a result, based on local policy. 6002 12.3. SCTP Interactions with Firewalls 6004 It is helpful for some firewalls if they can inspect just the first 6005 fragment of a fragmented SCTP packet and unambiguously determine 6006 whether it corresponds to an INIT chunk (for further information, 6007 please refer to [RFC1858]). Accordingly, we stress the requirements, 6008 as stated in Section 3.1, that (1) an INIT chunk MUST NOT be bundled 6009 with any other chunk in a packet and (2) a packet containing an INIT 6010 chunk MUST have a zero Verification Tag. The receiver of an INIT 6011 chunk MUST silently discard the INIT chunk and all further chunks if 6012 the INIT chunk is bundled with other chunks or the packet has a non- 6013 zero Verification Tag. 6015 12.4. Protection of Non-SCTP-Capable Hosts 6017 To provide a non-SCTP-capable host with the same level of protection 6018 against attacks as for SCTP-capable ones, all SCTP stacks MUST 6019 implement the ICMP handling described in Section 10. 6021 When an SCTP stack receives a packet containing multiple control or 6022 DATA chunks and the processing of the packet requires the sending of 6023 multiple chunks in response, the sender of the response chunk(s) MUST 6024 NOT send more than one packet. If bundling is supported, multiple 6025 response chunks that fit into a single packet MAY be bundled together 6026 into one single response packet. If bundling is not supported, then 6027 the sender MUST NOT send more than one response chunk and MUST 6028 discard all other responses. Note that this rule does not apply to a 6029 SACK chunk, since a SACK chunk is, in itself, a response to DATA and 6030 a SACK does not require a response of more DATA. 6032 An SCTP implementation SHOULD abort the association if it receives a 6033 SACK acknowledging a TSN that has not been sent. 6035 An SCTP implementation that receives an INIT that would require a 6036 large packet in response, due to the inclusion of multiple ERROR 6037 parameters, MAY (at its discretion) elect to omit some or all of the 6038 ERROR parameters to reduce the size of the INIT ACK. Due to a 6039 combination of the size of the COOKIE parameter and the number of 6040 addresses a receiver of an INIT indicates to a peer, it is always 6041 possible that the INIT ACK will be larger than the original INIT. An 6042 SCTP implementation SHOULD attempt to make the INIT ACK as small as 6043 possible to reduce the possibility of byte amplification attacks. 6045 13. Network Management Considerations 6047 The MIB module for SCTP defined in [RFC3873] applies for the version 6048 of the protocol specified in this document. 6050 14. Recommended Transmission Control Block (TCB) Parameters 6052 This section details a set of parameters that are expected to be 6053 contained within the TCB for an implementation. This section is for 6054 illustrative purposes and is not considered to be requirements on an 6055 implementation or as an exhaustive list of all parameters inside an 6056 SCTP TCB. Each implementation might need its own additional 6057 parameters for optimization. 6059 14.1. Parameters Necessary for the SCTP Instance 6061 Associations: A list of current associations and mappings to the 6062 data consumers for each association. This might be in the form of 6063 a hash table or other implementation-dependent structure. The 6064 data consumers might be process identification information such as 6065 file descriptors, named pipe pointer, or table pointers dependent 6066 on how SCTP is implemented. 6068 Secret Key: A secret key used by this endpoint to compute the MAC. 6070 This SHOULD be a cryptographic quality random number with a 6071 sufficient length. Discussion in [RFC4086] can be helpful in 6072 selection of the key. 6074 Address List: The list of IP addresses that this instance has bound. 6075 This information is passed to one's peer(s) in INIT and INIT ACK 6076 chunks. 6078 SCTP Port: The local SCTP port number to which the endpoint is 6079 bound. 6081 14.2. Parameters Necessary per Association (i.e., the TCB) 6083 Peer Verification Tag: Tag value to be sent in every packet and is 6084 received in the INIT or INIT ACK chunk. 6086 My Verification Tag: Tag expected in every inbound packet and sent 6087 in the INIT or INIT ACK chunk. 6089 State: COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING, 6090 SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT. 6092 Note: No "CLOSED" state is illustrated since if a association is 6093 "CLOSED" its TCB SHOULD be removed. 6095 Peer Transport Address List: A list of SCTP transport addresses to 6096 which the peer is bound. This information is derived from the 6097 INIT or INIT ACK and is used to associate an inbound packet with a 6098 given association. Normally, this information is hashed or keyed 6099 for quick lookup and access of the TCB. 6101 Primary Path: This is the current primary destination transport 6102 address of the peer endpoint. It might also specify a source 6103 transport address on this endpoint. 6105 Overall Error Count: The overall association error count. 6107 Overall Error Threshold: The threshold for this association that if 6108 the Overall Error Count reaches will cause this association to be 6109 torn down. 6111 Peer Rwnd: Current calculated value of the peer's rwnd. 6113 Next TSN: The next TSN number to be assigned to a new DATA chunk. 6114 This is sent in the INIT or INIT ACK chunk to the peer and 6115 incremented each time a DATA chunk is assigned a TSN (normally 6116 just prior to transmit or during fragmentation). 6118 Last Rcvd TSN: This is the last TSN received in sequence. This 6119 value is set initially by taking the peer's initial TSN, received 6120 in the INIT or INIT ACK chunk, and subtracting one from it. 6122 Mapping Array: An array of bits or bytes indicating which out-of- 6123 order TSNs have been received (relative to the Last Rcvd TSN). If 6124 no gaps exist, i.e., no out-of-order packets have been received, 6125 this array will be set to all zero. This structure might be in 6126 the form of a circular buffer or bit array. 6128 Ack State: This flag indicates if the next received packet is to be 6129 responded to with a SACK. This is initialized to 0. When a 6130 packet is received it is incremented. If this value reaches 2 or 6131 more, a SACK is sent and the value is reset to 0. Note: This is 6132 used only when no DATA chunks are received out of order. When 6133 DATA chunks are out of order, SACKs are not delayed (see 6134 Section 6). 6136 Inbound Streams: An array of structures to track the inbound 6137 streams, normally including the next sequence number expected and 6138 possibly the stream number. 6140 Outbound Streams: An array of structures to track the outbound 6141 streams, normally including the next sequence number to be sent on 6142 the stream. 6144 Reasm Queue: A reassembly queue. 6146 Receive Buffer: A buffer to store received user data which has not 6147 been delivered to the upper layer. 6149 Local Transport Address List: The list of local IP addresses bound 6150 in to this association. 6152 Maximum DATA Chunk Size: The smallest Path Maximum DATA Chunk Size 6153 of all destination addresses. 6155 14.3. Per Transport Address Data 6157 For each destination transport address in the peer's address list 6158 derived from the INIT or INIT ACK chunk, a number of data elements 6159 need to be maintained including: 6161 Error Count: The current error count for this destination. 6163 Error Threshold: Current error threshold for this destination, i.e., 6164 what value marks the destination down if error count reaches this 6165 value. 6167 cwnd: The current congestion window. 6169 ssthresh: The current ssthresh value. 6171 RTO: The current retransmission timeout value. 6173 SRTT: The current smoothed round-trip time. 6175 RTTVAR: The current RTT variation. 6177 partial bytes acked: The tracking method for increase of cwnd when 6178 in congestion avoidance mode (see Section 7.2.2). 6180 state: The current state of this destination, i.e., DOWN, UP, ALLOW- 6181 HB, NO-HEARTBEAT, etc. 6183 PMTU: The current known PMTU. 6185 PMDCS: The current known PMDCS. 6187 Per Destination Timer: A timer used by each destination. 6189 RTO-Pending: A flag used to track if one of the DATA chunks sent to 6190 this address is currently being used to compute an RTT. If this 6191 flag is 0, the next DATA chunk sent to this destination is 6192 expected to be used to compute an RTT and this flag is expected to 6193 be set. Every time the RTT calculation completes (i.e., the DATA 6194 chunk is SACK'd), clear this flag. 6196 last-time: The time to which this destination was last sent. This 6197 can be to determine if a HEARTBEAT is needed. 6199 14.4. General Parameters Needed 6201 Out Queue: A queue of outbound DATA chunks. 6203 In Queue: A queue of inbound DATA chunks. 6205 15. IANA Considerations 6207 SCTP defines three registries that IANA maintains: 6209 * through definition of additional chunk types, 6211 * through definition of additional parameter types, or 6213 * through definition of additional cause codes within ERROR chunks. 6215 SCTP requires that the IANA Port Numbers registry be opened for SCTP 6216 port registrations, Section 15.6 describes how. An IESG-appointed 6217 Expert Reviewer supports IANA in evaluating SCTP port allocation 6218 requests. 6220 15.1. IETF-Defined Chunk Extension 6222 The assignment of new chunk type codes is done through an IETF Review 6223 action, as defined in [RFC8126]. Documentation for a new chunk MUST 6224 contain the following information: 6226 a) A long and short name for the new chunk type. 6228 b) A detailed description of the structure of the chunk, which MUST 6229 conform to the basic structure defined in Section 3.2. 6231 c) A detailed definition and description of intended use of each 6232 field within the chunk, including the chunk flags if any. 6233 Defined chunk flags will be used as initial entries in the chunk 6234 flags table for the new chunk type. 6236 d) A detailed procedural description of the use of the new chunk 6237 type within the operation of the protocol. 6239 The last chunk type (255) is reserved for future extension if 6240 necessary. 6242 For each new chunk type, IANA creates a registration table for the 6243 chunk flags of that type. The procedure for registering particular 6244 chunk flags is described in Section 15.2. 6246 15.2. IETF Chunk Flags Registration 6248 The assignment of new chunk flags is done through an RFC Required 6249 action, as defined in [RFC8126]. Documentation for the chunk flags 6250 MUST contain the following information: 6252 a) A name for the new chunk flag. 6254 b) A detailed procedural description of the use of the new chunk 6255 flag within the operation of the protocol. It MUST be considered 6256 that implementations not supporting the flag will send '0' on 6257 transmit and just ignore it on receipt. 6259 IANA selects a chunk flags value. This MUST be one of 0x01, 0x02, 6260 0x04, 0x08, 0x10, 0x20, 0x40, or 0x80, which MUST be unique within 6261 the chunk flag values for the specific chunk type. 6263 15.3. IETF-Defined Chunk Parameter Extension 6265 The assignment of new chunk parameter type codes is done through an 6266 IETF Review action as defined in [RFC8126]. Documentation of the 6267 chunk parameter MUST contain the following information: 6269 a) Name of the parameter type. 6271 b) Detailed description of the structure of the parameter field. 6272 This structure MUST conform to the general Type-Length-Value 6273 format described in Section 3.2.1. 6275 c) Detailed definition of each component of the parameter value. 6277 d) Detailed description of the intended use of this parameter type, 6278 and an indication of whether and under what circumstances 6279 multiple instances of this parameter type can be found within the 6280 same chunk. 6282 e) Each parameter type MUST be unique across all chunks. 6284 15.4. IETF-Defined Additional Error Causes 6286 Additional cause codes can be allocated in the range 11 to 65535 6287 through a Specification Required action as defined in [RFC8126]. 6288 Provided documentation MUST include the following information: 6290 a) Name of the error condition. 6292 b) Detailed description of the conditions under which an SCTP 6293 endpoint issues an ERROR (or ABORT) with this cause code. 6295 c) Expected action by the SCTP endpoint that receives an ERROR (or 6296 ABORT) chunk containing this cause code. 6298 d) Detailed description of the structure and content of data fields 6299 that accompany this cause code. 6301 The initial word (32 bits) of a cause code parameter MUST conform to 6302 the format shown in Section 3.3.10, i.e.: 6304 * first 2 bytes contain the cause code value 6306 * last 2 bytes contain the length of the cause parameter. 6308 15.5. Payload Protocol Identifiers 6310 Except for value 0, which is reserved by SCTP to indicate an 6311 unspecified payload protocol identifier in a DATA chunk, SCTP will 6312 not be responsible for standardizing or verifying any payload 6313 protocol identifiers; SCTP simply receives the identifier from the 6314 upper layer and carries it with the corresponding payload data. 6316 The upper layer, i.e., the SCTP user, SHOULD standardize any specific 6317 protocol identifier with IANA if it is so desired. The use of any 6318 specific payload protocol identifier is out of the scope of SCTP. 6320 15.6. Port Numbers Registry 6322 SCTP services can use contact port numbers to provide service to 6323 unknown callers, as in TCP and UDP. IANA is therefore requested to 6324 open the existing "Service Name and Transport Protocol Port Number 6325 Registry" for SCTP using the following rules, which we intend to mesh 6326 well with existing port-number registration procedures. An IESG- 6327 appointed expert reviewer supports IANA in evaluating SCTP port 6328 allocation requests, according to the procedure defined in [RFC8126]. 6329 The details of this process are defined in [RFC6335]. 6331 This document registers the following ports. (These registrations 6332 are to be considered models to follow for future allocation 6333 requests.) 6334 discard 9/sctp Discard # IETF TSVWG 6335 # Randall Stewart 6336 # [RFC4960] 6338 The discard service, which accepts SCTP connections on port 6339 9, discards all incoming application data and sends no data 6340 in response. Thus, SCTP's discard port is analogous to 6341 TCP's discard port, and might be used to check the health 6342 of an SCTP stack. 6344 ftp-data 20/sctp FTP # IETF TSVWG 6345 # Randall Stewart 6346 # [RFC4960] 6348 ftp 21/sctp FTP # IETF TSVWG 6349 # Randall Stewart 6350 # [RFC4960] 6352 File Transfer Protocol (FTP) data (20) and control ports 6353 (21). 6355 ssh 22/sctp SSH # IETF TSVWG 6356 # Randall Stewart 6357 # [RFC4960] 6359 The Secure Shell (SSH) remote login service, which allows 6360 secure shell logins to a host. 6362 http 80/sctp HTTP # IETF TSVWG 6363 # Randall Stewart 6364 # [RFC4960] 6366 World Wide Web HTTP over SCTP. 6368 bgp 179/sctp BGP # IETF TSVWG 6369 # Randall Stewart 6370 # [RFC4960] 6372 Border Gateway Protocol over SCTP. 6374 https 443/sctp HTTPS # IETF TSVWG 6375 # Randall Stewart 6376 # [RFC4960] 6378 World Wide Web HTTP over TLS/SSL over SCTP. 6380 16. Suggested SCTP Protocol Parameter Values 6382 The following protocol parameters are RECOMMENDED: 6384 RTO.Initial: 1 second 6386 RTO.Min: 1 second 6388 RTO.Max: 60 seconds 6390 Max.Burst: 4 6392 RTO.Alpha: 1/8 6394 RTO.Beta: 1/4 6396 Valid.Cookie.Life: 60 seconds 6398 Association.Max.Retrans: 10 attempts 6400 Path.Max.Retrans: 5 attempts (per destination address) 6402 Max.Init.Retransmits: 8 attempts 6404 HB.interval: 30 seconds 6406 HB.Max.Burst: 1 6408 SACK.Delay: 200 milliseconds 6410 IMPLEMENTATION NOTE: The SCTP implementation can allow ULP to 6411 customize some of these protocol parameters (see Section 11). 6413 'RTO.Min' SHOULD be set as described above in this section. 6415 17. Acknowledgements 6417 An undertaking represented by this updated document is not a small 6418 feat and represents the summation of the initial co-authors of 6419 [RFC2960]: Q. Xie, K. Morneault, C. Sharp, H. Schwarzbauer, 6420 T. Taylor, I. Rytina, M. Kalla, L. Zhang, and V. Paxson. 6422 Add to that, the comments from everyone who contributed to [RFC2960]: 6423 Mark Allman, R. J. Atkinson, Richard Band, Scott Bradner, Steve 6424 Bellovin, Peter Butler, Ram Dantu, R. Ezhirpavai, Mike Fisk, Sally 6425 Floyd, Atsushi Fukumoto, Matt Holdrege, Henry Houh, Christian 6426 Huitema, Gary Lehecka, Jonathan Lee, David Lehmann, John Loughney, 6427 Daniel Luan, Barry Nagelberg, Thomas Narten, Erik Nordmark, Lyndon 6428 Ong, Shyamal Prasad, Kelvin Porter, Heinz Prantner, Jarno Rajahalme, 6429 Raymond E. Reeves, Renee Revis, Ivan Arias Rodriguez, A. Sankar, Greg 6430 Sidebottom, Brian Wyld, La Monte Yarroll, and many others for their 6431 invaluable comments. 6433 Then, add the co-authors of [RFC4460]: I. Arias-Rodriguez, K. Poon, 6434 and A. Caro. 6436 Then add to these the efforts of all the subsequent seven SCTP 6437 interoperability tests and those who commented on [RFC4460] as shown 6438 in its acknowledgements: Barry Zuckerman, La Monte Yarroll, Qiaobing 6439 Xie, Wang Xiaopeng, Jonathan Wood, Jeff Waskow, Mike Turner, John 6440 Townsend, Sabina Torrente, Cliff Thomas, Yuji Suzuki, Manoj Solanki, 6441 Sverre Slotte, Keyur Shah, Jan Rovins, Ben Robinson, Renee Revis, Ian 6442 Periam, RC Monee, Sanjay Rao, Sujith Radhakrishnan, Heinz Prantner, 6443 Biren Patel, Nathalie Mouellic, Mitch Miers, Bernward Meyknecht, Stan 6444 McClellan, Oliver Mayor, Tomas Orti Martin, Sandeep Mahajan, David 6445 Lehmann, Jonathan Lee, Philippe Langlois, Karl Knutson, Joe Keller, 6446 Gareth Keily, Andreas Jungmaier, Janardhan Iyengar, Mutsuya Irie, 6447 John Hebert, Kausar Hassan, Fred Hasle, Dan Harrison, Jon Grim, 6448 Laurent Glaude, Steven Furniss, Atsushi Fukumoto, Ken Fujita, Steve 6449 Dimig, Thomas Curran, Serkan Cil, Melissa Campbell, Peter Butler, Rob 6450 Brennan, Harsh Bhondwe, Brian Bidulock, Caitlin Bestler, Jon Berger, 6451 Robby Benedyk, Stephen Baucke, Sandeep Balani, and Ronnie Sellar. 6453 A special thanks to Mark Allman, who should actually be a co-author 6454 for his work on the max-burst, but managed to wiggle out due to a 6455 technicality. 6457 Also, we would like to acknowledge Lyndon Ong and Phil Conrad for 6458 their valuable input and many contributions. 6460 Furthermore, you have [RFC4960], and those who have commented upon 6461 that including Alfred Hönes and Ronnie Sellars. 6463 Then, add the co-author of [RFC8540]: Maksim Proshin. 6465 And people who have commented on [RFC8540]: Pontus Andersson, Eric 6466 W. Biederman, Cedric Bonnet, Spencer Dawkins, Gorry Fairhurst, 6467 Benjamin Kaduk, Mirja Kühlewind, Peter Lei, Gyula Marosi, Lionel 6468 Morand, Jeff Morriss, Tom Petch, Kacheong Poon, Julien Pourtet, Irene 6469 Rüngeler, Michael Welzl, and Qiaobing Xie. 6471 And finally the people who have provided comments for this document 6472 including Gorry Fairhurst, Marcelo Ricardo Leitner, Claudio Porfiri, 6473 Maksim Proshin, Timo Völker, and Magnus Westerlund. 6475 Our thanks cannot be adequately expressed to all of you who have 6476 participated in the coding, testing, and updating process of this 6477 document. All we can say is, Thank You! 6479 18. Normative References 6481 [ITU.V42.1994] 6482 International Telecommunications Union, "Error-correcting 6483 Procedures for DCEs Using Asynchronous-to-Synchronous 6484 Conversion", ITU-T Recommendation V.42, 1994. 6486 [RFC0768] Postel, J., "User Datagram Protocol", STD 6, RFC 768, 6487 DOI 10.17487/RFC0768, August 1980, 6488 . 6490 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 6491 RFC 793, DOI 10.17487/RFC0793, September 1981, 6492 . 6494 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 6495 Communication Layers", STD 3, RFC 1122, 6496 DOI 10.17487/RFC1122, October 1989, 6497 . 6499 [RFC1123] Braden, R., Ed., "Requirements for Internet Hosts - 6500 Application and Support", STD 3, RFC 1123, 6501 DOI 10.17487/RFC1123, October 1989, 6502 . 6504 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 6505 DOI 10.17487/RFC1191, November 1990, 6506 . 6508 [RFC1982] Elz, R. and R. Bush, "Serial Number Arithmetic", RFC 1982, 6509 DOI 10.17487/RFC1982, August 1996, 6510 . 6512 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6513 Requirement Levels", BCP 14, RFC 2119, 6514 DOI 10.17487/RFC2119, March 1997, 6515 . 6517 [RFC3873] Pastor, J. and M. Belinchon, "Stream Control Transmission 6518 Protocol (SCTP) Management Information Base (MIB)", 6519 RFC 3873, DOI 10.17487/RFC3873, September 2004, 6520 . 6522 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 6523 Architecture", RFC 4291, DOI 10.17487/RFC4291, February 6524 2006, . 6526 [RFC4301] Kent, S. and K. Seo, "Security Architecture for the 6527 Internet Protocol", RFC 4301, DOI 10.17487/RFC4301, 6528 December 2005, . 6530 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 6531 RFC 4303, DOI 10.17487/RFC4303, December 2005, 6532 . 6534 [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 6535 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 6536 . 6538 [RFC6335] Cotton, M., Eggert, L., Touch, J., Westerlund, M., and S. 6539 Cheshire, "Internet Assigned Numbers Authority (IANA) 6540 Procedures for the Management of the Service Name and 6541 Transport Protocol Port Number Registry", BCP 165, 6542 RFC 6335, DOI 10.17487/RFC6335, August 2011, 6543 . 6545 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 6546 Kivinen, "Internet Key Exchange Protocol Version 2 6547 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 6548 2014, . 6550 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 6551 Writing an IANA Considerations Section in RFCs", BCP 26, 6552 RFC 8126, DOI 10.17487/RFC8126, June 2017, 6553 . 6555 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6556 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6557 May 2017, . 6559 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 6560 (IPv6) Specification", STD 86, RFC 8200, 6561 DOI 10.17487/RFC8200, July 2017, 6562 . 6564 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 6565 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 6566 DOI 10.17487/RFC8201, July 2017, 6567 . 6569 [RFC8899] Fairhurst, G., Jones, T., Tüxen, M., Rüngeler, I., and T. 6570 Völker, "Packetization Layer Path MTU Discovery for 6571 Datagram Transports", RFC 8899, DOI 10.17487/RFC8899, 6572 September 2020, . 6574 19. Informative References 6576 [FALL96] Fall, K. and S. Floyd, "Simulation-based Comparisons of 6577 Tahoe, Reno, and SACK TCP", SIGCOM 99, V. 26, N. 3, 6578 pp 5-21, July 1996. 6580 [SAVAGE99] Savage, S., Cardwell, N., Wetherall, D., and T. Anderson, 6581 "TCP Congestion Control with a Misbehaving Receiver", ACM 6582 Computer Communications Review 29(5), October 1999. 6584 [ALLMAN99] Allman, M. and V. Paxson, "On Estimating End-to-End 6585 Network Path Properties", SIGCOM 99, 1999. 6587 [WILLIAMS93] 6588 Williams, R., "A PAINLESS GUIDE TO CRC ERROR DETECTION 6589 ALGORITHMS", SIGCOM 99, August 1993, 6590 . 6593 [RFC1858] Ziemba, G., Reed, D., and P. Traina, "Security 6594 Considerations for IP Fragment Filtering", RFC 1858, 6595 DOI 10.17487/RFC1858, October 1995, 6596 . 6598 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 6599 Hashing for Message Authentication", RFC 2104, 6600 DOI 10.17487/RFC2104, February 1997, 6601 . 6603 [RFC2196] Fraser, B., "Site Security Handbook", FYI 8, RFC 2196, 6604 DOI 10.17487/RFC2196, September 1997, 6605 . 6607 [RFC2522] Karn, P. and W. Simpson, "Photuris: Session-Key Management 6608 Protocol", RFC 2522, DOI 10.17487/RFC2522, March 1999, 6609 . 6611 [RFC2960] Stewart, R., Xie, Q., Morneault, K., Sharp, C., 6612 Schwarzbauer, H., Taylor, T., Rytina, I., Kalla, M., 6613 Zhang, L., and V. Paxson, "Stream Control Transmission 6614 Protocol", RFC 2960, DOI 10.17487/RFC2960, October 2000, 6615 . 6617 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 6618 "Randomness Requirements for Security", BCP 106, RFC 4086, 6619 DOI 10.17487/RFC4086, June 2005, 6620 . 6622 [RFC4460] Stewart, R., Arias-Rodriguez, I., Poon, K., Caro, A., and 6623 M. Tuexen, "Stream Control Transmission Protocol (SCTP) 6624 Specification Errata and Issues", RFC 4460, 6625 DOI 10.17487/RFC4460, April 2006, 6626 . 6628 [RFC4895] Tuexen, M., Stewart, R., Lei, P., and E. Rescorla, 6629 "Authenticated Chunks for the Stream Control Transmission 6630 Protocol (SCTP)", RFC 4895, DOI 10.17487/RFC4895, August 6631 2007, . 6633 [RFC4960] Stewart, R., Ed., "Stream Control Transmission Protocol", 6634 RFC 4960, DOI 10.17487/RFC4960, September 2007, 6635 . 6637 [RFC6458] Stewart, R., Tuexen, M., Poon, K., Lei, P., and V. 6638 Yasevich, "Sockets API Extensions for the Stream Control 6639 Transmission Protocol (SCTP)", RFC 6458, 6640 DOI 10.17487/RFC6458, December 2011, 6641 . 6643 [RFC7053] Tuexen, M., Ruengeler, I., and R. Stewart, "SACK- 6644 IMMEDIATELY Extension for the Stream Control Transmission 6645 Protocol", RFC 7053, DOI 10.17487/RFC7053, November 2013, 6646 . 6648 [RFC8540] Stewart, R., Tuexen, M., and M. Proshin, "Stream Control 6649 Transmission Protocol: Errata and Issues in RFC 4960", 6650 RFC 8540, DOI 10.17487/RFC8540, February 2019, 6651 . 6653 Appendix A. CRC32c Checksum Calculation 6655 We define a 'reflected value' as one that is the opposite of the 6656 normal bit order of the machine. The 32-bit CRC (Cyclic Redundancy 6657 Check) is calculated as described for CRC32c and uses the polynomial 6658 code 0x11EDC6F41 (Castagnoli93) or 6659 x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+ 6660 x^14+x^13+x^11+x^10+x^9+x^8+x^6+x^0. The CRC is computed using a 6661 procedure similar to ETHERNET CRC [ITU.V42.1994], modified to reflect 6662 transport-level usage. 6664 CRC computation uses polynomial division. A message bit-string M is 6665 transformed to a polynomial, M(X), and the CRC is calculated from 6666 M(X) using polynomial arithmetic. 6668 When CRCs are used at the link layer, the polynomial is derived from 6669 on-the-wire bit ordering: the first bit 'on the wire' is the high- 6670 order coefficient. Since SCTP is a transport-level protocol, it 6671 cannot know the actual serial-media bit ordering. Moreover, 6672 different links in the path between SCTP endpoints can use different 6673 link-level bit orders. 6675 A convention therefore is established for mapping SCTP transport 6676 messages to polynomials for purposes of CRC computation. The bit- 6677 ordering for mapping SCTP messages to polynomials is that bytes are 6678 taken most-significant first, but within each byte, bits are taken 6679 least-significant first. The first byte of the message provides the 6680 eight highest coefficients. Within each byte, the least-significant 6681 SCTP bit gives the most-significant polynomial coefficient within 6682 that byte, and the most-significant SCTP bit is the least-significant 6683 polynomial coefficient in that byte. (This bit ordering is sometimes 6684 called 'mirrored' or 'reflected' [WILLIAMS93].) CRC polynomials are 6685 to be transformed back into SCTP transport-level byte values, using a 6686 consistent mapping. 6688 The SCTP transport-level CRC value can be calculated as follows: 6690 * CRC input data are assigned to a byte stream, numbered from 0 to 6691 N-1. 6693 * The transport-level byte stream is mapped to a polynomial value. 6694 An N-byte PDU with j bytes numbered 0 to N-1 is considered as 6695 coefficients of a polynomial M(x) of order 8N-1, with bit 0 of 6696 byte j being coefficient x^(8(N-j)-8), and bit 7 of byte j being 6697 coefficient x^(8(N-j)-1). 6699 * The CRC remainder register is initialized with all 1s and the CRC 6700 is computed with an algorithm that simultaneously multiplies by 6701 x^32 and divides by the CRC polynomial. 6703 * The polynomial is multiplied by x^32 and divided by G(x), the 6704 generator polynomial, producing a remainder R(x) of degree less 6705 than or equal to 31. 6707 * The coefficients of R(x) are considered a 32-bit sequence. 6709 * The bit sequence is complemented. The result is the CRC 6710 polynomial. 6712 * The CRC polynomial is mapped back into SCTP transport-level bytes. 6713 The coefficient of x^31 gives the value of bit 7 of SCTP byte 0, 6714 and the coefficient of x^24 gives the value of bit 0 of byte 0. 6715 The coefficient of x^7 gives bit 7 of byte 3, and the coefficient 6716 of x^0 gives bit 0 of byte 3. The resulting 4-byte transport- 6717 level sequence is the 32-bit SCTP checksum value. 6719 IMPLEMENTATION NOTE: Standards documents, textbooks, and vendor 6720 literature on CRCs often follow an alternative formulation, in which 6721 the register used to hold the remainder of the long-division 6722 algorithm is initialized to zero rather than all-1s, and instead the 6723 first 32 bits of the message are complemented. The long-division 6724 algorithm used in our formulation is specified such that the initial 6725 multiplication by 2^32 and the long-division are combined into one 6726 simultaneous operation. For such algorithms, and for messages longer 6727 than 64 bits, the two specifications are precisely equivalent. That 6728 equivalence is the intent of this document. 6730 Implementors of SCTP are warned that both specifications are to be 6731 found in the literature, sometimes with no restriction on the long- 6732 division algorithm. The choice of formulation in this document is to 6733 permit non-SCTP usage, where the same CRC algorithm can be used to 6734 protect messages shorter than 64 bits. 6736 There can be a computational advantage in validating the association 6737 against the Verification Tag, prior to performing a checksum, as 6738 invalid tags will result in the same action as a bad checksum in most 6739 cases. The exceptions for this technique would be INIT and some 6740 SHUTDOWN-COMPLETE exchanges, as well as a stale COOKIE ECHO. These 6741 special-case exchanges represent small packets and will minimize the 6742 effect of the checksum calculation. 6744 The following non-normative sample code is taken from an open-source 6745 CRC generator [WILLIAMS93], using the "mirroring" technique and 6746 yielding a lookup table for SCTP CRC32c with 256 entries, each 32 6747 bits wide. While neither especially slow nor especially fast, as 6748 software table-lookup CRCs go, it has the advantage of working on 6749 both big-endian and little-endian CPUs, using the same (host-order) 6750 lookup tables, and using only the predefined ntohl() and htonl() 6751 operations. The code is somewhat modified from [WILLIAMS93], to 6752 ensure portability between big-endian and little-endian 6753 architectures. (Note that if the byte endian-ness of the target 6754 architecture is known to be little-endian, the final bit-reversal and 6755 byte-reversal steps can be folded into a single operation.) 6756 6757 /****************************************************************/ 6758 /* Note: The definitions for Ross Williams's table generator */ 6759 /* would be TB_WIDTH=4, TB_POLY=0x1EDC6F41, TB_REVER=TRUE. */ 6760 /* For Mr. Williams's direct calculation code, use the settings */ 6761 /* cm_width=32, cm_poly=0x1EDC6F41, cm_init=0xFFFFFFFF, */ 6762 /* cm_refin=TRUE, cm_refot=TRUE, cm_xorot=0x00000000. */ 6763 /****************************************************************/ 6765 /* Example of the crc table file */ 6766 #ifndef __crc32cr_h__ 6767 #define __crc32cr_h__ 6769 #define CRC32C_POLY 0x1EDC6F41UL 6770 #define CRC32C(c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF]) 6772 uint32_t crc_c[256] = { 6773 0x00000000UL, 0xF26B8303UL, 0xE13B70F7UL, 0x1350F3F4UL, 6774 0xC79A971FUL, 0x35F1141CUL, 0x26A1E7E8UL, 0xD4CA64EBUL, 6775 0x8AD958CFUL, 0x78B2DBCCUL, 0x6BE22838UL, 0x9989AB3BUL, 6776 0x4D43CFD0UL, 0xBF284CD3UL, 0xAC78BF27UL, 0x5E133C24UL, 6777 0x105EC76FUL, 0xE235446CUL, 0xF165B798UL, 0x030E349BUL, 6778 0xD7C45070UL, 0x25AFD373UL, 0x36FF2087UL, 0xC494A384UL, 6779 0x9A879FA0UL, 0x68EC1CA3UL, 0x7BBCEF57UL, 0x89D76C54UL, 6780 0x5D1D08BFUL, 0xAF768BBCUL, 0xBC267848UL, 0x4E4DFB4BUL, 6781 0x20BD8EDEUL, 0xD2D60DDDUL, 0xC186FE29UL, 0x33ED7D2AUL, 6782 0xE72719C1UL, 0x154C9AC2UL, 0x061C6936UL, 0xF477EA35UL, 6783 0xAA64D611UL, 0x580F5512UL, 0x4B5FA6E6UL, 0xB93425E5UL, 6784 0x6DFE410EUL, 0x9F95C20DUL, 0x8CC531F9UL, 0x7EAEB2FAUL, 6785 0x30E349B1UL, 0xC288CAB2UL, 0xD1D83946UL, 0x23B3BA45UL, 6786 0xF779DEAEUL, 0x05125DADUL, 0x1642AE59UL, 0xE4292D5AUL, 6787 0xBA3A117EUL, 0x4851927DUL, 0x5B016189UL, 0xA96AE28AUL, 6788 0x7DA08661UL, 0x8FCB0562UL, 0x9C9BF696UL, 0x6EF07595UL, 6789 0x417B1DBCUL, 0xB3109EBFUL, 0xA0406D4BUL, 0x522BEE48UL, 6790 0x86E18AA3UL, 0x748A09A0UL, 0x67DAFA54UL, 0x95B17957UL, 6791 0xCBA24573UL, 0x39C9C670UL, 0x2A993584UL, 0xD8F2B687UL, 6792 0x0C38D26CUL, 0xFE53516FUL, 0xED03A29BUL, 0x1F682198UL, 6793 0x5125DAD3UL, 0xA34E59D0UL, 0xB01EAA24UL, 0x42752927UL, 6794 0x96BF4DCCUL, 0x64D4CECFUL, 0x77843D3BUL, 0x85EFBE38UL, 6795 0xDBFC821CUL, 0x2997011FUL, 0x3AC7F2EBUL, 0xC8AC71E8UL, 6796 0x1C661503UL, 0xEE0D9600UL, 0xFD5D65F4UL, 0x0F36E6F7UL, 6797 0x61C69362UL, 0x93AD1061UL, 0x80FDE395UL, 0x72966096UL, 6798 0xA65C047DUL, 0x5437877EUL, 0x4767748AUL, 0xB50CF789UL, 6799 0xEB1FCBADUL, 0x197448AEUL, 0x0A24BB5AUL, 0xF84F3859UL, 6800 0x2C855CB2UL, 0xDEEEDFB1UL, 0xCDBE2C45UL, 0x3FD5AF46UL, 6801 0x7198540DUL, 0x83F3D70EUL, 0x90A324FAUL, 0x62C8A7F9UL, 6802 0xB602C312UL, 0x44694011UL, 0x5739B3E5UL, 0xA55230E6UL, 6803 0xFB410CC2UL, 0x092A8FC1UL, 0x1A7A7C35UL, 0xE811FF36UL, 6804 0x3CDB9BDDUL, 0xCEB018DEUL, 0xDDE0EB2AUL, 0x2F8B6829UL, 6805 0x82F63B78UL, 0x709DB87BUL, 0x63CD4B8FUL, 0x91A6C88CUL, 6806 0x456CAC67UL, 0xB7072F64UL, 0xA457DC90UL, 0x563C5F93UL, 6807 0x082F63B7UL, 0xFA44E0B4UL, 0xE9141340UL, 0x1B7F9043UL, 6808 0xCFB5F4A8UL, 0x3DDE77ABUL, 0x2E8E845FUL, 0xDCE5075CUL, 6809 0x92A8FC17UL, 0x60C37F14UL, 0x73938CE0UL, 0x81F80FE3UL, 6810 0x55326B08UL, 0xA759E80BUL, 0xB4091BFFUL, 0x466298FCUL, 6811 0x1871A4D8UL, 0xEA1A27DBUL, 0xF94AD42FUL, 0x0B21572CUL, 6812 0xDFEB33C7UL, 0x2D80B0C4UL, 0x3ED04330UL, 0xCCBBC033UL, 6813 0xA24BB5A6UL, 0x502036A5UL, 0x4370C551UL, 0xB11B4652UL, 6814 0x65D122B9UL, 0x97BAA1BAUL, 0x84EA524EUL, 0x7681D14DUL, 6815 0x2892ED69UL, 0xDAF96E6AUL, 0xC9A99D9EUL, 0x3BC21E9DUL, 6816 0xEF087A76UL, 0x1D63F975UL, 0x0E330A81UL, 0xFC588982UL, 6817 0xB21572C9UL, 0x407EF1CAUL, 0x532E023EUL, 0xA145813DUL, 6818 0x758FE5D6UL, 0x87E466D5UL, 0x94B49521UL, 0x66DF1622UL, 6819 0x38CC2A06UL, 0xCAA7A905UL, 0xD9F75AF1UL, 0x2B9CD9F2UL, 6820 0xFF56BD19UL, 0x0D3D3E1AUL, 0x1E6DCDEEUL, 0xEC064EEDUL, 6821 0xC38D26C4UL, 0x31E6A5C7UL, 0x22B65633UL, 0xD0DDD530UL, 6822 0x0417B1DBUL, 0xF67C32D8UL, 0xE52CC12CUL, 0x1747422FUL, 6823 0x49547E0BUL, 0xBB3FFD08UL, 0xA86F0EFCUL, 0x5A048DFFUL, 6824 0x8ECEE914UL, 0x7CA56A17UL, 0x6FF599E3UL, 0x9D9E1AE0UL, 6825 0xD3D3E1ABUL, 0x21B862A8UL, 0x32E8915CUL, 0xC083125FUL, 6826 0x144976B4UL, 0xE622F5B7UL, 0xF5720643UL, 0x07198540UL, 6827 0x590AB964UL, 0xAB613A67UL, 0xB831C993UL, 0x4A5A4A90UL, 6828 0x9E902E7BUL, 0x6CFBAD78UL, 0x7FAB5E8CUL, 0x8DC0DD8FUL, 6829 0xE330A81AUL, 0x115B2B19UL, 0x020BD8EDUL, 0xF0605BEEUL, 6830 0x24AA3F05UL, 0xD6C1BC06UL, 0xC5914FF2UL, 0x37FACCF1UL, 6831 0x69E9F0D5UL, 0x9B8273D6UL, 0x88D28022UL, 0x7AB90321UL, 6832 0xAE7367CAUL, 0x5C18E4C9UL, 0x4F48173DUL, 0xBD23943EUL, 6833 0xF36E6F75UL, 0x0105EC76UL, 0x12551F82UL, 0xE03E9C81UL, 6834 0x34F4F86AUL, 0xC69F7B69UL, 0xD5CF889DUL, 0x27A40B9EUL, 6835 0x79B737BAUL, 0x8BDCB4B9UL, 0x988C474DUL, 0x6AE7C44EUL, 6836 0xBE2DA0A5UL, 0x4C4623A6UL, 0x5F16D052UL, 0xAD7D5351UL, 6837 }; 6839 #endif 6841 /* Example of table build routine */ 6843 #include 6844 #include 6846 #define OUTPUT_FILE "crc32cr.h" 6847 #define CRC32C_POLY 0x1EDC6F41UL 6849 static FILE *tf; 6850 static uint32_t 6851 reflect_32(uint32_t b) 6852 { 6853 int i; 6854 uint32_t rw = 0UL; 6856 for (i = 0; i < 32; i++) { 6857 if (b & 1) 6858 rw |= 1 << (31 - i); 6859 b >>= 1; 6860 } 6861 return (rw); 6862 } 6864 static uint32_t 6865 build_crc_table (int index) 6866 { 6867 int i; 6868 uint32_t rb; 6870 rb = reflect_32(index); 6872 for (i = 0; i < 8; i++) { 6873 if (rb & 0x80000000UL) 6874 rb = (rb << 1) ^ (uint32_t)CRC32C_POLY; 6875 else 6876 rb <<= 1; 6877 } 6878 return (reflect_32(rb)); 6879 } 6881 int 6882 main (void) 6883 { 6884 int i; 6886 printf("\nGenerating CRC32c table file <%s>.\n", 6887 OUTPUT_FILE); 6888 if ((tf = fopen(OUTPUT_FILE, "w")) == NULL) { 6889 printf("Unable to open %s.\n", OUTPUT_FILE); 6890 exit (1); 6891 } 6892 fprintf(tf, "#ifndef __crc32cr_h__\n"); 6893 fprintf(tf, "#define __crc32cr_h__\n\n"); 6894 fprintf(tf, "#define CRC32C_POLY 0x%08XUL\n", 6895 (uint32_t)CRC32C_POLY); 6896 fprintf(tf, 6897 "#define CRC32C(c,d) (c=(c>>8)^crc_c[(c^(d))&0xFF])\n"); 6899 fprintf(tf, "\nuint32_t crc_c[256] =\n{\n"); 6900 for (i = 0; i < 256; i++) { 6901 fprintf(tf, "0x%08XUL,", build_crc_table (i)); 6902 if ((i & 3) == 3) 6903 fprintf(tf, "\n"); 6904 else 6905 fprintf(tf, " "); 6906 } 6907 fprintf(tf, "};\n\n#endif\n"); 6909 if (fclose(tf) != 0) 6910 printf("Unable to close <%s>.\n", OUTPUT_FILE); 6911 else 6912 printf("\nThe CRC32c table has been written to <%s>.\n", 6913 OUTPUT_FILE); 6914 return (0); 6915 } 6917 /* Example of crc insertion */ 6919 #include "crc32cr.h" 6921 uint32_t 6922 generate_crc32c(unsigned char *buffer, unsigned int length) 6923 { 6924 unsigned int i; 6925 uint32_t crc32 = 0xffffffffUL; 6926 uint32_t result; 6927 uint8_t byte0, byte1, byte2, byte3; 6929 for (i = 0; i < length; i++) { 6930 CRC32C(crc32, buffer[i]); 6931 } 6933 result = ~crc32; 6935 /* result now holds the negated polynomial remainder, 6936 * since the table and algorithm are "reflected" [williams95]. 6937 * That is, result has the same value as if we mapped the message 6938 * to a polynomial, computed the host-bit-order polynomial 6939 * remainder, performed final negation, and then did an 6940 * end-for-end bit-reversal. 6941 * Note that a 32-bit bit-reversal is identical to four in-place 6942 * 8-bit bit-reversals followed by an end-for-end byteswap. 6943 * In other words, the bits of each byte are in the right order, 6944 * but the bytes have been byteswapped. So, we now do an explicit 6945 * byteswap. On a little-endian machine, this byteswap and 6946 * the final ntohl cancel out and could be elided. 6948 */ 6950 byte0 = result & 0xff; 6951 byte1 = (result>>8) & 0xff; 6952 byte2 = (result>>16) & 0xff; 6953 byte3 = (result>>24) & 0xff; 6954 crc32 = ((byte0 << 24) | 6955 (byte1 << 16) | 6956 (byte2 << 8) | 6957 byte3); 6958 return (crc32); 6959 } 6961 int 6962 insert_crc32(unsigned char *buffer, unsigned int length) 6963 { 6964 SCTP_message *message; 6965 uint32_t crc32; 6966 message = (SCTP_message *) buffer; 6967 message->common_header.checksum = 0UL; 6968 crc32 = generate_crc32c(buffer,length); 6969 /* and insert it into the message */ 6970 message->common_header.checksum = htonl(crc32); 6971 return (1); 6972 } 6974 int 6975 validate_crc32(unsigned char *buffer, unsigned int length) 6976 { 6977 SCTP_message *message; 6978 unsigned int i; 6979 uint32_t original_crc32; 6980 uint32_t crc32; 6982 /* save and zero checksum */ 6983 message = (SCTP_message *)buffer; 6984 original_crc32 = ntohl(message->common_header.checksum); 6985 message->common_header.checksum = 0L; 6986 crc32 = generate_crc32c(buffer, length); 6987 return ((original_crc32 == crc32) ? 1 : -1); 6988 } 6989 6991 Authors' Addresses 6993 Randall R. Stewart 6994 Netflix, Inc. 6995 2455 Heritage Green Ave 6996 Davenport, FL 33837 6997 United States 6999 Email: randall@lakerest.net 7001 Michael Tüxen 7002 Münster University of Applied Sciences 7003 Stegerwaldstrasse 39 7004 48565 Steinfurt 7005 Germany 7007 Email: tuexen@fh-muenster.de 7009 Karen E. E. Nielsen 7010 Kamstrup A/S 7011 Industrivej 28 7012 DK-8660 Skanderborg 7013 Denmark 7015 Email: kee@kamstrup.com