作者:微信小助手
发布时间:2022-09-13T11:53:28
1.TCP和UDP的区别 TCP是面向连接的,UDP是面向无连接的; TCP只能一对一通信,UDP支持一对一,一对多,多对一和多对多交互通信; TCP是面向字节流的,UDP是面向报文的; TCP是可靠传输,使用流量控制和拥塞控制;UDP是不可靠传输 TCP首部最小20字节,最大60字节;UDP首部仅8字节。 2.ISO七层模型及相关协议 物理层:建立、维护、断开物理连接。 数据链路层:在物理层提供比特流服务的基础上,建立相邻结点之间的数据链路。 网络层:进行逻辑地址寻址,实现不同网络之间的路径选择,协议有ICMP、IGMP、IP等。 传输层:定义传输数据的协议端口号,以及流量控制和差错校验,协议有TCP、UDP。 会话层:建立、管理、终止会话,指本地主机与远程主机正在进行的会话。 表示层:确保一个系统的应用层所发送的信息可以被另一个系统的应用层读取。 应用层:网络服务与最终用户的一个接口,常见的协议有:HTTP、FTP、SMTP、DNS。 TCP/IP 四层模型
</ul>
<pre class="code-snippet__js"><code><span class="code-snippet_outer">网络接口层</span></code><code><span class="code-snippet_outer">网际层</span></code><code><span class="code-snippet_outer">传输层</span></code><code><span class="code-snippet_outer">应用层</span></code></pre>
</section>
</section>
<p><strong>五层体系结构</strong></p>
<section class="code-snippet__fix code-snippet__js">
<ul class="code-snippet__line-index code-snippet__js">
</ul>
<pre class="code-snippet__js"><code><span class="code-snippet_outer">物理层</span></code><code><span class="code-snippet_outer">数据链路层</span></code><code><span class="code-snippet_outer">网络层:IP网际协议、ARP地址转换协议、RIP路由信息协议</span></code><code><span class="code-snippet_outer">传输层:TCP传输控制协议、UDP用户数据报文协议</span></code><code><span class="code-snippet_outer">应用层:HTTP超文本传输协议、FTP文本传输协议、DNS域名系统</span></code></pre>
</section>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">3.如何理解HTTP协议是无状态的</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<p>当浏览器第一次发送请求给服务器时,服务器响应了;</p>
<p><br></p>
<p>如果同个浏览器发起第二次请求给服务器时,它还是会响应。但是呢,服务器不知道你就是刚才的那个浏览器。</p>
<p><br></p>
<p>简而言之,服务器不会去记住你是谁,所以是无状态协议。</p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">4.简述从浏览器地址栏输入url到显示主页的过程</span></strong></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li>
<section>
<p>DNS解析,查找域名对应的IP地址。</p>
</section></li>
<li>
<section>
<p>与服务器通过三次握手,建立TCP连接</p>
</section></li>
<li>
<section>
<p>向服务器发送HTTP请求。</p>
</section></li>
<li>
<section>
<p>服务器处理请求,返回网页内容。</p>
</section></li>
<li>
<section>
<p>浏览器解析并渲染页面。</p>
</section></li>
<li>
<section>
<p>TCP四次握手,连接结束。</p>
</section></li>
</ul>
<p><img class="rich_pages wxw-img" data-ratio="0.39537037037037037" src="/upload/e77b63bd0e8068234b936fff3ea233a2.png" data-type="png" data-w="1080"></p>
<p><br></p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">5.说下 HTTP/1.0,1.1,2.0 的区别</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<p>HTTP/1.0</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="67" data-source-title="">
<section class="js_blockquote_digest">
<section>
默认使用短连接,每次请求都需要建立一个TCP连接。它可以设置Connection: keep-alive 这个字段,强制开启长连接。
</section>
</section>
</blockquote>
<p><br></p>
<p>HTTP/1.1</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="102" data-source-title="">
<section class="js_blockquote_digest">
<section>
<p>默认使用长连接,即TCP连接默认不关闭,可以被多个请求复用。</p>
<p>分块传输编码,即服务端每产生一块数据,就发送一块,用“流模式”取代“缓存模式”。</p>
<p>管道机制,即在同一个TCP连接里面,客户端可以同时发送多个请求。</p>
</section>
</section>
</blockquote>
<p><br></p>
<p>HTTP/2.0</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="207" data-source-title="">
<section class="js_blockquote_digest">
<section>
<p>二进制协议,1.1版本的头信息是文本(ASCII编码),数据体可以是文本或二进制;2.0中,头信息和数据体都是二进制。</p>
<p><br></p>
<p>完全多路复用,在一个连接里,客户端和服务器都可以同时发送多个请求或响应,而且不用按照顺序一一对应。</p>
<p><br></p>
<p>报头压缩,HTTP协议不带有状态,每次请求都必须带上所有信息。HTTP/2.0引入了头信息压缩机制,使用gzip或compress压缩后再发送。</p>
<p><br></p>
<p>服务端推送,允许服务器未经请求,主动向客户端发送资源。</p>
</section>
</section>
</blockquote>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">6.POST和GET有哪些区别</span></strong></p>
<p><img class="rich_pages wxw-img" data-ratio="0.287962962962963" src="/upload/f040e8db9efff4ed5ff7d531d89e089.png" data-type="png" data-w="1080"></p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">7.HTTP 如何实现长连接?在什么时候会超时?</span></strong></p>
<p>什么是HTTP的长连接?</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="162" data-source-title="">
<section class="js_blockquote_digest">
<section>
<p>HTTP分为长连接和短连接,本质上说的是TCP的长短连接。TCP连接是一个双向的通道,它是可以保持一段时间不关闭的,因此TCP连接才具有真正的长连接和短连接这一说法。</p>
<p>TCP长连接可以复用一个TCP连接,来发起多次HTTP请求,这样就可以减少资源消耗,比如一次HTML请求,如果是短连接的话,可能还需要请求后续的JS/CSS。</p>
</section>
</section>
</blockquote>
<p><br></p>
<p>如何设置长连接?</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="81" data-source-title="">
<section class="js_blockquote_digest">
<section>
通过在请求头和响应头设置Connection字段指定为keep-alive,HTTP/1.0协议支持,但默认是关闭的,从HTTP/1.1以后,连接默认都是长连接。
</section>
</section>
</blockquote>
<p><br></p>
<p>在什么时候会超时?</p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="242" data-source-title="">
<section class="js_blockquote_digest">
<section>
<p>HTTP一般会有httpd守护进程,里面可以设置keep-alive timeout,当tcp连接闲置超过这个时间就会关闭,也可以在HTTP的header里面设置超时时间。</p>
<p>TCP 的keep-alive包含三个参数,支持在系统内核的net.ipv4里面设置;当 TCP 连接之后,闲置了tcp_keepalive_time,则会发生侦测包,如果没有收到对方的ACK,那么会每隔 tcp_keepalive_intvl 再发一次,直到发送了tcp_keepalive_probes,就会丢弃该连接。</p>
</section>
</section>
</blockquote>
<section class="code-snippet__fix code-snippet__js">
<ul class="code-snippet__line-index code-snippet__js">
</ul>
<pre class="code-snippet__js" data-lang="ini"><code><span class="code-snippet_outer"><span class="code-snippet__attr">tcp_keepalive_intvl</span> = <span class="code-snippet__number">15</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">tcp_keepalive_probes</span> = <span class="code-snippet__number">5</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">tcp_keepalive_time</span> = <span class="code-snippet__number">1800</span></span></code></pre>
</section>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">8.HTTP 与 HTTPS 的区别</span></strong></p>
<p>HTTP 即超文本传输协议,是一个基于TCP/IP通信协议来传递明文数据的协议。HTTP会存在这几个问题:</p>
<p><br></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li><p>请求信息是明文传输,容易被窃听截取。</p></li>
<li><p>没有验证对方身份,存在被冒充的风险。</p></li>
<li><p>数据的完整性未校验,容易被中间人篡改。</p><p><br></p></li>
</ul>
<p>为了解决HTTP存在的问题,HTTPS出现啦。</p>
<p>HTTPS是什么?</p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="66" data-source-title="">
<section class="js_blockquote_digest">
<section>
HTTPS= HTTP+SSL/TLS,可以理解为 HTTPS 是身披 SSL(Secure Socket Layer,安全套接层)的HTTP。
</section>
</section>
</blockquote>
<p>它们的主要区别如下:</p>
<p><img class="rich_pages wxw-img" data-ratio="0.2462962962962963" src="/upload/20d87af5d2aa9c419fe09580b2c7c7fc.png" data-type="png" data-w="1080"></p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">9.HTTPS的工作流程是怎样的?</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<p>HTTPS = HTTP + SSL/TLS,也就是用SSL/TLS对数据进行加密和解密,用HTTP进行传输。</p>
<p><br></p>
<p>SSL,即Secure Sockets Layer(安全套接层协议),是网络通信提供安全及数据完整性的一种安全协议。</p>
<p><br></p>
<p>TLS,即Transport Layer Security(安全传输层协议),它是SSL3.0的后续版本。</p>
<p><img class="rich_pages wxw-img" data-ratio="0.8351851851851851" src="/upload/a308c25e08b3714d29944fb61b8d4350.png" data-type="png" data-w="1080"></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li>
<section>
客户端发起HTTPS请求,连接到服务器的443端口。
</section></li>
<li>
<section>
服务器必须要有一套数字证书(证书内容有公钥、证书颁发机构、失效日期等)。
</section></li>
<li>
<section>
服务器将自己的数字证书发送给客户端(公钥在证书里面,私钥由服务器持有)。
</section></li>
<li>
<section>
客户端收到数字证书之后,会验证证书的合法性。如果证书验证通过,就会生成一个随机的对称密钥,用证书的公钥加密。
</section></li>
<li>
<section>
客户端将公钥加密后的密钥发送到服务器。
</section></li>
<li>
<section>
服务器接收到客户端发来的密文密钥之后,用自己之前保留的私钥对其进行非对称解密,解密之后就得到客户端的密钥,然后用客户端密钥对返回数据进行对称加密,这样子传输的数据都是密文啦。
</section></li>
<li>
<section>
服务器将加密后的密文返回到客户端。
</section></li>
<li>
<section>
客户端收到后,用自己的密钥对其进行对称解密,就能得到服务器返回的数据。
</section></li>
</ul>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">10.说说HTTP的状态码,301和302的区别?</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li><p>301:永久重定向,表示所请求的资源已经永久地转移到新的位置,这包含域名的改变或者是资源路径的改变。</p><p><br></p></li>
<li><p>302:临时重定向,表示所请求的资源临时地转移到新的位置,一般是24到48小时以内的转移会用到302。</p></li>
</ul>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">11.说说什么是数字签名?什么是数字证书?</span></strong></p>
<p><img class="rich_pages wxw-img" data-ratio="0.832807570977918" src="/upload/cbc1d16b708ebdaf211b67cd545b5559.png" data-type="png" data-w="951"></p>
<p>数字证书构成:</p>
<p><br></p>
<p>公钥和个人等信息,经过Hash算法加密,形成消息摘要;将消息摘要拿到拥有公信力的认证中心(CA),用它的私钥对消息摘要加密,形成数字签名。</p>
<p>公钥和个人信息、数字签名共同构成数字证书。</p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">12.对称加密和非对称加密有什么区别</span></strong></p>
<p>对称加密:指加密和解密使用同一密钥,优点是运算速度较快,缺点是不能安全地将密钥传输给另一方。常见的对称加密算法有:DES、AES等。</p>
<p><img class="rich_pages wxw-img" data-ratio="0.26851851851851855" src="/upload/429719cb6256ef04099acf7694474aba.png" data-type="png" data-w="1080"></p>
<p><br></p>
<p>非对称加密:指的是加密和解密使用不同的密钥(即公钥和私钥)。公钥与私钥是成对存在的,如果用公钥对数据进行加密,只有对应的私钥才能解密。常见的非对称加密算法有 RSA。</p>
<p><img class="rich_pages wxw-img" data-ratio="0.32222222222222224" src="/upload/61c4f0530c79018b49e7964cd35a5ef2.png" data-type="png" data-w="1080"></p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">13.说说 DNS 的解析过程?</span></strong></p>
<p>DNS的解析过程如下图:</p>
<p><img class="rich_pages wxw-img" data-ratio="1.3471502590673574" src="/upload/79e61740bfa226bba70bd84944f0d444.png" data-type="png" data-w="772"></p>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="72" data-source-title="">
<section class="js_blockquote_digest">
<section>
假设你要查询www.baidu.com的IP地址:浏览器 -> 本地DNS服务器 -> 根域名服务器 -> 顶级域名服务器 -> 权威域名服务器
</section>
</section>
</blockquote>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li><p>首先会查找浏览器的缓存,看看是否能找到www.baidu.com对应的IP地址,找到就直接返回;否则进行下一步。</p></li>
<li><p>将请求发往本地DNS服务器,如果查找到也直接返回,否则继续进行下一步;</p></li>
<li><p>本地DNS服务器向根域名服务器发送请求,根域名服务器返回负责.com的顶级域名服务器的列表。</p></li>
<li><p>本地DNS服务器再向其中一个顶级域名服务器发送一个请求,返回负责.baidu的权威域名服务器的列表。</p></li>
<li><p>本地DNS服务器再向其中一个权威域名服务器发送一个请求,返回www.baidu.com所对应的IP地址。</p></li>
</ul>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">14.说说 WebSocket与socket的区别</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<p>Socket是一套标准,它完成了对TCP/IP的高度封装,屏蔽网络细节,以便开发者更好地进行网络编程。</p>
<p><br></p>
<p>Socket等于IP地址 + 端口 + 协议。</p>
<p><br></p>
<p>WebSocket是一个持久化的协议,它是伴随H5而出的协议,用来解决HTTP不支持持久化连接的问题。</p>
<p><br></p>
<p>Socket是一个网络编程的标准接口,而WebSocket则是应用层通信协议。</p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">15.HTTP请求的过程与原理</span></strong></p>
<p>HTTP是一个基于TCP/IP协议来传递数据的超文本传输协议,传输的数据类型有HTML、图片等。</p>
<p><img class="rich_pages wxw-img" data-ratio="0.4759259259259259" src="/upload/a696ca58bc52d570f13234e77ae7ac6d.png" data-type="png" data-w="1080"></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li>
<section>
<p>客户端进行DNS域名解析,得到对应的IP地址</p>
</section></li>
<li>
<section>
<p>根据这个IP地址,找到对应的服务器建立TCP连接(三次握手)</p>
</section></li>
<li>
<section>
<p>建立TCP连接后发起HTTP请求(一个完整的http请求报文)</p>
</section></li>
<li>
<section>
<p>服务器响应HTTP请求,客户端得到html代码</p>
</section></li>
<li>
<section>
<p>客户端解析html代码,用html代码中的资源(如 js、css、图片等等)渲染页面。</p>
</section></li>
<li>
<section>
<p>服务器关闭TCP连接(四次挥手)</p>
</section></li>
</ul>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">16.forward和redirect的区别?</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<p>是servlet中的两种主要跳转方式。forward:转发,redirect:重定向</p>
<p><br></p>
<p>从地址栏显示来说</p>
<p>forward是服务器内部的重定向,服务器直接访问目标地址,把里面的东西取出来,但是客户端并不知道,因此用forward的话,客户端浏览器的网址是不会发生变化的。</p>
<p><br></p>
<p>redirect是服务器根据逻辑,发送一个状态码,告诉浏览器重新去请求那个地址,所以地址栏显示的是新地址。</p>
<p><br></p>
<p>从数据共享来说</p>
<p>由于在整个转发的过程中使用的是同一个request,因此forward会将request信息带到被重定向的jsp或servlet中使用,即可以共享数据。</p>
<p><br></p>
<p>redirect不能共享数据。</p>
<p><br></p>
<p>从运用的地方来说</p>
<p>forward一般用于用户登录时,根据角色转发到相应的模块</p>
<p><br></p>
<p>redirect一般用于用户注销登录时返回主页面</p>
<p><br></p>
<p>从本质上来说</p>
<p>forward转发是服务器上的行为,redirect重定向是客户端的行为。</p>
<p><br></p>
<p>从效率上来说</p>
<p>forword效率高,而redirect效率低。</p>
<p><br></p>
<p>从请求的次数来说</p>
<p>forword只有一次请求,而redirect有两次请求。</p>
<p><br></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;">17.Session和Cookie的区别</span></strong></p>
<p style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(34, 34, 34);font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background-color: rgb(255, 255, 255);font-size: 15px;letter-spacing: 2px;clear: both;min-height: 1em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong><span style="font-size: 18px;"><br></span></strong></p>
<ul class="list-paddingleft-1" style="list-style-type: disc;">
<li><p>Cookie 是保存在客户端的一小块文本串的数据。客户端向服务器发起请求时,服务器会向客户端发送一个 Cookie,客户端就把 Cookie 保存起来。下次向同一服务器再发起请求时,Cookie 就被携带发送到服务器。服务器可以根据这个 Cookie 判断用户的身份和状态。</p><p><br></p></li>
<li><p>Session 指的是服务器和客户端一次会话的过程。它是另一种记录客户端状态的机制。不同的是 Cookie 是保存在客户端浏览器中的,而 Session 是保存在服务器上的。客户端浏览器在访问服务器时,服务器会把客户端信息以某种形式记录在服务器上,这就是 Session。客户端浏览器再次访问时只需要从该 Session 中查找用户的状态。</p></li>
</ul>
<p><br></p>
<blockquote class="js_blockquote_wrap" data-type="2" data-url="" data-author-name="" data-content-utf8-length="23" data-source-title="">
<section class="j