How network messages are layered (protocol layers)
A network message passes through five layers. Each layer follows a protocol and adds a header to what it receives.
A food delivery app sends your order to its server as one short message, 24 bytes in this lesson. Before the message leaves your phone, five layers of software each add their own data in front of it. You never see that data.
Each layer puts its own header in front of what it receives from the layer above and passes the result down. The receiving machine removes the headers in reverse order. A router reads only the IP header and writes a new Ethernet header for the next hop. Click each layer to see what its header adds.
More detail
The 24-byte message from the application is carried unchanged. The header sizes are round numbers chosen for illustration, and real headers vary.
The selected layer in full
A network link cannot carry a message of any size. Ethernet carries about 1,500 bytes per frame, so a larger message is cut into packets, and every packet gets its own full set of headers. Drag the response size, then press Send it.
You can now explain why a large reply needs several round trips.
More detail
Each packet carries up to 1,460 bytes of your data and 54 bytes of Ethernet, IP and TCP headers. Header overhead is the share of all bytes that are headers. A round trip is a message out and the reply back.
Press Send it to watch the packets leave. They do not all leave at once. TCP sends about ten, waits to hear that they arrived, then sends twice as many. A large reply therefore costs several round trips of waiting, in addition to the time the bytes take to move.
The 144-byte JSON reply in Server or browser rendering arrives with 54 bytes of headers, so 27% of that transfer is headers. The 280 KB JavaScript bundle (the file of code the browser downloads) in the same lesson needs several round trips for the same reason.