Ethernet – Is a Datagram from Upper Network Layer Converted 1:1 to Lower Layer?

ethernetlayer2layer3layer4tcp

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.

Best Answer

  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.