Location>code7788 >text

Introduction to the TCP/IP protocol for computer networks

Popularity:237 ℃/2024-09-09 16:40:37

TCP/IP protocol

synopsis

First of all, the TCP/IP protocol does not just mean that the TCP protocol and IP protocol two protocols, but a protocol cluster. Protocol cluster is what is not difficult to understand, is the literal meaning of a combination of multiple protocols into a collection, which is most representative of the two protocols TCP and IP, in addition to these two and we are familiar with the FTP, UDP and other protocols. Of course, we are mainly introduced below or the two protagonists TCP and IP protocols.

network hierarchy

Network layering is a framework for our network transmission, each layer cooperates with each other to achieve our relatively fast and secure network transmission, we here introduce the OSI layering model introduced by the ISO organization.

  • Physical Layer: This layer defines the interface media etc. for physical transmission between physical nodes

  • Data Link Layer: This layer is the working layer of the switch and is used to encapsulate and decapsulate the MAC address of the data received from the physical layer.

    MAC address is the physical address of our network, it is the address of the network card level, each network card has its own MAC address

  • Network Layer: This layer is the working layer of the router and is used to encapsulate or decapsulate packets through the IP protocol.

  • Transport Layer: This layer defines the protocols and port numbers we use to transmit data, segmenting and transmitting our packets, and then reorganizing them once they reach the destination address, which is where the TCP and UDP protocols come into play.

  • Session Layer: Used to initiate or receive session requests over the transport path established by the transport layer.

  • Representation layer: used to transform the received data into something that we, the users, can recognize, and vice versa is to transform what we can recognize into computer data

  • Application Layer: This layer mainly provides terminal network services for users, such as web browsing or email transmission, etc. This layer is where HTTP, FTP and other protocols come into play.

IP protocol

IP refers to the Interconnection Protocol, an acronym for Internet Protocol, which belongs to the network layer in terms of our network hierarchy, and serves to encapsulate our data into the form of packets through the IP protocol or to disassemble the packets to provide them to the data link layer to help in the transmission of data.

Nowadays, our network environment is very complex, the network structure is also blossoming, each manufacturer of network equipment, systems, etc. There may be differences in protocols, so the IP protocol emphasizes the adaptability, simplicity and operability, and in the reliability of some concessions, IP does not guarantee the reliability of the packet transmitted by the possibility of loss, duplication, delay, or disorder and other problems.

IP sharding

IP packets in the process of transmission, may go through different physical networks, limited by the maximum transmission unit of the network data frame, when the IP packet is too large it will be split into multiple groups to meet the conditions of the transmission unit of the segment, the transmission is completed to reach the target host when the reorganization.

IP transport is mainly to solve two problems, one is the decomposition and reorganization, one is the transmission, the specific details of the study can be more in-depth research studies, but not too much to repeat here.

TCP protocol

TCP is the abbreviation of "Transmission Control Protocol", which translates to "Transmission Control Protocol". We can see through the above introduction, if we take the IP packet directly to the transmission is obviously very unreliable, slightly a network turbulence will lead to I can not receive packets, and the sender does not know. So what to do?

TCP provides end-to-end byte stream transmission, he creates a channel for our data and transmits packets as streams in the channel he creates, making end-to-end data transmission reliable. So how does he create & terminate this channel?

handshake

As shown in the figure shows the general flow of three handshakes, three message transmissions, three state updates, one step less will lead to connection failure. After the three handshakes are completed, the data can be transferred.

We do not dissect the principle of SYN and ACK, let's look at the contents of the brackets, it is not difficult to see, each time the data transmission is actually based on the received data for an agreed upon processing and then sent, it is equivalent to us to the poem, you a (the white sun according to the mountains are over) I a (the Yellow River into the sea), only in accordance with the rules of the agreed upon return to the contents of our transmission to properly establish a connection, so this connection So this kind of connection is really reliable.

Four waves.

As shown in the figure for the four waved roughly the process, four times the message transmission, the two ends were sent and received once ACK and FIN message. FIN message means the termination of the transmission request message, when the client applies for the termination of the transmission, is now sent to the server side to send a termination confirmation, meaning that the data transmission is complete, requesting the termination of the connection, and then the server side will send an ACK after receiving means the remaining Data transmission, to be transmitted after the end of sending FIN means that the server data transmission is complete to apply for termination of the connection, and finally the client responds with an ACK response to the server, indicating that the connection has been closed.

sliding window

TCP sliding window is a protocol used to control the flow of traffic during network transmission, which supports the sender to send multiple packets of data before stopping and waiting for an acknowledgement to improve network throughput, data transmission efficiency.

The general idea is that the sender wants to send data, the receiver gives the sender a window size, and then the sender groups its data flow through the window size given by the receiver and sends it in accordance with the size specified by the receiver, one section at a time, which has the advantage that the receiver can manage the sender's data size by controlling the window size, thus avoiding network congestion caused by sending a large amount of data directly into the network. The advantage of this is that the receiver can manage the size of the data sent by the sender by controlling the size of the window, thus avoiding the network congestion caused by the large amount of data sent directly by the sender.

Instead of sending a batch of packets to fill the window, the sender can start with one packet in slow start mode and increment it one by one up to the amount of packets in the receiver's window size.

retransmission after timeout

Timeout retransmission mechanism is an important part of the reliability of TCP, this mechanism can be more than a certain period of time the receiver did not receive the data but the sender has been sent to retransmit, to ensure that the receiver can have a better chance to receive the data.

TCP protocol requires the sender to send a message segment of each time to start a timer and wait for a response message, if the timeout will be reorganized and retransmission of the message segment. This mechanism is the most difficult to realize the retransmission timeout (RTO) confirmation, too large or too small will lead to problems, too large will lead to waiting for the confirmation of time is too long to affect the throughput, and too small will lead to frequent retransmission waste of network resources. So the dynamic confirmation of the RTO is very difficult, here but not too much detail (in fact, the strength is not hard enough T_T).

summarize

The TCP/IP protocol cluster is a very clever collection of protocols that are distributed at different network layers to help us agree, interface, and transmit data in the form of various messages, packets, and other forms of data. There are also different protocols for different scenarios, such as the trade-off between TCP and UDP, each with their own benefits and usage scenarios. This article only through my subjective understanding to introduce the general situation of the IP and TCP protocols. If you have the energy, we can continue to dig deeper together.

Thanks for stopping by, this article is heavy on introductions, if anything is wrong please take the trouble to enlighten me, thanks.