๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ5: ๐’ฆ๐‘œ๐“‡๐‘’๐’ถ ๐’ฐ๐“ƒ๐’พ๐“‹/Computer Network(COSE342)

[์ปดํ“จํ„ฐ๋„คํŠธ์›Œํฌ] CH2. Application Layer (#3)

E-mail (Electronic mail)

1. Overview

Three major components

  • User agents : ์œ ์ €
  • Mail servers : ๋ฉ”์ผ ์„œ๋ฒ„
  • Simple mail transfer protocol : SMTP
  1. User agent
    (= mail reader)
    • ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ํŽธ์ง‘ํ•˜๊ณ  ์ฝ์Œ
    • outgoing messages์™€ incoming message๋ฅผ ์„œ๋ฒ„์— ์ €์žฅํ•œ๋‹ค
  2. Mail Servers
    • ๋ฉ”์ผ์„ ์ฃผ๊ณ  ๋ฐ›๋Š” ์ผ์„ ํ•จ
    • Mailbox๋Š” ์œ ์ €์—๊ฒŒ ๋“ค์–ด์˜ค๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค
    • Message queue๋Š” ์œ ์ €๊ฐ€ ๋ณด๋‚ด๋Š” ๋ฉ”์ผ ๋ฉ”์‹œ์ง€๊ฐ€ ์ €์žฅ๋จ
  3. SMTP Protocol
    • ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•œ mail server ๊ฐ„์˜ ๊ทœ์น™
      • Client : ๋ฉ”์ผ์„ ์„œ๋ฒ„์—๊ฒŒ ๋ณด๋ƒ„
      • Server : ๋ฉ”์ผ์„ ๋ฐ›์Œ
    • user agent์—์„œ ๋ฉ”์ผ์„ ์ž‘์„ฑํ•˜๊ณ  ๋ฉ”์ผ ์„œ๋ฒ„์— ๋ณด๋‚ด ๋†“์œผ๋ฉด smtp ๋ผ๋ฆฌ ์ฃผ๊ณ ๋ฐ›๊ณ  ๋‹ค๋ฅธ user agent๊ฐ€ ๋ฉ”์ผ์ด ์˜จ ๊ฒƒ์„ ํ™•์ธํ•˜๊ณ  ๋ฐ›์•„์„œ ์ฝ์Œ

SMTP

  1. ํด๋ผ์ด์–ธํŠธ์™€ port 25์˜ ์„œ๋ฒ„ ๊ฐ„์˜ ์‹ ๋ขฐ์„ฑ์žˆ๋Š” ์ด๋ฉ”์ผ ๋ฉ”์‹œ์ง€ ๊ตํ™˜์„ ์œ„ํ•ด TCP ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค
  2. Direct transfer : server๋ฅผ receiving server๋กœ ๋ณด๋ƒ„...? sending server to receiving server
  3. ๋ฐ›๋Š” ์‚ฌ๋žŒ์˜ server๊นŒ์ง€ ์ง์ ‘ ์ „์†ก..??
  4. tranfer์˜ 3๊ฐ€์ง€ ๋‹จ๊ณ„
    1. Handshaking (greeting)
    2. Transfer of messages
    3. Closure
  5. Command/response interaction (like HTTP)
    • Commands : ASCII text
    • Response : status code and phrase
  6. ๋ฉ”์‹œ์ง€๋Š” ๋ฌด์กฐ๊ฑด 7 bit ASCII! (header & body)
  7. SMTP๋Š” persistent connection์„ ์‚ฌ์šฉํ•œ๋‹ค.
  8. SMTP ์„œ๋ฒ„๋Š” ๋ฉ”์‹œ์ง€์˜ ๋์„ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด CRLF.CRLF๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค

SMTP vs HTTP

  • HTTP : pull : server์— ๋ฐ์ดํ„ฐ๋ฅผ ์š”๊ตฌํ•ด์„œ ๊ฐ–๊ณ ์˜ด
    SMTP : push : server๊ฐ€ client์—๊ฒŒ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ๊ฐ€๋ผ๊ณ  ์คŒ
  • HTTP : ๋ฐ์ดํ„ฐ์— ํ˜•์‹ ์ œํ•œ์ด ์—†์Œ
    SMTP : ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋Š” ASCII format์ด์–ด์•ผ ํ•จ
  • HTTP : ๊ฐ object๋Š” ์ž์ฒด response message ์•ˆ์— ์บก์Šํ™”๋จ
    SMTP : ์—ฌ๋Ÿฌ object๊ฐ€ multi-part message๋กœ ๋ณด๋‚ด์ง

2. Scenario example

Alice๊ฐ€ Bobํ•œํ…Œ ๋ฉ”์ผ์„ ๋ณด๋‚ด๋ณด์ž.

  1. Alice๋Š” UA(User Agent)๋ฅผ ์‚ฌ์šฉํ•ด์„œ bob@someschool.edu์— ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•œ๋‹ค.
  2. Alice์˜ UA๋Š” ๊ทธ์˜ mail server์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ณ , ์ด ๋ฉ”์‹œ์ง€๋Š” message queue ์•ˆ์— ์œ„์น˜ํ•˜๊ฒŒ ๋œ๋‹ค.
  3. SMTP client๋Š” Bob์˜ mail ์„œ๋ฒ„์™€ TCP connection์„ ์—ฐ๋‹ค.
  4. SMTP client๋Š” TCP connection์„ ํ†ตํ•ด ์•จ๋ฆฌ์Šค์˜ ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐฅ์—๊ฒŒ ๋ณด๋‚ธ๋‹ค.
  5. Bob์˜ ๋ฉ”์ผ ์„œ๋ฒ„๋Š” ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ Bob's mailbox์— ๋†“๋Š”๋‹ค.
  6. Bob์€ ๊ทธ์˜ User agent๋ณด๊ณ  ๋ฉ”์‹œ์ง€๋ฅผ ์ฝ์œผ๋ผ๊ณ  ๊นจ์šด๋‹ค. (์•Œ๋ ค์ค€๋‹ค)

3. Mail access protocol

  • SMTP : receiver์˜ ์„œ๋ฒ„์— ์ „๋‹ฌ/์ €์žฅํ•˜๋Š” ๊ฒƒ
  • Mail access protocol : ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ํšŒ์ˆ˜, user agent๊ฐ€ ์„œ๋ฒ„์—์„œ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
    1. POP (Post Office Protocol) : ๊ถŒํ•œ, ๋‹ค์šด๋กœ๋“œ
      • POP3๋Š” ์„ธ์…˜ ๊ฐ„ stateless ํ•˜๋‹ค. (์ƒํƒœ ์ €์žฅ X)
        • POP3๋Š” "๋‹ค์šด๋กœ๋“œ ๋ฐ ์‚ญ์ œ" ์™€ "๋‹ค์šด๋กœ๋“œ ๋ฐ ๋ณด๊ด€" ๋ชจ๋“œ๊ฐ€ ์žˆ๋‹ค.
    2. IMAP (Internet Mail Access Protocol) : ๋” ๋งŽ์€ ๊ธฐ๋Šฅ ํƒ‘์žฌ (์„œ๋ฒ„์— ์ €์žฅ๋œ ๋ฉ”์‹œ์ง€๋ฅผ ์กฐ์ž‘ํ•˜๋Š” ๋“ฑ..)
    3. HTTP : gmail, hotmail, yahoo mail ๋“ฑ..

Domain Name System (DNS)

1. Structure

DNS

  • ์‚ฌ๋žŒ๋“ค์€ SSN, ์ด๋ฆ„, ์—ฌ๊ถŒ ๋ฒˆํ˜ธ ๋“ฑ ์‚ฌ๋žŒ๋งˆ๋‹ค ๋‹ค๋ฅธ ์—ฌ๋Ÿฌ๊ฐ€์ง€ Identifier ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
  • Internet hosts, router๋„ ์ด๋Ÿฌํ•œ identifier๊ฐ€ ์žˆ์Œ
    1. IP address (32 bit) : ๋ฐ์ดํ„ฐ๋“ค์—๊ฒŒ ์ฃผ์†Œ๋ฅผ ์ง€์ •ํ•ด์ค„ ๋•Œ ์”€
    2. name : ์‚ฌ๋žŒ์ด ์ฝ์„ ์ˆ˜ ์žˆ๋Š” ์ด๋ฆ„. ex) www.google.com

