Giao thức tầng ứng dụng Application Layer

14 413 1
Giao thức tầng ứng dụng Application Layer

Đ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

Chapter The Application Layer 1-6/2006 Chương (tiếp) Giao thức tầng ứng dụng (application layer) Đặng Xuân Hà F.I.T, HAU1 http://www.hau1.edu.vn/it/dxha 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 1-6/2006 2.4 FTP - File Transfer Protocol user at host FTP FTP user client interface file transfer local file system „ Truyền/tải tệp (to/from remote host) „ Client/server model „ … Client: đưa yêu cầu truyền tải … Server = remote host FTP server remote file system FTP: RFC 959 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer Chapter The Application Layer 1-6/2006 FTP: control & data connections TCP control connection port 21 FTP client TCP data connection port 20 „ FTP sử dụng TCP „ FTP sử dụng đồng thời liên kết TCP cổng: FTP server … TCP control connection, port 21: trao đổi 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 phiên làm việc (state vs HTTP is stateless) 1-6/2006 Chapter The Application Layer FTP: Quá trình trao đổi/truyền tải TCP control connection port 21 client TCP data connection port 20 server ¾ FTP server nghe cổng 21 ¾ FTP client yêu cầu kết nối với FTP server qua TCP 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) thiết lập Quá trình trao đổi bắt đầu ¾ Khi server nhận lệnh truyền tệp, mở liên kết liệu (data connection) tới client, tệp truyền qua liên kết ¾ Sau truyền xong tệp, server ngắt liên kết liệu (mỗi liên kết sử dụng để truyền tệp) 1-6/2006 Chapter The Application Layer FTP commands, responses Lệnh (commands), phúc đáp (responses) truyền dạng ASCII Sample commands: „ „ „ „ „ „ Sample return codes sent as ASCII text over control channel USER username PASS password „ LIST return list of file in current directory RETR filename retrieves (gets) file STOR filename stores (puts) file onto remote host „ 1-6/2006 dxha@hau1.edu.vn „ „ „ status code and phrase (as in HTTP) 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file Chapter The Application Layer Chapter The Application Layer 1-6/2006 FTP clients & servers FTP FTP user client interface user at host „ file transfer remote file system local file system Command-based client: … Windows FTP command … Linux FTP command „ FTP server „ „ Microsoft FTP Service … GUI clients … Windows … CuteFTP, Commander WS_FTP… Chapter The Application Layer 1-6/2006 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 1-6/2006 2.5 Electronic Mail Ba thành phần chính: „ … … „ Soạn, đọc thư (messages) Vd: Outlook, Eudora, Netscape Messenger … Lưu trữ, xử lý thư Vd: Exchange, MDeamon… Protocols … … … … Simple Mail Transfer Protocol (SMTP) Post Office Protocol (POP) Internet Mail Access Protocol (IMAP) HTTP 1-6/2006 dxha@hau1.edu.vn mail server SMTP SMTP Mail servers … „ user agent User agents (mail clients) mail server user agent Chapter The Application Layer SMTP user agent user agent mail server user agent user agent outgoing message queue user mailbox Chapter The Application Layer 1-6/2006 Alice Æ Bob 1) Alice sử dụng UA soạn thư, đ/c gửi 4) Mail server Alice gửi thư qua liên kết TCP tới “to”: bob@yahoo.com 2) Alice’s UA gửi thư đến mail server 5) Mail server Bob cất thư nhận vào hòm thư của Alice, thư xếp vào Bob hàng đợi (message queue) 6) Bob dùng UA để lấy thư từ 3) Mail server Alice mở liên kết server đọc thư TCP tới mail server Bob user agent mail server mail server Outlook hau1.edu.vn yahoo.com user agent Yahoo! Mail Chapter The Application Layer 1-6/2006 10 SMTP (Simple Mail Transfer Protocol) „ Sử dụng liên kết TCP (port 25) để gửi mails: … Từ … Từ „ sender’s mail client tới sender’s mail server sender’s mail server tới receiver’s mail server Ba pha: … Bắt tay (handshaking/greeting) đổi messages … Kết thúc … Trao „ Command/response: … commands: … responses: ASCII status code & phrase Chapter The Application Layer 1-6/2006 11 SMTP: sample interaction (C: client; S: server) S: C: S: C: S: C: S: C: S: C: C: C: S: C: S: 220 yahoo.com HELO hau1.edu.vn 250 Hello hau1.edu.vn, pleased to meet you MAIL FROM: 250 alice@hau1.edu.vn Sender ok RCPT TO: 250 bob@yahoo.com Recipient ok DATA 354 Enter mail, end with "." on a line by itself Hi Bob! Would you like to play tennis this evening? 250 Message accepted for delivery QUIT 221 yahoo.com closing connection 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 12 Chapter The Application Layer 1-6/2006 SMTP: more „ SMTP sử dụng persistent connection: liên kết, nhiều thông điệp „ Thông điệp (kể nội dung thư) phải mã hoá dạng ASCII bit (US-ASCII) „ Đánh dấu kết thúc msg CRLF.CRLF „ Một số liệu nhị phân (vd: picture) chứa CRLF.CRLF Æ cần mã hoá để đảm bảo liệu 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: obj chứa msg SMTP: cho phép nhiều obj (text, picture…) msg (multipart msg) 13 Chapter The Application Layer 1-6/2006 Mail message format SMTP: giao thức trao đổi email msg (exchange msgs) RFC 822: standard for text message format: „ Header lines, vd: … … … To: From: Subject: Khác với smtp commands (MAIL FROM, RCPT TO,…)! header blank line body Body „ … … The “message” ASCII Chapter The Application Layer 1-6/2006 14 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 header lines để mô tả nội dung email msg MIME version method used to encode data multimedia data type, subtype, parameter declaration encoded data 1-6/2006 dxha@hau1.edu.vn From: alice@hau1.edu.vn To: bob@yahoo.com Subject: Picture of yummy crepe MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data base64 encoded data Chapter The Application Layer 15 Chapter The Application Layer 1-6/2006 MIME: Content types Content-type: type/subtype; parameters Chapter The Application Layer 1-6/2006 16 MIME: Encoding types Content-Transfer-Encoding: Encoding type Chapter The Application Layer 1-6/2006 17 MIME: Multiple objects mail message From: alice@hau1.edu.vn To: bob@yahoo.com Subject: Picture of yummy crepe MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=StartOfNextPart StartOfNextPart Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Dear Bob, Please find a picture of a crepe StartOfNextPart Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data base64 encoded data StartOfNextPart 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 18 Chapter The Application Layer 1-6/2006 The received mail message „ Server thêm vào dòng header nhận thư: … … „ Received: Return-path: Mail chuyển qua nhiều server khác (forward) Received: from hamburger.edu by sushi.jp; 12 Oct 98 15:30:01 GMT Received: from crepes.fr by hamburger.edu; 12 Oct 98 15:27:39 GMT From: alice@crepes.fr To: bob@hamburger.edu Subject: Picture of yummy crepe MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data .base64 encoded data 19 Chapter The Application Layer 1-6/2006 Hiển thị full headers với Y! Mail 2.General Preference 1.Mail Options 3.Messages: Show all… 20 Chapter The Application Layer 1-6/2006 Mail access protocol user agent SMTP SMTP sender’s mail server „ „ access protocol user agent receiver’s mail server SMTP: giao thức gửi mail tới server Mail access protocol: giao thức nhận mail từ server … POP (Post Office Protocol): RFC 1939 TCP Port 110 (Internet Mail Access Protocol): RFC 1730 TCP port 143 … HTTP: Hotmail, Yahoo! … IMAP 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 21 Chapter The Application Layer 1-6/2006 POP3 protocol [1] Authorization phase „ „ client commands: … user: declare username … pass: password server responses … +OK … -ERR [2] Transaction phase, client: „ „ „ list: list message numbers retr: retrieve message by number dele: delete [3] Update phase: „ quit „ thay đổi (dele) cập nhật S: C: [1] S: C: S: C: S: S: S: C: [2] S: S: C: C: S: S: C: C: [3] S: +OK POP3 server ready user bob +OK pass hungry +OK user successfully logged on list 498 912 retr dele retr dele quit +OK POP3 server signing off Chapter The Application Layer 1-6/2006 22 POP3 (more) and IMAP IMAP4 More about POP3 „ „ „ Chế độ “download and delete” (xem vd trước): … Msg bị xoá thoát … Không thể nhận msg lần „ Lưu trữ toàn msg server „ Cho phép người dùng tổ chức lưu trữ server (tạo thư mục, di chuyển msg…) „ Lưu trạng thái phiên (state): “Download-and-keep”: … Msg giữ lại server … Có thể nhận msg nhiều lần từ nhiều client Không lưu trạng thái phiên làm việc (stateless) 1-6/2006 … Thư mục tự tạo … Các msgs di chuyển Chapter The Application Layer 23 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 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 24 Chapter The Application Layer 1-6/2006 2.6 DNS (Domain Name System) Mr Binh HTTP (Internet Explorer) www.hau1.edu.vn From: Đ.V.Bình To: Phòng ĐT Phòng ĐT => H.101 203.162.8.82 DNS client Ms Nam „ „ www.hau1.edu.vn => 203.162.8.82 DNS servers Địa IP (32 bit) sử dụng để xác định nút mạng TCP/IP: 203.162.8.82 Æ khó nhớ! Æ Sử dụng tên (host name) song song với IP address DNS (RFC 1034, RFC 1035, RFC 2136): … Chuyển host name Æ IP address 25 Chapter The Application Layer 1-6/2006 DNS services „ DNS không tương tác trực tiếp với users mà cung cấp dịch vụ cho chương trình khác (HTTP, FTP…) thuộc tầng ứng dụng: Host name Æ IP (hostname to IP resolve) Host aliasing „ Mail server aliasing „ Load distribution (phân tán tải) „ … Một máy tính có tên thức có bí danh (alias) … @hau1.edu.vn Æ mail server address = ? … Một dịch vụ web (cnn.com, yahoo.com…) cung cấp nhiều server có IP khác để phân tán tải lượng người sử dụng cao 26 Chapter The Application Layer 1-6/2006 Internet domain name space „ „ Domain name (tên miền): … … … … Miền = tập hợp nút mạng có nút cha sơ đồ Vd: hau1.edu.vn; yahoo.com; yale.edu Sub-domain: cs.yale.edu; Host name: www.hau1.edu.vn; mail.hau1.edu.vn … … … … … 1-6/2006 dxha@hau1.edu.vn vn: Vietnam edu: education hau1: Hanoi Agricultural University www: máy chủ world wide web mail: máy chủ mail Chapter The Application Layer 27 Chapter The Application Layer 1-6/2006 Domain name servers Root DNS Servers com DNS servers yahoo.com DNS servers amazon.com DNS servers org DNS servers pbs.org DNS servers edu DNS servers poly.edu umass.edu DNS servers DNS servers Vd: client muốn biết IP www.amazon.com thì: „ Tìm địa com DNS servers Å hỏi Root DNS servers „ amazon.com Å com DNS servers „ www.amazon.com Å amazon.com DNS servers 28 Chapter The Application Layer 1-6/2006 DNS: Root name servers a Verisign, Dulles, VA c Cogent, Herndon, VA (also Los Angeles) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD k RIPE London (also Amsterdam, Frankfurt) i Autonomica, Stockholm (plus other locations) j Verisign, ( 11 locations) m WIDE Tokyo e NASA Mt View, CA f Internet Software C Palo Alto, 13 root name servers worldwide CA (and 17 other locations) b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA „ „ Khi local name server chuyển host name Æ IP, gửi yêu cầu tới root srv root name server: … Liên lạc với authoritative name server chưa thể ánh xạ đ/c … Lấy kết ánh xạ gửi từ authoritative name server … Trả kết cho local name server Chapter The Application Layer 1-6/2006 29 TLD and Authoritative Servers „ Top-level domain (TLD) servers: chịu trách nhiệm miền com, org, net, edu… uk, fr, ca, jp… … Network Solutions: quản lý com TLD servers … Educause: „ quản lý edu TLD servers Authoritative DNS servers: … Mỗi host mạng muốn biết đến phải khai báo với authoritiative DNS server servers tổ chức ánh xạ hostname Æ IP cho hosts tổ chức (vd: web, mail…) … DNS … Có thể quản lý tổ chức hay nhà cung cấp dịch vụ 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 30 10 Chapter The Application Layer 1-6/2006 Local name server „ Thuộc quản lý ISP (ISP, company, university…) „ Khi host muốn biết IP host đó, trước tiên, “hỏi” local name server „ Không thiết phải nằm kiến trúc DNS servers (độc lập) „ “Gần” máy tính người sử dụng nên thường “hỏi thăm” có truy vấn DNS „ Xem Windows Local DNS: ipconfig 31 Chapter The Application Layer 1-6/2006 DNS example Tình huống: host surf.eurecom.fr cần đ/c IP gaia.cs.umass.edu Liên lạc với local DNS server: dns.eurecom.fr dns.eurecom.fr liên lạc với root name server (nếu cần) root name server liên lạc với authoritative name server: dns.umass.edu (nếu cần) root name server local name server dns.eurecom.fr Authorititive name server dns.umass.edu requesting host surf.eurecom.fr gaia.cs.umass.edu 32 Chapter The Application Layer 1-6/2006 DNS example Root name server có thể: „ „ Không biết authoritative name server (ans) Biết intermediate name server (ins) … Từ ins tìm ans root name server local name server dns.eurecom.fr requesting host intermediate name server dns.umass.edu authoritative name server dns.cs.umass.edu surf.eurecom.fr gaia.cs.umass.edu 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 33 11 Chapter The Application Layer 1-6/2006 DNS example root name server recursive query: „ „ A hỏi B, B hỏi C, C hỏi D,… trả lời ngược lại Server hỏi chịu tải nặng gấp đôi? iterative query: „ „ local name server dns.eurecom.fr DNS server hỏi gợi ý hỏi server khác “I don’t know this name, but ask this server” iterated query intermediate name server dns.umass.edu requesting host authoritative name server dns.cs.umass.edu surf.eurecom.fr gaia.cs.umass.edu Chapter The Application Layer 1-6/2006 34 DNS: caching & updating „ Mỗi DNS server nhận yêu cầu tra cứu IP, IP mà tìm lưu lại phục vụ cho lần tra cứu … Timeout: thời gian hết hạn (sau khoảng thời gian, ghi cache tương ứng bị xoá) … TLD servers thường cache local name servers „ Cơ chế cập nhật/thông báo đưa IETF: … RFC 2136 … http://www.ietf.org/html.charters/dnsind-charter.html Chapter The Application Layer 1-6/2006 35 DNS records DNS: distributed db storing resource records (RR) RR format: (name, „ Type=A = hostname … value = IP address … name „ Type=NS „ value, type, ttl) Type=CNAME … name = “bí danh” (alias) www.ibm.com … value = tên thật servereast.backup2.ibm.com = domain name = IP address „ Type=MX … name = domain name authoritative name server cho domain … value = tên mail server … name … value 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 36 12 Chapter The Application Layer 1-6/2006 DNS protocol, messages DNS Protocol: Query/reply messages có format „ „ „ Msg header (12 bytes) Identification: số 16 bit reply msg sử dụng id với req msg Flags: nhiều bit, bit có ý nghĩa: … … … … Query (0) hay reply (1) Authoritative DNS recursion desired: client mong muốn DNS server tra cứu đệ quy recursion available: server hỗ trợ tra cứu đệ quy 1-6/2006 Chapter The Application Layer 37 Chapter The Application Layer 38 DNS messages Name, type fields for a query RRs in reponse to query records for authoritative servers additional “helpful” info that may be used 1-6/2006 Summary Telnet! √ √ √ √ RTSP? Terminal Emulation ? Web programming TCP Socket Programming 1-6/2006 dxha@hau1.edu.vn ? Chapter The Application Layer 39 13 Chapter The Application Layer 1-6/2006 Bài tập Nhận thư điện tử, trả lời câu hỏi: gửi, lúc nào, từ đâu (sử dụng dịch vụ ISP nào)? Bài nộp dạng file *.txt Viết mail client cho phép gửi tới nhiều người nhận + hướng dẫn sử dụng chương trình: … Định … Danh dạng thư? sách người nhận? (table, record, field) 1-6/2006 dxha@hau1.edu.vn Chapter The Application Layer 40 14 ... server „ „ access protocol user agent receiver’s mail server SMTP: giao thức gửi mail tới server Mail access protocol: giao thức nhận mail từ server … POP (Post Office Protocol): RFC 1939 TCP... khác (HTTP, FTP…) thuộc tầng ứng dụng: Host name Æ IP (hostname to IP resolve) Host aliasing „ Mail server aliasing „ Load distribution (phân tán tải) „ … Một máy tính có tên thức có bí danh (alias)... connections TCP control connection port 21 FTP client TCP data connection port 20 „ FTP sử dụng TCP „ FTP sử dụng đồng thời liên kết TCP cổng: FTP server … TCP control connection, port 21: trao đổi

Ngày đăng: 07/09/2017, 23:27

Từ khóa liên quan

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

Tài liệu liên quan