参考书:计算机网络自顶向下方法(第6版)(黑皮书)
一些概念
- application architecture
- client-server
- peer-to-peer
- process communication进程通信
- socket套接字
- process-identifier=IP address+port numbers
- URL=host name+path name
应用层
提供了哪些服务:
- logic communication between hosts
- the type of messages exchanged类型
- the syntax of various message types语法
- the semantics of the fields字段语义
- rules for when and how process send&response
网络架构:
- client-server
- p2p
HTTP
- client-server model
- 使用TCP
- stateless无状态协议
- connections
- non-persistent
- persistent
- RTT: 一个来回
- non-persistent HTTP response time=2RTT+file transmission time
- default in HTTP/1.1: persistent with pipelining
报文格式
request
- request line
- method:GET/POST/…
- 目标url
- version:HTTP版本
- HTTP/1.0: GET/POST/HEAD
- HTTP/1.0: GET/POST/HEAD/PUT/DELETE
- header lines:header field name+value
- Host
- User-Agent
- Accept
- Accept-Language
- Accept-Encoding
- Accept-Charset
- Keep-Alive
- Connection
- body:POST提交数据时携带的数据放在body
response
- status line
- protocol: HTTP
- status code
- status phrase
- 200 OK
- 301 Moved Permanently: 访问对象改变位置了,新的位置会赋在返回的Location字段中
- 400 Bad Request:服务器不理解,语义有误或请求参数有误
- 404 Not Found
- 505 HTTP Version Not Supported
- header lines
- Server
- Last-Modified
- data
cookie
cookie的4个组成:
- cookie值由response返回
- 下一次请求会加上cookie首部行
- cookie文件保存在用户主机上,由浏览器管理
- 后端数据库back-end database at website
Web caches/proxy server
web缓存器既是客户端又是服务器端,一般由ISP使用(eg.大学校园网,公司,运营商)。
作用/原因:
- 减少用户请求的响应时间
- 减少接入链路的通信量
- 通过减少通信量能够在较小带宽的情况下高效传输数据。
一个计算
utilization流量强度=分组到达的速度/结点处理的速度?
原始情况:
局域网上的流量强度=$(15个请求/sec)×(100Kb/请求)/1Gbps=15%$
接入链路上的流量强度=$(15个请求/sec)×(100Kb/请求)/1.54Mbps=97.4%$
ps:流量强度接近1,链路上的时延非常大
解决办法:
- 增大接入链路的带宽,开销大
- 增加本地缓存
Conditional GET
- request: If-modified-since
- response: 304 Not Modified
组成:
- user agent: Outlook,
- mail server
- mail box: 存放用户发送的邮件
- message queue:server将要发送至另一server的邮件
- protocol
- SMTP
SMTP
用于push发送,TCP,port 25,7位ASCII码,持续连接
与HTTP比较:
- push vs pull(主要)
- 7位ASCII vs 无限制
- 对象存放,HTTP单独封装,SMTP把?
access protocols
POP
- authorization
- 只download
- stateless
- port 110
IMAP
操作manipulation of stored messages on server
HTTP
gmail
DNS
distributed database分布式数据库,53 port
为什么不是集中式(完全没有拓展能力):
- 单点故障a single point of failure
- 通信容量traffic volume太多
- 远距离的集中式数据库distant centralized database
- 维护:数据库过大+频繁更新
一些分类
- TLD :top-level domain server顶级域名
- authoritative server
- local DNS server:每个ISP都有
查询过程
ps:都是先查询本地DNS
- recursive query递归查询-一直往下查直至返回最终结果
- iterative query迭代查询-返回当下结果
P2P
应用:
- file distribution->BitTorrent
- VoIP->skype
- 迅雷
BitTorrent
- requests missing chunks from peers, rarest first(最稀少优先)