0

How are errors in the payload of TCP packets handled by the receiving application? The packet is received but for various reasons (including sending erroneous packets on purpose) the payload of the packet is unexpected/malformed so the application can't handle it (or does handle it in some way but still the original/expected data is missing).

Will the application send an ACK? Will the packet be handled like packet loss and retransmission will occur? Does it depend on the application in general or is this kind of error handling independent of OS or application?

1
  • What an application does and how it does that is off-topic here, sorry - see the help center. ACKs are not sent from an application by the stack, specifically by the TCP protocol handler (all part of the operating system). TCP also handles segment retransmission on loss.
    – Zac67
    Oct 11, 2021 at 18:46

1 Answer 1

2

ACK are send at the network/transport layer, not at the application layer. If the payload is damaged so that the TCP checksum fails the packet is simply discarded, i.e. treated as lost. The peer will then retransmit the data since no ACK was received. If the payload is damaged but the checksum does not fail (for example with errors in the sender application or with too much errors at the network layer - TCP checksum cannot handle arbitrary errors) then these corrupt data will be propagated to the application and it needs to deal with this.

4
  • the packet has to also have ports that can match to specific connection, and have sequence numbers that fit into receiver window for this connection. if it is not the case, packets are discarded as well. this will not prevent malicious packets from being received, but it will catch more errors, than checksum alone.
    – Effie
    Oct 11, 2021 at 18:50
  • @SteffenUllrich "and it needs to deal with this." Which, I guess, is application specific? Oct 11, 2021 at 19:10
  • @tcpbernardo: Yes, this is application specific. For example if the application is using TLS due to the integrity checks (cryptographic hashes etc) far more corruption can be detected than with the TCP checksum - and in this case the connection is usually simply aborted. In other cases applications might just process the data, not realizing that they are corrupted. Oct 11, 2021 at 19:18
  • 1
    @Effie: My understanding of the question is that it is only about TCP payload errors, i.e. not about TCP sequence numbers, flags, ports etc. Oct 11, 2021 at 19:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.