dccp.rst 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =============
  3. DCCP protocol
  4. =============
  5. .. Contents
  6. - Introduction
  7. - Missing features
  8. - Socket options
  9. - Sysctl variables
  10. - IOCTLs
  11. - Other tunables
  12. - Notes
  13. Introduction
  14. ============
  15. Datagram Congestion Control Protocol (DCCP) is an unreliable, connection
  16. oriented protocol designed to solve issues present in UDP and TCP, particularly
  17. for real-time and multimedia (streaming) traffic.
  18. It divides into a base protocol (RFC 4340) and pluggable congestion control
  19. modules called CCIDs. Like pluggable TCP congestion control, at least one CCID
  20. needs to be enabled in order for the protocol to function properly. In the Linux
  21. implementation, this is the TCP-like CCID2 (RFC 4341). Additional CCIDs, such as
  22. the TCP-friendly CCID3 (RFC 4342), are optional.
  23. For a brief introduction to CCIDs and suggestions for choosing a CCID to match
  24. given applications, see section 10 of RFC 4340.
  25. It has a base protocol and pluggable congestion control IDs (CCIDs).
  26. DCCP is a Proposed Standard (RFC 2026), and the homepage for DCCP as a protocol
  27. is at http://www.ietf.org/html.charters/dccp-charter.html
  28. Missing features
  29. ================
  30. The Linux DCCP implementation does not currently support all the features that are
  31. specified in RFCs 4340...42.
  32. The known bugs are at:
  33. http://www.linuxfoundation.org/collaborate/workgroups/networking/todo#DCCP
  34. For more up-to-date versions of the DCCP implementation, please consider using
  35. the experimental DCCP test tree; instructions for checking this out are on:
  36. http://www.linuxfoundation.org/collaborate/workgroups/networking/dccp_testing#Experimental_DCCP_source_tree
  37. Socket options
  38. ==============
  39. DCCP_SOCKOPT_QPOLICY_ID sets the dequeuing policy for outgoing packets. It takes
  40. a policy ID as argument and can only be set before the connection (i.e. changes
  41. during an established connection are not supported). Currently, two policies are
  42. defined: the "simple" policy (DCCPQ_POLICY_SIMPLE), which does nothing special,
  43. and a priority-based variant (DCCPQ_POLICY_PRIO). The latter allows to pass an
  44. u32 priority value as ancillary data to sendmsg(), where higher numbers indicate
  45. a higher packet priority (similar to SO_PRIORITY). This ancillary data needs to
  46. be formatted using a cmsg(3) message header filled in as follows::
  47. cmsg->cmsg_level = SOL_DCCP;
  48. cmsg->cmsg_type = DCCP_SCM_PRIORITY;
  49. cmsg->cmsg_len = CMSG_LEN(sizeof(uint32_t)); /* or CMSG_LEN(4) */
  50. DCCP_SOCKOPT_QPOLICY_TXQLEN sets the maximum length of the output queue. A zero
  51. value is always interpreted as unbounded queue length. If different from zero,
  52. the interpretation of this parameter depends on the current dequeuing policy
  53. (see above): the "simple" policy will enforce a fixed queue size by returning
  54. EAGAIN, whereas the "prio" policy enforces a fixed queue length by dropping the
  55. lowest-priority packet first. The default value for this parameter is
  56. initialised from /proc/sys/net/dccp/default/tx_qlen.
  57. DCCP_SOCKOPT_SERVICE sets the service. The specification mandates use of
  58. service codes (RFC 4340, sec. 8.1.2); if this socket option is not set,
  59. the socket will fall back to 0 (which means that no meaningful service code
  60. is present). On active sockets this is set before connect(); specifying more
  61. than one code has no effect (all subsequent service codes are ignored). The
  62. case is different for passive sockets, where multiple service codes (up to 32)
  63. can be set before calling bind().
  64. DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet
  65. size (application payload size) in bytes, see RFC 4340, section 14.
  66. DCCP_SOCKOPT_AVAILABLE_CCIDS is also read-only and returns the list of CCIDs
  67. supported by the endpoint. The option value is an array of type uint8_t whose
  68. size is passed as option length. The minimum array size is 4 elements, the
  69. value returned in the optlen argument always reflects the true number of
  70. built-in CCIDs.
  71. DCCP_SOCKOPT_CCID is write-only and sets both the TX and RX CCIDs at the same
  72. time, combining the operation of the next two socket options. This option is
  73. preferable over the latter two, since often applications will use the same
  74. type of CCID for both directions; and mixed use of CCIDs is not currently well
  75. understood. This socket option takes as argument at least one uint8_t value, or
  76. an array of uint8_t values, which must match available CCIDS (see above). CCIDs
  77. must be registered on the socket before calling connect() or listen().
  78. DCCP_SOCKOPT_TX_CCID is read/write. It returns the current CCID (if set) or sets
  79. the preference list for the TX CCID, using the same format as DCCP_SOCKOPT_CCID.
  80. Please note that the getsockopt argument type here is ``int``, not uint8_t.
  81. DCCP_SOCKOPT_RX_CCID is analogous to DCCP_SOCKOPT_TX_CCID, but for the RX CCID.
  82. DCCP_SOCKOPT_SERVER_TIMEWAIT enables the server (listening socket) to hold
  83. timewait state when closing the connection (RFC 4340, 8.3). The usual case is
  84. that the closing server sends a CloseReq, whereupon the client holds timewait
  85. state. When this boolean socket option is on, the server sends a Close instead
  86. and will enter TIMEWAIT. This option must be set after accept() returns.
  87. DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the
  88. partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums
  89. always cover the entire packet and that only fully covered application data is
  90. accepted by the receiver. Hence, when using this feature on the sender, it must
  91. be enabled at the receiver, too with suitable choice of CsCov.
  92. DCCP_SOCKOPT_SEND_CSCOV sets the sender checksum coverage. Values in the
  93. range 0..15 are acceptable. The default setting is 0 (full coverage),
  94. values between 1..15 indicate partial coverage.
  95. DCCP_SOCKOPT_RECV_CSCOV is for the receiver and has a different meaning: it
  96. sets a threshold, where again values 0..15 are acceptable. The default
  97. of 0 means that all packets with a partial coverage will be discarded.
  98. Values in the range 1..15 indicate that packets with minimally such a
  99. coverage value are also acceptable. The higher the number, the more
  100. restrictive this setting (see [RFC 4340, sec. 9.2.1]). Partial coverage
  101. settings are inherited to the child socket after accept().
  102. The following two options apply to CCID 3 exclusively and are getsockopt()-only.
  103. In either case, a TFRC info struct (defined in <linux/tfrc.h>) is returned.
  104. DCCP_SOCKOPT_CCID_RX_INFO
  105. Returns a ``struct tfrc_rx_info`` in optval; the buffer for optval and
  106. optlen must be set to at least sizeof(struct tfrc_rx_info).
  107. DCCP_SOCKOPT_CCID_TX_INFO
  108. Returns a ``struct tfrc_tx_info`` in optval; the buffer for optval and
  109. optlen must be set to at least sizeof(struct tfrc_tx_info).
  110. On unidirectional connections it is useful to close the unused half-connection
  111. via shutdown (SHUT_WR or SHUT_RD): this will reduce per-packet processing costs.
  112. Sysctl variables
  113. ================
  114. Several DCCP default parameters can be managed by the following sysctls
  115. (sysctl net.dccp.default or /proc/sys/net/dccp/default):
  116. request_retries
  117. The number of active connection initiation retries (the number of
  118. Requests minus one) before timing out. In addition, it also governs
  119. the behaviour of the other, passive side: this variable also sets
  120. the number of times DCCP repeats sending a Response when the initial
  121. handshake does not progress from RESPOND to OPEN (i.e. when no Ack
  122. is received after the initial Request). This value should be greater
  123. than 0, suggested is less than 10. Analogue of tcp_syn_retries.
  124. retries1
  125. How often a DCCP Response is retransmitted until the listening DCCP
  126. side considers its connecting peer dead. Analogue of tcp_retries1.
  127. retries2
  128. The number of times a general DCCP packet is retransmitted. This has
  129. importance for retransmitted acknowledgments and feature negotiation,
  130. data packets are never retransmitted. Analogue of tcp_retries2.
  131. tx_ccid = 2
  132. Default CCID for the sender-receiver half-connection. Depending on the
  133. choice of CCID, the Send Ack Vector feature is enabled automatically.
  134. rx_ccid = 2
  135. Default CCID for the receiver-sender half-connection; see tx_ccid.
  136. seq_window = 100
  137. The initial sequence window (sec. 7.5.2) of the sender. This influences
  138. the local ackno validity and the remote seqno validity windows (7.5.1).
  139. Values in the range Wmin = 32 (RFC 4340, 7.5.2) up to 2^32-1 can be set.
  140. tx_qlen = 5
  141. The size of the transmit buffer in packets. A value of 0 corresponds
  142. to an unbounded transmit buffer.
  143. sync_ratelimit = 125 ms
  144. The timeout between subsequent DCCP-Sync packets sent in response to
  145. sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit
  146. of this parameter is milliseconds; a value of 0 disables rate-limiting.
  147. IOCTLS
  148. ======
  149. FIONREAD
  150. Works as in udp(7): returns in the ``int`` argument pointer the size of
  151. the next pending datagram in bytes, or 0 when no datagram is pending.
  152. SIOCOUTQ
  153. Returns the number of unsent data bytes in the socket send queue as ``int``
  154. into the buffer specified by the argument pointer.
  155. Other tunables
  156. ==============
  157. Per-route rto_min support
  158. CCID-2 supports the RTAX_RTO_MIN per-route setting for the minimum value
  159. of the RTO timer. This setting can be modified via the 'rto_min' option
  160. of iproute2; for example::
  161. > ip route change 10.0.0.0/24 rto_min 250j dev wlan0
  162. > ip route add 10.0.0.254/32 rto_min 800j dev wlan0
  163. > ip route show dev wlan0
  164. CCID-3 also supports the rto_min setting: it is used to define the lower
  165. bound for the expiry of the nofeedback timer. This can be useful on LANs
  166. with very low RTTs (e.g., loopback, Gbit ethernet).
  167. Notes
  168. =====
  169. DCCP does not travel through NAT successfully at present on many boxes. This is
  170. because the checksum covers the pseudo-header as per TCP and UDP. Linux NAT
  171. support for DCCP has been added.