TCP/IP Architecture and protocols

Source: Internet
Author: User
Tags file transfer protocol

650) this.width=650; "src=" http://s13.sinaimg.cn/mw690/003F41cCty6UjqyyVgU8c&690 "width=" 1 "height=" 1 "alt=" 003f41ccty6ujqyyvgu8c&690 "/> One, TCP/IP is the most widely used Internet architecture, and it is a four-layer protocol system.

650) this.width=650; "id=" image_operate_99151439343977518 "name=" image_operate_4081438517383790 "src="/HTTP/ s3.sinaimg.cn/mw690/003f41ccty6ujqksrhi82&690 "width=" 219 "height=" 122 "alt=" 003f41ccty6ujqksrhi82&690 "/ >

Each layer is responsible for the different functions:

① Application layer: Responsible for handling specific application details;

② Transport Layer: provides end-to-end communication for applications on two hosts;

③ Network layer: The process of grouping activities in the network, such as grouping routing;

④ Data Link layer: Also known as the network interface layer, which typically includes the device drivers in the operating system and the corresponding network interface cards in the computer.

Workflow of the TCP/IP protocol: (Application-layer transfer file with File Transfer Protocol FTP)

650) this.width=650; "Name=" image_operate_81281438517543098 "src=" http://s10.sinaimg.cn/mw690/ 003f41ccty6ujujb84p99&690 "width=" 577 "height=" 233 "alt=" 003f41ccty6ujujb84p99&690 "/>

① on the target host, the application layer sends a stream of data to the transport layer;

The ② Transport layer truncates the data stream into groups, and the TCP header forms a TCP segment message, which is sent to the network layer;

③ the IP header of the source and destination host on the network layer, generates an IP packet and sends it to the link layer;

The ④ link layer is loaded with IP packets in the data portion of its Mac frame, plus the MAC address and frame head of the source and destination host, and the Mac frame is sent to the destination host or IP router according to its destination MAC address;

⑤ on the destination host, the link layer removes the frame header of the Mac frame and sends the IP packet to the network layer;

The ⑥ network layer checks the IP header, and if the header check is not the same as the computer, the IP packet is discarded, and if the checksum is the same, the IP header is removed and the TCP segment is sent to the transport layer;

⑦ Transport Layer checks the sequence number, determines whether the TCP packet is correct, and then checks the TCP header data, if correct, sends the acknowledgement to the source host, if it is incorrect or discarded, the source host is required to resend;

⑧ in the destination host, the transport layer removes the TCP header and sends the queued grouping of application data streams to the application so that the destination host receives a byte stream from the source host as if it were directly receiving a byte stream from the source host.

Second, TCP three handshake < request---> Answer---> Confirmation >

The bit code is the TCP flag bit 6 kinds: SYN establishes the connection the sign bit, the ACK confirms the bit, the PSH transmits, the fin ends closes the connection, the RST resets, the Urg emergency; SEQ starting serial number, ACK confirmation number;

650) this.width=650; "Name=" image_operate_16401438517544237 "src=" http://s12.sinaimg.cn/mw690/ 003f41ccty6ujtjxjsb0b&690 "Width=" 616 "height=" 393 "alt=" 003f41ccty6ujtjxjsb0b&690 "/>

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

Second handshake: The TCP SYN Packet arrives after the service machine, the SYN and ACK are all 1, the confirmation number ack=x+1, the service machine makes its starting sequence number seq=y, at this time called Synack message segment sends to the client;

Third handshake: After receiving the Synack message, send a third message to the server, the service machine allows the connection of the message segment to confirm, the message segment confirmation number ack=y+1, the starting sequence number seq=x+1, after the completion of the client and the server are in established state, Complete three handshake and start transmitting data.


Four breakup:

650) this.width=650; "Name=" image_operate_72841438517545141 "src=" http://s14.sinaimg.cn/mw690/ 003f41ccty6ujvlz4zxcd&690 "width=" 607 "height=" 439 "alt=" 003f41ccty6ujvlz4zxcd&690 "/>