Domain Name System

  • ๋งŽ์€ name servers์˜ ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ํ†ตํ•ด ๊ตฌํ˜„๋œ Distributed database (๋ถ„์‚ฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค)
  • Application-layer protocol : ํ˜ธ์ŠคํŠธ์™€ name server๋Š” ์ด๋ฆ„์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ํ†ต์‹ ํ•œ๋‹ค. (address/name translate)
    • ์ด๊ฒƒ์„ ํ†ตํ•ด"core Internet function"(ํ•ต์‹ฌ ์ธํ„ฐ๋„ท ๊ธฐ๋Šฅ)์ด ๊ตฌํ˜„๋จ
    • network์˜ "edge"์˜ ๋ณต์žก์„ฑ

DNS Services

  1. ํ˜ธ์ŠคํŠธ ์ด๋ฆ„๊ณผ IP ์ฃผ์†Œ ๊ฐ„์˜ ๋ณ€ํ™˜์„ ํ•ด์คŒ
  2. host Aliasing ; ๊ฐ™์€ IP์— ์—ฌ๋Ÿฌ name์ด ์žˆ์„ ๊ฒฝ์šฐ
    • Canonical names (๋ณต์žกํ•œ ์ด๋ฆ„) / alias names (๋ณ„์นญ)
  3. mail server aliasing
  4. Load distribution
    • ์›น ์„œ๋ฒ„์˜ ๋ณต์ œ๋ฅผ ํ—ˆ์šฉํ•œ๋‹ค ; ๋งŽ์€ IP address๊ฐ€ ํ•œ ์ด๋ฆ„์— ๋Œ€์‘๋  ์ˆ˜ ์žˆ๋‹ค.

