[ํ’€์Šคํƒ] Transport Layer 4 / Process-to-Process Delivery

2023. 4. 11. 17:24ใ†ComputerScience/FullStackProgramming

 

 

 

Process-to-Process Delivery

  • The data link layer is responsible for delivery of frames between two neighboring nodes over a link.
  • This is called node-to-node delivery. -> ์„œ๋กœ ๋‹ค๋ฅธ ๊ณ„์ธต, ex) 1 - 2 ๊ณ„์ธต ๊ฐ„ ์ฃผ๊ณ  ๋ฐ›์„ ๋•Œ 
  • The network layer is responsible for delivery of datagram between two hosts.
  • This is called host-to-host delivery. -> ๋™์ผํ•œ ๊ณ„์ธต๋ผ๋ฆฌ ์ฃผ๊ณ ๋ฐ›์„ ๋•Œ (host) 
    ์•ž์„œ ์‚ดํŽด๋ณธ 1,2 ๊ทธ๋ฆฌ๊ณ  3 ๊ณ„์ธต ์ด์•ผ๊ธฐ
  • The transport layer is responsible for process-to-process delivery, which is the delivery of a packet,
    part of a message, from one process to another.
  • ํ”„๋กœ์„ธ์Šค ๊ฐ„ ์ฃผ๊ณ  ๋ฐ›์Œ -> IPC์— ํ•ด๋‹นํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.
    TCP Application Protocol is an IPC (Inter-process Communication) created to provide common remote interface for between applications.
  • Two processes communicate in a client/server relationship.

 

  • 4๊ณ„์ธต ๊ฐ„ ํ†ต์‹  - ํ”„๋กœ๊ทธ๋žจ(ํ”„๋กœ์„ธ์Šค) ๊ฐ„ ํ†ต์‹ ์„ ์˜๋ฏธ
  • 4๊ณ„์ธต์˜ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์—ญํ• ์€ ๋ญ๋ƒ? 
    * ์—๋Ÿฌ ๊ฒ€์ถœ๋ณด๋‹ค ์ค‘์š”ํ•œ ๊ฒƒ 
    ๋„๋Œ€์ฒด ์–ด๋Š ํ”„๋กœ๊ทธ๋žจ์ด ๋ณด๋‚ธ๊ฑฐ์•ผ? ๋ˆ„๊ฐ€ ๋ฐ›์•„์•ผ ํ•˜๋Š”๊ฑฐ์•ผ?
    ์ฆ‰, ์†ก์‹ /์ˆ˜์‹  ํ”„๋กœ๊ทธ๋žจ์˜ ์‹๋ณ„ 
 

 

 

Client/Server Paradigm

  • The most common process-to-process communication is though the Client/Server Paradigm.
  • Client : A process on the local host
  • Server : A process on the remote host to provide services.
  • Both processes (Client and Server) have the same name.
  • Ex) day time Client process and day time Server process. For communication, we must define the following;
    • Local host
    • Local process
    • Remote host
    • Remote process 
      • ์–ด๋Š ์ปดํ“จํ„ฐ์˜ / ๋ฌด์Šจ ํ”„๋กœ๊ทธ๋žจ 
        ip address / application address
        ์ฃผ์š”ํ•œ ์ •๋ณด 4๊ฐ€์ง€

 

 

 

