OSDN Git Service

29fc835ab14dbdf6546708382fa72d10526eaa33
[linuxjm/LDP_man-pages.git] / draft / man7 / udp.7
1 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
2 .\" Permission is granted to distribute possibly modified copies
3 .\" of this page provided the header is included verbatim,
4 .\" and in case of nontrivial modification author and date
5 .\" of the modification is added to the header.
6 .\" $Id: udp.7,v 1.7 2000/01/22 01:55:05 freitag Exp $
7 .\"
8 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
9 .\" Translated 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>
10 .\" Updated 2005-10-09, Kentaro Shirakata <argrath@ub32.org>
11 .\" Updated 2007-01-05, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
12 .\" Updated 2008-12-29, Akihiro MOTOKI, LDP v3.14
13 .\" Updated 2010-04-10, Akihiro MOTOKI, LDP v3.24
14 .\"
15 .TH UDP  7 2009-09-30 "Linux" "Linux Programmer's Manual"
16 .\"O .SH NAME
17 .\"O udp \- User Datagram Protocol for IPv4
18 .SH 名前
19 udp \- IPv4 の ユーザーデータグラムプロトコル
20 .\"O .SH SYNOPSIS
21 .SH 書式
22 .B #include <sys/socket.h>
23 .br
24 .B #include <netinet/in.h>
25 .sp
26 .B udp_socket = socket(AF_INET, SOCK_DGRAM, 0);
27 .\"O .SH DESCRIPTION
28 .SH 説明
29 .\"O This is an implementation of the User Datagram Protocol
30 .\"O described in RFC\ 768.
31 .\"O It implements a connectionless, unreliable datagram packet service.
32 .\"O Packets may be reordered or duplicated before they arrive.
33 .\"O UDP generates and checks checksums to catch transmission errors.
34 これは RFC\ 768 で記述されている User Datagram Protocol の実装である。
35 UDP はコネクションレスの、信頼性の低いデータパケットサービスである。
36 パケットは到着前に並び替えられたり複製されたりする。
37 UDP は転送エラーを検出するためにチェックサムを生成・チェックする。
38
39 .\"O When a UDP socket is created,
40 .\"O its local and remote addresses are unspecified.
41 .\"O Datagrams can be sent immediately using
42 .\"O .BR sendto (2)
43 .\"O or
44 .\"O .BR sendmsg (2)
45 .\"O with a valid destination address as an argument.
46 .\"O When
47 .\"O .BR connect (2)
48 .\"O is called on the socket, the default destination address is set and
49 .\"O datagrams can now be sent using
50 .\"O .BR send (2)
51 .\"O or
52 .\"O .BR write (2)
53 .\"O without specifying a destination address.
54 UDP ソケットが生成されるとき、
55 ローカルアドレスやリモートアドレスは指定されない。
56 正しい行き先アドレスを引数として
57 .BR sendto (2)
58
59 .BR sendmsg (2)
60 を呼べば、データグラムはただちに送信される。
61 ソケットに対して
62 .BR connect (2)
63 を呼ぶと、デフォルトの行き先アドレスが設定され、
64 .BR send (2)
65
66 .BR write (2)
67 を使って、行き先アドレスの指定なしにデータグラムを送信できるようになる。
68 .\"O It is still possible to send to other destinations by passing an
69 .\"O address to
70 .\"O .BR sendto (2)
71 .\"O or
72 .\"O .BR sendmsg (2).
73 この場合でも、行き先アドレスを
74 .BR sendto (2)
75
76 .BR sendmsg (2)
77 に渡せば、デフォルト以外のアドレスに送信可能である。
78 .\"O In order to receive packets, the socket can be bound to a local
79 .\"O address first by using
80 .\"O .BR bind (2).
81 パケットを受信するために、まずソケットを
82 .BR bind (2)
83 を用いてローカルなアドレスにバインドさせることもできる。
84 .\"O Otherwise the socket layer will automatically assign
85 .\"O a free local port out of the range defined by
86 .\"O .I /proc/sys/net/ipv4/ip_local_port_range
87 .\"O and bind the socket to
88 .\"O .BR INADDR_ANY .
89 そうでない場合は、ソケット層は自動的に
90 .I /proc/sys/net/ipv4/ip_local_port_range
91 で定義されている範囲の外で空いているローカルなポートを割り当て、
92 ソケットを
93 .B INADDR_ANY
94 にバインドする。
95
96 .\"O All receive operations return only one packet.
97 .\"O When the packet is smaller than the passed buffer, only that much
98 .\"O data is returned, when it is bigger, the packet is truncated and the
99 .\"O .B MSG_TRUNC
100 .\"O flag is set.
101 受信動作はパケットを一つだけ返す。渡したバッファよりもパケットが
102 小さければ、そのパケットの大きさのデータだけが返される。
103 逆にバッファよりも大きい場合はパケットは丸められ、
104 .B MSG_TRUNC
105 フラグがセットされる。
106 .\"O .B MSG_WAITALL
107 .\"O is not supported.
108 .B MSG_WAITALL
109 はサポートしていない。
110
111 .\"O IP options may be sent or received using the socket options described in
112 .\"O .BR ip (7).
113 .\"O They are only processed by the kernel when the appropriate
114 .\"O .I /proc
115 .\"O parameter
116 .\"O is enabled (but still passed to the user even when it is turned off).
117 .\"O See
118 .\"O .BR ip (7).
119 IP オプションは、
120 .BR ip (7)
121 に記述されているソケットオプションを用いて読み書きできる。
122 これらは適切な
123 .I /proc
124 パラメータが有効な場合に限ってカーネルによって処理される
125 (しかし無効になっている場合でもユーザーには渡される)。
126 .BR ip (7)
127 を参照のこと。
128
129 .\"O When the
130 .\"O .B MSG_DONTROUTE
131 .\"O flag is set on sending, the destination address must refer to a local
132 .\"O interface address and the packet is only sent to that interface.
133 .B MSG_DONTROUTE
134 フラグが送信時にセットされている場合には、
135 行き先アドレスはローカルなインターフェースアドレスから
136 参照できなければならない。パケットはそのインターフェースにしか送られない。
137
138 .\"O By default, Linux UDP does path MTU (Maximum Transmission Unit) discovery.
139 .\"O This means the kernel
140 .\"O will keep track of the MTU to a specific target IP address and return
141 .\"O .B EMSGSIZE
142 .\"O when a UDP packet write exceeds it.
143 .\"O When this happens, the application should decrease the packet size.
144 .\"O Path MTU discovery can be also turned off using the
145 .\"O .B IP_MTU_DISCOVER
146 .\"O socket option or the
147 .\"O .I /proc/sys/net/ipv4/ip_no_pmtu_disc
148 .\"O file; see
149 .\"O .BR ip (7)
150 .\"O for details.
151 .\"O When turned off, UDP will fragment outgoing UDP packets
152 .\"O that exceed the interface MTU.
153 .\"O However, disabling it is not recommended
154 .\"O for performance and reliability reasons.
155 デフォルトでは、Linux の UDP は Path MTU Discovery を行う。
156 つまり、カーネルは特定の宛先 IP アドレスの MTU (Maximum Transmission Unit;
157 最大転送単位) を記録し、UDP パケットの書き込みが MTU を超えた場合
158 .B EMSGSIZE
159 を返す。
160 .B EMSGSIZE
161 を返された場合、アプリケーションはパケットサイズを小さくすべきである。
162 ソケットオプション
163 .B IP_MTU_DISCOVER
164 または
165 .I /proc/sys/net/ipv4/ip_no_pmtu_disc
166 ファイルを使って Path MTU Discovery を無効にすることもできる
167 (詳細は
168 .BR ip (7)
169 を参照)。
170 Path MTU Discovery を無効にした場合は、パケットサイズが
171 インタフェースの MTU よりも大きいと UDP はそのパケットを
172 フラグメント化して送出する。
173 しかしながら、性能と信頼性の理由から Path MTU Discovery を
174 無効にするのは推奨できない。
175 .\"O .SS Address Format
176 .SS アドレスのフォーマット
177 .\"O UDP uses the IPv4
178 .\"O .I sockaddr_in
179 .\"O address format described in
180 .\"O .BR ip (7).
181 UDP は IPv4 の
182 .I sockaddr_in
183 アドレスフォーマットを用いる。これは
184 .BR ip (7)
185 に記述されている。
186 .\"O .SS Error Handling
187 .SS エラー処理
188 .\"O All fatal errors will be passed to the user as an error return even
189 .\"O when the socket is not connected.
190 .\"O This includes asynchronous errors
191 .\"O received from the network.
192 .\"O You may get an error for an earlier packet
193 .\"O that was sent on the same socket.
194 致命的なエラーは、たとえソケットが接続されていなくても、
195 すべてエラー戻り値としてユーザーに渡される。
196 これにはネットワークから受け取る非同期エラーも含まれる。
197 同じソケットを使って送信した昔のパケットに関するエラーを受け取るかもしれない。
198 .\"O This behavior differs from many other BSD socket implementations
199 .\"O which don't pass any errors unless the socket is connected.
200 .\"O Linux's behavior is mandated by
201 .\"O .BR RFC\ 1122 .
202 この振る舞いは他の BSD ソケットの実装の多くとは異なる。
203 これらではソケットが接続されていない場合はエラーを全く返さない。
204 Linux の振る舞いは
205 .B RFC\ 1122
206 での指定に従ったものである。
207
208 .\"O For compatibility with legacy code, in Linux 2.0 and 2.2
209 .\"O it was possible to set the
210 .\"O .B SO_BSDCOMPAT
211 .\"O .B SOL_SOCKET
212 .\"O option to receive remote errors only when the socket has been
213 .\"O connected (except for
214 .\"O .B EPROTO
215 .\"O and
216 .\"O .BR EMSGSIZE ).
217 .\"O Locally generated errors are always passed.
218 .\"O Support for this socket option was removed in later kernels; see
219 .\"O .BR socket (7)
220 .\"O for further information.
221 Linux 2.0 と 2.2 では、古いコードとの互換性のために、
222 .B SO_BSDCOMPAT
223 .B SOL_SOCKET
224 オプションを設定すれば、ソケットが接続されている
225 場合に限ってリモートのエラーを受信するようにできた
226 .RB ( EPROTO " と " EMSGSIZE
227 を除く)。
228 ローカルで生成されたエラーは常に渡される。
229 このソケットオプションのサポートはそれ以降のバージョンの Linux で
230 削除された。詳細は
231 .BR socket (7)
232 を参照。
233
234 .\"O When the
235 .\"O .B IP_RECVERR
236 .\"O option is enabled, all errors are stored in the socket error queue
237 .\"O and can be received by
238 .\"O .BR recvmsg (2)
239 .\"O with the
240 .\"O .B MSG_ERRQUEUE
241 .\"O flag set.
242 .B IP_RECVERR
243 オプションが有効になっていると、
244 すべてのエラーはソケットのエラーキューに保存される。
245 これは
246 .B MSG_ERRQUEUE
247 フラグをセットして
248 .BR recvmsg (2)
249 を呼べば受信できる。
250 .\"O .SS /proc interfaces
251 .SS /proc インタフェース
252 .\"O System-wide UDP parameter settings can be accessed by files in the directory
253 .\"O .IR /proc/sys/net/ipv4/ .
254 システム全体の UDP パラメータ設定には、
255 .I /proc/sys/net/ipv4/
256 ディレクトリ内のファイルの読み書きでアクセスできる。
257 .TP
258 .\"O .IR udp_mem " (since Linux 2.6.25)"
259 .IR udp_mem " (Linux 2.6.25 以降)"
260 .\"O This is a vector of three integers governing the number
261 .\"O of pages allowed for queueing by all UDP sockets.
262 これは 3 つの整数からなるベクトル値で、
263 UDP の全ソケットのキューで利用可能なページ数を制御する。
264 .RS
265 .TP 10
266 .I min
267 .\"O Below this number of pages, UDP is not bothered about its
268 .\"O memory appetite.
269 .\"O When the amount of memory allocated by UDP exceeds
270 .\"O this number, UDP starts to moderate memory usage.
271 このページ数より少なければ、UDP はそのメモリ使用に関して
272 干渉されない。
273 UDP に割り当てられたメモリ総量がこの値を超過すると、
274 UDP はメモリ使用量を調整し始める。
275 .TP
276 .I pressure
277 .\"O This value was introduced to follow the format of
278 .\"O .IR tcp_mem
279 .\"O (see
280 .\"O .BR tcp (7)).
281 この値は
282 .I tcp_mem
283 の形式
284 .RB ( tcp (7)
285 参照) と合わせるために導入された
286 .TP
287 .I max
288 .\"O Number of pages allowed for queueing by all UDP sockets.
289 UDP の全ソケットのキューで利用可能なページ数。
290 .RE
291 .IP
292 .\"O Defaults values for these three items are
293 .\"O calculated at boot time from the amount of available memory.
294 これらの 3 つの値のデフォルト値は、
295 ブート時に利用可能なメモリ総量から計算される。
296 .TP
297 .\"O .IR udp_rmem_min " (integer; default value: PAGE_SIZE; since Linux 2.6.25)"
298 .IR udp_rmem_min " (integer; デフォルト値: PAGE_SIZE; Linux 2.6.25 以降)"
299 .\"O Minimal size, in bites, of receive buffers used by UDP sockets in moderation.
300 .\"O Each UDP socket is able to use the size for receiving data,
301 .\"O even if total pages of UDP sockets exceed
302 .\"O .I udp_mem
303 .\"O pressure.
304 メモリ使用量の調整中に、UDP ソケットが使用できる受信バッファの最小値
305 (バイト単位)。
306 UDP の全ソケットのページ使用量の合計が
307 .I udp_mem
308 pressure を超過している場合であっても、
309 各 UDP ソケットはデータの受信にこのサイズ分だけは使用することができる。
310 .TP
311 .\"O .IR udp_wmem_min " (integer; default value: PAGE_SIZE; since Linux 2.6.25)"
312 .IR udp_wmem_min " (integer; デフォルト値: PAGE_SIZE; Linux 2.6.25 以降)"
313 .\"O Minimal size, in bytes, of send buffer used by UDP sockets in moderation.
314 .\"O Each UDP socket is able to use the size for sending data,
315 .\"O even if total pages of UDP sockets exceed
316 .\"O .I udp_mem
317 .\"O pressure.
318 メモリ使用量の調整中に、UDP ソケットが使用できる送信バッファの最小値
319 (バイト単位)。
320 UDP の全ソケットのページ使用量の合計が
321 .I udp_mem
322 pressure を超過している場合であっても、
323 各 UDP ソケットはデータの送信にこのサイズ分だけは使用することができる。
324 .\"O \"O .SS "Socket Options"
325 .SS ソケットオプション
326 .\"O To set or get a UDP socket option, call
327 .\"O .BR getsockopt (2)
328 .\"O to read or
329 .\"O .BR setsockopt (2)
330 .\"O to write the option with the option level argument set to
331 .\"O .BR IPPROTO_UDP .
332 UDP ソケットオプションを設定または取得するには、
333 取得には
334 .BR getsockopt (2)
335 を、設定には
336 .BR setsockopt (2)
337 をオプションレベル引数に
338 .B IPPROTO_UDP
339 を指定して呼び出す。
340 .TP
341 .\"O .BR UDP_CORK " (since Linux 2.5.44)"
342 .BR UDP_CORK " (Linux 2.5.44 以降)"
343 .\"O If this option is enabled, then all data output on this socket
344 .\"O is accumulated into a single datagram that is transmitted when
345 .\"O the option is disabled.
346 .\"O This option should not be used in code intended to be
347 .\"O portable.
348 このオプションが指定されると、このソケットの全てのデータ出力は
349 一つのデータグラムに蓄積され、このオプションが無効化された時に
350 送信される。
351 このオプションは移植性を考慮したコードでは用いるべきではない。
352 .\" FIXME document UDP_ENCAP (new in kernel 2.5.67)
353 .\" From include/linux/udp.h:
354 .\" /* UDP encapsulation types */
355 .\" #define UDP_ENCAP_ESPINUDP_NON_IKE      1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
356 .\" #define UDP_ENCAP_ESPINUDP      2 /* draft-ietf-ipsec-udp-encaps-06 */
357 .\" #define UDP_ENCAP_L2TPINUDP     3 /* rfc2661 */
358 .\"O .SS Ioctls
359 .SS ioctl
360 .\"O These ioctls can be accessed using
361 .\"O .BR ioctl (2).
362 以下に示す ioctl は
363 .BR ioctl (2)
364 を使ってアクセスできる。
365 .\"O The correct syntax is:
366 正しい文法は以下の通り。
367 .PP
368 .RS
369 .nf
370 .BI int " value";
371 .IB error " = ioctl(" udp_socket ", " ioctl_type ", &" value ");"
372 .fi
373 .RE
374 .TP
375 .BR FIONREAD " (" SIOCINQ )
376 .\"O Gets a pointer to an integer as argument.
377 .\"O Returns the size of the next pending datagram in the integer in bytes,
378 .\"O or 0 when no datagram is pending.
379 integer のポインタを引数として取る。
380 次に待機しているデータグラムのサイズをバイト単位の整数で返す。
381 待機しているデータグラムがない場合は 0 を返す。
382 .TP
383 .BR TIOCOUTQ " (" SIOCOUTQ )
384 .\"O Returns the number of data bytes in the local send queue.
385 .\"O Only supported with Linux 2.4 and above.
386 ローカル送信キューにあるデータサイズをバイト単位で返す。
387 Linux 2.4 以上でのみ対応している。
388 .PP
389 .\"O In addition all ioctls documented in
390 .\"O .BR ip (7)
391 .\"O and
392 .\"O .BR socket (7)
393 .\"O are supported.
394 さらに、
395 .BR ip (7)
396
397 .BR socket (7)
398 で述べられている全ての ioctl も対応している。
399 .\"O .SH ERRORS
400 .SH エラー
401 .\"O All errors documented for
402 .\"O .BR socket (7)
403 .\"O or
404 .\"O .BR ip (7)
405 .\"O may be returned by a send or receive on a UDP socket.
406 .BR socket (7)
407
408 .BR ip (7)
409 に記述されている全てのエラーが、
410 UDP ソケットの送受信で返される可能性がある。
411 .TP
412 .B ECONNREFUSED
413 .\"O No receiver was associated with the destination address.
414 .\"O This might be caused by a previous packet sent over the socket.
415 行き先アドレスに関連づけられている受信者がいない。
416 これは以前のパケットがそのパケットを
417 上書き送信してしまっているからであることが多い。
418 .\"O .SH VERSIONS
419 .SH バージョン
420 .\"O .B IP_RECVERR
421 .\"O is a new feature in Linux 2.2.
422 .B IP_RECVERR
423 は Linux 2.2 の新しい機能である。
424 .\"O .\" .SH CREDITS
425 .\" .SH 著者
426 .\"O .\" This man page was written by Andi Kleen.
427 .\" この man ページは Andi Kleen が書いた。
428 .\"O .SH SEE ALSO
429 .SH 関連項目
430 .BR ip (7),
431 .BR raw (7),
432 .BR socket (7),
433 .BR udplite (7)
434
435 .\"O RFC\ 768 for the User Datagram Protocol.
436 RFC\ 768 : User Datagram Protocol
437 .br
438 .\"O RFC\ 1122 for the host requirements.
439 RFC\ 1122 : ホストの必要条件
440 .br
441 .\"O RFC\ 1191 for a description of path MTU discovery.
442 RFC\ 1191 : path MTU discovery の記述