Manual.tex 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. %
  2. % Copyright (C) 2012-2015 Irene Ruengeler
  3. % Copyright (C) 2012-2015 Michael Tuexen
  4. %
  5. % All rights reserved.
  6. %
  7. % Redistribution and use in source and binary forms, with or without
  8. % modification, are permitted provided that the following conditions
  9. % are met:
  10. % 1. Redistributions of source code must retain the above copyright
  11. % notice, this list of conditions and the following disclaimer.
  12. % 2. Redistributions in binary form must reproduce the above copyright
  13. % notice, this list of conditions and the following disclaimer in the
  14. % documentation and/or other materials provided with the distribution.
  15. % 3. Neither the name of the project nor the names of its contributors
  16. % may be used to endorse or promote products derived from this software
  17. % without specific prior written permission.
  18. %
  19. % THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  20. % ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. % ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  23. % FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. % DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. % OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. % LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. % OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. % SUCH DAMAGE.
  30. %
  31. \documentclass[a4paper]{article}
  32. %
  33. \usepackage{longtable}
  34. %
  35. \title{Socket API for the SCTP User-land Implementation (usrsctp)}
  36. \author{I.~R\"ungeler%
  37. \thanks{M\"unster University of Applied Sciences,
  38. Department of Electrical Engineering
  39. and Computer Science,
  40. Stegerwaldstr.~39,
  41. D-48565 Steinfurt,
  42. Germany,
  43. \texttt{i.ruengeler@fh-muenster.de}.}
  44. \and
  45. M.~T\"uxen%
  46. \thanks{M\"unster University of Applied Sciences,
  47. Department of Electrical Engineering
  48. and Computer Science,
  49. Stegerwaldstr.~39,
  50. D-48565 Steinfurt,
  51. Germany,
  52. \texttt{tuexen@fh-muenster.de}.}
  53. }
  54. %
  55. \begin{document}
  56. \setcounter{secnumdepth}{4}
  57. \setcounter{tocdepth}{4}
  58. \maketitle
  59. \tableofcontents
  60. \section{Introduction}
  61. In this manual the socket API for the SCTP User-land implementation will be described.
  62. It is based on RFC 6458~\cite{socketAPI}. The main focus of this document is on pointing out
  63. the differences to the SCTP Sockets API. For all aspects of the sockets API that are not
  64. mentioned in this document, please refer to RFC~6458. Questions about SCTP can hopefully be
  65. answered by RFC~4960~\cite{SCTP}.
  66. \section{Getting Started}
  67. The User-land stack has been tested on FreeBSD 10.0, Ubuntu 11.10, Windows 7, Mac OS X 10.6,
  68. and MAC OS X 10.7.
  69. The current version of the User-land stack is provided on \textit{http://sctp.fh-muenster.de/sctp-user-land-stack.html}.
  70. Download the tarball and untar it in a folder of your choice.
  71. The tarball contains all the sources to build the libusrsctp, which has to be linked to the object file of an
  72. example program. In addition there are two applications in the folder \textit{programs} that can be built and run.
  73. \subsection{Building the Library and the Applications}
  74. \subsubsection{Unix-like Operating Systems}
  75. In the folder \textit{usrsctp} type
  76. \begin{verbatim}
  77. ./bootstrap
  78. ./configure
  79. make
  80. \end{verbatim}
  81. Now, the library \textit{libusrsctp.la} has been built in the subdirectory \textit{usrsctplib}, and the example
  82. programs are ready to run from the subdirectory \textit{programs}.
  83. If you have root privileges or are in the sudoer group, you can install the library in \textit{/usr/local/lib}
  84. and copy the header file to \textit{/usr/include} with the command
  85. \begin{verbatim}
  86. sudo make install
  87. \end{verbatim}
  88. \subsubsection{Windows}
  89. On Windows you need a compiler like Microsoft Visual Studio. You can build the library and the
  90. example programs with the command line tool of the compiler by typing
  91. \begin{verbatim}
  92. nmake -f Makefile.nmake
  93. \end{verbatim}
  94. in the directory \textit{usrsctp}.
  95. \subsection{Running the Test Programs}
  96. There are two test programs included, a discard server and a client. You can run both to send data from the
  97. client to the server. The client reads data from stdin and sends them to the server, which prints the message
  98. in the terminal and discards it. The sources of the server are also provided in Section~\ref{server} and those
  99. of the client in Section~\ref{client}.
  100. \subsubsection{Using UDP Encapsulation}
  101. Both programs can either send data over SCTP directly or use UDP encapsulation, thus encapsulating the
  102. SCTP packet in a UDP datagram. The first mode works on loopback or in a protected setup without any
  103. NAT boxes involved. In all other cases it is better to use UDP encapsulation.
  104. The usage of the discard\_server is
  105. \begin{verbatim}
  106. discard_server [local_encaps_port remote_encaps_port]
  107. \end{verbatim}
  108. For UDP encapsulation the ports have to be specified. The local and remote encapsulation ports can be arbitrarily
  109. set.
  110. For example, you can call
  111. \begin{verbatim}
  112. ./discard_server 11111 22222
  113. \end{verbatim}
  114. on a Unix-like OS and
  115. \begin{verbatim}
  116. discard_server.exe 11111 22222
  117. \end{verbatim}
  118. on Windows.
  119. The client needs two additional parameters, the server's address and its port.
  120. Its usage is
  121. \begin{verbatim}
  122. client remote_addr remote_port [local_port local_encaps_port remote_encaps_port]
  123. \end{verbatim}
  124. The remote address is the server's address. If client and server are started on the same machine,
  125. the loopback address 127.0.0.1 can be used for Unix-like OSs and the local address on Windows.
  126. The discard port is 9, thus 9 has to be taken as remote port. The encapsulation ports have to
  127. match those of the server, i.e. the server's local\_encaps\_port is the client's
  128. remote\_encaps\_port and vice versa. Thus, the client can be started with
  129. \begin{verbatim}
  130. ./client 127.0.0.1 9 0 22222 11111
  131. \end{verbatim}
  132. on a Unix-like OS and
  133. \begin{verbatim}
  134. client.exe 192.168.0.1 9 0 22222 11111
  135. \end{verbatim}
  136. on Windows provided your local IP address is 192.168.0.1.
  137. \subsubsection{Sending over SCTP}
  138. To send data over SCTP directly you might need root privileges because raw sockets are used.
  139. Thus instead of specifying the encapsulation ports you have to start the programs prepending
  140. \texttt{sudo} or in case of Windows start the program from an administrator console.
  141. \subsubsection{Using the Callback API}
  142. Instead of asking constantly for new data, a callback API can be used that is triggered by
  143. SCTP. A callback function has to be registered that will be called whenever data is ready to
  144. be delivered to the application.
  145. The discard\_server has a flag to switch between the two modi. If use\_cb is set to 1, the
  146. callback API will be used. To change the setting, just set the flag and compile the program again.
  147. \section{Basic Operations}
  148. All system calls start with the prefix \textit{usrsctp\_} to distinguish them from the kernel variants.
  149. Some of them are changed to account for the different demands in the userland environment.
  150. \subsection{Differences to RFC 6458}
  151. \subsubsection{usrsctp\_init()}
  152. Every application has to start with \textit{usrsctp\_init()}. This function calls \textit{sctp\_init()} and reserves
  153. the memory necessary to administer the data transfer.
  154. The function prototype is
  155. \begin{verbatim}
  156. void
  157. usrsctp_init(uint16_t udp_port)
  158. \end{verbatim}
  159. As it is not always possible to send data directly over SCTP because not all NAT boxes can
  160. process SCTP packets, the data can be sent over UDP. To encapsulate SCTP into UDP
  161. a UDP port has to be specified, to which the datagrams can be sent. This local UDP port is set
  162. with the parameter \texttt{udp\_port}. The default value is 9899, the standard UDP encapsulation port.
  163. If UDP encapsulation is not necessary, the UDP port has to be set to 0.
  164. \subsubsection{usrsctp\_finish()}
  165. At the end of the program \textit{usrsctp\_finish()} should be called to free all the memory that has been
  166. allocated before.
  167. The function prototype is
  168. \begin{verbatim}
  169. int
  170. usrsctp_finish(void).
  171. \end{verbatim}
  172. The return code is 0 on success and -1 in case of an error.
  173. \subsubsection{usrsctp\_socket()}
  174. A representation of an SCTP endpoint is a socket. Is it created with \textit{usrsctp\_socket()}.
  175. The function prototype is:
  176. \begin{verbatim}
  177. struct socket *
  178. usrsctp_socket(int domain,
  179. int type,
  180. int protocol,
  181. int (*receive_cb)(struct socket *sock,
  182. union sctp_sockstore addr,
  183. void *data,
  184. size_t datalen,
  185. struct sctp_rcvinfo,
  186. int flags,
  187. void *ulp_info),
  188. int (*send_cb)(struct socket *sock,
  189. uint32_t sb_free,
  190. void *ulp_info),
  191. uint32_t sb_threshold,
  192. void *ulp_info).
  193. \end{verbatim}
  194. The arguments taken from RFC~6458 are:
  195. \begin{itemize}
  196. \item domain: PF\_INET or PF\_INET6 can be used.
  197. \item type: In case of a one-to-many style socket it is SOCK\_SEQPACKET, in case of a one-to-one style
  198. socket it is SOCK\_STREAM. For an explanation of the differences between the socket types please
  199. refer to RFC~6458.
  200. \item protocol: Set IPPROTO\_SCTP.
  201. \end{itemize}
  202. In usrsctp, a callback API can be used.
  203. \begin{itemize}
  204. \item The function pointers of the receive and send callbacks are new arguments to the socket call. If no callback API is used, these must be \textit{NULL}.
  205. \item The \textit{sb\_threshold} specifies the amount of free space in the send socket buffer before the send function in the application is called. If a send callback function is specified and \textit{sb\_threshold} is 0, the function is called whenever there is room in the send socket buffer.
  206. \item Additional data may be passed along within the \textit{ulp\_info} parameter. This value will be passed to the \textit{receive\_cb} when it is invoked.
  207. \end{itemize}
  208. On success \textit{usrsctp\_socket()} returns the pointer to the new socket in the \texttt{struct socket} data type.
  209. It will be needed in all other system calls. In case of a failure NULL is returned and
  210. errno is set to the appropriate error code.
  211. \subsubsection{usrsctp\_close()}
  212. The function prototype of \textit{usrsctp\_close()} is
  213. \begin{verbatim}
  214. void
  215. usrsctp_close(struct socket *so).
  216. \end{verbatim}
  217. Thus the only difference is the absence of a return code.
  218. \subsection{Same Functionality as RFC 6458}
  219. The following functions have the same functionality as their kernel pendants. There prototypes
  220. are described in the following subsections. For a detailed description please refer to RFC~6458.
  221. \subsubsection{usrsctp\_bind()}
  222. The function prototype of \textit{usrsctp\_bind()} is
  223. \begin{verbatim}
  224. int
  225. usrsctp_bind(struct socket *so,
  226. struct sockaddr *addr,
  227. socklen_t addrlen).
  228. \end{verbatim}
  229. The arguments are
  230. \begin{itemize}
  231. \item so: Pointer to the socket as returned by \textit{usrsctp\_socket()}.
  232. \item addr: The address structure (struct sockaddr\_in for an IPv4 address
  233. or struct sockaddr\_in6 for an IPv6 address).
  234. \item addrlen: The size of the address structure.
  235. \end{itemize}
  236. \textit{usrsctp\_bind()} returns 0 on success and -1 in case of an error.
  237. \subsubsection{usrsctp\_listen()}
  238. The function prototype of \textit{usrsctp\_listen()} is
  239. \begin{verbatim}
  240. int
  241. usrsctp_listen(struct socket *so,
  242. int backlog).
  243. \end{verbatim}
  244. The arguments are
  245. \begin{itemize}
  246. \item so: Pointer to the socket as returned by \textit{usrsctp\_socket()}.
  247. \item backlog: If backlog is non-zero, enable listening, else disable
  248. listening.
  249. \end{itemize}
  250. \textit{usrsctp\_listen()} returns 0 on success and -1 in case of an error.
  251. \subsubsection{usrsctp\_accept()}
  252. The function prototype of \textit{usrsctp\_accept()} is
  253. \begin{verbatim}
  254. struct socket *
  255. usrsctp_accept(struct socket *so,
  256. struct sockaddr * addr,
  257. socklen_t * addrlen).
  258. \end{verbatim}
  259. The arguments are
  260. \begin{itemize}
  261. \item so: Pointer to the socket as returned by \textit{usrsctp\_socket()}.
  262. \item addr: On return, the primary address of the peer (struct sockaddr\_in for an IPv4 address or
  263. struct sockaddr\_in6 for an IPv6 address).
  264. \item addrlen: Size of the returned address structure.
  265. \end{itemize}
  266. \textit{usrsctp\_accept()} returns the accepted socket on success and NULL in case of an error.
  267. \subsubsection{usrsctp\_connect()}
  268. The function prototype of \textit{usrsctp\_connect()} is
  269. \begin{verbatim}
  270. int
  271. usrsctp_connect(struct socket *so,
  272. struct sockaddr *name,
  273. socklen_t addrlen)
  274. \end{verbatim}
  275. The arguments are
  276. \begin{itemize}
  277. \item so: Pointer to the socket as returned by \textit{usrsctp\_socket()}.
  278. \item name: Address of the peer to connect to (struct sockaddr\_in for an IPv4 address or
  279. struct sockaddr\_in6 for an IPv6 address).
  280. \item addrlen: Size of the peer's address.
  281. \end{itemize}
  282. \textit{usrsctp\_connect()} returns 0 on success and -1 in case of an error.
  283. \subsubsection{usrsctp\_shutdown()}
  284. The function prototype of \textit{usrsctp\_shutdown()} is
  285. \begin{verbatim}
  286. int
  287. usrsctp_shutdown(struct socket *so, int how).
  288. \end{verbatim}
  289. The arguments are
  290. \begin{itemize}
  291. \item so: Pointer to the socket of the association to be closed.
  292. \item how: Specifies the type of shutdown. The values are as follows:
  293. \begin{itemize}
  294. \item SHUT\_RD: Disables further receive operations. No SCTP protocol
  295. action is taken.
  296. \item SHUT\_WR: Disables further send operations, and initiates the SCTP
  297. shutdown sequence.
  298. \item SHUT\_RDWR: Disables further send and receive operations, and
  299. initiates the SCTP shutdown sequence.
  300. \end{itemize}
  301. \end{itemize}
  302. \textit{usrsctp\_shutdown()} returns 0 on success and -1 in case of an error.
  303. \section{Sending and Receiving Data}
  304. Since the publication of RFC~6458 there is only one function for sending and one for receiving
  305. that is not deprecated. Therefore, only these two are described here.
  306. \subsection{usrsctp\_sendv()}
  307. The function prototype is
  308. \begin{verbatim}
  309. ssize_t
  310. usrsctp_sendv(struct socket *so,
  311. const void *data,
  312. size_t len,
  313. struct sockaddr *addrs,
  314. int addrcnt,
  315. void *info,
  316. socklen_t infolen,
  317. unsigned int infotype,
  318. int flags).
  319. \end{verbatim}
  320. The arguments are
  321. \begin{itemize}
  322. \item so: The socket to send data on.
  323. \item data: As it is more convenient to send data in a buffer and not a \texttt{struct iovec} data structure, we
  324. chose to pass the data as a void pointer.
  325. \item len: Length of the data.
  326. \item addrs: In this version of usrsctp at most one destination address is supported. In the case of a connected
  327. socket, the parameter \texttt{addrs} can be set to NULL.
  328. \item addrcnt: Number of addresses. As at most one address is supported, addrcnt is 0 if addrs is NULL and
  329. 1 otherwise.
  330. \item info: Additional information for a message is stored in \texttt{void *info}. The data types \texttt{struct~sctp\_sndinfo},
  331. \texttt{struct~sctp\_prinfo}, and \texttt{struct} \linebreak \texttt{sctp\_sendv\_spa} are supported as defined in
  332. RFC~6458. Support for \texttt{structsctp\_authinfo} is not implemented yet, therefore, errno is set EINVAL
  333. and -1 will be returned, if it is used.
  334. \item infolen: Length of info in bytes.
  335. \item infotype: Identifies the type of the information provided in info. Possible values are
  336. SCTP\_SENDV\_NOINFO, SCTP\_SENDV\_SNDINFO, \linebreak SCTP\_SENDV\_PRINFO, SCTP\_SENDV\_SPA.
  337. For additional information please refer to RFC~6458.
  338. \item flags: Flags as described in RFC~6458.
  339. \end{itemize}
  340. \textit{usrsctp\_sendv()} returns the number of bytes sent, or -1 if an error
  341. occurred. The variable errno is then set appropriately.
  342. \subsection{usrsctp\_recvv()}
  343. The function prototype is
  344. \begin{verbatim}
  345. ssize_t
  346. usrsctp_recvv(struct socket *so,
  347. void *dbuf,
  348. size_t len,
  349. struct sockaddr *from,
  350. socklen_t * fromlen,
  351. void *info,
  352. socklen_t *infolen,
  353. unsigned int *infotype,
  354. int *msg_flags).
  355. \end{verbatim}
  356. The arguments are
  357. \begin{itemize}
  358. \item so: The socket to receive data on.
  359. \item dbuf: Analog to \textit{usrsctp\_sendv()} the data is returned in a buffer.
  360. \item len: Length of the buffer in bytes.
  361. \item from: A pointer to an address to be filled with the sender of the
  362. received message's address.
  363. \item fromlen: An in/out parameter describing the from length.
  364. \item info: A pointer to the buffer to hold the attributes of the received
  365. message. The structure type of info is determined by the
  366. infotype parameter. The attributes returned in \texttt{info} have to be
  367. handled in the same way as specified in RFC~6458.
  368. \item infolen: An in/out parameter describing the size of the info buffer.
  369. \item infotype: On return, *infotype is set to the type of the info
  370. buffer. The current defined values are SCTP\_RECVV\_NOINFO,
  371. SCTP\_RECVV\_RCVINFO, SCTP\_RECVV\_NXTINFO, and
  372. SCTP\_RECVV\_RN. A detailed description is given in RFC~6458.
  373. \item flags: A pointer to an integer to be filled with any message flags
  374. (e.g., MSG\_NOTIFICATION). Note that this field is an in/out
  375. parameter. Options for the receive may also be passed into the
  376. value (e.g., MSG\_EOR). Returning from the call, the flags' value
  377. will differ from its original value.
  378. \end{itemize}
  379. \textit{usrsctp\_recvv()} returns the number of bytes sent, or -1 if an error
  380. occurred. The variable errno is then set appropriately.
  381. \section{Socket Options}
  382. Socket options are used to change the default behavior of socket calls.
  383. Their behavior is specified in RFC~6458. The functions to get or set them are
  384. \begin{verbatim}
  385. int
  386. usrsctp_getsockopt(struct socket *so,
  387. int level,
  388. int optname,
  389. void *optval,
  390. socklen_t *optlen)
  391. \end{verbatim}
  392. and
  393. \begin{verbatim}
  394. int
  395. usrsctp_setsockopt(struct socket *so,
  396. int level,
  397. int optname,
  398. const void *optval,
  399. socklen_t optlen).
  400. \end{verbatim}
  401. and the arguments are
  402. \begin{itemize}
  403. \item so: The socket of type struct socket.
  404. \item level: Set to IPPROTO\_SCTP for all SCTP options.
  405. \item optname: The option name as specified in Table~\ref{options}.
  406. \item optval: The buffer to store the value of the option as specified in the second column of Table~\ref{options}.
  407. \item optlen: The size of the buffer (or the length of the option
  408. returned in case of \textit{usrsctp\_getsockopt}).
  409. \end{itemize}
  410. These functions return 0 on success and -1 in case of an error.
  411. \begin{longtable}{|l|l|c|}
  412. \hline
  413. {\bfseries Option}&{\bfseries Datatype} &{\bfseries r/w}\tabularnewline
  414. \endhead
  415. \hline
  416. SCTP\_RTOINFO&struct sctp\_rtoinfo&r/w\tabularnewline \hline
  417. SCTP\_ASSOCINFO&struct sctp\_assocparams&r/w\tabularnewline \hline
  418. SCTP\_INITMSG&struct sctp\_initmsg&r/w\tabularnewline \hline
  419. SCTP\_NODELAY&int&r/w\tabularnewline \hline
  420. SCTP\_AUTOCLOSE&int&r/w\tabularnewline \hline
  421. SCTP\_PRIMARY\_ADDR&struct sctp\_setprim&r/w\tabularnewline \hline
  422. SCTP\_ADAPTATION\_LAYER&struct sctp\_setadaptation&r/w\tabularnewline \hline
  423. SCTP\_DISABLE\_FRAGMENTS&int&r/w\tabularnewline \hline
  424. SCTP\_PEER\_ADDR\_PARAMS&struct sctp\_paddrparams&r/w\tabularnewline \hline
  425. SCTP\_I\_WANT\_MAPPED\_V4\_ADDR&int&r/w\tabularnewline \hline
  426. SCTP\_MAXSEG&struct sctp\_assoc\_value&r/w\tabularnewline \hline
  427. SCTP\_DELAYED\_SACK&struct sctp\_sack\_info&r/w\tabularnewline \hline
  428. SCTP\_FRAGMENT\_INTERLEAVE&int&r/w\tabularnewline \hline
  429. SCTP\_PARTIAL\_DELIVERY\_POINT&int&r/w\tabularnewline \hline
  430. SCTP\_HMAC\_IDENT&struct sctp\_hmacalgo&r/w\tabularnewline \hline
  431. SCTP\_AUTH\_ACTIVE\_KEY&struct sctp\_authkeyid&r/w\tabularnewline \hline
  432. SCTP\_AUTO\_ASCONF&int&r/w\tabularnewline \hline
  433. SCTP\_MAX\_BURST&struct sctp\_assoc\_value&r/w\tabularnewline \hline
  434. SCTP\_CONTEXT&struct sctp\_assoc\_value&r/w\tabularnewline \hline
  435. SCTP\_EXPLICIT\_EOR&int&r/w\tabularnewline \hline
  436. SCTP\_REUSE\_PORT&int&r/w\tabularnewline \hline
  437. SCTP\_EVENT&struct sctp\_event&r/w\tabularnewline \hline
  438. SCTP\_RECVRCVINFO&int&r/w\tabularnewline \hline
  439. SCTP\_RECVNXTINFO&int&r/w\tabularnewline \hline
  440. SCTP\_DEFAULT\_SNDINFO&struct sctp\_sndinfo&r/w\tabularnewline \hline
  441. SCTP\_DEFAULT\_PRINFO&struct sctp\_default\_prinfo&r/w\tabularnewline \hline
  442. SCTP\_REMOTE\_UDP\_ENCAPS\_PORT&int&r/w\tabularnewline \hline
  443. SCTP\_ENABLE\_STREAM\_RESET&struct sctp\_assoc\_value&r/w\tabularnewline \hline
  444. SCTP\_STATUS&struct sctp\_status&r\tabularnewline \hline
  445. SCTP\_GET\_PEER\_ADDR\_INFO&struct sctp\_paddrinfo&r\tabularnewline \hline
  446. SCTP\_PEER\_AUTH\_CHUNKS&struct sctp\_authchunks&r\tabularnewline \hline
  447. SCTP\_LOCAL\_AUTH\_CHUNKS&struct sctp\_authchunks&r\tabularnewline \hline
  448. SCTP\_GET\_ASSOC\_NUMBER&uint32\_t&r\tabularnewline \hline
  449. SCTP\_GET\_ASSOC\_ID\_LIST&struct sctp\_assoc\_ids&r\tabularnewline \hline
  450. SCTP\_RESET\_STREAMS&struct sctp\_reset\_streams&w\tabularnewline \hline
  451. SCTP\_RESET\_ASSOC&struct sctp\_assoc\_t&w\tabularnewline \hline
  452. SCTP\_ADD\_STREAMS&struct sctp\_add\_streams&w\tabularnewline \hline
  453. \caption{Socket Options supported by usrsctp}
  454. \label{options}
  455. \end{longtable}
  456. An overview of the supported options is given in Table~\ref{options}. Their use is described in RFC~6458~\cite{socketAPI}, RFC~6525~\cite{streamReset}, and~\cite{udpencaps}.
  457. \section{Sysctl variables}
  458. In kernel implementations like for instance FreeBSD, it is possible to change parameters
  459. in the operating system. These parameters are called sysctl variables.
  460. In usrsctp applications can set or retrieve these variables with the functions
  461. \begin{verbatim}
  462. void
  463. usrsctp_sysctl_set_ ## (uint32_t value)
  464. \end{verbatim}
  465. and
  466. \begin{verbatim}
  467. uint32_t
  468. usrsctp_sysctl_get_ ## (void)
  469. \end{verbatim}
  470. respectively, where \#\# stands for the name of the variable.
  471. In the following paragraphs a short description of the parameters will be given.
  472. \subsection{Manipulate Memory}
  473. \subsubsection{usrsctp\_sysctl\_set\_sctp\_sendspace()}
  474. The space of the available send buffer can be changed from its default value of 262,144 bytes
  475. to a value between 0 and $2^{32}-1$ bytes.
  476. \subsubsection{usrsctp\_sysctl\_set\_sctp\_recvspace()}
  477. The space of the available receive buffer can be changed from its default value of 262,144 bytes
  478. to a value between 0 and $2^{32}-1$ bytes.
  479. \subsubsection{usrsctp\_sysctl\_set\_sctp\_hashtblsize()}
  480. The TCB (Thread Control Block) hash table sizes, i.e. the size of one TCB in the hash table, can be tuned between
  481. 1 and $2^{32}-1$ bytes. The default value is 1,024 bytes. A TCB contains for instance pointers to the socket, the
  482. endpoint, information about the association and some statistic data.
  483. \subsubsection{usrsctp\_sysctl\_set\_sctp\_pcbtblsize()}
  484. The PCB (Protocol Control Block) hash table sizes, i.e. the size of one PCB in the hash table, can be tuned between
  485. 1 and $2^{32}-1$ bytes. The default value is 256 bytes. The PCB contains all variables that characterize an endpoint.
  486. \subsubsection{usrsctp\_sysctl\_set\_sctp\_system\_free\_resc\_limit()}
  487. This parameters tunes the maximum number of cached resources in the system. It can be set between
  488. 0 and $2^{32}-1$. The default value is 1000.
  489. \subsubsection{usrsctp\_sysctl\_set\_sctp\_asoc\_free\_resc\_limit()}
  490. This parameters tunes the maximum number of cached resources in an association. It can be set between
  491. 0 and $2^{32}-1$. The default value is 10.
  492. \subsubsection{usrsctp\_sysctl\_set\_sctp\_mbuf\_threshold\_count()}
  493. Data is stored in mbufs. Several mbufs can be chained together. The maximum number of small mbufs in a chain
  494. can be set with this parameter, before an mbuf cluset is used. The default is 5.
  495. \subsubsection{usrsctp\_sysctl\_set\_sctp\_add\_more\_threshold()}
  496. TBD
  497. This parameter configures the threshold below which more space should be added to a socket send buffer.
  498. The default value is 1452 bytes.
  499. \subsection{Configure RTO}
  500. The retransmission timeout (RTO), i.e. the time that controls the retransmission of messages, has
  501. several parameters, that can be changed, for example to shorten the time, before a message is
  502. retransmitted. The range of these parameters is between 0 and $2^{32}-1$~ms.
  503. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rto\_max\_default()}
  504. The default value for the maximum retransmission timeout in ms is 60,000 (60~secs).
  505. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rto\_min\_default()}
  506. The default value for the minimum retransmission timeout in ms is 1,000 (1~sec).
  507. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rto\_initial\_default()}
  508. The default value for the initial retransmission timeout in ms is 3,000 (3~sec). This value is only
  509. needed before the first calculation of a round trip time took place.
  510. \subsubsection{usrsctp\_sysctl\_set\_sctp\_init\_rto\_max\_default()}
  511. The default value for the maximum retransmission timeout for an INIT chunk in ms is 60,000 (60~secs).
  512. \subsection{Set Timers}
  513. \subsubsection{usrsctp\_sysctl\_set\_sctp\_valid\_cookie\_life\_default()}
  514. A cookie has a specified life time. If it expires the cookie is not valid any more and an ABORT is sent.
  515. The default value in ms is 60,000 (60~secs).
  516. \subsubsection{usrsctp\_sysctl\_set\_sctp\_heartbeat\_interval\_default()}
  517. Set the default time between two heartbeats. The default is 30,000~ms.
  518. \subsubsection{usrsctp\_sysctl\_set\_sctp\_shutdown\_guard\_time\_default()}
  519. If a SHUTDOWN is not answered with a SHUTDOWN-ACK while the shutdown guard timer is still
  520. running, the association will be aborted after the default of 180~secs.
  521. \subsubsection{usrsctp\_sysctl\_set\_sctp\_pmtu\_raise\_time\_default()}
  522. TBD
  523. To set the size of the packets to the highest value possible, the maximum transfer unit (MTU)
  524. of the complete path has to be known. The default time interval for the path mtu discovery
  525. is 600~secs.
  526. \subsubsection{usrsctp\_sysctl\_set\_sctp\_secret\_lifetime\_default()}
  527. TBD
  528. The default secret lifetime of a server is 3600~secs.
  529. \subsubsection{usrsctp\_sysctl\_set\_sctp\_vtag\_time\_wait()}
  530. TBD
  531. Vtag time wait time, 0 disables it. Default: 60~secs
  532. \subsection{Set Failure Limits}
  533. Transmissions and retransmissions of messages might fail. To protect the system against too many
  534. retransmissions, limits have to be defined.
  535. \subsubsection{usrsctp\_sysctl\_set\_sctp\_init\_rtx\_max\_default()}
  536. The default maximum number of retransmissions of an INIT chunks is 8, before an ABORT is sent.
  537. \subsubsection{usrsctp\_sysctl\_set\_sctp\_assoc\_rtx\_max\_default()}
  538. This parameter sets the maximum number of failed retransmissions before the association is aborted.
  539. The default value is 10.
  540. \subsubsection{usrsctp\_sysctl\_set\_sctp\_path\_rtx\_max\_default()}
  541. This parameter sets the maximum number of path failures before the association is aborted.
  542. The default value is 5. Notice that the number of paths multiplied by this value should be
  543. equal to sctp\_assoc\_rtx\_max\_default. That means that the default configuration is good for two
  544. paths.
  545. \subsubsection{usrsctp\_sysctl\_set\_sctp\_max\_retran\_chunk()}
  546. The parameter configures how many times an unlucky chunk can be retransmitted before the
  547. association aborts. The default is set to 30.
  548. \subsubsection{usrsctp\_sysctl\_set\_sctp\_path\_pf\_threshold()}
  549. TBD
  550. Default potentially failed threshold. Default: 65535
  551. \subsubsection{usrsctp\_sysctl\_set\_sctp\_abort\_if\_one\_2\_one\_hits\_limit()}
  552. TBD
  553. When one-2-one hits qlimit abort. Default: 0
  554. \subsection{Control the Sending of SACKs}
  555. \subsubsection{usrsctp\_sysctl\_set\_sctp\_sack\_freq\_default()}
  556. The SACK frequency defines the number of packets that are awaited, before a SACK is sent.
  557. The default value is 2.
  558. \subsubsection{usrsctp\_sysctl\_set\_sctp\_delayed\_sack\_time\_default()}
  559. As a SACK (Selective Acknowledgment) is sent after every other packet, a timer is set to send a
  560. SACK in case another packet does not arrive in due time. The default value for this timer is
  561. 200~ms.
  562. \subsubsection{usrsctp\_sysctl\_set\_sctp\_strict\_sacks()}
  563. TBD
  564. This is a flag to turn the controlling of the coherence of SACKs on or off. The default value is
  565. 1 (on).
  566. \subsubsection{usrsctp\_sysctl\_set\_sctp\_nr\_sack\_on\_off()}
  567. If a slow hosts receives data on a lossy link it is possible that its receiver window is full and new
  568. data can only be accepted if one chunk with a higher TSN (Transmission Sequence Number) that has
  569. previously been acknowledged is dropped. As a consequence the sender has to store data, even if
  570. they have been acknowledged in case they have to be retransmitted. If this behavior is not necessary,
  571. non-renegable SACKs can be turned on.
  572. By default the use of non-renegable SACKs is turned off.
  573. \subsubsection{usrsctp\_sysctl\_set\_sctp\_enable\_sack\_immediately()}
  574. In some cases it is not desirable to wait for the SACK timer to expire before a SACK is sent. In these
  575. cases a bit called SACK-IMMEDIATELY~\cite{sack-imm} can be set to provoke the instant sending of a SACK.
  576. The default is to turn it off.
  577. \subsubsection{usrsctp\_sysctl\_set\_sctp\_L2\_abc\_variable()}
  578. TBD
  579. SCTP ABC max increase per SACK (L). Default: 1
  580. \subsection{Change Max Burst}
  581. Max burst defines the maximum number of packets that may be sent in one flight.
  582. \subsubsection{usrsctp\_sysctl\_set\_sctp\_max\_burst\_default()}
  583. The default value for max burst is 0, which means that the number of packets sent as a flight
  584. is not limited by this parameter, but may be by another one, see the next paragraph.
  585. \subsubsection{usrsctp\_sysctl\_set\_sctp\_use\_cwnd\_based\_maxburst()}
  586. The use of max burst is based on the size of the congestion window (cwnd).
  587. This parameter is set by default.
  588. \subsubsection{usrsctp\_sysctl\_set\_sctp\_hb\_maxburst()}
  589. Heartbeats are mostly used to verify a path. Their number can be limited. The default is 4.
  590. \subsubsection{usrsctp\_sysctl\_set\_sctp\_fr\_max\_burst\_default()}
  591. In the state of fast retransmission the number of packet bursts can be limited. The default
  592. value is 4.
  593. \subsection{Handle Chunks}
  594. \subsubsection{usrsctp\_sysctl\_set\_sctp\_peer\_chunk\_oh()}
  595. In order to keep track of the peer's advertised receiver window, the sender calculates the window by
  596. subtracting the amount of data sent. Yet, some OSs reduce the receiver window by the real space needed
  597. to store the data. This parameter sets the additional amount to debit the peer's receiver window per
  598. chunk sent. The default value is 256, which is the value needed by FreeBSD.
  599. \subsubsection{usrsctp\_sysctl\_set\_sctp\_max\_chunks\_on\_queue()}
  600. This parameter sets the maximum number of chunks that can be queued per association. The default
  601. value is 512.
  602. \subsubsection{usrsctp\_sysctl\_set\_sctp\_min\_split\_point()}
  603. TBD
  604. The minimum size when splitting a chunk is 2904 bytes by default.
  605. \subsubsection{usrsctp\_sysctl\_set\_sctp\_chunkscale()}
  606. TBD
  607. This parameter can be tuned for scaling of number of chunks and messages. The default is10.
  608. \subsubsection{usrsctp\_sysctl\_set\_sctp\_min\_residual()}
  609. TBD
  610. This parameter configures the minimum size of the residual data chunk in the second
  611. part of the split. The default is 1452.
  612. \subsection{Calculate RTT}
  613. The calculation of the round trip time (RTT) depends on several parameters.
  614. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rttvar\_bw()}
  615. TBD
  616. Shift amount for bw smoothing on rtt calc. Default: 4
  617. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rttvar\_rtt()}
  618. TBD
  619. Shift amount for rtt smoothing on rtt calc. Default: 5
  620. \subsubsection{usrsctp\_sysctl\_set\_sctp\_rttvar\_eqret()}
  621. TBD
  622. What to return when rtt and bw are unchanged. Default: 0
  623. \subsection{Influence the Congestion Control}
  624. The congestion control should protect the network against fast senders.
  625. \subsubsection{usrsctp\_sysctl\_set\_sctp\_ecn\_enable}
  626. Explicit congestion notifications are turned on by default.
  627. \subsubsection{usrsctp\_sysctl\_set\_sctp\_default\_cc\_module()}
  628. This parameter sets the default algorithm for the congestion control.
  629. Default is 0, i.e. the one specified in RFC~4960.
  630. \subsubsection{usrsctp\_sysctl\_set\_sctp\_initial\_cwnd()}
  631. Set the initial congestion window in MTUs. The default is 3.
  632. \subsubsection{usrsctp\_sysctl\_set\_sctp\_use\_dccc\_ecn()}
  633. TBD
  634. Enable for RTCC CC datacenter ECN. Default: 1
  635. \subsubsection{usrsctp\_sysctl\_set\_sctp\_steady\_step()}
  636. TBD
  637. How many the sames it takes to try step down of cwnd. Default: 20
  638. \subsection{Configure AUTH and ADD-IP}
  639. An important extension of SCTP is the dynamic address reconfiguration~\cite{addip}, also known as
  640. ADD-IP, which allows the changing of addresses during the lifetime of an association.
  641. For this feature the AUTH extension~\cite{auth} is necessary.
  642. \subsubsection{usrsctp\_sysctl\_set\_sctp\_auto\_asconf()}
  643. If SCTP Auto-ASCONF is enabled, the peer is informed automatically when a new address
  644. is added or removed. This feature is enabled by default.
  645. \subsubsection{usrsctp\_sysctl\_set\_sctp\_multiple\_asconfs()}
  646. By default the sending of multiple ASCONFs is disabled.
  647. \subsubsection{usrsctp\_sysctl\_set\_sctp\_auth\_disable()}
  648. The use of AUTH, which is normally turned on, can be disabled by setting this parameter to 1.
  649. \subsubsection{usrsctp\_sysctl\_set\_sctp\_asconf\_auth\_nochk()}
  650. It is also possible to disable the requirement to use AUTH in conjunction with ADD-IP by setting this parameter
  651. to 1.
  652. \subsection{Concurrent Multipath Transfer (CMT)}
  653. A prominent feature of SCTP is the possibility to use several addresses for the same association.
  654. One is the primary path, and the others are needed in case of a path failure. Using CMT the data is sent
  655. on several paths to enhance the throughput.
  656. \subsubsection{usrsctp\_sysctl\_set\_sctp\_cmt\_on\_off()}
  657. To turn CMT on, this parameter has to be set to 1.
  658. \subsubsection{usrsctp\_sysctl\_set\_sctp\_cmt\_use\_dac()}
  659. To use delayed acknowledgments with CMT this parameter has to be set to 1.
  660. \subsubsection{usrsctp\_sysctl\_set\_sctp\_buffer\_splitting()}
  661. For CMT it makes sense to split the send and receive buffer to have shares for each path.
  662. By default buffer splitting is turned off.
  663. \subsection{Network Address Translation (NAT)}
  664. To be able to pass NAT boxes, the boxes have to handle SCTP packets in a specific way.
  665. \subsubsection{usrsctp\_sysctl\_set\_sctp\_nat\_friendly()}
  666. SCTP NAT friendly operation. Default:1
  667. \subsubsection{usrsctp\_sysctl\_set\_sctp\_inits\_include\_nat\_friendly()}
  668. Enable sending of the nat-friendly SCTP option on INITs. Default: 0
  669. \subsubsection{usrsctp\_sysctl\_set\_sctp\_udp\_tunneling\_port()}
  670. Set the SCTP/UDP tunneling port. Default: 9899
  671. \subsection{SCTP Mobility}
  672. \subsubsection{usrsctp\_sysctl\_set\_sctp\_mobility\_base()}
  673. TBD
  674. Enable SCTP base mobility. Default: 0
  675. \subsubsection{usrsctp\_sysctl\_set\_sctp\_mobility\_fasthandoff()}
  676. TBD
  677. Enable SCTP fast handoff. default: 0
  678. \subsection{Miscellaneous}
  679. \subsubsection{usrsctp\_sysctl\_set\_sctp\_no\_csum\_on\_loopback()}
  680. Calculating the checksum for packets sent on loopback is turned off by default.
  681. To turn it on, set this parameter to 0.
  682. \subsubsection{usrsctp\_sysctl\_set\_sctp\_nr\_outgoing\_streams\_default()}
  683. The peer is notified about the number of outgoing streams in the INIT or INIT-ACK chunk.
  684. The default is 10.
  685. \subsubsection{usrsctp\_sysctl\_set\_sctp\_do\_drain()}
  686. Determines whether SCTP should respond to the drain calls. Default: 1
  687. \subsubsection{usrsctp\_sysctl\_set\_sctp\_strict\_data\_order()}
  688. TBD
  689. Enforce strict data ordering, abort if control inside data. Default: 0
  690. \subsubsection{usrsctp\_sysctl\_set\_sctp\_default\_ss\_module()}
  691. Set the default stream scheduling module. Implemented modules are:
  692. SCTP\_SS\_DEFAULT, SCTP\_SS\_ROUND\_ROBIN, SCTP\_SS\_ROUND\_ROBIN\_PACKET,
  693. SCTP\_SS\_PRIORITY, SCTP\_SS\_FAIR\_BANDWITH, and SCTP\_SS\_FIRST\_COME.
  694. \subsubsection{usrsctp\_sysctl\_set\_sctp\_default\_frag\_interleave()}
  695. TBD
  696. Default fragment interleave level. Default: 1
  697. \subsubsection{usrsctp\_sysctl\_set\_sctp\_blackhole()}
  698. TBD
  699. Enable SCTP blackholing. Default: 0
  700. \subsubsection{usrsctp\_sysctl\_set\_sctp\_logging\_level()}
  701. Set the logging level. The default is 0.
  702. \subsubsection{usrsctp\_sysctl\_set\_sctp\_debug\_on()}
  703. Turn debug output on or off. It is disabled by default. To obtain debug output,
  704. SCTP\_DEBUG has to be set as a compile flag.
  705. %The following variables are supported:
  706. %\begin{longtable}{|l|l|c|}
  707. %\hline
  708. %{\bfseries Parameter}&{\bfseries Meaning}&{\bfseries Default Value} \tabularnewline
  709. %\endhead
  710. %\hline
  711. %sctp\_sendspace&Send buffer space&1864135\tabularnewline \hline
  712. %sctp\_recvspace&Receive buffer space&1864135 \tabularnewline \hline
  713. %sctp\_hashtblsize&Tunable for TCB hash table sizes&1024 \tabularnewline \hline
  714. %sctp\_pcbtblsize&Tunable for PCB hash table sizes&256 \tabularnewline \hline
  715. %sctp\_system\_free\_resc\_limit&Cached resources in the system&1000 \tabularnewline \hline
  716. %sctp\_asoc\_free\_resc\_limit&Cashed resources in an association&10 \tabularnewline \hline
  717. %sctp\_rto\_max\_default&Default value for RTO\_max&60000~ms \tabularnewline \hline
  718. %sctp\_rto\_min\_default&Default value for RTO\_min&1000~ms \tabularnewline \hline
  719. %sctp\_rto\_initial\_default&Default value for RTO\_initial&3000~ms \tabularnewline \hline
  720. %sctp\_init\_rto\_max\_default&Default value for the maximum RTO&60000~ms \tabularnewline
  721. % &for sending an INIT& \tabularnewline \hline
  722. %sctp\_valid\_cookie\_life\_default&Valid cookie life time&60000~ms \tabularnewline \hline
  723. %sctp\_init\_rtx\_max\_default&Maximum number of INIT retransmissions&8 \tabularnewline \hline
  724. %sctp\_assoc\_rtx\_max\_default&Maximum number of failed retransmissions&10\tabularnewline
  725. % & before the association is aborted&\tabularnewline \hline
  726. %sctp\_path\_rtx\_max\_default&Maximum number of failed retransmissions&5\tabularnewline
  727. % &before a path fails&\tabularnewline \hline
  728. %sctp\_ecn\_enable&Enabling explicit congestion notifications&1\tabularnewline \hline
  729. %sctp\_strict\_sacks&Control the coherence of SACKs&1 \tabularnewline \hline
  730. %sctp\_delayed\_sack\_time\_default&Default delayed SACK timer&200~ms\tabularnewline \hline
  731. %sctp\_sack\_freq\_default&Default SACK frequency&2 \tabularnewline \hline
  732. %sctp\_nr\_sack\_on\_off&Turn non-renegable SACKs on or off&0 \tabularnewline \hline
  733. %sctp\_enable\_sack\_immediately&Enable sending of the SACK-&0 \tabularnewline &IMMEDIATELY bit.&\tabularnewline \hline
  734. %sctp\_no\_csum\_on\_loopback&Enable the compilation of the checksum on&1 \tabularnewline
  735. % &packets sent on loopback&\tabularnewline \hline
  736. %sctp\_peer\_chunk\_oh&Amount to debit peers rwnd per chunk sent&256 \tabularnewline \hline
  737. %sctp\_max\_burst\_default&Default max burst for SCTP endpoints&0 \tabularnewline \hline
  738. %sctp\_use\_cwnd\_based\_maxburst&Use max burst based on the size of &1\tabularnewline % &the congestion window&\tabularnewline \hline
  739. %sctp\_hb\_maxburst&Confirmation Heartbeat max burst&4 \tabularnewline \hline
  740. %sctp\_max\_chunks\_on\_queue&Default max chunks on queue per asoc&512 \tabularnewline \hline
  741. %sctp\_min\_split\_point&Minimum size when splitting a chunk&2904 \tabularnewline \hline
  742. %sctp\_chunkscale&Tunable for Scaling of number of chunks and&10\tabularnewline
  743. % &messages&\tabularnewline \hline
  744. %sctp\_mbuf\_threshold\_count&Maximum number of small mbufs in a chain&5\tabularnewline \hline
  745. %sctp\_heartbeat\_interval\_default&Default time between two Heartbeats&30000~ms\tabularnewline \hline
  746. %sctp\_pmtu\_raise\_time\_default&Default PMTU raise timer&600~secs\tabularnewline \hline
  747. %sctp\_shutdown\_guard\_time\_default&Default shutdown guard timer&180~secs\tabularnewline \hline
  748. %sctp\_secret\_lifetime\_default&Default secret lifetime&3600~secs \tabularnewline \hline
  749. %sctp\_add\_more\_threshold&Threshold when more space should &1452\tabularnewline
  750. % &be added to a socket send buffer&\tabularnewline \hline
  751. %sctp\_nr\_outgoing\_streams\_default&Default number of outgoing streams&10\tabularnewline \hline
  752. %sctp\_cmt\_on\_off&Turn CMT on or off.&0\tabularnewline \hline
  753. %sctp\_cmt\_use\_dac&Use delayed acknowledgment for CMT&0\tabularnewline \hline
  754. %sctp\_fr\_max\_burst\_default&Default max burst for SCTP endpoints when &4\tabularnewline
  755. % &fast retransmitting&\tabularnewline \hline
  756. %sctp\_auto\_asconf&Enable SCTP Auto-ASCONF&1\tabularnewline \hline
  757. %sctp\_multiple\_asconfs&Enable SCTP Multiple-ASCONFs&0 \tabularnewline \hline
  758. %sctp\_asconf\_auth\_nochk&Disable SCTP ASCONF AUTH requirement&0\tabularnewline \hline
  759. %sctp\_auth\_disable&Disable SCTP AUTH function&0\tabularnewline \hline
  760. %sctp\_nat\_friendly&SCTP NAT friendly operation&1\tabularnewline \hline
  761. %sctp\_inits\_include\_nat\_friendly&Enable sending of the nat-friendly &0\tabularnewline
  762. % &SCTP option on INITs.&\tabularnewline \hline
  763. %sctp\_udp\_tunneling\_port&Set the SCTP/UDP tunneling port&9899\tabularnewline \hline
  764. %sctp\_do\_drain&Determines whether SCTP should respond&1\tabularnewline
  765. % &to the drain calls&\tabularnewline \hline
  766. %sctp\_abort\_if\_one\_2\_one\_hits\_limit&When one-2-one hits qlimit abort&0 \tabularnewline \hline
  767. %sctp\_strict\_data\_order&Enforce strict data ordering, abort if control&0\tabularnewline
  768. % &inside data&\tabularnewline \hline
  769. %sctp\_min\_residual&Minimum residual data chunk in second&1452\tabularnewline
  770. % &part of split&\tabularnewline \hline
  771. %sctp\_max\_retran\_chunk&Maximum times an unlucky chunk can be&30\tabularnewline
  772. % & retransmitted before the association aborts&\tabularnewline \hline
  773. %sctp\_default\_cc\_module&Default congestion control module&0\tabularnewline \hline
  774. %sctp\_default\_ss\_module&Default stream scheduling module&0 \tabularnewline \hline
  775. %sctp\_default\_frag\_interleave&Default fragment interleave level&1\tabularnewline \hline
  776. %sctp\_mobility\_base&Enable SCTP base mobility&0\tabularnewline \hline
  777. %sctp\_mobility\_fasthandoff&Enable SCTP fast handoff&0\tabularnewline \hline
  778. %sctp\_L2\_abc\_variable&SCTP ABC max increase per SACK (L)&1\tabularnewline \hline
  779. %sctp\_vtag\_time\_wait&Vtag time wait time, 0 disables it.&60~secs\tabularnewline \hline
  780. %sctp\_blackhole&Enable SCTP blackholing&0\tabularnewline \hline
  781. %sctp\_path\_pf\_threshold&Default potentially failed threshold&65535\tabularnewline \hline
  782. %sctp\_rttvar\_bw&Shift amount for bw smoothing on rtt calc&4 \tabularnewline \hline
  783. %sctp\_rttvar\_rtt&Shift amount for rtt smoothing on rtt calc&5 \tabularnewline \hline
  784. %sctp\_rttvar\_eqret &What to return when rtt and bw are&0\tabularnewline
  785. % &unchanged&\tabularnewline \hline
  786. %sctp\_steady\_step&How many the sames it takes to try step&20\tabularnewline
  787. % &down of cwnd&\tabularnewline \hline
  788. %sctp\_use\_dccc\_ecn&Enable for RTCC CC datacenter ECN&1 \tabularnewline \hline
  789. %sctp\_buffer\_splitting&Enable send/receive buffer splitting&0 \tabularnewline \hline
  790. %sctp\_initial\_cwnd&Initial congestion window in MTUs&3\tabularnewline \hline
  791. %sctp\_logging\_level&Logging level&0 \tabularnewline \hline
  792. %sctp\_debug\_on&Turns debug output on or off.&0 \tabularnewline \hline
  793. %\caption{Sysctl variables supported by usrsctp}
  794. %\end{longtable}
  795. \section{Examples}
  796. \subsection{Discard Server}\label{server}
  797. \begin{verbatim}
  798. /*
  799. * Copyright (C) 2011-2012 Michael Tuexen
  800. *
  801. * All rights reserved.
  802. *
  803. * Redistribution and use in source and binary forms, with or without
  804. * modification, are permitted provided that the following conditions
  805. * are met:
  806. * 1. Redistributions of source code must retain the above copyright
  807. * notice, this list of conditions and the following disclaimer.
  808. * 2. Redistributions in binary form must reproduce the above copyright
  809. * notice, this list of conditions and the following disclaimer in the
  810. * documentation and/or other materials provided with the distribution.
  811. * 3. Neither the name of the project nor the names of its contributors
  812. * may be used to endorse or promote products derived from this software
  813. * without specific prior written permission.
  814. *
  815. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  816. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  817. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  818. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  819. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  820. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  821. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  822. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  823. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  824. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  825. * SUCH DAMAGE.
  826. */
  827. /*
  828. * Usage: discard_server [local_encaps_port] [remote_encaps_port]
  829. */
  830. #include <stdio.h>
  831. #include <stdlib.h>
  832. #include <string.h>
  833. #include <sys/types.h>
  834. #if !defined(_WIN32)
  835. #include <unistd.h>
  836. #include <sys/socket.h>
  837. #include <netinet/in.h>
  838. #include <arpa/inet.h>
  839. #endif
  840. #include <usrsctp.h>
  841. #define BUFFER_SIZE 10240
  842. const int use_cb = 0;
  843. static int
  844. receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
  845. size_t datalen, struct sctp_rcvinfo rcv, int flags)
  846. {
  847. char name[INET6_ADDRSTRLEN];
  848. if (data) {
  849. if (flags & MSG_NOTIFICATION) {
  850. printf("Notification of length %d received.\n", (int)datalen);
  851. } else {
  852. printf("Msg of length %d received from %s:%u on stream %d with "
  853. "SSN %u and TSN %u, PPID %d, context %u.\n",
  854. (int)datalen,
  855. addr.sa.sa_family == AF_INET ?
  856. inet_ntop(AF_INET, &addr.sin.sin_addr, name,
  857. INET6_ADDRSTRLEN):
  858. inet_ntop(AF_INET6, &addr.sin6.sin6_addr, name,
  859. INET6_ADDRSTRLEN),
  860. ntohs(addr.sin.sin_port),
  861. rcv.rcv_sid,
  862. rcv.rcv_ssn,
  863. rcv.rcv_tsn,
  864. ntohl(rcv.rcv_ppid),
  865. rcv.rcv_context);
  866. }
  867. free(data);
  868. }
  869. return 1;
  870. }
  871. int
  872. main(int argc, char *argv[])
  873. {
  874. struct socket *sock;
  875. struct sockaddr_in6 addr;
  876. struct sctp_udpencaps encaps;
  877. struct sctp_event event;
  878. uint16_t event_types[] = {SCTP_ASSOC_CHANGE,
  879. SCTP_PEER_ADDR_CHANGE,
  880. SCTP_REMOTE_ERROR,
  881. SCTP_SHUTDOWN_EVENT,
  882. SCTP_ADAPTATION_INDICATION,
  883. SCTP_PARTIAL_DELIVERY_EVENT};
  884. unsigned int i;
  885. struct sctp_assoc_value av;
  886. const int on = 1;
  887. int n, flags;
  888. socklen_t from_len;
  889. char buffer[BUFFER_SIZE];
  890. char name[INET6_ADDRSTRLEN];
  891. struct sctp_recvv_rn rn;
  892. socklen_t infolen = sizeof(struct sctp_recvv_rn);
  893. struct sctp_rcvinfo rcv;
  894. struct sctp_nxtinfo nxt;
  895. unsigned int infotype = 0;
  896. if (argc > 1) {
  897. usrsctp_init(atoi(argv[1]));
  898. } else {
  899. usrsctp_init(9899);
  900. }
  901. usrsctp_sysctl_set_sctp_debug_on(0);
  902. usrsctp_sysctl_set_sctp_blackhole(2);
  903. if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP,
  904. use_cb?receive_cb:NULL, NULL, 0)) == NULL) {
  905. perror("userspace_socket");
  906. }
  907. if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR,
  908. (const void*)&on, (socklen_t)sizeof(int)) < 0) {
  909. perror("setsockopt");
  910. }
  911. memset(&av, 0, sizeof(struct sctp_assoc_value));
  912. av.assoc_id = SCTP_ALL_ASSOC;
  913. av.assoc_value = 47;
  914. if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av,
  915. (socklen_t)sizeof(struct sctp_assoc_value)) < 0) {
  916. perror("setsockopt");
  917. }
  918. if (argc > 2) {
  919. memset(&encaps, 0, sizeof(struct sctp_udpencaps));
  920. encaps.sue_address.ss_family = AF_INET6;
  921. encaps.sue_port = htons(atoi(argv[2]));
  922. if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT,
  923. (const void*)&encaps,
  924. (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
  925. perror("setsockopt");
  926. }
  927. }
  928. memset(&event, 0, sizeof(event));
  929. event.se_assoc_id = SCTP_FUTURE_ASSOC;
  930. event.se_on = 1;
  931. for (i = 0; i < (unsigned int)(sizeof(event_types)/sizeof(uint16_t)); i++) {
  932. event.se_type = event_types[i];
  933. if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_EVENT, &event,
  934. sizeof(struct sctp_event)) < 0) {
  935. perror("userspace_setsockopt");
  936. }
  937. }
  938. memset((void *)&addr, 0, sizeof(struct sockaddr_in6));
  939. #ifdef HAVE_SIN_LEN
  940. addr.sin6_len = sizeof(struct sockaddr_in6);
  941. #endif
  942. addr.sin6_family = AF_INET6;
  943. addr.sin6_port = htons(9);
  944. addr.sin6_addr = in6addr_any;
  945. if (usrsctp_bind(sock, (struct sockaddr *)&addr,
  946. sizeof(struct sockaddr_in6)) < 0) {
  947. perror("userspace_bind");
  948. }
  949. if (usrsctp_listen(sock, 1) < 0) {
  950. perror("userspace_listen");
  951. }
  952. while (1) {
  953. if (use_cb) {
  954. #if defined(_WIN32)
  955. Sleep(1*1000);
  956. #else
  957. sleep(1);
  958. #endif
  959. } else {
  960. from_len = (socklen_t)sizeof(struct sockaddr_in6);
  961. flags = 0;
  962. rn.recvv_rcvinfo = rcv;
  963. rn.recvv_nxtinfo = nxt;
  964. n = usrsctp_recvv(sock, (void*)buffer, BUFFER_SIZE,
  965. (struct sockaddr *) &addr, &from_len, (void *)&rn,
  966. &infolen, &infotype, &flags);
  967. if (n > 0) {
  968. if (flags & MSG_NOTIFICATION) {
  969. printf("Notification of length %d received.\n", n);
  970. } else {
  971. printf("Msg of length %d received from %s:%u on stream "
  972. "%d with SSN %u and TSN %u, PPID %d, context %u, "
  973. "complete %d.\n",
  974. n,
  975. inet_ntop(AF_INET6, &addr.sin6_addr, name,
  976. INET6_ADDRSTRLEN), ntohs(addr.sin6_port),
  977. rn.recvv_rcvinfo.rcv_sid,
  978. rn.recvv_rcvinfo.rcv_ssn,
  979. rn.recvv_rcvinfo.rcv_tsn,
  980. ntohl(rn.recvv_rcvinfo.rcv_ppid),
  981. rn.recvv_rcvinfo.rcv_context,
  982. (flags & MSG_EOR) ? 1 : 0);
  983. }
  984. }
  985. }
  986. }
  987. usrsctp_close(sock);
  988. while (usrsctp_finish() != 0) {
  989. #if defined(_WIN32)
  990. Sleep(1000);
  991. #else
  992. sleep(1);
  993. #endif
  994. }
  995. return (0);
  996. }
  997. \end{verbatim}
  998. \subsection{Client}\label{client}
  999. \begin{verbatim}
  1000. /*
  1001. * Copyright (C) 2011-2012 Michael Tuexen
  1002. *
  1003. * All rights reserved.
  1004. *
  1005. * Redistribution and use in source and binary forms, with or without
  1006. * modification, are permitted provided that the following conditions
  1007. * are met:
  1008. * 1. Redistributions of source code must retain the above copyright
  1009. * notice, this list of conditions and the following disclaimer.
  1010. * 2. Redistributions in binary form must reproduce the above copyright
  1011. * notice, this list of conditions and the following disclaimer in the
  1012. * documentation and/or other materials provided with the distribution.
  1013. * 3. Neither the name of the project nor the names of its contributors
  1014. * may be used to endorse or promote products derived from this software
  1015. * without specific prior written permission.
  1016. *
  1017. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  1018. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1019. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1020. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  1021. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1022. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1023. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1024. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1025. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1026. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1027. * SUCH DAMAGE.
  1028. */
  1029. /*
  1030. * Usage: client remote_addr remote_port [local_encaps_port remote_encaps_port]
  1031. */
  1032. #include <stdio.h>
  1033. #include <stdlib.h>
  1034. #include <string.h>
  1035. #if !defined(_WIN32)
  1036. #include <unistd.h>
  1037. #endif
  1038. #include <sys/types.h>
  1039. #if !defined(_WIN32)
  1040. #include <sys/socket.h>
  1041. #include <netinet/in.h>
  1042. #include <arpa/inet.h>
  1043. #endif
  1044. #include <usrsctp.h>
  1045. int done = 0;
  1046. static int
  1047. receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
  1048. size_t datalen, struct sctp_rcvinfo rcv, int flags)
  1049. {
  1050. if (data == NULL) {
  1051. done = 1;
  1052. usrsctp_close(sock);
  1053. } else {
  1054. write(fileno(stdout), data, datalen);
  1055. free(data);
  1056. }
  1057. return 1;
  1058. }
  1059. int
  1060. main(int argc, char *argv[])
  1061. {
  1062. struct socket *sock;
  1063. struct sockaddr_in addr4;
  1064. struct sockaddr_in6 addr6;
  1065. struct sctp_udpencaps encaps;
  1066. char buffer[80];
  1067. if (argc > 3) {
  1068. usrsctp_init(atoi(argv[3]));
  1069. } else {
  1070. usrsctp_init(9899);
  1071. }
  1072. usrsctp_sysctl_set_sctp_debug_on(0);
  1073. usrsctp_sysctl_set_sctp_blackhole(2);
  1074. if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP,
  1075. receive_cb, NULL, 0)) == NULL) {
  1076. perror("userspace_socket ipv6");
  1077. }
  1078. if (argc > 4) {
  1079. memset(&encaps, 0, sizeof(struct sctp_udpencaps));
  1080. encaps.sue_address.ss_family = AF_INET6;
  1081. encaps.sue_port = htons(atoi(argv[4]));
  1082. if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT,
  1083. (const void*)&encaps,
  1084. (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
  1085. perror("setsockopt");
  1086. }
  1087. }
  1088. memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
  1089. memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
  1090. #if !defined(__linux__) && !defined(_WIN32)
  1091. addr4.sin_len = sizeof(struct sockaddr_in);
  1092. addr6.sin6_len = sizeof(struct sockaddr_in6);
  1093. #endif
  1094. addr4.sin_family = AF_INET;
  1095. addr6.sin6_family = AF_INET6;
  1096. addr4.sin_port = htons(atoi(argv[2]));
  1097. addr6.sin6_port = htons(atoi(argv[2]));
  1098. if (inet_pton(AF_INET6, argv[1], &addr6.sin6_addr) == 1) {
  1099. if (usrsctp_connect(sock, (struct sockaddr *)&addr6,
  1100. sizeof(struct sockaddr_in6)) < 0) {
  1101. perror("userspace_connect");
  1102. }
  1103. } else if (inet_pton(AF_INET, argv[1], &addr4.sin_addr) == 1) {
  1104. if (usrsctp_connect(sock, (struct sockaddr *)&addr4,
  1105. sizeof(struct sockaddr_in)) < 0) {
  1106. perror("userspace_connect");
  1107. }
  1108. } else {
  1109. printf("Illegal destination address.\n");
  1110. }
  1111. while ((fgets(buffer, sizeof(buffer), stdin) != NULL) && !done) {
  1112. usrsctp_sendv(sock, buffer, strlen(buffer), NULL, 0,
  1113. NULL, 0, SCTP_SENDV_NOINFO, 0);
  1114. }
  1115. if (!done) {
  1116. usrsctp_shutdown(sock, SHUT_WR);
  1117. }
  1118. while (!done) {
  1119. #if defined(_WIN32)
  1120. Sleep(1*1000);
  1121. #else
  1122. sleep(1);
  1123. #endif
  1124. }
  1125. while (usrsctp_finish() != 0) {
  1126. #if defined(_WIN32)
  1127. Sleep(1000);
  1128. #else
  1129. sleep(1);
  1130. #endif
  1131. }
  1132. return(0);
  1133. }
  1134. \end{verbatim}
  1135. \bibliographystyle{plain}
  1136. %
  1137. \begin{thebibliography}{99}
  1138. \bibitem{socketAPI}
  1139. R.~Stewart, M.~T\"uxen, K.~Poon, and V.~Yasevich:
  1140. \textit{Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)}.
  1141. RFC~6458, Dezember~2011.
  1142. \bibitem{SCTP}
  1143. R.~Stewart:
  1144. \textit{Stream Control Transmission Protocol}.
  1145. RFC~4960, September~2007.
  1146. \bibitem{auth}
  1147. M.~T\"uxen, R.~Stewart, P.~Lei, and E.~Rescorla:
  1148. \textit{Authenticated Chunks for the Stream Control Transmission Protocol (SCTP)}.
  1149. RFC~4895, August~2007.
  1150. \bibitem{streamReset}
  1151. R.~Stewart, M.~T\"uxen, and P.~Lei:
  1152. \textit{Stream Control Transmission Protocol (SCTP) Stream Reconfiguration}.
  1153. RFC~6525, February~2012.
  1154. \bibitem{addip}
  1155. R.~Stewart, Q.~Xie, M.~T\"uxen, S.~Maruyama, and M.~Kozuka:
  1156. \textit{Stream Control Transmission Protocol (SCTP) Dynamic Address Reconfiguration}.
  1157. RFC~5061, September~2007.
  1158. \bibitem{sack-imm}
  1159. M.~T\"uxen, I.~R\"ungeler, and R.~Stewart:
  1160. \textit{SACK-IMMEDIATELY Extension for the Stream Control Transmission Protocol}.
  1161. draft-tuexen-tsvwg-sctp-sack-immediately-09 (work in progress), April~2012.
  1162. \bibitem{udpencaps}
  1163. M.~T\"uxen and R.~Stewart
  1164. \textit{UDP Encapsulation of SCTP Packetsl}.
  1165. draft-ietf-tsvwg-sctp-udp-encaps-03 (work in progress), March~2012.
  1166. \end{thebibliography}
  1167. \end{document}