1. TCP/IP is a protocol suite that can be divided into three layers: network layer, transport layer, and application layer.
At the network layer, there are IP, ICMP, ARP, RARP, and BOOTP protocols.
There are TCP and UDP protocols at the transport layer.
Protocols at the application layer include FTP, HTTP, TELNET, SMTP, and DNS.
Therefore, HTTP is itself a protocol, a transport protocol for transferring hypertext from a Web server to a local browser.
2. The HTTP protocol is based on the request/response model. The client establishes a TCP connection to the server and sends a request to the server containing the request method, URI, protocol version, and associated MIME style message. The server responds with a status line containing the protocol version of the message, a success and failure code, and the associated MIME style of the message.
HTTP/1.0 establishes a new TCP link for each HTTP request/response, so a page containing HTML content and images will need to establish multiple short-term TCP links. A TCP connection will require three handshakes.
In addition, additional loop connection time (RTT) is required for TCP to obtain the appropriate transmission speed. This overhead is required for each link to be created, with no actual useful data, just to ensure the reliability of the link, so HTTP/1.1 proposed the implementation of sustainable links. HTTP/1.1 will establish only one TCP link and use it repeatedly to transmit a series of request/response messages, thus reducing the number of link establishment and recurrent link overhead.
Conclusion: Although HTTP is a protocol in itself, it is ultimately based on TCP.
TCP Three-way and four-way handshake
In contrast to SOCKET developers, the TCP creation process and connection removal process are automatically created by the TCP/IP protocol stack. So developers don’t have to control the process. But it’s helpful to understand the underlying workings of TCP.
Three-way Handshake A TCP connection is established with Three packets sent by the client and server. The specific process is available online, and I will not repeat it again. The purpose of the three-way handshake is to connect to the specified port of the server, establish a TCP connection, synchronize the serial number and confirmation number of the connection parties, and exchange TCP window size information. In socket programming, when the client executes connect(). Three handshakes will trigger.
Removing a TCP connection requires four packets. This is called a four-way handshake. The client or server can initiate the wave action
Differences between TCP and UDP
Attached is a picture, simple and clear 👇
What is a Socket?
Socket is the intermediate software abstraction layer of communication between application layer and TCP/IP protocol family. It is a group of interfaces. In the design mode, Socket is actually a facade mode, it hides the complex TCP/IP protocol family behind the Socket interface, for the user, a simple set of interfaces is all, let the Socket to organize data to conform to the specified protocol.
In contrast to SOCKET developers, the TCP creation process and connection removal process are automatically created by the TCP/IP protocol stack. So developers don’t have to control the process. But it’s helpful to understand the underlying workings of TCP.