[Network] Application Layer - Electronic Mail
Electronic mail 에는 세가지 주요 구성요소가 있다 : user agents, mail servers and Simple Mail Transfer Protocol(SMTP).
User Agent 는 mail reader 라고도 부르며, user 가 mail message 를 쓰고, 읽고 보내는 등의 역할을 할 수 있게 한다. mail server 로 mail 을 보내거나 mail server 에서 mail 을 가져올 수 있다. user agent 의 종류로 Microsoft Outlook 과 Apple Mail 등이 있다.
Mail Server 는 e-mail infrastructure 의 core이다. mail server 에는 mail box 와 message queue 가 있다. mail box 는 user 가 보낸 message 를 받아 저장한다. message queue 는 mail server 가 다른 mail server 로 mail 을 전달하지 못할 때 message 를 보관하여 나중에 보낼 수 있게 한다.
SMTP 는 Internet electronic mail 을 위한 application-layter protocol 로 mail server 사이에 email message 를 보낼 때 사용한다. client side 와 server side 가 존재하며, client side(SMTP client) 는 mail 을 보내는 mail server이고 server side(SMTP server) 는 mail 을 받는 mail server 이다.
SMTP
SMTP 는 electronic mail 의 핵심으로, senders' mail server 에서 recipients' mail server 로 message 를 보내는 역할을 한다. SMTP 는 좋은 성능을 갖지만, HTTP 보다 오래되어 mail message 는 7-bit ASCII 로 제한된다는 특징이 있다.
SMTP 는 email 을 reliablly 하게 보내기 위해 TCP 를 사용하며 port 번호로 25번을 사용한다. SMTP client 와 SMT server 를 direct connection 을 이루며 intermediate mail server 를 사용하지 않는다.
SMTP 는 세 단계를 거쳐 message 를 전송한다. 먼저 server 와 client 사이에 handshaking 을 통해 TCP connection 을 맺는다. handshaking 이 끝난 후 clinet 는 server 로 message 를 보내고, 전송할 message 가 더 없다면 TCP connection 을 close 한다.
Alice 가 Bob 에게 mail message 를 보내는 시나리오는 다음과 같다.
- Alice 는 UA 를 사용해 'bob@someschool.edu' 에 message 를 보낸다.
- Alice's UA 는 Alice's mail server 에 message 를 보내고, message 는 message queue 에 보관된다.
- Alice's mail server(SMTP client) 는 Bob's mail server(SMTP server) 와 TCP connection 을 맺는다.
- SMTP client 는 TCP connection 을 통해 Alice's message 를 보낸다.
- SMTP server 는 message 를 받아 mail box 에 보관한다.
- Bob 은 UA 를 통해 message 를 읽을 수 있다.
HTTP 와 몇 가지 차이점이 있다. HTTP 는 pull protocol 인 반면 SMTP 는 push protocol 이다. pull protocol 은 server 에서 information 을 pull 하는 protocol 이고 push protocol 은 server 로 information 을 push 하는 protocol 이다.
HTTP 는 message 제한이 없지만, SMTP 는 7-bit ASCII 로 제한된다.
HTTP 는 한 HTTP response message 에 한 object 가 들어있지만 SMTP 는 한 message 에 모든 message 의 objects 가 들어있다.
Mail Access Protocols
SMTP 가 sender's server 에서 receiver's server 로 message 를 보내고 저장하는 프로토콜이라면, receiver's server 의 mail box 에서 UA 가 mail 을 접근할 프로토콜, 즉 Mail Access Protocol 이 필요하다. Mail Access Protocol 에는 Post Office Protocol - Version 3(POP3), Internet Mail Access Protocl(IMAP), HTTP 등이 있다.
POP3
POP3 는 가장 단순하지만, 제약이 있는 프로토콜이다. POP3 는 UA 와 mail server 사이에 port 110 으로 TCP connection 을 연다. TCP connection 이 맺어지면 UA를 확인하는 authorization, message 를 전달하는 transaction, mail server 가 message 를 지우고 POP3 seesion 을 종료하는 update 순으로 진행된다.
"download and delete" mode 와 "downlaod and keep" mode 를 선택할 수 있다. POP3 session 내에서는 state 하지만 POP3 session 넘어서는 stateless 하다.
IMAP
IMAP 은 POP3 보다 많은 기능을 가지지만, 다소 복잡하다. IMAP 은 message 를 folder 를 만들어 message 를 folder 저장할 수 있다. 또한 user 는 특정 message 를 찾기위해 remote folder 를 검색할 수 있다.
POP3 와 달리 IMAP seesion 을 넘어서도 user state information 을 유지한다.
IMAP 은 messag 의 header 같은 component 를 얻을 수 있는데, low-bandwidth connection 이 있을 때 유용하다.
HTTP
gmail, Hotmail 등이 속하며 UA 는 보통 Web browser 가 된다.
참조
Computer Networking _ A Top Down Approach, 7th, converted