SCTP Programmer's Guide HP-UX 11i v2, HP-UX 11i v3 HP Part Number: 5992-4578 Published: April 2008 Edition: 1
© Copyright 2007–2008 Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice.
Table of Contents About This Document...................................................................................................................13 Intended Audience.............................................................................................................13 Document Organization.....................................................................................................13 Typographical Conventions.............................................................................
Overview............................................................................................................................41 Socket API Versus SCTP Socket API..................................................................................41 Different Socket API Styles.................................................................................................42 One-to-One Socket APIs................................................................................................
3 Compiling and Running Applications that Use the SCTP Socket APIs..............................................69 Compiling Applications that Use the SCTP APIs..............................................................69 Running Sample Applications that use the SCTP APIs.....................................................70 4 Migrating TCP Applications to SCTP...........................................................................................73 A SCTP Sample Programs............................
List of Figures 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 The Internet Protocol Stack.........................................................................................20 Three-Way Handshake in TCP....................................................................................21 Four-Way Handshake in SCTP...................................................................................22 SCTP Packet Format....................................................................................................
List of Tables 1-1 1-2 2-1 Chunk Types...............................................................................................................24 Comparison Between SCTP, TCP, and UDP...............................................................27 Data Structures in the recvmsg() and sendmsg() Calls........................................
List of Examples 3-1 3-2 3-3 Sample Commands to Compile the Server and Client Programs...............................70 Sample Command to Run the Server Application......................................................70 Sample Command to Run the Client Application......................................................
About This Document This document describes how to write, compile, and run applications using Stream Control Transmission Protocol (SCTP) socket APIs on systems running the HP-UX 11i v2 and HP-UX 11i v3 operating systems. HP's implementation of SCTP conforms to the RFCs and RFC drafts listed in “Related Information” (page 14). The document printing date and part number indicate the document’s current edition. The printing date will change when a new edition is printed.
audit(5) Book Title KeyCap Emphasis Emphasis Term ComputerOut UserInput Command Variable [] {} ... | An HP-UX manpage. The name of the manpage is audit and 5 is the section in the HP-UX Reference. On the web and on the Instant Information CD, it may be a link to the manpage itself. From the HP-UX command line, you can enter “man audit” or “man 5 audit” to view the manpage. See man(1). The title of a book. On the web and on the Instant Information CD, it may be a link to the book itself.
— RFC 3873 (Stream Control Transmission Protocol (SCTP) Management Information Base (MIB)) at: http://www.ietf.org/rfc/rfc3873.txt?number=3873 — RFC 3309 (Stream Control Transmission Protocol (SCTP) Checksum Change) at: http://www.ietf.org/rfc/rfc3309.txt?number=3309 — RFC 3758 (Stream Control Transmission Protocol (SCTP) Partial Reliability Extension) at: http://www.ietf.org/rfc/rfc3758.txt?number=3758 — RFC 4460 (Stream Control Transmission Protocol (SCTP) Specification Errata and Issues) at: http://www.
1 Introduction This chapter introduces Stream Control Transmission Protocol (SCTP). It also discusses the SCTP architecture, the features that SCTP supports, the security features that SCTP offers, and error handling.
NOTE: In SCTP, the term “stream” refers to a sequence of user messages that are delivered in sequence, with respect to other messages within the same stream. In TCP, “stream” refers to a sequence of bytes.
• • • TCP not only makes partial ordering of data impossible, it also causes unnecessary delay in the overall data delivery. Moreover, if a single packet is lost, delivery of subsequent packets is blocked until the lost TCP packet is delivered. This causes head-of-line (HOL) blocking. TCP transmits data in a stream. This requires that applications add their own record marking, to delineate their messages.
• • “SCTP Packet” (page 23) “Congestion Control in SCTP” (page 26) SCTP in the IP Stack Figure 1-1 illustrates a typical IP stack and denotes the layer in which SCTP is located. Figure 1-1 The Internet Protocol Stack An Internet protocol stack contains several layers and each layer provides a specific functionality. Following are the layers in an IP stack and their functionalities: • • • • 20 The physical layer defines the physical means of sending data over network devices.
• • Control Protocol (TCP) and the User Datagram Protocol (UDP). TCP supports reliable and sequential packet delivery through error recovery and flow control mechanisms. UDP is a simple message-based connectionless protocol compared to TCP. SCTP is yet another transport layer protocol that application developers can use to transmit data between endpoints. The socket layer provides the transport layer with an interface to interact with the application layer.
1. 2. 3. Host A sends a Synchronize (SYN) packet to Host B. Upon receiving the SYN packet, Host B allocates resources for the connection and sends a Synchronize-Acknowledge (SYN-ACK) packet to Host A. Host A sends an ACK packet to confirm the receipt of the SYN-ACK packet. The connection is set up between Host A and Host B, and Host A can now start sending data to Host B. Figure 1-3 illustrates the four-way handshake in SCTP.
4. COOKIE-ECHO packet. As a result, the conversation ends without the server allocating any resources for the connection. Host B responds with a COOKIE-ACK chunk and allocates resources for the connection. The connection is now established between Host A and Host B. Host A can now start sending data to Host B. In SCTP, the transfer of data may be delayed because of the additional handshake. The four-way handshake may seem to be less efficient than a three-way handshake.
An SCTP packet contains a common header, and one or more chunks. The SCTP common header contains the following information: • • • Source and destination port numbers to enable multiplexing of different SCTP associations at the same address. A 32-bit verification tag that guards against the insertion of an out-of-date or false message into the SCTP association. A 32-bit checksum for error detection. The checksum can be either a 32-bit CRC checksum or Adler-32 checksum.
Table 1-1 Chunk Types (continued) Chunk Definition Heartbeat Request ( HEARTBEAT) Tests the connectivity of a specific destination address in the association. Heartbeat Acknowledgement ( Acknowledges the receipt of the HEARTBEAT HEARTBEAT ACK) chunk. Chunk Flag Chunk Length Chunk Data Abort Association (ABORT) Informs the peer endpoint to close the association. The ABORT chunk also informs the receiver of the reason for aborting the association. Operation Error (ERROR) Reports error conditions.
Congestion Control in SCTP SCTP uses various congestion control algorithms to effectively handle network failures or unexpected traffic surges, and ensures quick recovery from data congestion. SCTP and TCP support the same set of congestion control algorithms. Following are the congestion control algorithm supported by SCTP: • • Slow Start and Congestion Control Fast Retransmit and Fast Recovery However, in SCTP, the congestion control algorithms are modified to suite the protocol-specific requirements.
Partial Bytes Acknowledged (partial_byte_acked) Adjusts of the cwnd parameter. In an SCTP connection, the sender uses the slow start algorithm if the value of cwnd is less than the ssthresh value. If the value of cwnd is greater than the ssthresh value, the sender uses the congestion avoidance algorithm. If the values for cwnd and ssthresh are same, the sender can use either the slow start or congestion avoidance algorithm.
Table 1-2 Comparison Between SCTP, TCP, and UDP (continued) Feature SCTP TCP UDP Multi-stream support yes no no Unordered data delivery yes no yes Security cookie against SYN flood attack yes no no Built-in heartbeat (reachability check) yes no3 1 2 3 In UDP, a node can communicate with another node without going through a setup procedure, or without changing any state information.
Figure 1-5 A Single-Homed Connection In Figure 1-5, Host A contains a single network interface (NIA1) and Host B contains a single network interface (NIB1). NIA1 is the only interface for Host A to interact with Host B. When a network or path failure occurs, the endpoint is completely isolated from the network. Multihoming in SCTP ensures better chances of survival if a network failure occurs, when compared to TCP.
may occur because of continued failure to send DATA to the primary address. As a result, all DATA chunks are transmitted to the alternate address until the HEARTBEAT chunks have re-established contact with the primary address During the initiation of an association, the SCTP endpoints exchange the list of IP addresses, so that each endpoint can receive messages from any of the addresses associated with the remote endpoint.
Figure 1-7 illustrates how multi-streaming works in an SCTP association. Figure 1-7 Multistreaming in an SCTP Association NOTE: By default, SCTP contains two streams. SCTP uses stream 0 as the default stream to transmit data. Applications can modify the number of streams through which SCTP transmits data. Conservation of Data Boundaries In SCTP, a sending application can construct a message out of a block of data bytes and instruct SCTP to transport the message to a receiving application.
before completing the shutdown process. When an immediate shutdown is required, SCTP sends an ABORT message to an endpoint. Figure 1-8 illustrates graceful shutdown in SCTP and the half-closed state in TCP. Figure 1-8 Shutdown in TCP and SCTP SCTP Support for IPv4 and IPv6 Addresses SCTP supports both IPv4 and IPv6 address parameters in an SCTP packet, as defined in RFC 2960 (Stream Control Transmission Protocol).
the delay between SACKs. The frequency of sending SACKs increases to one per received packet if gaps are detected in the TSN sequence. For information on an SCTP packet, see “SCTP Packet” (page 23). • SCTP contains various congestion control algorithms, such as slow start, congestion avoidance, fast recovery, and fast retransmit, to control the flow and retransmission of data. For information on these congestion control algorithms see, “Congestion Control in SCTP” (page 26).
under-utilization of the network link. Depending on the severity of the error, the sender can remain in a state of congestion, which affects the performance of the association. SCTP contains the PKTDROP chunk that discovers packets that are dropped because of errors other than congestion. After receiving the PKTDROP chunk, an SCTP endpoint can inform its peer that it has received an SCTP packet with an incorrect CRC32C or Adler-32 checksum.
that provides congestion signal to the sender. This is because ECN does not contain mechanisms to avoid network elements from clearing the ECNE flag. Moreover, ECN requires the cooperation of the receiver to return congestion experienced signals to the sender. If the receiver erases the congestion signals to conceal congestion and does not send these signals to the sender, the sender gains a performance advantage at the expense of competing connections that do not experience congestion.
The communication failure detection and protection capabilities of reliable SCTP data traffic are also applicable to partially reliable data traffic. PR-SCTP enables an endpoint to detect a failure destination address quickly and to failover to an alternate destination address. It also notifies when the destination address becomes unreachable. The chunk bundling capability in SCTP enables reliable and unreliable messages to be multiplexed over a single PR-SCTP association.
• • Restrain from sending a FORWARD TSN chunk at any time during the lifetime of an association. Check with the upper layer if it has requested a notification on whether the peer endpoint supports the Forward-TSN-Supported parameter. Error Handling in SCTP The network traffic in the Internet is unpredictable. Sudden network failures and traffic surges can occur, which result in non-reachability of an endpoint.
SCTP also uses the four SACK rule to avoid retransmission caused by normal occurrences, such as packets received out of sequence. HEARTBEATs to Identify Path Failures SCTP periodically sends HEARTBEAT chunks to idle destinations, or alternate addresses to identify a path failure. SCTP maintains a counter to store the number of heartbeats that are sent to the inactive destination, without receiving a corresponding Heartbeat Ack chunk.
information, together with a valid lifetime and a signature for authentication, and sends these back in the INIT ACK chunk. The blind attacker cannot obtain the cookie, because the INIT ACK always goes back to the source address of the INIT. A valid SCTP client gets the cookie and returns it in the COOKIE ECHO chunk, where the SCTP server can validate the cookie and use it to rebuild the TCB. The cookie is created by the server, and the cookie format and secret key remain with the server.
2 SCTP Socket APIs This chapter discusses the different SCTP socket API types, their call flow sequence, SCTP events and notifications, socket options, command socket calls, and the SCTP ancillary data structures.
However, because of the unique features of SCTP, such as multistreaming and multihoming, the existing socket APIs either do not work on an SCTP socket, or the semantics of the socket APIs need modification. For example, because of the multi-homing feature supported in SCTP, the socket APIs, getsockname() and getpeername(), do not work on an SCTP socket if a given association is bound to multiple local addresses and the association has multiple peer addresses.
Basic One-to-One Call Flow Sequence A one-to-one style SCTP application uses the following system call sequence to prepare an SCTP endpoint for servicing requests: 1. 2. 3. 4. 5. 6. socket() bind() or sctp_bindx() sctp_getladdrs() sctp_freeladdrs listen() accept() When a client sends a connection request to the server, the accept() call returns with a new socket descriptor.
SOCK_STREAM IPPROTO_SCTP Indicates the creation of a one-to-one style socket. Specifies the type of the protocol. The first syntax of the socket() socket API creates an endpoint that can use only IPv4 addresses, while the second syntax creates an endpoint, which can use both IPv6 and IPv4 addresses. The bind() Socket API Applications use bind() to specify the local address with which an SCTP endpoint must associate.
The listen() Socket API Applications use listen() to prepare the SCTP endpoint for accepting inbound associations. Following is the syntax for the listen() socket API: int listen(int sd, int backlog); where: sd backlog Represents the socket descriptor of the SCTP endpoint. Represents the maximum number of outstanding associations allowed in the accept queue of the socket. These associations have completed the four-way initiation handshake and are in the ESTABLISHED state.
If SCTP does not call the bind() API before calling connect() , the application picks a transient port and chooses an address set that is equivalent to binding with INADDR_ANY and IN6ADDR_ANY for IPv4 and IPv6 sockets, respectively. One of these addresses serves as the primary address for the association. When an application calls bind() with the INADDR_ANY or the IN6ADDR_ANY_INIT wildcard address, the multihoming feature is enabled in SCTP.
descriptor open, so that the receiving endpoint can receive data that SCTP was unable to deliver. The sendmsg() and recvmsg() Socket APIs Applications use the sendmsg() and recvmsg() socket APIs to transmit data to and receive data from its peer. Following is the syntax for the sendmsg() and recvmsg() socket APIs: ssize_t sendmsg(int sd, const struct msghdr *message, int flags); ssize_t recvmsg(int sd, struct msghdr *message, int flags); where: sd message Represents the socket descriptor of the endpoint.
NOTE: A sendmsg() API does not fail if it contains an invalid SCTP stream identifier but an error is returned on all subsequent calls on the file descriptor. The getpeername() Socket API Applications use the getpeername() socket API to retrieve the primary socket address of the peer. Following is the syntax for the getpeername() socket API: int getpeername(int sd, struct sockaddr *address, socklen_t *len); where: sd address len Specifies the socket descriptor to be queried.
7. 8. 9. 10. 11. sctp_setpaddrs() recvmsg() or sctp_recvmsg() sendmsg() or sctp_sendmsg() sctp_peeloff() close() A client in the one-to-many style API uses the following call sequence to set up an association with a server, and to request services from that server: 1. 2. 3. 4. socket() sendmsg() or sctp_sendmsg() recvmsg() or sctp_recvmsg() close() By default, all the associations connected to an endpoint are represented with a single socket.
sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); or sd = socket(PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP); where: SOCK_SEQPACKET IPProto_SCTP PF_INET PF_INET6 Indicates the creation of a one-to-one or one-to-many style socket. Specifies the type of the protocol. Specifies the IPv4 domain. Specifies the IPv6 domain. The first syntax of socket() creates an endpoint that can use only IPv4 addresses, while the second syntax creates an endpoint that can use both IPv6 and IPv4 addresses.
binding with a wildcard address. One of the addresses in the address set serves as the primary address for the association. This automatically enables the multi-homing feature of SCTP. The listen() Socket API An application uses listen() to indicate that a socket is ready to accept new associations. Following is the syntax for the listen() socket API: int listen(int sd, int backlog); where: sd backlog Specifies the socket descriptor of the endpoint. Defines the number of connections in the listen queue.
The close() Socket API Applications use close() to gracefully shutdown all the associations represented by a one-to-many style socket. Following is the syntax for the close() socket API: close(int sd); where: sd Specifies the socket descriptor of the associations to be closed. To gracefully shutdown a specific association that is represented by the one-to-many style socket, an application must use the sendmsg() call and include the MSG_EOF flag.
You can use the getsockopt() and setsockopt() system calls to modify the socket options. These system calls set or retrieve socket interface options, or lower-level protocol options. Following is the syntax for the getsockopt() system call: int getsockopt( int s, int level, int optname, void *optval, int *optlen ); where: s level optname optval optlen Indicates the file descriptor. Specifies the type of protocol. You must set the level to IPPROTO_SCTP for all the SCTP options. Specifies the option name.
In the case of the one-to-many style APIs, the socket options are applied to all associations that belong to a socket. For a one-to-one API, the socket options apply to all peer addresses of the association controlled by the socket. In the SCTP stack, the getsockopt() is read-only. This means that applications cannot specify any information in the getsockopt() call. As a result, applications must use the sctp_opt_info() API to pass information both into and out of the SCTP stack.
The send(), sendto(), recv(), and recvfrom() Socket Calls Applications can use the send() and sendto() socket calls to transmit data to the peer. The recv() and recvfrom() socket calls can be used to receive data from the peer.
NOTE: If an application calls a send function without user and ancillary data, SCTP rejects the request with an appropriate error message. The setsocktopt() and getsockopt() Socket Calls Applications use the setsockopt() and the getsockopt() calls to set and retrieve socket options. You can use the socket options to modify the default behavior of the sockets calls. For information on socket options, see “API Options to Modify Socket Behavior” (page 52).
The getsockname() Socket Call Applications use getsockname() to retrieve the locally-bound socket address of the specified socket. This is especially useful if the caller allows SCTP to select a local port. The getsockname() API is also useful if an SCTP endpoint is not multihomed. An HP-UX socket uses its copy of the bound address to implement the getsockname() system call.
union sctp_notification { struct { uint16_t sn_type; uint16_t sn_flags; uint32_t sn_length; } sn_header; struct sctp_assoc_change struct sctp_paddr_change struct sctp_remote_error struct sctp_send_failed struct sctp_shutdown_event struct sctp_adaption_event struct sctp_pdapi_event }; /* Notification type.
An SCTP application can use ancillary data structures to communicate certain aspects of an association, such as: • • Treating a user date if it cannot be sent in a certain time Specifying the number of inbound streams to be advertised during association setup SCTP provides the following ancillary data structures: • • SCTP Initiation Structure SCTP Header Information The following sections discuss these ancillary data structures in detail.
Following is the data structure for the sctp_sndrcvinfo structure: struct sctp_sndrcvinfo { uint16_t sinfo_stream; uint16_t sinfo_ssn; uint16_t sinfo_flags; uint32_t sinfo_ppid; uint32_t sinfo_context; uint32_t sinfo_timetolive; uint32_t sinfo_tsn; uint32_t sinfo_cumtsn; sctp_assoc_t sinfo_assoc_id; }; The msghdr structure in the recvmsg() and sendmsg() APIs uses the sctp_sndrcvinfo structure to set and get various control information from the SCTP endpoint.
Table 2-1 Data Structures in the recvmsg() and sendmsg() Calls (continued) Variable recvmsg() sendmsg() sinfo_tsn Specifies the transmission sequence number (TSN) assigned to one of the SCTP data chunks. Not applicable sinfo_cumtsn Specifies the cumulative TSN, while presenting an unordered message (if the MSG_UNORDRED flag is set) Not applicable sinfo_assoc_id Specifies the association ID. Specifies the association ID.
sctp_bindx() returns an array of type sockaddr_in6. For an IPv4 socket, sctp_bindx() returns an array of type sockaddr_in. Specifies the number of addresses in the array (sockaddr_in6 or sockaddr_in). You cannot use wildcard addresses with sctp_bindx(). Contains flags affecting the message that is being sent.
On success, sctp_getpaddrs() returns the number of peer addresses in the association. The sctp_getpaddrs() API can fail for the following reasons: • • If an association does not exist on a socket, sctp_getpaddrs() returns 0. The value of *addrs is undefined. If an error occurs, sctp_getpaddrs() returns -1 and the value of *addrs is left undefined. The sctp_freepaddrs() SCTP Socket API Applications must use the sctp_freepaddrs() socket API to free all resources allocated by the sctp_getpaddrs() API.
The sctp_freeladdrs() SCTP Socket API Applications use the sctp_freeladdrs() API to free all resources allocated by the sctp_getladdrs() socket API. Following is the syntax for the sctp_freeladdrs() API: void sctp_freeladdrs(struct sockaddr *addrs); where: addrs Specifies the array of peer addresses returned by the sctp_getladdrs() socket API. The sctp_sendmsg() SCTP Socket API Applications can use sctp_sendmsg() to send an SCTP message.
The sctp_recvmsg() SCTP Socket API Applications can use the sctp_recvmsg() SCTP socket API to receive messages. This API is similar to the recvmsg() API, with the SCTP_SNDRCV option. For the sctp_sndrcvinfo structure to be populated by sctp_recvmsg(), an application must enable the sctp_data_io_events with the SCTP_EVENTS option.
The sctp_send() SCTP Socket API Applications can use the sctp_send() SCTP socket API to send data without using the cmsg header structures. This API is similar to the sendmsg() API, with the SCTP_SNDRCV option. Following is the syntax for the sctp_send() SCTP socket API: int sctp_send(int sd, const void *msg, size_t len, const struct sctp_sndrcvinfo *sinfo, int flags); where: sd msg len sinfo flags Specifies the socket descriptor. Specifies the message to be sent. Specifies the length of the message.
sinfo flags Specifies a pointer to an sctp_sndrcvinfo structure used for a sendmsg() call. Contains flags in the same format as the sendmsg() call flags (for example, MSG_DONTROUTE) This API can also be used to terminate an association using an association ID, by setting the sinfo.sinfo_flags to MSG_EOF, and the sinfo.sinf_associd to the association that must be terminated. In such a case, the length of the message is 0 (zero).
3 Compiling and Running Applications that Use the SCTP Socket APIs This chapter discusses how to compile and run an application using the SCTP APIs. SCTP offers one-to-one and one-to-many APIs. Applications can use these APIs to use the protocol-specific features of SCTP. The following libraries contain both the one-to-one and one-to-many APIs: • • libxnet libsctp The libxnet library is an XOPEN library, and the libsctp library is an HP-specific library.
Specifies the /usr/lib/libxnet library. This option indicates that the application program must use the libraries defined in this library during compilation. Specifies the libsctp library. This option indicates that the application program must use the libraries defined in this library during compilation. -lxnet -lsctp Example 3-1 Sample Commands to Compile the Server and Client Programs Consider a server application called srv.c and a client application called cli.c.
#./cli_app where: cli_app ip_address port_number Specifies the executable file. Specifies the IP address of the server to which the client wants to connect. Specifies the port number on which the server accepts connections. NOTE: Before running the server and client applications, ensure that sctpd is running on the system that contains the server and client applications.
4 Migrating TCP Applications to SCTP This chapter discusses the changes required to a migrate a TCP application to SCTP. NOTE: TCP calls, such as bind(), listen(), accept(), connect(), send(), recv(), sendto(), recvfrom(), senmsg(), recvmsg(), work in an SCTP stack without incorporating any changes.
A SCTP Sample Programs This appendix lists the sample programs for a client and server, in both one-to-one and one-to-many associations. Sample Server Programs This section lists the sample server programs in one-to-one and one-to-many associations.
printf("^^^ sendfailed: len=%hu err=%d\n", ssf->ssf_length, ssf->ssf_error); break; case SCTP_PEER_ADDR_CHANGE: spc = &snp->sn_paddr_change; if (spc->spc_aaddr.
perror("listen"); exit(1); } memset (&sri, 0, sizeof(sri)); printf ("{one-to-one}: Waiting for associations ...\n"); FD_ZERO(&fdset); FD_SET(fd, &fdset); /* Wait for new associations */ while(1) { if (select (fd+1, &fdset, 0, 0, 0) <= 0) continue; new_fd = accept (fd, (struct sockaddr *) &cli_addr, (socklen_t *) &le); if (new_fd >=0 ) printf ("\n Connection from: %s\n", inet_ntoa(cli_addr.
#include #include #include #include #include #include #include #include #include
printf("^^^ shutdown event\n"); break; default: printf("unknown type: %hu\n", snp->sn_header.
if (listen(fd, 1) < 0) { perror("listen"); exit(1); } memset (&sri, 0, sizeof(sri)); printf ("{one-to-many}: Waiting for associations ...
int debug=0; int main(argc, argv) int argc; char **argv; { int sock_fd, sz, len, msg_flags; int idleTime = 2; struct sockaddr_in sin[1], serv_addr; struct sctp_event_subscribe event; char buf[256]; struct sctp_sndrcvinfo sri; if (argc < 3) { printf ("\nUsage: <%s> return -1; } \n\n", argv[0]); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons (atoi(argv[2])); serv_addr.sin_addr.
break; printf ("Error, line must be of the form '[stream#]text'\n"); continue; } sri.sinfo_stream = strtol(buf+1, NULL, 0); sz = strlen(buf); len = sizeof(serv_addr); sz = sctp_sendmsg (sock_fd, buf, sz, 0, len, 0, 0, sri.sinfo_stream, 0, 0); if (debug) printf ("sctp_sendmsg:[%d,e:%d]\n", sz, errno); if (sz <= 0) break; sz = sctp_recvmsg (sock_fd, buf, sizeof(buf), 0, 0, &sri, &msg_flags); if (debug) printf ("sctp_recvmsg:[%d,e:%d] ", sz, errno); if (sz <= 0) break; printf ("<-- %s on str %d\n", buf, sri.
{ int sock_fd, sz, len, msg_flags; int idleTime = 2; struct sockaddr_in sin[1], serv_addr; struct sctp_event_subscribe event; char buf[256]; struct sctp_sndrcvinfo sri; if (argc < 3) { printf ("\nUsage: <%s> \n\n", argv[0]); return -1; } serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons (atoi(argv[2])); serv_addr.sin_addr.
len = sizeof(serv_addr); sz = sctp_sendmsg (sock_fd, buf, sz, &serv_addr, len, 0, 0, sri.sinfo_stream, 0, 0); if (debug) printf ("sctp_sendmsg:[%d,e:%d]\n", sz, errno); sz = sctp_recvmsg (sock_fd, buf, sizeof(buf), &serv_addr, &len, &sri, &msg_flags); if (debug) printf ("sctp_recvmsg:[%d,e:%d] ", sz, errno); if (sz <= 0) break; printf ("<-- %s on str %d\n", buf, sri.
Glossary Bundling An optional multiplexing operation, where more than one user message can be carried in the same SCTP packet. Each user message occupies its own DATA chunk. Chunk A unit of information within an SCTP packet, consisting of a chunk header and chunk-specific content. Congestion Window An SCTP variable that limits the data (in bytes) that a sender can send to a particular destination transport address before receiving an acknowledgement.
defined by the combination of an IP address and an SCTP port number (where SCTP is the transport protocol). Unordered Message Unordered messages are "unordered" with respect to any other message, this includes both other unordered and ordered messages. Unordered message can be delivered before or later than ordered messages sent on the same stream. Verification Tag A 32-bit unsigned integer that is randomly generated.
Index Symbols D -lsctp library, 70 -lxnet library, 70 /usr/lib/libsctp library, 73 /usr/lib/libxnet library, 70, 73 D_XOPEN_SOURCE_EXTENDED macro, 69 data boundaries, 31 DATA chunk, 24, 37 default stream in SCTP, 55 delayed acknowledgement, 32 denial of service attack (see DoS) difference in TCP and SCTP, 46 disabling receive operation at an endpoint, 46 disabling send operation at an endpoint, 46 DoS, 19 preventing, 21 A ABORT chunk, 25, 32 achieving half-closed state in SCTP, 46 ACK packet, 22 acknowl
I O IN6ADDR_ANY option, 46 IN6ADDR_ANY_INIT option, 44 INADDR_ANY option, 44, 46 INIT ACK chunk, 24 INIT chunk, 24 INIT-ACK chunk, 22 Initiate tag, 39 initiating an association, 45 IP stack application layer, 21 data link layer, 20 network layer, 20 physical layer, 20 socket layer, 21 transport layer SCTP, 20 IPPROTO_SCTP, 53 IPPROTO_SCTP parameter, 44 IPPROTO_SCTP value, 56 one-to-many client call sequence, 49 one-to-one client call sequence, 43 optlen, 53 buffer size, 53 optlen parameter, 56 optname, 5
control chunk, 24 DATA chunk, 24 SID, 24 SCTP_ASSOC_CHANGE event, 51 SCTP_AUTOCLOSE option, 49 SCTP_EVENTS option, 65 SCTP_INITMSG option, 45 sctp_initmsg structure, 59 sctp_notification structure, 57 sctp_opt_info() call, 54 SCTP_SNDRCV option, 64, 65 sctp_sndrcvinfo structure, 60 selecting peer address (see sockaddr_storage) setsockoptg() call, 57 setting control information (see scto_sndrcvinfo structure) setting socket option, 53 SHUT_RD parameter, 46 SHUT_RDWR parameter, 46 SHUT_WR parameter, 46 shutdo