When will a TCP network packet be fragmented at th

2019-01-07 11:12发布

When will a TCP packet be fragmented at the application layer? When a TCP packet is sent from an application, will the recipient at the application layer ever receive the packet in two or more packets? If so, what conditions cause the packet to be divided. It seems like a packet won't be fragmented until it reaches the Ethernet (at the network layer) limit of 1500 bytes. But, that fragmentation will be transparent to the recipient at the application layer since the network layer will reassemble the fragments before sending the packet up to the next layer, right?

10条回答
太酷不给撩
2楼-- · 2019-01-07 11:42

A the "application layer" a TCP packet (well, segment really; TCP at its own layer doesn't know from packets) is never fragmented, since it doesn't exist. The application layer is where you see the data as a stream of bytes, delivered reliably and in order.

If you're thinking about it otherwise, you're probably approaching something in the wrong way. However, this is not to say that there might not be a layer above this, say, a sequence of messages delivered over this reliable, in-order bytestream.

查看更多
3楼-- · 2019-01-07 11:45

This page is a good source of information about some of the issues that others have brought up, namely the need for data encapsulation on an application protocol by application protocol basis Not quite authoritative in the sense you describe but it has examples and is sourced to some pretty big names in network programming.

查看更多
仙女界的扛把子
4楼-- · 2019-01-07 11:51

Correct - the most informative way to see this is using Wireshark, an invaluable tool. Take the time to figure it out - has saved me several times, and gives a good reality check

查看更多
手持菜刀,她持情操
5楼-- · 2019-01-07 12:01

If a 3000 byte packet enters an Ethernet network with a default MTU size of 1500 (for ethernet), it will be fragmented into two packets of each 1500 bytes in length. That is the only time I can think of.

Wireshark is your best bet for checking this. I have been using it for a while and am totally impressed

查看更多
Fickle 薄情
6楼-- · 2019-01-07 12:02

Different network segments can have different MTU values. In that case fragmentation can occur. For more information see TCP Maximum segment size

This (de)fragmentation happens in the TCP layer. In the application layer there are no more packets. TCP presents a contiguous data stream to the application.

查看更多
你好瞎i
7楼-- · 2019-01-07 12:04

Fragmentation should be transparent to a TCP application. Keep in mind that TCP is a stream protocol: you get a stream of data, not packets! If you are building your application based on the idea of complete data packets then you will have problems unless you add an abstraction layer to assemble whole packets from the stream and then pass the packets up to the application.

查看更多
登录 后发表回答