Computer network study notes 2 TCP/IP architecture

table of Contents

1. OSI model
1. OSI seven-layer model
2. Five-layer protocol system structure
2. TCP/IP protocol system
1. 4-layer structure, application layer, transport layer, network layer, data link layer
2. TCP protocol Difference with udp protocol
3. TCP three-way handshake <request—>response—>confirm>
4. wave four times

Back to top
1. OSI model
1, OSI seven-layer model,

(1) Description of each layer structure
Copy code
Data link layer, network layer (IP), link layer (tcp, udp) are in kernel mode,
application layer (DNS, ftp, https protocol) is in user area

Application layer (data): Determine the nature of communication between processes to meet user needs and provide network and user applications (file transfer, email, file service, virtual terminal)
Presentation layer (data): Mainly solve the problem of grammatical representation of user information , Such as encryption and decryption (data formatting, code conversion, data encryption)
session layer (data): provides mechanisms for establishing and maintaining communication between applications including access verification and session management. For example, the server verifies that the user logs in by the session Layer completed (releasing or establishing contact with other contacts)
Transport layer (segment): to realize data communication between user processes on different hosts in the network, reliable and unreliable transmission, error detection at the transport layer, flow control (provide End-to-end interface)
Network layer (packet): Provide logical address (IP), routing, data transmission from source to destination (choose route for data packet)
Data link layer (frame): Encapsulate upper layer data into frames , Use MAC address to access the medium, error detection and correction (transmission of addressed frames and error detection function)
physical layer (bit stream): bit stream transmission between devices, physical interfaces, electrical characteristics, etc. (in the form of binary data Data transmission on physical media)
Copy code
(2) Device application
Copy code
Gateway: application layer, transport layer
(the gateway is interconnected by a four-wire network on the transport layer, which is the most complex network interconnection device, only used for two upper layers Networks with different protocols are interconnected. The structure of the gateway is similar to that of the router, but the difference is the interconnection layer. The gateway can be used for both WAN and LAN interconnection)

Router: network layer
(routing, store and forward)

Switch: data link layer, network layer
(identify the MAC address information in the data packet, forward it according to the MAC address, and record these MAC addresses and corresponding ports in an internal address table)

Bridge: data link layer
(connect two LANs and forward frames according to MAC addresses)

Hub: physical layer
(pure hardware device, mainly used to connect to network terminals such as computers)

Repeater:: physical layer
(regenerate and retiming network signals at the bit level, so that they can transmit longer distances on the network)
copy code
2, five-layer protocol architecture,

Back to top
2. TCP/IP protocol system
1. Adopt 4-layer structure, application layer, transport layer, network layer, data link layer

Each layer calls the protocol provided by the lower layer to complete the demand;

Copy the code
Data link layer:
(1) ARP (Address Resolution Protocol): It realizes the conversion of IP address to physical address (usually MAC address, commonly understood as network card address).
     Application: The network layer uses the IP address to find a machine, while the data link layer uses the physical address to find a machine, so the network layer must first convert the target machine’s IP address into a physical address before it can be provided by the data link layer Service.

(2) RARP (Reverse Address Resolution Protocol): As the name suggests, it is the opposite of ARP. It is an
     application that realizes the conversion from physical address to IP address : RARP protocol is only used for some diskless workstations on the network because of lack of storage. Devices and diskless workstations cannot record their own IP addresses, but the mapping from physical addresses to IP addresses can be seen through RARP.
Network layer:
(1) IP
(2) ICMP: mainly used to detect the
    8-bit type of network connection : ICMP messages are divided into two categories: one is error messages, such as target unreachable (type value 3) and Redirection (type value is 5); the other type is query messages, which are used to query network information.

Some ICMP messages also use 8-bit code fields to subdivide different conditions. For example, a code value of 0 means network redirection, and a code value of 1 means host redirection.

16-bit checksum: Perform cyclic redundancy check (CRC) on the entire message (including the header and content part).

Note: The ICMP protocol is not strictly a network layer protocol, because it uses the services provided by the IP protocol at the same layer. Generally speaking, the upper layer protocol uses the service provided by the lower layer protocol.

Transport layer:

(1) TCP protocol (Transmission Control Protocol): Provide reliable, connection-oriented and streaming services for the application layer

(2) UDP protocol (User Datagram Protocol): Provide unreliable, connectionless and datagram services for the application layer

(3) SCTP protocol (Stream Control Transmission Protocol): transmission of telephone signals

Application layer:

(1) OSPF (Open Shortest Path First) protocol: It is a dynamic routing update protocol used for communication between routers to inform each other of their respective routing information.

