To distinguish between messages, data packets, datagrams, and frames, we can first understand the following three basic knowledge points:

  1. The five-layer structure of computer networks: application layer, transport layer, network layer, link layer, and physical layer.
  2. Encapsulation of messages is from the upper layer to the lower layer:application layer-->transport layer-->network layer-->data link layer-->physical layer, and decapsulation of messages is from the lower layer to the upper layer.
  3. Data transmission process: Messages are generated by the application layer and are called messages/data. They are encapsulated by the transport layer to form segments/datagrams, and then encapsulated by the network layer to form packets/packets. Finally, they are encapsulated by the data link layer to form frames. Finally, data transmission is completed in the form of binary bit streams at the physical layer. During the transmission process, each layer will add some headers composed of control information, which are the message headers. At the receiving end, each layer will remove the headers it added and restore the original data.

We can use a vivid example to illustrate this: when we send express delivery, it is equivalent to being at the application layer, sending the express delivery in hand. The goods are the message. After filling in the destination information at the delivery point, it forms a datagram, which is at the transport layer; the logistics center marks the destination information in its own way to form a data packet, which is at the network layer; and the data link layer is responsible for selecting the transportation tool to add the frame header and frame tail to form a data frame; finally, it comes to the physical layer, and the express delivery needs to complete the delivery, that is, the data is transmitted in the form of a bit stream. After arriving at the destination, the header added by the layer in which it is located is removed layer by layer, which can also be understood as being dispatched layer by layer according to the express address information, and finally delivered to our recipients. Our goods remain unchanged.

With the above understanding, we only need to explain the above terms separately and emphasize the points that are easy to confuse, so that we can distinguish them.

  1. Message/Data:

We call the information grouping at the application layer a message. Message is the data unit exchanged and transmitted in the network, that is, the data block to be sent by the station at one time. The message contains the complete data information to be sent, and its length is very inconsistent, and the length is unlimited and variable.

  1. Datagram/Segment:

Now we come to the transport layer, which should be combined with the following two protocols:

The first is the TCP (Transmission Control Protocol) protocol that we often hear, that is, the transmission control protocol. It is connection-oriented, and the unit of data transmission is the message segment, which can provide reliable delivery.

The second is the UDP (User Datagram Protocol) protocol, that is, the user datagram protocol, which is connectionless, and the unit of data transmission is the user datagram. It does not guarantee reliable delivery, and can only provide "best effort delivery".

  1. Packet:

Packet is the data unit in TCP/IP protocol communication transmission, which is in the network layer. In the local area network, "packet" is contained in "frame". Some materials will call it IP datagram, but it is just a different name.

  1. Frame:

Frame is the transmission unit of the data link layer. The data transmitted in the upper layer is added with a header and a tail to form a frame.

In short, in fact, messages, segments/datagrams, data packets, and frames are named differently based on the different protocol layers. Their most essential data has not changed.