Giao thức tầng ứng dụng (application layer)

Chia sẻ bởi Nguyễn Việt Vương | Ngày 29/04/2019 | 121

Chia sẻ tài liệu: Giao thức tầng ứng dụng (application layer) thuộc Bài giảng khác

Nội dung tài liệu:

Chương 2.
Giao thức tầng ứng dụng (application layer)
Đặng Xuân Hà
Computer Networking 2005
(http://www.hau1.edu.vn/cs/dxha/courses/0405/comnet)
Dept. of CS, HAU1.
Application Layer
Ch2. The Application Layer
2.1. Một số khái niệm và nguyên tắc.
2.2. Web & Hyper Text Transfer Protocol.
2.3. Web design and HTTP, Web programming.
2.4. File Transfer Protocol.
2.5. Electronic Mail Protocols.
2.6. Domain Name System.
2.1. Một số khái niệm và nguyên tắc
Một số chương trình ứng dụng (network applications):
Email (Yahoo! Mail, MS Outlook…).
Web browser (MS Internet Explorer, Netscape Navigator…).
Instant messenger (Yahoo! Messenger, ICQ…).
P2P file sharing (Napster, KazaA…).
Internet games (Yahoo! Games).
Internet telephone (Skype, FPTFone,VNNFone…).
Streaming stored video clips.
Real-time video conference.
Massive parallel computing.
Một số giao thức (application-layer protocols)
HTTP (Hyper Text Transfer Protocol)
Giao thức web.
FTP (File Transfer Protocol)
Giao thức truyền tệp.
SMTP (Simple Mail Transfer Protocol)
Giao thức truyền thư điện tử.
POP (Post Office Protocol)
Giao thức nhận thư điện tử.
IMAP (Internet Mail Access Protocol)
Giao thức nhận thư điện tử (khác POP3)
DNS (Domain Name System)
DNS = hệ thống tên miền, giao thức DNS quy định quy tắc sử dụng tên miền.
TFTP (Trivial FTP)
Một dạng khác của FTP.
Net applications vs. application-layer protocols
Applications:
Chương trình ứng dụng chạy trên các máy tính.
Trao đổi thông điệp (message) với các ứng dụng khác nhằm thực thi vai trò của ứng dụng.
Vd: web browser, email client…
Application-layer protocols:
Là một thành phần của chương trình ứng dụng.
Định nghĩa các quy tắc trao đổi thông điệp.
Giao tiếp với các dịch vụ được cung cấp bởi tầng dưới (TCP, UDP).
Các chương trình giao tiếp với nhau ntn?
Các chương trình trên cùng một máy tính
Sử dụng các dịch vụ được cung cấp bởi hệ điều hành (interprocess communication).
Các chương trình trên các máy tính khác nhau
Giao tiếp thông qua giao thức của tầng ứng dụng (application-layer protocol).
Chương trình phía người dùng = user agent
Giao tiếp với người sử dụng (giao diện sử dụng).
Giao tiếp với các giao thức mạng.
Mô hình khách-phục vụ (client-server paradigm)
Mô hình khách-phục vụ được quen gọi là mô hình khách-chủ. Một ứng dụng cụ thể bao gồm hai phần:

Client
Thiết lập liên kết với server.
Yêu cầu dịch vụ từ server.
Nhiều clients.
Vd: web browser.
Server
Chờ và cung cấp các dịch vụ khi client yêu cầu.
Thường chỉ có 1 server, không thay đổi địa chỉ, chạy 24/7.
Vd: web server.
Mô hình ngang hàng (Peer-to-peer paradigm)
Không có máy dịch vụ cố định, các máy tính trong mạng lúc này là server (nhận yêu cầu kết nối) nhưng lúc khác lại là client (yêu cầu máy khác kết nối).
Các máy tính là ngang hàng, tự do kết nối và giao tiếp đôi một.
Địa chỉ của các máy tính tham gia giao tiếp liên tục thay đổi.
Client-server & P2P examples
CNN.com
Yahoo! Mail
Google
Yahoo! Messenger
Internet Relay Chat (IRC)
Client-server
Client-server
Client-server
Client-server & P2P
Client-server & P2P
Dịch vụ tầng dưới đối với application-layer
Có thể coi tầng application (Internet) = tầng application + presentation + session trong mô hình OSI.
Các dịch vụ với application:
Presentation: gắn liền với application trong TCP/IP
File formats: picture (JPEG, GIF…), audio (MP3, RM…), video (MPEG, MOV…), document (HTML, XML…).
Data encryption & compression.
Session: gắn liền với application trong TCP/IP
NFS (Network File System), RPC (Remote Procedure Call), SQL (Structured Query Language), SSL (Secure Socket Layer).
Transport (*)
Cung cấp dịch vụ vận chuyển cho application (TCP/IP).
Hai giao thức: TCP và UDP.
Yêu cầu đối với việc vận chuyển dữ liệu
Data loss
Các ứng dụng audio/video có thể chấp nhận mất mát, sai lệch dữ liệu trong khoảng cho phép.
Email, file transfer yêu cầu dữ liệu phải chính xác.
Timing
Các ứng dụng online cần độ trễ (delay) nhỏ (phone, games).
Bandwidth
Các ứng dụng multimedia cần đường truyền tốc độ cao để đảm bảo chất lượng.
Các ứng dụng email, file transfer mềm dẻo hơn, tuỳ theo tốc độ.
Các yêu cầu giao vận của một số ứng dụng
Internet Transport protocols: TCP & UDP
TCP (Transmission Control Protocol)
connection-oriented: setup required between client, server.
reliable transport between sending and receiving process.
flow control: sender won’t overwhelm receiver.
congestion control: throttle sender when network overloaded.
does not providing: timing, minimum bandwidth guarantees.
UDP (User Datagram Protocol)
unreliable data transfer between sending and receiving process
does not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee.
Internet applications: TCP or UDP?
Ch2. The Application Layer
2.1. Một số khái niệm và nguyên tắc.
2.2. Web & Hyper Text Transfer Protocol.
2.3. Web design and programming.
2.4. File Transfer Protocol.
2.5. Electronic Mail Protocols.
2.6. Domain Name System.
2.2. Web & HTTP
Trang web (web page): một loại tài liệu có chứa trong đó nhiều đối tượng: text, image, audio, Java applet, HTML…
Về cơ bản, web page = HTML file (base HTML).
HTML = Hyper Text Markup Language.
HTML sử dụng các thẻ (tag) để mô tả đối tượng chứa trong nó.
Mỗi đối tượng được chỉ ra bởi địa chỉ URL (Uniform Resource Locator)
http://www.hau1.edu.vn:80/cs/index.htm
http://www.hau1.edu.vn:80/cs/images/calendar.jpg
Protocol Host name & port Path
HTTP (Hyper Text Transfer Protocol)
Giao thức tầng ứng dụng web.
Sử dụng mô hình client/server.
Client (user agent):
Trình duyệt web (web browser)
Yêu cầu truy cập web thông qua URL (URL request).
Server
Máy phục vụ web (web server).
Gửi các đối tượng tới client thông quan phản hồi (response).
HTTP version:
HTTP 1.0: RFC 1945
HTTP 1.1: RFC 2068
HTTP: Quá trình trao đổi thông điệp
Client (browser) thiết lập liên kết tới web server (TCP connection) qua cổng 80 (mặc định).
Server đồng ý kết nối (accept).
Các thông điệp (HTTP messages) được trao đổi giữa browser và server.
Ngắt kết nối.
HTTP example
1a. http client thiết lập liên kết TCP với http server (process) tại địa chỉ www.hau1.edu.vn, cổng 80 (ngầm định với http server).
2. http client gửi http request message (bao gồm cả URL) tới TCP connection socket
1b. http server tại máy phục vụ www.hau1.edu.vn chờ yêu cầu kết nối TCP tại cổng 80, chấp nhận kết nối rồi thông báo với client.
3. http server nhận request message, tạo ra http response message có chứa các đối tượng được yêu cầu rồi gửi vào socket.
time
Giả sử người dùng truy cập URL: www.hau1.edu/cs/index.htm
(trang web có text và 10 hình ảnh jpeg)
5. http client nhận response message có chứa html file, hiển thị html. Sau đó, phân tích html file, tìm URL của 10 hình ảnh jpeg trong tài liệu.
6. Bước 1-5 được lặp lại với từng hình ảnh.
4. http server ngắt liên kết.
time
HTTP Connection: Persistent & Non-persistent
Non-persistent HTTP
Nhiều nhất là một đối tượng được truyền qua liên kết TCP.
HTTP 1.0
Persistent HTTP
Cho phép nhiều đối tượng được truyền trên cùng một liên kết.
Client phân tích, tìm ra và gửi yêu cầu tới tất cả các đối tượng ngay sau khi nhận được trang HTML ban đầu (base HTML).
HTTP 1.1 sử dụng liên kết loại này ở chế độ mặc định.
HTTP Message Format: request & response
Hai loại message: request và response.
HTTP request message: dạng ASCII (đọc được!)
GET /somedir/page.html HTTP/1.0
User-agent: Mozilla/4.0
Accept: text/html, image/gif,image/jpeg
Accept-language:fr

(extra carriage return, line feed)
request line
(GET, POST,
HEAD commands)
header
lines
Carriage return,
line feed
indicates end
of message
HTTP request message
HTTP response message
HTTP/1.0 200 OK
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html

data data data data data ...
status line
(protocol
status code
status phrase)
header
lines
data, e.g.,
requested
html file
HTTP response message
HTTP response message: status codes
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
Ví dụ thực hành
1. Telnet tới web server:
Mở một kết nối (TCP) tới cổng 80 tại web server của trường ĐHNNI. Sau khi kết nối, tất cả ký tự gõ vào sẽ được gửi tới cổng 80.
telnet www.hau1.edu.vn 80
2. Nhập vào GET http request:
GET /cs/index.htm HTTP/1.0
Đây là một http request đơn giản.
Nhập xong gõ 2 lần Enter để gửi tới server
3. Kiểm tra kết quả nhận được (http response message)!
User-server interaction: authentication & cookies
client
server
usual http request msg
401: authorization req.
WWW authenticate:
Authenthication
Cookies: keeping “state”
Server phát sinh một con số nào đó (#) khi client request, đồng thời ghi nhớ số này để sử dụng sau này:
Chứng thực (authentication)
Ghi nhớ sở thích, thói quen, lựa chọn truy cập lần trước.
server gửi “cookie” tới client qua response msg, vd:
Set-cookie: 1678453
Lần sau truy cập website, client gửi kèm cookie, vd:
cookie: 1678453
client
server
usual http request msg
usual http response +
Set-cookie: #
cookie-
spectific
action
cookie-
spectific
action
Conditional GET: client-side caching
MĐ: server không cần gửi obj tới client khi client đã có phiên bản cập nhật (up-to-date) của obj.
Client phải chỉ ra thời gian sửa gần đây nhất của obj trong http request msg.
If-modified-since:
Server sẽ trả về response msg không chứa obj nếu obj là cập nhật:
HTTP/1.0 304 Not Modified
client
server
http request msg
If-modified-since:
object
not
modified
http request msg
If-modified-since:
http response
HTTP/1.1 200 OK

object
modified
Web Caches (proxy server)
Client gửi http requests tới web cache thay vì tới server.
Nếu obj có tại web cache: web cache tạo http response msg gửi về cho client.
Nếu không, web cache tạo gửi http request tới server, nhận obj, lưu trữ, rồi gửi http response msg tới client.
Web cache sẽ khiến người dùng có cảm giác duyệt web nhanh hơn, giảm nghẽn mạng.
Vd: proxy server trong IE.
client
Proxy
server
client
http request
http request
http response
http response
http request
http response
origin
server
origin
server
Why Web Caching?
Assume: cache is “close” to client (e.g., in same network)
smaller response time: cache “closer” to client
decrease traffic to distant servers
link out of institutional/local ISP network often bottleneck
origin
servers
public
Internet
institutional
network
10 Mbps LAN
1.5 Mbps
access link
institutional
cache
Web servers
IIS (Microsoft Internet Information Server)
Chạy trên môi trường Windows
Đi kèm Windows 2000 Server (IIS 5.0).
Apache web server
Mã nguồn mở.
Linux/Windows…
http://www.apache.org
Web server được dùng nhiều nhất.
Tomcat, Netscape, Xitami…
Ch2. The Application Layer
2.1. Một số khái niệm và nguyên tắc.
2.2. Web & Hyper Text Transfer Protocol.
2.3. Web design and HTTP, Web programming.
2.4. File Transfer Protocol.
2.5. Electronic Mail Protocols.
2.6. Domain Name System.
Web design: HTML
Thiết kế web: Tạo ra tài liệu HTML
HTML (Hyper Text Markup Language)
Trong tài liệu HTML có thể có nhiều đối tượng
Text
Images
Hyper link
Sử dụng thẻ (tag) để diễn đạt đối tượng.
Thẻ mở, vd: ; ; ; <body>…<br>Thẻ đóng, vd: </html>; </head>;;
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...

Người chia sẻ: Nguyễn Việt Vương
Dung lượng: | Lượt tài: 4
Loại file:
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)