2

I'm trying to better understand the difference between IP fragments and TCP segments (https://www.shubhsblog.com/tech/difference-ip-fragmentation-tcp-segmentation.html) and there's one thing I'm not able to theoretically figure out. If the netowrk layer automatically breaks things up into fragments to accommodate network interfaces, why does TCP need to break up its messages into segments? Shouldn't all that be done at the network layer anyway?

2

IP packets have a size limitation (65,535 bytes), so a reassembled packet is limited, and the application would need to send chunks no larger than the theoretical IP packet payload size (total packet length minus the packet header for IPv4). On the other hand, TCP can handle an arbitrarily large (mega-, giga-, etc. bytes) data stream by segmenting it.

Also, IP fragmentation has fallen out of favor because of the resources used by the intermediate routers necessary to preform the fragmentation, and the possibility of fragment attacks on the destination hosts.

  • Thanks @Ron, but I'm still not quite connecting the dots. Why does TCP need to segment a large stream if the IP layer is going to break everything up into 65535-byte fragments? Why doesn't TCP just send its arbitrarily large message down the network layer and let the network layer deal with breaking it up? – Dave May 9 at 19:59
  • 1
    @Dave Not the fragments are limited to 64K - the total size is. You'd only be able to send 64K datagrams and the application would need to organize those itself. TCP provides a transparent, serial stream like a simple serial port. – Zac67 May 9 at 20:02
  • IP cannot break everything up into packets of that size. IPv4 routers will break up packets, which are a maximum total length of 65,535, into smaller packets. The reassembled packet cannot be larger than the maximum packet size. You are unlikely to find a layer-2 protocols that even comes close to that size. – Ron Maupin May 9 at 20:02
  • Thanks all. I didn't grasp that the total size was limited to 64K. That well explains why the transport layer would need to break up messages into segments. – Dave May 9 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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