TCP/IP protocol

Source: Internet
Author: User
Tags snmp file transfer protocol

Why is there a TCP/IP protocol

All over the world, a wide variety of computers run their own different operating systems for everyone, and these computers are used in many ways when expressing the same message. It is as if God in the Bible has disturbed the accents of people everywhere and made them unable to cooperate. Computer users realize that the computer is only a man-in-the-war and does not play a big role. Only by bringing them together can the computer play its greatest potential. So people are trying to connect the computer to each other by electric wires.

But the simple connection is not enough, as if the language of the different two people meet each other, completely unable to exchange information. So they need to define something common to communicate, and TCP/IP is born for that. TCP/IP is not a protocol, but a generic term for a protocol family . It includes IP protocols, IMCP protocols, TCP protocols, and more familiar HTTP, FTP, POP3 protocols, and more. Computers have these, as if learning a foreign language, you can and other computer terminals to do free communication.

TCP/IP protocol tiering

 The physical layer (RS-232, v.35) and the Data Link layer (HDLC, x.) involve the original bit stream transmitted on the communication channel, which realizes the mechanical, electrical, functional and process of transmitting the data, and provides the methods of error detection, correction, synchronization, etc. Make it appear on the network layer error-free line, and flow control. Bits, Frames

  The network layer checks the network topology to determine the best route for transmitting messages and performs data forwarding. The key issue is determining how packets are routed from the source to the destination. The primary protocols for the network layer are IP, ICMP (Internet Control message Protocol, Internet Controlled message Protocol), IGMP (Internet group Management Protocol, Internet Groups Management Protocol), ARP (Addresses Resolution Protocol, Address Resolution Protocol) and RARP (Reverse address Resolution Protocol, reverse Address Resolution Protocol) and so on. Packets

  The basic function of the Transport layer is to provide end-to-end communication for applications between two hosts. The transport layer accepts the data from the application layer and, when necessary, divides it into smaller units, which are passed to the network layer and ensure that each piece of information that arrives at the other side is correct. The main protocols of the transport layer are TCP, UDP (user datagraph Protocol, Subscriber Datagram Protocol). Segments

  The Application layer is responsible for handling specific application details. The application layer displays the received information, sends the user's data to the lower level, and provides the network interface for the application software. The application tier contains a large number of commonly used applications, such as HTTP (Hypertext Transfer Protocol Text Transfer Protocol), Telnet (telnet), FTP (File Transfer Protocol), and so on.

  The sender , the encapsulated operation is carried out on a level-by-layer basis. The data sent by each application is sent to the transport layer, and the Transport Layer (TCP/UDP) segments the data segment to a certain size, plus the header of this layer. Sent to the network layer. In the transport beginning header, contains the port number of the upper layer protocol or application that receives the data it carries, for example, the port number of Telnet is 23. The Transport Layer protocol uses port numbers to invoke and differentiate application-tier applications.

The network layer of the data from the Transport Layer processing (using protocol number to differentiate the Transport layer protocol, the search for the next hop address, the resolution of the Data Link layer Physical address, etc.), and the IP packet header of the layer, converted to a packet, and then sent to the link layer (Ethernet, Frame Relay, PPP, HDLC, etc.);

The link layer is sent to the physical layer to send the message in the form of bitstream by adding the frame header of the layer according to the different data link layer protocols.

  on the receiver side , this encapsulation operation is done on a level-by-layer basis. From the physical layer to the data link layer, the headers of each layer are stripped down, passing the data to the application execution.

Application Layer

FTP (File Transfer Protocol, files Transfer Protocol) is the Internet standard for file transfer. FTP supports some text files (such as ASCII, binary, and so on) and the file structure for byte streams. FTP uses Transport-layer protocol TCP to perform file transfers between FTP-enabled end systems, so FTP is considered to provide a reliable connection-oriented service for file transfers over long distances and less reliable lines.

The TFTP (Trivial file Transfer Protocol, simple Files Transfer Protocol) is also used for file transfer, but TFTP uses UDP to provide services that are considered unreliable and non-connected. TFTP is typically used for reliable file transfers within a LAN.

SMTP (Simple Mail Transfer Protocol. Simple Mail Transfer Protocol) supports Internet transmission of text messages.

POP3 (Post Office Protocol) is a popular Internet mail standard.

SNMP (Simple Network Management Protocol. Simple Network Management Protocol) is responsible for network equipment monitoring and maintenance, support security management, performance management and so on.

