SCTP(7) | Linux Programmer's Manual | SCTP(7) |
sctp - SCTP protocol.
#include <sys/socket.h> #include <netinet/in.h> #include <netinet/sctp.h> sctp_socket = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); sctp_socket = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
This is an implementation of the SCTP protocol as defined in RFC4960. It is a message oriented, reliable transport protocol with direct support for multihoming that runs on top of ip(7), and supports both v4 and v6 versions.
Like TCP, SCTP provides reliable, connection oriented data delivery with congestion control. Unlike TCP, SCTP also provides message boundary preservation, ordered and unordered message delivery, multi-streaming and multi-homing. Detection of data corruption, loss of data and duplication of data is achieved by using checksums and sequence numbers. A selective retransmission mechanism is applied to correct loss or corruption of data.
This implementation supports a mapping of SCTP into sockets API as defined in the RFC6458(Sockets API extensions for SCTP). Two styles of interfaces are supported.
A one-to-many style interface with 1 to MANY relationship between socket and associations where the outbound association setup is implicit. The syntax of a one-to-many style socket() call is
sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
A typical server in this style uses the following socket calls in sequence to prepare an endpoint for servicing requests.
1. socket()
2. bind()
3. listen()
4. recvmsg()
5. sendmsg()
6. close()
A typical client uses the following calls in sequence to setup an association with a server to request services.
1. socket()
2. sendmsg()
3. recvmsg()
4. close()
A one-to-one style interface with a 1 to 1 relationship between socket and association which enables existing TCP applications to be ported to SCTP with very little effort. The syntax of a one-to-one style socket() call is
sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
A typical server in one-to-one style uses the following system call sequence to prepare an SCTP endpoint for servicing requests:
1. socket()
2. bind()
3. listen()
4. accept()
The accept() call blocks until a new association is set up. It returns with a new socket descriptor. The server then uses the new socket descriptor to communicate with the client, using recv() and send() calls to get requests and send back responses. Then it calls
5. close()
to terminate the association. A typical client uses the following system call sequence to setup an association with a server to request services:
1. socket()
2. connect()
After returning from connect(), the client uses send() and recv() calls to send out requests and receive responses from the server. The client calls
3. close()
to terminate this association when done.
SCTP is built on top of IP (see ip(7)). The address formats defined by ip(7) apply to SCTP. SCTP only supports point-to-point communication; broadcasting and multicasting are not supported.
These variables can be accessed by the /proc/sys/net/sctp/* files or with the sysctl(2) interface. In addition, most IP sysctls also apply to SCTP. See ip(7).
These variables can be accessed by the /proc/net/sctp/* files.
The ancillary data is carried in msg_control field of struct msghdr, which is used in sendmsg(2) and recvmsg(2) call. The SCTP stack uses the ancillary data to communicate the attributes, such as SCTP_RCVINFO, of the message stored in msg_iov to the socket endpoint. Each ancillary data item is preceded by a struct cmsghdr, see cmsg(3). The different cmsg types for SCTP are listed below, and all these related macros and structures are defined in /usr/include/netinet/sctp.h.
Note that an application must use the SCTP_RECVRCVINFO socket option to enable the delivery of this information.
Note that an application must use the SCTP_RECVNXTINFO socket option to enable the delivery of this information.
Note that an application must use the SCTP_RECVRCVINFO and SCTP_RECVNXTINFO socket options accordingly to enable the delivery of this information.
An SCTP application may need to understand and process events and errors that happen on the SCTP stack. These events include network status changes, association startups, remote operational errors, and undeliverable messages. When a notification arrives, recvmsg() returns the notification in the application-supplied data buffer via msg_iov, and sets MSG_NOTIFICATION in msg_flags. See socket option SCTP_EVENT for the event enabling. The different events are listed below, and all these related macros and structures are defined in /usr/include/netinet/sctp.h.
To set or get a SCTP socket option, call getsockopt(2) to read or setsockopt(2) to write the option with the option level argument set to SOL_SCTP. Note that all these macros and structures described for parameters are defined in /usr/include/netinet/sctp.h, and for one-to-one style sockets a specified assoc_id works the same as SCTP_FUTURE_ASSOC.
The parameter type is struct sctp_rtoinfo, for reading and writing. srto_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: srto_max=sysctl_net.sctp.rto_max, srto_min=sysctl_net.sctp.rto_min, srto_initial=sysctl_net.sctp.rto_initial.
The parameter type is struct sctp_assocparams, for reading and writing. sasoc_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. Note that some fields of this structure are for reading only:
struct sctp_assocparams {
sctp_assoc_t sasoc_assoc_id;
__u16 sasoc_asocmaxrxt; (RW)
__u16 sasoc_number_peer_destinations; (R)
__u32 sasoc_peer_rwnd; (R)
__u32 sasoc_local_rwnd; (R)
__u32 sasoc_cookie_life; (RW)
};
Default: sasoc_asocmaxrxt=sysctl_net.sctp.association_max_retrans, sasoc_cookie_life=sysctl_net.sctp.valid_cookie_life.
The parameter type is struct sctp_initmsg, for reading and writing.
Default: sinit_num_ostreams=10, sinit_max_instreams=10, sinit_max_attempts=sysctl_net.sctp.max_init_retransmits, sinit_max_init_timeo=sysctl_net.sctp.rto_max.
The parameter type is int boolean, for reading and writing.
Default: 0.
The parameter type is int(seconds), for reading and writing. 0 indicates that no automatic close of any associations should be performed.
Default: sysctl_net.sctp.max_autoclose.
The parameter type is struct sctp_setpeerprim, for writing only. sspp_assoc_id is a specified assoc_id.
Default: the 1st local address added. Require: SCTP_ASCONF_SUPPORTED.
The parameter type is struct sctp_prim, for writing only. ssp_assoc_id is a specified assoc_id.
Default: the 1st peer address added. Require: SCTP_ASCONF_SUPPORTED.
The parameter type is int boolean, for reading and writing.
Default: 0.
The parameter type is struct sctp_paddrparams, for reading and writing. spp_address is a specified transport address or 0, spp_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: hbinterval=sysctl_net.sctp.hb_interval, pathmaxrxt=sysctl_net.sctp.path_max_retrans, pathmtu=dev/route's, sackdelay=sysctl_net.sctp.sack_timeout, param_flags=HB_ENABLE|PMTUD_ENABLE|SACKDELAY_ENABLE, flowlabel=0, dscp=0.
The parameter type is struct sctp_sndrcvinfo. For reading, sinfo_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, sinfo_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: default_stream=0, default_flags=0, default_ppid=0, default_context=0, default_timetolive=0.
The parameter type is struct sctp_event_subscribe, for reading and writing.
Default: 0.
The parameter type is int boolean, for reading and writing.
Default: 1.
The parameter type is struct sctp_assoc_value, for reading and writing. assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: 0(no limit).
The parameter type is struct sctp_status, for reading only. sstat_assoc_id is a specified assoc_id.
The parameter type is struct sctp_paddrinfo, for reading only. spinfo_address is a specified transport address, sas_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
The parameter type is struct sctp_assoc_stats, for reading only. sas_assoc_id is a specified assoc_id.
The parameter type is struct sctp_sack_info. For reading, sack_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, sack_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: sackdelay=sysctl_net.sctp.sack_timeout,sackfreq=2.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: 0.
The parameter type is int boolean, for reading and writing.
Default: 0.
The parameter type is uint32_t, for reading and writing.
Default: 0.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: sysctl_net.sctp.max_burst.
The parameter type is struct sauth_chunk, for writing only.
Default: no chunks. Require: SCTP_AUTH_SUPPORTED. RFC: RFC4895.
The parameter type is struct sctp_hmacalgo, for reading and writing. shmac_idents can include SCTP_AUTH_HMAC_ID_{SHA1|SHA256}.
Default: SCTP_AUTH_HMAC_ID_SHA1. Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authkey, for writing only. sca_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: null_key. Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authkeyid, for writing only. scact_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: 0. Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authkeyid, for writing only. scact_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authkeyid, for writing only. scact_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authchunks, for reading only. gauth_assoc_id is a specified assoc_id.
Require: SCTP_AUTH_SUPPORTED.
The parameter type is struct sctp_authchunks, for reading only. gauth_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Require: SCTP_AUTH_SUPPORTED.
The parameter type is uint32_t, for reading only.
The parameter type is struct sctp_assoc_ids, for reading only.
The parameter type is struct sctp_assoc_value, for reading and writing. assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.pf_expose.
The parameter type is struct sctp_paddrthlds, for reading and writing. spt_address is a specified transport address or 0, spt_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: pathmaxrxt=sysctl_net.sctp.path_max_retrans, ps_retrans=sysctl_net.sctp.ps_retrans.
The parameter type is struct sctp_paddrthlds_v2, for reading and writing. spt_address is a specified transport address or 0, spt_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: pathmaxrxt=sysctl_net.sctp.path_max_retrans, ps_retrans=sysctl_net.sctp.ps_retrans, pf_retrans=sysctl_net.sctp.pf_retrans.
The parameter type is int, for reading and writing.
Default: 0.
The parameter type is int, for reading and writing.
Default: 0.
The parameter type is struct sctp_sndinfo. For reading, snd_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, snd_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
Default: default_stream=0, default_flags=0, default_ppid=0, default_context=0.
The parameter type is int, for reading and writing.
Default: 0.
The parameter type is struct sockaddr[], for writing only.
The parameter type is struct sockaddr[], for writing only.
The parameter type is sctp_peeloff_arg_t, for reading only. associd is a specified assoc_id.
The parameter type is sctp_peeloff_flags_arg_t, for reading only. associd is a specified assoc_id.
The parameter type is struct sockaddr[], for writing only.
The parameter type is struct sockaddr[], for writing only. The new assoc's id is passed to users by the return value.
The parameter type is struct sctp_getaddrs_old, for reading only. assoc_id is set to the new assoc's id by kernel and passed to users.
The parameter type is struct sctp_getaddrs, for reading only. assoc_id is a specified assoc_id.
The parameter type is struct sctp_getaddrs, for reading only. assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
The parameter type is struct sctp_setadaptation, for reading and writing.
Default: 0.
The parameter type is struct sctp_event. For reading, se_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, se_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC. se_type can be one of enum sctp_sn_type.
Default: 0.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.prsctp_enable. RFC: RFC7496.
The parameter type is struct sctp_default_prinfo. For reading, pr_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, pr_assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC. pr_policy can be SCTP_PR_SCTP_{NONE|TTL|RTX|PRIO}.
Default: SCTP_PR_SCTP_NONE. Require: SCTP_DEFAULT_PRINFO.
The parameter type is struct sctp_prstatus, for reading only. sprstat_assoc_id is a specified assoc_id, sprstat_policy can be SCTP_PR_SCTP_{TTL|RTX|PRIO|ALL}.
The parameter type is struct sctp_prstatus, for reading only. sprstat_assoc_id is a specified assoc_id, sprstat_policy can be SCTP_PR_SCTP_{TTL|RTX|PRIO|ALL}.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.reconf_enable. RFC: RFC6525.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC. assoc_value can be SCTP_ENABLE_{RESET_STREAM_REQ|RESET_ASSOC_REQ|CHANGE_ASSOC_REQ}.
Default: 0. Require: SCTP_RECONFIG_SUPPORTED.
The parameter type is struct sctp_reset_streams, for writing only. srs_assoc_id is a specified assoc_id.
Require: SCTP_ENABLE_STREAM_RESET.
The parameter type is sctp_assoc_t, for writing only. It is a specified assoc_id.
Require: SCTP_ENABLE_STREAM_RESET.
The parameter type is struct sctp_add_streams, for writing only. sas_assoc_id is a specified assoc_id.
Require: SCTP_ENABLE_STREAM_RESET.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is a specified assoc_id or SCTP_{FUTURE|CURRENT|ALL}_ASSOC. assoc_value can be SCTP_SS_{FCFS|PRIO|RR|FC|WFQ}.
Default: SCTP_SS_FCFS. RFC: RFC8260.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id. For writing, assoc_id is a specified assoc_id or SCTP_CURRENT_ASSOC.
Require: SCTP_STREAM_SCHEDULER.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.intl_enable. Require: SCTP_FRAGMENT_INTERLEAVE. RFC: RFC8260.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.addip_enable. RFC: RFC5061.
The parameter type is int boolean, for reading and writing.
Default: sysctl_net.sctp.default_auto_asconf.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, ssoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.auth_enable. RFC: RFC4895.
The parameter type is struct sctp_assoc_value. For reading, assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC. For writing, assoc_id is SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.ecn_enable.
The parameter type is struct sctp_udpencaps, for reading and writing. sue_address is a specified transport address or 0, sue_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: sysctl_net.sctp.encap_port. RFC: RFC6951.
The parameter type is struct sctp_probeinterval, for reading and writing. spi_address is a specified transport address or 0, spi_assoc_id is a specified assoc_id or SCTP_FUTURE_ASSOC.
Default: 0(disabled). RFC: RFC8899.
Sridhar Samudrala <sri@us.ibm.com>
socket(7), socket(2), ip(7), bind(2), listen(2), accept(2), connect(2), sendmsg(2), recvmsg(2), sysctl(2), getsockopt(2), sctp_bindx(3), sctp_connectx(3), sctp_sendmsg(3), sctp_sendv(3), sctp_send(3), sctp_recvmsg(3), sctp_recvv(3), sctp_peeloff(3), sctp_getladdrs(3), sctp_getpaddrs(3), sctp_opt_info(3).
RFC2960, RFC3309 for the SCTP specification.
2005-10-25 | Linux Man Page |