(2) DNS (Domain Name Service) protocol: Provides the conversion of machine domain names to IP addresses. (For example, if you convert www.baidu.com into Baidu's IP, you can enter the domain name directly. Because the IP address is too troublesome to remember, just like everyone is uniquely identified by an ID card, but just to remember it Name. DNS is a process of matching a name with an ID card)

(3) The telnet protocol is a remote login protocol that enables us to complete remote tasks locally.

(4) HTTP protocol (Hypertext Transfer Protocol) is a stateless, application layer protocol based on request and response mode, often based on TCP connection.

(5) TFTP protocol

(6) SNMP protocol

(7) SMTP protocol

Copy code
2. The difference between tcp protocol and udp protocol
TCP transmission control protocol. UDP User Datagram Protocol
TCP requires more resources, while UDP requires less resources.
TCP can ensure the correctness of data, and UDP may lose packets.
TCP can guarantee the order of data, but UDP does not.

3. TCP three-way handshake <request—>response—>confirmation>
bit codes are 6 types of TCP flag bits: SYN connection establishment flag, ACK confirmation bit, PSH transmission, FIN end to close the connection, RST reset bit, URG emergency bit ; Seq starting sequence number, ack confirmation number;

The first handshake: The TCP client process first sends a TCP message segment to the TCP server process. The flag bit SYN=1 (sign) in the header of the message segment, the starting sequence number seq=x, the message segment is called It is a SYN message segment, which is encapsulated in an IP data packet and sent to the server;

Second handshake: After the TCP SYN segment arrives at the server, SYN and ACK are both 1, and the confirmation number ack=x+1, the server sets its own starting sequence number seq=y, which is called the SYNACK segment at this time Sent to the client;

The third handshake: After receiving the SYNACK message, send the third segment to the server to confirm the segment that the server is allowed to connect to. The segment confirmation number ack=y+1, the starting sequence number seq=x+1, after sending, both the client and server enter the ESTABLISHED state, complete the three-way handshake, and start to transmit data.
4. Wave four times

Copy code
1) The client process sends a connection release message and stops sending data. Release the header of the data message, FIN=1, and its sequence number is seq=u (equal to the sequence number of the last byte of the previously transmitted data plus 1), at this time, the client enters FIN-WAIT-1 (terminate waiting 1) Status. TCP stipulates that even if the FIN segment does not carry data, it will consume a sequence number.
2) The server receives the connection release message and sends an acknowledgment message, ACK=1, ack=u+1, and brings its own serial number seq=v. At this time, the server enters CLOSE-WAIT (close waiting )status. The TCP server informs the high-level application process that the client is released in the direction of the server. At this time, it is in a half-closed state, that is, the client has no data to send, but if the server sends data, the client still has to accept it. This state will continue for a while, that is, the duration of the entire CLOSE-WAIT state.
3) After the client receives the server's confirmation request, at this time, the client enters the FIN-WAIT-2 (termination waiting 2) state, waiting for the server to send a connection release message (before that, it needs to accept the last sent by the server). data).
4) After the server sends the final data, it sends a connection release message to the client, FIN=1, ack=u+1. Because it is in the semi-closed state, the server is likely to send some more data. The sequence number is seq=w. At this time, the server enters the LAST-ACK (last confirmation) state, waiting for the client's confirmation.
5) After the client receives the connection release message from the server, it must send an acknowledgment, ACK=1, ack=w+1, and its own serial number is seq=u+1, at this time, the client enters TIME- WAIT (time waiting) status. Note that the TCP connection has not been released at this time, it must pass 2**MSL (the longest message segment life) time, when the client cancels the corresponding TCB, it enters the CLOSED state.
6) As long as the server receives the confirmation from the client, it immediately enters the CLOSED state. Similarly, after canceling the TCB, this TCP connection is ended. It can be seen that the server ends the TCP connection earlier than the client.
Copy code
5. TCP/IP realizes reliable transmission method

Copy code
1, serial number, ACK signal: the sender marks each packet to be sent with a serial number. After receiving the data packet, the receiver sends an ACK signal to the sender to include the sequence number of the next data packet required.
2. Timeout retransmission: When the sender does not receive the receiver's ACK within the specified time, the data packet will be retransmitted, and the next time waiting for retransmission will increase exponentially. After a certain number of retransmissions, if the ACK has not been received, the connection will be forcibly disconnected.
3. TCP connection management: three handshake, four waves.
4. Send data packets in units of segments: When the communication parties establish a connection, the unit of the data packet is negotiated (Maximum Message Length (MSS)).
5. Sliding window: including data packets that have been sent but not received by the front end, and data packets to be sent by the back end. After the receiving end receives the ACK, the window slides forward until it stops when there is unacknowledged data.
6. Flow control: TCP datagram header field to control the size of the sliding window.
7. Congestion control: The sender actively controls the data flow through the congestion window. Slow start: Prevent both parties from sending a large number of data packets at the beginning. The initial size of the congestion window is: 1MSS. The congestion window is doubled every time an ACK is received. When sending data packets, choose the smaller of the congestion window and sliding window. value. Congestion avoidance algorithm: Compared with slow start, the growth rate of the congestion window is slower. Fast retransmission: When the ACK is not received within the specified time limit, it is likely that there is a problem with the network. At this time, reduce the congestion window to one and start again slowly.
Copy code

About the article migration CSDN https://blog.csdn.net/weixin_40960688

Guess you like

Origin blog.csdn.net/yimzuenmuanggg/article/details/111147992