TCP/IP network protocol BASICS (1)
Introduction
This article is a basic knowledge of TCP/IP protocol. It focuses on the content and functions of TCP/IP protocol clusters and the basic knowledge related to TCP, UDP, and IP network protocols.
Content
TCP/IP protocol clusters are developed from the OSI Layer-7 model. The OSI Interconnection Reference model has the following benefits:
1. Used to solve the interconnection problem between devices of different vendors: Compatibility considerations;
2. the hierarchical structure is highly independent and highly scalable;
3. unified standards for easy learning;
TCP/IP Model
Shows the relationship between the TCP/IP model and the OSI model:
Note
1. Application Layer: it corresponds to the application layer, presentation layer, and Session Layer of OSI. It mainly serves to provide network access interfaces to user applications;
2. Transport Layer: it is also called the host-to-host layer. It corresponds to the OSI transport layer and specifies the protocol for controlling the network layer. It defines whether the data transmission mode is TCP or UDP, establish end-to-end connections between the two devices. Both the transport layer and the data link layer define traffic control and error control mechanisms. The difference is that the data link layer protocol emphasizes traffic control on the data link, that is, the physical media traffic connecting the two devices, and the transport layer controls the traffic on the Logical Link, that is, the end-to-end connection between the two devices. This logical connection may span a series of data links;
3. Network Layer: defines the packet format and address format. The main role is IP address addressing and route selection.
4. access layer: includes the data link layer and the physical layer. The data link layer defines how to access and share the media, and how to identify the device on the media, that is, the two-layer addressing (MAC address) and how to complete data frame before sending data on the media, common L2 protocols include Ethernet, PPP, HDLC, frame transfer, ATM, etc. The physical layer defines the Protocols related to the physical media: electronic/Optical protocols (voltage, light intensity, coding, Signal Waveforms) Mechanical protocols (dimensions, metallic composition of wires) Functional protocols (description of what to do) procedural protocols (describes how to do such: 1 indicates the voltage is less than-3 V)
TCP protocol
Explanation
Transmission Control Protocol (TCP): a reliable connection-oriented service. That is, a point-to-point connection is provided.
Mechanism
1. Mark the data packet with the serial number;
2. Use the validation, checksum timer system and retransmission mechanism to provide reliability;
3. Sliding Window Mechanism to adjust the data packet traffic: reduce the possibility of packet loss due to the full buffer of the receiver.
Packets
Note
1. Source Port and destination port: Each has 16 bits, specifying the Source and Destination applications for the encapsulated data. The application port number and the IP address of the host where the application is located are collectively referred to as sockets. Each application is uniquely identified by a socket on the network.
(Supplement: services corresponding to common port numbers: FTP: TCP21; TELNET: TCP23; SMTP: TCP25; BGP: TCP179; DNS: TCP/UDP53; TFTP: UDP69; SNMP: UDP161; RIP: UDP520 ;)
2. Serial number: The field length is 32 bits, and the encapsulated data location in the data stream sent by the sender is determined;
3. Confirmation Number: The length is 32 bits. It determines the next serial number expected to be accepted from the target at the source point, and implicitly confirms the previous packet that received the serial number;
4. Header Length: The length is 4 bits, and the header length in 32 bits is specified.
5. Reserved: The length is 4 bits, which is usually set to 0;
6. MARK: 8 bits for stream and Connection Control. From left to right: CWR, ECE, URG, ACK, PSH, RST, SYN, and FIN;
7. Window Size: The field length is 16 bits and is mainly used for throttling. Window Size indicates the size of the buffer received by the receiver;
8. checksum: the header and encapsulated data are verified with a length of 16 bits;
9. Emergency pointer: used only when the URG flag is set. The 16-bit serial number is added to indicate the end of the emergency data;
10. Optional: Specifies the options required by the TCP sending process. The common option is the maximum segment length, which is used to notify the recipient of the maximum segment length that the sender is willing to receive, to ensure that the packet length is a multiple of 32 octal groups, fill the remaining part of this field with 0.
UDP protocol
Explanation
User Datagram Protocol (UDP): a data forwarding service that is connectionless and best-effort.
Advantages
If you do not spend time establishing a connection and send data directly, that is, the overhead is small, which can improve the performance of applications that send small data volumes.