When data from the application layer pass to transport layer: data may be fragmented into pieces of data, and then the transport layer will be added to the transport layer header (may be TCP header, or UDP header).

But I have a question, where does the data be fragmented into pieces segmentations (is in application layer?) and does it base on MTU?

  • Are you asking a) "what decides how big each TCP segment or UDP datagram should be?" or b) "When IP packets are sent they might be fragmented on certain links"?
    – jonathanjo
    Sep 9, 2018 at 10:44

2 Answers 2


It takes place when the IP packet is being handed off to the link level, and as you say, depends on the MTU. Each link would normally have its own MTU.

The procedure is pretty clearly laid out in the Internet Protocol RFC on page 23, and begins:

If the total length is less than or equal the maximum transmission unit then submit this datagram to the next step in datagram processing; otherwise cut the datagram into two fragments, the first fragment being the maximum size, and the second fragment being the rest of the datagram. The first fragment is submitted to the next step in datagram processing, while the second fragment is submitted to this procedure in case it still too large.

PS: When a stream of data is sent through TCP, the process of cutting it into pieces is normally called segmentation, where each segment goes in an individual IP packet. When IP packets are broken into pieces to go through a particular link, it's normally called fragmentation. While in ordinary English these words sound pretty much the same, in IP networking they've been given these precise meanings.

[EDIT] Do also see other answer about how TCP segmentation (according to maximum segment size) is related to the MTU.

  • This talks about IP fragmentation (which should be avoided as far as possible), I don't think this is what the OP asks about.
    – JeanPierre
    Sep 9, 2018 at 8:08

It take different approaches for TCP and for UDP.

Int TCP it's a bit of behind the scenes for developer - you just say send(buffer, buffer_size, tcp_connection_id) and that's it. But the OS tcp stack driver will first see for TCP maximum segment size (TCP MSS) for particular connection and first segmentation occurs there if your buffer length larger then MSS - it will break your data into tcp-segments of MSS size. MSS is calculated from MTU of your network adapter minus all required headers (ethernet, ip, tcp). It's done that way to avoid unneeded ip-fragmentation at sending host. Then os driver forms ip packet and sends it out of network interface. Second and more fragmentations can occur on network path due to links there can have lesser MTU than your link.

For UDP it's bit harder, because it's you as developer has to form an UDP packet and it's application responsibility to fragment a data. You can form an UDP packet up to 65507 bytes of data and try to send it. And network driver can fragment it into lesser IP packets, according to MTU.

  • The MTU is the maximum data size of an Ethernet frame, so you don't want to substract the Ethernet header size from that.
    – JeanPierre
    Sep 9, 2018 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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