HTTP(TCP)

HTTP is a stateless protocol, in which a server sends a requested file to a client without storing any status information about the client.

HTTP is connection-oriented, divided into non-continuous connections, where each object request uses a separate connection, and continuous connections, where all object requests share the same connection. Persistent connection is supported after HTTP1.1 and is also the default connection mode.

For persistent connections, there is a configurable timeout interval after which the server closes the connection if it is not used.

Web cache: also known as proxy server. For example, Chinese ISPs can set up a proxy server to reduce network latency if the network latency of a Chinese site visiting the United States may be large.

Conditional get: When a client requests the object again, if the time interval between last-Modified and last-modified exceeds a specified value, the proxy server sends an if-Modified-since message: Last-modified Request on the header line, if the object has Not changed, the server returns the proxy server 304 Not Modified.

Content Distribution Network (CDN) : CDN companies set up a number of geographically dispersed caches on the Internet, allowing a large amount of traffic to be localized.

SMTP(TCP)

Components of E-mail system: user agent, mail server, simple Mail Transfer Protocol (SMTP).

Each user agent corresponds to A mail server. The mail server has A packet queue and several mailboxes. Mail is sent from the packet queue of user agent A to mail server A and from the mailbox of user agent B on mail server B.

SMTP generally does not use an intermediate server, even if mail server A is in China and mail server B is in the United States. If mail server B is not powered on, mail server A keeps the mail and tries to send the mail again after 30 minutes. If the mail fails after several days, mail server A deletes the mail and notifies user agent A by email.

Whereas HTTP is a pull protocol, SMTP is a push protocol. SMTP requires each packet to be encoded in 7-bit ASCII format. If a packet contains non-7-bit ASCII characters or binary data, the packet must be encoded in 7-bit ASCII format. HTTP does not have this restriction. HTTP encapsulates each object into its own HTTP response message. SMTP encapsulates all message objects into one message.

User agent A cannot directly push mail to mail server B. Through mail server A, the user agent can repeatedly try to send packets to unreachable mail server B until mail server B runs.

User agent A uses SMTP to communicate with user server A, and user server A uses SMTP to communicate with user server B. However, user agent B cannot use SMTP to obtain mails from user server B, because SMTP is A push protocol. There are several popular mail access protocols to solve this problem, including version 3 post Office Protocol (POP3), Internet Mail Access Protocol (IMAP), and HTTP.

Web-based E-mail: HTTP is used between the user agent and the mail server, and SMTP is used between the mail server.

DNS(UDP)

Domain Name System (DNS) :① A distributed database implemented by hierarchical DNS server; ② An application layer protocol that enables hosts to query distributed databases.

A DNS server is typically a UNIX machine running the BIND software. The DNS protocol runs over UDP, using port 53.

In addition to translating host names into IP addresses, the DNS server provides other services. ② Mail server alias; ③ Load distribution.

DNS workflow: hosts an application calls the DNS client, host name, need to be converted in the DNS client receives, sends a DNS query message to the network, after several millisecond delay, the DNS client receives the DNS response message, mapping and the result was passed to call the DNS client application.

DNS uses a distributed hierarchical database. No DNS server has mappings for all hosts on the Internet. Instead, these mappings are distributed across all DNS servers. There are three DNS server types: root DNS server, top-level DOMAIN (TLD)DNS server, and authoritative DNS server.

Suppose a DNS client wants to determine the IP address of www.amazon.com by first contacting one of the root servers, returning the TLD server address of the top-level domain com, and then contacting one of these TLD servers, returning the amazon.com authoritative server address, The customer finally contacts one of Amazon.com’s authoritative servers and returns the IP address of www.amazon.com.

Each ISP has a local DNS server, and when a host makes a DNS request, the request is sent to the local DNS server, which acts as a proxy and forwards the request to the DNS server hierarchy. The local DNS server can be used as DNS cache in addition to forwarding.