Bài giảng Mạng máy tính và Internet: Chương 2 - Trần Quang Hải Bằng

22 5 0
Bài giảng Mạng máy tính và Internet: Chương 2 - Trần Quang Hải Bằng

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Mục tiêu của chương 2 Giao thức tầng ứng dụng nằm trong bài giảng mạng máy tính và Internet nhằm trình bày về một số khái niệm và nguyên tắc, Web & Hyper Text Transfer Protocol, Web design and HTTP, Web programming, File Transfer Protocol, Electronic Mail Protocols và Domain Name System.

Chương Giao thức tầng ứng dụng (application layer) Trần Quang Hải Bằng Computer Networking and Internet (course of 2009) Faculty of Information Technology University of Communication and Transport (Unit 2) Office location: Administration building, Block D3, Room Office phone: 38962018 Cell phone: N/A Email: bangtqh@hotmail.com Application Layer 24/8-25/10/2009 Chapter The Application Layer Ch2 The Application Layer 2.1 Một số khái niệm 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 24/8-25/10/2009 Chapter The Application Layer 2.1 Một số khái niệm nguyên tắc n Mt s chng trỡnh ng dng (network applications): Ô Ô ¤ ¤ ¤ ¤ ¤ ¤ ¤ Email (Yahoo! Mail, MS Outlook, Google mail,…) Web browser (MS Internet Explorer, Fire Fox, Netscape Navigator,…) Instant messenger (Yahoo! Messenger, ICQ, AOL,…) 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 24/8-25/10/2009 Chapter The Application Layer Một số giao thức (application-layer protocols) n HTTP (Hyper Text Transfer Protocol) Ô n FTP (File Transfer Protocol) Ô n Giao thức nhận thư điện tử (khác POP3) DNS (Domain Name System) Ô n Giao thc nhn th in t IMAP (Internet Mail Access Protocol) Ô n Giao thc truyn th in t POP (Post Office Protocol) Ô n Giao thc truyn SMTP (Simple Mail Transfer Protocol) Ô n Giao thức web 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) Ô Mt dng khỏc ca FTP 24/8-25/10/2009 Chapter The Application Layer Net applications vs application-layer protocols n Applications: Ô Ô Ô n Chng trỡnh ng dng chạy máy tính Trao đổi thơng điệp (message) với ứng dụng khác nhằm thực thi vai trò ứng dụng Vd: web browser, email client… Application-layer protocols: ¤ ¤ ¤ Là thành phần chương trình ứng dụng Định nghĩa quy tắc trao đổi thông điệp Giao tiếp với dịch vụ cung cấp tầng (TCP, UDP) 24/8-25/10/2009 Chapter The Application Layer Các chương trình giao tiếp với ntn? n Cỏc chng trỡnh trờn cựng mt mỏy tớnh Ô n Các chương trình máy tính khác ¤ n Sử dụng dịch vụ cung cấp hệ điều hành (interprocess communication) Giao tiếp thông qua giao thức tầng ứng dụng (application-layer protocol) Chương trình phớa ngi dựng = user agent Ô Ô Giao tip với người sử dụng (giao diện sử dụng) Giao tiếp với giao thức mạng 24/8-25/10/2009 Chapter The Application Layer Mơ hình khách-phục vụ (client-server paradigm) Mơ hình khách-phục vụ quen gọi mơ hình khách-chủ Một ứng dụng application cụ thể bao gồm hai phần: transport n Client Ô Ô Ô Ô n network data link physical 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 request Server ¤ ¤ ¤ Chờ cung cấp dịch vụ client u cầu Thường có server, khơng thay đổi địa chỉ, chạy 24/7 Vd: web server 24/8-25/10/2009 Chapter The Application Layer reply application transport network data link physical Mơ hình ngang hàng (Peer-to-peer paradigm) n n n Khơng có máy dịch vụ cố định, máy tính mạng lúc server (nhận yêu cầu kết nối) lúc khác lại client (yêu cầu máy khác kết nối) Các máy tính ngang hàng, tự kết nối giao tiếp đôi Địa máy tính tham gia giao tiếp liên tục thay đổi 24/8-25/10/2009 Chapter The Application Layer Client-server & P2P examples n CNN.com Client-server n Yahoo! Mail Client-server n Google Client-server n Yahoo! Messenger Client-server & P2P n Internet Relay Chat (IRC) Client-server & P2P 24/8-25/10/2009 Chapter The Application Layer 10 Dịch vụ tầng application-layer n Có thể coi tầng application (Internet) = tầng application + presentation + session mơ hình OSI Các dịch vụ với application: § Presentation: gắn liền với application TCP/IP § § § Session: gắn liền với application TCP/IP § § File formats: picture (JPEG, GIF…), audio (MP3, RM…), video (MPEG, MOV…), document (HTML, XML…) Data encryption & compression 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 UDP 24/8-25/10/2009 Chapter The Application Layer 11 Yêu cầu vic chuyn d liu n Data loss Ô Ô n Timing Ô n Cỏc ng dng audio/video cú th chấp nhận mát, sai lệch liệu khoảng cho phép Email, file transfer yêu cầu liệu phải xác Các ứng dụng online cần độ trễ (delay) nh (phone, games) Bandwidth Ô Ô Cỏc ng dng 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 độ 24/8-25/10/2009 Chapter The Application Layer 12 Các yêu cầu giao vận số ứng dụng 24/8-25/10/2009 Chapter The Application Layer 13 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 24/8-25/10/2009 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 Chapter The Application Layer 14 Internet applications: TCP or UDP? 24/8-25/10/2009 Chapter The Application Layer 15 Ch2 The Application Layer 2.1 Một số khái niệm 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 24/8-25/10/2009 Chapter The Application Layer 16 2.2 Web & HTTP n n Trang web (web page): loại tài liệu có chứa nhiều đối tượng: text, image, audio, Java applet, HTML… Về bản, web page = HTML file (base HTML) Ô Ô n HTML = Hyper Text Markup Language HTML sử dụng thẻ (tag) để mô tả đối tượng chứa Mỗi đối tượng ch bi a ch URL (Uniform Resource Locator) Ô http://www.uct2.edu.vn/ Ô http://uct2.edu.vn:80/userimages/tqhbang/nhaphoc.jpg Protocol Host name & port Path Chapter The Application Layer 24/8-25/10/2009 17 HTTP (Hyper Text Transfer Protocol) n n Giao thức tầng ứng dụng web Sử dng mụ hỡnh client/server Ô Client (user agent): n n ¤ Server n n n Trình duyệt web (web browser) Yêu cầu truy cập web thông qua URL (URL request) Máy phục vụ web (web server) Gửi đối tượng ti client thụng quan phn hi (response) HTTP version: Ô ¤ HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068 24/8-25/10/2009 Chapter The Application Layer 18 HTTP: Quá trình trao đổi thông điệp n n n n 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) trao đổi browser server Ngắt kết nối 24/8-25/10/2009 Chapter The Application Layer 19 HTTP example Giả sử người dùng truy cập URL: www.uct2.edu/index.html (trang web có text 10 hình ảnh jpeg) 1a http client thiết lập liên kết TCP với http server (process) địa www.uct2.edu.vn, cổng 80 (ngầm định với http server) http client gửi http request message (bao gồm URL) tới TCP connection socket time 24/8-25/10/2009 1b http server máy phục vụ www.uct2.edu.vn chờ yêu cầu kết nối TCP cổng 80, chấp nhận kết nối thông báo với client http server nhận request message, tạo http response message có chứa đối tượng yêu cầu gửi vào socket Chapter The Application Layer 20 http server ngắt liên kết 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 10 hình ảnh jpeg tài liệu time Bước 1-5 lặp lại với hình ảnh 24/8-25/10/2009 Chapter The Application Layer 21 HTTP Connection: Persistent & Non-persistent Non-persistent HTTP n Nhiều đối tượng truyền qua liên kết TCP n HTTP 1.0 24/8-25/10/2009 Persistent HTTP n Cho phép nhiều đối tượng truyền liên kết n Client phân tích, tìm gửi u cầu tới tất đối tượng sau nhận trang HTML ban đầu (base HTML) n HTTP 1.1 sử dụng liên kết loại chế độ mặc định Chapter The Application Layer 22 HTTP Message Format: request & response n n Hai loại message: request response HTTP request message: dạng ASCII (đọc được!) request line (GET, POST, HEAD commands) GET /somedir/page.html HTTP/1.0 User-agent: Mozilla/4.0 Accept: text/html, image/gif,image/jpeg header Accept-language:fr lines Carriage return, line feed indicates end of message 24/8-25/10/2009 (extra carriage return, line feed) Chapter The Application Layer 23 HTTP request message 24/8-25/10/2009 Chapter The Application Layer 24 HTTP response message status line (protocol status code status phrase) header lines 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 data, e.g., requested html file 24/8-25/10/2009 Chapter The Application Layer 25 HTTP response message 24/8-25/10/2009 Chapter The Application Layer 26 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 24/8-25/10/2009 Chapter The Application Layer 27 Ví dụ thực hành Telnet tới web server: telnet www.uct2.edu.vn 80 Mở kết nối (TCP) tới cổng 80 web server UCT2 Sau kết nối, tất ký tự gõ vào gửi tới cổng 80 Nhập vào GET http request: GET /dangkythilai/help.htm HTTP/1.0 Đây http request đơn giản Nhập xong gõ lần Enter để gửi tới server Kiểm tra kết nhận (http response message)! 24/8-25/10/2009 Chapter The Application Layer 28 User-server interaction: authentication & cookies Authenthication server client usual http request msg 401: authorization req WWW authenticate: usual http request msg + Authorization: usual http response msg time usual http request msg + Authorization: usual http response msg 24/8-25/10/2009 Chapter The Application Layer 29 Cookies: keeping “state” n n Server phát sinh số server (#) client request, client đồng thời ghi nhớ số để usual http request msg s dng sau ny: usual http response + Ô Chng thc Set-cookie: # (authentication) Ô Ghi nh s thớch, thói usual http request msg quen, lựa chọn truy cập cookiecookie: # lần trước spectific server gửi “cookie” tới usual http response msg action client qua response msg, vd: Set-cookie: 1678453 n Lần sau truy cập website, client gửi kèm cookie, vd: cookie: 1678453 24/8-25/10/2009 usual http request msg cookie: # usual http response msg Chapter The Application Layer cookiespectific action 30 Conditional GET: client-side caching n n MĐ: server không cần gửi client obj tới client client có http request msg phiên cập nhật (up-toIf-modified-since: date) obj Client phải thời gian http response sửa gần obj HTTP/1.0 304 Not Modified http request msg server object not modified If-modified-since: n http request msg Server trả response msg không chứa obj obj cập nhật: If-modified-since: object modified http response HTTP/1.0 304 Not Modified HTTP/1.1 200 OK 24/8-25/10/2009 31 Chapter The Application Layer Web Caches (proxy server) n Client gửi http requests ti web cache thay vỡ ti server Ô Ô n n Nếu obj có web cache: web cache tạo http response msg gửi cho client Nếu không, web cache tạo gửi http request tới server, nhận obj, lưu trữ, gửi http response msg tới client Web cache 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 IE 24/8-25/10/2009 origin server h tt pr client http Proxy server eq u es t res pon se st ue q e pr nse po ht t s re ht client Chapter The Application Layer es t eq u r p se h tt pon s e pr h tt origin server 32 Why Web Caching? Assume: cache is “close” to client (e.g., in same network) n smaller response time: cache “closer” to client n decrease traffic to distant servers ¤ origin servers public Internet 1.5 Mbps access link institutional network link out of institutional/local ISP network often bottleneck 24/8-25/10/2009 10 Mbps LAN institutional cache Chapter The Application Layer 33 Web servers n IIS (Microsoft Internet Information Server) Ô ¤ n Apache web server ¤ ¤ ¤ ¤ n Chạy môi trường Windows Đi kèm Windows 2000 Server (IIS 5.0) Mã nguồn mở Linux/Windows… http://www.apache.org Web server dùng nhiều Tomcat, Netscape, Xitami… 24/8-25/10/2009 Chapter The Application Layer 34 Ch2 The Application Layer 2.1 Một số khái niệm 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 Chapter The Application Layer 24/8-25/10/2009 35 Web design: HTML n n Thiết kế web: Tạo tài liệu HTML HTML (Hyper Text Markup Language) Ô Trong ti liu HTML có nhiều đối tượng n n n ¤ Sử dụng thẻ (tag) để diễn đạt đối tượng n n n Thẻ mở, vd: ; ; ; … Th úng, vd: ; ;; Cụng c: Ô Ô Ô n Text Images Hyper link Text editor: Notepad, Ultra Edit Microsoft FrontPage Macromedia Dreamweaver http://www.w3schools.org (http://www.w3schools.com) 24/8-25/10/2009 Chapter The Application Layer 36 Web programming n n HTML = trang web tĩnh (Static web): Web server trả trang HTML cố định nhận yêu cầu người dùng Lập trình web: tương tác với người s dng thụng qua web Ô Lp trỡnh web # Lp trỡnh Pascal, C: n Ô Ô Tng tỏc thụng qua HTTP Message Client-side scripts: Java script, VB script Server-side scripts: ASP, JSP, PHP, Perl… 24/8-25/10/2009 Chapter The Application Layer 37 HTML Form: Send user requests HTML Simple Form

24/8-25/10/2009 ASP Simple ASP

Ngày đăng: 08/05/2021, 13:00

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan