UDP データが破損して届く可能性はありますか? 紛失する可能性があることは承知しています。
6 に答える
UDP パケットは 16 ビットのチェックサムを使用します。UDP パケットが破損する可能性はありますが、ほとんどありません。いずれにせよ、TCP よりも破損しやすいわけではありません。
First of all, the "IP checksum" referenced above is only an IP header checksum. It does not protect the payload. See RFC 791
Secondly, UDP allows transport with NO checksum, which means that the 16-bit checksum is set to 0 (ie, none). See RFC 768. (An all zero transmitted checksum value means that the transmitter generated no checksum)
Thirdly, as others have mentioned, UDP has a 16-bit checkSUM, which is not the best way to detect a multi-bit error, but is not bad. It is certainly possible for an undetected error to sneak in, but very unlikely.
可能?絶対。検出されませんか?UDP は複数ビットのエラーが有効に見えるようにする必要があるチェックサムを採用しているため、可能性は低いです。エラーが検出された場合、システムはパケットをドロップする可能性があります。これは、UDP を使用するリスクです。
UDP パケットも順不同で配信される可能性があるため、UDP の上にプロトコルを考案する場合は、それも考慮に入れる必要があります。
疑うことを知らないプログラマーに影響を与える「破損」の一般的な形態は、データグラムの切り捨てです。詳細については、Stevens による「Unix Network Programming」を参照してください (第 2 版の 539 ページ)。
MSG_TRUNC フラグを確認できます...