Why not centralize DNS ?

  1. Single point of failure ; ํ•˜๋‚˜๊ฐ€ ์ž˜๋ชป๋˜๋ฉด ์ „์ฒด๊ฐ€ ๋‹ค ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด๋‹ค
  2. Traffic volume์ด ๋„ˆ๋ฌด ํฌ๋‹ค
  3. Slow response ; centralized database๋กœ๋ถ€ํ„ฐ ๊ฑฐ๋ฆฌ๊ฐ€ ๋ฉ€๋ฉด ์‘๋‹ต์ด ๋Šฆ์–ด์ง„๋‹ค
  4. Maintenance ; ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ํž˜๋“ค๋‹ค.

Distributed, hierarchical database

Root DNS servers -> com DNS servers -> amazon.com DNS servers

๋งŒ์•ฝ ํด๋ผ์ด์–ธํŠธ๊ฐ€(local DNS Server) www.amazon.com์˜ IP ์ฃผ์†Œ๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด์„œ๋Š”?!

  1. ์ผ๋‹จ root server์— ์ฟผ๋ฆฌ ๋‚ ๋ ค์„œ com DNS server๋ฅผ ์ฐพ๋Š”๋‹ค.
  2. .com DNS serber์— ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ ค์„œ amazon.com DNS server๋ฅผ ์ฐพ๋Š”๋‹ค
  3. amazon.com DNS server์— ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ ค์„œ www.amazon.com์˜ IP ์ฃผ์†Œ๋ฅผ ์ฐพ๋Š”๋‹ค.

