[Network] Web and HTTP(1)

sebยท2023๋…„ 4์›” 8์ผ
0

๋„คํŠธ์›Œํฌ

๋ชฉ๋ก ๋ณด๊ธฐ
4/9
post-thumbnail

๐Ÿ“š Network

ใ„ด ๐Ÿ“’ Chap.2 Application Layer

ใ„ด ๐Ÿ“„ Web and HTTP


๐Ÿ“Œ Web and HTTP

์›น ํŽ˜์ด์ง€๋Š” ๊ฐ๊ฐ ๋‹ค๋ฅธ ์›น ์„œ๋ฒ„์— ์ €์žฅ๋  ์ˆ˜ ์žˆ๋Š” ๊ฐ์ฒด(objects)๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.
ex) HTML file, JPEG image, JavaScript, audio file..

์›น ํŽ˜์ด์ง€๋Š” ๊ฐ๊ฐ uniform resource locator(URL)๋กœ ์ฃผ์†Œ ์ง€์ •์ด ๊ฐ€๋Šฅํ•œ referenced objects (์ฐธ์กฐ ๊ฐ์ฒด)๋“ค์„ ํฌํ•จํ•œ ๊ธฐ๋ณธ HTML ํŒŒ์ผ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

-> host name + path name


๐Ÿ“Œ HTTP

HTTP(Hyper Text Transfer Protocol)

HTTP๋Š” ์›น์—์„œ ์‚ฌ์šฉํ•˜๋Š” application layer protocol์ด๋‹ค.

- Hyperlink : ์‚ฌ์šฉ์ž๊ฐ€ ํด๋ฆญํ•˜์—ฌ ๋ฐ”๋กœ ์ฐพ์„ ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ์ฐธ์กฐ

- client / server model :

  • client : HTTP protocol์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์š”์ฒญ,์ˆ˜์‹ ํ•˜์—ฌ web objects๋ฅผ ๋ธŒ๋ผ์šฐ์ €์— ๋ณด์—ฌ์ค€๋‹ค.

  • server : HTTP protocol์„ ์‚ฌ์šฉํ•˜์—ฌ ์š”์ฒญ์— ๋”ฐ๋ฅธ object๋ฅผ ์†ก์‹ ํ•˜๋Š” ์›น ์„œ๋ฒ„

- HTTP๋Š” TCP๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์›น์€ ์‹ ๋ขฐ์„ฑ์ด ์ค‘์š”ํ•˜๊ธฐ์— ์‹ ๋ขฐ์„ฑ์„ ์ œ๊ณตํ•˜์ง€ ์•Š๋Š” UDP๋ณด๋‹ค TCP๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

์›น์ด TCP๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ˆœ์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  1. client๊ฐ€ TCP connection(creates socket)์„ ์„œ๋ฒ„์—์„œ port nubmer 80์œผ๋กœ ์š”์ฒญํ•œ๋‹ค.

  2. server๊ฐ€ client๋กœ๋ถ€ํ„ฐ ์š”์ฒญ๋œ TCP connection์„ ์ˆ˜๋ฝํ•œ๋‹ค.

  3. HTTP messages(application layer protocol message)๊ฐ€ client์™€ server ์‚ฌ์ด์—์„œ ๊ตํ™˜๋œ๋‹ค.

  4. TCP connection์ด ๋‹ซํžŒ๋‹ค.

- HTTP๋Š” "Stateless (๋น„์ƒํƒœ)" ์ด๋‹ค. server๋Š” client์˜ ์ด์ „ ์š”์ฒญ์˜ ์ •๋ณด, ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•˜์ง€ ์•Š๋Š”๋‹ค. ์ด์™€๋Š” ๋ฐ˜๋Œ€๋กœ server๊ฐ€ client์˜ ์ด์ „ ์ƒํƒœ๋ฅผ ๋ณด์กดํ•˜๋Š” staeful์ด ์žˆ๋‹ค. stateless๋Š” ์ƒํƒœ๋ฅผ ๋ณด๊ด€ํ•˜์ง€ ์•Š๊ธฐ์— ๊ฐ€๋ฒผ์šฐ๋ฉฐ client์˜ ์š”์ฒญ์— ์–ด๋–ค server๊ฐ€ ์‘๋‹ต์„ ํ•ด๋„ ์ƒ๊ด€์ด ์—†๊ธฐ์— client์˜ ์š”์ฒญ์ด ์ฆ๊ฐ€ํ•˜์—ฌ๋„ ์„œ๋ฒ„์˜ ์ฆ์„ค์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.


๐Ÿ“Œ HTTP Connection

HTTP Connection์—๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ์‹์ด ์žˆ๋‹ค.

  • Non-persistent connection HTTP(๋น„์ง€์† ์—ฐ๊ฒฐ)
    ๋น„์ง€์† ์—ฐ๊ฒฐ์€ TCP connection์„ ์—ด๊ณ  ํ•˜๋‚˜์˜ ๊ฐ์ฒด๋ฅผ ๋ณด๋‚ด๊ณ  ์—ฐ๊ฒฐ์„ ์ข…๋ฃŒํ•œ๋‹ค. ์›นํŽ˜์ด์ง€์˜ ๊ฐ์ฒด๊ฐ€ 10๊ฐœ๋ผ๋ฉด 10๋ฒˆ์˜ TCP connenction์ด ์ด๋ฃจ์–ด์ ธ์•ผ ํ•œ๋‹ค.
  • Persistent connection HTTP(์ง€์† ์—ฐ๊ฒฐ)
    ์ง€์† ์—ฐ๊ฒฐ์€ ํ•œ ๋ฒˆ์˜ TCP connection์—์„œ ๋‹ค์ˆ˜์˜ ๊ฐ์ฒด๋ฅผ ๋ณด๋‚ด๊ณ  ์ „๋‹ฌ์ด ๋๋‚ฌ์„ ๊ฒฝ์šฐ ์ข…๋ฃŒ๋œ๋‹ค.

๐Ÿ“Œ Non-persistent HTTP: response time

RTT(round-trip-time) : ํŒจํ‚ท์ด client๋กœ๋ถ€ํ„ฐ server๋ฅผ ํ†ตํ•ด ์™•๋ณตํ•˜๋Š” ์‹œ๊ฐ„.

Non-persistent connection์—์„œ์˜ HTTP response time์€ TCP Connection์„ ๋งŒ๋“œ๋Š” ๊ฒƒ์— ํ•˜๋‚˜์˜ RTT, ํ•˜๋‚˜์˜ ๊ฐ์ฒด๋ฅผ ์š”์ฒญํ•˜๊ณ  ๋ฐ›๋Š” ๊ฒƒ์— ํ•˜๋‚˜์˜ RTT, server์—์„œ client์— ํŒŒ์ผ์€ ์ „์†กํ•˜๋Š” ์‹œ๊ฐ„์„ ํฌํ•จํ•˜๊ฒŒ ๋œ๋‹ค.

Non-persistent HTTP response time : 2RTT + file transmission time

Non-persistent HTTP๋Š” ์—ฌ๋Ÿฌ ๊ฐ์ฒด๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด์„œ TCP connection์„ ์—ด๊ณ  ๋‹ซ๋Š” ํ–‰์œ„๋ฅผ ๋ฐ˜๋ณตํ•ด์•ผ ํ•˜๋ฏ€๋กœ ๋น„ํšจ์œจ์ ์ด๊ณ  ๋Š๋ฆฌ๋‹ค.

