sanjihan
sanjihan

Reputation: 5992

When exactly are network packets created?

At which point in message transmission from client to host (or vice versa) is the message actually sliced into packets?

From my current understanding, the application puts an entire file in the socket and hands it over to TCP entirely. TCP first buffers the file/message, and when the time is right (when is the time right?) cuts chunks of the buffer data (creates packets) and adds TCP headers to transform chunks into segments.

Why do we talk about packets in the application layer, if there are no packets in the application layer at all? Just whole files... This doesn't add right.

Can someone confirm my understanding?

Upvotes: 3

Views: 2164

Answers (2)

jch
jch

Reputation: 5651

A TCP-based application has a message to send. What the message is depends on the application — it could be just a small request, or a whole file. It passes the message to the transport layer (TCP), which chops up the message into segments and passes them one by one to the network layer (Internet Protocol). The network layer adds a header to each packet, and passes it to the link layer (Ethernet), which handles frames.

So, in principle, we have:

  • messages at the application layer;
  • segments at the transport layer;
  • packets at the network layer; and
  • frames at the link layer.

In practice, however, people are not that pedantic, and tend to mix the notions up. You'll often hear people speak about TCP packets (the correct term would be IP packets with a TCP payload), and they will even speak about the application sending packets (the correct formulation would be that the application passes messages to the transport layer). Most of the time the inexact terminology is not a problem, since context disambiguates things.

Upvotes: 6

Ron Maupin
Ron Maupin

Reputation: 6452

The data are sliced into, and encapsulated by segments at the transport layer (UDP, TCP). The segments are encapsulated by packets by the network layer (IPv4, IPv6, etc.). The packets are encapsulated by frames at the data-link layer (ethernet, etc.).

Upvotes: 1

Related Questions