Home >Product dynamics>Product dynamics
3 steps to learn the TCP/IP protocol of the communication protocol


TCP/IP (Transmission Control Protocol/Internet Protocol, Transmission Control Protocol/Internet Protocol) refers to a protocol cluster that can realize information transmission between multiple different networks.
The TCP/IP protocol not only refers to the two protocols of
TCP and IP, but refers to a protocol cluster composed of FTP, SMTP, TCP, UDP, IP and other protocols, just because the TCP protocol and the IP protocol in the TCP/IP protocol The most representative, so it is called the TCP/IP protocol.

On the page :

Step1: Know the jargon: packet, frame, packet, segment, message

Step2: The process of data transmission in the protocol stack

Step3: Transport layer protocols in TCP/IP: TCP and UDP



MODBUS TCP and RTU

Refer article :


Know the jargon: packet, frame, packet, segment, message


The below five terms are all used to describe the unit of data, roughly distinguished as follows:

① Package can be said to be a versatile term;

② Frame is used to represent the unit of packet in the data link layer;

③ Data packet is the unit of packet in layers above the network layer such as IP and UDP;

The segment represents the information in the TCP data stream;

⑤ Message refers to the unit of data in the application protocol.

In each layer, a header is attached to the sent data, which contains the necessary information of this layer, such as the destination address and protocol related information. Usually, the information provided for the protocol is the packet header, and the content to be sent is the data. From the perspective of the next layer, all the packets received from the upper layer are considered as the data of this layer.

In addition, you need to understand IP, MAC, port

IP address: Used to identify interconnected hosts and routers in a TCP/IP network.

MAC: Identify different computers on the same link.

Port: Port numbers are used to identify different applications communicating on the same computer. Therefore, it is also called program address.

MAC vs IP

The process of data transmission in the protocol stack


① Application processing

First of all, the application program will perform encoding processing. These encodings are equivalent to the presentation layer function of OSI; after encoding conversion, emails may not be sent out immediately. This kind of management function of when to establish a communication connection and when to send data is equivalent to an OSI session. layer function.

② Processing of TCP module

TCP is responsible for establishing a connection, sending data, and disconnecting according to the instructions of the application. TCP provides a reliable transmission that smoothly sends data from the application layer to the peer. In order to realize this function, a TCP header needs to be appended in front of the application layer data.

③ Handling of IP modules

IP combines the TCP header and TCP data transmitted by TCP as its own data, and adds its own IP header to the front end of the TCP header. After the IP packet is generated, refer to the routing control table to determine the route or host that accepts the IP packet.

④ Processing of network interface (Ethernet driver)

IP packets transmitted from IP are data to Ethernet. Attach the Ethernet header to the data and send it, and the generated Ethernet data packet will be transmitted to the receiving end through the physical layer.

⑤ Processing of network interface (Ethernet driver)

After the host receives the Ethernet packet, it first finds the MAC address from the header of the Ethernet packet to judge whether it is a packet sent to itself, and discards the data if not. If it is a packet sent to itself, determine the data type from the type in the Ethernet packet header, and then pass it to the corresponding module, such as IP, ARP, etc. The example here is IP.

⑥ Handling of IP modules

The IP module also performs similar processing after receiving the data. Judging from the packet header whether this IP address matches its own IP address, if it matches, it will send the data to the corresponding module according to the protocol type of the header, such as TCP and UDP. The example here is TCP. In addition, in the case of a router, the address of the receiving end is often not its own address. At this time, it is necessary to use the routing control table to investigate the host or router that should be sent before forwarding the data.

⑦ Processing of TCP module

In the TCP module, the checksum is first calculated to determine whether the data is corrupted. Then check to see if data is being received by sequence number. Finally, check the port number to determine the specific application. After the data is received in its entirety, it is passed to the application identified by the port number.

⑧ Application processing

The receiver application will directly receive the data sent by the sender. By parsing the data, display the corresponding content.
picture

Transport layer protocols in TCP/IP: TCP and UDP

TCP is a connection-oriented, reliable streaming protocol. Stream refers to an uninterrupted data structure. When an application uses TCP to send messages, although the order of sending can be guaranteed, it is still sent to the receiving end as if there is no interval of data stream. In order to provide reliable transmission, TCP implements a "sequence control" or "retransmission control" mechanism. In addition, it has many functions such as "flow control (flow control)", "congestion control", and improvement of network utilization.

UDP is an unreliable packet protocol. The subtle processing will be handed over to the upper application to complete. In the case of UDP, while the size of the sent message can be guaranteed, there is no guarantee that the message will arrive. Therefore, the application sometimes performs retransmission processing according to its own needs.

The advantages and disadvantages of TCP and UDP cannot be compared simply and absolutely: TCP is used when reliable transmission is necessary at the transport layer; on the other hand, UDP is mainly used for those who have high requirements for high-speed transmission and real-time performance communications or broadcast communications. TCP and UDP should be used as needed according to the purpose of the application.

Communication identification through IP address, port number, protocol number: