1 / 21

Chapter 6 Network Protocol

Chapter 6 Network Protocol. 소켓 프로그래밍. Network Protocol. Hypertext Transfer Protocol (HTTP) Simple Mail Transfer Protocol (SMTP) Post Office Protocol Version 3 (POP3) File Transfer Protocol (FTP). Hypertext Transfer Protocol. Hypertext Transfer Protocol (RFC 2616) HTML 문서를 전송하기 위해 이용

cherie
Download Presentation

Chapter 6 Network Protocol

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. Chapter 6Network Protocol 소켓 프로그래밍

  2. Network Protocol • Hypertext Transfer Protocol (HTTP) • Simple Mail Transfer Protocol (SMTP) • Post Office Protocol Version 3 (POP3) • File Transfer Protocol (FTP)

  3. Hypertext Transfer Protocol • Hypertext Transfer Protocol (RFC 2616) • HTML 문서를 전송하기 위해 이용 • TCP를 전송 프로토콜로 이용 • 요청-응답 메시지 교환 방식 • 클라이언트가 요청을 보낸 후 서버에 의해 순서대로 처리되고 응답이 올 때까지 대기해야 함 • 일반적인HTTP 메시지 포맷(based on RFC 822) :

  4. Hypertext Transfer Protocol • HTTP 요청 메시지 포맷 Start Line (request line) 헤더 공백 (CRLF)

  5. Hypertext Transfer Protocol • HTTP 요청 메시지 • Start Line (request line) • 8개의 메서드 (대소문자 구별) - OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT • Request URI - 요청할 리소스 • HTTP 버전 • 한 줄의 끝을 나타내는 문자 - Carriage Return (CR), Line Feed (LF) • Header (헤더) • Blank line (공백) - CRLF로만 구성 • HTTP 요청 메시지의 예 GET /rfc.html HTTP/1.1<CR><LF> Host: www.ietf.org<CR><LF> <CR><LF> • HTTP 버전 1.1에서는 Host 헤더가 필수

  6. Hypertext Transfer Protocol • HTTP 응답 메시지 포맷 Start Line (status line) 헤더 공백 (CRLF) HTML Content

  7. Hypertext Transfer Protocol • HTTP 응답 메시지 • Start Line (status line) • HTTP 버전 • Status Code (상태코드) • 첫 번째 숫자에 기초하여 5개의 클래스로 분류 • 1## - Informational • 2## - Success • 3## - Redirection • 4## - Client Error • 5## - Server Error • Reason Phrase (설명 구) • 가장 흔히 볼 수 있는 상태코드 – 404 Not Found • HTML 문서 - 응답 메시지의 끝 부분(blank line 뒤)에위치 • 예제 프로그램: HTTPClient.cs

  8. Simple Mail Transfer Protocol • Simple Mail Transfer Protocol (RFC 5321) • 메일을 보낼 때 사용되는 프로토콜 • TCP를 전송 프로토콜로 이용 • RFC 5321 – SMTP 명령, 응답 메시지에 대한 설명 • 각 명령은 CRLF로 끝남 • RFC 5322 – 이메일의Date, Time 필드에 대한 정의 • Example Fri, 25 Dec 2009 13:15:33 +0900

  9. Simple Mail Transfer Protocol • SMTP 명령

  10. Simple Mail Transfer Protocol • SMTP 응답 • Single line - 코드다음에 메시지가 옴 • Multi-line • Non-final line • 코드 다음에 마이너스(-)기호가 온 후에 메시지가 옴 • Final line • Single line과 동일한 방식으로 코드 다음에 메시지가 옴

  11. Simple Mail Transfer Protocol • SMTP 응답코드 • 3 digits • 첫 번째 숫자 – 응답 상태를 나타냄 • 2## - Positive Completion reply • 3## - Positive Intermediate reply • 4## - Transient Negative Completion reply • 5## - Permanent Negative Completion reply • 두 번째 숫자 – 응답 코드의 범주 • #0# - Syntax • #1# - Information • #2# - Connection • #5# - Mail system

  12. Simple Mail Transfer Protocol • Sample SMTP Transaction S: 220 example.com ESMTP C: EHLO example.org S: 250-Hello [208.77.188.166] S: 250-8BITMIME S: 250-SIZE S: 250 HELP C: MAIL FROM:<user@example.com> S: 250 OK C: RCPT TO:<otheruser@example.org> S: 250 OK C: DATA S: 354 Enter mail. End mail with <CRLF>.<CRLF> C: whatever content that should goes here C: . S: 250 OK C: QUIT S: 221 Bye • 예제 프로그램 : SMTPClient.cs

  13. Post Office Protocol Version 3 • Post Office Protocol Version 3 (RFC 1939) • 메일을 가져올 때 사용되는 프로토콜 • TCP를 전송 프로토콜로 이용 • 각 POP3 명령은 CRLF로 끝남 • 명령은 대소문자에 관계없이 사용가능 • 명령어가 인수를 포함하는 경우 명령어와 인수를 공백으로 구분 • 각 인수는 40문자를 넘을 수 없음

  14. Post Office Protocol Version 3 • POP3 명령

  15. Post Office Protocol Version 3 • POP3 응답 • 서버에서 반환되는 두 가지 응답상태, 대문자 • +OK : 긍정적인 상태 • -ERR : 부정적인 상태 • STAT명령을 사용할 경우 status 뒤에 추가 메시지가 올 수 있음 • 각 응답 메시지는 CRLF로 끝남 • 응답 메시지의 최대크기는 512문자 • Multiline 메시지를 반환할 경우에는 <CRLF>.<CRLF>로끝남 • 예제 프로그램: POP3Client.cs

  16. File Transfer Protocol • File Transfer Protocol (RFC 959) • 파일 업로드와 다운로드를 위해 사용됨 • TCP를 전송 프로토콜로 이용 • 서버에 대해 두 개의 분리된 연결을 요구 • Out-of-band control • 제어 연결 • 데이터 연결 • 제어와 데이터 전송이 같은 연결을 공유하지 않음 • 제어 연결을 통해 서버로 접속

  17. File Transfer Protocol • FTP 명령 • 일반적인 콘솔/명령 프롬프트 상의FTP 클라이언트에서 찾아볼 수 있는 FTP 명령과는 차이가 있음 • 어떠한 명령은 데이터 연결을 요구 • 데이터 연결이 필요할 때에는 데이터 연결을 설정 • 수행이 완료될 때 데이터 연결을 종료 • 데이터 연결은 특정 포트번호를 통해 설정될 수 있거나, 또는 서버에 의해 선택된 포트번호를 통해서도 데이터 연결이 설정될 수 있음(Passive mode) • 포트번호는 콤마(,)로 분리된 6개의 10진수 a1,a2,a3,a4,p1,p2를 인수로 가지는 PORT 명령에 의해 계산될 수 있음 • 앞에 오는 4개의 십진수는 IPv4주소를 의미 • 마지막 2개의 십진수가 포트번호를 의미 • Port number = p1 × 256 + p2

  18. File Transfer Protocol • FTP 명령

  19. File Transfer Protocol • FTP 명령

  20. File Transfer Protocol • FTP 명령

  21. File Transfer Protocol • FTP 응답 • SMTP 응답 포맷과 유사함 • 응답 코드 - 3 digits • 첫 번째 숫자 – 응답 상태 • 1## - Positive Preliminary reply • 2## - Positive Completion reply • 3## - Positive Intermediate reply • 4## - Transient Negative Completion reply • 5## - Permanent Negative Completion reply • 두 번째 숫자 – 범주 • #0# - Syntax • #1# - Information • #2z - Connections • #3# - Authentication and accounting • #5# - File system 예제 프로그램: FTPClient.cs

More Related