intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài giảng Mạng máy tính: Chương 2 - TS. Trần Quang Diệu (Tiếp)

Chia sẻ: Nguoibakhong02 Nguoibakhong02 | Ngày: | Loại File: PPT | Số trang:46

34
lượt xem
3
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Nối tiếp nội dung phần 1, phần 2 bài giảng trình bày các kiến thức về web design and HTTP, web programming, file transfer protocol, electronic mail protocols, domain name system. Mời các bạn cùng tham khảo nội dung chi tiết.

Chủ đề:
Lưu

Nội dung Text: Bài giảng Mạng máy tính: Chương 2 - TS. Trần Quang Diệu (Tiếp)

  1. Chương 2 (tiếp). Giao thức tầng ứng dụng (application layer) Quang Dieu Tran, PhD Faculty of Information Technology University of Communication and Transport  (Branch in Ho Chi Minh City) Email: dieutq@gmail.com Website: sites.google.com/sites/tranlectures
  2. Discussion  Web programming with ASP.  Visual Basic programming.  Object oriented programming.  Event driven programming.  Component driven programming.  TCP Socket programming.  Simple web server. Chapter 2. The Application Layer 2
  3. Winsock Chapter 2. The Application Layer 3
  4. HTTP example Giả sử người dùng truy cập URL: www.uct2.edu.vn/index.htm (trang web có text và 10 hình ảnh jpeg) 0. http server tại máy phục vụ 1a. http client thiết lập liên kết  www.uct2.edu.vn chờ yêu cầu TCP với http server (process)  kết nối TCP tại cổng 80. tại địa chỉ www.uct2.edu.vn,  cổng 80 (ngầm định với http  server). 1b. http server chấp nhận kết nối  rồi thông báo với client. 2. http client gửi http request  message (bao gồm cả URL)  tới TCP connection socket 3. http server nhận request  message, tạo ra http response  time message có chứa các đối  tượng được yêu cầu rồi gửi  vào socket. Chapter 2. The Application Layer 4
  5. 4. http server ngắt liên kết.  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  time 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. Chapter 2. The Application Layer 5
  6. 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. Chapter 2. The Application Layer 6
  7. 2.4. FTP ­ File Transfer Protocol FTP file transfer FTP FTP user client server interface user  at host local file remote file system system  Truyền/tải tệp (to/from remote host).  Client/server model  Client: đưa ra yêu cầu truyền tải.  Server = remote host.  FTP: RFC 959 Chapter 2. The Application Layer 7
  8. FTP: control & data connections TCP control connection port 21 TCP data connection FTP port 20 FTP  FTP sử dụng TCP. client server  FTP sử dụng đồng thời 2 liên kết TCP tại 2 cổng:  TCP control connection, port 21: trao đổi các thông điệp điều  khiển (commands, responses…).  TCP data connection, port 20: truyền tải tệp.  FTP lưu giữ trạng thái client trong phiên làm việc (state  vs. HTTP is stateless). Chapter 2. The Application Layer 8
  9. FTP: Quá trình trao đổi/truyền tải TCP control connection port 21 TCP data connection  FTP server nghe tại cổng 21. client port 20 server  FTP client yêu cầu kết nối với FTP server qua TCP tại cổng 21.  Gửi user & password để đăng nhập.  FTP server chấp nhận, liên kết điều khiển (control connection)  được thiết lập. Quá trình trao đổi có thể bắt đầu.  Khi server nhận được lệnh truyền tệp, nó mở liên kết dữ liệu (data  connection) tới client, tệp được truyền qua liên kết này.  Sau khi truyền xong một tệp, server ngắt liên kết dữ liệu (mỗi liên  kết chỉ sử dụng để truyền một tệp). Chapter 2. The Application Layer 9
  10. FTP commands, responses Lệnh (commands), phúc đáp (responses) được truyền dạng ASCII Sample commands: Sample return codes  sent as ASCII text over control   status code and phrase (as in  channel HTTP)  USER username  331 Username OK,  PASS password password required  LIST return list of file in   125 data connection current directory already open; transfer starting  RETR filename retrieves   425 Can’t open data (gets) file connection  STOR filename stores   452 Error writing (puts) file onto remote host file Chapter 2. The Application Layer 10
  11. FTP clients & servers FTP file transfer FTP FTP user client server interface user  at host local file remote file system system  Command­based client:  Microsoft FTP Service  Windows FTP command.  …  Linux FTP command.  GUI clients  Windows Commander.  CuteFTP, WS_FTP… Chapter 2. The Application Layer 11
  12. 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. Chapter 2. The Application Layer 12
  13. 2.5. Electronic Mail Ba thành phần chính: user agent  User agents (mail clients) mail user  Soạn, đọc thư (messages). server agent  Vd: Outlook, Eudora, Netscape  SMTP mail Messenger... server user  Mail servers SMTP agent  Lưu trữ, xử lý thư. SMTP  Vd: Exchange, MDeamon… mail user server agent  Protocols  Simple Mail Transfer Protocol (SMTP). user  Post Office Protocol (POP). agent user outgoing   Internet Mail Access Protocol (IMAP). agent message queue  HTTP. user mailbox Chapter 2. The Application Layer 13
  14. Alice   Bob  1) Alice sử dụng UA soạn thư, đ/c  4) Mail server của Alice gửi  gửi tới “to”: bob@yahoo.com. thư qua liên kết TCP. 2) Alice’s UA gửi thư đến mail  5) Mail server của Bob cất thư  server của Alice, bức thư được  nhận được vào hòm thư  xếp vào hàng đợi (message  của Bob. queue). 6) Bob dùng UA để lấy thư từ  3) Mail server của Alice mở liên kết  server về rồi đọc thư. TCP tới mail server của Bob. 1 mail mail server user user server 2 agent agent 3 6 4 5 Outlook Yahoo! Mail uct2.edu.vn yahoo.com Chapter 2. The Application Layer 14
  15. SMTP (Simple Mail Transfer Protocol)  Sử dụng liên kết TCP (port 25) để gửi mails:  Từ sender’s mail client tới sender’s mail server.  Từ sender’s mail server tới receiver’s mail server.  Ba pha (three ways handshake):  Bắt tay (handshaking/greeting).  Trao đổi messages.  Kết thúc.  Command/response:  commands: ASCII.  responses: status code & phrase. Chapter 2. The Application Layer 15
  16. SMTP: sample interaction (C: client; S: server) S: 220 yahoo.com C: HELO uct2.edu.vn S: 250 Hello uct2.edu.vn, pleased to meet you C: MAIL FROM: S: 250 alice@uct2.edu.vn... Sender ok C: RCPT TO: S: 250 bob@yahoo.com ... Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Hi Bob! C: Would you like to play tennis this evening? C: . S: 250 Message accepted for delivery C: QUIT S: 221 yahoo.com closing connection Chapter 2. The Application Layer 16
  17. SMTP: more  SMTP sử dụng persistent connection: một liên kết, nhiều thông  điệp.  Thông điệp (kể cả nội dung thư) phải được mã hoá dạng ASCII 7  bit (US­ASCII).  Đánh dấu kết thúc msg bởi CRLF.CRLF  Một số dữ liệu nhị phân (vd: picture) có thể chứa CRLF.CRLF  cần  mã hoá để đảm bảo không có dữ liệu nào trùng với ký hiệu kết  thúc message (vd: base64).  So sánh với HTTP:  HTTP: pull protocol  SMTP: push protocol.  Cùng sử dụng ASCII (command/req/resp/status code).  HTTP: mỗi obj chứa trong một msg  SMTP: cho phép nhiều obj (text,  picture…) trong một msg (multipart msg). Chapter 2. The Application Layer 17
  18. Mail message format SMTP: giao thức trao đổi email msg  (exchange msgs). RFC 822: standard for text message  header blank format: line  Header lines, vd:  To: body  From:  Subject: Khác với smtp commands (MAIL FROM,  RCPT TO,…)!  Body  The “message”.  ASCII Chapter 2. The Application Layer 18
  19. MIME (Multipurpose Internet Mail Extension)  RFC 822: text msg, gặp khó khăn với multimedia.  MIME: RFC 2045, RFC 2056.  So với RFC 822, MIME thêm vào các header lines để mô  tả nội dung của email msg. From: alice@uct2.edu.vn MIME version To: bob@yahoo.com Subject: Picture of yummy crepe. method used MIME-Version: 1.0 to encode data Content-Transfer-Encoding: base64 Content-Type: image/jpeg multimedia data type, subtype,  base64 encoded data ..... parameter declaration ......................... ......base64 encoded data encoded data Chapter 2. The Application Layer 19
  20. MIME: Content types Content-type: type/subtype; parameters Chapter 2. The Application Layer 20
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2