1. The application layer

http\ftp\smtp\dns\ssh\dhcp\telnet

 First, the concept of the application layer

  The transport layer provides end to end communication services for the application process. But the process between different network applications also require different communication rules. Thus, over the transport layer protocol also requires the application layer.

  The application layer is the task to complete the application process by interaction between specific network applications . The application layer protocol is defined by the rules of communication and interaction between the application process for different network needs to use a different application layer protocols. Such as Domain Name System DNS, HTTP protocol support Web applications, e-mail support SMTP protocol, and so on.

  Interactive application layer data unit called packets .

 


 

Second, the network application model

  Divided into two categories:

  ① Client Server (C / S) model: a server corresponding to a plurality of clients.

  ②P2P Model: correspond to each other among a plurality of users.

 


 

Third, the Domain Name System -DNS

  1.DNS is used to facilitate people using the machine name is converted into an IP address .

  2. domain name to IP address resolution process: when a certain application process needs to resolve host names to IP addresses, the application process will invoke the parser , and become a client of the DNS; to be resolved domain name on the DNS request text to UDP user datagram way distributed to local domain name server (using UDP is to reduce overhead); after finding the local domain name server domain name, the corresponding IP address in the reply message returned. To communicate the application process to obtain the IP address of the destination host;

  3. Domain Name Process

    ① recursive queries (by others less): If the host inquired about the local domain name server does not know the IP address being queried, the local name server to the DNS client identity issued to other domain name server query request message;

    ② iterative queries (on their own): When the root name server receives iterative queries sent by the local domain name server, or given IP address or domain name server next step should be to inform the local query to which a domain name server;

 


 

Fourth, the File Transfer Protocol -FTP

  1. · FTP for file transfer capability between different hosts; Protocol based on C / S, the user connects to the server program running on a remote computer by a client program.

   . 1.1 FTP client: FTP server connection, follow the computer server and FTP protocol for transferring files;

   1.2.FTP server: computer file transfer service in accordance with the FTP protocol; an FTP server can simultaneously serve multiple client processes. FTP server process consists of two parts: a main process, responsible for receiving a new request; another plurality of slave processes responsible for processing a single request;

     Working steps of the main process as follows: ① Open well-known port (port number 21), is capable of connecting the client;

                   ② wait for the client process makes a connection request;

                 ③ start slave process to handle client process requests sent. Slave process client requests processed after termination, but the process may also create some books other sub-processes during operation as required;

                 ④ back to the wait state, will continue to accept other requests sent by the client process. Concurrent processing executed when the master process and slave processes;

    

 

 

    TCP control connection will remain, TCP data connection to keep for a while.

 

    FTP operational use tcp 21 and two ports 20 in the active mode, a random port 1024 operates in the passive mode will be greater than the work.

 

  1.3 FTP port mode (active mode)

 

  客户端从一个任意的非特权端口N(N>1024)连接到FTP服务器的命令端口(即tcp 21端口)。紧接着客户端开始监听端口N+1,并发送FTP命令“port N+1”到FTP服务器。最后服务器会从它自己的数据端口(20)连接到客户端指定的数据端口(N+1),这样客户端就可以和ftp服务器建立数据传输通道了。

 

  1.4 FTP pasv模式(被动模式)

 

  在被动方式FTP中,命令连接和数据连接都由客户端。当开启一个FTP连接时,客户端打开两个任意的非特权本地端口(N > 1024和N+1)。第一个端口连接服务器的21端口,但与主动方式的FTP不同,客户端不会提交PORT命令并允许服务器来回连它的数据端口,而是提交 PASV命令。这样做的结果是服务器会开启一个任意的非特权端口(P > 1024),并发送PORT P命令给客户端。然后客户端发起从本地端口N+1到服务器的端口P的连接用来传送数据。

 

  1.5 简单文件传送协议-TFTP

  TFTP是一个很小且易于实现的文件传送协议,使用UDP数据报,因此TFTP需要有自己的差错改正措施。

 


 

五、远程终端协议-TELNET

  TELNET是一个简单的远程终端协议。用户使用TELNET就可以在其所在地通过TCP连接注册(登录)到远程的另一台主机上。通过网络虚拟终端NVT解决许多计算机和操作系统的差异问题。

 


 

六、超文本传送协议-HTTP

  1.首先介绍一下万维网:万维网是一个大规模的、联机式的信息储藏所,是无数个网站站点和网页的集合。万维网以C/S方式工作,用户通过点击统一资源定位符URL获取资源,这些资源通过超文本传输协议HTTP传输给使用者。万维网使用超文本标记语言HTML使得万维网设计者跳转页面并显示。

  URL格式:<协议>://<主机/域名/IP>:<端口号>/<路径>      (使用HTTP协议默认端口号为80)

 

  2. HTTP

  HTTP协议定义了浏览器怎么向万维网服务器请求万维网资源以及服务器如何把文档送给浏览器

  每一个万维网服务器都有一个服务器进程,不断的监听TCP的端口80,以便发现是否有浏览器向他发出连接建立请求。一旦监听到请求并建立TCP连接之后(TCP建立连接的三次握手中第三个报文段稍带了客户对万维网文档的请求),浏览器就向万维网服务器发出浏览某个页面的请求,服务器接着就返回所请求的页面作为响应。最后TCP连接就被释放了。在浏览器和服务器之间的请求和相应的交互必须按照规定的格式和遵循一定的规则,这些格式和规则就是超文本传送协议HTTP。

  (非持久连接)

 

 

  ①HTTP协议是无状态的,也就是说,同一个客户第二次访问同一个服务器上的页面时,服务器的响应和第一次被访问时的相同。但在实际工作中,一些万维网希望识别用户,此时可以使用Cookie,Cookie是存储在用户主机上的文本文件,记录一段时间内用户的访问记录。

 

   ②HTTP/1.0主要缺点:非持久连接,每次请求一个文档就需要花费两倍RTT时间。

  ③HTTP/1.1使用了持久连接,使同一个用户和该服务器可以继续在这条连接上传送后续的请求报文和响应报文。

  ④HTTP是无连接的,采用TCP作为运输层协议。通信双方交换HTTP报文不惜要建立连接。

 

    

  3.HTTP报文(详细内容参考HTTP笔记)

  HTTP请求报文:请求行(方法+URL+版本)、首部行(首部字段名+值)、实体主体

  HTTP响应报文:状态行(版本+状态码+短语)、首部行(首部字段名+值)、实体主体

  请求方法:GET、HEAD、POST、PUT、DELETE…… 

状态码 意义
1xx 表示通知消息的,如请求收到了或正在进行处理
2xx 表示成功,如接受或知道了
3xx 表示重定向,如要完成请求还必须采取进一步的行动 
4xx 表示客户的差错,如请求中有错误的语法或者不能完成
5xx 表示服务器的差错,如服务器失效无法完成请求

 


 

七、简单邮件传送协议-SMTP

 

 

 

   SMTP规定了两个相互通信的SMTP进程之间应如何交换信息。发件人的邮件发送到发送邮件服务器的邮件缓存后SMTP客户每隔一段时间对邮件缓存扫描一次。如果发现有邮件,就是用SMTP的熟知端口(25)与接收方邮件服务器的SMTP服务器建立TCP链接。在建立就连接之后,接收方SMTP服务器发送“220 Service ready”。然后SMTP客户向SMTP服务器发送HELO命令,附上发送方的主机名。SMTP如果有能力接收邮件,则回答“250 OK”,表示已准备好接受。若SMTP不可用,则回答“421 Service not available”。

  SMTP使用C/S模式。建立在TCP连接之上。


 

八、邮件读取协议-POP3、IMAP

  邮局协议POP是一个非常简单的、但功能有限的邮件读取协议。使用C/S方式,熟知端口号为11-,采用TCP连接。POP协议的一个特点就是只要用户从POP服务器读取了邮件,POP服务器就把该邮件删除。

  网际报文存取协议IMAP,IMAP最大的好处就是用户可以在不同地方使用不同的计算机随时上网阅读和处理自己的邮件。IMAP还允许收件人只读取邮件中某一部分。缺点是如果用户没有将邮件复制到自己的PC上,则邮件会一直存放在IMAP服务器上,因此用户需要经常和IMAP服务器建立连接。

 


 

九、动态主机配置协议-DHCP

   为了把协议软件做成通用且便于移植的,协议软件的编写者将协议软件参数化。通过一些不同的计算机参数来实现通用性。在协议软件中给这些参数赋值的动作称为协议配置。用人工进行协议配置麻烦,因此采用动态主机配置协议DPCP,它提供了一种机制,即即插即用连网。这种机制允许一台计算机自动加入新的网络和获取IP地址。

 


 

十、安全外壳协议-SSH

   SSH 为建立在应用层基础上的安全协议。SSH 是较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用 SSH 协议可以有效防止远程管理过程中的信息泄露问题。SSH有很多功能,它既可以代替Telnet,又可以为FTPPoP、甚至为PPP提供一个安全的"通道"。

   从客户端来看,SSH提供两种级别的安全验证。

  第一种级别(基于口令的安全验证)
  只要你知道自己帐号和口令,就可以登录到远程主机。所有传输的数据都会被加密,但是不能保证你正在连接的服务器就是你想连接的服务器。可能会有别的服务器在冒充真正的服务器,也就是受到“中间人”这种方式的攻击。
  第二种级别(基于密匙的安全验证)
  需要依靠密匙,也就是你必须为自己创建一对密匙,并把公用密匙放在需要访问的服务器上。如果你要连接到SSH服务器上,客户端软件就会向服务器发出请求,请求用你的密匙进行安全验证。服务器收到请求之后,先在该服务器上你的主目录下寻找你的公用密匙,然后把它和你发送过来的公用密匙进行比较。如果两个密匙一致,服务器就用公用密匙加密“质询”(challenge)并把它发送给客户端软件。客户端软件收到“质询”之后就可以用你的私人密匙解密再把它发送给服务器。
  用这种方式,你必须知道自己密匙的口令。但是,与第一种级别相比,第二种级别不需要在网络上传送口令。第二种级别不仅加密所有传送的数据,而且“中间人”这种攻击方式也是不可能的(因为他没有你的私人密匙)。但是整个登录的过程可能需要10秒 。

   SSH 主要由三部分组成:传输层协议、用户认证协议、连接协议。

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/qmillet/p/12006766.html