Telnet is a standard terminal emulation protocol used by clients to establish a connection to a remote server.

The ping command is a valid tool for diagnosing whether a network device is properly connected.

The tracert command is similar to a ping command, and it is a good diagnostic command to display information about each network device that the packet passes through.

The HTTP protocol supports WWW (World Wide Web) and intranet information interaction, and supports multiple file types, including video. HTTP is today's popular Internet standard.

DNS (domain Name System) translates the easy-to-remember names of network nodes into network addresses.

WINS (Windows Internet name server,windows Internet naming server), which registers and resolves the NetBIOS name to the IP address used on the network.

BootP (Bootstrap Protocol, boot Protocol) is a protocol that dynamically obtains an IP address using the Transport Layer UDP protocol.

  

Transport Layer

The transport layer is located between the application layer and the network layer, providing end-to-end connections to the end host, as well as traffic control (implemented by the window mechanism), reliability (implemented by serial number and acknowledgement technology), support for full-duplex transmission, and so on. There are two kinds of transport layer protocols: TCP and UDP. Although both TCP and UDP use the same network layer protocol IP, TCP and UDP provide a completely different service to the application tier.

Transmission Control Protocol TCP: Provides a reliable, connection-oriented communication service for applications that require responsive applications. Currently, many popular applications use TCP.

User Datagram Protocol UDP: provides no-connection communication and does not reliably guarantee the transmission of packets. Suitable for transmitting small amounts of data at a time, reliability is the responsibility of the application layer.

The TCP protocol guarantees the reliability of end-to-end data communication through the following procedures:

1, the TCP entity divides the application into the appropriate data block, plus the TCP packet header, generates the data section;

2, when the TCP entity sends out the data section, starts the timer immediately, if the source device after the timer clear 0 still did not receive the target device confirmation message, re-sends the data section;

3, when the peer TCP entity received data, send back a confirmation.

4. TCP contains an end-to-end checksum field that detects any changes in the data transfer process. If the data checksum computed by the destination device is incorrect, TCP discards the data segment, and the source device re-sends the data segment after clearing 0 of the timer described earlier.

5, because the TCP data is hosted in the IP packet, and IP provides a non-connected, unreliable service, the packet may be out of sequence. TCP provides a reordering mechanism for the device to reorder the received data and hand it to the application.

6, TCP provides flow control. Each end of a TCP connection has a buffer window. The destination device only allows the source device to send data that it can receive, preventing a buffer overflow.

7, TCP supports full duplex data transmission.

The TCP protocol provides a connection-oriented and reliable network service for terminal equipment, and the UDP protocol provides non-connected and unreliable datagram service for terminal equipment. As we can see, TCP protocol in order to ensure the reliability of data transmission, compared to UDP packets, TCP packet header has more field options.

First, let's look at the main fields of TCP headers:

Each TCP packet header contains the source port number and the destination port number (destination port), which is used to identify and differentiate the application process of the source-side device and the destination device. In the TCP/IP protocol stack, the source port number and destination port number consist of a socket (socket), respectively, with the source IP address and destination IP address, which uniquely determines a TCP connection.

The Sequence number field is used to identify the byte stream that the TCP source-side device sends to the destination device, which represents the first bytes of data in the message segment. If you consider a stream of bytes as a one-way flow between two applications, TCP counts each byte with a sequence number. The serial number is a 32bits number.

Since each transmitted byte is counted, the confirmation sequence number (acknowledgement number,32bits) contains the next ordinal number that is expected to be received at the end of the sending acknowledgment. Therefore, the confirmation sequence number should be the last successfully received data byte sequence numbers plus 1.

Traffic control for TCP is provided by each end of the connection by the declared window size (Windows size). The window size is represented by a packet, such as Windows Size=3, which indicates that three packets can be sent at a time. The window size starts with the value indicated in the confirmation field and is a 16bits field. The window size can be adjusted.

The checksum (checksum) field is used to verify the correctness of the TCP header and data parts.

The most common optional fields are MSS (Maximum Segment size, maximum message size). MSS indicates the maximum length of the message segment that can be received on this side. When a TCP connection is established, both sides of the connection are notified of the maximum length of the message that can be transmitted by the respective MSS negotiation. Our common MSS has 1024 bytes (Ethernet up to 1460 bytes).

Compared to TCP packets, UDP packets have only a small number of fields: Source port number, destination port number, length, checksum, and so on, each field function is the same as the corresponding field of TCP message.

