4

I know datagrams from upper layers are converted to those of lower layers by adding metadata, but I cannot seem to find this information anywhere. Which one of the below is correct?

  1. A single TCP segment is always converted to a single IP packet by adding IP header, which is in turn converted to a single Ethernet frame by adding Ethernet header (and footer). In other word, a datagram of an upper layer is converted to the payload of the datagram of the lower layer as a whole.
  2. The network software groups all datagrams of an upper layer as a a bundle of binary (eg: 3 IP packets of size 1000, 800, and 1200 bytes to a bundle of 3000 bytes) then cut that bundle anywhere it feels best to make the payloads for datagrams of lower layer (e.g: to 2 Ethernet frames with payload of 1500 bytes each). The receiving device can always get 3 original IP packets from 2 Ethernet frames.
7
  1. A single TCP segment is always converted to a single IP packet by adding IP header, which is in turn converted to a single Ethernet frame by adding Ethernet header (and footer). In other word, a datagram of an upper layer is converted to the payload of the datagram of the lower layer as a whole.

That depends. For example, TCP receives a stream of data from an application-layer protocol, e.g. HTTP, and it will segment it. That is a lower protocol chopping up a higher protocol. TCP itself uses the MSS to determine the segment size, which should fit the MTU, but I have seen people do stupid things like set the MSS to much larger than the MTU (thinking it will increase the speed, but the effect is the opposite). That forces IP to create fragments prior to sending. Also, if the MTU shrinks along the path, that can cause IPv4 fragmentation (IPv6 does not have path fragmentation). IP fragmentation and reassembly is resource expensive. We have PMTUD to discover the smallest MTU in the path so that the MTU, and by extension the MSS, can be automatically set prior to sending.

By the way, it is a mistake to simply assume ethernet, which has been dethroned as the King of the LAN by Wi-Fi. Also, you really do not know what layer-2 protocols will be encountered along the path, For example, many DSL connections use PPPoA (PPP over ATM) instead of ethernet.

  1. The network software groups all datagrams of an upper layer as a a bundle of binary (eg: 3 IP packets of size 1000, 800, and 1200 bytes to a bundle of 3000 bytes) then cut that bundle anywhere it feels best to make the payloads for datagrams of lower layer (e.g: to 2 Ethernet frames with payload of 1500 bytes each). The receiving device can always get 3 original IP packets from 2 Ethernet frames.

The lower-layer network protocols do not bundle datagrams of the upper-layer network protocols. TCP, because it is a stream protocol, may bundle application-layer datagrams and chop the datagrams into proper TCP segments.

  • Dovetailing into the touch on 802.11, 802.11n introduced frame aggregation with the A-MSDU and A-MPDU concepts. These are two different mechanisms that allow a wireless station (client or AP) to aggregate data frames to send during one transmission. A-MPDUs have a maximum size of 64k. While technically they are aggregating the equivalent of Ethernet frames, I figured it functions as an example of a protocol aggregating traffic handed off by another protocol that is then de-aggregated by the receiver before handing it back up the network stack. – YLearn Dec 14 '19 at 19:27
  • Yes, I was careful in my answer ("The lower-layer network protocols do not bundle datagrams of the upper-layer network protocols."). I didn't see how this fit with the three packets in two frames concept of the question, so I avoided it. – Ron Maupin Dec 14 '19 at 19:35
  • @RonMaupin I got what you said. After studying the structure of TCP segments, I just realize that they have sequence number field to control the segmented binary pieces. IP packets and Ethernet frames provide no mechanism to do that. IP fragmentation is a way to work around with low Ethernet MTU, but it works on a packet basis, not on a bundle of binary data. – Livy Dec 15 '19 at 18:18
  • @RonMaupin with ATM's cell-size being so small, do you know whether multiple IP packets ever go into the same cell? – jonathanjo Dec 18 '19 at 20:06
  • I really do not know, but I doubt it. Since packets are individually routed, and ATM uses virtual circuits, it seems unlikely that packets would get combined into one cell. – Ron Maupin Dec 19 '19 at 3:54
4

There is no conversion. Upper layer data units are encapsulated by lower layer data units. The data unit itself isn't changed (except special translation schemes like NAPT). It is embedded as a whole (service data unit) into the next lower layer's data unit (protocol data unit).

As an example, user data is encapsulated in a UDP datagram (UDP header is prepended), which is encapsulated by an IP packet (IP header is prepended). The IP packet is encapsulated by an Ethernet frame (Ethernet frame header is prepended, FCS is appended). The Ethernet frame is encapsulated by physical layer signaling, sometimes called Ethernet packet (preamble is prepended, IPG is appended). (Actually, there's some conversion on this stage as the data very often needs to be line encoded.)

A single TCP segment is always converted to a single IP packet by adding IP header, which is in turn converted to a single Ethernet frame by adding Ethernet header (and footer).

Yes, in the simplest case. The resulting IP packet may be too large to fit into a single Ethernet frame and then needs to be fragmented (in case the source host isn't aware of the MTU limits along the path).

The network software groups all datagrams of an upper layer as a a bundle of binary (eg: 3 IP packets of size 1000, 800, and 1200 bytes to a bundle of 3000 bytes) then cut that bundle anywhere it feels best to make the payloads for datagrams of lower layer (e.g: to 2 Ethernet frames with payload of 1500 bytes each).

With TCP, the TCP/IP stack decides on how user data is divided into TCP segments (and reassembled). UDP datagrams are encapsulated and sent as is (apart from possible fragmenting). Generally, data from different sockets cannot be bundled together.

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.