2.应用层
C/S,P2P
1. C/S
客户是服务的请求方,服务器是服务的提供方。
Client/Server的好处是系统管理容易,问题是Server容易成为系统的bottleneck瓶颈.
2. P2P
P2P中,没有在C/S中处于中心地位的Server,所有Host的地位平等,叫做Peers,因此这种系统也叫Peer to Peer.
P2P的最大好处是系统可扩展性(scalability)强。由于每个peer既是Server又是Client, 随着系统中Peer的数量增多,系统的处理能力越强。
P2P的问题是可管理性,由于系统是完全分散的、无中心的,管理起来极其困难。
RTT
(definition): time for asmall packet to travel from
client to server and back。
RTT是评价延时的基本单位
HTTP协议
超文本传输协议
端口:80
运输层协议:TCP
HTTP是 无状态的
服务器不保留有关客户机过去请求的任何信息
用户与服务器交互:coockies
持续连接和非持续连接:
- non-persistent HTTP(非持续连接)
at most one object sent over TCP connection
connection then closed
downloading multiple objects required multiple connections - persistent HTTP(持续连接)
multiple objects can be sent over single TCP connection between client, server
HTTP格式:
URL:each object is addressable by a URL
编码:ASCII 码
提交方法:
- POST method:表单输入值在实体部分
- GET method: 表单输入值在URL之中
- HEAD:asks server to leave requested object out
of response(不需要服务器应答) - PUT(HTTP 1.1):uploads file in entity body to path specified
in URL field(上传文件) - DELETE(HTTP 1.1):deletes file specified in
the URL field(删除文件)
HTTP响应状态码:
- 200 OK
- 301 Moved Permanently:
requested object moved, new location specified later in this msg - 400 Bad Request: request msg not understood by server
- 404 Not Found
- 505 HTTP Version Not Supported
FTP协议
文件传输协议
FTP客户机联系FTP服务器的21号端,指定TCP为运输协议
FTP 分离控制命令和数据传输连接,“带外” 传输
FTP 服务器维护“状态”:当前目录,身份验证
邮件协议
简单邮件传输协议: SMTP
uses TCP to reliably transfer email message from
client to server, port 25
SMTP与HTTP比较:
- HTTP: pull (拉协议)
SMTP: push (推协议) - both have ASCII command/response interaction, status codes
- SMTP uses persistent connections
SMTP: delivery/storage to receiver’s server
mail access protocol: retrieval from server:
- POP: Post Office Protocol [RFC 1939]: authorization,download
- IMAP: Internet Mail Access Protocol [RFC 1730]: more features, including manipulation of stored msgs on server
- HTTP: gmail, Hotmail, Yahoo! Mail, etc.
DNS
端口号:53
传输层协议:UDP
作用:
DNS服务提供主机名到IP地址的转换,还提供主机别名、邮件服务器别名、负载分配等服务。
查询方式:递归查询、迭代查询