The first breakup: The client sends a fin to turn off client A to Server B data transfer, after which the client enters the fin-wait-1 state, this state indicates that the socket wants to actively close the connection, send fin message to the other side;

Second breakup: The server received a FIN message, it returns a confirmation message segment (ack=1), the confirmation number seq for the received sequence number plus 1, the notification application process to close the connection, B can also send data, a can send confirmation but not send data, a received confirmation message, by Fin-wait-1 into Fin-wait-2;

Third breakup: The server closes the connection with the client, sends a fin to the client message, the server side waits for the client to make the final confirmation, is in the Last-ack State;

Fourth break: The client sends ACK message confirmation, the confirmation number seq for the received sequence number plus 1, after the completion of the time-wait state, and then wait 2MSL (possibly because the timeout server did not receive an ACK message, can not guarantee that the last ACK message sent will be received by the other party, So it can be used to re-send the possible missing ACK messages and return to the closed state.

Problem: When establishing a connection agreement is three handshake while closing the connection is four break: Because the server side listen state receives the connection request from the client, it can send the ACK and SYN (ACK acknowledgment function, SYN synchronization action) in a message, but when closed, The client sends a FIN close request, only indicates that the client does not have data to send, and the service side may not have no data to send, so the server will send the data to the other side, finally send fin message to agree to close the connection, so here the ACK message and fin messages are sent separately.


The difference between TCP and UDP:

TCP provides connection-oriented, reliable data connection transmission, when sending and receiving data, must establish a reliable connection with the other side, and UDP provides non-connection-oriented, unreliable traffic transmission, when it wants to convey It is easy to crawl data from the application and throw it to the network as soon as possible , because the transfer data does not establish a connection, there is no need to maintain the connection state, so a server can transmit the same message to multiple clients at the same time. Simply put, TCP focuses on data security, while UDP data transfer is fast, but security is common .

Third, the ARP protocol

the ARP (address Resolution Protocol) is a protocol for addressing resolution, which is a TCP/IP protocol that obtains physical addresses based on a network layer.

How ARP Works:

① First, each host establishes an ARP list in its own ARP cache (ARP cache) to represent the correspondence between the IP address and the MAC address;

② when the source host needs to send a packet to the destination host, it will first check its ARP list for the MAC address of the IP address, if any, use this MAC address, if not, the host first to determine whether the destination IP with itself in the same network segment (host IP and subnet mask) With "Operation"), if a network segment is launched, a broadcast packet of ARP requests is initiated to all hosts in the local network, and the host in the local network queries the MAC address of this destination host after receiving the ARP request; If the destination host is on a remote network, Then, through the router and other routing device forwarding this ARP request to the broadcast in the remote network, this ARP request packet includes the source host's IP address, MAC address, and the destination host IP address;

③ source host and destination host in a network situation, all hosts in the network receive this ARP request, will check the packet destination IP and its own IP is consistent, if the inconsistency is discarded, but the host will still check its own ARP cache; The host first adds the MAC address and IP address of the sending side to its ARP list, and then sends an ARP response packet to the source host, telling it to find the MAC address;

If the source and destination host is not in a network, the ARP request will be forwarded by the router to the other network, if the destination host can be found, the MAC address of this router as the destination host network address forwarded to the source host, the source host and the destination host after the exchange of information between the router, The router is called the ARP proxy, and if the destination host is not found, an incomplete table entry record is present in the ARP cache;

After the ④ source host receives the ARP response packet, it adds the IP address and MAC address of the destination host to its own ARP list, the native cache has a lifetime, and after the end of the lifetime, it repeats the above process again and then uses this information to transmit the data.


This article is from the "8397752" blog, please be sure to keep this source http://8407752.blog.51cto.com/8397752/1683877

TCP/IP Architecture and protocols

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.