1 Star 0 Fork 2

程闯/觅友突击课程

forked from 大灰/觅友突击课程 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1.计算机网络.html 406.75 KB
一键复制 编辑 原始数据 按行查看 历史
大灰 提交于 2021-04-30 16:30 +08:00 . 'dfs'
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
<!doctype html>
<html style='font-size:17px !important'>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>1.计算机网络</title><link href='https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext' rel='stylesheet' type='text/css' /><style type='text/css'>html {overflow-x: initial !important;}:root { --bg-color:#ffffff; --text-color:#333333; --select-text-bg-color:#B5D6FC; --select-text-font-color:auto; --monospace:"Lucida Console",Consolas,"Courier",monospace; --title-bar-height:20px; }
.mac-os-11 { --title-bar-height:28px; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; tab-size: 4; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; overflow-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 36px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
.typora-export .task-list-item input { pointer-events: none; }
@media screen and (max-width: 500px) {
body.typora-export { padding-left: 0px; padding-right: 0px; }
#write { padding-left: 20px; padding-right: 20px; }
.CodeMirror-sizer { margin-left: 0px !important; }
.CodeMirror-gutters { display: none !important; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; image-orientation: from-image; }
button, input, select, textarea { color: inherit; font: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 4; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror-linenumber { user-select: none; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li blockquote { margin: 1rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; font-variant-ligatures: no-common-ligatures; }
#write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; }
.typora-export * { -webkit-print-color-adjust: exact; }
.typora-export #write { break-after: avoid; }
.typora-export #write::after { height: 0px; }
.is-mac table { break-inside: avoid; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
#write.first-line-indent p > .md-image:only-child:not(.md-img-error) img { left: -2em; position: relative; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
.MathJax_ref { fill: currentcolor; }
[contenteditable="true"]:active, [contenteditable="true"]:focus, [contenteditable="false"]:active, [contenteditable="false"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
.md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
.md-toc-h4 .md-toc-inner { margin-left: 5em; }
.md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
.md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); }
code { text-align: left; vertical-align: initial; }
a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.html-for-mac .inline-math-svg .MathJax_SVG { vertical-align: 0.2px; }
.md-math-block .MathJax_SVG_Display { text-align: center; margin: 0px; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; overflow-y: hidden; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: var(--monospace); }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none 0s ease 0s; }
.MathJax_SVG_Display svg { vertical-align: middle !important; margin-bottom: 0px !important; margin-top: 0px !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }
mark { background: rgb(255, 255, 0); color: rgb(0, 0, 0); }
.md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; }
mark .md-meta { color: rgb(0, 0, 0); opacity: 0.3 !important; }
@media print {
.typora-export h1, .typora-export h2, .typora-export h3, .typora-export h4, .typora-export h5, .typora-export h6 { break-inside: avoid; }
}
.md-diagram-panel .messageText { stroke: none !important; }
.md-diagram-panel .start-state { fill: var(--node-fill); }
.md-diagram-panel .edgeLabel rect { opacity: 1 !important; }
.md-require-zoom-fix foreignobject { font-size: var(--mermaid-font-zoom); }
:root {
--side-bar-bg-color: #fafafa;
--control-text-color: #777;
}
@include-when-export url(https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);
/* open-sans-regular - latin-ext_latin */
/* open-sans-italic - latin-ext_latin */
/* open-sans-700 - latin-ext_latin */
/* open-sans-700italic - latin-ext_latin */
html {
font-size: 16px;
}
body {
font-family: "Open Sans","Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: rgb(51, 51, 51);
line-height: 1.6;
}
#write {
max-width: 860px;
margin: 0 auto;
padding: 30px;
padding-bottom: 100px;
}
@media only screen and (min-width: 1400px) {
#write {
max-width: 1024px;
}
}
@media only screen and (min-width: 1800px) {
#write {
max-width: 1200px;
}
}
#write > ul:first-child,
#write > ol:first-child{
margin-top: 30px;
}
a {
color: #4183C4;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "方正颜宋简体";
position: relative;
margin-top: 1rem;
margin-bottom: 1rem;
font-weight: bold;
line-height: 1.4;
cursor: text;
}
h1:hover a.anchor,
h2:hover a.anchor,
h3:hover a.anchor,
h4:hover a.anchor,
h5:hover a.anchor,
h6:hover a.anchor {
text-decoration: none;
}
h1 tt,
h1 code {
font-size: inherit;
}
h2 tt,
h2 code {
font-size: inherit;
}
h3 tt,
h3 code {
font-size: inherit;
}
h4 tt,
h4 code {
font-size: inherit;
}
h5 tt,
h5 code {
font-size: inherit;
}
h6 tt,
h6 code {
font-size: inherit;
}
h1 {
font-size: 2.25em;
line-height: 1.2;
border-bottom: 1px solid #eee;
}
h2 {
font-size: 1.75em;
line-height: 1.225;
border-bottom: 1px solid #eee;
}
/*@media print {
.typora-export h1,
.typora-export h2 {
border-bottom: none;
padding-bottom: initial;
}
.typora-export h1::after,
.typora-export h2::after {
content: "";
display: block;
height: 100px;
margin-top: -96px;
border-top: 1px solid #eee;
}
}*/
h3 {
font-size: 1.5em;
line-height: 1.43;
}
h4 {
font-size: 1.25em;
}
h5 {
font-size: 1em;
}
h6 {
font-size: 1em;
color: #777;
}
p,
blockquote,
ul,
ol,
dl,
table{
font-family: "方正宋三简体";
margin: 0.8em 0;
color: #000;
}
li>ol,
li>ul {
margin: 0 0;
}
hr {
height: 2px;
padding: 0;
margin: 16px 0;
background-color: #e7e7e7;
border: 0 none;
overflow: hidden;
box-sizing: content-box;
}
li p.first {
display: inline-block;
}
ul,
ol {
padding-left: 30px;
}
ul:first-child,
ol:first-child {
margin-top: 0;
}
ul:last-child,
ol:last-child {
margin-bottom: 0;
}
blockquote {
border-left: 4px solid #dfe2e5;
padding: 0 15px;
color: #777777;
}
blockquote blockquote {
padding-right: 0;
}
table {
padding: 0;
word-break: initial;
}
table tr {
border-top: 1px solid #dfe2e5;
margin: 0;
padding: 0;
}
table tr:nth-child(2n),
thead {
background-color: #f8f8f8;
}
table th {
font-weight: bold;
border: 1px solid #dfe2e5;
border-bottom: 0;
margin: 0;
padding: 6px 13px;
}
table td {
border: 1px solid #dfe2e5;
margin: 0;
padding: 6px 13px;
}
table th:first-child,
table td:first-child {
margin-top: 0;
}
table th:last-child,
table td:last-child {
margin-bottom: 0;
}
.CodeMirror-lines {
padding-left: 4px;
}
.code-tooltip {
box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
border-top: 1px solid #eef2f2;
}
.md-fences,
code,
tt {
border: 1px solid #e7eaed;
background-color: #f8f8f8;
border-radius: 3px;
padding: 0;
padding: 2px 4px 0px 4px;
font-size: 0.9em;
}
code {
background-color: #f3f4f4;
padding: 0 2px 0 2px;
}
.md-fences {
margin-bottom: 15px;
margin-top: 15px;
padding-top: 8px;
padding-bottom: 6px;
}
.md-task-list-item > input {
margin-left: -1.3em;
}
@media print {
html {
font-size: 13px;
}
table,
pre {
page-break-inside: avoid;
}
pre {
word-wrap: break-word;
}
}
.md-fences {
background-color: #f8f8f8;
}
#write pre.md-meta-block {
padding: 1rem;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border: 0;
border-radius: 3px;
color: #777777;
margin-top: 0 !important;
}
.mathjax-block>.code-tooltip {
bottom: .375rem;
}
.md-mathjax-midline {
background: #fafafa;
}
#write>h3.md-focus:before{
left: -1.5625rem;
top: .375rem;
}
#write>h4.md-focus:before{
left: -1.5625rem;
top: .285714286rem;
}
#write>h5.md-focus:before{
left: -1.5625rem;
top: .285714286rem;
}
#write>h6.md-focus:before{
left: -1.5625rem;
top: .285714286rem;
}
.md-image>.md-meta {
/*border: 1px solid #ddd;*/
border-radius: 3px;
padding: 2px 0px 0px 4px;
font-size: 0.9em;
color: inherit;
}
.md-tag {
color: #a7a7a7;
opacity: 1;
}
.md-toc {
margin-top:20px;
padding-bottom:20px;
}
.sidebar-tabs {
border-bottom: none;
}
#typora-quick-open {
border: 1px solid #ddd;
background-color: #f8f8f8;
}
#typora-quick-open-item {
background-color: #FAFAFA;
border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee;
border-style: solid;
border-width: 1px;
}
/** focus mode */
.on-focus-mode blockquote {
border-left-color: rgba(85, 85, 85, 0.12);
}
header, .context-menu, .megamenu-content, footer{
font-family: "Segoe UI", "Arial", sans-serif;
}
.file-node-content:hover .file-node-icon,
.file-node-content:hover .file-node-open-state{
visibility: visible;
}
.mac-seamless-mode #typora-sidebar {
background-color: #fafafa;
background-color: var(--side-bar-bg-color);
}
.md-lang {
color: #b4654d;
}
.html-for-mac .context-menu {
--item-hover-bg-color: #E6F0FE;
}
#md-notification .btn {
border: 0;
}
.dropdown-menu .divider {
border-color: #e5e5e5;
}
.ty-preferences .window-content {
background-color: #fafafa;
}
.ty-preferences .nav-group-item.active {
color: white;
background: #999;
}
</style>
</head>
<body class='typora-export os-windows'>
<div id='write' class=''><h1><a name="计算机网络" class="md-header-anchor"></a><span>计算机网络</span></h1><p><span>所谓的计算机网络是指将地理位置不同的具有独立功能的多台计算机及其外部设备,通过通信线路连接起来,在网络操作系统、网络管理软件及网络通信协议的管理和协调下,实现资源共享和信息传递的计算机系统。位于同一个网络中的计算机若想实现彼此间的通信,必须通过编写网络程序来实现,即在不同的计算机上编写一些实现了网络连接的程序,通过这些程序可以实现数据的交换。</span></p><p><span>虽然通过计算机网络可以使多台计算机实现连接,但是位于同一个网络中的计算机在进行连接和通信时必须要遵守一定的规则,这就好像在道路中行驶的汽车一定要遵守交通规则一样。在计算机网络中,这些连接和通信的规则被称为网络通信协议,它对数据的传输格式、传输速率、传输步骤等做了统一规定,通信双方必须同时遵守才能完成数据交换。</span></p><p><span>网络通信协议有很多种,目前应用最广泛的是TCP/IP协议( Transmission Control Protocol/Internet Protocol,传输控制协议/英特网互联协议)、UDP协议(User DatagramProtocol,用户数据报协议)、ICMP协议( Internet Control Message Protocol, Internet控制报文协议)和其他一些协议的协议组。</span></p><p><span>在⼤型分布式系统中,网络起着⾄关重要的作用,本章对常用的网络7层架构,以及TCP/IP、HTTP和CDN的原理做简单介绍,这是我们构建分布式系统所必须了解的,只有理解这些原理,才能设计出好的系统,并更有针对性地做系统架构调优。</span></p><h2><a name="一计算机网络架构" class="md-header-anchor"></a><span>一、计算机网络架构</span></h2><p><span>学习计算机网络时我们一般采用折中的办法,也就是中和 OSI 和 TCP/IP 的优点,采用一种只有五层协议的体系结构,这样既简洁又能将概念阐述清楚。</span></p><p><span>结合互联网的情况,自上而下地,非常简要的介绍一下各层的作用。</span></p><p><img src="images/五层体系结构.png" referrerpolicy="no-referrer" alt="五层体系结构"></p><h3><a name="osi七层架构体系" class="md-header-anchor"></a><span>OSI/七层架构体系</span></h3><p><img src="images/image-20210318192626836.png" alt="image-20210318192626836" style="zoom:80%;" /></p><h4><a name="1)物理层" class="md-header-anchor"></a><span>1)物理层</span></h4><ul><li><strong><span>功能</span></strong><span>:负责为数据端设备</span><strong><span>透明地传输原始比特流</span></strong><span>,并且定义了数据终端设备和数据通信设备的物理和逻辑链接方法。传输单位是</span><strong><span>比特</span></strong><span>。</span></li><li><strong><span>协议</span></strong><span>:RJ45、CLOCK、IEEE802.3 </span></li><li><strong><span>设备</span></strong><span>:中继器,集线器</span></li></ul><h4><a name="2)数据链路层" class="md-header-anchor"></a><span>2)数据链路层</span></h4><ul><li><strong><span>功能</span></strong><span>:将网络层传下来的IP数据报组装成帧,并检测和矫正物理层产生的传输差错,使得链路对网络层显示一条无差错、可靠的数据传输线路。功能可以概括为成帧,差错控制、流量控制和传输管理</span></li><li><strong><span>协议</span></strong><span>:HDLC(高级数据链路控制协议),PPP,STP,SDLC,CSMA(载波监听多路访问)</span></li><li><strong><span>设备</span></strong><span>: 网桥,交换机</span></li></ul><h4><a name="3)网络层" class="md-header-anchor"></a><span>3)网络层</span></h4><ul><li><strong><span>功能</span></strong><span>:负责在网络层上将数据</span><strong><span>封装成数据报</span></strong><span>,将数据报从源端传到目的端,同时进行</span><strong><span>路由选择</span></strong><span>,为分组交换网上的不同主机提供</span><strong><span>通信服务</span></strong><span>。关键问题是对分组进行选择,并实现流量控制、拥塞控制、差错控制和网际互联等功能。传输单位</span><strong><span>数据报</span></strong><span>。</span></li><li><strong><span>协议</span></strong><span>: IP,ICMP(因特网控制报文协议),IGMP(因特网组管理协议),ARP,RARP,OSPF(开放最短路径优先),IPX</span></li><li><strong><span>设备</span></strong><span>: 路由器</span></li></ul><h4><a name="4)传输层" class="md-header-anchor"></a><span>4)传输层</span></h4><ul><li><strong><span>功能</span></strong><span>:负责主机中两个进程之间的通信,为端到端连接提供可靠的传输服务。为端到端连接提供流量控制、差错控制、服务质量、数据传输管理等服务。</span></li><li><strong><span>协议</span></strong><span>:TCP,UDP</span></li></ul><h4><a name="5)会话层" class="md-header-anchor"></a><span>5)会话层</span></h4><ul><li><strong><span>功能</span></strong><span>:会话层允许不同主机上各个进程之间的</span><strong><span>会话</span></strong><span>,会话层利用传输层提供的端到端的服务,向表示层提供它的增值服务。这种服务主要是为表示层实体或用户进程</span><strong><span>建立连接</span></strong><span>并在连接上提供</span><strong><span>有序</span></strong><span>地传输数据。</span></li><li><strong><span>协议</span></strong><span>:SQL、RPC(远程调用协议)</span></li></ul><h4><a name="6)表示层" class="md-header-anchor"></a><span>6)表示层</span></h4><ul><li><strong><span>功能</span></strong><span>:用于处理两个通信系统中交换信息的表示方式。如数据压缩,加密和解密等。</span></li><li><strong><span>协议</span></strong><span>:JPEG、MPEG、ASII</span></li></ul><h4><a name="7)应用层" class="md-header-anchor"></a><span>7)应用层</span></h4><ul><li><strong><span>功能</span></strong><span>:是TCP/IP的最高层,它是直接为应用进程服务的一层。当不同的应用进程数据通信或数据交换时,就去调用应用层的</span><strong><span>不同协议实体</span></strong><span>,让这些实体去调用TCP或者UDP层服务来进行网络传输。</span></li><li><strong><span>协议</span></strong><span>:FTP(21) TELNET(23) SMTP(25) DNS(53) TFTP(69) HTTP(80) SNMP(161),DHCP(动态主机配置协议)</span></li></ul><h3><a name="tcpip体系" class="md-header-anchor"></a><span>TCP/IP体系</span></h3><p><span>TCP/IP(又称TCP/IP协议簇)是一组用于实现网络互连的通信协议,其名称来源于该协议簇中两个重要的协议(TCP协议和IP协议)。</span></p><p><img src="images/image-20210419162607611.png" referrerpolicy="no-referrer" alt="image-20210419162607611"></p><ul><li><span>链路层(接收和发送数据报):也称为网络接口层,该层负责监视数据在主机和网络之间的交换。事实上,TCP/IP本身并未定义该层的协议,而由参与互连的各网络使用自己的物理层和数据链路层协议与 TCP/IP的网络互联层进行连接。负责将数据报发送到</span><strong><span>网络介质</span></strong><span>上,以及从网络上接收TCP/IP数据报,相当于OSI的物理层和数据层。</span></li><li><span>网络层(数据报封装和路由寻址功能):也称网络互联层,是整个TCP/IP协议的核心,它主要用于将传输的数据进行分组,将分组数据发送到目标计算机或者网络。主要负责寻址和对数据报的封装以及重要的路由选择功能。</span></li><li><span>传输层:负责在应用进程之间的“端到端”的通信,主要使网络程序进行通信,即从某个应用进程传输到另一个应用进程。在进行网络通信时,可以采用TCP协议,也可以采用UDP协议。</span></li><li><span>应用层:是TCP/IP的最高层,它是直接为应用进程服务的一层。当不同的应用进程数据通信或数据交换时,就去调用应用层的</span><strong><span>不同协议实体</span></strong><span>,让这些实体去调用TCP或者UDP层服务来进行网络传输。主要负责应用程序的协议,例如HTTP协议、FTP协议等。</span></li></ul><h3><a name="五层架构体系" class="md-header-anchor"></a><span>五层架构体系</span></h3><p><strong><span>物理层</span></strong><span>:考虑的是怎样在传输媒体上传输数据比特流,而不是指具体的传输媒体。物理层的作用是尽可能屏蔽传输媒体和通信手段的差异,使数据链路层感觉不到这些差异。</span></p><p><strong><span>数据链路层</span></strong><span>:网络层针对的还是主机之间的数据传输服务,而主机之间可以有很多链路,链路层协议就是为同一链路的结点提供服务。数据链路层把网络层传来的分组封装成帧。</span></p><p><strong><span>网络层</span></strong><span>:为主机之间提供数据传输服务,而运输层协议是为主机中的进程提供服务。网络层把运输层传递下来的报文段或者用户数据报封装成分组。</span></p><p><strong><span>运输层</span></strong><span>:提供的是进程间的通用数据传输服务。由于应用层协议很多,定义通用的运输层协议就可以支持不断增多的应用层协议。运输层包括两种协议:传输控制协议 TCP,提供面向连接、可靠的数据传输服务,数据单位为报文段;用户数据报协议 UDP,提供无连接、尽最大努力的数据传输服务,数据单位为用户数据报。TCP 主要提供完整性服务,UDP 主要提供及时性服务。</span></p><p><strong><span>应用层</span></strong><span>:为特定应用程序提供数据传输服务,例如 HTTP、DNS 等。数据单位为报文。</span></p><h3><a name="网络术语" class="md-header-anchor"></a><span>网络术语</span></h3><h4><a name="报文" class="md-header-anchor"></a><span>报文:</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">把应用层交互的数据单元称为报文</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="结点-node)" class="md-header-anchor"></a><span>结点 (node):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">网络中的结点可以是计算机,集线器,交换机或路由器等。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="链路link--)" class="md-header-anchor"></a><span>链路(link ):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 从一个结点到另一个结点的一段物理线路。中间没有任何其他交点。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="主机host)" class="md-header-anchor"></a><span>主机(host):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 连接在因特网上的计算机.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="ispinternet-service-provider)" class="md-header-anchor"></a><span>ISP(Internet Service Provider): </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 因特网服务提供者(提供商).</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="ixpinternet-exchange-point)" class="md-header-anchor"></a><span>IXP(Internet eXchange Point): </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 互联网交换点IXP的主要作用就是允许两个网络直接相连并交换分组,而不需要再通过第三个网络来转发分组。.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="rfcrequest-for-comments" class="md-header-anchor"></a><span>RFC(Request For Comments) </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 意思是“请求评议”,包含了关于Internet几乎所有的重要的文字资料。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="广域网wanwide-area-network)" class="md-header-anchor"></a><span>广域网WAN(Wide Area Network)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 任务是通过长距离运送主机发送的数据</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="城域网manmetropolitan-area-network)" class="md-header-anchor"></a><span>城域网MAN(Metropolitan Area Network)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">用来将多个局域网进行互连</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="局域网lanlocal-area-network)" class="md-header-anchor"></a><span>局域网LAN(Local Area Network)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 学校或企业大多拥有多个互连的局域网</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="个人区域网panpersonal-area-network)" class="md-header-anchor"></a><span>个人区域网PAN(Personal Area Network)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在个人工作的地方把属于个人使用的电子设备用无线技术连接起来的网络 &nbsp;</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="端系统end-system)" class="md-header-anchor"></a><span>端系统(end system): </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">处在因特网边缘的部分即是连接在因特网上的所有的主机.</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="分组packet-)" class="md-header-anchor"></a><span>分组(packet ):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">因特网中传送的数据单元。由首部header和数据段组成。分组又称为包,首部可称为包头。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="存储转发store-and-forward-)" class="md-header-anchor"></a><span>存储转发(store and forward ): </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">路由器收到一个分组,先存储下来,再检查其首部,查找转发表,按照首部中的目的地址,找到合适的接口转发出去。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="带宽bandwidth)" class="md-header-anchor"></a><span>带宽(bandwidth):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在计算机网络中,表示在单位时间内从网络中的某一点到另一点所能通过的“最高数据率”。常用来表示网络的通信线路所能传送数据的能力。单位是“比特每秒”,记为b/s。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="吞吐量throughput-)" class="md-header-anchor"></a><span>吞吐量(throughput ): </span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">表示在单位时间内通过某个网络(或信道、接口)的数据量。吞吐量更经常地用于对现实世界中的网络的一种测量,以便知道实际上到底有多少数据量能够通过网络。吞吐量受网络的带宽或网络的额定速率的限制。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="数据data)" class="md-header-anchor"></a><span>数据(data):</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">运送消息的实体。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="信号signal)" class="md-header-anchor"></a><span>信号(signal)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">数据的电气的或电磁的表现。或者说信号是适合在传输介质上传输的对象。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="码元-code)" class="md-header-anchor"></a><span>码元( code)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在使用时间域(或简称为时域)的波形来表示数字信号时,代表不同离散数值的基本波形。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="单工simplex-)" class="md-header-anchor"></a><span>单工(simplex )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">只能有一个方向的通信而没有反方向的交互。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="半双工half-duplex-)" class="md-header-anchor"></a><span>半双工(half duplex )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">通信的双方都可以发送信息,但不能双方同时发送(当然也就不能同时接收)。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="全双工full-duplex)" class="md-header-anchor"></a><span>全双工(full duplex)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">通信的双方可以同时发送和接收信息。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="奈氏准则" class="md-header-anchor"></a><span>奈氏准则</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在任何信道中,码元的传输的效率是有上限的,传输速率超过此上限,就会出现严重的码间串扰问题,使接收端对码元的判决(即识别)成为不可能。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="基带信号baseband-signal)" class="md-header-anchor"></a><span>基带信号(baseband signal)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">来自信源的信号。指没有经过调制的数字信号或模拟信号。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="带通频带)信号bandpass-signal)" class="md-header-anchor"></a><span>带通(频带)信号(bandpass signal)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">把基带信号经过载波调制后,把信号的频率范围搬移到较高的频段以便在信道中传输(即仅在一段频率范围内能够通过信道),这里调制过后的信号就是带通信号。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="调制modulation)" class="md-header-anchor"></a><span>调制(modulation)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">对信号源的信息进行处理后加到载波信号上,使其变为适合在信道传输的形式的过程。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="信噪比signal-to-noise-ratio-)" class="md-header-anchor"></a><span>信噪比(signal-to-noise ratio )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">指信号的平均功率和噪声的平均功率之比,记为S/N。信噪比(dB)=10*log10(S/N)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="信道复用channel-multiplexing-)" class="md-header-anchor"></a><span>信道复用(channel multiplexing )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">指多个用户共享同一个信道。(并不一定是同时)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="比特率bit-rate-)" class="md-header-anchor"></a><span>比特率(bit rate )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">单位时间(每秒)内传送的比特数。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="波特率baud-rate)" class="md-header-anchor"></a><span>波特率(baud rate)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">单位时间载波调制状态改变的次数。针对数据信号对载波的调制速率。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="复用multiplexing)" class="md-header-anchor"></a><span>复用(multiplexing)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">共享信道的方法</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="adslasymmetric-digital-subscriber-line----)-font" class="md-header-anchor"></a><span>ADSL(Asymmetric Digital Subscriber Line ): </span><font></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">非对称数字用户线。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="光纤同轴混合网hfc网)" class="md-header-anchor"></a><span>光纤同轴混合网(HFC网)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在目前覆盖范围很广的有线电视网的基础上开发的一种居民宽带接入网</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="链路link)" class="md-header-anchor"></a><span>链路(link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">一个结点到相邻结点的一段物理链路</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="数据链路data-link)" class="md-header-anchor"></a><span>数据链路(data link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">把实现控制数据运输的协议的硬件和软件加到链路上就构成了数据链路</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="循环冗余检验crccyclic-redundancy-check)" class="md-header-anchor"></a><span>循环冗余检验CRC(Cyclic Redundancy Check)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">为了保证数据传输的可靠性,CRC是数据链路层广泛使用的一种检错技术</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="帧frame)" class="md-header-anchor"></a><span>帧(frame)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">一个数据链路层的传输单元,由一个数据链路层首部和其携带的封包所组成协议数据单元。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="mtumaximum-transfer-uint--)" class="md-header-anchor"></a><span>MTU(Maximum Transfer Uint )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">最大传送单元。帧的数据部分的的长度上限。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="误码率berbit-error-rate-)" class="md-header-anchor"></a><span>误码率BER(Bit Error Rate )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在一段时间内,传输错误的比特占所传输比特总数的比率。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="ppppoint-to-point-protocol--)" class="md-header-anchor"></a><span>PPP(Point-to-Point Protocol )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">点对点协议。即用户计算机和ISP进行通信时所使用的数据链路层协议。以下是PPP帧的示意图:</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><p><img src="images/1627f8291c6b032c" referrerpolicy="no-referrer" alt="PPP"></p><h4><a name="mac地址media-access-control或者medium-access-control)" class="md-header-anchor"></a><span>MAC地址(Media Access Control或者Medium Access Control)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">意译为媒体访问控制,或称为物理地址、硬件地址,用来定义网络设备的位置。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在OSI模型中,第三层网络层负责 IP地址,第二层数据链路层则负责 MAC地址。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">因此一个主机会有一个MAC地址,而每个网络位置会有一个专属于它的IP地址 。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">地址是识别某个系统的重要标识符,“名字指出我们所要寻找的资源,地址指出资源所在的地方,路由告诉我们如何到达该处”</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="网桥bridge)" class="md-header-anchor"></a><span>网桥(bridge)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 一种用于数据链路层实现中继,连接两个或多个局域网的网络互连设备。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="交换机switch-)" class="md-header-anchor"></a><span>交换机(switch )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">广义的来说,交换机指的是一种通信系统中完成信息交换的设备。这里工作在数据链路层的交换机指的是交换式集线器,其实质是一个多接口的网桥</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="虚电路virtual-circuit)" class="md-header-anchor"></a><span>虚电路(Virtual Circuit)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在两个终端设备的逻辑或物理端口之间,通过建立的双向的透明传输通道。虚电路表示这只是一条逻辑上的连接,分组都沿着这条逻辑连接按照存储转发方式传送,而并不是真正建立了一条物理连接。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="ipinternet-protocol-)" class="md-header-anchor"></a><span>IP(Internet Protocol )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">网际协议 IP 是 TCP/IP体系中两个最主要的协议之一,是TCP/IP体系结构网际层的核心。配套的有ARP,RARP,ICMP,IGMP。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><p><span> </span><img src="images/1627f92f98436286" referrerpolicy="no-referrer" alt="这里写图片描述"></p><h4><a name="arpaddress-resolution-protocol)" class="md-header-anchor"></a><span>ARP(Address Resolution Protocol)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">地址解析协议</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="icmpinternet-control-message-protocol-)" class="md-header-anchor"></a><span>ICMP(Internet Control Message Protocol )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">网际控制报文协议 (ICMP 允许主机或路由器报告差错情况和提供有关异常情况的报告。)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="子网掩码subnet-mask-)" class="md-header-anchor"></a><span>子网掩码(subnet mask )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">它是一种用来指明一个IP地址的哪些位标识的是主机所在的子网以及哪些位标识的是主机的位掩码。子网掩码不能单独存在,它必须结合IP地址一起使用。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="cidr-classless-inter-domain-routing-)" class="md-header-anchor"></a><span>CIDR( Classless Inter-Domain Routing )</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">无分类域间路由选择 (特点是消除了传统的 A 类、B 类和 C 类地址以及划分子网的概念,并使用各种长度的“网络前缀”(network-prefix)来代替分类地址中的网络号和子网号)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="默认路由default-route)" class="md-header-anchor"></a><span>默认路由(default route)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">当在路由表中查不到能到达目的地址的路由时,路由器选择的路由。默认路由还可以减小路由表所占用的空间和搜索路由表所用的时间。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="路由选择算法virtual-circuit)" class="md-header-anchor"></a><span>路由选择算法(Virtual Circuit)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">路由选择协议的核心部分。因特网采用自适应的,分层次的路由选择协议。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="进程process)" class="md-header-anchor"></a><span>进程(process)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">指计算机中正在运行的程序实体</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="应用进程互相通信" class="md-header-anchor"></a><span>应用进程互相通信</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">一台主机的进程和另一台主机中的一个进程交换数据的过程(另外注意通信真正的端点不是主机而是主机中的进程,也就是说端到端的通信是应用进程之间的通信)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="传输层的复用与分用" class="md-header-anchor"></a><span>传输层的复用与分用</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">复用指发送方不同的进程都可以通过统一个运输层协议传送数据。分用指接收方的运输层在剥去报文的首部后能把这些数据正确的交付到目的应用进程。 </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="tcptransmission-control-protocol)" class="md-header-anchor"></a><span>TCP(Transmission Control Protocol)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">传输控制协议</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="udpuser-datagram-protocol)" class="md-header-anchor"></a><span>UDP(User Datagram Protocol)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">用户数据报协议</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="http协议" class="md-header-anchor"></a><strong><span>HTTP协议</span></strong></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。所有的 WWW(万维网) 文件都必须遵守这个标准。设计 HTTP 最初的目的是为了提供一种发布和接收 HTML 页面的方法。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="端口port)link)" class="md-header-anchor"></a><span>端口(port)(link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">端口的目的是为了确认对方机器是那个进程在于自己进行交互,比如MSN和QQ的端口不同,如果没有端口就可能出现QQ进程和MSN交互错误。端口又称协议端口号。 </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="停止等待协议link)" class="md-header-anchor"></a><span>停止等待协议(link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">指发送方每发送完一个分组就停止发送,等待对方确认,在收到确认之后在发送下一个分组。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="流量控制link)" class="md-header-anchor"></a><span>流量控制(link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">就是让发送方的发送速率不要太快,既要让接收方来得及接收,也不要使网络发生拥塞。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="拥塞控制link)" class="md-header-anchor"></a><span>拥塞控制(link)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">防止过多的数据注入到网络中,这样可以使网络中的路由器或链路不致过载。拥塞控制所要做的都有一个前提,就是网络能够承受现有的网络负荷。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><h4><a name="域名系统dns)" class="md-header-anchor"></a><span>域名系统(DNS)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">域名系统(Domain Name System缩写 DNS,Domain Name被译为域名)是因特网的一项核心服务,它作为可以将域名和IP地址相互映射的一个分布式数据库,能够使人更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。(百度百科)例如:一个公司的 Web 网站可看作是它在网上的门户,而域名就相当于其门牌地址,通常域名都使用该公司的名称或简称。例如上面提到的微软公司的域名,类似的还有:IBM 公司的域名是 www.ibm.com、Oracle 公司的域名是 www.oracle.com、Cisco公司的域名是 www.cisco.com 等。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="文件传输协议ftp)" class="md-header-anchor"></a><span>文件传输协议(FTP)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> FTP 是File TransferProtocol(文件传输协议)的英文简称,而中文简称为“文传协议”。用于Internet上的控制文件的双向传输。同时,它也是一个应用程序(Application)。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 基于不同的操作系统有不同的FTP应用程序,而所有这些应用程序都遵守同一种协议以传输文件。在FTP的使用当中,用户经常遇到两个概念:"下载"(Download)和"上传"(Upload)。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> "下载"文件就是从远程主机拷贝文件至自己的计算机上;"上传"文件就是将文件从自己的计算机中拷贝至远程主机上。用Internet语言来说,用户可通过客户机程序向(从)远程主机上传(下载)文件。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 144px;"></div><div class="CodeMirror-gutters" style="display: none; height: 144px;"></div></div></div></pre><h4><a name="简单文件传输协议tftp)" class="md-header-anchor"></a><span>简单文件传输协议(TFTP)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。端口号为69。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="远程终端协议telenet)" class="md-header-anchor"></a><span>远程终端协议(TELENET)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Telnet协议是TCP/IP协议族中的一员,是Internet远程登陆服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">在终端使用者的电脑上使用telnet程序,用它连接到服务器。终端使用者可以在telnet程序中输入命令,这些命令会在服务器上运行,就像直接在服务器的控制台上输入一样。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">可以在本地就能控制服务器。要开始一个telnet会话,必须输入用户名和密码来登录服务器。Telnet是常用的远程控制Web服务器的方法。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="万维网www)" class="md-header-anchor"></a><span>万维网(WWW)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">WWW是环球信息网的缩写,(亦作“Web”、“WWW”、“'W3'”,英文全称为“World Wide Web”),中文名字为“万维网”,"环球网"等,常简称为Web。分为Web客户端和Web服务器程序。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">WWW可以让Web客户端(常用浏览器)访问浏览Web服务器上的页面。是一个由许多互相链接的超文本组成的系统,通过互联网访问。在这个系统中,每个有用的事物,称为一样“资源”;并且由一个全局“统一资源标识符”(URI)标识;这些资源通过超文本传输协议(Hypertext Transfer Protocol)传送给用户,而后者通过点击链接来获得资源。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">万维网联盟(英语:World Wide Web Consortium,简称W3C),又称W3C理事会。1994年10月在麻省理工学院(MIT)计算机科学实验室成立。万维网联盟的创建者是万维网的发明者蒂姆·伯纳斯-李。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">万维网并不等同互联网,万维网只是互联网所能提供的服务其中之一,是靠着互联网运行的一项服务。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 192px;"></div><div class="CodeMirror-gutters" style="display: none; height: 192px;"></div></div></div></pre><h4><a name="万维网的大致工作工程" class="md-header-anchor"></a><span>万维网的大致工作工程</span></h4><p><img src="images/1627ff96a96087af" referrerpolicy="no-referrer" alt="万维网的大致工作工程"></p><h4><a name="统一资源定位符url)" class="md-header-anchor"></a><span>统一资源定位符(URL)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">统一资源定位符是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示,是互联网上标准资源的地址。互联网上的每个文件都有一个唯一的URL,它包含的信息指出文件的位置以及浏览器应该怎么处理它。 </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="超文本传输协议http)" class="md-header-anchor"></a><span>超文本传输协议(HTTP)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。所有的WWW文件都必须遵守这个标准。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法。1960年美国人Ted Nelson构思了一种通过计算机处理文本信息的方法,并称之为超文本(hypertext),这成为了HTTP超文本传输协议标准架构的发展根基。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 72px;"></div><div class="CodeMirror-gutters" style="display: none; height: 72px;"></div></div></div></pre><h4><a name="代理服务器proxy-server)" class="md-header-anchor"></a><span>代理服务器(Proxy Server)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 代理服务器(Proxy Server)是一种网络实体,它又称为万维网高速缓存。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 代理服务器把最近的一些请求和响应暂存在本地磁盘中。当新请求到达时,若代理服务器发现这个请求与暂时存放的的请求相同,就返回暂存的响应,而不需要按URL的地址再次去互联网访问该资源。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 代理服务器可在客户端或服务器工作,也可以在中间系统工作。 </span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="http请求头" class="md-header-anchor"></a><span>http请求头</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">http请求头,HTTP客户程序(例如浏览器),向服务器发送请求的时候必须指明请求类型(一般是GET或者POST)。如有必要,客户程序还可以选择发送其他的请求头。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Accept:浏览器可接受的MIME类型。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Accept-Charset:浏览器可接受的字符集。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Accept-Encoding:浏览器能够进行解码的数据编码方式,比如gzip。Servlet能够向支持gzip的浏览器返回经gzip编码的HTML页面。许多情形下这可以减少5到10倍的下载时间。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Accept-Language:浏览器所希望的语言种类,当服务器能够提供一种以上的语言版本时要用到。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Authorization:授权信息,通常出现在对服务器发送的WWW-Authenticate头的应答中。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Connection:表示是否需要持久连接。如果Servlet看到这里的值为“Keep-Alive”,或者看到请求使用的是HTTP 1.1(HTTP 1.1默认进行持久连接),它就可以利用持久连接的优点,当页面包含多个元素时(例如Applet,图片),显著地减少下载所需要的时间。要实现这一点,Servlet需要在应答中发送一个Content-Length头,最简单的实现方法是:先把内容写入ByteArrayOutputStream,然后在正式写出内容之前计算它的大小。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Content-Length:表示请求消息正文的长度。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Cookie:这是最重要的请求头信息之一</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- From:请求发送者的email地址,由一些特殊的Web客户程序使用,浏览器不会用到它。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Host:初始URL中的主机和端口。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- If-Modified-Since:只有当所请求的内容在指定的日期之后又经过修改才返回它,否则返回304“Not Modified”应答。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Pragma:指定“no-cache”值表示服务器必须返回一个刷新后的文档,即使它是代理服务器而且已经有了页面的本地拷贝。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- Referer:包含一个URL,用户从该URL代表的页面出发访问当前请求的页面。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- User-Agent:浏览器类型,如果Servlet返回的内容与浏览器类型有关则该值非常有用。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 456px;"></div><div class="CodeMirror-gutters" style="display: none; height: 456px;"></div></div></div></pre><h4><a name="简单邮件传输协议smtp" class="md-header-anchor"></a><span>简单邮件传输协议(SMTP)</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> SMTP协议属于TCP/IP协议簇,它帮助每台计算机在发送或中转信件时找到下一个目的地。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 通过SMTP协议所指定的服务器,就可以把E-mail寄到收信人的服务器上了,整个过程只要几分钟。SMTP服务器则是遵循SMTP协议的发送邮件服务器,用来发送或中转发出的电子邮件。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="搜索引擎" class="md-header-anchor"></a><span>搜索引擎</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 搜索引擎(Search Engine)是指根据一定的策略、运用特定的计算机程序从互联网上搜集信息,在对信息进行组织和处理后,为用户提供检索服务,将用户检索相关的信息展示给用户的系统。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 搜索引擎包括全文索引、目录索引、元搜索引擎、垂直搜索引擎、集合式搜索引擎、门户搜索引擎与免费链接列表等。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 72px;"></div><div class="CodeMirror-gutters" style="display: none; height: 72px;"></div></div></div></pre><h4><a name="全文索引" class="md-header-anchor"></a><span>全文索引</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> 全文索引技术是目前搜索引擎的关键技术。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">试想在1M大小的文件中搜索一个词,可能需要几秒,在100M的文件中可能需要几十秒,如果在更大的文件中搜索那么就需要更大的系统开销,这样的开销是不现实的。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">所以在这样的矛盾下出现了全文索引技术,有时候有人叫倒排文档技术。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="目录索引" class="md-header-anchor"></a><span>目录索引</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">目录索引( search index/directory),顾名思义就是将网站分门别类地存放在相应的目录中,因此用户在查询信息时,可选择关键词搜索,也可按分类目录逐层查找。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="垂直搜索引擎" class="md-header-anchor"></a><span>垂直搜索引擎</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">垂直搜索引擎是针对某一个行业的专业搜索引擎,是搜索引擎的细分和延伸,是对网页库中的某类专门的信息进行一次整合,定向分字段抽取出需要的数据进行处理后再以某种形式返回给用户。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">垂直搜索是相对通用搜索引擎的信息量大、查询不准确、深度不够等提出来的新的搜索引擎服务模式,通过针对某一特定领域、某一特定人群或某一特定需求提供的有一定价值的信息和相关服务。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">其特点就是“专、精、深”,且具有行业色彩,相比较通用搜索引擎的海量信息无序化,垂直搜索引擎则显得更加专注、具体和深入。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 120px;"></div><div class="CodeMirror-gutters" style="display: none; height: 120px;"></div></div></div></pre><h4><a name="arp地址解析协议的工作原理" class="md-header-anchor"></a><span>ARP地址解析协议的工作原理</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">ARP和RARP是网络层的协议,但是它所工作的内容是链路层的,具体来说应该是在网络层。 </span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">每个主机都存有一个ARP高速缓存,存放**本局域网上**各主机和路由器的**IP地址到MAC地址的映射表**,称为ARP表。使用ARP协议动态维护此表。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">ARP工作在网络层中,其工作原理是:当主机A欲向**本局域网上**的某个主机B发送IP数据报时,就先在其ARP高速缓存中查看有无主机B的IP地址:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 如果有可以查出其对应的硬件地址,再将此硬件地址写入**MAC帧**,然后通过局域网将该MAC帧发往此硬件地址。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 如果没有,就通过使用目的MAC地址为本网络的广播地址即32个1的帧来封装并广播ARP请求分组,可以使同一个局域网里的所有主机收到ARP请求。当主机B收到该ARP请求后,就会向主机A发出响应ARP分组,分组中包含主机B的IP与MAC地址的映射关系,主机A在收到后将此映射写入ARP缓存中,然后按查询到的硬件地址发送MAC帧。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">ARP是解决同一个局域网上主机与路由器的IP地址和硬件地址的映射问题。如果所要找的主机和源主机不在同一个局域网上,那么通过ARP协议找到一个位于本局域网上的某个路由器硬件地址,然后把分组发送给这个路由器,让这个路由器把分组转发给下一个网络。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 216px;"></div><div class="CodeMirror-gutters" style="display: none; height: 216px;"></div></div></div></pre><h4><a name="描述rarp协议" class="md-header-anchor"></a><span>描述RARP协议</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">RARP是逆地址解析协议,作用是完成**硬件地址到IP地址的映射**.(请求是广播,应答是单播):</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 网络上的每台设备都会有一个独一无二的硬件地址,通常是由设备厂商分配的MAC地址。主机从网卡上读取MAC地址,然后在网络上发送一个RARP请求的广播数据包,请求的RARP服务器分配一个IP地址。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 本地网段上的RARP服务器收到此请求后,检查其RARP列表,查找该MAC地址对应的IP地址。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 如果存在,RARP服务器就给源主机发送一个响应数据包并将此IP地址提供给对方主机使用。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 如果不存在,RARP服务器对此不做任何的响应。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - 源主机收到从RARP服务器的响应信息,就利用得到的IP地址进行通讯;如果一直没有收到RARP服务器的响应信息,表示初始化失败</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 168px;"></div><div class="CodeMirror-gutters" style="display: none; height: 168px;"></div></div></div></pre><h4><a name="常见的路由选择协议以及它们的区别" class="md-header-anchor"></a><span>常见的路由选择协议,以及它们的区别</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">常见的路由选择协议有:RIP协议、OSPF协议。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **RIP协议(路由信息协议)**:底层是贝尔曼福特算法(Bellman-Ford),**基于距离向量的路由选择协议**,它选择路由的度量标准(metric)是**跳数**,最大跳数是15跳,如果大于15跳,它就会丢弃数据包。仅和相邻路由器交换当前路由器所知道的全部信息。是应用层协议,使用UDP传输数据,端口520</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **OSPF协议(开放最短路由优先)**:底层是迪杰斯特拉(Dijkstra)算法,**是链路状态路由选择协议**,它选择路由的度量标准是**带宽**,延迟。向本自治系统中所有路由器发送与本路由器相邻的所有路由器的链路状态,但这只是路由器知道的部分信息。网络层协议,直接IP数据报传输. 端口89。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 168px;"></div><div class="CodeMirror-gutters" style="display: none; height: 168px;"></div></div></div></pre><h4><a name="交换机路由器网关" class="md-header-anchor"></a><span>交换机、路由器、网关</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">概念:</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **路由器**是具有多个输入输出端口的专用计算机,**其任务是连接不同的网络并完成路由转发**。当源主机向目标主机发送数据报时,路由器先检查源主机与目标主机是否连接在一个网络上。如果源主机和目标主机在一个网络上则直接交付而无需通过路由器。但如果源主机和目标主机不在同一个网络上,则路由器转发表指出路由将数据报转发给下一个路由器,即间接交付。路由器隔离了广播域。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **交换机**:是多个端口的网桥,工作在数据链路上,**将两个或多个以太网连接起来成为更大的以太网。它能将网络分成小的冲突域,为每个工作站提供更高的带宽**。其原理是,检测从以太端口来的数据帧的源和目的地的MAC地址,然后与系统内部的动态查找表进行比较。若数据帧的MAC地址不在查找表中,则将该地址加入查找表中,并将数据帧发送给相应的端口。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">区别:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **路由器**:工作在网络层,是能够连接不同的广域网形成更大的广域网。连接的是异构网络。根据IP地址转发。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **交换机**:工作在数据链路层,是将以太网连接形成更大的以太网,同一个网络。根据MAC地址进行转发。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **网关(Gateway)**又称网间连接器、协议转换器。网关在网络层以上实现网络互连,是最复杂的网络互连设备,**仅用于两个高层协议不同的网络互连**。网关既可以用于广域网互连,也可以用于局域网互连。 网关是一种充当转换重任的计算机系统或设备。使用在不同的通信协议、数据格式或语言,甚至体系结构完全不同的两种系统之间,网关是一个翻译器。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 360px;"></div><div class="CodeMirror-gutters" style="display: none; height: 360px;"></div></div></div></pre><h4><a name="tcp报文段的首部格式" class="md-header-anchor"></a><span>TCP报文段的首部格式</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">1. **源端口和目的端口**。各占2字节。</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">2. **序号**: TCP每个一个字节都是按顺序编号。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">3. **确认号**: 期望收到对方下一个报文段的第一个数据字节的序号。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">4. **数据偏移**:占用4字节,指出TCP报文段数据处距离TCP报文段的起始处有多远。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">5. **保留**: 占用6位,留以后使用。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">6. **紧急URG**: URG=1表示紧急,告诉系统有紧急数据,应尽快传送,而不按原来的排队顺序来传送。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">7. **确认ACK**:只有ACK=1时,确认号ack才有效。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">8. **推送PSH**: 希望立即能够收到对方的响应。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">9. **复位RST**:RST=1,表明连接中出现严重差错,必须释放连接,然后再重新建立运输连接。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">10. **同步SYN**: 在连接建立时用来同步序号。当SYN=1,ACK=0时表示连接请求报文段。如果对方同意则响应报文中使用SYN=1,ACK=1.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">11. **终止FIN**: 用来释放连接。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">12. **窗口**:占两字节,窗口值作为接收方让发送方设置发送窗口的依据。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">13. **校验和**:占2字节,校验和字段校验的范围包括首部和数据两部分。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">14. **紧急指针**:占两字节,只有URG=1时才有意义,紧急指针指出紧急数据的末尾在报文段中的位置。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">15. **选项**:长度可变,最长40字节。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 360px;"></div><div class="CodeMirror-gutters" style="display: none; height: 360px;"></div></div></div></pre><h4><a name="udp报文段首部格式" class="md-header-anchor"></a><span>UDP报文段首部格式</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **源端口**: 源端口号,在需要对方回信时选用,不需要时可用全0.</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **目的端口**: 目的端口号,在终点交付报文时必须使用</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **长度**: UDP用户数据报的长度,其最小值是8(仅有头部)。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **校验和**: 检测UDP用户数据报在传输中是否有错。有错就丢弃。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 96px;"></div><div class="CodeMirror-gutters" style="display: none; height: 96px;"></div></div></div></pre><h4><a name="tcp应用场景" class="md-header-anchor"></a><span>TCP应用场景</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">效率要求相对低,但对准确性要求相对高的场景。因为传输中需要对数据确认、重发、排序等操作,相比之下效率没有UDP高。举几个例子:文件传输(准确高要求高、但是速度可以相对慢)、接受邮件、远程登录。 NSQ底层通讯就采用TCP。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="udp应用场景" class="md-header-anchor"></a><span>UDP应用场景</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">效率要求相对高,对准确性要求相对低的场景。举几个例子:QQ聊天、在线视频、网络语音电话(即时通讯,速度要求高,但是出现偶尔断续不是太大问题,并且此处完全不可以使用重发机制)、广播通信(广播、多播)。</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 48px;"></div><div class="CodeMirror-gutters" style="display: none; height: 48px;"></div></div></div></pre><h4><a name="tcp对应的协议和udp对应的协议" class="md-header-anchor"></a><span>TCP对应的协议和UDP对应的协议</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">1)TCP对应的协议</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **FTP(21)**:定义了**文件传输协议**,使用21端口。常说某某计算机开了FTP服务便是启动了文件传输服务。下载文件,上传主页,都要用到FTP服务。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **ssh(22)**: 专为**远程登录会话**和其他网络服务提供安全性的协议</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **Telnet(23)**:(远程登陆协议)它是一种用于**远程登陆**的端口,用户可以以自己的身份远程连接到计算机上,通过这种端口可以提供一种基于DOS模式下的通信服务。如以前的BBS是-纯字符界面的,支持BBS的服务器将23端口打开,对外提供服务。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **SMTP(25)**:定义了**简单邮件传送协议**,现在很多邮件服务器都用的是这个协议,用于发送邮件。如常见的免费邮件服务中用的就是这个邮件服务端口,所以在电子邮件设置-中常看到有这么SMTP端口设置这个栏,服务器开放的是25号端口。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **POP3(110)**:它是和SMTP对应,POP3用于**接收邮件**。通常情况下,POP3协议所用的是110端口。也是说,只要你有相应的使用POP3协议的程序(例如Fo-xmail或Outlook),就可以不以Web方式登陆进邮箱界面,直接用邮件程序就可以收到邮件(如是163邮箱就没有必要先进入网易网站,再进入自己的邮-箱来收信)。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> - **HTTP(80)协议**:是从Web服务器传输超文本到本地浏览器的传送协议。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">2)UDP对应的协议</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **DNS(53)**:用于域名解析服务,将域名地址转换为IP地址。DNS用的是53号端口。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **RIP(520)**:路由信息协议,端口520</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **SNMP(161)**:简单网络管理协议,使用161号端口,是用来管理网络设备的。由于网络设备很多,无连接的服务就体现出其优势。</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">- **TFTP(69)(Trival File Transfer Protocal)**,简单文件传输协议,该协议在熟知端口69上使用UDP服务。</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 432px;"></div><div class="CodeMirror-gutters" style="display: none; height: 432px;"></div></div></div></pre><p>&nbsp;</p><h3><a name="网络基本知识" class="md-header-anchor"></a><span>网络基本知识</span></h3><ol start='' ><li><p><span>计算机网络(简称网络)把许多计算机连接在一起,而互联网把许多网络连接在一起,是网络的网络。</span></p></li><li><p><span>小写字母i开头的internet(互联网)是通用名词,它泛指由多个计算机网络相互连接而成的网络。在这些网络之间的通信协议(即通信规则)可以是任意的。</span></p></li><li><p><span>大写字母I开头的Internet(互联网)是专用名词,它指全球最大的,开放的,由众多网络相互连接而成的特定的互联网,并采用TCP/IP协议作为通信规则,其前身为ARPANET。Internet的推荐译名为因特网,现在一般流行称为互联网。</span></p></li><li><p><span>路由器是实现分组交换的关键构件,其任务是转发收到的分组,这是网络核心部分最重要的功能。分组交换采用存储转发技术,表示把一个报文(要发送的整块数据)分为几个分组后再进行传送。在发送报文之前,先把较长的报文划分成为一个个更小的等长数据段。在每个数据端的前面加上一些由必要的控制信息组成的首部后,就构成了一个分组。分组又称为包。分组是在互联网中传送的数据单元,正是由于分组的头部包含了诸如目的地址和源地址等重要控制信息,每一个分组才能在互联网中独立的选择传输路径,并正确地交付到分组传输的终点。</span></p></li><li><p><span>互联网按工作方式可划分为边缘部分和核心部分。主机在网络的边缘部分,其作用是进行信息处理。由大量网络和连接这些网络的路由器组成核心部分,其作用是提供连通性和交换。</span></p></li><li><p><span>计算机通信是计算机中进程(即运行着的程序)之间的通信。计算机网络采用的通信方式是客户-服务器方式(C/S方式)和对等连接方式(P2P方式)。</span></p></li><li><p><span>客户和服务器都是指通信中所涉及的应用进程。客户是服务请求方,服务器是服务提供方。</span></p></li><li><p><span>按照作用范围的不同,计算机网络分为广域网WAN,城域网MAN,局域网LAN,个人区域网PAN。</span></p></li><li><p><span>计算机网络最常用的性能指标是:速率,带宽,吞吐量,时延(发送时延,处理时延,排队时延),时延带宽积,往返时间和信道利用率。</span></p></li><li><p><span>网络协议即协议,是为进行网络中的数据交换而建立的规则。计算机网络的各层以及其协议集合,称为网络的体系结构。</span></p></li><li><p><span>五层体系结构由应用层,运输层,网络层(网际层),数据链路层,物理层组成。运输层最主要的协议是TCP和UDP协议,网络层最重要的协议是IP协议。</span></p></li><li><p><span>物理层的主要任务就是确定与传输媒体接口有关的一些特性,如机械特性,电气特性,功能特性,过程特性。</span></p></li><li><p><span>一个数据通信系统可划分为三大部分,即源系统,传输系统,目的系统。源系统包括源点(或源站,信源)和发送器,目的系统包括接收器和终点。</span></p></li><li><p><span>通信的目的是传送消息。如话音,文字,图像等都是消息,数据是运送消息的实体。信号则是数据的电器或电磁的表现。</span></p></li><li><p><span>根据信号中代表消息的参数的取值方式不同,信号可分为模拟信号(或连续信号)和数字信号(或离散信号)。在使用时间域(简称时域)的波形表示数字信号时,代表不同离散数值的基本波形称为码元。</span></p></li><li><p><span>根据双方信息交互的方式,通信可划分为单向通信(或单工通信),双向交替通信(或半双工通信),双向同时通信(全双工通信)。</span></p></li><li><p><span>来自信源的信号称为基带信号。信号要在信道上传输就要经过调制。调制有基带调制和带通调制之分。最基本的带通调制方法有调幅,调频和调相。还有更复杂的调制方法,如正交振幅调制。</span></p></li><li><p><span>要提高数据在信道上的传递速率,可以使用更好的传输媒体,或使用先进的调制技术。但数据传输速率不可能任意被提高。</span></p></li><li><p><span>传输媒体可分为两大类,即导引型传输媒体(双绞线,同轴电缆,光纤)和非导引型传输媒体(无线,红外,大气激光)。</span></p></li><li><p><span>为了有效利用光纤资源,在光纤干线和用户之间广泛使用无源光网络PON。无源光网络无需配备电源,其长期运营成本和管理成本都很低。最流行的无源光网络是以太网无源光网络EPON和吉比特无源光网络GPON。</span></p></li><li><h5><a name="物理层的任务透明地传送比特流也可以将物理层的主要任务描述为确定与传输媒体的接口的一些特性即机械特性接口所用接线器的一些物理属性如形状尺寸)电气特性接口电缆的各条线上出现的电压的范围)功能特性某条线上出现的某一电平的电压的意义)过程特性对于不同功能能的各种可能事件的出现顺序)" class="md-header-anchor"></a><span>物理层的任务:透明地传送比特流。也可以将物理层的主要任务描述为确定与传输媒体的接口的一些特性,即:机械特性(接口所用接线器的一些物理属性如形状尺寸),电气特性(接口电缆的各条线上出现的电压的范围),功能特性(某条线上出现的某一电平的电压的意义),过程特性(对于不同功能能的各种可能事件的出现顺序)。</span></h5></li><li><p><span>物理层考虑的是怎样才能在连接各种计算机的传输媒体上传输数据比特流,而不是指具体的传输媒体。现有的计算机网络中的硬件设备和传输媒体的种类非常繁多,而且通信手段也有许多不同的方式。物理层的作用正是尽可能地屏蔽掉这些传输媒体和通信手段的差异,使物理层上面的数据链路层感觉不到这些差异,这样就可以使数据链路层只考虑完成本层的协议和服务,而不必考虑网络的具体传输媒体和通信手段是什么。</span></p></li><li><h5><a name="几种常用的信道复用技术" class="md-header-anchor"></a><span>几种常用的信道复用技术</span></h5><p><img src="images/1627f7a170ec6611" referrerpolicy="no-referrer" alt="这里写图片描述"></p></li><li><p><span>几种常用的宽带接入技术,主要是ADSL和FTTx</span></p></li><li><p><span>用户到互联网的宽带接入方法有非对称数字用户线ADSL(用数字技术对现有的模拟电话线进行改造,而不需要重新布线。ASDL的快速版本是甚高速数字用户线VDSL。),光纤同轴混合网HFC(是在目前覆盖范围很广的有线电视网的基础上开发的一种居民宽带接入网)和FTTx(即光纤到······)。</span></p></li><li><p><span>链路是从一个结点到相邻节点的一段物理链路,数据链路则在链路的基础上增加了一些必要的硬件(如网络适配器)和软件(如协议的实现)</span></p></li><li><p><span>数据链路层使用的主要是</span><strong><span>点对点信道</span></strong><span>和</span><strong><span>广播信道</span></strong><span>两种。</span></p></li><li><p><span>数据链路层传输的协议数据单元是帧。数据链路层的三个基本问题是:</span><strong><span>封装成帧</span></strong><span>,</span><strong><span>透明传输</span></strong><span>和</span><strong><span>差错检测</span></strong></p></li><li><p><strong><span>循环冗余检验CRC</span></strong><span>是一种检错方法,而帧检验序列FCS是添加在数据后面的冗余码</span></p></li><li><p><strong><span>点对点协议PPP</span></strong><span>是数据链路层使用最多的一种协议,它的特点是:简单,只检测差错而不去纠正差错,不使用序号,也不进行流量控制,可同时支持多种网络层协议。</span></p></li><li><p><span>PPPoE是为宽带上网的主机使用的链路层协议</span></p></li><li><p><span>局域网的优点是:具有广播功能,从一个站点可方便地访问全网;便于系统的扩展和逐渐演变;提高了系统的可靠性,可用性和生存性。</span></p></li><li><p><span>共向媒体通信资源的方法有二:一是静态划分信道(各种复用技术),而是动态媒体接入控制,又称为多点接入(随即接入或受控接入)</span></p></li><li><p><span>计算机与外接局域网通信需要通过通信适配器(或网络适配器),它又称为网络接口卡或网卡。</span><strong><span>计算器的硬件地址就在适配器的ROM中</span></strong><span>。</span></p></li><li><p><span>以太网采用的无连接的工作方式,对发送的数据帧不进行编号,也不要求对方发回确认。目的站收到有差错帧就把它丢掉,其他什么也不做</span></p></li><li><p><span>以太网采用的协议是具有冲突检测的</span><strong><span>载波监听多点接入CSMA/CD</span></strong><span>。协议的特点是:</span><strong><span>发送前先监听,边发送边监听,一旦发现总线上出现了碰撞,就立即停止发送。然后按照退避算法等待一段随机时间后再次发送。</span></strong><span> 因此,每一个站点在自己发送数据之后的一小段时间内,存在这遭遇碰撞的可能性。以太网上的各站点平等的争用以太网信道</span></p></li><li><p><span>以太网的适配器具有过滤功能,它只接收单播帧,广播帧和多播帧。</span></p></li><li><p><span>使用集线器可以在物理层扩展以太网(扩展后的以太网仍然是一个网络)</span></p></li><li><h5><a name="数据链路层的点对点信道和广播信道的特点以及这两种信道所使用的协议ppp协议以及csmacd协议)的特点" class="md-header-anchor"></a><span>数据链路层的点对点信道和广播信道的特点,以及这两种信道所使用的协议(PPP协议以及CSMA/CD协议)的特点</span></h5></li><li><h5><a name="数据链路层的三个基本问题封装成帧透明传输差错检测" class="md-header-anchor"></a><span>数据链路层的三个基本问题:</span><strong><span>封装成帧</span></strong><span>,</span><strong><span>透明传输</span></strong><span>,</span><strong><span>差错检测</span></strong></h5></li><li><h5><a name="以太网的mac层硬件地址" class="md-header-anchor"></a><span>以太网的MAC层硬件地址</span></h5></li><li><h5><a name="适配器转发器集线器网桥以太网交换机的作用以及适用场合" class="md-header-anchor"></a><span>适配器,转发器,集线器,网桥,以太网交换机的作用以及适用场合</span></h5></li><li><p><span>TCP/IP协议中的网络层向上只提供简单灵活的,无连接的,尽最大努力交付的数据报服务。网络层不提供服务质量的承诺,不保证分组交付的时限所传送的分组可能出错,丢失,重复和失序。进程之间通信的可靠性由运输层负责</span></p></li><li><p><span>在互联网的交付有两种,一是在本网络直接交付不用经过路由器,另一种是和其他网络的间接交付,至少经过一个路由器,但最后一次一定是直接交付</span></p></li><li><p><span>分类的IP地址由网络号字段(指明网络)和主机号字段(指明主机)组成。网络号字段最前面的类别指明IP地址的类别。IP地址是一种分等级的地址结构。IP地址管理机构分配IP地址时只分配网络号,主机号由得到该网络号的单位自行分配。路由器根据目的主机所连接的网络号来转发分组。一个路由器至少连接到两个网络,所以一个路由器至少应当有两个不同的IP地址</span></p></li><li><p><span>IP数据报分为首部和数据两部分。首部的前一部分是固定长度,共20字节,是所有IP数据包必须具有的(源地址,目的地址,总长度等重要地段都固定在首部)。一些长度可变的可选字段固定在首部的后面。IP首部中的生存时间给出了IP数据报在互联网中所能经过的最大路由器数。可防止IP数据报在互联网中无限制的兜圈子。</span></p></li><li><p><span>地址解析协议ARP把IP地址解析为硬件地址。ARP的高速缓存可以大大减少网络上的通信量。因为这样可以使主机下次再与同样地址的主机通信时,可以直接从高速缓存中找到所需要的硬件地址而不需要再去广播方式发送ARP请求分组</span></p></li><li><p><span>无分类域间路由选择CIDR是解决目前IP地址紧缺的一个好办法。CIDR记法把IP地址后面加上斜线“/”,然后写上前缀所所占的位数。前缀(或网络前缀用来指明网络),前缀后面的部分是后缀,用来指明主机。CIDR把前缀都相同的连续的IP地址组成一个“CIDR地址块”,IP地址分配都以CIDR地址块为单位。</span></p></li><li><p><span>网际控制报文协议是IP层的协议.ICMP报文作为IP数据报的数据,加上首部后组成IP数据报发送出去。使用ICMP数据报并不是为了实现可靠传输。ICMP允许主机或路由器报告差错情况和提供有关异常情况的报告。ICMP报文的种类有两种 ICMP差错报告报文和ICMP询问报文。</span></p></li><li><p><span>要解决IP地址耗尽的问题,最根本的办法是采用具有更大地址空间的新版本IP协议-IPv6。IPv6所带来的变化有①更大的地址空间(采用128位地址)②灵活的首部格式③改进的选项④支持即插即用⑤支持资源的预分配⑥IPv6的首部改为8字节对齐。另外IP数据报的目的地址可以是以下三种基本类型地址之一:单播,多播和任播</span></p></li><li><p><span>虚拟专用网络VPN利用公用的互联网作为本机构专用网之间的通信载体。VPN内使用互联网的专用地址。一个VPN至少要有一个路由器具有合法的全球IP地址,这样才能和本系统的另一个VPN通过互联网进行通信。所有通过互联网传送的数据都需要加密</span></p></li><li><p><span>MPLS的特点是:①支持面向连接的服务质量②支持流量工程,平衡网络负载③有效的支持虚拟专用网VPN。MPLS在入口节点给每一个IP数据报打上固定长度的“标记”,然后根据标记在第二层(链路层)用硬件进行转发(在标记交换路由器中进行标记交换),因而转发速率大大加快。</span></p></li><li><h5><a name="虚拟互联网络的概念" class="md-header-anchor"></a><span>虚拟互联网络的概念</span></h5></li><li><h5><a name="ip地址和物理地址的关系" class="md-header-anchor"></a><span>IP地址和物理地址的关系</span></h5></li><li><h5><a name="传统的分类的ip地址包括子网掩码)和无分类域间路由选择cidr" class="md-header-anchor"></a><span>传统的分类的IP地址(包括子网掩码)和无分类域间路由选择CIDR</span></h5></li><li><h5><a name="路由选择协议的工作原理" class="md-header-anchor"></a><span>路由选择协议的工作原理</span></h5></li><li><p><span>运输层提供应用进程之间的逻辑通信,也就是说,运输层之间的通信并不是真正在两个运输层之间直接传输数据。运输层向应用层屏蔽了下面网络的细节(如网络拓补,所采用的路由选择协议等),它使应用进程之间看起来好像两个运输层实体之间有一条端到端的逻辑通信信道。</span></p></li><li><p><span>网络层为主机提供逻辑通信,而运输层为应用进程之间提供端到端的逻辑通信。</span></p></li><li><p><span>运输层的两个重要协议是用户数据报协议UDP和传输控制协议TCP。按照OSI的术语,两个对等运输实体在通信时传送的数据单位叫做运输协议数据单元TPDU(Transport Protocol Data Unit)。但在TCP/IP体系中,则根据所使用的协议是TCP或UDP,分别称之为TCP报文段或UDP用户数据报。</span></p></li><li><p><span>UDP在传送数据之前不需要先建立连接,远地主机在收到UDP报文后,不需要给出任何确认。虽然UDP不提供可靠交付,但在某些情况下UDP确是一种最有效的工作方式。 TCP提供面向连接的服务。在传送数据之前必须先建立连接,数据传送结束后要释放连接。TCP不提供广播或多播服务。由于TCP要提供可靠的,面向连接的传输服务,这一难以避免增加了许多开销,如确认,流量控制,计时器以及连接管理等。这不仅使协议数据单元的首部增大很多,还要占用许多处理机资源。</span></p></li><li><p><span>硬件端口是不同硬件设备进行交互的接口,而软件端口是应用层各种协议进程与运输实体进行层间交互的一种地址。UDP和TCP的首部格式中都有源端口和目的端口这两个重要字段。当运输层收到IP层交上来的运输层报文时,就能够 根据其首部中的目的端口号把数据交付应用层的目的应用层。(两个进程之间进行通信不光要知道对方IP地址而且要知道对方的端口号(为了找到对方计算机中的应用进程))</span></p></li><li><p><span>运输层用一个16位端口号标志一个端口。端口号只有本地意义,它只是为了标志计算机应用层中的各个进程在和运输层交互时的层间接口。在互联网的不同计算机中,相同的端口号是没有关联的。协议端口号简称端口。虽然通信的终点是应用进程,但只要把所发送的报文交到目的主机的某个合适端口,剩下的工作(最后交付目的进程)就由TCP和UDP来完成。</span></p></li><li><p><span>运输层的端口号分为服务器端使用的端口号(0~1023指派给熟知端口,1024~49151是登记端口号)和客户端暂时使用的端口号(49152~65535)</span></p></li><li><p><span>UDP的主要特点是①无连接②尽最大努力交付③面向报文④无拥塞控制⑤支持一对一,一对多,多对一和多对多的交互通信⑥首部开销小(只有四个字段:源端口,目的端口,长度和检验和)</span></p></li><li><p><span>TCP的主要特点是①面向连接②每一条TCP连接只能是一对一的③提供可靠交付④提供全双工通信⑤面向字节流</span></p></li><li><p><span>TCP用主机的IP地址加上主机上的端口号作为TCP连接的端点。这样的端点就叫做套接字(socket)或插口。套接字用(IP地址:端口号)来表示。每一条TCP连接唯一被通信两端的两个端点所确定。</span></p></li><li><p><span>停止等待协议是为了实现可靠传输的,它的基本原理就是每发完一个分组就停止发送,等待对方确认。在收到确认后再发下一个分组。</span></p></li><li><p><span>为了提高传输效率,发送方可以不使用低效率的停止等待协议,而是采用流水线传输。流水线传输就是发送方可连续发送多个分组,不必每发完一个分组就停下来等待对方确认。这样可使信道上一直有数据不间断的在传送。这种传输方式可以明显提高信道利用率。</span></p></li><li><p><span>停止等待协议中超时重传是指只要超过一段时间仍然没有收到确认,就重传前面发送过的分组(认为刚才发送过的分组丢失了)。因此每发送完一个分组需要设置一个超时计时器,其重转时间应比数据在分组传输的平均往返时间更长一些。这种自动重传方式常称为自动重传请求ARQ。另外在停止等待协议中若收到重复分组,就丢弃该分组,但同时还要发送确认。连续ARQ协议可提高信道利用率。发送维持一个发送窗口,凡位于发送窗口内的分组可连续发送出去,而不需要等待对方确认。接收方一般采用累积确认,对按序到达的最后一个分组发送确认,表明到这个分组位置的所有分组都已经正确收到了。</span></p></li><li><p><span>TCP报文段的前20个字节是固定的,后面有4n字节是根据需要增加的选项。因此,TCP首部的最小长度是20字节。</span></p></li><li><p><span>TCP使用滑动窗口机制。发送窗口里面的序号表示允许发送的序号。发送窗口后沿的后面部分表示已发送且已收到确认,而发送窗口前沿的前面部分表示不允许发送。发送窗口后沿的变化情况有两种可能,即不动(没有收到新的确认)和前移(收到了新的确认)。发送窗口的前沿通常是不断向前移动的。一般来说,我们总是希望数据传输更快一些。但如果发送方把数据发送的过快,接收方就可能来不及接收,这就会造成数据的丢失。所谓流量控制就是让发送方的发送速率不要太快,要让接收方来得及接收。</span></p></li><li><p><span>在某段时间,若对网络中某一资源的需求超过了该资源所能提供的可用部分,网络的性能就要变坏。这种情况就叫拥塞。拥塞控制就是为了防止过多的数据注入到网络中,这样就可以使网络中的路由器或链路不致过载。拥塞控制所要做的都有一个前提,就是网络能够承受现有的网络负荷。拥塞控制是一个全局性的过程,涉及到所有的主机,所有的路由器,以及与降低网络传输性能有关的所有因素。相反,流量控制往往是点对点通信量的控制,是个端到端的问题。流量控制所要做到的就是抑制发送端发送数据的速率,以便使接收端来得及接收。</span></p></li><li><p><span>为了进行拥塞控制,TCP发送方要维持一个拥塞窗口cwnd的状态变量。拥塞控制窗口的大小取决于网络的拥塞程度,并且动态变化。发送方让自己的发送窗口取为拥塞窗口和接收方的接受窗口中较小的一个。</span></p></li><li><p><span>TCP的拥塞控制采用了四种算法,即慢开始,拥塞避免,快重传和快恢复。在网络层也可以使路由器采用适当的分组丢弃策略(如主动队列管理AQM),以减少网络拥塞的发生。</span></p></li><li><p><span>运输连接的三个阶段,即:连接建立,数据传送和连接释放。</span></p></li><li><p><span>主动发起TCP连接建立的应用进程叫做客户,而被动等待连接建立的应用进程叫做服务器。TCP连接采用三报文握手机制。服务器要确认用户的连接请求,然后客户要对服务器的确认进行确认。</span></p></li><li><p><span>TCP的连接释放采用四报文握手机制。任何一方都可以在数据传送结束后发出连接释放的通知,待对方确认后进入半关闭状态。当另一方也没有数据再发送时,则发送连接释放通知,对方确认后就完全关闭了TCP连接</span></p></li><li><h5><a name="端口和套接字的意义" class="md-header-anchor"></a><span>端口和套接字的意义</span></h5></li><li><h5><a name="无连接udp的特点" class="md-header-anchor"></a><span>无连接UDP的特点</span></h5></li><li><h5><a name="面向连接tcp的特点" class="md-header-anchor"></a><span>面向连接TCP的特点</span></h5></li><li><h5><a name="在不可靠的网络上实现可靠传输的工作原理停止等待协议和arq协议" class="md-header-anchor"></a><span>在不可靠的网络上实现可靠传输的工作原理,停止等待协议和ARQ协议</span></h5></li><li><h5><a name="tcp的滑动窗口流量控制拥塞控制和连接管理" class="md-header-anchor"></a><span>TCP的滑动窗口,流量控制,拥塞控制和连接管理</span></h5></li><li><p><span>文件传输协议(FTP)使用TCP可靠的运输服务。FTP使用客户服务器方式。一个FTP服务器进程可以同时为多个用户提供服务。在进进行文件传输时,FTP的客户和服务器之间要先建立两个并行的TCP连接:控制连接和数据连接。实际用于传输文件的是数据连接。</span></p></li><li><p><span>万维网客户程序与服务器之间进行交互使用的协议是超文本传输协议HTTP。HTTP使用TCP连接进行可靠传输。但HTTP本身是无连接、无状态的。HTTP/1.1协议使用了持续连接(分为非流水线方式和流水线方式)</span></p></li><li><p><span>电子邮件把邮件发送到收件人使用的邮件服务器,并放在其中的收件人邮箱中,收件人可随时上网到自己使用的邮件服务器读取,相当于电子邮箱。一个电子邮件系统有三个重要组成构件:用户代理、邮件服务器、邮件协议(包括邮件发送协议,如SMTP,和邮件读取协议,如POP3和IMAP)。用户代理和邮件服务器都要运行这些协议。</span></p></li><li><h5><a name="域名系统-从域名解析出ip地址" class="md-header-anchor"></a><span>域名系统-从域名解析出IP地址</span></h5></li><li><h5><a name="访问一个网站大致的过程" class="md-header-anchor"></a><span>访问一个网站大致的过程</span></h5></li><li><h5><a name="系统调用和应用编程接口概念" class="md-header-anchor"></a><span>系统调用和应用编程接口概念</span></h5><p>&nbsp;</p></li></ol><h2><a name="二tcpip协议" class="md-header-anchor"></a><span>二、TCP/IP协议</span></h2><p><span>在互联网使用的各种协中最重要和最著名的就是 TCP/IP 两个协议。现在人们经常提到的TCP/IP并不一定单指TCP和IP这两个具体的协议,而往往表示互联网所使用的整个TCP/IP协议族。</span></p><p><span>上面我们对计算机网络的五层体系结构有了初步的了解,下面附送一张七层体系结构图总结一下(图片来源于网络)。</span></p><p><img src="images/七层体系结构图.png" referrerpolicy="no-referrer" alt="七层体系结构图"></p><p>&nbsp;</p><h3><a name="tcp-三次握手和四次挥手概念" class="md-header-anchor"></a><span>TCP 三次握手和四次挥手概念</span></h3><p><span>为了准确无误地把数据送达目标处,TCP协议采用了三次握手策略。</span></p><h4><a name="tcp-三次握手漫画图解" class="md-header-anchor"></a><span>TCP 三次握手漫画图解</span></h4><p><span>如下图所示,下面的两个机器人通过3次握手确定了对方能正确接收和发送消息(图片来源:《图解HTTP》)。</span>
<img src="images/三次握手.png" referrerpolicy="no-referrer" alt="TCP三次握手"></p><p><strong><span>简单示意图:</span></strong>
<img src="images/三次握手2.png" referrerpolicy="no-referrer" alt="TCP三次握手"></p><ul><li><span>客户端–发送带有 SYN 标志的数据包–一次握手–服务端</span></li><li><span>服务端–发送带有 SYN/ACK 标志的数据包–二次握手–客户端</span></li><li><span>客户端–发送带有带有 ACK 标志的数据包–三次握手–服务端</span></li></ul><p>&nbsp;</p><h4><a name="三次握手" class="md-header-anchor"></a><span>三次握手</span></h4><ul><li><strong><span>第一次握手</span></strong><span>:客户机首先向服务器的TCP发送一个连接请求报文段,这个特殊的报文段不含应用层数据,其首部中同步位SYN被设置为1。另外,客户机会随机选择一个起始序号seq=x(连接请求报文不携带数据,但要消耗一个序号);</span></li><li><strong><span>第二次握手</span></strong><span>:服务器的TCP收到连接请求报文段后,如果同意建立连接,就向客户机发回确认,并为该TCP连接分配TCP缓存和变量。在确认报文段中,SYN和ACK位都被设置为1,确认号字段值为ack=x+1,并且服务器随机产生起始序号seq=y. 确认包同样不包含应用层数据。</span></li><li><strong><span>第三次握手</span></strong><span>:当客户机收到确认报文段后,还要向服务器给出确认,并且也要给该连接</span><strong><span>分配缓存和变量</span></strong><span>。这个报文段的确认位ACK被设置为1,序号段被设置为seq=x+1,确认号字段ack=y+1. 该报文段可以携带数据,如果不携带数据则不消耗序号。</span></li></ul><p><span>理想状态下,TCP连接一旦建立,在通信双方中的任何一方主动关闭连接之前,TCP 连接都将被一直保持下去。因为TCP提供全双工通信,因此双方任何时候都可以发送数据。</span></p><h4><a name="四次挥手" class="md-header-anchor"></a><span>四次挥手</span></h4><ul><li><strong><span>第一次挥手</span></strong><span>:客户机打算关闭连接,就向其TCP发送一个连接释放报文,并停止再发送数据,主动关闭TCP连接。该报文段的结束标志位FIN被设置为1,seq=u,它等于前面已经发送过的数据的最后一个字节的序号加1。</span></li><li><strong><span>第二次挥手</span></strong><span>:服务器收到连接释放报文段后即发出确认,确认号是ack=u+1,序号为v,等于它前面已经发送过的数据的最后一个字节序号加1.此时客户机到服务器这个方向的连接就释放了,TCP处于半关闭状态。ACK=1,seq=v,ack=u+1</span></li><li><strong><span>第三次挥手</span></strong><span>:若服务器已经没有要向客户机发送的数据,就通知TCP释放连接,此时发出FIN=1,确认号ack=u+1,序号seq=w,已经发送过的数据最后一个字节加1。确认为ACK=1.(FIN=1, ACK=1, seq=w, ack=u+1) </span></li><li><strong><span>第四次挥手</span></strong><span>:客户机收到连接释放报文段后,必须发出确认。在确认报文段中,确认位ACK=1,序号seq=u+1,确认号ack=w+1. 此时连接还没有释放掉,必须经过时间等待计时器设置的时间2MSL(Max Segment Lifetime),后,客户机才进入连接关闭状态。(ACK=1,seq=u+1,ack=w+1)</span></li></ul><h3><a name="tcp常见问题" class="md-header-anchor"></a><span>TCP常见问题</span></h3><h4><a name="为什么要三次握手" class="md-header-anchor"></a><span>为什么要三次握手</span></h4><p><strong><span>三次握手的目的是建立可靠的通信信道,说到通讯,简单来说就是数据的发送与接收,而三次握手最主要的目的就是双方确认自己与对方的发送与接收是正常的。</span></strong></p><p><span>第一次握手:Client 什么都不能确认;Server 确认了对方发送正常,自己接收正常</span></p><p><span>第二次握手:Client 确认了:自己发送、接收正常,对方发送、接收正常;Server 确认了:对方发送正常,自己接收正常</span></p><p><span>第三次握手:Client 确认了:自己发送、接收正常,对方发送、接收正常;Server 确认了:自己发送、接收正常,对方发送、接收正常</span></p><p><span>所以三次握手就能确认双发收发功能都正常,缺一不可。</span></p><h4><a name="为什么会采用三次握手若采用二次握手可以吗" class="md-header-anchor"></a><span>为什么会采用三次握手,若采用二次握手可以吗?</span></h4><p><span>采用三次握手是为了防止失效的连接请求报文段再次传到服务器,因而产生错误。如果由于网络不稳定,虽然客户端以前发送的连接请求以到达服务方,但服务方的同意连接的应答未能到达客户端。则客户方要重新发送连接请求,若采用二次握手,服务方收到客服端重传的请求连接后,会以为是新的请求,就会发送同意连接报文,并新开进程提供服务,这样会造成服务方资源的无谓浪费。</span></p><p><strong><span>如果只采用一次的话,客户端不知道服务端是否已经收到自己发送的数据,则会不断地发送数据。为了保证服务端能收接受到客户端的信息并能做出正确的应答而进行前两次(第一次和第二次)握手,为了保证客户端能够接收到服务端的信息并能做出正确的应答而进行后两次(第二次和第三次)握手</span></strong><span>。</span></p><h4><a name="为什么要四次挥手" class="md-header-anchor"></a><span>为什么要四次挥手</span></h4><p><img src="images/TCP四次挥手.png" referrerpolicy="no-referrer" alt="TCP四次挥手"></p><p><span>断开一个 TCP 连接则需要“四次挥手”:</span></p><ul><li><span>客户端-发送一个 FIN,用来关闭客户端到服务器的数据传送</span></li><li><span>服务器-收到这个 FIN,它发回一 个 ACK,确认序号为收到的序号加1 。和 SYN 一样,一个 FIN 将占用一个序号</span></li><li><span>服务器-关闭与客户端的连接,发送一个FIN给客户端</span></li><li><span>客户端-发回 ACK 报文确认,并将确认序号设置为收到序号加1</span></li></ul><p><span>任何一方都可以在数据传送结束后发出连接释放的通知,待对方确认后进入半关闭状态。当另一方也没有数据再发送的时候,则发出连接释放通知,对方确认后就完全关闭了TCP连接。</span></p><p><span>举个例子:A 和 B 打电话,通话即将结束后,A 说“我没啥要说的了”,B回答“我知道了”,但是 B 可能还会有要说的话,A 不能要求 B 跟着自己的节奏结束通话,于是 B 可能又巴拉巴拉说了一通,最后 B 说“我说完了”,A 回答“知道了”,这样通话才算结束。</span></p><h4><a name="第2次握手传回了ack为什么还要传回syn" class="md-header-anchor"></a><span>第2次握手传回了ACK,为什么还要传回SYN?</span></h4><p><span>接收端传回发送端所发送的ACK是为了告诉客户端,我接收到的信息确实就是你所发送的信号了,这表明从客户端到服务端的通信是正常的。而回传SYN则是为了建立并确认从服务端到客户端的通信。”</span></p><blockquote><p><span>SYN 同步序列编号(Synchronize Sequence Numbers) 是 TCP/IP 建立连接时使用的握手信号。在客户机和服务器之间建立正常的 TCP 网络连接时,客户机首先发出一个 SYN 消息,服务器使用 SYN-ACK 应答表示接收到了这个消息,最后客户机再以 ACK(Acknowledgement)消息响应。这样在客户机和服务器之间才能建立起可靠的 TCP 连接,数据才可以在客户机和服务器之间传递。</span></p></blockquote><h4><a name="为什么tcp客户端最后还要发送一次确认呢" class="md-header-anchor"></a><span>为什么TCP客户端最后还要发送一次确认呢?</span></h4><p><strong><span>一句话,主要防止已经失效的连接请求报文突然又传送到了服务器,从而产生错误。</span></strong></p><p><span>如果使用的是两次握手建立连接,假设有这样一种场景,客户端发送了第一个请求连接并且没有丢失,只是因为在网络结点中滞留的时间太长了,由于TCP的客户端迟迟没有收到确认报文,以为服务器没有收到,此时重新向服务器发送这条报文,此后客户端和服务器经过两次握手完成连接,传输数据,然后关闭连接。此时此前滞留的那一次请求连接,网络通畅了到达了服务器,这个报文本该是失效的,但是,两次握手的机制将会让客户端和服务器再次建立连接,这将导致不必要的错误和资源的浪费。</span></p><p><span>如果采用的是三次握手,就算是那一次失效的报文传送过来了,服务端接受到了那条失效报文并且回复了确认报文,但是客户端不会再次发出确认。由于服务器收不到确认,就知道客户端并没有请求连接。</span></p><h4><a name="为什么客户端最后还要等待2msl才关闭连接" class="md-header-anchor"></a><span>为什么客户端最后还要等待2MSL才关闭连接?</span></h4><p><span>MSL(Maximum Segment Lifetime)报文最大生存时间(Windows : MSL = 2 min,Linux(Ubuntu, CentOs) : MSL = 60s,Unix : MSL = 30s),TCP允许不同的实现可以设置不同的MSL值。</span></p><p><span>第一,确保客户端发送的最后一个ACK报文能够到达服务器。因为这个ACK报文可能丢失,站在服务器的角度看来,我已经发送了FIN+ACK报文请求断开了,客户端还没有给我回应,应该是我发送的请求断开报文它没有收到,于是服务器又会重新发送一次,而客户端就能在这个2MSL时间段内收到这个重传的报文,接着给出回应报文,并且会重启2MSL计时器。</span></p><p><span>第二,确保TCP协议的全双工连接能够可靠关闭。如果Client直接CLOSED了,那么由于IP协议的不可靠性或者是其它网络原因,导致Server没有收到Client最后回复的ACK。那么Server就会在超时之后继续发送FIN,此时由于Client已经CLOSED了,就找不到与重发的FIN对应的连接,最后Server就会收到RST而不是ACK,Server就会以为是连接错误把问题报告给高层。所以,Client不是直接进入CLOSED,而是要保持2MSL,如果在这个时间内又收到了server的关闭请求时可以进行重传,否则说明server已经受到确认包则可以关闭。</span></p><p><span>第三,防止类似与“三次握手”中提到了的“已经失效的连接请求报文段”出现在本连接中。客户端发送完最后一个确认报文后,在这个2MSL时间中,就可以使本连接持续的时间内所产生的所有报文段都从网络中消失。这样新的连接中不会出现旧连接的请求报文。</span></p><h4><a name="为什么建立连接是三次握手关闭连接确是四次挥手呢" class="md-header-anchor"></a><span>为什么建立连接是三次握手,关闭连接确是四次挥手呢?</span></h4><p><span>建立连接的时候, 服务器在LISTEN状态下,收到建立连接请求的SYN报文后,把ACK和SYN放在一个报文里发送给客户端。</span>
<span>而关闭连接时,服务器收到对方的FIN报文时,仅仅表示对方不再发送数据了但是还能接收数据,而自己也未必全部数据都发送给对方了,所以己方可以立即关闭,也可以发送一些数据给对方后,再发送FIN报文给对方来表示同意现在关闭连接,因此,己方ACK和FIN一般都会分开发送,从而导致多了一次。</span></p><p><span>上面讲的比较概括,推荐一篇讲的比较细致的文章:</span><a href='https://blog.csdn.net/qzcsu/article/details/72861891'><span>https://blog.csdn.net/qzcsu/article/details/72861891</span></a></p><h3><a name="tcp拥塞控制" class="md-header-anchor"></a><span>TCP拥塞控制</span></h3><p><span>为了更好对TCP进行拥塞控制,因特网建议标准定义了以下四种算法:</span><strong><span>慢开始,拥塞避免,快重传,快恢复</span></strong><span>。</span>
<span>首先在TCP要求发送端维护两个窗口:</span></p><ul><li><strong><span>接收窗口 rwnd</span></strong><span>: 接收方根据当前缓存大小所许诺的最新窗口值.</span></li><li><strong><span>拥塞窗口 cwnd</span></strong><span>: 发送方根据自己估算的网络拥塞程度而设置的窗口值。</span></li></ul><p><span>发送窗口的上限是取这两者(接收窗口、拥塞窗口)的最小值。</span></p><ul><li><strong><span>慢开始</span></strong><span>: TCP刚连接好时,先令拥塞窗口cwnd =1 ,在每次收到一个对新报文段的确认时将cwnd加1(因此是成倍增长2的n次方). Cwnd的大小呈指数增长。</span></li><li><strong><span>拥塞避免算法</span></strong><span>: 当cwnd大于等于慢开始门限</span><strong><span>ssthresh</span></strong><span>时,cwnd窗口每次加1而不是加倍。当发送方检测到</span><strong><span>超时事件</span></strong><span>的发生时,</span><strong><span>就将慢开始门限ssthresh设置为当前cwnd的一半,同时将cwnd设置为1</span></strong><span>. 这样的目的是迅速减少主机发送到网络的分组数,使得发生拥塞的路由器有足够的时间吧队列中积压的分组处理完毕。</span></li><li><strong><span>快重传</span></strong><span>:当发送方连续收到</span><strong><span>三个重复的ACK报文时</span></strong><span>,就立即进行重传。直接重传对方尚未收到的报文段,而不必等待那个报文段设置的重传计时器超时。</span></li><li><strong><span>快恢复</span></strong><span>:当发送端收到连续三个冗余的ACK时,发送端调整门限值 </span><strong><span>cwnd = ssthresh = cwnd / 2</span></strong><span>, 即发送端口、阈值都等于当前窗口的一半。</span></li></ul><h3><a name="tcp滑动窗口与回退n针协议" class="md-header-anchor"></a><span>TCP滑动窗口与回退N针协议</span></h3><h4><a name="滑动窗口" class="md-header-anchor"></a><span>滑动窗口</span></h4><p><span>发送方都维持一组连续的允许发送的帧的序号称为</span><strong><span>发送窗口</span></strong><span>。同时接收方也维持一组连续的允许接收的帧序号,称为</span><strong><span>接收窗口</span></strong><span>。发送窗口是用来对发送方进行流量控制,接收窗口是用来控制接收那些数据帧不可以接收那些帧。</span></p><p><span>在发送端,收到一个确认帧,发送窗口就向前滑动一个帧位置,当发送窗口没有可以发送的帧时,发送方就停止发送。直到接收方发送的确认帧使发送窗口向前移动。</span></p><p><span>在接收端,只有收到数据帧的序号落在接收窗口内才将该帧收下,否则一律丢弃。每收到一个帧后就发送回确认帧。</span></p><h4><a name="后退n帧协议" class="md-header-anchor"></a><span>后退N帧协议</span></h4><p><span>发送窗口大于1,接收窗口等于1.在后退N帧中,发送方不需要收到上一帧的ACK后才能发送下一帧,而是可以连续发送帧。</span></p><p><span>当接收方检测出失序信息帧后,要求发送方重发最后一个正确接收的帧之后的所有未被确认的帧。源站每发完一帧就要为该帧设置超时计时器,如果在超时时间内没有收到确认帧则进行重发。服务端会采用累积确认的方式,不是每个帧都发确认,可以连续收到好几个正确帧后发回一个确认信息。接收方因为窗口为1,所以必须按序接收数据帧,如果某个序大于当前所期望的序号时就会连续发送3个ACK确认帧,要求客户端重传失序帧。</span></p><h3><a name="tcp的可靠性如何保证" class="md-header-anchor"></a><span>TCP的可靠性如何保证</span></h3><p><span>在TCP的连接中,数据流必须以正确的顺序送达对方。TCP的可靠性是通过确认机制来保证 安全的到达,即采用顺序编号、确认(ACK)、超时重传等来实现的。TCP在开始传送一个段时,为准备重传而首先将该段插入到发送队列之中,同时启动时钟。其后,如果收到了接受端对该段的ACK信息,就将该段从队列中删去。如果在时钟规定的时间内,ACK未返回,那么就从发送队列中再次送出这个段。TCP在协议中就对数据可靠传输做了保障,握手与断开都需要通讯双方确认,数据传输也需要双方确认成功,在协议中还规定了:分包、重组、重传等规则;而UDP主要是面向不可靠连接的,不能保证数据正确到达目的地。 </span></p><h3><a name="tcpudp-协议的区别" class="md-header-anchor"></a><span>TCP,UDP 协议的区别</span></h3><p><img src="images/tcp-vs-udp.jpg" referrerpolicy="no-referrer" alt="TCP、UDP协议的区别"></p><p><span>UDP 在传送数据之前不需要先建立连接,远地主机在收到 UDP 报文后,不需要给出任何确认。虽然 UDP 不提供可靠交付,但在某些情况下 UDP 确是一种最有效的工作方式(一般用于即时通信),比如: QQ 语音、 QQ 视频 、直播等等</span></p><p><span>TCP 提供面向连接的服务。在传送数据之前必须先建立连接,数据传送结束后要释放连接。 TCP 不提供广播或多播服务。由于 TCP 要提供可靠的,面向连接的传输服务(TCP的可靠体现在TCP在传递数据之前,会有三次握手来建立连接,而且在数据传递时,有确认、窗口、重传、拥塞控制机制,在数据传完后,还会断开连接用来节约系统资源),这一难以避免增加了许多开销,如确认,流量控制,计时器以及连接管理等。这不仅使协议数据单元的首部增大很多,还要占用许多处理机资源。TCP 一般用于文件传输、发送和接收邮件、远程登录等场景。</span></p><h4><a name="tcp与udp区别" class="md-header-anchor"></a><span>TCP与UDP区别:</span></h4><ol start='' ><li><span>TCP面向连接(如打电话要先拨号建立连接);UDP是无连接的,即发送数据之前不需要建立连接。</span></li><li><span>TCP提供可靠</span><strong><span>全双功</span></strong><span>的通信服务。UDP是半双功,只能单向传播。</span></li><li><span>TCP提供可靠的服务。也就是说,通过TCP连接传送的数据,无差错,不丢失,不重复,且按序到达;UDP尽最大努力交付,即不保证可靠交付。</span></li><li><span>TCP面向字节流,实际上是TCP把数据看成一连串无结构的字节流;UDP是面向报文的 UDP没有拥塞控制,因此网络出现拥塞不会使源主机的发送速率降低(对实时应用很有用,如IP电话,实时视频会议等)。</span></li><li><span>每一条TCP连接只能是点到点的;UDP支持一对一,一对多,多对一和多对多的交互通信。</span></li><li><span>TCP首部开销20字节;UDP的首部开销小,只有8个字节。</span></li><li><span>TCP的逻辑通信信道是全双工的可靠信道,UDP则是不可靠信道。</span></li></ol><h3><a name="tcp-协议如何保证可靠传输" class="md-header-anchor"></a><span>TCP 协议如何保证可靠传输</span></h3><p><span>在TCP的连接中,数据流必须以正确的顺序送达对方。TCP的可靠性是通过确认机制来保证 安全的到达,即采用顺序编号、确认(ACK)、超时重传等来实现的。TCP在开始传送一个段时,为准备重传而首先将该段插入到发送队列之中,同时启动时钟。其后,如果收到了接受端对该段的ACK信息,就将该段从队列中删去。如果在时钟规定的时间内,ACK未返回,那么就从发送队列中再次送出这个段。TCP在协议中就对数据可靠传输做了保障,握手与断开都需要通讯双方确认,数据传输也需要双方确认成功,在协议中还规定了:分包、重组、重传等规则;而UDP主要是面向不可靠连接的,不能保证数据正确到达目的地。</span></p><ol start='' ><li><span>应用数据被分割成 TCP 认为最适合发送的数据块。 </span></li><li><span>TCP 给发送的每一个包进行编号,接收方对数据包进行排序,把有序数据传送给应用层。 </span></li><li><strong><span>校验和:</span></strong><span> TCP 将保持它首部和数据的检验和。这是一个端到端的检验和,目的是检测数据在传输过程中的任何变化。如果收到段的检验和有差错,TCP 将丢弃这个报文段和不确认收到此报文段。 </span></li><li><span>TCP 的接收端会丢弃重复的数据。 </span></li><li><strong><span>流量控制:</span></strong><span> TCP 连接的每一方都有固定大小的缓冲空间,TCP的接收端只允许发送端发送接收端缓冲区能接纳的数据。当接收方来不及处理发送方的数据,能提示发送方降低发送的速率,防止包丢失。TCP 使用的流量控制协议是可变大小的滑动窗口协议。 (TCP 利用滑动窗口实现流量控制)</span></li><li><strong><span>拥塞控制:</span></strong><span> 当网络拥塞时,减少数据的发送。</span></li><li><strong><span>ARQ协议:</span></strong><span> 也是为了实现可靠传输的,它的基本原理就是每发完一个分组就停止发送,等待对方确认。在收到确认后再发下一个分组。</span></li><li><strong><span>超时重传:</span></strong><span> 当 TCP 发出一个段后,它启动一个定时器,等待目的端确认收到这个报文段。如果不能及时收到一个确认,将重发这个报文段。 </span></li></ol><h4><a name="41-arq协议" class="md-header-anchor"></a><span>4.1 ARQ协议</span></h4><p><strong><span>自动重传请求</span></strong><span>(Automatic Repeat-reQuest,ARQ)是OSI模型中数据链路层和传输层的错误纠正协议之一。它通过使用确认和超时这两个机制,在不可靠服务的基础上实现可靠的信息传输。如果发送方在发送后一段时间之内没有收到确认帧,它通常会重新发送。ARQ包括停止等待ARQ协议和连续ARQ协议。</span></p><h4><a name="停止等待arq协议" class="md-header-anchor"></a><span>停止等待ARQ协议</span></h4><ul><li><span>停止等待协议是为了实现可靠传输的,它的基本原理就是每发完一个分组就停止发送,等待对方确认(回复ACK)。如果过了一段时间(超时时间后),还是没有收到 ACK 确认,说明没有发送成功,需要重新发送,直到收到确认后再发下一个分组;</span></li><li><span>在停止等待协议中,若接收方收到重复分组,就丢弃该分组,但同时还要发送确认;</span></li></ul><p><strong><span>优点:</span></strong><span> 简单</span></p><p><strong><span>缺点:</span></strong><span> 信道利用率低,等待时间长</span></p><p><strong><span>1) 无差错情况:</span></strong></p><p><span>发送方发送分组,接收方在规定时间内收到,并且回复确认.发送方再次发送。</span></p><p><strong><span>2) 出现差错情况(超时重传):</span></strong></p><p><span>停止等待协议中超时重传是指只要超过一段时间仍然没有收到确认,就重传前面发送过的分组(认为刚才发送过的分组丢失了)。因此每发送完一个分组需要设置一个超时计时器,其重传时间应比数据在分组传输的平均往返时间更长一些。这种自动重传方式常称为 </span><strong><span>自动重传请求 ARQ</span></strong><span> 。另外在停止等待协议中若收到重复分组,就丢弃该分组,但同时还要发送确认。</span><strong><span>连续 ARQ 协议</span></strong><span> 可提高信道利用率。发送维持一个发送窗口,凡位于发送窗口内的分组可连续发送出去,而不需要等待对方确认。接收方一般采用累积确认,对按序到达的最后一个分组发送确认,表明到这个分组位置的所有分组都已经正确收到了。</span></p><p><strong><span>3) 确认丢失和确认迟到</span></strong></p><ul><li><strong><span>确认丢失</span></strong><span> :确认消息在传输过程丢失。当A发送M1消息,B收到后,B向A发送了一个M1确认消息,但却在传输过程中丢失。而A并不知道,在超时计时过后,A重传M1消息,B再次收到该消息后采取以下两点措施:1. 丢弃这个重复的M1消息,不向上层交付。 2. 向A发送确认消息。(不会认为已经发送过了,就不再发送。A能重传,就证明B的确认消息丢失)。</span></li><li><strong><span>确认迟到</span></strong><span> :确认消息在传输过程中迟到。A发送M1消息,B收到并发送确认。在超时时间内没有收到确认消息,A重传M1消息,B仍然收到并继续发送确认消息(B收到了2份M1)。此时A收到了B第二次发送的确认消息。接着发送其他数据。过了一会,A收到了B第一次发送的对M1的确认消息(A也收到了2份确认消息)。处理如下:1. A收到重复的确认后,直接丢弃。2. B收到重复的M1后,也直接丢弃重复的M1。</span></li></ul><h5><a name="连续arq协议" class="md-header-anchor"></a><span>连续ARQ协议</span></h5><p><span>连续 ARQ 协议可提高信道利用率。发送方维持一个发送窗口,凡位于发送窗口内的分组可以连续发送出去,而不需要等待对方确认。接收方一般采用累计确认,对按序到达的最后一个分组发送确认,表明到这个分组为止的所有分组都已经正确收到了。</span></p><p><strong><span>优点:</span></strong><span> 信道利用率高,容易实现,即使确认丢失,也不必重传。</span></p><p><strong><span>缺点:</span></strong><span> 不能向发送方反映出接收方已经正确收到的所有分组的信息。 比如:发送方发送了 5条 消息,中间第三条丢失(3号),这时接收方只能对前两个发送确认。发送方无法知道后三个分组的下落,而只好把后三个全部重传一次。这也叫 Go-Back-N(回退 N),表示需要退回来重传已经发送过的 N 个消息。</span></p><h4><a name="42-滑动窗口和流量控制" class="md-header-anchor"></a><span>4.2 滑动窗口和流量控制</span></h4><p><strong><span>TCP 利用滑动窗口实现流量控制。流量控制是为了控制发送方发送速率,保证接收方来得及接收。</span></strong><span> 接收方发送的确认报文中的窗口字段可以用来控制发送方窗口大小,从而影响发送方的发送速率。将窗口字段设置为 0,则发送方不能发送数据。</span></p><h4><a name="43-拥塞控制" class="md-header-anchor"></a><span>4.3 拥塞控制</span></h4><p><span>在某段时间,若对网络中某一资源的需求超过了该资源所能提供的可用部分,网络的性能就要变坏。这种情况就叫拥塞。拥塞控制就是为了防止过多的数据注入到网络中,这样就可以使网络中的路由器或链路不致过载。拥塞控制所要做的都有一个前提,就是网络能够承受现有的网络负荷。拥塞控制是一个全局性的过程,涉及到所有的主机,所有的路由器,以及与降低网络传输性能有关的所有因素。相反,流量控制往往是点对点通信量的控制,是个端到端的问题。流量控制所要做到的就是抑制发送端发送数据的速率,以便使接收端来得及接收。</span></p><p><span>为了进行拥塞控制,TCP 发送方要维持一个 </span><strong><span>拥塞窗口(cwnd)</span></strong><span> 的状态变量。拥塞控制窗口的大小取决于网络的拥塞程度,并且动态变化。发送方让自己的发送窗口取为拥塞窗口和接收方的接受窗口中较小的一个。</span></p><p><span>TCP的拥塞控制采用了四种算法,即 </span><strong><span>慢开始</span></strong><span> 、 </span><strong><span>拥塞避免</span></strong><span> 、</span><strong><span>快重传</span></strong><span> 和 </span><strong><span>快恢复</span></strong><span>。在网络层也可以使路由器采用适当的分组丢弃策略(如主动队列管理 AQM),以减少网络拥塞的发生。</span></p><ul><li><strong><span>慢开始:</span></strong><span> 慢开始算法的思路是当主机开始发送数据时,如果立即把大量数据字节注入到网络,那么可能会引起网络阻塞,因为现在还不知道网络的符合情况。经验表明,较好的方法是先探测一下,即由小到大逐渐增大发送窗口,也就是由小到大逐渐增大拥塞窗口数值。cwnd初始值为1,每经过一个传播轮次,cwnd加倍。</span></li><li><strong><span>拥塞避免:</span></strong><span> 拥塞避免算法的思路是让拥塞窗口cwnd缓慢增大,即每经过一个往返时间RTT就把发送放的cwnd加1.</span></li><li><strong><span>快重传与快恢复:</span></strong>
<span>在 TCP/IP 中,快速重传和恢复(fast retransmit and recovery,FRR)是一种拥塞控制算法,它能快速恢复丢失的数据包。没有 FRR,如果数据包丢失了,TCP 将会使用定时器来要求传输暂停。在暂停的这段时间内,没有新的或复制的数据包被发送。有了 FRR,如果接收机接收到一个不按顺序的数据段,它会立即给发送机发送一个重复确认。如果发送机接收到三个重复确认,它会假定确认件指出的数据段丢失了,并立即重传这些丢失的数据段。有了 FRR,就不会因为重传时要求的暂停被耽误。  当有单独的数据包丢失时,快速重传和恢复(FRR)能最有效地工作。当有多个数据信息包在某一段很短的时间内丢失时,它则不能很有效地工作。</span></li></ul><p>&nbsp;</p><h2><a name="三http协议" class="md-header-anchor"></a><span>三、HTTP协议</span></h2><p><span>B/S结构(Browser/Server,浏览器/服务器模式),是WEB兴起后的一种网络结构模式,</span><a href='https://baike.baidu.com/item/WEB/150564'><span>WEB</span></a><span>浏览器是客户端最主要的应用软件。这种模式统一了客户端,将系统功能实现的核心部分集中到服务器上,简化了系统的开发、维护和使用。客户机上只要安装一个浏览器,如Netscape Navigator或Internet Explorer,服务器安装SQL Server、Oracle、MYSQL等数据库。浏览器通过Web Server 同数据库进行数据交互。</span></p><p><span>而服务器-客户机,即Client-Server(</span><a href='https://baike.baidu.com/item/C%2FS/826311'><span>C/S</span></a><span>)结构。C/S结构通常采取两层结构。服务器负责</span><a href='https://baike.baidu.com/item/数据/5947370'><span>数据</span></a><span>的管理,客户机负责完成与用户的交互任务。</span></p><p><span>随着Web2.0时代的到来,互联网的网络架构已经从传统的C/S架构转变为更加方便、快捷的B/S架构,B/S架构大大简化了用户使用网络应用的难度。</span></p><p><span>B/S架构带来了以下两方面的好处。</span></p><ul><li><span>客户端使用统一的浏览器( Browser)。由于浏览器具有统一性,它不需要特殊的配置和网络连接,有效地屏蔽了不同服务提供商提供给用户使用服务的差异性。另外,最重要的一点是,浏览器的交互特性使得用户使用它非常简便,且用户行为的可继承性非常强,也就是用户只要学会了上网,不管使用的是哪个应用,旦学会了,在使用其他互联网服务时同样具有了使用经验,因为它们都基于同样的浏览器操作界面。</span></li><li><span>服务端(Server)基于统一的HTTP。和传统的CS架构使用自定义的应用层协议不同,B/S架构使用的都是统一的HTTP。使用统一的HTTP也为服务提供商简化了开发模式,使得服务器开发者可以采用相对规范的开发模式,这样可以大大节省开发成本。由于使用统一的HTTP,所以基于HTTP的服务器就有很多,如 Apache、IS、 nginx、 Tomcat、 Jboss等,这些服务器可以直接拿来使用,不需要服务开发者单独来开发。不仅如此,连开发服务的通用框架都不需要单独开发,服务开发者只需要关注提供服务的应用逻辑,其他一切平台和框架都可以直接拿来使用,所以B/S架构同样简化了服务器提供者的开发,从而出现了越来越多的互联网服务。</span></li></ul><p><span>接下来,我们将围绕这一过程的工作原理,来讲解涉及浏览器的基本行为和HTTP的解析过程、DNS如何解析到对应的IP地址、CDN又是如何工作和设计的,以及浏览器如何渲染出返回的结果等。</span></p><h3><a name="bs网络架构概述" class="md-header-anchor"></a><span>B/S网络架构概述</span></h3><p><span>B/S网络架构从前端到后端都得到了简化,都基于统一的应用层协议HTTP来交互数据,与大多数传统CS互联网应用程序采用的长连接的交互模式不同,HTTP采用无状态的短连接的通信方式,通常情况下,一次请求就完成了一次数据交互,通常也对应一个业务逻辑,然后这次通信连接就断开了。采用这种方式是为了能够同时服务更多的用户,因为当前互联网应用每天都会处理上亿的用户请求,不可能每个用户访问一次后就一直保持这个连接。</span></p><p><span>基于HTTP本身的特点,目前的B/S网络架构大多采用下图所示的架构设计,既要满足海量用户的访问请求,又要保持用户请求的快速响应,所以现在的网络架构也越来越复杂。</span></p><p><span>当一个用户在浏览器里输入</span><a href='http://www.taobao.com' target='_blank' class='url'>www.taobao.com</a><span> 这个URL时,将会发生很多操作。首先它会请求DNS把这个域名解析成对应的IP地址,然后根据这个IP地址在互联网上找到对应的服务器,向这个服务器发起一个get请求,由这个服务器决定返回默认的数据资源给访问的用户。在服务器端实际上还有很复杂的业务逻辑:服务器可能有很多台,到底指定哪台服务器来处理请求,这需要一个负载均衡设备来平均分配所有用户的请求:还有请求的数据是存储在分布式缓存里还是一个静态文件中,或是在数据库里;当数据返回浏览器时,浏览器解析数据发现还有一些静态资源(如CSS、JS或者图片)时又会发起另外的HTTP请求,而这些请求很可能会在CDN上,那么CDN服务器又会处理这个用户的请求,大体上一个用户请求会涉及这么多的操作。每一个细节都会影响这个请求最终是否会成功。</span></p><p><img src="images/image-20210421142216089.png" referrerpolicy="no-referrer" alt="image-20210421142216089"></p><p><span>CND架构图</span></p><p><span>不管网络架构如何变化,始终有一些固定不变的原则需要遵守。</span></p><ul><li><span>互联网上所有资源都要用一个URL来表示。URL就是统一资源定位符,如果你要发布一个服务或者一个资源到互联网上,让别人能够访问到,那么你首先必须要有一个在世界上独一无二的URL。</span></li><li><span>必须基于HTTP与服务端交互。不管你要访问的是国内的还是国外的数据,是文本数据还是流媒体,都必须按照套路出牌,也就是都得采用统一打招呼的方式,这样人家才会明白你要的是什么。</span></li><li><span>数据展示必须在浏览器中进行。当你获取到数据资源后,必须在浏览器上才能恢复它的容貌。</span></li></ul><p><span>只要满足上面的几点,一个互联网应用基本上就能正确地运转起来了。</span></p><h3><a name="如何发起一个请求" class="md-header-anchor"></a><span>如何发起一个请求</span></h3><h4><a name="如何发起一个http请求" class="md-header-anchor"></a><span>如何发起一个HTTP请求?</span></h4><p><span>如何发起一个HTTP请求和如何建立一个Socket连接区别不大,只不过outputstreamwrite写的二进制字节数据格式要符合HTTP。浏览器在建立Socket连接之前,必须根据地址栏里输入的URL的域名DNS解析出IP地址,再根据这个IP地址和默认的80端口与远程服务器建立Socket连接,然后浏览器根据这个URL组装成一个get类型的HTTP请求头,通过 outputstream.write发送到目标服务器,服务器等待 inputstream.read返回数据,最后断开这个连接。</span></p><p><span>当然,不同浏览器在如何使用这个已经建立好的连接以及根据什么规则来管理连接上,有各种不同的实现方法。一句话,发起一个HTTP请求的过程就是建立一个Socket通信的过程。</span></p><p><span>既然发起一个HTTP连接本质上就是建立一个Socket连接,那么我们完全可以模拟浏览器来发起HTTP请求,这很好实现,也有很多方法实现,如Httpclient就是一个开源的通过程序实现的处理HTTP请求的工具包。当然如果你对HTTP的数据结构非常熟悉,你完全可以自己再实现另外一个 Http Client,甚至可以自己写个简单的浏览器。</span></p><p><span>下面是一个基本的 Httpclient的调用示例:</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="java" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="java"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">HttpClient</span> <span class="cm-variable">httpclient</span> <span class="cm-operator">=</span> <span class="cm-variable">createHttpClient</span>();</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable-3">String</span> <span class="cm-variable">domainname</span> <span class="cm-operator">=</span> <span class="cm-variable">Switcher</span>.<span class="cm-variable">domain</span>;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">PostMethod</span> <span class="cm-variable">postMethod</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">PostMethod</span>(<span class="cm-variable">domainname</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-variable">postMethod</span>.<span class="cm-variable">addRequestHeader</span>(<span class="cm-string">"content-type"</span>, <span class="cm-string">"application/x-www-form-urlencode; charset=GBK"</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">for</span> (</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">Filterdata</span> <span class="cm-variable">filterdata</span> : <span class="cm-variable">filterdatas</span>) {</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">postMethod</span>.<span class="cm-variable">addParameter</span>(<span class="cm-string">"ip"</span>, <span class="cm-variable">filterData</span>.<span class="cm-variable">ip</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">postMethod</span>.<span class="cm-variable">addParameter</span>(<span class="cm-string">"count"</span>, <span class="cm-variable-3">String</span>.<span class="cm-variable">valueOf</span>(<span class="cm-variable">filterdata</span>.<span class="cm-variable">count</span>));</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-keyword">try</span> {</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">httpclient</span>.<span class="cm-variable">executemethod</span>(<span class="cm-variable">postmethod</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">postmethod</span>.<span class="cm-variable">getResponseBodyAsString</span>();</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">} <span class="cm-keyword">catch</span> (</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">Exception</span> <span class="cm-variable">e</span>) {</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;<span class="cm-variable">logger</span>.<span class="cm-variable">error</span>(<span class="cm-variable">e</span>);</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 408px;"></div><div class="CodeMirror-gutters" style="display: none; height: 408px;"></div></div></div></pre><p><span>处理Java中使用非常普遍的 Httpclient还有很多类似的工具,如 Linux中的curl命令,通过curl+URL就可以简单地发起一个HTTP请求,非常方便。</span></p><p><span>例如,</span><em><span>curl</span></em><span> -L </span><em><a href='http://item.taobao' target='_blank' class='url'>http://item.taobao</a></em><span>.</span><em><span>com/item.htm?id=</span></em><span>25823396605 可以返回这个页面的HTML数据,如图所示。</span></p><p><img src="images/image-20210421145819863.png" referrerpolicy="no-referrer" alt="image-20210421145819863"></p><p>&nbsp;</p><h4><a name="在浏览器中输入url地址到显示主页整个过程是怎么样的" class="md-header-anchor"></a><span>在浏览器中输入url地址到显示主页整个过程是怎么样的</span></h4><blockquote><p><span>打开一个网页,整个过程会使用哪些协议?</span></p><p><span>DNS、HTTP、TCP、OSPF、IP、ARP</span></p></blockquote><ul><li><span>1) 浏览器分析连接指向的页面URL(</span><a href='http://www.baidu.com' target='_blank' class='url'>http://www.baidu.com</a><span>)</span></li><li><span>2) 浏览器向DNS请求</span><a href='http://www.baidu.com' target='_blank' class='url'>www.baidu.com</a><span>.的IP地址</span></li><li><span>3) 域名系统DNS解析出百度官网的服务器IP地址</span></li><li><span>4) 浏览器与该服务器建立TCP连接(默认端口80)</span></li><li><span>5) 浏览器发出HTTP请求获取指定页面。</span></li><li><span>6) 服务器通过HTTP响应把文件对应页面发送给浏览器。</span></li><li><span>7) TCP连接释放。</span></li><li><span>8) 浏览器将文件进行解析,并将web网页显示给用户。</span></li></ul><h4><a name="http的传输流程" class="md-header-anchor"></a><span>HTTP的传输流程</span></h4><p><span>HTTP的传输流程包括地址解析、封装HTTP数据包、封装TCP包、建⽴ TCP连接、客户端发送请求、服务端响应、服务端关闭TCP连接,具体流程如下。 </span></p><p><span>(1)地址解析:地址解析通过域名系统DNS解析服务器域名从⽽获得主机的IP地址。例如,用客户端的浏览器请求</span><a href='http://localhost.com:8080/index.htm' target='_blank' class='url'>http://localhost.com:8080/index.htm</a><span>,则可从中分解出协议名、主机名、端⼝、对象路径等部分结果如下。</span></p><ul><li><span>协议名:HTTP。</span></li><li><span>主机名:localhost.com。</span></li><li><span>端⼝:8080。</span></li><li><span>对象路径:/index.htm。 </span></li></ul><p><span>(2)封装HTTP数据包:解析协议名、主机名、端⼝、对象路径等并结合本机⾃⼰的信息封装成⼀个HTTP请求数据包。 </span></p><p><span>(3)封装TCP包:将HTTP请求数据包进⼀步封装成TCP数据包。 </span></p><p><span>(4)建⽴TCP连接:基于TCP的三次握⼿机制建⽴TCP连接。 </span></p><p><span>(5)客户端发送请求:在建⽴连接后,客户端发送⼀个请求给服务器。</span></p><p><span>(6)服务器响应:服务器在接收到请求后,结合业务逻辑进⾏数据处 理,然后向客户端返回相应的响应信息。在响应信息中包含状态⾏、协议版本号、成功或错误的代码、消息体等内容。 </span></p><p><span>(7)服务器关闭TCP连接:服务器在向浏览器发送请求响应数据后关闭TCP连接。但如果浏览器或者服务器在消息头中加⼊了Connection:keep-alive,则TCP连接在请求响应数据发送后仍然保 持连接状态,在下⼀次请求中浏览器可以继续使用相同的连接发送请求。采用keep-alive⽅式不但减少了请求响应的时间,还节约了网络带宽和系统资源。</span></p><h3><a name="http解析" class="md-header-anchor"></a><span>HTTP解析</span></h3><p><span>HTTP是⼀个无状态的协议,无状态指在客户端(Web浏览器)和服务器之间不需要建⽴持久的连接,在⼀个客户端向服务器端发出请求且服务器收到该请求并返回响应(response)后,本次通信结束,HTTP连接将被关闭,服务器不保留连接的相关信息。</span></p><p><span>HTTP遵循请求(Request)/应答(Response)模型,客户端向服务器发送请求,服务器处理请求并返回适当的应答。</span></p><h4><a name="http协议报文的结构" class="md-header-anchor"></a><span>Http协议报文的结构</span></h4><p><span>Http报文分2个:一个是Http请求报文,一个Http响应报文。</span></p><h5><a name="http请求报文的结构" class="md-header-anchor"></a><span>Http请求报文的结构</span></h5><p><span>浏览器发送给Web服务器的HTTP请求报文内容如图所示。</span></p><p><img src="images/image-20210420163258836.png" referrerpolicy="no-referrer" alt="image-20210420163258836"></p><p><img src="images/image-20210420163328930.png" referrerpolicy="no-referrer" alt="image-20210420163328930"></p><p><span>HTTP请求报文分为3部分:第一部分叫起始行(Requestline),第二部分叫首部( Request Header),第三部分叫主体(Body)。</span></p><p><span>第一行中的 Method表示请求方法,比如“POST”或者“GET”,现在使用的HTP协议版本是HTTP/1.1。</span></p><p><span>第二部分是首部(Header),后面会详细介绍这些首部的用法。</span></p><p><span>第三部分是主体(Body)。</span></p><p><span>特别要注意, Header首部和Body(主体)之间有一个空行。</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">方法 [空格] URL [空格] 版本</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">首部字段名: [空格] 值</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">…</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">首部字段名: [空格] 值</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[空一行]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">实体主体</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 144px;"></div><div class="CodeMirror-gutters" style="display: none; height: 144px;"></div></div></div></pre><h5><a name="http响应报文的结构" class="md-header-anchor"></a><span>Http响应报文的结构</span></h5><p><span>Web服务器发送给浏览器的HTTP响应报文内容如图所示。</span></p><p><img src="images/image-20210420163630458.png" referrerpolicy="no-referrer" alt="image-20210420163630458"></p><p><span>HTTP响应报文的详细内容如图所示。</span></p><p><img src="images/image-20210420163717288.png" referrerpolicy="no-referrer" alt="image-20210420163717288"></p><p><span>Response消息的结构和 Request消息的结构基本一样,同样也分为3部分:第一部分叫响应行( Response line),第二部分叫响应首部( Response Header),第三部分是主体(Body)。</span></p><p><span>第一部分是起始行,有状态码和状态码消息。</span></p><p><span>第二部分是首部( Header)。</span></p><p><span>第三部分是主体(Body),如果是GET方法,就没有主体。</span></p><p><span>特别要注意, Header首部和Body(主体)之间有一个空行。</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">版本[空格] 状态码 [空格] 短语</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">首部字段名: [空格] 值</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">…</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">首部字段名: [空格] 值</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[空一行]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">实体主体</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 144px;"></div><div class="CodeMirror-gutters" style="display: none; height: 144px;"></div></div></div></pre><p>&nbsp;</p><p><span>B/S网络架构的核心是HTTP,掌握HTTP对一个从事互联网工作的程序员来说非常重要,也许你已经非常熟悉HTTP,这里除了简单介绍HTTP的基本知识外,还将侧重介绍实际使用中的一些心得。</span></p><p><span>要理解HTTP,最重要的就是要熟悉HTTP中的HTTPHeader,HTTPHeader控制着互联网上成千上万的用户的数据的传输。最关键的是,它控制着用户浏览器的渲染行为和服务器的执行逻辑。例如,当服务器没有用户请求的数据时就会返回一个404状态码,告诉浏览器没有要请求的数据,通常浏览器就会展示一个非常不愿意看到的该页面不存在的错误信息。</span></p><p><span>常见的HTTP请求头和响应头以及常见的HTTP状态码分别如表所示。</span></p><h5><a name="常见的http请求头" class="md-header-anchor"></a><span>常见的HTTP请求头</span></h5><figure><table><thead><tr><th><span>请求头</span></th><th><span>说明</span></th></tr></thead><tbody><tr><td><span>Accept-Charset</span></td><td><span>用于指定客户端接受的字符集</span></td></tr><tr><td><span>Accept-Encoding</span></td><td><span>用于指定可接受的内容编码,如 Accept-Encoding:gzip.deflate</span></td></tr><tr><td><span>Accept-Language</span></td><td><span>用于指定一种自然语言,如 Accept-Language:zh-cn</span></td></tr><tr><td><span>Host</span></td><td><span>用于指定被请求资源的Internet主机和端口号,如Host:</span><a href='http://www.taobao.com' target='_blank' class='url'>www.taobao.com</a></td></tr><tr><td><span>User-Agent</span></td><td><span>客户端将它的操作系统、浏览器和其他属性告诉服务器</span></td></tr><tr><td><span>Connection</span></td><td><span>当前连接是否保持,如 Connection: Keep-Alive</span></td></tr></tbody></table></figure><h5><a name="常见的http响应头" class="md-header-anchor"></a><span>常见的HTTP响应头</span></h5><figure><table><thead><tr><th><span>响应头</span></th><th><span>说明</span></th></tr></thead><tbody><tr><td><span>Server</span></td><td><span>使用的服务器名称,如 Server: Apache36(Unix)</span></td></tr><tr><td><span>Content-Type</span></td><td><span>用来指明发送给接收者的实体正文的媒体类型,如 Content-Type: text/html; charset=GBK</span></td></tr><tr><td><span>Content-Encoding</span></td><td><span>与请求报头 Accept-Encoding对应,告诉浏览器服务端采用的是什么压缩编码</span></td></tr><tr><td><span>Content-Language</span></td><td><span>描述了资源所用的自然语言,与 Accept-Language对应</span></td></tr><tr><td><span>Content-Lengtth</span></td><td><span>指明实体正文的长度,用以字节方式存储的十进制数字来表示</span></td></tr><tr><td><span>Keep-Alive</span></td><td><span>保持连接的时间,如Keep-Alive: timeout=5,max=120</span></td></tr></tbody></table></figure><h5><a name="常见的http状态码" class="md-header-anchor"></a><span>常见的HTTP状态码</span></h5><p><img src="images/状态码.png" referrerpolicy="no-referrer" alt="状态码"></p><figure><table><thead><tr><th><span>状态码</span></th><th><span>说明</span></th></tr></thead><tbody><tr><td><span>2xx</span></td><td><span>成功</span></td></tr><tr><td><span>200</span></td><td><span>客户端请求成功</span></td></tr><tr><td><span>3xx</span></td><td><span>重定向</span></td></tr><tr><td><span>301</span></td><td><span>Moved Permanently: 客户请求的文档在其他地方</span></td></tr><tr><td><span>302</span></td><td><span>临时跳转,跳转的地址通过 Location指定</span></td></tr><tr><td><span>4xx</span></td><td><span>客户机中出现的错误</span></td></tr><tr><td><span>400</span></td><td><span>Bad Request:客户端请求有语法错误,不能被服务器识别</span></td></tr><tr><td><span>401</span></td><td><span>Unauthorized: 客户试图未经授权访问受密码保护的页面。</span></td></tr><tr><td><span>403</span></td><td><span>Forbidden:资源不可用,服务器理解客户的请求,但拒绝处理它。通常由于服务器上文件或目录的权限设置导致。</span></td></tr><tr><td><span>404</span></td><td><span>Not Found:请求的资源不存在,无法找到指定位置的资源。这也是一个常用的应答。</span></td></tr><tr><td><span>5xx</span></td><td><span>服务器中出现的错误</span></td></tr><tr><td><span>500</span></td><td><span>服务器发生不可预期的错误</span></td></tr><tr><td><span>501</span></td><td><span>Not Implemented:服务器不支持实现请求所需要的功能。例如,客户发出了一个服务器不支持的PUT请求。</span></td></tr><tr><td><span>502</span></td><td><span>Bad Gateway: 服务器作为网关或者代理时,为了完成请求访问下一个服务器,但该服务器返回了非法的应答。</span></td></tr><tr><td><span>503</span></td><td><span>Service Unavailable: 服务器由于维护或者负载过重未能应答。</span></td></tr><tr><td><span>504</span></td><td><span>Gateway Timeout: 由作为代理或网关的服务器使用,表示不能及时地从远程服务器获得应答。</span></td></tr><tr><td><span>505</span></td><td><span>HTTP Version Not Supported:服务器不支持请求中所指明的HTTP版本。(HTTP 1.1新)</span></td></tr></tbody></table></figure><h4><a name="http常见问题" class="md-header-anchor"></a><span>HTTP常见问题</span></h4><h5><a name="http-request的几种类型" class="md-header-anchor"></a><span>Http request的几种类型</span></h5><p><span>HTTP协议中共定义了八种方法或者叫“动作”来表明对Request-URI指定的资源的不同操作方式,具体介绍如下:</span></p><ul><li><strong><span>GET</span></strong><span>:向特定的资源发出请求。</span></li><li><strong><span>POST</span></strong><span>:向指定资源提交数据进行处理请求(例如提交表单或者上传文件)。数据被包含在请求体中。POST请求可能会导致新的资源的创建和/或已有资源的修改。</span></li><li><strong><span>PUT</span></strong><span>:向指定资源位置上传其最新内容。</span></li><li><strong><span>DELETE</span></strong><span>:请求服务器删除Request-URI所标识的资源。</span></li><li><strong><span>HEAD</span></strong><span>:请求读取由URL所标志的信息的首部。</span></li><li><strong><span>OPTIONS</span></strong><span>:返回服务器针对特定资源</span><strong><span>所支持的HTTP请求方法</span></strong><span>。也可以利用向Web服务器发送&#39;*&#39;的请求来测试服务器的功能性。</span></li><li><strong><span>TRACE</span></strong><span>:回显服务器收到的请求,主要用于测试或诊断。</span></li><li><strong><span>CONNECT</span></strong><span>:HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。</span></li></ul><h5><a name="get提交和post提交的区别" class="md-header-anchor"></a><span>get提交和post提交的区别</span></h5><ol start='' ><li><span>根据HTTP规范,</span><strong><span>GET用于信息获取,而且应该是安全的和幂等的</span></strong><span>。</span></li></ol><ul><li><span>所谓安全的意味着该操作用于获取信息而非修改信息。换句话说,GET 请求一般不应产生副作用。就是说,它仅仅是获取资源信息,就像数据库查询一样,不会修改,增加数据,不会影响资源的状态。</span></li><li><span>幂等的意味着对同一URL的多个请求应该返回同样的结果。</span></li></ul><ol start='' ><li><span>根据HTTP规范,</span><strong><span>POST表示可能修改变服务器上的资源的请求</span></strong><span>。还是新闻以网站为例,读者对新闻发表自己的评论应该通过POST实现,因为在评论提交后站点的资源已经不同了,或者说资源被修改了。</span></li><li><span>GET请求的数据会附在URL之后(就是把数据放置在HTTP协议头中),以?分割URL和传输数据,参数之间以&amp;相连.POST把提交的数据则放置在是HTTP包的包体中。</span></li><li><strong><span>GET安全性较低,POST安全性较高</span></strong><span>。因为GET在传输过程,数据被放在请求的URL中,而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中,然后放在某个地方,这样就可能会有一些隐私的信息被第三方看到。另外,用户也可以在浏览器上直接看到提交的数据,一些系统内部消息将会一同显示在用户面前。</span></li><li><strong><span>get传送的数据量较小,最多2083个字符。post传送的数据量较大</span></strong><span>,一般被默认为不受限制。</span></li><li><span>在FORM(表单)中,Method默认为&quot;GET&quot;</span></li></ol><blockquote><p><span>幂等(idempotent、idempotence)是一个数学或计算机学概念,常见于抽象代数中。幂等有一下几种定义:</span></p><ul><li><span>对于单目运算,如果一个运算对于在范围内的所有的一个数多次进行该运算所得的结果和进行一次该运算所得的结果是一样的,那么我们就称该运算是幂等的。比如绝对值运算就是一个例子,在实数集中,有abs(a)=abs(abs(a))。</span></li><li><span>对于双目运算,则要求当参与运算的两个值是等值的情况下,如果满足运算结果与参与运算的两个值相等,则称该运算幂等,如求两个数的最大值的函数,有在在实数集中幂等,即max(x,x) = x。</span></li></ul></blockquote><h5><a name="http-10和http-11的主要区别是什么" class="md-header-anchor"></a><span>HTTP 1.0和HTTP 1.1的主要区别是什么?</span></h5><blockquote><p><span>这部分回答引用这篇文章 </span><a href='https://mp.weixin.qq.com/s/GICbiyJpINrHZ41u_4zT-A?' target='_blank' class='url'>https://mp.weixin.qq.com/s/GICbiyJpINrHZ41u_4zT-A?</a><span> 的一些内容。</span></p></blockquote><p><span>HTTP1.0最早在网页中使用是在1996年,那个时候只是使用一些较为简单的网页上和网络请求上,而HTTP1.1则在1999年才开始广泛应用于现在的各大浏览器网络请求中,同时HTTP1.1也是当前使用最为广泛的HTTP协议。 主要区别主要体现在:</span></p><ol start='' ><li><strong><span>长连接</span></strong><span> : </span><strong><span>HTTP1.0 是短连接,HTTP1.1是长连接</span></strong><span>。</span><strong><span>在HTTP/1.0中,默认使用的是短连接</span></strong><span>,也就是说每次请求都要重新建立一次连接。服务器完成请求处理后立即断开TCP连接,服务器不跟踪每个客户也不记录过去的请求。如果一个html包含多个图片或资源时需要多次与服务器建立连接。HTTP 是基于TCP/IP协议的,每一次建立或者断开连接都需要三次握手四次挥手的开销,如果每次请求都要这样的话,开销会比较大。因此最好能维持一个长连接,可以用个长连接来发多个请求。</span><strong><span>HTTP 1.1起,默认使用长连接</span></strong><span> ,默认开启Connection: keep-alive。在一个TCP连接上可以传送多个HTTP请求和响应,减少了建立和关闭连接的消耗和延迟。一个包含有许多图像的网页文件的多个请求和应答可以在一个连接中传输,但每个单独的网页文件的请求和应答仍然需要使用各自的连接。 </span><strong><span>HTTP/1.1的持续连接有非流水线方式和流水线方式</span></strong><span>,</span><strong><span>HTTP/1.1的默认模式使用带流水线的持久连接</span></strong><span>,即客户端不用等待上一次请求结果返回,就可以发出下一次请求,但服务器端必须按照接收到客户端请求的先后顺序依次回送响应结果,以保证客户端能够区分出每次请求的响应内容,这样也显著地减少了整个下载过程所需要的时间。如果是不带流水线的版本,那么客户只在收到前一个请求的响应后才发出新的请求。</span></li><li><strong><span>错误状态响应码</span></strong><span> :在HTTP1.1中新增了24个错误状态响应码,如409(Conflict)表示请求的资源与资源的当前状态发生冲突;410(Gone)表示服务器上的某个资源被永久性的删除。</span></li><li><strong><span>缓存处理</span></strong><span> :在HTTP1.0中主要使用header里的If-Modified-Since,Expires来做为缓存判断的标准,HTTP1.1则引入了更多的缓存控制策略例如Entity tag,If-Unmodified-Since, If-Match, If-None-Match等更多可供选择的缓存头来控制缓存策略。HTTP 1.1还提供了与</span><strong><span>身份认证、状态管理和Cache缓存等机制</span></strong><span>相关的请求头和响应头。</span></li><li><strong><span>带宽优化及网络连接的使用</span></strong><span> :HTTP1.0中,存在一些浪费带宽的现象,例如客户端只是需要某个对象的一部分,而服务器却将整个对象送过来了,并且不支持断点续传功能,例如,客户端只需要显示一个文档的部分内容,又比如下载大文件时需要支持断点续传功能,而不是在发生断连后不得不重新下载完整的包。HTTP1.1则在请求头引入了range头域,它允许只请求资源的某个部分,即返回码是206(Partial Content),这样就方便了开发者自由的选择以便于充分利用带宽和连接。</span></li><li><strong><span>HTTP 1.0不支持Host请求头字段</span></strong><span>,WEB浏览器无法使用主机头名来明确表示要访问服务器上的哪个WEB站点,这样就无法使用WEB服务器在同一个IP地址和端口号上配置多个虚拟WEB站点。在HTTP 1.1中增加Host请求头字段后,WEB浏览器可以使用主机头名来明确表示要访问服务器上的哪个WEB站点,这才实现了在一台WEB服务器上可以在同一个IP地址和端口号上使用不同的主机名来创建多个虚拟WEB站点。</span></li><li><span>HTTP/1.1增加了</span><strong><span>OPTIONS</span></strong><span>方法,它允许客户端获取一个服务器支持的方法列表</span></li></ol><h5><a name="http怎么处理长连接" class="md-header-anchor"></a><span>Http怎么处理长连接</span></h5><p><span>HTTP1.1和HTTP1.0相比较而言,最大的区别就是增加了持久连接支持。TCP连接在发送后将仍然保持打开状态,于是,浏览器可以继续通过相同的连接发送请求。保持连接节省了为每个请求建立新连接所需的时间,还节约了带宽。</span></p><p><span>使用长连接的HTTP协议,会在响应头有加入这行代码:</span><strong><span>Connection:keep-alive</span></strong><span>。在使用长连接的情况下,当一个网页打开完成后,客户端和服务器之间用于传输HTTP数据的 TCP连接不会关闭,如果客户端再次访问这个服务器上的网页,会继续使用这一条已经建立的连接。Keep-Alive不会永久保持连接,它有一个保持时间,可以在不同的服务器软件(如Apache)中设定这个时间。实现长连接要客户端和服务端都支持长连接。</span></p><h5><a name="各种协议与http协议之间的关系" class="md-header-anchor"></a><span>各种协议与HTTP协议之间的关系</span></h5><p><img src="images/各种协议与HTTP协议之间的关系.png" referrerpolicy="no-referrer" alt="各种协议与HTTP协议之间的关系"></p><h5><a name="http长连接短连接" class="md-header-anchor"></a><span>HTTP长连接,短连接</span></h5><p><span>在HTTP/1.0中默认使用短连接。也就是说,客户端和服务器每进行一次HTTP操作,就建立一次连接,任务结束就中断连接。当客户端浏览器访问的某个HTML或其他类型的Web页中包含有其他的Web资源(如JavaScript文件、图像文件、CSS文件等),每遇到这样一个Web资源,浏览器就会重新建立一个HTTP会话。</span></p><p><span>而从HTTP/1.1起,默认使用长连接,用以保持连接特性。使用长连接的HTTP协议,会在响应头加入这行代码:</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Connection:keep-alive</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 24px;"></div><div class="CodeMirror-gutters" style="display: none; height: 24px;"></div></div></div></pre><p><span>在使用长连接的情况下,当一个网页打开完成后,客户端和服务器之间用于传输HTTP数据的TCP连接不会关闭,客户端再次访问这个服务器时,会继续使用这一条已经建立的连接。Keep-Alive不会永久保持连接,它有一个保持时间,可以在不同的服务器软件(如Apache)中设定这个时间。实现长连接需要客户端和服务端都支持长连接。</span></p><p><span>—— </span><a href='https://www.cnblogs.com/gotodsp/p/6366163.html'><span>《HTTP长连接、短连接究竟是什么?》</span></a></p><h5><a name="http协议与tcpip协议的关系" class="md-header-anchor"></a><span>HTTP协议与TCP/IP协议的关系</span></h5><p><strong><span>HTTP协议的长连接和短连接,实质上是TCP协议的长连接和短连接。</span></strong><span>HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议。 IP协议主要解决网络路由和寻址问题,TCP协议主要解决如何在IP层之上可靠地传递数据包,使得网络上接收端收到发送端所发出的所有包,并且顺序与发送顺序一致。TCP协议是可靠的、面向连接的。</span></p><h5><a name="如何理解http协议是无状态的" class="md-header-anchor"></a><span>如何理解HTTP协议是无状态的</span></h5><p><span>HTTP协议是无状态的,指的是协议对于事务处理没有记忆能力,服务器不知道客户端是什么状态。也就是说,打开一个服务器上的网页和上一次打开这个服务器上的网页之间没有任何联系。HTTP是一个无状态的面向连接的协议,无状态不代表HTTP不能保持TCP连接,更不能代表HTTP使用的是UDP协议(无连接)。</span></p><h5><a name="tcp连接" class="md-header-anchor"></a><span>TCP连接</span></h5><p><span>当网络通信时采用TCP协议时,在真正的读写操作之前,客户端与服务器端之间必须建立一个连接,当读写操作完成后,双方不再需要这个连接时可以释放这个连接。连接的建立依靠“三次握手”,而释放则需要“四次握手”,所以每个连接的建立都是需要资源消耗和时间消耗的。</span></p><h5><a name="长连接短连接操作过程" class="md-header-anchor"></a><strong><span>长连接短连接操作过程</span></strong></h5><p><span>短连接的操作步骤是:</span>
<span>建立连接——数据传输——关闭连接...建立连接——数据传输——关闭连接</span></p><p><span>长连接的操作步骤是:</span>
<span>建立连接——数据传输...(保持连接)...数据传输——关闭连接</span></p><h5><a name="什么时候用长连接短连接" class="md-header-anchor"></a><span>什么时候用长连接,短连接?   </span></h5><p><strong><span>长连接</span></strong><span>多用于操作频繁,点对点的通讯,而且连接数不能太多情况。每个TCP连接都需要三步握手,这需要时间,如果每个操作都是先连接,再操作的话那么处理速度会降低很多,所以每个操作完后都不断开,次处理时直接发送数据包就OK了,不用建立TCP连接。例如:数据库的连接用长连接, 如果用短连接频繁的通信会造成socket错误,而且频繁的socket 创建也是对资源的浪费。 </span></p><p><span>  而像WEB网站的http服务一般都用</span><strong><span>短链接</span></strong><span>,因为长连接对于服务端来说会耗费一定的资源,而像WEB网站这么频繁的成千上万甚至上亿客户端的连接用短连接会更省一些资源,如果用长连接,而且同时有成千上万的用户,如果每个用户都占用一个连接的话,那可想而知吧。所以并发量大,但每个用户无需频繁操作情况下需用短连好。</span></p><h5><a name="http是不保存状态的协议如何保存用户状态" class="md-header-anchor"></a><span>HTTP是不保存状态的协议,如何保存用户状态?</span></h5><p><span>HTTP 是一种不保存状态,即无状态(stateless)协议。也就是说 HTTP 协议自身不对请求和响应之间的通信状态进行保存。那么我们保存用户状态呢?Session 机制的存在就是为了解决这个问题,Session 的主要作用就是通过服务端记录用户的状态。典型的场景是购物车,当你要添加商品到购物车的时候,系统不知道是哪个用户操作的,因为 HTTP 协议是无状态的。服务端给特定的用户创建特定的 Session 之后就可以标识这个用户并且跟踪这个用户了(一般情况下,服务器会在一定时间内保存这个 Session,过了时间限制,就会销毁这个Session)。</span></p><p><span>在服务端保存 Session 的方法很多,最常用的就是内存和数据库(比如是使用内存数据库redis保存)。既然 Session 存放在服务器端,那么我们如何实现 Session 跟踪呢?大部分情况下,我们都是通过在 Cookie 中附加一个 Session ID 来方式来跟踪。</span></p><p><strong><span>Cookie 被禁用怎么办?</span></strong></p><p><span>最常用的就是利用 URL 重写把 Session ID 直接附加在URL路径的后面。</span></p><p><img src="images/HTTP是无状态的.png" referrerpolicy="no-referrer" alt="HTTP是无状态协议"></p><h5><a name="cookie的作用是什么和session有什么区别" class="md-header-anchor"></a><span>Cookie的作用是什么?和Session有什么区别?</span></h5><p><span>Cookie 和 Session都是用来跟踪浏览器用户身份的会话方式,但是两者的应用场景不太一样。</span></p><p><span> </span><strong><span>Cookie 一般用来保存用户信息</span></strong><span> 比如①我们在 Cookie 中保存已经登录过得用户信息,下次访问网站的时候页面可以自动帮你登录的一些基本信息给填了;②一般的网站都会有保持登录也就是说下次你再访问网站的时候就不需要重新登录了,这是因为用户登录的时候我们可以存放了一个 Token 在 Cookie 中,下次登录的时候只需要根据 Token 值来查找用户即可(为了安全考虑,重新登录一般要将 Token 重写);③登录一次网站后访问网站其他页面不需要重新登录。</span><strong><span>Session 的主要作用就是通过服务端记录用户的状态。</span></strong><span> 典型的场景是购物车,当你要添加商品到购物车的时候,系统不知道是哪个用户操作的,因为 HTTP 协议是无状态的。服务端给特定的用户创建特定的 Session 之后就可以标识这个用户并且跟踪这个用户了。</span></p><p><span>Cookie 数据保存在客户端(浏览器端),Session 数据保存在服务器端。</span></p><p><span>Cookie 存储在客户端中,而Session存储在服务器上,相对来说 Session 安全性更高。如果要在 Cookie 中存储一些敏感信息,不要直接写入 Cookie 中,最好能将 Cookie 信息加密然后使用到的时候再去服务器端解密。</span></p><h5><a name="uri和url的区别是什么" class="md-header-anchor"></a><span>URI和URL的区别是什么?</span></h5><ul><li><span>URI(Uniform Resource Identifier) 是统一资源标志符,可以唯一标识一个资源。</span></li><li><span>URL(Uniform Resource Location) 是统一资源定位符,可以提供该资源的路径。它是一种具体的 URI,即 URL 可以用来标识一个资源,而且还指明了如何 locate 这个资源。</span></li></ul><p><span>URI的作用像身份证号一样,URL的作用更像家庭住址一样。URL是一种具体的URI,它不仅唯一标识资源,而且还提供了定位该资源的信息。</span></p><h4><a name="浏览器缓存机制" class="md-header-anchor"></a><span>浏览器缓存机制</span></h4><p><span>浏览器缓存是一个比较复杂但是又比较重要的机制,在我们浏览一个页面时发现有异常的情况下,通常考虑的就是是不是浏览器做了缓存,所以一般的做法就是按Ctrl+F5组合键重新请求一次这个页面,重新请求的页面肯定是最新的页面。为什么重新请求就一定能够请求到没有缓存的页面呢?首先是在浏览器端,如果是按Ctrl+F5组合键刷新页面,那么浏览器会直接向目标URL发送请求,而不会使用浏览器缓存的数据;其次即使请求发送到服务端,也有可能访问到的是缓存的数据,比如,在我们的应用服务器的前端部署个缓存服务器,如 Varnish代理,那么 Varnish也可能直接使用缓存数据。所以为了保证用户能够看到最新的数据,必须通过HTTP来控制。</span></p><p><span>当我们使用Ctrl+F5组合键刷新一个页面时,在HTTP的请求头中会增加一些请求头,它告诉服务端我们要获取最新的数据而不是缓存。</span></p><p><img src="images/image-20210421140123602.png" referrerpolicy="no-referrer" alt="image-20210421140123602"></p><p><span>这次请求时从服务端返回的数据,最重要的是在其请求头中增加了两个请求项Pragma: no-cache和 Cache-Control:no-cache。</span></p><h5><a name="cache-control-pragma" class="md-header-anchor"></a><span>Cache-control/ Pragma</span></h5><p><span>这个HTTPHead字段用于指定所有缓存机制在整个请求/响应链中必须服从的指令,如果知道该页面是否为缓存,不仅可以控制浏览器,还可以控制和HTTP相关的缓存或代理服务器。HTTP Head字段有一些可选值,这些值及其说明如表所示。</span></p><h5><a name="httphead字段的可选值" class="md-header-anchor"></a><span>HTTPHead字段的可选值</span></h5><figure><table><thead><tr><th><span>可选值</span></th><th><span>说明</span></th></tr></thead><tbody><tr><td><span>Public</span></td><td><span>所有内容都将被缓存,在响应头中设置</span></td></tr><tr><td><span>Private</span></td><td><span>内容只缓存到私有缓存中,在响应头中设置</span></td></tr><tr><td><span>no-cache</span></td><td><span>所有内容都不会被缓存,在请求头和响应头中设置</span></td></tr><tr><td><span>no-store</span></td><td><span>所有内容都不会被缓存到缓存或 Internet临时文件中,在响应头中设置</span></td></tr><tr><td><span>must-revalidation/proxy-revalidation</span></td><td><span>如果缓存的内容失效,请求必须发送到服务器代理以进行重新验证,在请求头中设置</span></td></tr><tr><td><span>max-age=xxx</span></td><td><span>缓存的内容将在xxx秒后失效,这个选项只在HTP11中可用,和 Last-modifiedmax-age-xxx起使用时优先级较高,在响应头中设置</span></td></tr></tbody></table></figure><p><span>Cache- Control请求字段被各个浏览器支持得较好,而且它的优先级也比较高,它和其他一些请求字段(如 Expires)同时出现时, Cache-control会覆盖其他字段。Pragma字段的作用和Cache-control有点类似,它也是在HTTP头中包含一个特殊的指令,使相关的服务器遵守该指令,最常用的就是 Pragma: no-cache,它和 Cache-control: no-cache的作用是一样的。</span></p><h5><a name="expiresexpires" class="md-header-anchor"></a><span>ExpiresExpires</span></h5><p><span>通常的使用格式是 Expires:Sat,25Feb201212:2:17GMT,后面跟着一个日期和时间,超过这个时间值后,缓存的内容将失效,也就是浏览器在发出请求之前检查这个页面的这个字段,看该页面是否已经过期了,过期了就重新向服务器发起请求。</span></p><h5><a name="last-modifiedetag" class="md-header-anchor"></a><span>Last-Modified/Etag</span></h5><p><span>Last-Modified字段一般用于表示一个服务器上的资源的最后修改时间,资源可以是静态(静态内容自动加上Last- Modified字段)或者动态的内容(如 Servlet提供了一个getlastmodified方法用于检查某个动态内容是否已经更新),通过这个最后修改时间可以判断当前请求的资源是否是最新的。</span></p><p><span>一般服务端在响应头中返回一个 Last-modified字段,告诉浏览器这个页面的最后修改时间,如Last- Modified:Sat,25Fcb201212:55:04GMT,浏览器再次请求时在请求头中增加一个If- Modified- Since:Sat,25Feb201212:55:04GMT字段,询问当前缓存的页面是否是最新的,如果是最新的就返回304状态码,告诉浏览器是最新的,服务器也不会传输新的数据。</span></p><p><span>与Last-Modified字段有类似功能的还有一个Etag字段,这个字段的作用是让服务端给每个页面分配一个唯一的编号,然后通过这个编号来区分当前这个页面是否是最新的这种方式比使用Last-Modified更加灵活,但是在后端的web服务器有多台时比较难处理,因为每个web服务器都要记住网站的所有资源,否则浏览器返回这个编号就没有意义了。</span></p><h4><a name="cookie与session作用原理" class="md-header-anchor"></a><span>Cookie与Session作用原理</span></h4><h5><a name="cookie" class="md-header-anchor"></a><span>Cookie</span></h5><p><span>会话跟踪是Web程序中常用的技术,用来跟踪用户的整个会话。常用的会话跟踪技术是Cookie与Session。Cookie通过在客户端记录信息确定用户身份,Session通过在服务器端记录信息确定用户身份。</span></p><p><span>Cookie实际上是一小段的文本信息。客户端请求服务器,如果服务器需要</span><strong><span>记录该用户状态</span></strong><span>,就产生一个用户身份标识,然后在响应消息中将该标识号以Cookie的形式传递给浏览器.客户端浏览器会把Cookie保存起来。浏览器在以后每次访问该web服务器时,浏览器把请求的网址连同该Cookie一同提交给服务器。服务器检查该Cookie,以此来辨认用户状态。服务器还可以根据需要修改Cookie的内容. Cookie不能被浏览器共享</span>
<span>Cookie具有不可跨域名性,例如浏览器访问Google只会携带Google的Cookie,而不会携带Baidu的Cookie。Cookie的maxAge决定着Cookie的有效期,单位为秒(Second).</span></p><p><strong><span>默认情况下,cookie是一个会话级别的,用户退出浏览器后被删除</span></strong></p><h5><a name="session" class="md-header-anchor"></a><span>Session </span></h5><p><span>Session是另一种记录客户状态的机制,不同的是Cookie保存在客户端浏览器中,而Session保存在服务器上。客户端浏览器访问服务器的时候,服务器把客户端信息以某种形式记录在服务器上。这就是Session。</span>
<span>如果说Cookie机制是通过检查客户身上的“通行证”来确定客户身份的话,那么Session机制就是通过检查服务器上的“客户明细表”来确认客户身份。Session相当于程序在服务器上建立的一份客户档案,客户来访的时候只需要查询客户档案表就可以了。</span></p><p><span>Session保存在服务器端。为了获得更高的存取速度,服务器一般把Session放在内存里。每个用户都会有一个独立的Session。如果Session内容过于复杂,当大量客户访问服务器时可能会导致内存溢出。因此,Session里的信息应该尽量精简。</span></p><p><span>session工作原理:</span></p><ul><li><span>web不会在客户端开始访问它时创建session,在访问特殊的程序并且该程序(servlet)决定与客户端开启会话时,服务器生成一个唯一值,称为Session ID(好像是通过取进程ID的方式取得的)。服务器开辟一块内存,对应于该Session ID。</span></li><li><span>服务器再将该Session ID写入浏览器的cookie。</span></li><li><span>服务器内有一进程,监视所有Session的活动状况,如果有Session超时或是主动关闭,服务器就释放改内存块。</span></li><li><span>当浏览器连入服务器时并请求Session时,服务器就读浏览器Cookie中的Session ID。</span></li><li><span>然后,服务检查该Session ID所对应的内存是否有效。</span></li><li><span>如果有效,就读出内存中的值。</span></li><li><span>如果无效,就建立新的Session。</span></li></ul><p><strong><span>tomcat默认设置是30分钟</span></strong><span>,具体设置很简单,方法有三种:</span></p><p><span>(1)在主页面或者公共页面中加入:session.setMaxInactiveInterval(900);</span>
<span>参数900单位是秒,即在没有活动15分钟后,session将失效。设置为-1将永不关闭。</span>
<span>这里要注意这个session设置的时间是根据服务器来计算的,而不是客户端。所以如果是在调试程序,应该是修改服务器端时间来测试,而不是客户端。</span></p><p><span>(2)也是比较通用的设置session失效时间的方法,就是在项目的web.xml中设置</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang=""><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang=""><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">&lt;session-config&gt;</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">&lt;session-timeout&gt;15&lt;/session-timeout&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">&lt;/session-config&gt;</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 72px;"></div><div class="CodeMirror-gutters" style="display: none; height: 72px;"></div></div></div></pre><p><span>这里的15也就是15分钟失效.</span></p><p><span>(3)直接在应用服务器中设置,如果是tomcat,可以在tomcat目录下conf/web.xml中</span>
<span>找到</span><session-config><span>元素,tomcat默认设置是30分钟,只要修改这个值就可以了。</span>
<span>需要注意的是如果上述三个地方如果都设置了,有个优先级的问题,从高到低:</span></p><p><span>(1)--&gt;(2)---&gt;(3) </span></p><p><span>生命周期:</span></p><ul><li><span>1)tomcat默认是30分钟 </span></li><li><span>2)因为session和cookie有关系,客户端浏览器通过cookie维持该会话,cookie不支持跨浏览器共享,意味着如果把浏览器关该会闭的话该会话就会失效(但服务端还保存着)。因此同一机器的两个浏览器窗口访问服务器时,会生成两个不同的Session。</span></li></ul><h3><a name="dns城名解析" class="md-header-anchor"></a><span>DNS城名解析</span></h3><p><span>我们知道互联网都是通过URL来发布和请求资源的,而URL中的域名需要解析成IP地址才能与远程主机建立连接,如何将域名解析成I地址就属于DNS解析的工作范畴。</span></p><h4><a name="dns域名解析过程" class="md-header-anchor"></a><span>DNS域名解析过程</span></h4><p><img src="images/image-20210421150419352.png" referrerpolicy="no-referrer" alt="image-20210421150419352"></p><p><span>如图所示,当一个用户在浏览器中输入</span><a href='http://www.abc.con' target='_blank' class='url'>www.abc.con</a><span>时,DNS解析将会有将近10个步骤,这个过程大体描述如下。</span></p><p><span>当用户在浏览器中输入域名并按下回车键后,第1步,浏览器会检查缓存中有没有这个域名对应的解析过的IP地址,如果缓存中有,这个解析过程就将结束。浏览器缓存域名也是有限制的,不仅浏览器缓存大小有限制,而且缓存的时间也有限制,通常情况下为几分钟到几小时不等,域名被缓存的时间限制可以通过TTL属性来设置。这个缓存时间太长和太短都不好,如果缓存时间太长,一旦域名被解析到的IP有变化,会导致被客户端缓存的域名无法解析到变化后的IP地址,以致该域名不能正常解析,这段时间内有可能会有一部分用户无法访问网站。如果时间设置太短,会导致用户每次访问网站都要重新解析一次域名。</span></p><p><span>第2步,如果用户的浏览器缓存中没有,浏览器会查找操作系统缓存中是否有这个域名对应的DNS解析结果。其实操作系统也会有一个域名解析的过程,在 Windows中可以通过C: Windows\System32 driversletc hosts文件来设置,你可以将任何域名解析到任何能够访问的IP地址。如果你在这里指定了一个域名对应的IP地址,那么浏览器会首先使用这个IP地址。例如,我们在测试时可以将一个域名解析到一台测试服务器上,这样不用修改任何代码就能测试到单独服务器上的代码的业务逻辑是否正确。正是因为有这种本地DNS解析的规程,所以黑客就有可能通过修改你的域名解析来把特定的域名解析到它指定的IP地址上,导致这些域名被劫持。这导致在早期的 Windows版本中出现过很严重的问题,而且对于一般没有太多计算机知识的用户来说,出现问题后很难发现,即使发现也很难自己解决,所以 Windows7中将hosts文件设置成了只读的,防止这个文件被轻易修改。在 Linux中这个配置文件是/etc/ hosts,修改这个文件可以达到同样的目的,当解析到这个配置文件中的某个域名时,操作系统会在缓存中缓存这个解析结果,缓存的时间同样是受这个域名的失效时间和缓存的空间大小控制的。前面这两个步骤都是在本机完成的,所以在图1-10中没有表示出来。到这里还没有涉及真正的域名解析服务器,如果在本机中仍然无法完成域名的解析,就会真正请求域名服务器来解析这个域名了。</span></p><p><span>第3步,如何、怎么知道域名服务器呢?在我们的网络配置中都会有“DNS服务器地址”这一项,这个地址就用于解决前面所说的如果两个过程无法解析时要怎么办,操作系统会把这个域名发送给这里设置的LDNS,也就是本地区的域名服务器。这个DNS通常都提供给你本地互联网接入的一个DNS解析服务,例如你是在学校接入互联网,那么你的DNS服务器肯定在你的学校,如果你是在一个小区接入互联网的,那这个DNS就是提供给你接入互联网的应用提供商,即电信或者联通,也就是通常所说的SPA,那么这个DNS通常也会在你所在城市的某个角落,通常不会很远。在 Windows下可以通过 ipconfig查询这个地址,如图所示。</span></p><p><img src="images/image-20210421151231764.png" referrerpolicy="no-referrer" alt="image-20210421151231764"></p><p><span>在 Linux下可以通过如下方式查询配置的 DNS Server。</span></p><p><img src="images/image-20210421151323908.png" referrerpolicy="no-referrer" alt="image-20210421151323908"></p><p><span>这个专门的域名解析服务器性能都会很好,它们一般都会缓存域名解析结果,当然缓存时间是受域名的失效时间控制的,一般缓存空间不是影响域名失效的主要因素。大约80%的域名解析都到这里就已经完成了,所以LDNS主要承担了域名的解析工作。</span></p><p><span>第4步,如果LDNS仍然没有命中,就直接到 Root server域名服务器请求解析。</span></p><p><span>第5步,根域名服务器返回给本地域名服务器一个所査询域的主域名服务器(gTLDServer)地址。gTLD是国际顶级域名服务器,如,com、,cn、,org等,全球只有13台左右。</span></p><p><span>第6步,本地域名服务器( Local dns server)再向上一步返回的gTLD服务器发送请求。</span></p><p><span>第7步,接受请求的gTLD服务器查找并返回此域名对应的 Name Server域名服务器的地址,这个 Name Server通常就是你注册的域名服务器,例如你在某个域名服务提供商申请的域名,那么这个域名解析任务就由这个域名提供商的服务器来完成。</span></p><p><span>第8步, Name server域名服务器会查询存储的域名和IP的映射关系表,在正常情况下都根据域名得到目标IP记录,连同一个TTL值返回给 DNS Server域名服务器。</span></p><p><span>第9步,返回该域名对应的IP和TTL值, Local dns Server会缓存这个域名和IP的对应关系,缓存的时间由TTL值控制。</span></p><p><span>第10步,把解析的结果返回给用户,用户根据TTL值缓存在本地系统缓存中,域名解析过程结束。</span></p><p><span>在实际的DNS解析过程中,可能还不止这10个步骤,如 Name Server也可能有多级,或者有一个GTM来负载均衡控制,这都有可能会影响域名解析的过程。</span></p><h4><a name="dns域名系统简单描述其工作原理" class="md-header-anchor"></a><span>DNS域名系统,简单描述其工作原理</span></h4><p><span>域名系统DNS是因特网使用的命名系统,用于把便于人们记忆的含有特定含义的主机名转换为便于机器处理的IP地址。DNS系统采用C/S模式,其协议运行在UDP上,使用53号端口。从概念上讲DNS可以分为3个部分:层次域名空间,域名服务器和解析器。</span></p><p><span>域名解析是把域名映射成IP地址或者把IP地址映射成域名的过程。域名解析有两种方式:递归查询和迭代查询。</span></p><p><strong><span>递归查询</span></strong><span>:如果本地主机询问的本地域名服务器不知道被查询的域名IP地址,那么</span><strong><span>本地域名服务器</span></strong><span>就以DNS客户的身份,向</span><strong><span>根域名服务器</span></strong><span>继续发出查询请求报文,而不是自己进行下一步非查询。根域名服务器会继续向</span><strong><span>顶级域名服务器</span></strong><span>查询请求,如果存在则直接返回给根服务器,否则顶级域名服务器向对应的</span><strong><span>权限域名服务器</span></strong><span>查询。是一种递归的查询方式。</span></p><p><strong><span>迭代查询</span></strong><span>:本地域名服务器负责转发和调用功能。如果本地主机询问的本地域名服务器不知道被查询的域名IP地址,那么本地域名服务器就以DNS客户的身份,向根域名服务器继续发出查询请求报文。跟服务器收到请求报文时,要么给出所有查询的IP地址,要么告诉本地域名服务器下一步需要查询的顶级域名服务器。然后本地服务器向这个顶级域名服务器进行后续的查询。同样的顶级域名服务器收到查询报文后,要么给出所要查询的IP地址,要么告诉本地域名服务器下一步应该查找那个权限域名服务器。</span></p><h4><a name="清除缓存的域名" class="md-header-anchor"></a><span>清除缓存的域名</span></h4><p><span>我们知道DNS域名解析后会缓存解析结果,其中主要在两个地方缓存结果,一个是Local dns Server,另外一个是用户的本地机器。这两个缓存都是TTL值和本机缓存大小控制的,但是最大缓存时间是TTL值,基本上 Local dns Server的缓存时间就是TTL控制的,很难人工介入,但是我们的本机缓存可以通过如下方式清除。</span></p><p><span>在 Windows下可以在命令行模式下执行 ipconfig/ flushing命令来刷新缓存。</span></p><p><img src="images/image-20210421151715530.png" referrerpolicy="no-referrer" alt="image-20210421151715530"></p><p><span>在 Linux下可以通过 /etc/init.d/nscd restart来清除缓存。</span></p><p><strong><span>重启依然是解决很多问题的第一选择。</span></strong></p><h4><a name="几种域名解析方式" class="md-header-anchor"></a><span>几种域名解析方式</span></h4><p><span>域名解析记录主要分为A记录、MX记录、 CNAME记录、NS记录和TXT记录。</span></p><ul><li><span>A记录,A代表的是Address,,用来指定域名对应的IP地址,如将item.taobao.com指定到115.238.23xxx,将 switch. taobao. com指定到121.11.24xxx。A记录可以将多个域名解析到一个P地址,但是不能将一个域名解析到多个IP地址。</span></li><li><span>MX记录,表示的是 Mail Exchange,就是可以将某个域名下的邮件服务器指向自己的 Mail server,如 taobao. com域名的A记录IP地址是115238.25xxx,如果将MX记录设置为11523825xx,即</span><a href='mailto:xx@Taobao.com' target='_blank' class='url'>xx@Taobao.com</a><span>的邮件路由,DNS会将邮件发送到115.238.25xxx所在的服务器,而正常通过Web请求的话仍然解析到A记录的IP地址。</span></li><li><span>CNAME记录,全称是 Canonical Name(别名解析)。所谓的别名解析就是可以为一个域名设置一个或者多个别名。如将taobao.com解析到xuling,net,将stefan.com也解析到xuling.net。其中xuling.net分别是taobao.com和srcfan.com的别名。前面的跟踪域名解析中的“</span><a href='http://www.taobaocom.1542INCNAMEwww.gslb.taobao.com' target='_blank' class='url'>www.taobaocom.1542INCNAMEwww.gslb.taobao.com</a><span>”就是CNAME解析。</span></li><li><span>NS记录,为某个域名指定DNS解析服务器,也就是这个域名有指定的IP地址的DNS服务器去解析,前面的“gslbtaobao.com.86400INNSgslbns2taobaocom.”就是NS解析。</span></li><li><span>TXT记录,为某个主机名或域名设置说明,如可以为 xulingbo. net设置TXT记录为“阿灰在大街上吃瓜”这样的说明。</span></li></ul><h4><a name="面向连接和非面向连接的服务的特点是什么" class="md-header-anchor"></a><span>面向连接和非面向连接的服务的特点是什么?</span></h4><p><span>面向连接的服务:通信双方进行通信之前,必须先建立连接,在通信过程中,整个连接情况一直都是被实时地监控和管理。当通信结束后,则应释放这个连接。</span>
<span>无连接服务:两个实体之间的通信不需要先建立好连接,需要通信的时候,直接将信息发送到”网络”中,让该信息的传递在网上尽力而为地往目的地传送。</span></p><p>&nbsp;</p><h2><a name="四https协议" class="md-header-anchor"></a><span>四、HTTPS协议</span></h2><p><span>HTTPS是以安全为目标的HTTP通道,它在HTTP中加⼊SSL层以提⾼数据传输的安全性。HTTP被用于在Web浏览器和网站服务器之间传递信息,但以明文⽅式发送内容,不提供任何⽅式的数据加密,如果攻击者 截取了We b浏览器和网站服务器之间的传输报文,就可以直接读懂其中的信息,因此HTTP不适合传输⼀些敏感信息,⽐如⾝份证号码、密 码等。为了数据传输的安全,HTTPS在HTTP的基础上加⼊了SSL协 议,SSL依靠证书来验证服务器的⾝份,并对浏览器和服务器之间的通 信进⾏数据加密,以保障数据传输的安全性,其端⼝⼀般是443。</span></p><p><span>HTTP的加密流程如下,如图所⽰。 </span></p><p><span>(1)发起请求:客户端在通过TCP和服务器建⽴连接之后(443端⼝),发出⼀个请求证书的消息给服务器,在该请求消息⾥包含⾃⼰可实现的算法列表和其他需要的消息。 </span></p><p><span>(2)证书返回:服务器端在收到消息后回应客户端并返回证书,在证书中包含服务器信息、域名、申请证书的公司、公钥、数据加密算法等。</span></p><p><span>(3)证书验证:客户端在收到证书后,判断证书签发机构是否正确, 并使用该签发机构的公钥确认签名是否有效,客户端还会确保在证书中列出的域名就是它正在连接的域名。如果客户端确认证书有效,则⽣成对称密钥,并使用公钥将对称密钥加密。 </span></p><p><span>(4)密钥交换:客户端将加密后的对称密钥发送给服务器,服务器在接收到对称密钥后使用私钥解密。 </span></p><p><span>(5)数据传输:经过上述步骤,客户端和服务器就完成了密钥对的交 换,在之后的数据传输过程中,客户端和服务端就可以基于对称加密(加密和解密使用相同密钥的加密算法)对数据加密后在网络上传输,保证了网络数据传输的安全性。 </span></p><p><img src="images/image-20210318193555641.png" alt="image-20210318193555641" style="zoom:80%;" /></p><p>&nbsp;</p><h3><a name="https如何加密的" class="md-header-anchor"></a><span>https如何加密的</span></h3><p><span>HTTPS介绍:</span>
<span>HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议 它是一个安全通信通道,它基于HTTP开发,用于在客户计算机和服务器之间交换信息。</span><strong><span>它使用安全套接字层(SSL)进行信息交换</span></strong><span>,简单来说它是HTTP的安全版。 它是由Netscape开发并内置于其浏览器中,使用SSL在发送方把原始数据进行加密,然后在接受方进行解密保证数据的安全性.然而,加密和解密过程需要耗费系统大量的开销,严重降低机器的性能.</span></p><p><span>HTTPS实际上就是SSL over HTTP,它使用默认端口</span><strong><span>443</span></strong><span>,而不是像HTTP那样使用端口80来和TCP/IP进行通信。HTTPS协议使用SSL在发送方把原始数据进行加密,然 后在接受方进行解密,加密和解密需要发送方和接受方通过交换共知的密钥来实现,因此,所传送的数据不容易被网络黑客截获和解密.然而,加密和解密过程需要耗费系统大量的开销,严重降低机器的性能,相关测试数据表明使用HTTPS协议传输数据的工作效率只有使用HTTP协议传输的十分之一。</span></p><p><span>如何实现加密:(其实就是sssl的交互过程)</span>
<span>HTTPS其实是有两部分组成:HTTP + SSL / TLS,也就是在HTTP上又加了一层处理加密信息的模块。服务端和客户端的信息传输都会通过TLS进行加密,所以传输的数据都是加密后的数据。具体是如何进行加密,解密,验证的。</span></p><h3><a name="http和https的区别" class="md-header-anchor"></a><span>http和https的区别</span></h3><ol start='' ><li><p><span>https协议需要到ca申请证书,一般免费证书很少,需要交费.</span></p></li><li><p><span>http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议。</span></p></li><li><p><span>完全不同的连接方式:http的连接很简单,是无状态的 </span></p></li><li><p><span>HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议 要比http协议安全 HTTPS解决的问题.</span></p></li><li><p><strong><span>端口</span></strong><span>:HTTP的URL由“http://”起始且默认使用端口80,而HTTPS的URL由“https://”起始且默认使用端口443。</span></p></li><li><p><strong><span>安全性和资源消耗:</span></strong><span> HTTP协议运行在TCP之上,所有传输的内容都是明文,客户端和服务器端都无法验证对方的身份。HTTPS是运行在SSL/TLS之上的HTTP协议,SSL/TLS 运行在TCP之上。所有传输的内容都经过加密,加密采用对称加密,但对称加密的密钥用服务器方的证书进行了非对称加密。所以说,HTTP 安全性没有 HTTPS高,但是 HTTPS 比HTTP耗费更多服务器资源。此外客户端可以验证服务器端的身份。如果配置了客户端验证,服务器方也可以验证客户端的身份。</span></p><ul><li><span>对称加密:密钥只有一个,加密解密为同一个密码,且加解密速度快,典型的对称加密算法有DES、AES等;</span></li><li><span>非对称加密:密钥成对出现(且根据公钥无法推知私钥,根据私钥也无法推知公钥),加密解密使用不同密钥(公钥加密需要私钥解密,私钥加密需要公钥解密),相对对称加密速度较慢,典型的非对称加密算法有RSA、DSA等。</span></li></ul></li></ol><h3><a name="ssl协议及完整交互过程" class="md-header-anchor"></a><span>SSL协议及完整交互过程</span></h3><p><span>SSL是Netscape公司所提出的安全保密协议,在浏览器(如Internet Explorer、Netscape Navigator)和Web服务器(如Netscape的Netscape Enterprise Server、ColdFusion Server等等)之间构造安全通道来进行数据传输,SSL运行在TCP/IP层之上、应用层之下,为应用程序提供加密数据通道,它采用了RC4、MD5 以及RSA等加密算法,使用40 位的密钥,适用于商业信息的加密。</span></p><p><span>开始加密通信之前,客户端和服务器首先必须建立连接和交换参数,这个过程叫做握手(handshake)。</span></p><h4><a name="1-客户端发出请求clienthello)" class="md-header-anchor"></a><span>1 客户端发出请求(ClientHello)</span></h4><p><span>首先,客户端(通常是浏览器)先向服务器发出加密通信的请求,这被叫做ClientHello请求。在这一步,客户端主要向服务器提供以下信息。</span></p><ul><li><span>(1) 支持的协议版本,比如TLS 1.0版。</span></li><li><span>(2) 一个客户端生成的随机数,稍后用于生成&quot;对话密钥&quot;。</span></li><li><span>(3) 支持的加密方法,比如RSA公钥加密。</span></li><li><span>(4) 支持的压缩方法。</span></li></ul><h4><a name="2-服务器回应severhello" class="md-header-anchor"></a><span>2 服务器回应(SeverHello)</span></h4><p><span>服务器收到客户端请求后,向客户端发出回应,这叫做SeverHello。服务器的回应包含以下内容:</span></p><ul><li><span>(1) 确认使用的加密通信协议版本,比如TLS 1.0版本。如果浏览器与服务器支持的版本不一致,服务器关闭加密通信。</span></li><li><span>(2) 一个服务器生成的随机数,稍后用于生成&quot;对话密钥&quot;。</span></li><li><span>(3) 确认使用的加密方法,比如RSA公钥加密。</span></li><li><span>(4) 服务器证书。(公钥)</span></li></ul><h4><a name="3-客户端回应" class="md-header-anchor"></a><span>3 客户端回应</span></h4><p><span>客户端收到服务器回应以后,首先验证服务器证书。如果证书不是可信机构颁布、或者证书中的域名与实际域名不一致、或者证书已经过期,就会向访问者显示一个警告,由其选择是否还要继续通信。</span>
<span>如果证书没有问题,客户端就会从证书中取出服务器的公钥。然后,向服务器发送下面三项信息。</span></p><ul><li><span>一个随机数。该随机数用服务器公钥加密,防止被窃听。</span></li><li><span>编码改变通知,表示随后的信息都将用双方商定的加密方法和密钥发送.</span></li><li><span>客户端握手结束通知,表示客户端的握手阶段已经结束。这一项同时也是前面发送的所有内容的hash值,用来供服务器校验。</span></li></ul><p><span>上面第一项的随机数,是整个握手阶段出现的第三个随机数,又称&quot;pre-master key&quot;。有了它以后,客户端和服务器就同时有了三个随机数,接着双方就用事先商定的加密方法,各自生成本次会话所用的同一把&quot;会话密钥&quot;。(会话秘钥是采用对称加密方式,而这里的公钥是采用非对称加密)</span></p><h4><a name="4-服务器的最后回应" class="md-header-anchor"></a><span>4 服务器的最后回应</span></h4><p><span>服务器通过私钥解密收到客户端的第三个随机数pre-master key之后,计算生成本次会话所用的&quot;会话密钥&quot;。然后,向客户端最后发送下面信息。</span></p><ul><li><span>编码改变通知,表示随后的信息都将用双方商定的加密方法和密钥发送。</span></li><li><span>服务器握手结束通知,表示服务器的握手阶段已经结束。这一项同时也是前面发送的所有内容的hash值,用来供客户端校验。</span></li></ul><p><span>至此,整个握手阶段全部结束。接下来,客户端与服务器进入加密通信,就完全是使用普通的HTTP协议,只不过用&quot;会话密钥&quot;加密内容。</span></p><h4><a name="至于为什么一定要用三个随机数来生成会话密钥dog250解释得很好" class="md-header-anchor"></a><span>至于为什么一定要用三个随机数,来生成&quot;会话密钥&quot;,dog250解释得很好:</span></h4><p><span>&quot;不管是客户端还是服务器,都需要随机数,这样生成的密钥才不会每次都一样。由于SSL协议中证书是静态的,因此十分有必要引入一种随机因素来保证协商出来的密钥的随机性。</span></p><p><span>对于RSA密钥交换算法来说,pre-master-key本身就是一个随机数,再加上hello消息中的随机,三个随机数通过一个密钥导出器最终导出一个对称密钥。</span></p><p><span>pre master的存在在于SSL协议不信任每个主机都能产生完全随机的随机数,如果随机数不随机,那么pre master secret就有可能被猜出来,那么仅适用pre master secret作为密钥就不合适了,因此必须引入新的随机因素,那么客户端和服务器加上pre master secret三个随机数一同生成的密钥就不容易被猜出了,一个伪随机可能完全不随机,可是是三个伪随机就十分接近随机了,每增加一个自由度,随机性增加的可不是一。&quot;</span></p><p><a href='http://limboy.me/tech/2011/02/19/https-workflow.html' target='_blank' class='url'>http://limboy.me/tech/2011/02/19/https-workflow.html</a>
<a href='http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html' target='_blank' class='url'>http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html</a>
<a href='http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html' target='_blank' class='url'>http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html</a>
<a href='http://kb.cnblogs.com/page/162080/' target='_blank' class='url'>http://kb.cnblogs.com/page/162080/</a></p><h3><a name="https处理的一个过程对称加密和非对称加密参考上一条这一条就是通俗的表示)" class="md-header-anchor"></a><span>https处理的一个过程,对称加密和非对称加密(参考上一条,这一条就是通俗的表示)</span></h3><ol start='' ><li><span>SSL原理很简单。当你的浏览器向服务器请求一个安全的网页(通常是 https://)</span></li><li><span>服务器就把它的证书和公匙发回来</span><span> </span></li><li><span>浏览器检查证书是不是由可以信赖的机构颁发的,确认证书有效和此证书是此网站的。</span></li><li><span>浏览器使用公钥加密了一个随机对称密钥,包括加密的URL一起发送到服务器。</span></li><li><span>服务器用自己的私匙解密了你发送的钥匙。然后用这把对称加密的钥匙给你请求的URL链接解密。</span></li><li><span>服务器用你发的对称钥匙给你请求的网页加密。你也有相同的钥匙就可以解密发回来的网页了</span></li></ol><p><span>加密算法绝大部分都属于以下两种加密类型之一:</span></p><ul><li><span>对称加密:加密解密用的是同样的“钥匙”</span></li><li><span>非对称加密:加密解密用的是不同的“钥匙”</span></li></ul><h4><a name="对称加密" class="md-header-anchor"></a><span>对称加密</span></h4><p><span>Alice 在盒子里放有信息,盒子上有挂锁,她有钥匙。通过邮局她把这个盒子寄给Bob。Bob收到盒子后,用相同的钥匙打开盒子(钥匙之前就得到了,可能是Alice面对面给他的)。然后Bob可以用同样的方法回复。</span></p><h4><a name="非对称加密" class="md-header-anchor"></a><span>非对称加密</span></h4><p><span>Bob和Alice各有自己的盒子。Alice要跟Bob秘密通信,她先让Bob把开着的盒子通过邮局发给她。Alice拿到盒子后放入信息锁上,然后发给Bob。Bob就可以用他自己的钥匙打开了。回复的话就用同样的方法。</span>
<span>非对称算法在加密和解密时用的是不同的钥匙。信息接受者有两把钥匙:一把“公匙”,一把“私匙”。公匙是给信息发送者用来加密的,私匙是自己用来解密的。这样最大的好处是:不必通过不安全的渠道发送私密的东西。公匙本来就是给别人用的,不用藏好。你的私匙在你产生私匙的电脑里保存着。</span></p><p><a href='http://article.yeeyan.org/view/90729/174903/' target='_blank' class='url'>http://article.yeeyan.org/view/90729/174903/</a></p><p>&nbsp;</p><h3><a name="https中的tls" class="md-header-anchor"></a><span>HTTPS中的TLS</span></h3><h4><a name="1-ssl-与-tls" class="md-header-anchor"></a><span>1. SSL 与 TLS</span></h4><p><span>SSL:(Secure Socket Layer) 安全套接层,于 1994 年由网景公司设计,并于 1995 年发布了 3.0 版本</span><br/><span>TLS:(Transport Layer Security)传输层安全性协议,是 IETF 在 SSL3.0 的基础上设计的协议</span><br/><span>以下全部使用 TLS 来表示</span></p><h4><a name="2-从网络协议的角度理解-https" class="md-header-anchor"></a><span>2. 从网络协议的角度理解 HTTPS</span></h4><p><span>HTTP:HyperText Transfer Protocol 超文本传输协议</span><br/><span>HTTPS:Hypertext Transfer Protocol Secure 超文本传输安全协议</span><br/><span>TLS:位于 HTTP 和 TCP 之间的协议,其内部有 TLS握手协议、TLS记录协议</span><br/><span>HTTPS 经由 HTTP 进行通信,但利用 TLS 来保证安全,即 HTTPS = HTTP + TLS</span></p><h4><a name="3-从密码学的角度理解-https" class="md-header-anchor"></a><span>3. 从密码学的角度理解 HTTPS</span></h4><p><span>HTTPS 使用 TLS 保证安全,这里的“安全”分两部分,一是传输内容加密、二是服务端的身份认证</span></p><h5><a name="31-tls-工作流程" class="md-header-anchor"></a><span>3.1. TLS 工作流程</span></h5><p><span>此为服务端单向认证,还有客户端/服务端双向认证,流程类似,只不过客户端也有自己的证书,并发送给服务器进行验证</span></p><h5><a name="32-密码基础" class="md-header-anchor"></a><span>3.2. 密码基础</span></h5><h6><a name="321-伪随机数生成器" class="md-header-anchor"></a><span>3.2.1. 伪随机数生成器</span></h6><p><span>为什么叫伪随机数,因为没有真正意义上的随机数,它的主要作用在于生成对称密码的秘钥、用于公钥密码生成秘钥对</span></p><h6><a name="322-消息认证码" class="md-header-anchor"></a><span>3.2.2. 消息认证码</span></h6><p><span>消息认证码主要用于验证消息的完整性与消息的认证,其中消息的认证指“消息来自正确的发送者” </span></p><blockquote><p><span>消息认证码用于验证和认证,而不是加密 </span></p></blockquote><ol start='' ><li><span>发送者与接收者事先共享秘钥</span></li><li><span>发送者根据发送消息计算 MAC 值</span></li><li><span>发送者发送消息和 MAC 值 </span></li><li><span>接收者根据接收到的消息计算 MAC 值</span></li><li><span>接收者根据自己计算的 MAC 值与收到的 MAC 对比</span></li><li><span>如果对比成功,说明消息完整,并来自与正确的发送者</span></li></ol><h6><a name="323-数字签名" class="md-header-anchor"></a><span>3.2.3. 数字签名</span></h6><p><span>消息认证码的缺点在于</span><strong><span>无法防止否认</span></strong><span>,因为共享秘钥被 client、server 两端拥有,server 可以伪造 client 发送给自己的消息(自己给自己发送消息),为了解决这个问题,我们需要它们有各自的秘钥不被第二个知晓(这样也解决了共享秘钥的配送问题) </span></p><blockquote><p><span>数字签名和消息认证码都</span><strong><span>不是为了加密</span></strong><span></span><br/><span>可以将单向散列函数获取散列值的过程理解为使用 md5 摘要算法获取摘要的过程 </span></p></blockquote><p><span>使用自己的私钥对自己所认可的消息生成一个该消息专属的签名,这就是数字签名,表明我承认该消息来自自己</span><br/><span>注意:</span><strong><span>私钥用于加签,公钥用于解签,每个人都可以解签,查看消息的归属人</span></strong><span> </span></p><h6><a name="324-公钥密码" class="md-header-anchor"></a><span>3.2.4. 公钥密码</span></h6><p><span>公钥密码也叫非对称密码,由公钥和私钥组成,它是最开始是为了解决秘钥的配送传输安全问题,即,我们不配送私钥,只配送公钥,私钥由本人保管 </span><br/><span>它与数字签名相反,公钥密码的私钥用于解密、公钥用于加密,每个人都可以用别人的公钥加密,但只有对应的私钥才能解开密文</span><br/><span>client:明文 + 公钥 = 密文</span><br/><span>server:密文 + 私钥 = 明文</span><br/><span>注意:</span><strong><span>公钥用于加密,私钥用于解密,只有私钥的归属者,才能查看消息的真正内容</span></strong><span> </span></p><h6><a name="325-证书" class="md-header-anchor"></a><span>3.2.5. 证书</span></h6><p><span>证书:全称公钥证书(Public-Key Certificate, PKC),里面保存着归属者的基本信息,以及证书过期时间、归属者的公钥,并由认证机构(Certification Authority, </span><strong><span>CA</span></strong><span>)施加数字签名,表明,某个认证机构认定该公钥的确属于此人 </span></p><blockquote><p><span>想象这个场景:你想在支付宝页面交易,你需要支付宝的公钥进行加密通信,于是你从百度上搜索关键字“支付宝公钥”,你获得了支什宝的公钥,这个时候,支什宝通过中间人攻击,让你访问到了他们支什宝的页面,最后你在这个支什宝页面完美的使用了支什宝的公钥完成了与支什宝的交易</span></p></blockquote><p><span>在上面的场景中,你可以理解支付宝证书就是由支付宝的公钥、和给支付宝颁发证书的企业的数字签名组成</span><br/><span>任何人都可以给自己或别人的公钥添加自己的数字签名,表明:我拿我的尊严担保,我的公钥/别人的公钥是真的,至于信不信那是另一回事了</span></p><h6><a name="326-密码小结" class="md-header-anchor"></a><span>3.2.6. 密码小结</span></h6><figure><table><thead><tr><th style='text-align:left;' ><span>密码</span></th><th style='text-align:left;' ><span>作用</span></th><th style='text-align:left;' ><span>组成</span></th></tr></thead><tbody><tr><td style='text-align:left;' ><span>消息认证码</span></td><td style='text-align:left;' ><span>确认消息的完整、并对消息的来源认证</span></td><td style='text-align:left;' ><span>共享秘钥+消息的散列值</span></td></tr><tr><td style='text-align:left;' ><span>数字签名</span></td><td style='text-align:left;' ><span>对消息的散列值签名</span></td><td style='text-align:left;' ><span>公钥+私钥+消息的散列值</span></td></tr><tr><td style='text-align:left;' ><span>公钥密码</span></td><td style='text-align:left;' ><span>解决秘钥的配送问题</span></td><td style='text-align:left;' ><span>公钥+私钥+消息</span></td></tr><tr><td style='text-align:left;' ><span>证书</span></td><td style='text-align:left;' ><span>解决公钥的归属问题</span></td><td style='text-align:left;' ><span>公钥密码中的公钥+数字签名</span></td></tr></tbody></table></figure><h5><a name="33-tls-使用的密码技术" class="md-header-anchor"></a><span>3.3. TLS 使用的密码技术</span></h5><ol start='' ><li><span>伪随机数生成器:秘钥生成随机性,更难被猜测</span></li><li><span>对称密码:对称密码使用的秘钥就是由伪随机数生成,相较于非对称密码,效率更高</span></li><li><span>消息认证码:保证消息信息的完整性、以及验证消息信息的来源</span></li><li><span>公钥密码:证书技术使用的就是公钥密码</span></li><li><span>数字签名:验证证书的签名,确定由真实的某个 CA 颁发 </span></li><li><span>证书:解决公钥的真实归属问题,降低中间人攻击概率 </span></li></ol><h5><a name="34-tls-总结" class="md-header-anchor"></a><span>3.4. TLS 总结</span></h5><p><span>TLS 是一系列密码工具的框架,作为框架,它也是非常的灵活,体现在每个工具套件它都可以替换,即:客户端与服务端之间协商密码套件,从而更难的被攻破,例如使用不同方式的对称密码,或者公钥密码、数字签名生成方式、单向散列函数技术的替换等</span></p><h4><a name="4-rsa-简单示例" class="md-header-anchor"></a><span>4. RSA 简单示例</span></h4><p><span>RSA 是一种公钥密码算法,我们简单的走一遍它的加密解密过程</span><br/><span>加密算法:密文 = (明文^E) mod N,其中公钥为{E,N},即”求明文的E次方的对 N 的余数“</span><br/><span>解密算法:明文 = (密文^D) mod N,其中秘钥为{D,N},即”求密文的D次方的对 N 的余数“</span><br/><span>例:我们已知公钥为{5,323},私钥为{29,323},明文为300,请写出加密和解密的过程: </span></p><blockquote><p><span>加密:密文 = 123 ^ 5 mod 323 = 225</span><br/><span>解密:明文 = 225 ^ 29 mod 323 = [[(225 ^ 5) mod 323] * [(225 ^ 5) mod 323] * [(225 ^ 5) mod 323] * [(225 ^ 5) mod 323] * [(225 ^ 5) mod 323] * [(225 ^ 4) mod 323]] mod 323 = (4 * 4 * 4 * 4 * 4 * 290) mod 323 = 123</span></p></blockquote><h4><a name="端口及对应的服务" class="md-header-anchor"></a><span>端口及对应的服务?</span></h4><ul><li><span>FTP 21 </span></li><li><span>SSH 22 </span></li><li><span>telnet 23 </span></li><li><span>SMTP 25 </span></li><li><span>Domain(域名服务器) 53 </span></li><li><span>HTTP 80</span></li><li><span>POP3 110 </span></li><li><span>NTP(网络时间协议)123 </span></li><li><span>MySQL数据库服务3306 </span></li><li><span>https 443 </span></li><li><span>SNMP(161) </span></li><li><span>TFTP(69)</span></li><li><span>Shell或 cmd 514 </span></li><li><span>POP-2 109 </span></li><li><span>SQL Server 1433 </span></li></ul><h4><a name="各种协议" class="md-header-anchor"></a><span>各种协议</span></h4><ul><li><strong><span>ICMP协议</span></strong><span>: 因特网控制报文协议。它是TCP/IP协议族的一个子协议,用于在IP主机、路由器之间传递控制消息。</span></li><li><strong><span>TFTP协议</span></strong><span>: 是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。</span></li><li><strong><span>HTTP协议</span></strong><span>: 超文本传输协议,是一个属于应用层的面向对象的协议,由于其简捷、快速的方式,适用于分布式超媒体信息系统。</span></li><li><strong><span>DHCP协议</span></strong><span>: 动态主机配置协议,是一种让系统得以连接到网络上,并获取所需要的配置参数手段。</span></li><li><strong><span>NAT协议</span></strong><span>:网络地址转换属接入广域网(WAN)技术,是一种将私有(保留)地址转化为合法IP地址的转换技术,</span></li><li><strong><span>DHCP协议</span></strong><span>:一个局域网的网络协议,使用UDP协议工作,用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段。</span></li></ul><h4><a name="ping的整个过程" class="md-header-anchor"></a><span>Ping的整个过程</span></h4><p><span>同一个局域网中:</span></p><ol start='' ><li><span>Pc1在应用层发起个目标IP位IP2的Ping请求。</span></li><li><span>传输层接到上层请求的数据,将数据分段并加上UDP报头。下传到Internet层。</span></li><li><span>网际层接收来处上层的数据后,根据ICMP协议进行封装,添加PC1的IP为源IP为和PC2IP为目标IP后封装成数据包。下传到网络接口层。</span></li><li><span>网络接口层接收数据包后,进行封装,源MAC地址为PC1的MAC地址,目标MAC地址则查询自己的ARP缓存表获取。如果PC1 arp缓存表中没有目标IP对应的MAC地址,则PC1发出一个ARP广播报文。ARP报文中源MAC地址为Pc1mac地址,源IP地址为pc1 IP,所要请求的是PC2的IP对应的mac地址。</span></li><li><span>PC2收到ARP广播后,进行解封装,发现所请求的MAC地址是自己的。则PC2将PC1的mac地址写入arp缓存表中。然后向PC1发送一个 ARP应答单播。该单播消息包括目标IP为PC1ip,目标Mac为pc1mac地址,源IP为PC2的IP,源Mac为pc2的Mac。</span></li><li><span>Pc1接收到PC2的arp应答报文后,将Pc2的MAC地址存入arp缓存中,并将Pc2的Mac地址作为目标地址封装到数据帧中。发给下层进行网络传输。</span></li><li><span>PC2接收这个帧后,在网络接口层查看目标mac地址是否指向自己。是,PC2则将帧头去掉,向上层传输。</span></li><li><span>Pc2网际层接收到这个信息包,查看包头,发现目标IP和自己匹配,则解封装,将数据向上层传输。</span></li><li><span>传输层接收来自下层的Ping请求的UDP报文,则去掉UDP报头,向应用层传送。</span></li><li><span>应用层收到ping请求后,发送一个PIng回应报文给PC1</span></li></ol><p>&nbsp;</p><h2><a name="五cdn" class="md-header-anchor"></a><span>五、CDN</span></h2><p><span>CDN(Content Delivery Network,</span><strong><span>内容分发网络</span></strong><span>)指基于部署在各地的机房服务器,通过中心平台的负载均衡、内容分发、调度的能力,使用户就近获取所需内容,降低网络延迟,提升用户访问的响应速度和体验度。</span></p><p><span>目前CDN都以缓存网站中的静态数据为主,如CSS、JS、图片和静态页面等数据用户在从主站服务器请求到动态内容后,再从CDN上下载这些静态数据,从而加速网页数据内容的下载速度,如淘宝有90%以上的数据都是由CDN来提供的。</span></p><p><span>通常来说CDN要达到以下几个目标。</span></p><ul><li><span>可扩展( Scalability)。性能可扩展性:应对新增的大量数据、用户和事务的扩展能力。成本可扩展性:用低廉的运营成本提供动态的服务能力和高质量的内容分发。</span></li><li><span>安全性( Security)。强调提供物理设备、网络、软件、数据和服务过程的安全性,(趋势)减少因为DDoS攻击或者其他恶意行为造成商业网站的业务中断。</span></li><li><span>可靠性、响应和执行( Reliability、 Responsiveness和 Performance)。服务可用性指能够处理可能的故障和用户体验下降的问题,通过负载均衡及时提供网络的容错机制。</span></li></ul><h3><a name="cdn的特点" class="md-header-anchor"></a><span>CDN的特点</span></h3><h4><a name="1cdn的关键技术" class="md-header-anchor"></a><span>1.CDN的关键技术</span></h4><p><span>CDN的关键技术包括内容发布、内容路由、内容交换和性能管理,具体如下。 </span></p><ul><li><span>内容发布:借助建⽴索引、缓存、流分裂、组播等技术,将内容发布到网络上距离用户最近的中心机房。 </span></li><li><span>内容路由:通过内容路由器中的重定向(DNS)机制,在多个中心机房的服务器上负载均衡用户的请求,使用户从最近的中心机房获取数据。</span></li><li><span>内容交换:根据内容的可用性、服务器的可用性及用户的背景,在缓 存服务器上利用应用层交换、流分裂、重定向等技术,智能地平衡负载 </span></li></ul><p><span>流量。 </span></p><ul><li><span>性能管理:通过内部和外部监控系统,获取网络部件的信息,测量内容发布的端到端性能(包丢失、延时、平均带宽、启动时间、帧速率等),保证网络处于最佳运⾏状态。</span></li></ul><h4><a name="2cdn的主要特点" class="md-header-anchor"></a><span>2.CDN的主要特点 </span></h4><ul><li><span>本地缓存(Cache)加速:将用户经常访问的数据(尤其静态数据)缓存在本地,以提升系统的响应速度和稳定性。 </span></li><li><span>镜像服务:消除不同运营商之间的网络差异,实现跨运营商的网络加速,保证不同运营商网络中的用户都能得到良好的网络体验。- 远程加速:利用DNS 负载均衡技术为用户选择服务质量最优的服务 器,加快用户远程访问的速度。 </span></li><li><span>带宽优化:⾃动⽣成服务器的远程镜像缓存服务器,远程用户在访问时从就近的缓存服务器上读取数据,减少远程访问的带宽,分担网络流量,并降低原站点的Web服务器负载等。 </span></li><li><span>集群抗攻击:通过网络安全技术和CDN 之间的智能冗余机制,可以有效减少网络攻击对网站的影响。</span></li></ul><h4><a name="3内容分发系统" class="md-header-anchor"></a><span>3.内容分发系统 </span></h4><p><span>将用户请求的数据分发到就近的各个中心机房,以保障为用户提供快速、⾼效的内容服务。缓存的内容包括静态图⽚、视频、文本、用户最近访问的JSON数据等。缓存的技术包括内存环境、分布式缓存、本地文件缓存等。缓存的策略主要考虑缓存更新、缓存淘汰机制。</span></p><h4><a name="4负载均衡系统" class="md-header-anchor"></a><span>4.负载均衡系统 </span></h4><p><span>负载均衡系统是整个CDN系统的核心,负载均衡根据当前网络的流量分布、各中心机房服务器的负载和用户请求的特点将用户的请求负载到不同的中心机房或不同的服务器上,以保障用户内容访问的流畅性。负载均衡系统包括全局负载均衡(GSLB)和本地负载均衡(SLB)。 </span></p><ul><li><span>全局负载均衡主要指跨机房的负载均衡,通过DNS 解析或者应用层 重定向技术将用户的请求负载到就近的中心机房上。 </span></li><li><span>本地负载均衡主要指机房内部的负载均衡,⼀般通过缓存服务器,基于LVS、Nginx、服务网关等技术实现用户访问的负载。</span></li></ul><h4><a name="5管理系统" class="md-header-anchor"></a><span>5.管理系统</span></h4><h3><a name="cnd架构" class="md-header-anchor"></a><span>CND架构</span></h3><p>&nbsp;</p><p><img src="images/image-20210421152338825.png" referrerpolicy="no-referrer" alt="image-20210421152338825"></p><p><span>管理系统分为运营管理和网络管理⼦系统。网络管理系统主要对整个CDN网络资源的运⾏状态进⾏实时监控和管理。运营管理指对CDN⽇ 常运维业务的管理,包括用户管理、资源管理、流量计费和流量限流等。</span></p><p><span>一个用户访问某个静态文件(如CSS文件),这个静态文件的域名假如是cdn.taobao.com,那么首先要向Localdns服务器发起请求,一般经过迭代解析后回到这个域名的注册服务器去解析,一般每个公司都会有一个DNS解析服务器。这时这个DNS解析服务器通常会把它重新 CNAME解析到另外一个域名,而这个域名最终会被指向CDN全局中的DNS负载均衡服务器,再由这个GTM来最终分配是哪个地方的访问用户,返回给离这个访问用户最近的CDN节点拿到DNS解析结果,用户就直接去这个CDN节点访问这个静态文件了,如果这个节点中所请求的文件不存在,就会再回到源站去获取这个文件,然后再返回给用户。</span></p><h3><a name="负载均衡" class="md-header-anchor"></a><span>负载均衡 </span></h3><p><span>负载均衡( Load balance)就是对工作任务进行平衡、分摊到多个操作单元上执行如图片服务器、应用服务器等,共同完成工作任务。它可以提高服务器响应速度及利用效率,避免软件或者硬件模块出现单点失效,解决网络拥塞问题,实现地理位置无关性,为用户提供较一致的访问质量。通常有三种负载均衡架构,分别是链路负载均衡、集群负载均衡和操作系统负载均衡所谓的链路负载均衡也就是前面提到的通过DNS解析成不同的IP,然后用户根据这个IP来访问不同的目标服务器,如图所示。</span></p><p><img src="images/image-20210421152624493.png" referrerpolicy="no-referrer" alt="image-20210421152624493"></p><p><span>负载均衡是由DNs的解析来完成的,用户最终访问哪个 Web Server是由 DNS Server来控制的,在这里就是由 Global DNS Server来动态解析域名服务。这种DNs解析的优点是用户会直接访问目标服务器,而不需要经过其他的代理服务器,通常访问速度会更快。但是也有缺点,由于DNS在用户本地和 Local dns Server都有缓存,一旦某台 Web Server挂掉,就很难及时更新用户的域名解析结构。如果用户的域名没有及时更新,那么用户将无法访问这个域名,带来的后果非常严重。集群负载均衡是另外一种常见的负载均衡方式,它一般分为硬件负载均衡和软件负载均衡。硬件负载均衡一般使用一台专门的硬件设备来转发请求,如图1-18所示硬件负载均衡的关键就是这台价格非常昂贵的设备,如F5,通常为了安全需要一主备。它的优点很显然就是性能非常好,缺点就是非常贵,一般公司是用不起的,还有就是当访问量陡然增大超出服务极限时,不能进行动态扩容软件负载均衡是使用最普遍的一种负载方式,它的特点是使用成本非常低,直接使用廉价的PC就可以搭建。缺点就是一般一次访问请求要经过多次代理服务器,会增加网络延时。</span></p><p><img src="images/image-20210421152728893.png" referrerpolicy="no-referrer" alt="image-20210421152728893"></p><p><img src="images/image-20210421152741649.png" referrerpolicy="no-referrer" alt="image-20210421152741649"></p><p><span>项目中常用的负载均衡有四层负载均衡和七层负载均衡。</span></p><p><span>图中上面的两台是LVS,使用四层负载均衡,也就是在网络层利用IP地址进行地址转发。下面的三台使用Haproxy进行七层负载,也就是可以根据访问用户的HTTP请求头来进行负载均衡,如可以根据不同的URL来将请求转发到特定机器或者根据用户的 Cookie信息来指定访问的机器。</span></p><p><span>最后一种是操作系统负载均衡,就是利用操作系统级别的软中断或者硬件中断来达到负载均衡,如可以设置多队列网卡等来实现。</span></p><p><span>这几种负载均衡不仅在CDN的集群中能使用,而且在Web服务或者分布式数据集群中同样也能使用,但是在这些地方后两种使用得要多一点。</span></p><h4><a name="四层负载均衡与七层负载均衡的对⽐" class="md-header-anchor"></a><span>四层负载均衡与七层负载均衡的对⽐ </span></h4><p><span>四层负载均衡基于IP和端⼝的⽅式实现网络的负载均衡,具体实现为对外提供⼀个虚拟IP和端⼝接收所有用户的请求,然后根据负载均衡配置和负载均衡策略将请求发送给真实的服务器。 </span></p><p><span>七层负载均衡基于URL等资源来实现应用层基于内容的负载均衡,具体实现为通过虚拟的URL或主机名接收所有用户的请求,然后将请求发送给真实的服务器。 </span></p><p><span>四层负载均衡和七层负载均衡的最⼤差别是:四层负载均衡只能针对IP地址和端⼝上的数据做统⼀的分发,⽽七层负载均衡能根据消息的内容做更加详细的有针对性的负载均衡。我们通常使用LVS等技术实现基于Socket的四层负载均衡,使用Nginx等技术实现基于内容分发的七层负 载均衡,⽐如将以“/user/”开头的URL请求负载到单点登录服务器,⽽将以“/business/***”开头的URL请求负载到具体的业务服务器,如图所⽰。</span></p><p><img src="images/image-20210318193657339.png" referrerpolicy="no-referrer" alt="image-20210318193657339"></p><p>&nbsp;</p><h5><a name="1四层负载均衡" class="md-header-anchor"></a><strong><span>1.</span></strong><span>四层负载均衡 </span></h5><p><span>四层负载均衡主要通过修改报文中的目标地址和端⼝来实现报文的分发和负载均衡。以TCP为例,负载均衡设备在接收到第1个来⾃客户端的SYN请求后,会根据负载均衡配置和负载均衡策略选择⼀个最佳的服务 器,并将报文中的目标IP地址修改为该服务器的IP直接转发给该服务 器。TCP连接的建⽴(即三次握⼿过程)是在客户端和服务器端之间完成的,负载均衡设备只起到路由器的转发功能。 </span></p><p><span>四层负载均衡常用的软硬件如下。</span></p><ul><li><span>F5:硬件负载均衡器,功能完备,价格昂贵。 </span></li><li><span>LVS:基于IP+端⼝实现的四层负载软件,常和Keepalive配合使用。</span></li><li><span>Nginx:同时实现四层负载和七层负载均衡,带缓存功能,可基于正则表达式灵活转发。</span></li></ul><h5><a name="2七层负载均衡" class="md-header-anchor"></a><strong><span>2.</span></strong><span>七层负载均衡 </span></h5><p><span>七层负载均衡⼜叫作“内容负载均衡”,主要通过解析报文中真正有意义 的应用层内容,并根据负载均衡配置和负载均衡策略选择⼀个最佳的服 务器响应用户的请求。 </span></p><p><span>七层应用负载可以使整个网络更智能化,七层负载均衡根据不同的数据 类型将数据存储在不同的服务器上来提⾼网络整体的负载能力。⽐如将客户端的基本信息存储在内存较⼤的缓存服务器上,将文件信息存储在磁盘空间较⼤的文件服务器上,将图⽚视频存储在网络I/O能力较强的流媒体服务器上。在接收到不同的客户端的请求时从不同的服务器上获 取数据并将其返回给客户端,提⾼客户端的访问效率。 </span></p><p><span>七层负载均衡常用的软件如下。</span></p><ul><li><span>HAProxy:支持七层代理、会话保持、标记、路径转移等。 </span></li><li><span>Nginx:同时实现四层负载和七层负载均衡,在HTTP和Mail协议上功能⽐较好,性能与HAProxy差不多。</span></li><li><span>Apache:使用简单,性能较差。</span></li></ul><h4><a name="负载均衡算法" class="md-header-anchor"></a><span>负载均衡算法 </span></h4><p><span>常用的负载均衡算法有:轮询均衡(Round Robin)、权重轮询均衡(Weighted Round Robin)、随机均衡(Random)、权重随机均 衡(Weighted Random)、响应速度均衡(Response Time)、最少连接数均衡(Least Connection)、处理能力均衡、DNS响应均衡 (Flash DNS)、散列算法均衡、IP地址散列、URL散列。不同的负载均衡算法适用于不同的应用场景。</span></p><h5><a name="1-轮询均衡round-robin)" class="md-header-anchor"></a><strong><span>1.</span></strong><span> 轮询均衡(</span><strong><span>Round Robin</span></strong><span>) </span></h5><p><span>轮询均衡指将客户端请求轮流分配到 1⾄ </span><em><span>N</span></em><span> 台服务器上,每台服务器 均被均等地分配⼀定数量的客户端请求。轮询均衡算法适用于集群中所有服务器都有相同的软硬件配置和服务能力的情况下。</span></p><h5><a name="2-权重轮询均衡weighted-round-robin)" class="md-header-anchor"></a><strong><span>2.</span></strong><span> 权重轮询均衡(</span><strong><span>Weighted Round Robin</span></strong><span>) </span></h5><p><span>权重轮询均衡指根据每台服务器的不同配置及服务能力,为每台服务器都设置不同的权重值,然后按照设置的权重值轮询地将请求分配到不同的服务器上。例如,服务器A的权重值被设计成 3,服务器B的权重值被设计成 3,服务器C的权重值被设计成 4,则服务器A、B、C将分别承 担 30%、30%、40%的客户端请求。权重轮询均衡算法主要用于服务器配置不均等的集群中。</span></p><h5><a name="3-随机均衡random)" class="md-header-anchor"></a><strong><span>3.</span></strong><span> 随机均衡(</span><strong><span>Random</span></strong><span>) </span></h5><p><span>随机均衡指将来⾃网络的请求随机分配给内部的多台服务器,不考虑服务器的配置和负载情况。</span></p><h5><a name="4-权重随机均衡weighted-random)" class="md-header-anchor"></a><strong><span>4.</span></strong><span> 权重随机均衡(</span><strong><span>Weighted Random</span></strong><span>) </span></h5><p><span>权重随机均衡算法类似于权重轮询算法,只是在分配请求时不再轮询发 送,⽽是随机选择某个权重的服务器发送。</span></p><h5><a name="5响应速度均衡response-time)" class="md-header-anchor"></a><strong><span>5.</span></strong><span>响应速度均衡(</span><strong><span>Response Time</span></strong><span>) </span></h5><p><span>响应速度均衡指根据服务器设备响应速度的不同将客户端请求发送到响应速度最快的服务器上。对响应速度的获取是通过负载均衡设备定时为 每台服务都发出⼀个探测请求(例如Ping)实现的。响应速度均衡能够 为当前的每台服务器根据其不同的负载情况分配不同的客户端请求,这有效避免了某台服务器单点负载过⾼的情况。但需要注意的是,这⾥探测到的响应速度是负载均衡设备到各个服务器之间的响应速度,并不完全代表客户端到服务器的响应速度,因此存在⼀定偏差。</span></p><h5><a name="6-最少连接数均衡least-connection)" class="md-header-anchor"></a><strong><span>6.</span></strong><span> 最少连接数均衡(</span><strong><span>Least Connection</span></strong><span>) </span></h5><p><span>最少连接数均衡指在负载均衡器内部记录当前每台服务器正在处理的连 接数量,在有新的请求时,将该请求分配给连接数最少的服务器。这种均衡算法适用于网络连接和带宽有限、CPU处理任务简单的请求服务,例如FTP。</span></p><h5><a name="7-处理能力均衡" class="md-header-anchor"></a><strong><span>7.</span></strong><span> 处理能力均衡 </span></h5><p><span>处理能力均衡算法将服务请求分配给内部负荷最轻的服务器,负荷是根据服务器的CPU型号、CPU数量、内存⼤⼩及当前连接数等换算⽽成 的。处理能力均衡算法由于考虑到了内部服务器的处理能力及当前网络的运⾏状况,所以相对来说更加精确,尤其适用于七层负载均衡的场景。</span></p><h5><a name="8-dns响应均衡flash-dns)" class="md-header-anchor"></a><strong><span>8. DNS</span></strong><span>响应均衡(</span><strong><span>Flash DNS</span></strong><span>)</span></h5><p><span>DNS响应均衡算法指在分布在不同中心机房的负载均衡设备都收到同⼀个客户端的域名解析请求时,所有负载均衡设备均解析此域名并将解析 后的服务器IP地址返回给客户端,客户端向收到第⼀个域名解析后的IP地址发起请求服务,⽽忽略其他负载均衡设备的响应。这种均衡算法适用于全局负载均衡的场景。</span></p><h5><a name="9散列算法均衡" class="md-header-anchor"></a><strong><span>9.</span></strong><span>散列算法均衡 </span></h5><p><span>散列算法均衡指通过⼀致性散列算法和虚拟节点技术将相同参数的请求 总是发送到同⼀台服务器,该服务器将⻓期、稳定地为某些客户端提供服务。在某个服务器被移除或异常宕机后,该服务器的请求基于虚拟节点技术平摊到其他服务器,⽽不会影响集群整体的稳定性。</span></p><h5><a name="10-ip地址散列" class="md-header-anchor"></a><strong><span>10. IP</span></strong><span>地址散列</span></h5><p><span>IP地址散列指在负载均衡器内部维护了不同链接上客户端和服务器的IP对应关系表,将来⾃同⼀客户端的请求统⼀转发给相同的服务器。该算法能够以会话为单位,保证同⼀客户端的请求能够⼀直在同⼀台服务器 上处理,主要适用于客户端和服务器需要保持⻓连接的场景,⽐如基于TCP⻓连接的应用。</span></p><h5><a name="11-url散列" class="md-header-anchor"></a><strong><span>11. URL</span></strong><span>散列</span></h5><p><span>URL散列指通过管理客户端请求URL信息的散列表,将相同URL的请求转发给同⼀台服务器。该算法主要适用于在七层负载中根据用户请求类型的不同将其转发给不同类型的应用服务器。</span></p><h4><a name="cdn动态加速" class="md-header-anchor"></a><span>CDN动态加速</span></h4><p><span>CDN的动态加速技术也是当前比较流行的一种优化技术,它的技术原理就是在CDN的DNS解析中通过动态的链路探测来寻找回源最好的一条路径,然后通过DNS的调度将所有请求调度到选定的这条路径上回源,从而加速用户访问的效率。</span></p><p><img src="images/image-20210421153018356.png" referrerpolicy="no-referrer" alt="image-20210421153018356"></p><p><span>由于CDN节点是遍布全国的,所以用户接入一个CDN节点后,可以选择一条从离用户最近的CDN节点到源站链路最好的路径让用户走。一个简单的原则就是在每个CDN节点上从源站下载一个一定大小的文件,看哪个链路的总耗时最短,这样可以构成一个链路列表,然后绑定到DNS解析上,更新到CDN的 Local DNS。当然是否走这个链路并不定根据耗时这个唯一条件,有时也要考虑网络成本,例如走某个节点虽然可以节省10ms,但是网络带宽的成本却增加了很多,还有其他网络链路的安全等因素也要综合考虑。</span></p><h4><a name="lvs的原理及应用" class="md-header-anchor"></a><span>LVS的原理及应用 </span></h4><p><span>LVS(Linux Virtual Server)是⼀个虚拟的服务器集群系统,采用IP负载均衡技术将请求均衡地转移到不同的服务器上执⾏,且通过调度器⾃动屏蔽故障服务器,从⽽将⼀组服务器构成⼀个⾼性能、⾼可用的虚 拟服务器。整个服务器集群的结构对用户是透明的,无须修改客户端和服务器端的程序,便可实现客户端到服务器的负载均衡。</span></p><h5><a name="1lvs的原理" class="md-header-anchor"></a><strong><span>1.LVS</span></strong><span>的原理 </span></h5><p><span>LVS由前端的负载均衡器(Load Balancer,LB)和后端的真实服务器(Real Server,RS)群组成,在真实服务器间可通过局域网或⼴域网 连接。LVS的这种结构对用户是透明的,用户只需要关注作为LB的虚拟 服务器(Virtual Server),⽽不需要关注提供服务的真实服务器群。 </span></p><p><span>在用户的请求被发送给虚拟服务器后,LB根据设定的包转发策略和负载均衡调度算法将用户的请求转发给真实服务器,真实服务器再将用户请 求的结果返回给用户。实现LVS的核心组件有负载均衡调度器、服务器池和共享存储。 </span></p><ul><li><span>负载均衡调度器(Load Balancer/Director):是整个集群对外提供服务的⼊⼝,通过对外提供⼀个虚拟IP 来接收客户端请求。在客户端 将请求发送到该虚拟IP 后,负载均衡调度器会负责将请求按照负载均衡策略发送到⼀组具体的服务器上。 </span></li><li><span>服务器池(Server Pool):服务器池是⼀组真正处理客户端请求的真实服务器,具体执⾏的服务有WEB、MAIL、FTP和DNS等。 </span></li><li><span>共享存储(Shared Storage):为服务器池提供⼀个共享的存储区,使得服务器池拥有相同的内容,提供相同的服务。 </span></li></ul><p><span>在接收LVS内部数据的转发流程前,这⾥先以表介绍LVS技术中常用的⼀些名词,以让我们更好地理解LVS的工作原理。 </span></p><p><img src="images/image-20210318193742471.png" referrerpolicy="no-referrer" alt="image-20210318193742471"></p><p><span>LVS的IP负载均衡技术是通过IPVS模块实现的。IPVS是LVS集群系统的核心软件,被安装在Director Server上,同时在Director Server上虚 拟出⼀个IP地址。用户通过这个虚拟的IP地址访问服务器。这个虚拟的IP地址⼀般被称为LVS的VIP,即Virtual IP。访问的请求⾸先经过VIP到达负载调度器,然后由负载调度器从真实服务器列表中选取⼀个服务节 点响应用户的请求。</span></p><h5><a name="2lvs数据转发" class="md-header-anchor"></a><strong><span>2.LVS</span></strong><span>数据转发</span></h5><p><span>LVS的数据转发流程是LVS设计的核心部分,如下所述,如图所⽰。 </span></p><p><span>(1)PREROUTING链接收用户请求:客户端向PREROUTING链发送请求。 </span></p><p><span>(2)INPUT链转发:在PREROUTING链通过RouteTable列表发现请求数据包的目的地址是本机时,将数据包发送给INPUT链。 </span></p><p><span>(3)IPVS检查:IPVS检查INPUT链上的数据包,如果数据包中的目的地址和端⼝不在规则列表中,则将该数据包发送到用户空间的ipvsadm。ipvsadm主要用于用户定义和管理集群。 </span></p><p><span>(4)POSTROUTING链转发:如果数据包⾥⾯的目的地址和端⼝都在规则⾥⾯,那么将该数据包中的目的地址修改为事先定义好的真实服务 器地址,通过FORWARD将数据发送到POSTROUTING链。 </span></p><p><span>(5)真实服务器转发:POSTROUTING链根据数据包中的目的地址将数据包转发到真实服务器。</span></p><p><img src="images/image-20210318193811663.png" referrerpolicy="no-referrer" alt="image-20210318193811663"></p><h5><a name="3lvs-nat模式" class="md-header-anchor"></a><strong><span>3.LVS NAT</span></strong><span>模式 </span></h5><p><span>LVS NAT(Network Address Translation)即网络地址转换模式, 具体的实现流程如图所⽰。 </span></p><p><img src="images/image-20210318193835055.png" referrerpolicy="no-referrer" alt="image-20210318193835055"></p><p><span>NAT模式通过对请求报文和响应报文的地址进⾏改写完成对数据的转发,具体流程如下。(1)客户端将请求报文发送到LVS,请求报文的源地址是CIP(Client</span></p><p><span>IP Address,客户端IP),目标地址是VIP(Virtual IP Address,虚拟IP)。 </span></p><p><span>(2)LVS在收到报文后,发现请求的IP地址在LVS的规则列表中存在,则将客户端请求报文的目标地址VIP修改为RIP(Real-server IP Address,后端服务器的真实IP),并将报文发送到具体的真实服务器上。</span></p><p><span>(3)真实服务器在收到报文后,由于报文的目标地址是⾃⼰的IP,所以会响应该请求,并将响应报文返回给LVS。 </span></p><p><span>(4)LVS在收到数据后将此报文的源地址修改为本机IP地址,即VIP, 并将报文发送给客户端。</span></p><p><span>NAT模式的特点如下:</span></p><ul><li><span>请求的报文和响应的报文都需要通过LVS进⾏地址改写,因此在并发访问量较⼤的时候LVS存在瓶颈问题,⼀般适用于节点不是很多的情况 下。</span></li><li><span>只需要在LVS上配置⼀个公网IP即可。</span></li><li><span>每台内部的真实服务器的网关地址都必须是LVS的内网地址。 </span></li><li><span>NAT 模式支持对IP 地址和端⼝进⾏转换,即用户请求的端⼝和真实 服务器的端⼝可以不同。</span></li></ul><h5><a name="4lvs-dr模式" class="md-header-anchor"></a><strong><span>4.LVS DR</span></strong><span>模式 </span></h5><p><span>LVS DR(Direct Routing)模式用直接路由技术实现,通过改写请求报文的MAC地址将请求发送给真实服务器,具体的实现流程如图所⽰。</span></p><p><img src="images/image-20210318193857254.png" referrerpolicy="no-referrer" alt="image-20210318193857254"></p><p><span>LVD DR模式是局域网中经常被用到的⼀种模式,其报文转发流程如下。</span></p><p><span>(1)客户端将请求发送给LVS,请求报文的源地址是CIP,目标地址是VIP。 </span></p><p><span>(2)LVS在收到报文后,发现请求在规则中存在,则将客户端请求报文的源MAC地址改为⾃⼰的DIP(Direct IP Address,内部转发IP)的MAC地址,将目标MAC改为RIP的MAC地址,并将此包发送给真实服务器。 </span></p><p><span>(3)真实服务器在收到请求后发现请求报文中的目标MAC是⾃⼰,就会将此报文接收下来,在处理完请求报文后,将响应报文通过lo(回环路由)接⼝发送给eth0网卡,并最终发送给客户端。</span></p><p><span>NAT模式的特点如下:</span></p><ul><li><span>通过LVS修改数据包的目的MAC地址实现转发。注意,源IP地址仍然是CIP,目标IP地址仍然是VIP地址。- 请求的报文均经过LVS,⽽真实服务器响应报文时无须经过LVS,因 此在并发访问量⼤时⽐NAT模式的效率⾼很多。 </span></li><li><span>因为DR 模式是通过MAC 地址改写机制实现转发的,因此所有真实服务器节点和LVS只能被部署在同⼀个局域网内。 </span></li><li><span>真实服务器主机需要绑定VIP 地址在lo接⼝(掩码 32 位)上,并且需要配置ARP抑制。 </span></li><li><span>真实服务器节点的默认网关无须被配置为LVS网关,只需要被配置为上级路由的网关,能让真实服务器直接出网即可。 </span></li><li><span>DR 模式仅做MAC 地址的改写,不能改写目标端⼝,即真实服务器端⼝和VIP端⼝必须相同。</span></li></ul><h5><a name="5lvs-tun模式" class="md-header-anchor"></a><strong><span>5.LVS TUN</span></strong><span>模式</span></h5><p><span>TUN(IP Tunneling)通过IP隧道技术实现,具体的实现流程如图所⽰。 </span></p><p><span>LVS TUN模式常用于跨网段或跨机房的负载均衡,具体的报文转发流程 如下。 </span></p><p><span>(1)客户端将请求发送给前端的LVS,请求报文的源地址是CIP,目标地址是VIP。 </span></p><p><span>(2)LVS在收到报文后,发现请求在规则⾥中存在,则将在客户端请求报文的⾸部再封装⼀层IP报文,将源地址改为DIP,将目标地址改为RIP,并将此包发送给真实服务器。</span></p><p><img src="images/image-20210318193925781.png" referrerpolicy="no-referrer" alt="image-20210318193925781"></p><p>&nbsp;</p><p><span>(3)真实服务器在收到请求报文后会先拆开第1层封装,因为发现⾥⾯ 还有⼀层IP⾸部的目标地址是⾃⼰lo接⼝上的VIP,所以会处理该请求报文,并将响应报文通过lo接⼝发送给eth0网卡,并最终发送给客户端。</span></p><p><span>TUN模式的特点如下。</span></p><ul><li><span>UNNEL模式需要设置lo接⼝的VIP不能在公网上出现。</span></li><li><span>TUNNEL模式必须在所有的真实服务器上绑定VIP的IP地址。 </span></li><li><span>TUNNEL 模式中VIP→真实服务器的包通信通过TUNNEL 隧道技术实现,不管是内网还是外网都能通信,所以不需要LVS和真实服务器在同⼀个网段内。 </span></li><li><span>在TUNNEL 模式中,真实服务器会把响应报文直接发送给客户端⽽不经过LVS,负载能力较强。</span></li><li><span>TUNNEL 模式采用的是隧道模式,使用⽅法相对复杂,⼀般用于跨机房LVS实现,并且需要所有服务器都支持IP Tunneling 或 IP Encapsulation协议。</span></li></ul><p><strong><span>6.LVS FULLNAT</span></strong><span>模式 </span></p><p><span>无论是DR模式还是NAT模式,都要求LVS和真实服务器在同⼀个VLAN下,否则LVS无法作为真实服务器的网关,因此跨VLAN的真实服务器无法接⼊。同时,在流量增⼤、真实服务器⽔平扩容时,单点LVS会成为瓶颈。</span></p><p><span>FULLNAT能够很好地解决LVS和真实服务器跨VLAN的问题,在跨VLAN问题解决后,LVS和真实服务器不再存在VLAN上的从属关系,可 以做到多个LVS对应多个真实服务器,解决⽔平扩容的问题。FULLNAT 的原理是在NAT的基础上引⼊Local Address IP(内网IP地址),将CIP→VIP转换为LIP→RIP,⽽LIP和RIP均为IDC内网IP,可以通过交换机实现跨VLAN通信。FULLNAT的具体实现流程如图所⽰。 </span></p><p><img src="images/image-20210318193952582.png" referrerpolicy="no-referrer" alt="image-20210318193952582"></p><p>&nbsp;</p><p><span>LVS FULLNAT具体的报文转发流程如下。</span></p><p><span>(1)客户端将请求发送给LVS的DNAT,请求报文的源地址是CIP,目 标地址是VIP。 </span></p><p><span>(2)LVS在收到数据后将源地址CIP修改成LIP(Local IP Address,LVS的内网IP),将目标地址VIP修改为RIP,并将数据发送到真实服务器。多个LIP在同⼀个IDC数据中心,可以通过交换机跨VLAN通信。 </span></p><p><span>(3)真实服务器在收到数据包并处理完成后,将目标地址修改为LIP,将源地址修改为RIP,最终将这个数据包返回给LVS。 </span></p><p><span>(4)LVS在收到数据包后,将数据包中的目标地址修改为CIP,将源地址修改为VIP,并将数据发送给客户端。</span></p><h4><a name="nginx反向代理与负载均衡" class="md-header-anchor"></a><span>Nginx反向代理与负载均衡 </span></h4><p><span>⼀般的负载均衡软件如LVS实现的功能只是对请求数据包的转发和传递,从负载均衡下的节点服务器来看,接收到的请求还是来⾃访问负载均衡器的客户端的真实用户;⽽反向代理服务器在接收到用户的访问请 求后,会代理用户重新向节点服务器(We b服务器、文件服务器、视频服务器)发起请求,反向代理服务器和节点服务器做具体的数据交互,最后把数据返回给客户端用户。在节点服务器看来,访问的节点服 务器的客户端就是反向代理服务器,⽽⾮真实的网站访问用户,具体原理如图所⽰。</span></p><p><img src="images/image-20210318194021951.png" referrerpolicy="no-referrer" alt="image-20210318194021951"></p><h5><a name="1upstreammodule" class="md-header-anchor"></a><span>1.upstream_module</span></h5><p><span>ngx_http_upstream_module是Nginx的负载均衡模块,可以实现网站的负载均衡功能即节点的健康检查。upstream模块允许Nginx定义⼀组或多组节点服务器,在使用时可通过proxy_pass代理⽅式把网站 的请求发送到事先定义好的对应Upstream组的名字上。具体的upstream定义如下: </span></p><p><img src="images/image-20210318194036167.png" referrerpolicy="no-referrer" alt="image-20210318194036167"></p><p><span>如上代码定义了名为restLVSServer的upstream,并在其中定义了 3 个服务地址,在用户请求restLVSServer服务时,Nginx会根据权重将请求转发到具体的服务器。常用的upstream配置如下。</span></p><ul><li><span>weight:服务器权重。 </span></li><li><span>max_fails:Nginx尝试连接后端服务器的最⼤失败次数,如果失败时⼤于max_fails,则认为该服务器不可用。 </span></li><li><span>fail_timeout:max_fails和fail_timeout⼀般会关联使用,如果某台服务器在fail_timeout时间内出现了max_fails次连接失败,那么Nginx会认为其已经挂掉,从⽽在fail_timeout时间内不再去请求它,fail_timeout默认是 10s,max_fails默认是1,即在默认情况下只要 发⽣错误就认为服务器挂了,如果将max_fails设置为0,则表⽰取消这项检查。</span></li><li><span>backup:表⽰当前服务器是备用服务器,只有其他⾮backup后端服务器都挂掉或很忙时,才会分配请求给它。</span></li><li><span>down:标志服务器永远不可用。</span></li></ul><h5><a name="2proxypass" class="md-header-anchor"></a><span>2.proxy_pass</span></h5><p><span>proxy_pass指令属于ngx_http_proxy_module模块,此模块可以将请求转发到另⼀台服务器,在实际的反向代理工作中,会通过location功能匹配指定的URI,然后把接收到的服务匹配URI的请求通过proxy_pass抛给定义好的upstream节点池。具体的proxy_pass定义如下: </span></p><p><img src="images/image-20210318194048938.png" referrerpolicy="no-referrer" alt="image-20210318194048938"></p><p><span>如上代码定义了⼀个download的反向代理,在客户端请求/download时,Nginx会将具体的请求转发给proxy_pass配置的地址处理请求,这⾥配置的地址是</span><a href='http://192.168.1.13:9000/download/vedio/' target='_blank' class='url'>http://192.168.1.13:9000/download/vedio/</a><span>。常用的proxy_pass配置如表所⽰。</span></p><p><img src="images/image-20210318194109970.png" referrerpolicy="no-referrer" alt="image-20210318194109970"></p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p></div>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chengchuang/micode_lesson.git
git@gitee.com:chengchuang/micode_lesson.git
chengchuang
micode_lesson
觅友突击课程
master

搜索帮助