개발하는 뚝딱이

컴퓨터 네트워크 ch2(3) 본문

컴퓨터 네트워크

컴퓨터 네트워크 ch2(3)

개발자뚝딱이 2019. 10. 8. 23:59

Electronic Mail (SMTP, POP3, IMAP)

 


 

 

Electronic Mail

 

Three major components:

  • user agents
  • mail servers
  • simple mail transfer protocol : SMTP

 

User Agent

  • "mail reader" - 메일을 보내고 읽을 때 사용된다.
  • composing, editing, reading mail messages
  • e.g., Outlook, elm, Netscape Messenger
  • outgoing, incoming messages stored on server

Electronic Mail : mail servers

Mail servers

  • mailbox contains incoming messages for user (receiver 쪽)
  • message queue of outgoing(to be sent) mail messages (sender 쪽)
  • SMTP protocol between mail servers to send email messages [client-server 모델에서 작동]
  • client : sending mail server
  • server : receiving mail server

 

 

SMTP

  • uses TCP to reliably transfer email message from client to server on port 25
    • three phases of transfer
      • handshaking (greeting)
      • transfer of messages
      • closure
  • SMTP uses persistent connections
    • can send several messages over the same TCP connection
    • direct transfer : sending server to receiving server
  • The message must be in 7-bit ASCII
  • command/response interaction
    • commands : ASCII text
    • response : status code and phrase

 

 

E-mail scenario

Mail server 서로가 client, server 될 수 있다

Message queue (sender 쪽)

메시지를 저장하고 모아서 receiver 쪽 서버로 데이터 전달.

receiver에 따라서 다르게 만들 필요X, 그냥 queue에 쭉 넣는다.

 

Bob's mailbox

receiver에 따라서 mail box 따로따로 만들어 넣기

메일을 요청하면 꺼내온다.

 

 

 

 

Sample SMTP interaction

  • HELO : email server에 자신을 identify하는 command
  • MAIL FORM : 자기쪽 email 주소 주기
  • RCPT TO : 받는 사람의 email 주소 주기
  • DATA : 데이터 주기
  • . : carriage return / line feed
  • QUIT : 종료

 

Comparison with HTTP

  • 공통점
    • HTTP 1.1 and SMTP : persistent connection
    • both have ASCII command/response interaction, status code
  • 차이점
      • HTTP : pull protocol
      • SMTP : push protocol

     

    • HTTP : 하나의 HTTP response msg에 하나의 object가 들어있다
    • SMTP : 하나의 msg에 여러 개 mail이 들어있을 수 있다. 원래는 mail 보내는 것이므로 body에도 ASCII만 쓰도록 되어있다
    • SMTP는 body내용은 ASCII여야하지만, HTTP는 제약이 없다.

 

 

Mail message format

  • The message must be in 7-bit ASCII
  • MIME extension for non-ASCII data
    • RFC 2045, 2056
    • additional lines in msg header declare MIME content type

MIME [Multipurpose Internet Mail Extensions]

 

 

Message format : multimedia extensions

문자 'M'을 인코딩해보자!

1. ASCII 코드표에서 M의 값을 가져온다. [77]

2. 그 값을 8bit 2진수로 가져온다. [01001101]

3. 6bit로 나눈다. 이 때, 6bit로 나누고 남는 bit가 있다면 뒤에 0들을 추가한다. (패딩과정)

4. 6bit를 Base64 표에서 가져온다. [T]

5. 이 값을 다시 8bit로 변환한다.

 

3/4 효율

 

 

 

Non-ASCII :: 0X9D

Quoted-printable로 0011 1101 "=" (control character) 추가

0으로 시작 → ASCII 가능

1로 시작 → 역변환

 

1/3효율 

 

 

Protocols related to Mail

지금은 MAA에서 주로, POP/IMAP4 이용

 

Web-based e-mail

 

Mail access protocols

  • SMTP : delivery/storage to receiver's server
  • Mail access protocol : retrieval from server
    • POP3 : Post Office Protocol [RFC 1939]
      • authorization (agent ↔ server) and download
      • Use TCP connection on port 110
    • IMAP4 : Internet Mail Access Protocol [RFC 1730]
      • more features (more complex)
      • manipulation of stored msgs on server - provide the folder functionality
  • HTTP : gmail, Hotmail, Yahoo! Mail, etc (요즘은 거의 이것을 사용)

 

 

POP3 protocol

  • authorization phase
    • client commands :
      • user : declare username
      • pass : password
    • server responses
      • + OK
      • - ERR
  • transaction phase, client :
    • list : list message numbers (메일함에 있는 메일을 list해라)
    • retr : retrieve message by number (#번 메일을 보여줘라)
    • delete : delete
    • quit

위쪽이 authorization, 아래쪽이 transaction phase

 

 

 

 

 

 

 

 

 

 

 

 

 

 

'컴퓨터 네트워크' 카테고리의 다른 글

컴퓨터 네트워크 ch2(5)  (0) 2019.10.09
컴퓨터 네트워크 ch2(4)  (0) 2019.10.09
컴퓨터 네트워크 ch2 (2)  (0) 2019.10.08
컴퓨터 네트워크 ch2(1)  (0) 2019.09.27
컴퓨터 네트워크 ch1 (3)  (0) 2019.09.25