[ Team LiB ] Previous Section Next Section

10.6 Controlling the Number of Streams

We have seen how SCTP streams can be used, but how can we control the number of streams an endpoint requests at association initialization? Our previous examples used the system default for the number of outbound streams. For the FreeBSD KAME implementation of SCTP, this default is set to 10 streams. What if our application and server would like to use more than 10 streams? In Figure 10.10, we show a modification that allows a server to increase the number of streams the endpoint requests on association startup. Note that this change must be made on the socket before an association is created.

Figure 10.10 Requesting more streams in our server.

sctp/sctpserv02.c

14      if (argc == 2)
15          stream_increment = atoi (argv[1]);
16      sock_fd = Socket (AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
17      bzero (&initm, sizeof (initm));
18      initm.sinit_num_ostreams = SERV_MORE_STRMS_SCTP;
19      Setsockopt (sock_fd, IPPROTO_SCTP, SCTP_INITMSG, &initm, sizeof (initm));

Initial setup

14–16 As before, the server sets up the flags based on additional arguments and opens the socket.

Modifying the streams request

17–19 These lines contain the new code we have added to our server. The server first zeros out the sctp_initmsg structure. This change assures that the setsockopt call will not unintentionally change any other values. The server then sets the sinit_max_ostreams field to the number of streams it would like to request. Next, it sets the socket option with the initial message parameters.

An alternative to setting a socket option would be to use the sendmsg function and provide ancillary data to request different stream parameters from the default. This type of ancillary data is only effective on the one-to-many-style socket interface.

    [ Team LiB ] Previous Section Next Section