Each application layer of the Protocol is to solve a certain class of application problems, and the problem is often solved by the different hosts between multiple application processes between the communication and collaboration work to complete. The specific content of the application layer is to specify the protocol that the application process follows when communicating.
DNS (Domain Name System)
When users communicate with the Internet, they are obviously reluctant to use a hard-to-remember 32-bit binary host, even if the dot-decimal IP address is not easy to remember, instead willing to use some kind of easy-to-remember host name.
In the early days, there were only hundreds of computers on the entire network, when a hosts file was used to list all the host names and corresponding IP addresses, and the user could simply enter a host name and the computer would be able to convert it to a recognized IP.
Why not use the domain name directly, because the domain name length is not fixed, the machine is difficult to handle.
Theoretically using a computer to load all the hostname and IP mappings, but this is not advisable, as the Internet scale, the computer will certainly be overloaded because of the inability to work, and there is a single point of failure.
Later, the Internet uses a hierarchical naming tree as the host name and uses the Distributed Domain Name System DNS.
DNS is an online distributed database system, in the form of a client server, because DNS uses most of the names are resolved locally, only a small number of needs to be resolved on the Internet, and therefore very efficient, and because DNS is a distributed system, there will be no single point of failure.
Domain-to-IP parsing is resolved by a number of domain name server programs running on the Internet, and the Domain name server program runs on dedicated nodes, so the machine that runs the domain name server program is called a domain name server.
- DNS Domain name structure:
Any host or router connected to the Internet has a unique hierarchical name, the domain name.
A domain refers to a manageable division in a namespace. Domains can be divided into sub-domains, subdomains can also be divided, which constitute the top-level domain, two-level domain, three-level domain and so on.
The domain name is made up of a sequence of labels consisting of an English letter, a number, and a hyphen (-), and each label is separated by a decimal point, each marking is not more than 63 characters, and is not a case-sensitive letter.
Like what
Mail.cctv.com CCTV computer for sending and receiving e-mails
(Level three domain name. Two-level domain name. TLD)
Top-level domains fall into three categories:
National top-level domain name (. us,.cn ... ), the international top-level domain name (. int), the generic top-level domain (. com,.org,.net ...).
The two-level domain name registered under the national top-level domain name is determined by the country itself.
The domain name namespace is as follows:
The leaf of a domain name is the name of a single computer.
The figure shows that CCTV and Tsinghua University each have a computer named mail, but they do not conflict, because its domain name is not the same, one is mail.cctv.com, one is mail.tsinghua.edu.cn. So the domain name must be unique in the Internet.
Domain Name server classification :
Each domain name server can not only resolve the domain name to the IP, but also to the other domain name server information, when they can not be domain-to-IP conversion, you know where to find other domain name server.
The domain name server is also divided by hierarchy, and now four different types of domain name servers:
local domain name server:
The local domain name server is also known as the default domain name server. When a host sends out a DNS query request, it is first sent to the local domain name server. Every ISP of an Internet service provider, or a university, or even a department in a university, can have a local domain name server.
ROOT name server:
is the highest level of the domain name server, but also the most important domain name server, all the root nameservers are aware of all the top-level domain name server domain name and IP address;
Regardless of which local domain name server, if any domain name on the Internet can not be resolved, the first to help the root name server
top-level domain name servers:
These domain name servers are responsible for managing all two-level domain names registered with the top-level domain name server, and when a DNS request is received, a corresponding answer is given.
rights domain Name server:
Each host must be registered at a privileged domain name server. Therefore, the domain name server knows what IP address the host name it governs should be converted to.
the reliability of the domain name server:
DNS nameservers replicate data to several domain name servers, one of which is the primary name server, and the other is the secondary domain name server. In this way, when the primary domain server fails, the secondary name server ensures that DNS queries are not interrupted.
The host queries to the local domain name server generally use recursive queries.
When an application process needs to resolve the host name to an IP address, the application process invokes the resolver and becomes a client of the DNS, placing the domain name to be resolved in the DNS request packet and sending it to the local domain name server in UDP User datagram (using UDP to reduce overhead). If the local domain name server does not know the IP address of the domain name being queried, the domain name server continues to send the query request message to the other root nameservers as a DNS client.
the local domain name server's query to the root domain server is typically an iterative query. is a circular query by the local domain name server.
When the root domain receives an iterative query request message from the local domain name server,
Tell the local name server to know the IP address of the top-level nameservers, and the local domain name server is making subsequent queries.
The difference between an iterative query and a recursive query:
The local domain name server uses an iterative query
Steps:
1、主机m.xyz.com先向本地域名服务器dns.xyz.com进行递归查询2、本地域名服务器采用迭代查询。先向一个根域名服务器查询3、根域名服务器告诉本地域名服务器,下一次应该查询的顶级域名服务器dns.com的IP地址4、本地域名服务器对顶级域名服务器dns.com进行查询5、顶级域名服务器dns.com告诉本地域名服务器,下一次应该查询的权限权限域名服务器dns.abc.com的IP地址 6、本地域名服务器向权限域名服务器进行查询7、权限域名服务器告诉本地域名服务器所查询的IP地址8、本地域名服务器将最后的查询结果返回给主机
Note: During the query process, it is possible for the top-level domain server to query directly to the IP and return it to the local domain name server.
Local domain name servers use recursive queries (less)
Similar to the above analysis method, the local domain name server only need to query the root name server once (the following is the query between several domain name servers), you can get IP
In order to improve the efficiency of DNS query, and reduce the root name server compliance and online DNS query messages.
Cache is widely used in the domain name server, which is used to store the most recently queried domain name and where to get the record of the domain name.
If the local domain name server has previously queried a similar domain name, you can query the IP directly from the cache
If the cache has only the IP of the top-level domain, then you can directly go to the top-level domain name query, thereby alleviating the burden of the root name server.
There will also be a need for caching in the host, and only the name server will be used if it is not found in the cache.
The World Wide Web is not a special kind of network, is a large-scale, online information storage, the World Wide Web is a distributed hypermedia system, is the extension of hypertext system, also known as the Web. can display www information called a Web browser
The World Wide Web uses a link method to easily link to another site from one site on the Internet.
Hypertext is the foundation of the World Wide Web , and so-called hypertext is text that contains links to other documents. In other words, a hypertext is linked by multiple sources of information, and the number of these sources is virtually unlimited.
This link allows the user to find another document, which can be linked to another document. These documents can be found in any hypertext system in the world that is connected to the Internet.
The World Wide Web works as a client server , and the browser is the World Wide Web client on the user's host, and the host on which the World Wide Web document resides runs the server program, so this host is also known as the World Wide Web server. The client program makes a request to the server program and the server program sends the client program back to the Web document that the customer wants. The World Wide Web document that is displayed in a client program main window is called a page.
The World Wide Web defines three concepts:url,http,html
URL Uniform Resource Locator is a concise representation of how resource locations and access methods can be obtained from the Internet
The URL is equivalent to a file name extension in the network scope, the URL general form is as follows:
<协议>:// <主机>:<端口>/<路径>
The previous protocol was to say what protocol was used to obtain the World Wide Web document.
Now the most common is HTTP, followed by FTP
http:// <主机>:<端口>/<路径>
://is the specified format; The default port number for HTTP is 80, which can often be omitted, and if the path is omitted, the URL points to a home page on the Internet
For example, to view Tsinghua University's information, you can first enter the Tsinghua University's homepage, its URL is
http://www.tsinghua.edu.cn
The default port number is omitted here 80
We can also point to a deeper level of page based on the path
Http://www.tsinghua.edu.cn/chn/yxsz/index.htm
This is the URL for the faculty settings page of Tsinghua University. This URL points to the path of the file, the last file name opened is index.htm, the suffix htm or HTML representation is written in Hypertext Markup Language HTML file
HTML:
Hypertext Markup Language is a standard language for making Web pages, eliminating the barriers of communication between different computers.
HTML (hypertext Markup Language) makes it easy for the designer of the World Wide Web page to link to any Web page on the Internet from somewhere on this page with a hyperlink, and to display the pages on their own computer screen. No details are described here.
Let's focus on the HTTP
The HTTP protocol defines how a browser (World Wide Web client process) can request a World Wide Web server for a Web document and how the server transmits the document to the browser. HTTP is an application-layer protocol that uses a TCP connection to ensure its reliable transmission.
The World Wide Web works as follows:
Events that occur after the user clicks the mouse:
1、浏览器分析超链指向页面的URL2、浏览器向DNS请求解析www.tsinghua.edu.cn的IP地址3、域名系统DNS解析出清华大学服务器的IP地址4、浏览器与服务器建立了TCP连接5、浏览器发出取文件命令:GET /chn/yxsz/index.htm6、服务器给出想赢,把文件index.htm发给浏览器7、TCP连接释放8、浏览器里显示index.htm中的所有文本。
http is stateless , that is, when the same customer accesses a page on the same server for the second time, the server responds the same as the first time it was accessed, because the server does not remember the client that was visited, which simplifies the design of the server. Makes it easier for the server to support a large number of concurrent HTTP requests.
HTTP itself is non-connected , which means that both parties do not need to establish an HTTP connection before exchanging HTTP messages. Although HTTP uses TCP as the Transport layer protocol, the data is guaranteed to be reliable. That is, HTTP does not consider how data is retransmitted after it is discarded in transit.
A rough estimate of the time it takes from the browser request to the receipt of the entire document:
It can be seen that the time required to request a World Wide Web document is the transfer time of the document plus twice times round trip time Rtt ( one is to establish a TCP connection and the other is to request and receive World Wide Web documents )
As you can see, every request for a document will have twice times the cost of RTT, when there are many linked objects on a page that need to be linked sequentially, each link causes twice times the overhead of the RTT
The http/1.1 protocol is a good solution to this http/1.0 disadvantage, using a continuous connection. The so-called persistent connection is that the World Wide Web server still maintains this connection for a period of time after sending a response so that the same client (browser) and server can continue to transmit subsequent HTTP request messages and response messages on this link.
There are two ways to work with HTTP persistent connections:
Non-assembly line and pipeline way.
Non-pipelined features
客户在收到前一个响应后才能发送下一个请求,因此比非持续链接的两倍RTT的开销节省了建立TCP连接所需的一个RTTI时间。但是服务器发送完一个对象后,其TCP连接就处于空闲状态,浪费了服务器资源。
Pipeline style Features
客户在收到HTTP的响应报文之前就能够接着发送新的请求报文。一个接一个的请求报文到达服务器后,服务器就可连续的发回响应报文。这样所有的对象只需花费一个RTT时间,使TCP连接中的空闲时间减少,提高了下载效率。
Proxy Server is also known as the World Wide Web cache, Proxy server bar recently some of the request and response messages exist on the local disk, when the new request arrives, the proxy server discovers that the request is the same as the staging, so it returns the staged response instead of accessing the resource on the Internet based on the URL's address.
:
Do not use a proxy server:
This makes all the PC in the campus network through this line, so the campus network PC access to the Internet traffic will often make this 2mb/s chain, resulting in a relatively large delay.
Using a proxy server:
The Red Representative request in the figure, dark green dashed line represents the answer.
1. When the browser requests the service from the Internet server, it first establishes a TCP connection with the proxy server of the campus network and sends the HTTP request message to it.
2. If there is a requested object in the proxy server, return this object to the browser in the HTTP response message
3, if the proxy server does not have the requested object, the proxy server on behalf of the requested user browser, and the Internet source point server to establish a TCP connection, and send HTTP request message
4. The source point server puts the requested object into the HTTP response message and returns it to the proxy server on the campus network.
5, the proxy server receives this object, the first copy it in its own local storage, and then put the object in the HTTP response message, through the established TCP connection, returned to the browser requesting the object.
When using a proxy server, because a large portion of traffic is confined to the internal campus network, so the 2mb/s line link traffic is greatly reduced, thus reducing the latency of access to the Internet.
HTTP message structure:
HTTP messages are divided into two categories, request messages and response messages
Request message:
The URL represents the URL of the requested resource, and the version represents the version number of the HTTP
Method refers to the operation of the requested object, it can be said that some of the commands, is the HTTP request message some methods
Response message:
The status codes are three-digit numbers:
1XX 表示通知信息,如请求收到了或正在进行处理2XX表示成功,如接受或知道了3XX表示重定向,表示要完成请求还必须采取进一步的行动4XX表示客户的差错,如请求中有错误的语法或不能完成5XX表示服务器的差错,如服务器失效无法完成请求
From
Computer Networks-fifth edition. Shehiren
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Computer network Reading Notes-----Application layer