์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด Persistent connection์ด ๋“ฑ์žฅํ•˜์˜€๋‹ค. Persistent HTTP๋Š” server๊ฐ€ response๋ฅผ ๋ณด๋‚ธ ์ดํ›„ connection์„ ์—ด์–ด๋‘๊ณ , client๋Š” ์ƒˆ๋กœ์šด ์ฐธ์กฐ ๊ฐ์ฒด๋ฅผ ํŒŒ์‹ฑํ•˜๋ฉด ์ฆ‰์‹œ server์—๊ฒŒ ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ๋ฐฉ์‹์œผ๋กœ HTTP message๋ฅผ ๊ตํ™˜ํ•œ๋‹ค. ์ดํ›„ ์ผ์ • ์‹œ๊ฐ„๋™์•ˆ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜ค์ง€ ์•Š์œผ๋ฉด connection์„ ๋‹ซ๋Š”๋‹ค. ํ•œ ๋ฒˆ์˜ RTT๋กœ ๋‹ค์ˆ˜์˜ ๊ฐ์ฒด๋“ค์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ธฐ์— response time์„ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค.


๐Ÿ“Œ HTTP request message

request line : method, url, version , carriage return, line-feed

  • Header lines

  • General format

Method

  • POST : client์˜ user input์ด entity body์— ๋‹ด๊ฒจ POST request message๋กœ server์—๊ฒŒ ์ „๋‹ฌ

  • GET : user data๊ฐ€ HTTP GET request message์˜ URL field์— ํฌํ•จ๋˜์–ด ์ „๋‹ฌํ•œ๋‹ค. ์–ด๋– ํ•œ ์ •๋ณด๋ฅผ ์กฐํšŒํ•  ๋•Œ ๋งŽ์ด ์‚ฌ์šฉ.

  • PUT : PUT HTTP request entity body์˜ content์™€ ํŠน์ • URL์˜ ํŒŒ์ผ๊ณผ ๋Œ€์ฒดํ•œ๋‹ค.

  • DELETE : web server์˜ ๊ฐ์ฒด๋ฅผ ์‚ญ์ œํ•œ๋‹ค.

  • HEAD : ๊ธฐ๋ณธ์ ์œผ๋กœ GET method ์™€ ๋™์ผํ•˜๋‹ค.

    GET๊ณผ HEAD์˜ ์ฐจ์ด์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

    1. HEAD๋Š” GET์˜ ์š”์ฒญ๊ณผ ๋™์ผํ•œ ์‘๋‹ต์„ ์š”๊ตฌํ•˜์ง€๋งŒ, ์‘๋‹ต ๋ณธ๋ฌธ(body)์„ ํฌํ•จํ•˜์ง€ ์•Š๋Š”๋‹ค.

    2. GET์€ ํ—ค๋”์™€ ๋ฐ์ดํ„ฐ๋ฅผ ์„œ๋ฒ„์—๊ฒŒ ๋ณด๋‚ด๋Š” ๋ฐ˜๋ฉด, HEAD๋ฉ”์†Œ๋“œ๋Š” ํ—ค๋” ์™ธ์—๋Š” ์ „์†กํ•˜์ง€ ์•Š๋Š”๋‹ค.


๐Ÿ“Œ HTTP response message

  • status line : versin, status code

  • Header lines

  • Status Codes
    ์ƒํƒœ ์ฝ”๋“œ๋Š” 3์ž๋ฆฌ ์ˆซ์ž์ด๋ฉฐ ์ฒซ ๋ฒˆ์งธ ์ž๋ฆฌ๋Š” 1 ~ 5์˜ ์ˆซ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ 4, 5์ธ ๊ฒฝ์šฐ๋Š” ์ •์ƒ์ ์ธ ์ƒํ™ฉ์ด ์•„๋Š๋ฏ€๋กœ ๊ด€๋ฆฌ์ž๊ฐ€ ์ฆ‰์‹œ ์•Œ์•„์•ผ ํ•˜๋Š” ์ •๋ณด์ด๋‹ค.
    MDN : status codes

    • 1xx : information
    • 2xx : success
      ex) 200 OK
    • 3xx : redirection
      ex) 301 Moved Permanently
    • 4xx : client error
      ex) 400 Bad Request, 404 Not Found
    • 5xx : server error
      ex) 505 HTTP Version Not Supported

๐Ÿ”Ž [์ฐธ๊ณ  ๋ฌธํ—Œ]
Computer Networking A Top-Down Approach 7-th Edition / Kurose, Ross / Pearson

0๊ฐœ์˜ ๋Œ“๊ธ€