Search code examples
network-programmingtcpudprouterpacket

Why Does Entire TCP/UDP Packet Get Retransmitted Instead of Just Missing Data


So, this may be a dumb question, but to my understanding if I am sending data via TCP or UDP, if any one of the IP packets that make up that TCP/UDP packet get dropped, the entire TCP/UDP packet is retransmitted, but my question is why can't we just send the parts of the data that are missing. Currently, my only reasoning for this is because if we were to send a ACK for each IP packet that got received that would add to network congestion. Is this correct or are there other reasons we have to resend all the data in a TCP/UDP packet when only a single or a few IP packets are dropped?


Solution

  • IP fragmentation and reassembly happen transparently to upper layers: upper layers aren't aware of that. Also, the transport for TCP is not necessarily IP.

    TCP stack tracks the dispatch and retransmission of TCP segments. Each TCP segment has a sequence number. TCP stack tracks the TCP sequence numbers and can only retransmit the entire TCP segment.

    Should a TCP segment get fragmented into multiple IP datagrams, TCP stack is not aware of that and fragmentation may happen on intermediate hops. Normally, though, TCP segment fragmentation doesn't happen because TCP obeys MTU/MSS specifically to avoid TCP segment fragmentation on IP level.