The terms Frame
, Packet
, and Segment
exist to create abstractions from what one layer is responsible for verses the others.
To explain that, and to answer your question thoroughly, I'm going to start a bit "earlier" than what you are really asking.
Therefore...
- When Layer 4 gets data, it adds to it a header which facilitates service to service delivery like TCP or UDP ports (among other things) -- this whole datagram is referred to as a Segment.
- When Layer 3 gets data, it adds to it a header which facilitates end to end delivery like the source IP of the initial sender and the destination IP of the final recipient -- this whole datagram is referred to as a Packet.
- When Layer 2 gets data, it adds to it a header which facilitates hop to hop delivery like the Source and Destination MAC addresses of the current "hop" in the network -- this whole datagram is referred to as a Frame.
The is essentially the process of Encapsulation, illustrated in this animation:
A Frame then, is the L2 header plus whatever data needs to be delivered to the next hop:
Frame: [L2 HDR][110011001010101011110000...010101]
You and I know that inside the frame is a L3 header and a L4 header and application data, but as far as L2 is concerned, everything inside is just a series of 1
s and 0
s that need to be delivered to another hop.
A Packet then, is the L3 header, plus whatever data needs to be delivered to the other end:
Packet: [L3 HDR][1010101011110000...010101]
You and I know that inside the packet is a L4 header and application data, but as far as L3 is concerned, everything inside is just a series of 1
s and 0
s that need to be another endpoint
A Segment then, is the L4 header, plus whatever data needs to be deliverred to the other service:
Segment: [L4 HDR][11110000...010101]
You and I know that inside the Segment is the application data which is to be processed by the receiving service
And the application data itself, of course, is going to differ with every application. HTTP for web requests, FTP for file transfers, and so on.
The term Datagram itself is simply the construct of a header and bits. And the terms above are simply the unique names for the particular Datagram that operates at each layer.
- A Frame is the Datagram at L2
- A Packet is the Datagram at L3
- A Segment is the Datagram at L4