Root Name Servers

  • ๋”์ด์ƒ ์ชผ๊ฐค์ˆ˜ ์—†๋Š”..? ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†๋Š”..?? ๊ทธ๋Ÿฐ name์˜ local name server๊ฐ€ ์—ฐ๊ฒฐํ•˜๋Š”..? ๋ญ๋ž˜
  • ์„ธ์ƒ์—๋Š” 13๊ฐœ์˜ logical root name server๊ฐ€ ์กด์žฌํ•œ๋‹ค.

TLD and Authoritative servers

  • Top-level domain (TLD) servers:
    • com, org, net, edu, aero, jobs, museums ๋“ฑ๊ณผ ๋ชจ๋“  top-level ๋‚˜๋ผ ๋„๋ฉ”์ธ kr, uk, ca ๋“ฑ
    • VeriSign์€ .com TLD ์„œ๋ฒ„๋ฅผ ์œ ์ง€๊ด€๋ฆฌํ•œ๋‹ค
    • .edu TLD๋Š” ๊ต์œก์„ ์œ„ํ•œ ์„œ๋ฒ„
  • Authoritative DNS servers:
    • ๊ธฐ๊ด€์˜ ์ž์ฒด DNS ์„œ๋ฒ„๋Š” ๊ธฐ๊ด€์˜ named host์— ๋Œ€ํ•œ IP mappings์— ๋Œ€ํ•œ ๊ถŒํ•œ์žˆ๋Š” hostname์„ ์ œ๊ณตํ•œ๋‹ค.
    • ๊ธฐ๊ด€์ด๋‚˜ ์„œ๋น„์Šค ์ œ๊ณต์ž์— ์˜ํ•ด ์œ ์ง€๋ณด์ˆ˜ ๋œ๋‹ค.

Local DNS name server

  • ๊ณ„์ธต ๊ตฌ์กฐ์— ์—„๊ฒฉํ•˜๊ฒŒ ์†ํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • ๊ฐ ISP๋Š” ํ•˜๋‚˜์˜ default name server๋ฅผ ๊ฐ–๋Š”๋‹ค.
  • host๊ฐ€ DNS Query๋ฅผ ๋งŒ๋“ค ๋•Œ, ์ด ์ฟผ๋ฆฌ๋Š” ๊ทธ๊ฒƒ์˜ local DNS server๋กœ ์ „์†ก๋œ๋‹ค.
    • ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ „์†กํ•œ name-to-address pairs์˜ local cache๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
    • ๋งŒ์•ฝ cache๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด poroxy์ฒ˜๋Ÿผ DNS hierarchy์— ๋”ฐ๋ผ์„œ query๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.

2. DNS Name Resolution Examples

cis.poly.edu๊ฐ€ gaia.cs.umass.edu. ์˜ IP address๋ฅผ ๊ตฌํ•˜๋ ค ํ•œ๋‹ค.

Iterated query

  • ์—ฐ๊ฒฐ๋œ ์„œ๋ฒ„๋Š” ๋‹ค๋ฅธ ์„œ๋ฒ„์˜ name๊ณผ address๋กœ ์‘๋‹ตํ•œ๋‹ค.
  • ๋‚˜๋„ ์ด ์ด๋ฆ„ ๋ชจ๋ฅด๋‹ˆ๊นŒ ์ €๊ธฐ๊ฐ€์„œ ๋ฌผ์–ด๋ด!! ํ•˜๊ณ  ๋‹ค์Œ์— ์ ‘์†ํ•  ์„œ๋ฒ„ ์ด๋ฆ„๊ณผ ์ฃผ์†Œ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ๊ฒƒ

local DNS server์— ๋ฌธ์˜ -> local server๊ฐ€ root DNS server์— ๋ฌธ์˜ -> TLD DNS server์— ๋ฌธ์˜ -> authoritative DNS server "dns.cs.umass.edu" ์— ๋ฌธ์˜ -> gaia.cs.umass.edu ์ฐพ์Œ!! local server๊ฐ€ requesting hostํ•œํ…Œ IP ์ฃผ์†Œ ๋„˜๊น€