Addressing

  •  A frame in the data link layer needs a destination MAC address.
  • At the network layer, we need an IP address.
  • At the transport layer, we need a transport layer address, called a Port number to choose among multiple processes running on the host.
  • Port number range : 0~65,535 (16-bit integer) Well-known port number
    : Universal port No. for server (fixed value, ranging : 0 ~1,023)
    • ๊ณ ์ •๋˜์–ด ์žˆ์œผ๋ฉฐ, ์‚ฌ์šฉํ•ด์„œ๋Š” ์•ˆ๋˜๋Š” well - known ํฌํŠธ ๋ฒˆํ˜ธ
    • ๋Œ€๋ถ€๋ถ„ ์šด์˜์ฒด์ œ ์„œ๋น„์Šค 
    • ์ด๊ฒƒ ์ด์ƒ์˜ ํ†ต์‹  ํ”„๋กœ๊ทธ๋žจ์„ ๋„์šธ ์ˆ˜ ์—†์Œ
  • Ephemeral port number : A port No.
    chosen randomly by the transport layer SW running on the client host.

 

  • ๊ฒฐ๊ตญ ํ”„๋กœ๊ทธ๋žจ์€ ์ฃผ์†Œ๋ฅผ ๊ฐ€์ ธ์•ผ ํ•œ๋‹ค. 
    port number : ๊ตฌ๋ฉ์˜ ๋ฒˆํ˜ธ
    ํ”„๋กœ๊ทธ๋žจ์ด ์šด์˜์ฒด์ œ ์œ„์— ๊ตฌ๋ฉ์„ ๋šซ๊ณ , ์ด๋ฅผ ํ†ตํ•ด ์ •๋ณด๋ฅผ ๋‚ด๋ฆฌ๊ณ  ๋ฐ›์Œ
    * cpp io stream -> file์€ ๋ฌผ๋ฆฌ์ ์ธ ์œ„์น˜์— ๋ฐ”์ดํŠธ๋ฅผ ๊ฐ•๋ฌผ์ฒ˜๋Ÿผ ์Ÿ์•„๋ถ‡๋Š” ๊ฒƒ
    port ๊ตฌ๋ฉ์„ ํ†ตํ•ด, ์ •๋ณด๋ฅผ stream์œผ๋กœ ๋‚ด๋ฆฌ๋Š” ๊ฒƒ

 

  • ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€, ํ”„๋กœ๊ทธ๋žจ(ํ”„๋กœ์„ธ์Šค)๋ฅผ ์‹๋ณ„ํ•˜๋Š” ๊ฒƒ 
  • IP Address vs Port number 
    • ์•„์ดํ”ผ ์ฃผ์†Œ(3)๋ฅผ ํ†ตํ•ด ์ปดํ“จํ„ฐ ๊ธฐ๊ธฐ๋ฅผ ์‹๋ณ„ํ•˜๊ณ , ๋‚ด๋ถ€์˜ ํ”„๋กœ๊ทธ๋žจ(ํ”„๋กœ์„ธ์Šค)๋ฅผ ํฌํŠธ ๋„˜๋ฒ„(4)๋ฅผ ํ†ตํ•ด ์ฐพ๋Š”๋‹ค.

 

 

 

Socket Addresses

  • 5๊ณ„์ธต ์ด์ƒ์˜ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜
    ๊ตณ์ด ip ์ฃผ์†Œ์™€ ํฌํŠธ ๋ฒˆํ˜ธ๋ฅผ ๋”ฐ๋กœ ์ค˜์•ผ ํ• ๊นŒ?
    ๋‘˜์„ ํ•ฉ์ณ์„œ ํ•˜๋‚˜์˜ ์ˆซ์ž๋กœ ํ‘œํ˜„ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.
  • socket address ๋ผ๊ณ  ๋ถ€๋ฅด๊ธฐ๋„ ํ•˜๊ณ , ๋‘˜์„ ํ•ฉ์นœ ํ—ฅ์‚ฌ ๋ฒˆํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•œ๋‹ค. 

 

  • ์†Œ์ผ“ - ์ฝ˜์„ผํŠธ ๊ฝ‚๋Š” ๊ฒƒ
    ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์™ธ๋ถ€ ํ†ต์‹ ์„ ์œ„ํ•ด
    ์šด์˜์ฒด์ œ์— ํ†ต์‹ ์„ ์œ„ํ•œ ์†Œ์ผ“์„ ๊ฝ‚์€ ๊ฒƒ์ด๋‹ค.
    tcp udp ๊ธฐ๋ฐ˜์˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ == ์†Œ์ผ“ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
  • IP ์œ„์—์„œ ์ฃผ์†Œ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๊ณ , tcp ์œ„์—์„œ ์ •๋ณด๋ฅผ ์ฃผ๊ณ  ๋ฐ›์Œ

 

 

 

