質問

Note: I am primarily concerned with data validity and not authenticity, i.e I care if data becomes corrupt due to transmission error but care less about if a malicious user tries to alter and retransmit packets to the original intended party (something like a MITM attack).

I am recently building a network protocol based upon TCP (specifically using java's Socket and ServerSocket) and I ran into a little problem regarding how reliable data can be transferred from point A to point B using TCP.

My main concern right now is whether to include a SHA-2 hash on the payload (and possibly header) data of my custom packet structure. Through some research I've seen that TCP does have its own ECC but I've also heard its not particularly "strong".

Since java's Socket is based off a TCP architecture, my questions are:

  1. Does the Socket class guarantee valid (non-corrupted/lost) data (at least to the certainty that I don't need to include my own data checksum)?

  2. Does java itself (through whatever java code infrastructure) provide additional validation (over plain-old TCP) to data when its being sent over a TCP connection?

役に立ちましたか?

解決 2

The TCP protocol contains checksums and retransmit machanisms to make sure your data doesn't get corrupted on the way. If a package is damaged (i.e. the checksum doesn't match on the receiving end), the TCP/IP stack will automatically ask the server to send this frame again.

There is no need to do anything at the Socket or Java application layer.

他のヒント

  1. TCP does that. Nothing to do with the Socket class.

  2. Java doesn't add anything to what TCP does.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top