Recursive query ๋ฐฉ์‹ (๋งŽ์ด ์“ฐ์ด์ง€๋Š” ์•Š์Œ)

  • ์—ฐ๊ฒฐ๋œ name server์—๊ฒŒ ์ด name ํ•ด๊ฒฐํ•˜๋ผ๊ณ  ์ฑ…์ž„์„ ๋– ๋ฐˆ
  • ์Šคํƒ์„ ์ด์šฉํ•ด์„œ ๊ณ„์† ๋ฌผ์–ด๋ณด๊ณ  ์Šคํƒ์„ ํ‘ธ๋Š” ๋ฐฉ์‹์œผ๋กœ ๋Œ์•„์™€์„œ ํ˜ธ์ŠคํŠธํ•œํ…Œ ip๊ฐ€ ๋Œ์•„์˜ค๊ฒŒ ๋จ
  • ์ƒ์œ„ ๊ณ„์ธต์—์„œ์˜ ๋ถ€ํ•˜๊ฐ€ ์‹ฌํ•˜๋‹ค.

Caching, Updating Records

  1. ํ•œ ๋ฒˆ ์–ด๋–ค name server๊ฐ€ mapping์„ ํ•™์Šตํ•˜๋ฉด, ์ด mapping์„ caches์— ์ €์žฅํ•จ
    • ์ด ์บ์‹œ๋Š” ์–ด๋Š์ •๋„ ์‹œ๊ฐ„์ด ์ง€๋‚˜๋ฉด(TTL) ์‚ฌ๋ผ์ง€๊ฒŒ ๋˜์–ด์žˆ์Œ(timeout)
    • TLD ์„œ๋ฒ„๋Š” ๋ณดํ†ต local name server์— ์บ์‹œ๋˜์–ด์žˆ์œผ๋ฏ€๋กœ root name server์— ๋ฐฉ๋ฌธํ•  ์ผ์ด ๋งŽ์ง€๋Š” ์•Š์Œ
  2. ์บ์‹œ๋˜์—ˆ๋˜ entries๊ฐ€ out-of-date, ์ด๋ฏธ ์ง€๋‚˜๋ฒ„๋ฆฐ ์˜ˆ์ „ ๊ฒƒ์ผ ์ˆ˜ ์žˆ์Œ.
    • ๋งŒ์•ฝ ํ˜ธ์ŠคํŠธ๊ฐ€ IP ์ฃผ์†Œ๋ฅผ ๋ฐ”๊ฟจ์„ ๊ฒฝ์šฐ, ์ด ์‚ฌ์‹ค์€ ๋ชจ๋“  TTL์ด ๋งŒ๋ฃŒ๋  ๋•Œ๊นŒ์ง€๋Š” ์ธํ„ฐ๋„ท ์ „์ฒด๊ฐ€ ์•Œ ์ˆ˜๊ฐ€ ์—†์Œ
  3. IETF standard์—๊ฒŒ ์ œ์•ˆ๋œ update/notify mechanisms : RFC 2136.

Formats of record and message

DNS Records

DNS : distributed database storing resource records (RR)

RR format : (name, value, type, ttl)

  • type=A
    • name : hostname
    • value : IP address
  • type=NS
    • name : domain
    • value : ์ด ๋„๋ฉ”์ธ์— ๋Œ€ํ•œ authoritative name server์˜ hostname
  • type=CNAME
    • name : canonical name(the real name)์„ ์œ„ํ•œ alias name(๋ณ„์นญ)
      (www.ibm.com์€ ์‹ค์ œ๋กœ๋Š” servereast.backup2.ibm.com์ž„)
    • value : canonical name
  • type=MX
    • value: name๊ณผ ์—ฐ๊ด€๋œ mail server์˜ ์ด๋ฆ„

DNS Message Format

  • ์ฟผ๋ฆฌ์™€ reply ๋ฉ”์‹œ์ง€ ๋ชจ๋‘ ๊ฐ™์€ message format์„ ์”€