Connectionless vs Connection-Oriented Service

  • Connectionless Service
    • The packets are not numbered; they may be delayed or connection release.
    • There is no acknowledgment either.
    • UDP protocol is connectionless in the Internet model.
    • ์—๋Ÿฌ ๊ฒ€์ถœ ๋ฐ ๋ณต๊ตฌ๊ฐ€ ํ•„์š” ์—†๋‹ค๋ฉด UDP ์จ๋„ ๋˜๋Š” ๊ฒƒ

 

  • Connection-Oriented Service
    • A connection is first established between the sender and the receiver.
    • Data are transferred.
    • At the end, the connection is released.
    • TCP and SCTP are connection-Oriented protocols.

 

  • osi 7 ๊ณ„์ธต์ด ํ•ด์•ผํ•  ์ผ
    • layer 4 - ์„œ๋กœ ๋‹ค๋ฅธ ์ปดํ“จํ„ฐ ๊ฐ„ ์—๋Ÿฌ ๊ฒ€์ถœ, ๋ณต๊ตฌ, ํ๋ฆ„ ์ œ์–ด
      ์ด๋ฅผ ์ถฉ์‹คํžˆ ํ•˜๋Š”๊ฒŒ tcp
      ์ถฉ์‹คํžˆ ์•ˆํ•˜๋Š”๊ฒŒ udp 
  • ์•ˆํ•ด๋„ ๋˜๋ƒ? ํ†ต์‹ ์€ ์•ˆ ํ•  ์ˆ˜๋„ ์žˆ์Œ
  • ์—๋Ÿฌ ๊ฒ€์ถœ ๋ฐ ๋ณต๊ตฌ ํ•˜๋ ค๋ฉด ์ฃผ๊ณ  ๋ฐ›๋Š” ์ •๋ณด ๋งค์šฐ ๋งŽ๋‹ค
    ์„œ๋กœ ์ค€๋น„ ํƒœ์„ธ๊ฐ€ ํ•„์š”ํ•˜๋‹ค
    tcp - ์—ฐ๊ฒฐ ์„ค์ • ๊ณผ์ •์„ ํ•œ๋‹ค - ๋ฏธ๋ฆฌ ์ •๋ณด๋ฅผ ์ฃผ๊ณ  ๋ฐ›์•„ ๋ณด์ž
    ์ค€๋น„ ๋˜์—ˆ๋‹ค๋ฉด? ๋ฐ์ดํ„ฐ๋ฅผ ์˜์ž! -> ์ปค๋„ฅ์…˜์ด ๋จผ์ € ์ค€๋น„๋˜์–ด์•ผ ํ•œ๋‹ค. 
  • ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฝ”๋“œ ์•ˆ์— ์ด ๊ณผ์ •์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

 

 

Reliable vs Unreliable

  • Reliable Service (์‹ ๋ขฐ)
    • If the application layer program needs reliability,
      we use a reliable transport protocol such as TCP and SCTP.
    • This means a slower and more complex service.
  • Unreliable Service
    • If the application layer program does not need reliability
      because it uses its own flow and error control mechanism 
      or it needs fast service
      or the nature of the service does not demand flow and error control (real-time application),
      then unreliable protocol such as UDP can be used.
  • TCP ์ตœ๋Œ€ํ•œ ์‹œ๋„ํ•˜๋‹ค๊ฐ€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค? -> ํฌ๊ธฐ ๋ณด๋‹ค๋Š” reset
    ์—ฐ๊ฒฐ ์„ค์ •์„ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค. ์™œ? 
    ํ”„๋กœํ† ์ฝœ์ด ๋„ˆ๋ฌด ๋ณต์žกํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ์šฐ๋ฆฌ๊ฐ€ ํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ์„ ์€ Reset
  • TCP ์—๋Ÿฌ ๊ฒ€์ถœ ๋ฐ ๋ณต๊ตฌ๋ฅผ ํ•˜์ง€๋งŒ,
    2๊ณ„์ธต๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ
    4๊ณ„์ธต์˜ tcp๋„ ์ตœ์„ ์„ ๋‹คํ•˜๋Š” ๊ฒƒ -> ์•ˆ๋˜๋ฉด ? ํฌ๊ธฐ

 

 

 

https://www.javatpoint.com/computer-network-transport-layer

 

 

 

  • Do we need reliability control at the transport layer,
    even the data link layer(2๊ณ„์ธต) is reliable and has flow and error control?
  • The answer is yes.
  • The network layer in the Internet is unreliable (best- effort delivery),
    we need to implement reliability at the transport layer.
  • ์™œ 2๊ณ„์ธต -> 4๊ณ„์ธต๋„ ๋˜ ์—๋Ÿฌ๊ฒ€์ถœ ๋ณต๊ตฌ๋ฅผ ํ•ด์•ผ ํ•ด์š”? 
    1) 1-2๊ณ„์ธต์—์„œ ํฌ๊ธฐ ๊ฐ€๋Šฅ 
    2) 3๊ณ„์ธต์—์„œ๋„ ์˜ค๋ฅ˜ ๋‚  ์ˆ˜ ์žˆ๊ณ , (๋ผ์šฐํ„ฐ, ๊ฐ€๋Šฅ์„ฑ์€ ๊ฑฐ์˜ ์—†์ง€๋งŒ)
    3) ์ •์ƒ์  ์˜ค๋ฅ˜ ์ƒํ™ฉ (์—๋Ÿฌ๋ผ๊ณ  ๋ณด๊ธฐ๋Š” ์–ด๋ ต๊ณ )
     - ํŠน์ • ํฌํŠธ๋กœ ํŠธ๋ž˜ํ”ฝ์ด ๋ชฐ๋ฆฌ๋ฉด -> ๋ฒ„ํผ ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ -> ํŒจํ‚ท์ด ๋ฒ„๋ ค์งˆ ์ˆ˜ ๋ฐ–์— ์—†๋‹ค.