1 / 42

Web 與 Email

Web 與 Email. HTTP. HTTP: Hyper Text Transfer Protocol Web 的應用層協定 採用用戶端和伺服器端的服務架構 用戶端 : 要求 、 接收並顯示所接收的 web pages 伺服器端 : 接受要求並回應所要求的 web pages. www.someschool.edu/someDept/pic.gif. path name. host name. HTTP. Web page 所包含的原件有 Objects HTML file, jpeg image, java applet … Base HTML file

azura
Download Presentation

Web 與 Email

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web 與Email

  2. HTTP • HTTP: Hyper Text Transfer Protocol • Web的應用層協定 • 採用用戶端和伺服器端的服務架構 • 用戶端:要求、接收並顯示所接收的web pages • 伺服器端:接受要求並回應所要求的web pages

  3. www.someschool.edu/someDept/pic.gif path name host name HTTP • Web page所包含的原件有 • Objects • HTML file, jpeg image, java applet… • Base HTML file • HTML是用來描述web page的一種語言 • URL:是用來表示一個page或是object • www.cyu.edu.tw/web/index.html(hostname + path name) • 目前HTTP有兩種標準 • http 1.0 (RFC 1945) • http 1.1 (RFC 2068)—目前所使用

  4. HTML: Hypertext Markup Language • 使一種用來描述網頁的文件要如何定義的語言 • Embedding markup commands with each HTML files so that a browser can reformat the files. • HTML的標準化 由WWW組織所制訂 • ex: W3C

  5. HTTP • HTTP下層協定使用TCP傳送服務 • 由用戶端初始化連線(setup TCP connection),使用socket port 80與伺服器端溝通 • 伺服器端回應後,兩端開始交換訊息直到結束(TCP connection close) • HTTP是一個stateless的協定 • Stateless意指伺服器端不需要保有任何有關過去用戶端的要求訊息(request message) • 通常協定要保有過去的state,就會變的很複雜

  6. Non-persistent HTTP/1.0 每一個TCP連線都會在server送完物件後結束 所以每一個連線都只會有一個request和一個respond Respond time = 2 RTTs + Ttrans 每一個所傳送的物件,都會受到slow start影響 Persistent Default for HTTP/1.1 在同一個用戶端會一直使用同一個TCP連線,直到time out才關掉 有較少的RTT和slow start 有分成pipeline和non-pipeline Non-persistent和persistent連線的不同

  7. HTTP的訊息格式-- request • 訊息是使用ASCII text所寫(易於閱讀) • Http的要求訊息格式 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 Accept-language:fr (extra carriage return, line feed) header lines Carriage return, line feed indicates end of message

  8. HTTP的要求訊息格式-- 一般式

  9. HTTP的訊息格式-- response 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

  10. 常見的回應訊息 200 OK • 要求成功, 所要求的物件會夾帶在接下來的訊息 301 Moved Permanently • 所要求的物件已經一到別處,新的位置將會出現在下一個訊息中(Location:) 400 Bad Request • 所要求的訊息,伺服器無法判讀 404 Not Found • 所要求的物件並不存在伺服器裡 505 HTTP Version Not Supported • 所要求使用的協定,伺服器端並不支援

  11. Java Language (爪窪語言) • 在1995年,由昇揚公司(Sun Microsystems Inc.)所制訂 • For waiting interactive web pages. • A small Java program, called an applet, is associated with a web page and downloaded to the client machine to interpret the web page.

  12. Java Language (cont.)

  13. 目的:為了要控制存取伺服器資料的權力 因為是stateless所以用戶端每一次request都要認證一次 認證通常使用name和password 為避免需要重覆輸入認證資料,瀏覽器會自行讀取catch的資料 認證步驟如右 usual http request msg + Authorization:line usual http request msg + Authorization:line usual http response msg usual http response msg time 認證(Authentication) server client usual http request msg 401: authorization req. WWW authenticate:

  14. 設定cookie是為了方便在下一次存取網站時,可以不需要再輸入一些重複性的資料設定cookie是為了方便在下一次存取網站時,可以不需要再輸入一些重複性的資料 Cookie是由伺服器端要求用戶端建立,並且存在用戶端的機器上 Cookie大多用來 認證 使用者的訊息 建立步驟如右 usual http request msg cookie: # usual http request msg cookie: # usual http response msg usual http response msg cookies server client usual http request msg usual http response + Set-cookie: # cookie- spectific action cookie- spectific action

  15. Web快取(proxy伺服器) • 目的:為了可以使用戶端送出的request不用直接到原來的伺服器,如此一來便可以加速網頁的取得及瀏覽 • 所以大部分的用戶端都會透過proxy server來存取網路資源,而proxy server會保有一些web的快取資料,以利存取 • 如果現在的網頁資料不是最新的,則proxy會去原始的網站去更新目前保有的資料 origin server Proxy server http request http request client http response http response http request http request http response http response client origin server

  16. 因為proxy一般會離用戶端較近,會使的存取的速度較快因為proxy一般會離用戶端較近,會使的存取的速度較快 可以減少一些較長距離的traffic 同一筆資料可以統一由proxy來維持更新 右圖為示意圖 1.5 Mbps access link是一個bottleneck 為什麼使用web catching origin servers public Internet 1.5 Mbps access link institutional network 10 Mbps LAN

  17. 1. Telnet to your favorite Web server: 用指令方式連線HTTP (client side)網頁 Opens TCP connection to port 80 (default HTTP server port) at cis.poly.edu. Anything typed in sent to port 80 at cis.poly.edu telnet mail.cyu.edu.tw 80 2. Type in a GET HTTP request: By typing this in (兩行指令輸入完成後 按兩次Enter), you send this minimal (but complete) GET request to HTTP server GET /index.html HTTP/1.1 Host: mail.cyu.edu.tw 3. Look at response message sent by HTTP server!

  18. FTP user interface FTP client FTP server local file system FTP: File Transfer Protocol • FTP是現在較普遍也較常用的一個檔案傳輸的協定 • 採用用戶端與伺服器端模式溝通 • RFC編號:959 • 所使用的port:21 file transfer user at host remote file system

  19. TCP control connection port 21 TCP data connection port 20 FTP client FTP server FTP: File Transfer Protocol (cont.) • FTP使用TCP作為傳輸層所使用的協定 • 在FTP的連結中有分為兩種 • Control:在client和server之間交換commands和response,屬於”out of band control” • Data:在client和server之間的data交換 • FTP和HTTP不同,他會maintain state • 目前所在目錄 • 登錄所做的認證

  20. Commands Open:連接FTP server User: 使用者帳號 Pass: 密碼 RETR filename: 取得檔案 STOR filename: 上傳檔案 Bye: 結束連線 回應訊息 331 帳號OK,需要密碼 125 data connection 已經開啟; 傳送開始 425 無法開啟data connection 452 檔案寫入錯誤 FTP: File Transfer Protocol (cont.) 如何連結上FTP server? >>ftp xxx.xxx.xxx.xxx port >>get file.xxx (取得檔案) >>put file.xxx (上傳檔案)

  21. user agent user agent user agent user agent user agent user agent SMTP SMTP SMTP mail server mail server mail server outgoing message queue user mailbox Electronic-mail (E-mail, 電子郵件) • 包含三個部分 • 使用者代理人 (user agent) • 郵件伺服器 (mail server) • SMTP協定

  22. E-mail– user agent • 有時亦稱為郵件讀取者(mail reader) • 它可以讓user讀取、回復、轉發、儲存和建構訊息(message, mail…) • 使用者需要讀取信息時,user agent會去跟郵件伺服器溝通,取回信息,或是送出信息 • User agent常見的有: • Microsoft Outlook or Outlook Express • Netscape Messenger

  23. E-mail– Mail server • 每一個user都會有一個信箱(mail box)來存放尚未讀取的信件 • 尚未傳送出去的信件會暫時存在message queue • SMTP扮演了兩種角色 • Client:當作傳送信件的server • Server:當作接收信件的server • Client和server這兩種服務都會執行在每一台郵件伺服器上

  24. E-mail– SMTP • SMTP: Simple Mail Transfer Protocol • RFC編號: 821 • 使用TCP作為下層溝通的協定 • Port: 25 • 傳送三部曲 • Handshaking • Transfer of messages • closure • 所有信息資訊必須是7-bit ASCII

  25. SMTP和HTTP的比較 • 相同處 • 使用TCP為傳輸層協定 • Client and server model • 使用persistent connections • 不同處 • http是pull protocol而SMTP是push protocol • SMTP的message限定在7 bit ASCII • 文件組成方式不同

  26. SMTP溝通範例 S: 220 cs.nthu.edu.tw C: HELO oz.nthu.edu.tw S: 250 Hello oz.nthu.edu.tw, pleased to meet you C: MAIL FROM: <alice@oz.nthu.edu.tw> S: 250 alice@oz.nthu.edu.tw... Sender ok C: RCPT TO: <bob@cs.nthu.edu.tw> S: 250 bob@cs.nthu.edu.tw ... Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 cs.nthu.edu.tw closing connection

  27. 信息格式 • RFC 822為text message exchange標準 • Header lines • To: • From: • Subject: • Body • The message, ASCII character only header blank line body

  28. 信息格式 (cont.)

  29. 信息格式 (cont.)

  30. 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 MIME extension for Non-ASCII data • MIME: multimedia mail extension • RFC 2045, 2056 • 目的:為了要能夠支援非ASCII的data • 在標頭檔定義MIME的格式 MIME version(版本) 壓縮資料的方法 (encode data) 多媒體資料的種類 及副檔名(type, subtype) 壓縮的資料 (encoded data)

  31. MIME (cont.) • RFC 822 MIME所增加的標頭檔(headers)

  32. 文字(Text) 例如:副檔名為plain, html 圖片(Image) 例如:副檔名為jpeg, gif 聲音(Audio) 例如:副檔名為basic (8-bit mu-law encoded), 32kadpcm (32 kbps coding) 影像(Video) 例如:副檔名為mpeg, quicktime 應用程式(Application) other data that must be processed by reader before “viewable” 例如:副檔名為 msword, octet-stream MIME 的種類(types)Content-Type: 種類/副檔名; 參數(type/subtype; parameters)

  33. 郵件存取協定(mail access protocol) • SMTP負責接收端server的傳送及儲存信息 • Mail access protocol:從server取回信件 • POP: Post Office Protocol • RFC 1939 • 提供認證及下載服務 • IMAP • RFC 2060 • 可以遠端操作信件,不需下載信件至機器上 • HTTP (web mail) • Hot mail, mail2000, yahoo…

  34. POP3協定 S: +OK POP3 server ready C: user alice S: +OK C: pass hungry S: +OK user successfully logged on authorization phase • client commands: • user: declare username • pass: password • server responses • +OK • -ERR transaction phase, client: • list: list message numbers • retr: retrieve message by number • dele: delete • quit C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

  35. 用指令方式連線SMTP 送Email • telnet mail.cyu.edu.tw 25 • see 220 reply from server • enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email client (reader)

  36. Sample SMTP interaction S: 220 mail.cyu.edu.tw …… C: HELO mail.cyu.edu.tw S: 250 Hello mail.cyu.edu.tw, pleased to meet you C: MAIL FROM: <B96xxxxx@cyu.edu.tw> S: 250 B96xxxxx@cyu.edu.tw... OK C: RCPT TO: <B96xxxxx@cyu.edu.tw> S: 250 B96xxxxx@cyu.edu.tw... Recipient ok C: DATA S: 354 Enter mail, end with "." C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 mail.cyu.edu.tw closing connection

  37. 用指令方式連線 POP 收 Email • telnet mail.cyu.edu.tw 110 • See +OK reply from server • enter user, pass, list commands above lets you receive email without using email client (reader)

  38. authorization phase client commands: user: declare username pass: password server responses +OK -ERR transaction phase, client: list: list message numbers retr: retrieve message by number dele: delete quit POP3 protocol S: +OK POP3 server ready C: user B9613xxx S: +OK C: pass keyin密碼 S: +OK user successfully logged on C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

  39. 網路工具軟體 • Wireshark(封包解析軟體) • http://www.wireshark.org/ • Free IP Scanner(網路掃瞄工具) • http://www.eusing.com/ipscan/free_ip_scanner.htm • TCP View(檢查Windows開啟的TCP連線) • http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx

  40. Windows網路相關指令 • arp –a 查詢IP的MAC位址 • Ping IP_address送出ICMP封包,查詢該IP的回應時間 • Tracert 查詢路由路徑 • netstat -anb參數“b”,除了會列出PID外,也會列出該程式的名稱,及相關的動態函式庫 • Ipconfig 電腦IP的設定情況與指令

More Related