计算机网络-应用层笔记
计算机网络-应用层笔记
忧伤的小马
:博客主页:https://blog.csdn.net/qq_45504981
github传送门:https://github.com/rzy0901
文章目录
- 2.1 principles of network applications
- 2.2 Web and HTTP
- 2.3 electronic mail: SMTP,POP3,IMAP
- 2.4 DNS
- 2.5 P2P applications
- 2.6 Video streaming and content distribution networks (CDNs)
- 2.7 socket programming with UDP and TCP
- Reference:
2.1 principles of network applications
network apps:
Some network apps:
e-mail, web, text messaging, remote login, P2P file sharing, multi-user network games, streaming stored video(YouTube, Hulu, Netflix), voice over IP (e.g. Skype), real-time video conferencing, social networking, search.
Creating a network app:
- run on (different) end systems;
- communicate over network;
client-server:
- server: always on host, permanently ip, data centers for scaling.
- client: 可以断开,dynamic ip;
P2P:
- no always on server;
- arbitrary end systems;
- peers are intermittently connected and change IP addresses(断续连接,改变ip; )
- self-scalability.
Process, socket(套接字):
Who?: Process send/receive message to/from network.
Where?: Process send/receive message to/from sockets.
Process with same hosts: inter-process communication( defined by OS)
内部(process with same host)进程通信由操作系统决定。
P2P 既有server process 又有 client process.
IP and Port number
process has identifier (both ip address and port numbers)
32-bit ip address.
many processes run on same host.
所以需要端口?
Example port number:
- HTTP server: 80;
- Mail server: 25;
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210102222855928.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDA3Nzk1NQ==,size_16,color_FFFFFF,t_70#pic_center) ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210102222903639.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDA3Nzk1NQ==,size_16,color_FFFFFF,t_70#pic_center)
Internet transfer protocols service
TCP UDP 是传输层协议
TCP service:
Reliable transport; Flow control; Congestion control; Connection-oriented;
Dose not provide timing, minimum throughput guarantee, and security.
UDP service:
- Unreliable data transfer.
- Does not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, or connection setup.
2.2 Web and HTTP
Web
Web page consists of objects.
object can be HTML file, JPEG image, Java applet, audio file,…
web page consists of base HTML-file which includes several referenced objects.
Each object is addressable by a URL.
HTML 基本文件 (bases HTML-file) 通过对象的URL地址引用页面中的对象。
HTTP overview
Hypertext transfer protocol
Web’s application layer protocol (应用层协议)
client/server mode.
uses TCP.(步骤从上到下1、2、3)
#mermaid-svg-CTodsgHcbd7p2pHK .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-CTodsgHcbd7p2pHK .label text{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .node rect,#mermaid-svg-CTodsgHcbd7p2pHK .node circle,#mermaid-svg-CTodsgHcbd7p2pHK .node ellipse,#mermaid-svg-CTodsgHcbd7p2pHK .node polygon,#mermaid-svg-CTodsgHcbd7p2pHK .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-CTodsgHcbd7p2pHK .node .label{text-align:center;fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .node.clickable{cursor:pointer}#mermaid-svg-CTodsgHcbd7p2pHK .arrowheadPath{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-CTodsgHcbd7p2pHK .flowchart-link{stroke:#333;fill:none}#mermaid-svg-CTodsgHcbd7p2pHK .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-CTodsgHcbd7p2pHK .edgeLabel rect{opacity:0.9}#mermaid-svg-CTodsgHcbd7p2pHK .edgeLabel span{color:#333}#mermaid-svg-CTodsgHcbd7p2pHK .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-CTodsgHcbd7p2pHK .cluster text{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-CTodsgHcbd7p2pHK .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-CTodsgHcbd7p2pHK text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-CTodsgHcbd7p2pHK .actor-line{stroke:grey}#mermaid-svg-CTodsgHcbd7p2pHK .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-CTodsgHcbd7p2pHK .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-CTodsgHcbd7p2pHK #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-CTodsgHcbd7p2pHK .sequenceNumber{fill:#fff}#mermaid-svg-CTodsgHcbd7p2pHK #sequencenumber{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK #crosshead path{fill:#333;stroke:#333}#mermaid-svg-CTodsgHcbd7p2pHK .messageText{fill:#333;stroke:#333}#mermaid-svg-CTodsgHcbd7p2pHK .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-CTodsgHcbd7p2pHK .labelText,#mermaid-svg-CTodsgHcbd7p2pHK .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-CTodsgHcbd7p2pHK .loopText,#mermaid-svg-CTodsgHcbd7p2pHK .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-CTodsgHcbd7p2pHK .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-CTodsgHcbd7p2pHK .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-CTodsgHcbd7p2pHK .noteText,#mermaid-svg-CTodsgHcbd7p2pHK .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-CTodsgHcbd7p2pHK .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-CTodsgHcbd7p2pHK .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-CTodsgHcbd7p2pHK .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-CTodsgHcbd7p2pHK .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .section{stroke:none;opacity:0.2}#mermaid-svg-CTodsgHcbd7p2pHK .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-CTodsgHcbd7p2pHK .section2{fill:#fff400}#mermaid-svg-CTodsgHcbd7p2pHK .section1,#mermaid-svg-CTodsgHcbd7p2pHK .section3{fill:#fff;opacity:0.2}#mermaid-svg-CTodsgHcbd7p2pHK .sectionTitle0{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .sectionTitle1{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .sectionTitle2{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .sectionTitle3{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-CTodsgHcbd7p2pHK .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .grid path{stroke-width:0}#mermaid-svg-CTodsgHcbd7p2pHK .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-CTodsgHcbd7p2pHK .task{stroke-width:2}#mermaid-svg-CTodsgHcbd7p2pHK .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .taskText:not([font-size]){font-size:11px}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-CTodsgHcbd7p2pHK .task.clickable{cursor:pointer}#mermaid-svg-CTodsgHcbd7p2pHK .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-CTodsgHcbd7p2pHK .taskText0,#mermaid-svg-CTodsgHcbd7p2pHK .taskText1,#mermaid-svg-CTodsgHcbd7p2pHK .taskText2,#mermaid-svg-CTodsgHcbd7p2pHK .taskText3{fill:#fff}#mermaid-svg-CTodsgHcbd7p2pHK .task0,#mermaid-svg-CTodsgHcbd7p2pHK .task1,#mermaid-svg-CTodsgHcbd7p2pHK .task2,#mermaid-svg-CTodsgHcbd7p2pHK .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutside0,#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutside2{fill:#000}#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutside1,#mermaid-svg-CTodsgHcbd7p2pHK .taskTextOutside3{fill:#000}#mermaid-svg-CTodsgHcbd7p2pHK .active0,#mermaid-svg-CTodsgHcbd7p2pHK .active1,#mermaid-svg-CTodsgHcbd7p2pHK .active2,#mermaid-svg-CTodsgHcbd7p2pHK .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-CTodsgHcbd7p2pHK .activeText0,#mermaid-svg-CTodsgHcbd7p2pHK .activeText1,#mermaid-svg-CTodsgHcbd7p2pHK .activeText2,#mermaid-svg-CTodsgHcbd7p2pHK .activeText3{fill:#000 !important}#mermaid-svg-CTodsgHcbd7p2pHK .done0,#mermaid-svg-CTodsgHcbd7p2pHK .done1,#mermaid-svg-CTodsgHcbd7p2pHK .done2,#mermaid-svg-CTodsgHcbd7p2pHK .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-CTodsgHcbd7p2pHK .doneText0,#mermaid-svg-CTodsgHcbd7p2pHK .doneText1,#mermaid-svg-CTodsgHcbd7p2pHK .doneText2,#mermaid-svg-CTodsgHcbd7p2pHK .doneText3{fill:#000 !important}#mermaid-svg-CTodsgHcbd7p2pHK .crit0,#mermaid-svg-CTodsgHcbd7p2pHK .crit1,#mermaid-svg-CTodsgHcbd7p2pHK .crit2,#mermaid-svg-CTodsgHcbd7p2pHK .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-CTodsgHcbd7p2pHK .activeCrit0,#mermaid-svg-CTodsgHcbd7p2pHK .activeCrit1,#mermaid-svg-CTodsgHcbd7p2pHK .activeCrit2,#mermaid-svg-CTodsgHcbd7p2pHK .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-CTodsgHcbd7p2pHK .doneCrit0,#mermaid-svg-CTodsgHcbd7p2pHK .doneCrit1,#mermaid-svg-CTodsgHcbd7p2pHK .doneCrit2,#mermaid-svg-CTodsgHcbd7p2pHK .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-CTodsgHcbd7p2pHK .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-CTodsgHcbd7p2pHK .milestoneText{font-style:italic}#mermaid-svg-CTodsgHcbd7p2pHK .doneCritText0,#mermaid-svg-CTodsgHcbd7p2pHK .doneCritText1,#mermaid-svg-CTodsgHcbd7p2pHK .doneCritText2,#mermaid-svg-CTodsgHcbd7p2pHK .doneCritText3{fill:#000 !important}#mermaid-svg-CTodsgHcbd7p2pHK .activeCritText0,#mermaid-svg-CTodsgHcbd7p2pHK .activeCritText1,#mermaid-svg-CTodsgHcbd7p2pHK .activeCritText2,#mermaid-svg-CTodsgHcbd7p2pHK .activeCritText3{fill:#000 !important}#mermaid-svg-CTodsgHcbd7p2pHK .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-CTodsgHcbd7p2pHK g.classGroup text .title{font-weight:bolder}#mermaid-svg-CTodsgHcbd7p2pHK g.clickable{cursor:pointer}#mermaid-svg-CTodsgHcbd7p2pHK g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-CTodsgHcbd7p2pHK g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-CTodsgHcbd7p2pHK .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-CTodsgHcbd7p2pHK .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-CTodsgHcbd7p2pHK .dashed-line{stroke-dasharray:3}#mermaid-svg-CTodsgHcbd7p2pHK #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK .commit-id,#mermaid-svg-CTodsgHcbd7p2pHK .commit-msg,#mermaid-svg-CTodsgHcbd7p2pHK .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-CTodsgHcbd7p2pHK g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-CTodsgHcbd7p2pHK g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-CTodsgHcbd7p2pHK g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-CTodsgHcbd7p2pHK .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-CTodsgHcbd7p2pHK .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-CTodsgHcbd7p2pHK .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-CTodsgHcbd7p2pHK .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-CTodsgHcbd7p2pHK .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-CTodsgHcbd7p2pHK .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-CTodsgHcbd7p2pHK .edgeLabel text{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-CTodsgHcbd7p2pHK .node circle.state-start{fill:black;stroke:black}#mermaid-svg-CTodsgHcbd7p2pHK .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-CTodsgHcbd7p2pHK #statediagram-barbEnd{fill:#9370db}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-state .divider{stroke:#9370db}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-CTodsgHcbd7p2pHK .note-edge{stroke-dasharray:5}#mermaid-svg-CTodsgHcbd7p2pHK .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-CTodsgHcbd7p2pHK .error-icon{fill:#522}#mermaid-svg-CTodsgHcbd7p2pHK .error-text{fill:#522;stroke:#522}#mermaid-svg-CTodsgHcbd7p2pHK .edge-thickness-normal{stroke-width:2px}#mermaid-svg-CTodsgHcbd7p2pHK .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-CTodsgHcbd7p2pHK .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-CTodsgHcbd7p2pHK .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-CTodsgHcbd7p2pHK .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-CTodsgHcbd7p2pHK .marker{fill:#333}#mermaid-svg-CTodsgHcbd7p2pHK .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}#mermaid-svg-CTodsgHcbd7p2pHK {color: rgba(0, 0, 0, 0.75);font: ;}HTTP messages exchangedHTTP messages exchangedclient initiate TCP connectionserver accepts TCP connection from clientbrowser (HTTP client)Web server (HTTP server)TCP connection closedHTTP is stateless .
server maintains no information about past client request.
HTTP connection
non-persistent HTTP: (非持续连接HTTP)
At most one object sent over TCP connection.
Connection then closed.
Downloading multiple objects required multiple connections.
一个connection传一个object. 每传完object都会关闭connection.
persistent HTTP: (持续连接HTTP)
multiple objects can be sent over single TCP connection between client, server.
一个connection传多个object.
Non-persistent HTTP
第4步,HTTP server 通知TCP断开connection,但是直到TCP确认客户完整收到响应报文为止,它才会实际中断连接。
Non-persistent HTTP: response time
RTT (definition): time for a small packet to travel from client to server and back.
传输一个packet往返的时间。
Non-persistent HTTP: response time = 2*RTT+file transmission time.
一个RTT建立connection, 一个RTT传输HTTP request和HTTP response
Persistent HTTP
server leaves connection open after sending response.
One RTT needed.
HTTP message
HTTP request message
-
CR: carriage return;(回车) LF: line feed(换行) 其实就是\r\rn
request line coding = ASCII (human-readable format)
request line = method + url + http version
Uploading form input: POST method, URL method.
Method types:
HTTP/1.0:
GET. POST, HEAD
HTTP/1.1:
GET,POST,HEAD.
PUT, DELETE.(上传或删除指定URL文件)
HTTP response messages
User-server state: Cookies
Four components for “cookie”: (对应下图蓝色圆柱)
- cookie header line in HTTP response message.
- cookie header line in next HTTP request message.
- cookie file kept on user’s host, managed by user’s browser.
- back-end database at Web site.
第一次request没有cookie, 创建ID:1678,返回response message (cookie header line: Set cookie:1678)
Web caches (proxy server) 缓存器、代理服务器
goal: satisfy client request without involving origin server
if HTTP request in cache:
return HTTP response from cache
else:
cache requests object from origin server
then return object to client
Cache acts as server for original requesting client.
Cache acts as client to origin server.
Lower link utilization, lower delay.
Typically cache is installed by ISP (university, company, residential ISP).
1.减少响应时间 2.减少“交通压力”3.使内容提供商更加有效传输数据Example:
Conditional GET
Goal: don’t send object if cache has up-to-date cached version
cache: specify date of cached copy in HTTP request:
- If-modified-since: <date>
server: response contains no object if cached copy is up-to-date:
- HTTP/1.0 304 Not Modified
2.3 electronic mail: SMTP,POP3,IMAP
Electronic mail:
Three major components:
- user agent;
- mail server;
- SMTP (simple mail transfer control);
User agent:
composing, editing, reading mail messages;
outgoing, incoming messages stored on server;
mailbox : incoming messages
message queue: outgoing messages
Mail server:
- mailbox contains incoming messages for user;
- message queue of outgoing (to be sent) mail messages;
- SMTP protocol between mail servers to send email messages;
Scenario:
(1)Alice uses UA to compose message to bob@someschool.edu;
(2)Alice’s UA sends message to her mail server; message placed in message queue;
(3)client side of SMTP opens TCP connection with Bob’s mail server;
(4)SMTP client sends Alice’s message over the TCP connection;
(5)Bob’s mail server places the message in Bob’s mailbox;
(6)Bob invokes his user agent to read message;
Electronic Mail: SMTP
uses TCP to reliably transfer email message from client to server, port 25;
direct transfer: sending server to receiving server;
three phases of transfer:
handshaking (greeting);
transfer of messages;
closure;
command/response interaction (like HTTP):
- commands: ASCII text
- response: status code and phrase
messages must be in 7-bit ASCII;
SMTP uses persistent connections;
\r\n.\r\n
determines end of message.
三次握手以后,连接建立成功,服务器推送就绪信息:
- 220: 服务就绪
server: 交代认证服务器域名,发件者邮箱,收件者邮箱:
- 250
client: 发送
DATA\r\n
server: 服务器返回354,表示自己已经作好接受邮件的准备.
client: 客户端发送邮件正文
client: 正文结束符
.
server: 服务端返回250表示成功。
client: 邮件发送结束,客户端请求断开连接。 发送
QUIT\r\n
server: 服务器返回211,提示断开申请被采纳,并主动断开连接,整个邮件发送过程结束。
SMTP vs HTTP
SMTP: push (推协议)
HTTP: pull (拉协议)
both have ASCII command/response interaction, status codes;
HTTP: each object encapsulated in its own response message;
网页上每个object都有自己的url链接?
SMTP: multiple objects sent in multipart message;
邮件很多附件?
Mail access protocols (邮件访问协议)
POP: Post Office Protocol [RFC 1939]: authorization, download.
IMAP: Internet Mail Access Protocol [RFC 1730]: more features, including manipulation of stored messages on server.
HTTP: gmail, Hotmail, Yahoo! Mail, etc.
2.4 DNS
Domain Name system:
distributed database implemented in hierarchy of many name servers.
application-layer protocol: hosts, name servers communicate to resolve names (address/name translation)
域名,ip映射
DNS service:
Host name to ip address translation.
Host aliasing.
Mail server aliasing.
Load distribution.
replicated Web servers: many IP addresses correspond to one name.
DNS: a distributed, hierarchical database:
查询 www.amazon.com ip地址:
- 查询root dns server返回com DNS server
- 查询 .com DNS server返回 amazon.com DNS server;
- 查询 amazon.com DNS server 得到 www.amazon.com ip地址;
查询 www.sustech.edu.cn ip地址:
- root dns server 返回 cn;
- top 返回 edu.cn;
- authoritative 返回 sustech.edu.cn ➡️ www.sustech.edu.cn;
DNS servers
root name servers (根DNS服务器);
- contacts authoritative name server if name mapping not known
- gets mapping
- returns mapping to local name server
top-level domain (TLD) servers (顶级域服务器);
com org net edu aero cn
Authoritative DNS servers(权威DNS服务器);
- organization’s own DNS servers
- providing authoritative hostname to IP mappings for organization’s named hosts
- can be maintained by organization or service provider
Local DNS name server. (default name server)
does not strictly belong to hierarchy
each ISP (residential ISP, company, university) has one
when host makes DNS query, query is sent to its local DNS server
has local cache of recent name-to-address translation pairs;
(but may be out of date!)
acts as proxy, forwards query into hierarchy;
2.5 P2P applications
Pure P2P architecture:
no always on server;
arbitrary end systems;
peers are intermittently connected and change IP addresses(断续连接,改变ip; )
self-scalability.
examples:
- file distribution (BitTorrent)
- Streaming (KanKan)
- VoIP (Skype)
File distribution:
Question: how much time to distribute file (size F) from one server to N peers?
Parameter | Description |
---|---|
usu_sus | server upload capacity |
uiu_iui | peer iii upload capacity |
did_idi | peer iii download capacity |
dmind_{min}dmin | minimum download capacity: dmin=min{d1,d2,...,dN}d_{min}=min\{d_1,d_2,...,d_N\}dmin=min{d1,d2,...,dN} unit: bits/secbits/secbits/sec |
Dc−sD_{c-s}Dc−s | time to distribute FFF to NNN clients |
FFF | File size |
- For client server model:
Dc−s≥max{NF/us,F/dmin}D_{c-s}\geq max\{NF/u_s,F/d_{min}\} Dc−s≥max{NF/us,F/dmin}
N 足够大,由NF/uSNF/u_SNF/uS决定
- For P2P model:
Dc−s≥max{F/us,F/dmin,NF/(us+∑ui)}D_{c-s}\geq max\{F/u_s,F/d_{min},NF/(u_s+\sum u_i)\} Dc−s≥max{F/us,F/dmin,NF/(us+∑ui)}
极限为:max{F/us,F/dmin,F/uimin}max\{F/u_s,F/d_{min},F/u_{i_{min}}\}max{F/us,F/dmin,F/uimin}
P2P file distribution: BitTorrent
- file divided into 256 Kb chunks.
- peers in torrent send/receive file chunks.
2.6 Video streaming and content distribution networks (CDNs)
Bob通过local dns server访问netcinema,netcinema给了他一个新的url --> Bob 通过新的url 访问资源。
2.7 socket programming with UDP and TCP
略
- 转载请注明出处:
https://blog.csdn.net/weixin_44077955/article/details/112125922
文章难免有疏漏错误之处,欢迎私信博主及时更正,大家共同进步
计算机网络-应用层笔记相关推荐
- 计算机网络应用层笔记--域名系统DNS
域名系统DNS 标识因特网上主机的方式 主机名 IP地址 域名系统(DNS) 工作过程 互联网的域名结构 顶级域名 国家顶级域名nTLD 通用顶级域名gTLD 基础结构域名 二级域名 类别域名 行政区 ...
- 计算机网络原理笔记 精整理 第六章 应用层
计算机网络原理笔记 精整理 第六章 应用层 6.1域名系统DNS 6.1.1什么是域名 6.1.2域名的结构 6.1.3Internet中的域名服务器 6.1.4域名解析过程 6.2动态主机配置协议D ...
- 计算机网络-自顶向下笔记-应用层-P2P应用
计算机网络所有笔记 P2P文件分发 P2P(peer to peer)应用的特性: 没有服务器 任意端系统之间直接进行通信 节点阶段性接入Internet 节点可能更换IP地址 P2P的明显的缺点:复 ...
- 计算机网络学习笔记:第三章
文章目录 计算机网络学习笔记:第三章 前言 3.1.概述和运输层服务 3.1.1 运输层和网络层的关系 3.1.2 因特网运输层概述 3.2.多路复用与多路分解 前言 运输层位于应用层和网络层之间,是 ...
- 计算机网络学习笔记:第二章
文章目录 计算机网络学习笔记:第二章 前言 2.1.应用层协议原理 2.1.1 网络应用程序体系结构 2.1.2 进程通信 2.1.3 可供应用程序使用的运输服务 2.1.4 因特网提供的传输层服务 ...
- 计算机网络-学习笔记
计算机网络-学习笔记 1.1.1 概念.组成.功能和分类 概念:计算机网络:是一个将分散的.具有独立功能的计算机系统,通过通信设备与线路连接起来,由功能完善的软件实现资源共享和信息传递的系统.计算机网 ...
- 【计算机网络学习笔记】计算机网络
计算机网络学习笔记 第一章 计算机网络概述 1. 计算机网络概述 1.1 计算机网络的概念 1.2 计算机网络的组成 1.3 计算机网络的功能 1.4 计算机网络的分类 1.5 计算机网络的标准化工作 ...
- 计算机网络学习笔记(详尽版)
计算机网络学习笔记 计算机网络 第一章 定义和特点 网络 定义 功能 特点 组成 类别 性能 结构 本章重要概念 第二章 物理层 基本概念和标准 数据通信基础知识 物理层下的传输媒体 引导型传输媒体 ...
- 【计算机网络学习笔记08】ICMP
[计算机网络学习笔记08]ICMP 1 概念 由[RFC 792]定义的因特网控制报文协议(Internet Control Message Protocol,ICMP),被主机和路由器用来彼此沟通的 ...
- 《计算机网络》笔记-第1章计算机网络和因特网
title: <计算机网络>笔记-第1章计算机网络和因特网 date: 2020-01-19 10:21:14 文章目录 0. 前言 1. What Is the Internet 1.1 ...
最新文章
- log4j配置文件详解
- log4net简介(三)之无法写入日志
- 在c++中使用for循环遍历map并删除map中的元素的注意事项
- 使用 Blazor 开发内部后台(二):了解 Blazor 组件
- php进度条插件,分享8款优秀的 jQuery 加载动画和进度条插件_jquery
- [AH2017/HNOI2017] 大佬
- 关于前端学习路线的一些建议(值得零基础拥有)
- 动态加载子节点_省市区递归嵌套子流程动态选择实现
- Java加密与解密笔记(二) 对称加密
- 普通程序员如何向人工智能方向转型?
- mac 修改idea 占用内容_mac之idea卡顿修改内存设置
- Meta Learning 入门:MAML 和 Reptile
- 夜深人静写算法(五)- 初等数论
- 《女生宿舍第二部》(1-46上) 转贴
- ”消费全返“是割韭菜,非也,广告电商引领全新“全返”模式
- H5外部浏览器唤起微信分享
- win10计算机用户名修改密码,win10怎么修改登录用户名 win10修改开机密码的详细教程...
- 五种常见的聚类算法总结
- 职场面试中遇到的问题,八个方案,见招拆招
- 微信的「对方正在输入…」,到底是怎么来的?