udpv6

UDP (インターネット)

[14] UDP は、インターネットで使われるトランスポート層プロトコルの1つです。 TCP と並び非常によく使われています。

仕様書

性質

[18] UDP信頼性を持ちません。再送制御フロー制御輻輳制御は行いません。ただし検査和を含めることはできます。

[19] UDP状態を持ちません。

データグラム

[17] UDP では通信に用いるデータの単位をデータグラム (datagram) と呼んでいます。

[1] UDP データグラムの書式
width
32
  1. 16 送信元ポート (0〜15 ビット)
  2. 16 宛先ポート (16〜31 ビット)
  3. 16 長さ (32〜47 ビット)
  4. 16 検査和 (48〜63 ビット)
  5. 32... データ (64 ビット〜)

[2] 送信元ポート (source port) :

[3] 宛先ポート (destination port) :

[4] 長さ (length) :

[13] 16ビット整数ですから、最大値は 216-1 = 65535 です。ヘッダー分を除外すると payload の最大長は 65527 バイトです。

検査和

[5] 検査和 (checksum) :

  1. IP頭部から作った擬似頭部, UDP頭部, データに、
  2. 偶数オクテットになるように末尾に零のオクテットを加えたものの、
  3. 1の補数和の
  4. 16ビット1の補数

[6] 擬似頭部 (pseudo header) : 検査和の計算に用いる擬似頭部は、 IP頭部に含まれる次の情報で、UDP頭部の前に置きます。

width
32
  1. 32 送信元番地 (0〜31 ビット)
  2. 32 宛先番地 (32〜63 ビット)
  3. 8 零 (64〜71 ビット)
  4. 8 プロトコル (72〜79 ビット)
  5. 16 UDP長さ (80〜95 ビット)

下位層

[15] UDP は、 IP上位層プロトコルとして使います。

[8] IP 界面: UDPモジュールはIP頭部から送信元宛先IP番地プロトコル欄を決定できなければなりません。

UDP/IP界面受信操作に対する応答としてIP頭部も含めた全体を返すのもありです。 また、UDP側がIP頭部も埋めて渡すのもありです。 IP側では欄の整合性を検証してIP頭部検査和を計算することになります。

[10] プロトコル番号: IPにおけるUDPプロトコル番号は17です。

上位層

[9] UDP下位層として使ったプロトコルとしては、次のアプリケーション層プロトコルがあります。

[12] また次のプロトコル下位層にも使われています。

[24] 次の API があります。

[7] 利用者界面: 利用者界面は、次の機能を提供するべきです。

派生プロトコル

[20] UDP から派生した次のプロトコルが存在しています。

URL scheme

[22] UDP を使ったアクセスを表すために udp: URL scheme が使われることがあります。

[23] UDPトランスポート層プロトコルであり、その上位のアプリケーション層プロトコルなしに 「UDP」を使うとだけ言っても意味がありません。 udp: URL schemeURL が何を表しているのかは、それ自体では自明ではありません。

[25] PHP が実装しています。

[21] udp://:1234/{e06d8023-db46-11cf-b4d1-00805f6cbbea} Media Player Classic

[26] UDP Tracker Protocol Extensions (Michael C. Toren <mct@toren.net>著, ) <http://www.bittorrent.org/beps/bep_0041.html>

Prior to the extensions defined in this document, UDP tracker URLs that contained PATH and QUERY components were completely valid, but those components were invisible to the tracker. For example, from the tracker's perspective, the URL:

udp://tracker.example.com:80/dir?a=b&c=d

and the URL:

udp://tracker.example.com:80

were completely indistinguishable. This differs from the HTTP-based Tracker Protocol, and places restrictions on how a UDP tracker URLs may be used in practice.

Our primary motivation was to develop an extension to the UDP protocol to allow the PATH and QUERY components to be sent to UDP trackers. Rather than implementing a protocol change that only addressed this one issue, we chose to define an extension mechanism to allow future extensions to be easily added without risk of breaking the existing protocol.

[27] FFmpeg Protocols Documentation () <https://ffmpeg.org/ffmpeg-protocols.html#udp>

User Datagram Protocol.

The required syntax for an UDP URL is:

udp://hostname:port[?options]

options contains a list of &-separated options of the form key=val.

[28] FFmpeg Protocols Documentation () <https://ffmpeg.org/ffmpeg-protocols.html#udp>

Use ffmpeg to stream over UDP to a remote endpoint:

ffmpeg -i input -f format udp://hostname:port

Use ffmpeg to stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer:

ffmpeg -i input -f mpegts udp://hostname:port?pkt_size=188&buffer_size=65535

Use ffmpeg to receive over UDP from a remote endpoint:

ffmpeg -i udp://[multicast-address]:port ...

[29] www.twitch.tvの名前が引けない、もしくはチェックサムが0x0000のUDPパケットの件のまとめ - (ひ)メモ () <http://d.hatena.ne.jp/hirose31/20160127/1453870603>

[30] VLC command-line help - VideoLAN Wiki () <https://wiki.videolan.org/VLC_command-line_help/>

udp://[[<source address>]@[<bind address>][:<bind port>]]

UDP stream sent by a streaming server