The UDP message has no reliability guarantee and sequence guarantee field, flow control field, etc., the reliability is poor. Of course, applications that use transport-layer UDP services also have an advantage. Due to the low UDP protocol control options, in the data transmission process, the delay is small, the data transmission efficiency is high, suitable for the reliability of the application is not high, or can guarantee the reliability of applications such as DNS, TFTP, SNMP, etc., UDP protocol can also be used to transport link reliable network

The TCP protocol and the UDP protocol use a 16bits port number (or socket) to represent and differentiate between different applications in the network, and the Network layer protocol IP uses a specific protocol number (TCP 6,udp 17) to represent and differentiate the Transport layer protocol.

The services provided by any TCP/IP implementation are the port numbers between 1~1023, which are managed by the IANA (Internet Assigned Numbers authority,internet number allocation authority). Where the port number below 255 is reserved for public applications, the 255 to 1023 port numbers are assigned to individual companies for special applications, and for port numbers above 1023, called temporary port numbers, the IANA does not make provisions.

The commonly used TCP port numbers are: HTTP 80,ftp 20/21,telnet 23,smtp 25,dns 53, etc., common reserved UDP port number is: DNS 53,BOOTP (server)/(client), TFTP 69,SNMP 161 and so on.

Socket (socket) is divided into source sockets and destination sockets:

SOURCE socket: Source port number + source IP address;

Purpose Socket: Destination port number + Destination IP address;

Source sockets and destination sockets are used to uniquely determine a TCP connection. About the IP address, which is described later.

In order to establish a connection between the host and server shown, it is necessary to synchronize the two devices first. Synchronization (synchronization) is achieved through each data segment exchange process that carries the initial sequence number.

The host sends a message segment with a serial number of 1;

The server sends back the message segment 2 containing the serial number B, and confirms the message segment 1 of the host with the confirmation number a+1;

The host receiving server sends back the message segment 2, sends the message segment 3, confirms the message segment 2 with the confirmation number b+1.

This establishes a TCP connection between the host and the server, a process known as a three-step handshake (three-way handshake). Next, the data transfer begins.

After the data transfer is complete, the connection should be terminated. Terminating a TCP connection requires a 4-time handshake.

TCP sliding window technology adjusts the data transfer between two hosts by dynamically changing the window size. Each TCP/IP host supports full-duplex data transfer, so TCP has two sliding windows: one for receiving data and the other for sending data. TCP uses a positive acknowledgment technique whose confirmation number refers to the next expected byte.

Below we take the data single direction to send As an example, describes how the sliding window realizes the flow control.

Assume that the sender device sends data at three packets each time, that is, the window size is 3. The sender sends three packets with a serial number of 1, 2, 3, and the receiving device successfully receives the packet and confirms it with the serial number 4. The sender device receives confirmation and continues to send data at window size 3. When the receiver device needs to reduce or increase network traffic, the window size can be reduced or increased, this example reduces the window size of 2, each time sending two packets. When the receiver device requires a window size of 0, it indicates that the receiver has received all the data, or the receiving application does not have time to read the data, requiring a pause to send. The sender receives a confirmation with a window number of 0 to stop the data transfer in this direction.

The sliding window mechanism provides a reliable flow control mechanism for data transmission between end-to-end devices. However, it can only work on source and destination devices, and the sliding window mechanism will not work when network intermediate devices (such as routers, etc.) are congested. We can use the ICMP source suppression mechanism for congestion management. About ICMP, we'll cover it later.

Network layer

The network layer is located in the middle of the TCP/IP protocol stack Data link layer and the transport layer, and the network layer receives the data packet of the transmission layer, and the segment is the appropriate size, which is encapsulated with the IP packet head and passed to the data link layer. To ensure the successful forwarding of packets, the network layer defines the following protocols:

IP (Internet Protocol) protocol: The IP Protocol and routing protocol work together to find the optimal path that can transmit packets to the destination. The IP protocol does not care about the contents of the data message and provides a non-connected, unreliable service.

ARP protocol (address Resolution Protocol): Resolves a known IP address to a MAC address;

RARP (Reverse address Resolution Protocol, reverse resolution): For the data Link layer address is known, the IP address is resolved;

ICMP (Internet Control Message Protocol, an internetwork-controlled messaging protocol) defines the network layer's ability to control and deliver messages.

IGMP (Internet group Management Protocol, Internetwork Management Protocol), a multicast application protocol.

Articles excerpted from other websites

TCP/IP protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.