728x90
๋ฐ˜์‘ํ˜•

๊ฐœ๋ฐœ์„ ์ง„ํ–‰ํ•˜๋˜ ์ค‘, ๋ฒ„ํŠผ ์•ˆ์— ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ๊ณ  ์‹ถ์€๋ฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

์ด ๋ฌธ์ œ๋Š” ์ด์ „์— ํ•ด๊ฒฐํ•œ ์ ์ด ์žˆ์—ˆ๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ํ–ˆ๋Š”์ง€ ๊ธฐ์–ต์ด ๋‚˜์งˆ ์•Š์•˜๋‹ค.

 

์•ž์œผ๋กœ ๋น„์Šทํ•œ ์ƒํ™ฉ์„ ๋งˆ์ฃผํ–ˆ์„ ๋•Œ ์ฐพ์•„๋ณด๊ธฐ ์œ„ํ•ด ์ •๋ฆฌํ•œ๋‹ค!!

 

์ด๋ฏธ์ง€ ํฌ๊ธฐ ์กฐ์ •ํ•˜๊ธฐ

์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋จผ์ € extension์„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

import UIKit

extension UIImage {
    func resize(targetSize: CGSize) -> UIImage? {
        let rect = CGRect(origin: .zero, size: targetSize)
        UIGraphicsBeginImageContextWithOptions(targetSize, false, 0.0)
        self.draw(in: rect)
        let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return resizedImage
    }
}

์ด๋ ‡๊ฒŒ UIImage ์ต์Šคํ…์…˜์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

 

 

 

๊ทธ๋ฆฌ๊ณ , ์›ํ•˜๋Š” ๋ฒ„ํŠผ์„ ์„ธํŒ…ํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

private let settingButton = UIButton().then {
    let imageSize = CGSize(width: 100, height: 100) // 1
    let resizedImage = UIImage(systemName: "gearshape")?.resize(targetSize: imageSize) // 2
    $0.imageView?.contentMode = .scaleToFill // 3
    $0.setImage(resizedImage, for: .normal) // 4
}

(๋‚˜๋Š” then์„ ์‚ฌ์šฉํ•˜์˜€๋‹ค.)

1. ๋จผ์ €, ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ CGSize๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •ํ•ด์ค€๋‹ค. ์œ„ ์ฝ”๋“œ์—์„œ๋Š” ๋„ˆ๋น„์™€ ๋†’์ด ๋ชจ๋‘ 100์œผ๋กœ ์„ค์ •๋˜์—ˆ๋‹ค.

2. ๊ทธ๋ฆฌ๊ณ , ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜๊ณ ์ž ํ•˜๋Š” ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€ ์•„๊นŒ ๋งŒ๋“ค์–ด๋‘” extension์„ ์‚ฌ์šฉํ•ด์ค€๋‹ค.

3. ์ด์ œ ์ด๋ฏธ์ง€๋ทฐ์˜ contentMode๋ฅผ scaleToFill๋กœ ์„ค์ •ํ•ด ์ด๋ฏธ์ง€๊ฐ€ ๋ทฐ์— ๊ฐ€๋“ ์ฐจ๋„๋ก ํ•œ๋‹ค.

4. UIButton์— ์žˆ๋Š” setImageํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ์ด์ „์— ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€์ค€๋‹ค.

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด, UIButton ์•ˆ์— ์›ํ•˜๋Š” ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , ๊ทธ ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ ๋งˆ์Œ๋Œ€๋กœ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

๊ฐœ๋ฐœ์„ ํ•˜๋˜ ์ค‘, ํ…Œ์ด๋ธ” ๋ทฐ ์•„๋ž˜ ์ž๊พธ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ๋ถ„์„ ์ด ์ƒ๊ธฐ๋Š” ๊ฑธ ํ™•์ธํ–ˆ๋‹ค.

 

limitTableView.separatorStyle = .none

 

๊ทธ๋Ÿด ๋•Œ๋Š” ์ด๋ ‡๊ฒŒ ๊ตฌ๋ถ„ ์Šคํƒ€์ผ์„ .none์œผ๋กœ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋œ๋‹ค.

 

 

์ด์ œ ์ด๋ ‡๊ฒŒ ๊ตฌ๋ถ„์„ ์ด ์‚ฌ๋ผ์ง„ ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค !

728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•
๋ฐ˜์‘ํ˜•

2.1 ๋„คํŠธ์›Œํฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์›๋ฆฌ

Creating a network app

  • software ๊ฐœ๋ฐœ์ž ๊ด€์ ์—์„œ๋Š” ๋„คํŠธ์›Œํฌ ๊ตฌ์กฐ๊ฐ€ ๊ณ ์ •๋˜์–ด ์žˆ๋‹ค. ํ•˜์ง€๋งŒ, application ๊ตฌ์กฐ๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ์„ค๊ณ„ํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ์ข…๋‹จ ์‹œ์Šคํ…œ์—์„œ ์–ด๋–ป๊ฒŒ ์กฐ์ง๋˜์–ด์•ผ ํ•˜๋Š”์ง€๋ฅผ ์•Œ๋ ค์ค€๋‹ค.
  • ์ด๋Ÿฌํ•œ application ๊ตฌ์กฐ๋Š” ํฌ๊ฒŒ 2๊ฐ€์ง€๋กœ ๋‚˜๋‰œ๋‹ค.
    • Client - server ๊ตฌ์กฐ
    • P2P ๊ตฌ์กฐ

Client-server paradigm

  • Server
    • ํ•ญ์ƒ ๋™์ž‘ํ•˜๊ณ  ์žˆ๋Š” ์„œ๋ฒ„๊ฐ€ ์กด์žฌํ•˜๊ณ , Client๋ผ๋Š” ๋‹ค๋ฅธ ํ˜ธ์ŠคํŠธ๋“ค๋กœ๋ถ€ํ„ฐ ์„œ๋น„์Šค ์š”์ฒญ์„ ๋ฐ›๋Š”๋‹ค.
    • ์„œ๋ฒ„๋Š” ์ž˜ ์•Œ๋ ค์ง„ ๊ณ ์ • IP ์ฃผ์†Œ๋ฅผ ๊ฐ–๋Š”๋‹ค. (permanent IP address - not change)
    • ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ๋กœ๋ถ€ํ„ฐ ์˜ค๋Š” ๋ชจ๋“  ์š”์ฒญ์— ๋” ์‘๋‹ตํ•˜๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•  ๋•Œ
      • ๋งŽ์€ ์ˆ˜์˜ ํ˜ธ์ŠคํŠธ๋ฅผ ๊ฐ–์ถ˜ data center๊ฐ€ ๊ฐ•๋ ฅํ•œ ๊ฐ€์ƒ์˜ ์„œ๋ฒ„๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์—ญํ• ๋กœ ์‚ฌ์šฉ๋œ๋‹ค.
      • ๋ณดํ†ต 10๋งŒ๊ฐœ ์ •๋„์˜ ์„œ๋ฒ„๋ฅผ ๊ฐ–์ถ”๊ณ  ์žˆ๋‹ค.
  • Clients
    • ํ•„์š”ํ•  ๋•Œ connect ํ•œ๋‹ค.
    • may be intermittently connected (๊ฐ„์ ‘์ ์œผ๋กœ, ๊ฐ€๋”์‹ ์—ฐ๊ฒฐ๋œ๋‹ค)
    • dynamic IP address๋ฅผ ๊ฐ–๋Š”๋‹ค.
    • Client๋ผ๋ฆฌ๋Š” ์ง์ ‘ ํ†ต์‹ ํ•˜์ง€ ์•Š๋Š”๋‹ค.

P2P ๊ตฌ์กฐ

  • Client์™€ server ๋‘˜ ๋‹ค์˜ responsibility๋ฅผ ๊ฐ–๋Š”๋‹ค.
  • ํ•ญ์ƒ ์ผœ์ ธ์žˆ๋Š” ์„œ๋ฒ„์— ์˜์กดํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • ์ž„์˜์˜(arbitrary) end system๋“ค์€ ์ง์ ‘ ์†Œํ†ตํ•œ๋‹ค.
    • ์ฆ‰, peer๋ผ๋Š” ๊ฐ„ํ—์ ์œผ๋กœ ์—ฐ๊ฒฐ๋œ ํ˜ธ์ŠคํŠธ ์Œ์ด ์„œ๋กœ ์ง์ ‘ ํ†ต์‹ ํ•˜๊ฒŒ ํ•œ๋‹ค.
  • peer๋Š” ์šฐ๋ฆฌ๊ฐ€ ํ”ํžˆ ์•Œ๊ณ  ์žˆ๋Š” Client(laptop ๊ฐ™์€ ๊ฒƒ๋“ค)
  • **Self scalability(์ž๊ฐ€ํ™•์žฅ์„ฑ)**๋ฅผ ๊ฐ–๋Š”๋‹ค.
    • ์ฆ‰, ์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ์•„์งˆ์ˆ˜๋ก ๋„คํŠธ์›Œํฌ์— ๋ถ€๋‹ด์ด ์ปค์ง€๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์˜คํžˆ๋ ค ์„œ๋กœ ๋„์™€์„œ ๋„คํŠธ์›Œํฌ์˜ ํšจ์œจ์„ฑ์ด ๋†’์•„์ง„๋‹ค.
    • ์˜ˆ๋ฅผ ๋“ค์–ด, ํŒŒ์ผ ๊ณต์œ  application์—์„œ๋Š” ๊ฐ peer๋“ค์ด ํŒŒ์ผ์„ ์š”๊ตฌํ•˜์—ฌ ์ž‘์—… ๋ถ€ํ•˜๊ฐ€ ์ƒ๊ธฐ์ง€๋งŒ, ๊ฐ Peer๋“ค์€ ํŒŒ์ผ์„ ๋‹ค๋ฅธ Peer๋“ค์—๊ฒŒ ๋ถ„๋ฐฐํ•˜์—ฌ ์‹œ์Šคํ…œ์— ์„œ๋น„์Šค ๋Šฅ๋ ฅ์„ ๊ฐ–์ถ˜๋‹ค.
  • data center ๋“ฑ์ด ํ•„์š” ์—†์œผ๋ฏ€๋กœ ๋น„์šฉ์ด ํšจ์œจ์ ์ด๋‹ค.

 

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป 2.1.2 ํ”„๋กœ์„ธ์Šค ๊ฐ„ ํ†ต์‹ 

์‹ค์ œ ํ†ต์‹ ํ•˜๋Š” ๊ฒƒ์€ ํ”„๋กœ๊ทธ๋žจ์ด ์•„๋‹ˆ๋ผ, ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” ํ”„๋กœ๊ทธ๋žจ์ธ process์ด๋‹ค.

  • ๊ฐ™์€ host ๋ฒ”์œ„ ๋‚ด์—์„œ, ๋‘๊ฐœ์˜ process๋“ค์€ IPC๋ฅผ ์‚ฌ์šฉํ•ด communication ํ•œ๋‹ค.
    • Inter-process-communication : ๋‘ ๊ฐœ ์ด์ƒ์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•
  • ๋‹ค๋ฅธ host ๋ฒ”์œ„ ๋‚ด์—์„œ๋Š” exchanging messages๋ฅผ ํ†ตํ•ด ์†Œํ†ตํ•œ๋‹ค.
  • 2๊ฐœ์˜ ์ข…๋‹จ ์‹œ์Šคํ…œ์—์„œ ํ”„๋กœ์„ธ์Šค๋Š” ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•œ ๋ฉ”์‹œ์ง€ ๊ตํ™˜์œผ๋กœ ์„œ๋กœ ํ†ต์‹ ํ•œ๋‹ค.
  • P2P ๊ตฌ์กฐ์—์„œ์ฒ˜๋Ÿผ Client๋„ ์„œ๋ฒ„ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋  ์ˆ˜ ์žˆ๊ณ , ์„œ๋ฒ„๋„ client process๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.
  • ์†ก์‹  ํ”„๋กœ์„ธ์Šค : ๋ฉ”์‹œ์ง€๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ณด๋ƒ„
  • ์ˆ˜์‹  ํ”„๋กœ์„ธ์Šค : ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›๊ณ  ์—ญ์œผ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ƒ„์œผ๋กœ์จ ์‘๋‹ต

Client, Server process

  • client process : process that initiates communication
    • ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ์ชฝ์˜ ํ”„๋กœ์„ธ์Šค
  • server process : process that waits to be contacted
    • ์š”์ฒญ์„ ๋ฐ›๋Š” ์ชฝ์˜ ํ”„๋กœ์„ธ์Šค

Socket

process๋Š” socket์„ ํ†ตํ•ด ๋„คํŠธ์›Œํฌ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ณ  ๋ฐ›๋Š”๋‹ค. (๋ฌธ ๊ฐ™์€ ๊ฐœ๋…)

  • ํ˜ธ์ŠคํŠธ์˜ application ๊ณ„์ธต๊ณผ transport ๊ณ„์ธต๊ฐ„์˜ ์ธํ„ฐํŽ˜์ด์Šค์ด๋‹ค.
  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์ž๋Š” ์†Œ์ผ“์˜ application ๊ณ„์ธต์— ๋Œ€ํ•œ ๋ชจ๋“  ํ†ต์ œ๊ถŒ์„ ๊ฐ–์ง€๋งŒ, ์†Œ์ผ“์˜ transport ๊ณ„์ธต์— ๋Œ€ํ•œ ํ†ต์ œ๊ถŒ์€ ๊ฑฐ์˜ ๊ฐ–์ง€ ๋ชปํ•œ๋‹ค.
    • transport protocol์„ ์„ ํƒ
    • ์ตœ๋Œ€ ๋ฒ„ํผ์™€ ์ตœ๋Œ€ ์„ธ๊ทธ๋จผํŠธ ํฌ๊ธฐ ๊ฐ™์€ ์•ฝ๊ฐ„์˜ ๋งค๊ฐœ๋ณ€์ˆ˜ ์„ค์ •
  • sending process shoves message out door - ์ „์†ก ํ”„๋กœ์„ธ์Šค๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ–์œผ๋กœ ๋ฐ€์–ด๋‚ธ๋‹ค.
  • Application๊ณผ network ์‚ฌ์ด์˜ API๋ผ๊ณ ๋„ ํ•œ๋‹ค.

Addressing processes

ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ˆ˜ํ–‰๋˜๊ณ  ์žˆ๋Š” ๋‹ค๋ฅธ ํŒจํ‚ท์œผ๋กœ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ˆ˜์‹  ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ฃผ์†Œ๋ฅผ ๊ฐ–๊ณ  ์žˆ์–ด์•ผ ํ•œ๋‹ค. ์ˆ˜์‹  ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‘ ๊ฐ€์ง€ ์ •๋ณด๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

Identifier๋Š” IP์ฃผ์†Œ์™€ port number๋ฅผ ๊ฐ–๋Š”๋‹ค.

  1. ํ˜ธ์ŠคํŠธ์˜ ์ฃผ์†Œ ์ฆ‰, IP ์ฃผ์†Œ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.
    1. IP ์ฃผ์†Œ๊ฐ€ identifier๊ฐ€ ๋œ๋‹ค.
  2. ํ˜ธ์ŠคํŠธ ๋‚ด์˜ ์ˆ˜์‹  ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ช…์‹œํ•˜๋Š” ์‹๋ณ„์ž. ์ฆ‰ port ๋ฒˆํ˜ธ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.
    1. ์ด port ๋ฒˆํ˜ธ๋กœ ๋‚ด process๋ฅผ ํŠน์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
    2. ๊ฐ™์€ IP ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง„ ์—ฌ๋Ÿฌ application์ด๋‚˜ process๊ฐ€ ๋™์‹œ์— ์ˆ˜ํ–‰๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— port ๋ฒˆํ˜ธ๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.
  • IP๋ฅผ ํ†ตํ•ด ์ ์ ˆํ•œ computer๋ฅผ ์ฐพ๋Š”๋‹ค.

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป 2.1.3 An Application-layer protocol defines

application ๊ฐœ๋ฐœ์ž๋Š” ์†Œ์ผ“์˜ application ๊ณ„์ธต์— ๋Œ€ํ•œ ๋ชจ๋“  ํ†ต์ œ๊ถŒ์„ ๊ฐ–์ง€๋งŒ, ์†Œ์ผ“์˜ transport ๊ณ„์ธต์— ๋Œ€ํ•œ ํ†ต์ œ๊ถŒ์€ ๊ฑฐ์˜ ๊ฐ–์ง€ ๋ชปํ•œ๋‹ค. ์ฆ‰, ์—ฌ๊ธฐ์—์„œ๋Š” ๊ทธ ์ค‘ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์–ด๋–ค transport service๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€์— ๋Œ€ํ•œ ๋‚ด์šฉ์ด๋‹ค.

  1. Data integrity
    1. ์†์‹ค๋˜์ง€ ์•Š๋Š” data๋ฅผ ์ „์†ก
  2. throughput
    1. ๋‹ค๋ฅธ session๋“ค์ด network ๊ฒฝ๋กœ๋ฅผ ๋”ฐ๋ผ ๋Œ€์—ญํญ์„ ๊ณต์œ ํ•˜๊ณ , ์ด ์„ธ์…˜๋“ค์ด ์ƒ๊ฒผ๋‹ค ์—†์–ด์กŒ๋‹ค ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ€๋Šฅํ•œ ์ฒ˜๋ฆฌ์œจ์€ ์‹œ๊ฐ„์— ๋”ฐ๋ผ ๋ณ€ํ•œ๋‹ค. ์ด๋Š” ์–ด๋Š ๋ช…์‹œ๋œ ์†๋„์—์„œ ๋ณด์žฅ๋œ ๊ฐ€์šฉ ์ฒ˜๋ฆฌ์œจ์„ ์ œ๊ณตํ•œ๋‹ค.
    2. ์ด๋Ÿฌํ•œ ์ฒ˜๋ฆฌ์œจ ์š”๊ตฌ์‚ฌํ•ญ ์—ฌ๋ถ€๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‘ ๊ฐ€์ง€๋กœ ๋‚˜๋‰œ๋‹ค.
      1. effective app : ์ฒ˜๋ฆฌ์œจ ์š”๊ตฌ์‚ฌํ•ญ์ด ์žˆ๋Š” ๋ฏผ๊ฐ application
      2. elastic app : ํƒ„๋ ฅ์  application. ์ฒ˜๋ฆฌ์œจ ์š”๊ตฌ์‚ฌํ•ญ์ด ์—†๋‹ค.
  3. timing
    1. ์˜ˆ๋ฅผ ๋“ค์–ด, ์†ก์‹ ๊ธฐ๊ฐ€ socket์œผ๋กœ ๋‚ด๋ณด๋‚ด๋Š” ๋ชจ๋“  bit๊ฐ€ ์ˆ˜์‹ ์ž์˜ socket์— 100ms ๋‚ด์— ๋„์ฐฉํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฃผ๋กœ ์‹ค์‹œ๊ฐ„ application์—์„œ ์‚ฌ์šฉํ•œ๋‹ค.
  4. security
    1. data๋ฅผ ์•”ํ˜ธํ™” ํ•  ์ˆ˜ ์žˆ๋‹ค.

Internet transport protocols services

์ธํ„ฐ๋„ท ์ „์†ก ํ”„๋กœํ† ์ฝœ์ด ์ œ๊ณตํ•˜๋Š” ์„œ๋น„์Šค

  1. TCP ์„œ๋น„์Šค
  2. UDP ์„œ๋น„์Šค

TCP service

  • reliable transport
  • ์„œ๋กœ ์ „์†ก ์ œ์–ด ์ •๋ณด๋ฅผ ๊ตํ™˜ํ•˜๊ฒŒ ํ•œ๋‹ค.

UDP service

  • unreliable data transefer
  • hand shaking ๊ณผ์ •์ด ์—†๊ณ , ๋ฐ์ดํ„ฐ๊ฐ€ ์ „๋‹ฌ๋˜๋Š” ๊ฒƒ์„ ๋ณด์žฅํ•˜์ง€ ์•Š๋Š”๋‹ค.

TCP vs. UDP

  • TCP๊ฐ€ UDP๋ณด๋‹ค ๋” ์œ ์šฉํ•˜์ง€๋งŒ, UDP๋Š” ๋” ๋น ๋ฅด๋‹ค.
  • ๋‘˜ ๋‹ค ์ฒ˜๋ฆฌ์œจ ํ˜น์€ ์‹œ๊ฐ„ ๋ณด์žฅ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š๋Š”๋‹ค.
    • ๊ทธ๋ž˜์„œ ์‹œ๊ฐ„ ๋ฏผ๊ฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐ™์€ ๊ฒฝ์šฐ, ์ด๋Ÿฌํ•œ ์ฒ˜๋ฆฌ์œจ ๋ฐ ์‹œ๊ฐ„ ์ง€์—ฐ์— ์ž˜ ๋Œ€์ฒ˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์–ด ์žˆ๋‹ค.

 

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป 2.1.5 Application layer: Protocol

๋‹ค๋ฅธ ์ข…๋‹จ ์‹œ์Šคํ…œ์—์„œ ์‹คํ–‰๋˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์„œ๋กœ ๋ฉ”์‹œ์ง€ ๋ณด๋‚ด๋Š” ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•œ๋‹ค.

  • ๊ตํ™˜ ๋ฉ”์‹œ์ง€์˜ ํƒ€์ž…
  • ์—ฌ๋Ÿฌ ๋ฉ”์‹œ์ง€ ํƒ€์ž…์˜ ๋ฌธ๋ฒ•(syntax)
  • ํ•„๋“œ์˜ ์˜๋ฏธ, ์ฆ‰ ํ•„๋“œ์— ์žˆ๋Š” ์ •๋ณด์˜ ์˜๋ฏธ(semantics)
  • ์–ธ์ œ, ์–ด๋–ป๊ฒŒ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋ฉ”์‹œ์ง€๋ฅผ ์ „์†กํ•˜๊ณ  ๋ฉ”์‹œ์ง€์— ์‘๋‹ต ํ•˜๋Š”์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ๊ทœ์น™
728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

๋„คํŠธ์›Œํฌ์˜ ํ”„๋กœํ† ์ฝœ ๊ณ„์ธต ๊ตฌ์กฐ์™€ ์„œ๋น„์Šค ๋ชจ๋ธ, ์ธํ„ฐ๋„ท ํ”„๋กœํ† ์ฝœ ์Šคํƒ๊ณผ OSI ๋ชจ๋ธ, ์บก์Šํ™”, ์—ญ์บก์Šํ™”

๐Ÿช Why layering?

๊ณ„์ธต๊ตฌ์กฐ๋Š” ์–ด๋–ค ํ•œ ๊ณ„์ธต์˜ ๊ตฌํ˜„์ด ๋ณ€ํ•˜๋”๋ผ๋„ ์‹œ์Šคํ…œ์˜ ๋‚˜๋จธ์ง€ ๋ถ€๋ถ„์€ ๋ณ€ํ•˜์ง€ ์•Š๋Š”๋‹ค.
ํ•˜์ง€๋งŒ, layering์˜ ๋‹จ์ ์€ overhead๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. duplicateํ•  ๋•Œ overhead๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

  • ๊ฐ ๊ณ„์ธต์—์„œ ์ถ”๊ฐ€์ ์ธ ๋ฐ์ดํ„ฐ์™€ ์ฒ˜๋ฆฌ๋ฅผ ๋”ํ•จ์œผ๋กœ์จ ๋น„ํšจ์œจ์ด ์ƒ๊ธธ ์ˆ˜ ์žˆ๋‹ค.
    • ์ฆ‰, ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ๋•Œ, ์ถ”๊ฐ€์ ์ธ ์ •๋ณด(ํ—ค๋”)๋ฅผ ๋ถ™์—ฌ์•ผ ํ•œ๋‹ค.
  1. ๋ณต์žกํ•œ ์‹œ์Šคํ…œ ์ฒ˜๋ฆฌ:
    • ๋ณต์žกํ•œ ๋„คํŠธ์›Œํฌ ์‹œ์Šคํ…œ์„ ๊ณ„์ธต์œผ๋กœ ๋‚˜๋ˆ ์„œ ๊ฐ ๊ณ„์ธต์˜ ๊ธฐ๋Šฅ์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Œ.
  2. ๋ชจ๋“ˆํ™”์˜ ์žฅ์ :
    • ๊ณ„์ธต ๊ตฌ์กฐ ๋•๋ถ„์— ํ•œ ๊ณ„์ธต์˜ ๊ตฌํ˜„์„ ๋ณ€๊ฒฝํ•˜๋”๋ผ๋„ ๋‹ค๋ฅธ ๊ณ„์ธต์— ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š์Œ. ์ด๋ฅผ ํ†ตํ•ด ์‹œ์Šคํ…œ ์œ ์ง€๋ณด์ˆ˜ ๋ฐ ์—…๋ฐ์ดํŠธ๊ฐ€ ์šฉ์ดํ•ด์ง.
  3. ๊ณ„์ธตํ™”์˜ ๋‹จ์ :
    • ๊ณ„์ธต ๊ตฌ์กฐ๋Š” ์ค‘๋ณต๋œ ๊ธฐ๋Šฅ์„ ์ดˆ๋ž˜ํ•  ์ˆ˜ ์žˆ์Œ. ์˜ˆ๋ฅผ ๋“ค์–ด, ์˜ค๋ฅ˜ ๊ฒ€์ถœ ๊ธฐ๋Šฅ์ด ์—ฌ๋Ÿฌ ๊ณ„์ธต์—์„œ ์ค‘๋ณต๋˜์–ด ์žˆ์„ ์ˆ˜ ์žˆ์Œ. ๋˜ํ•œ, ๊ฐ ๊ณ„์ธต์—์„œ ์ถ”๊ฐ€๋˜๋Š” ์˜ค๋ฒ„ํ—ค๋“œ๋กœ ์ธํ•ด ์„ฑ๋Šฅ ์ €ํ•˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Œ.

 

๐Ÿช ISO/OSI reference model

์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์–ด๋–ป๊ฒŒ ์ฃผ๊ณ  ๋ฐ›๋Š”์ง€ ์„ค๋ช…ํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“  7๊ณ„์ธต ๊ตฌ์กฐ์˜ reference model์ด๋‹ค. ๊ฐ ๊ณ„์ธต์€ ๋…๋ฆฝ์ ์ด๋ฉฐ, ๊ณ„์ธต๊ฐ„ ์ƒํ˜ธ์ž‘์šฉ์„ ํ†ตํ•ด data๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š”๋‹ค.
  1. Application (์‘์šฉ)
  2. Presentation (ํ‘œํ˜„)
  3. Session (์„ธ์…˜)
  4. Transport (์ „์†ก)
  5. Network (๋„คํŠธ์›Œํฌ)
  6. Data Link (๋ฐ์ดํ„ฐ ๋งํฌ)
  7. Physical (๋ฌผ๋ฆฌ)

 

Presentation

data๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋ฐ์ดํ„ฐ ์•”ํ˜ธํ™” ํ˜น์€ ํ…์ŠคํŠธ๋ฅผ ASCII ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค.

 

Session

๋‘ ์žฅ์น˜๊ฐ€ ํ†ต์‹ ํ•˜๋Š” ๋™์•ˆ ์—ฐ๊ฒฐ ์„ธ์…˜์„ ๊ด€๋ฆฌํ•˜๊ณ , ์œ ์ง€ํ•œ๋‹ค.

→ ์œ„์˜ Presentation๊ณผ Session ๊ณ„์ธต์€ ํŠน์ • ์ƒํ™ฉ์—์„œ๋งŒ ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.

 

๐Ÿช Internet protocol stack

์ธํ„ฐ๋„ท ํ”„๋กœํ† ์ฝœ ์Šคํƒ์€ OSI ๋ชจ๋ธ๋ณด๋‹ค ๊ฐ„์†Œํ™” ๋œ 5๊ณ„์ธต ๋ชจ๋ธ๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋‹ค.

  1. Application (์‘์šฉ) - 5๊ณ„์ธต
    1. ํ•œ ์ข…๋‹จ system์— ์žˆ๋Š” application์ด ๋‹ค๋ฅธ ์ข…๋‹จ system์— ์žˆ๋Š” application๊ณผ ์ •๋ณด ํŒจํ‚ท์„ ๊ตํ™˜ํ•  ๋•Œ ์ด ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•œ๋‹ค.
    2. IMAP, SMTP, HTTP
  2. Transport (์ „์†ก) - 4๊ณ„์ธต
    1. data๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.
    2. TCP, UDP
  3. Network (๋„คํŠธ์›Œํฌ) - 3๊ณ„์ธต
    1. ๋ฐ์ดํ„ฐ๋ฅผ ์†ก์ˆ˜์‹  ํ•  ๊ฒฝ๋กœ๋ฅผ ์ฐพ์•„์ฃผ๋ฉฐ, IP์ฃผ์†Œ์™€ ๋ผ์šฐํŒ…์„ ๋‹ด๋‹นํ•œ๋‹ค.
    2. IP, routing protocols
  4. Link (๋ฐ์ดํ„ฐ ๋งํฌ) - 2๊ณ„์ธต
    1. ์ธ์ ‘ํ•œ ๋„คํŠธ์›Œํฌ ์žฅ์น˜๊ฐ„์˜ ๋ฐ์ดํ„ฐ ์ „์†ก์„ ๋‹ด๋‹นํ•œ๋‹ค.
    2. Ethernet, Wifi, PPP
  5. Physical (๋ฌผ๋ฆฌ) - 1๊ณ„์ธต
    1. ๋ฌผ๋ฆฌ์  ๋งค์ฒด๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•œ๋‹ค.

 

๐Ÿช Encapsulation / Decapsulation

๋ฐ์ดํ„ฐ๋ฅผ ์•ˆ์ „ํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•œ ํ•ต์‹ฌ ๊ฐœ๋…์ด๋‹ค.

๋„คํŠธ์›Œํฌ์—์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ „์†ก๋  ๋•Œ, ๊ฐ ๊ณ„์ธต์€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌ ํ•˜๋ฉด์„œ ์ž์‹ ๋งŒ์˜ ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ์บก์Šํ™” ๊ณผ์ •์„ ๊ฑฐ์นœ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์ˆ˜์‹  ์ธก์—์„œ ์ด ํ—ค๋”๋“ค์„ ์ œ๊ฑฐํ•˜๋Š” ์—ญ์บก์Šํ™” ๊ณผ์ •์„ ๊ฑฐ์ณ ๋ฐ์ดํ„ฐ๊ฐ€ ์ƒ์œ„ ๊ณ„์ธต์œผ๋กœ ์ „๋‹ฌ๋œ๋‹ค.

  • Encapsulation : higher → lower (ํ—ค๋”๋ฅผ ๋ถ™์—ฌ๊ฐ€๋Š” ๊ณผ์ •)
  • Decapsulation : lower → higher (ํ—ค๋”๋ฅผ ๋–ผ๊ฐ€๋Š” ๊ณผ์ •)

Encapsulation

  1. Application Layer: ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฉ”์‹œ์ง€๋กœ ์ „์†ก๋จ.
  2. Transport Layer: ๋ฉ”์‹œ์ง€์— ์„ธ๊ทธ๋จผํŠธ๊ฐ€ ์ถ”๊ฐ€๋จ.
  3. Network Layer์„ธ๊ทธ๋จผํŠธ์— IP ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๊ทธ๋žจ์ด ๋จ.
  4. Link Layerํ”„๋ ˆ์ž„ ํ—ค๋”์™€ ํ”„๋ ˆ์ž„ ํŠธ๋ ˆ์ผ๋Ÿฌ๊ฐ€ ์ถ”๊ฐ€๋จ.
  5. Physical Layer: ๋น„ํŠธ๋กœ ๋ณ€ํ™˜๋˜์–ด ๋ฌผ๋ฆฌ์  ๋งค์ฒด๋ฅผ ํ†ตํ•ด ์ „์†ก๋จ.

 

Decapsulation

์ˆ˜์‹  ์ธก์—์„œ๋Š” ์ด ๊ณผ์ •์„ ์—ญ์ˆœ์œผ๋กœ ์ˆ˜ํ–‰ํ•จ. ๋ฌผ๋ฆฌ ๊ณ„์ธต์—์„œ ๋ฐ›์€ ๋น„ํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ๋งํฌ ๊ณ„์ธต์—์„œ ํ”„๋ ˆ์ž„์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ , ๋„คํŠธ์›Œํฌ ๊ณ„์ธต์—์„œ ๋ฐ์ดํ„ฐ๊ทธ๋žจ์œผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋ชฉ์ ์ง€๊นŒ์ง€ ๋„๋‹ฌํ•จ.

728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

Chapter 1.5 : Performance: loss, delay, throughput

์ธํ„ฐ๋„ท์„ ํ†ตํ•ด ํŒŒ์ผ์„ ์ „์†กํ•˜๊ณ , ์ด๋ฉ”์ผ์„ ๋ณด๋‚ด๊ณ , ์›น์‚ฌ์ดํŠธ์— ์ ‘์†ํ•˜๋Š” ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. ํ•˜์ง€๋งŒ ์‹ค์ œ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์—์„œ๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ์ฆ‰์‹œ ์ „์†ก๋˜๊ฑฐ๋‚˜ ์†์‹ค ์—†์ด ์™„๋ฒฝํ•˜๊ฒŒ ์ „๋‹ฌ๋˜๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

ํŒจํ‚ท ์Šค์œ„์นญ ๋„คํŠธ์›Œํฌ๋Š” ๋ฐ์ดํ„ฐ ์ „์†ก ์†๋„๋ฅผ ์ œํ•œํ•˜๊ณ , ์ง€์—ฐ์„ ์œ ๋ฐœํ•˜๋ฉฐ, ๊ฒฝ์šฐ์— ๋”ฐ๋ผ Packet Loss๊ฐ€ ๋˜๊ธฐ๋„ ํ•œ๋‹ค.

๐ŸŒฑ Packet delay: four sources

1. ์ฒ˜๋ฆฌ ์ง€์—ฐ(Processing Delay) : determine output link

  • - router๊ฐ€ packet์„ ์ˆ˜์‹ ํ•˜๋ฉด ๋จผ์ € packet์˜ header๋ฅผ ํ™•์ธํ•˜๊ณ , ํ•ด๋‹น packet์„ ์–ด๋Š ๊ฒฝ๋กœ๋กœ ๋ณด๋‚ผ์ง€ ๊ฒฐ์ •ํ•œ๋‹ค. (์ด ๋•Œ ์†Œ์š”๋˜๋Š” ์‹œ๊ฐ„์ด ์ฒ˜๋ฆฌ์ง€์—ฐ)
  • ๋ผ์šฐํ„ฐ์˜ ์„ฑ๋Šฅ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง€๋ฉฐ, ์ผ๋ฐ˜์ ์œผ๋กœ ๋งค์šฐ ์งง์€ ์‹œ๊ฐ„์ด ์†Œ์š”๋จ

2. ๋Œ€๊ธฐ ์ง€์—ฐ(Queuing Delay) : ํŒจํ‚ท์„ ์ „์†กํ•˜๊ธฐ ์œ„ํ•ด ๋Œ€๊ธฐํ•˜๋Š” ์‹œ๊ฐ„

  • ํŒจํ‚ท์ด ๋ผ์šฐํ„ฐ์— ๋„์ฐฉํ–ˆ์„ ๋•Œ, ํ•ด๋‹น ํŒจํ‚ท์„ ์ „์†กํ•˜๊ธฐ ์œ„ํ•ด ๋Œ€๊ธฐํ•˜๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•œ๋‹ค.
  • ๋ผ์šฐํ„ฐ๊ฐ€ ๋ฐ”์˜๊ฑฐ๋‚˜, ํŠธ๋ž˜ํ”ฝ์ด ๋งŽ์€ ๊ฒฝ์šฐ ํŒจํ‚ท์€ ์ „์†ก๋˜๊ธฐ ์ „, ๋Œ€๊ธฐ์—ด์—์„œ ๊ธฐ๋‹ค๋ ค์•ผ ํ•œ๋‹ค.
  • ์ด Queuing Delay๋Š” ํŠธ๋ž˜ํ”ฝ์˜ ์–‘์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง€๋ฉฐ, ๋„คํŠธ์›Œํฌ์˜ ํ˜ผ์žก๋„์— ๋”ฐ๋ผ ์ง€์—ฐ ์‹œ๊ฐ„์ด ํฌ๊ฒŒ ์ฆ๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

3. ์ „์†ก ์ง€์—ฐ(Transmission Delay) : ๋ผ์šฐํ„ฐ์—์„œ ๋งํฌ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด ํŒจํ‚ท์˜ ๋ชจ๋“  ๋น„ํŠธ๋ฅผ ‘๋ฐ€์–ด ๋„ฃ๋Š”’๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„

  • L : packet length (bits)
  • R : link transmission rate (bps)
  • Transmission Delay = L/R

4. ์ „ํŒŒ ์ง€์—ฐ(Propagation Delay) : ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌผ๋ฆฌ์  ๋งค์ฒด๋ฅผ ํ†ตํ•ด ์ด๋™ํ•˜๋Š” ๋ฐ ์†Œ์š”๋˜๋Š” ์‹œ๊ฐ„

  • ํŒจํ‚ท์ด ๋งํฌ๋ฅผ ํ†ตํ•ด ๋‹ค์Œ ๋ผ์šฐํ„ฐ๋กœ ์ „ํŒŒ๋˜๋Š” ๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„
  • ๊ฑฐ๋ฆฌ์— ๋น„๋ก€ํ•œ๋‹ค.
  • ๋งค์ฒด์˜ ์ „ํŒŒ ์†๋„์— ๋”ฐ๋ผ ๊ฒฐ์ •๋œ๋‹ค.
  • ์ผ๋ฐ˜์ ์œผ๋กœ ๋น›์˜ ์†๋„์— ๊ฐ€๊น๋‹ค.

 

๐ŸŒฑ Packet queueing delay (revisited)

traffic intensity : ํŒจํ‚ท์ด ๋Œ€๊ธฐ์—ด์—์„œ ๋Œ€๊ธฐํ•˜๋Š” ์‹œ๊ฐ„์— ์˜ํ–ฅ์„ ๋ฏธ์นจ

traffic intensity = La/R (a : ํŒจํ‚ท ๋„์ฐฉ๋ฅ )

  • La/R ≈ 0: ํŒจํ‚ท์ด ๊ฑฐ์˜ ๋Œ€๊ธฐํ•˜์ง€ ์•Š๊ณ  ์ „์†ก๋˜๋ฉฐ, ํ‰๊ท  ์ง€์—ฐ ์‹œ๊ฐ„๋„ ์ž‘์Œ.
  • La/R → 1: ๋Œ€๊ธฐ ์‹œ๊ฐ„์ด ๊ธ‰๊ฒฉํžˆ ์ฆ๊ฐ€ํ•จ.
  • La/R > 1: ํŒจํ‚ท ๋„์ฐฉ๋ฅ ์ด ์ฒ˜๋ฆฌ ๋Šฅ๋ ฅ์„ ์ดˆ๊ณผํ•˜๋ฏ€๋กœ ๋Œ€๊ธฐ ์‹œ๊ฐ„์ด ๋ฌดํ•œ๋Œ€๋กœ ์ฆ๊ฐ€ํ•˜๊ฑฐ๋‚˜ ํŒจํ‚ท์ด ์†์‹ค๋  ์ˆ˜ ์žˆ์Œ.
  • ๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๋Š” traffic intensity๊ฐ€ 1๋ณด๋‹ค ํฌ์ง€ ์•Š๊ฒŒ ์„ค๊ณ„ํ•ด์•ผ ํ•œ๋‹ค.
  • traceroute๋ผ๋Š” ํ”„๋กœ๊ทธ๋žจ์€ delay๋ฅผ ์ธก์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค.

 

๐ŸŒฑ Packet loss

  • queue์˜ ์šฉ๋Ÿ‰์ด ์œ ํ•œํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
  • full queue์— ๋“ค์–ด์˜ค๋ฉด packet์„ dropํ•œ๋‹ค.
  • ๋ฒ„๋ ค์ง„ packet์€ retransmitted ๋œ๋‹ค.

 

๐ŸŒฑ Throughput (์ฒ˜๋ฆฌ๋Ÿ‰)

์ฃผ์–ด์ง„ ์‹œ๊ฐ„ ๋™์•ˆ ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•ด ์ „์†ก๋˜๋Š” ๋ฐ์ดํ„ฐ์˜ ์–‘์„ ์˜๋ฏธํ•œ๋‹ค.

  • ์ฒ˜๋ฆฌ๋Ÿ‰์€ ์—ฌ๋Ÿฌ ์š”์ธ์— ์˜ํ•ด ๊ฒฐ์ •๋˜๋Š”๋ฐ, ํŠนํžˆ ๋„คํŠธ์›Œํฌ ์ƒ์˜ ๊ฐ€์žฅ ๋ณ‘๋ชฉ ๋งํฌ(bottleneck link_๊ฐ€์žฅ ๋Š๋ฆฐ ๊ตฌ๊ฐ„)์— ์˜ํ•ด ์ œํ•œ๋œ๋‹ค.
    • ์ฆ‰, ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋ชจ๋“  ๋งํฌ ์ค‘ ๊ฐ€์žฅ ๋‚ฎ์€ ์ „์†ก์†๋„๋ฅผ ๊ฐ€์ง„ ๋งํฌ๊ฐ€ ์ „์ฒด ์ฒ˜๋ฆฌ๋Ÿ‰์„ ๊ฒฐ์ •ํ•˜๊ฒŒ ๋œ๋‹ค.

์ฒ˜๋ฆฌ๋Ÿ‰ ๊ฒฐ์ •

๊ฐ ์—ฐ๊ฒฐ์˜ ์ฒ˜๋ฆฌ๋Ÿ‰์€ ๋‹ค์Œ ์„ธ ๊ฐ€์ง€ ๊ฐ’ ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’์— ์˜ํ•ด ๊ฒฐ์ •๋œ๋‹ค.

  • Rc : ์ˆ˜์‹ ์ž์˜ ์ˆ˜์‹  ์†๋„
  • Rs : ์†ก์‹ ์ž์˜ ์†ก์‹  ์†๋„
  • R/10 : ๋ฐฑ๋ณธ ๋งํฌ(R)์˜ ๋Œ€์—ญํญ์ด 10๊ฐœ์˜ ์—ฐ๊ฒฐ๋กœ ๊ณตํ‰ํ•˜๊ฒŒ ๋ถ„๋ฐฐ๋˜์—ˆ์„ ๋•Œ ๊ฐ ์—ฐ๊ฒฐ์— ํ• ๋‹น๋˜๋Š” ๋Œ€์—ญํญ์ฒ˜๋ฆฌ๋Ÿ‰์€ min(Rc, Rs, R/10)์œผ๋กœ ๊ฒฐ์ •.
  • ์ฆ‰, ์ด ์„ธ ๊ฐ€์ง€ ๊ฐ’ ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ๊ฒƒ์ด ๊ทธ ์—ฐ๊ฒฐ์˜ ์ฒ˜๋ฆฌ๋Ÿ‰์„ ์ œํ•œํ•จ.
throughput = min ( Rc, Rs, R/10)
728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

Chapter 1.3 : Network core : packet/circuit switching, internet structure

The network core

๋ฐ์ดํ„ฐ๊ฐ€ ๋น ๋ฅด๊ณ  ํšจ์œจ์ ์œผ๋กœ ์ด๋™ํ•˜๋„๋ก ๋•๋Š” ์ค‘์•™ ๋„คํŠธ์›Œํฌ ์ธํ”„๋ผ.
์ฆ‰, ์ธํ„ฐ๋„ท์˜ ๊ณ ์†๋„๋กœ๊ฐ™์€ ์—ญํ• ์„ ํ•œ๋‹ค. ์ธํ„ฐ๋„ท์˜ ์ค‘์‹ฌ์—์„œ packet switching๊ณผ link๋ฅผ ํ†ตํ•ด ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋ฉฐ ์—ฌ๋Ÿฌ ์—ฃ์ง€ ์žฅ์น˜๋“ค์„ ์—ฐ๊ฒฐํ•˜๋Š” ๊ณ ์† ๋ฐ์ดํ„ฐ ๊ฒฝ๋กœ ์—ญํ• ์„ ํ•œ๋‹ค.

Packet Switching

๋ฐ์ดํ„ฐ๋ฅผ ์ž‘์€ ํŒจํ‚ท์œผ๋กœ ๋‚˜๋ˆ„์–ด ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•ด ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

๊ฐ ํŒจํ‚ท์€ ๋…๋ฆฝ์ ์œผ๋กœ ๊ฒฝ๋กœ๋ฅผ ์ฐพ์•„๊ฐ€๋ฉฐ ๋ชฉ์ ์ง€์—์„œ ๋‹ค์‹œ ๊ฒฐํ•ฉ๋˜์–ด ์›๋ž˜์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณต์›ํ•œ๋‹ค.

 

์ž‘๋™ ์›๋ฆฌ

  1. ๋ฐ์ดํ„ฐ ๋ถ„ํ• : ๋ฐ์ดํ„ฐ๊ฐ€ ๊ธด ๋ฉ”์‹œ์ง€์ผ ๊ฒฝ์šฐ, ์ด๋ฅผ ์ž‘์€ ํŒจํ‚ท์œผ๋กœ ๋‚˜๋ˆ”.
  2. ์ „์†ก ๊ณผ์ •: ๊ฐ ํŒจํ‚ท์€ ๋ผ์šฐํ„ฐ์™€ ์Šค์œ„์น˜๋ฅผ ํ†ตํ•ด ์ „์†ก๋˜๋ฉฐ, ๊ฐ ๋งํฌ์—์„œ ์ตœ๋Œ€ ์ „์†ก ์†๋„๋กœ ํŒจํ‚ท์„ ๋ณด๋ƒ„.
  3. ์ €์žฅ ํ›„ ์ „๋‹ฌ (Store-and-Forward)๋ผ์šฐํ„ฐ๋Š” ํŒจํ‚ท์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›๊ธฐ ์ „๊นŒ์ง€ ๋‹ค์Œ ๋งํฌ๋กœ ์ „์†กํ•˜์ง€ ์•Š์Œ.

 

์˜ˆ์‹œ

ํŒจํ‚ท์ด 100 Mbps ์†๋„์˜ ๋งํฌ๋ฅผ ํ†ตํ•ด ์ „์†ก๋˜๋ฉด, **ํŒจํ‚ท ํฌ๊ธฐ(L)**์™€ **์ „์†ก ์†๋„(R = 100 Mbps)**์— ๋”ฐ๋ผ ์ „์†ก ์‹œ๊ฐ„์€ L/R(100 Mbps) ๊ฐ€ ๋จ.

Packet transmission delay = L(bits) / R(bits/sec)

 

Queueing delay, loss

๋ผ์šฐํ„ฐ๊ฐ€ ์—ฌ๋Ÿฌ ๋งํฌ๋ฅผ ๊ด€๋ฆฌํ•  ๋•Œ, ํŒจํ‚ท์€ ์ถœ๋ ฅ ๋ฒ„ํผ์—์„œ ๋Œ€๊ธฐํ•œ๋‹ค.
๋งŒ์•ฝ ๋ผ์šฐํ„ฐ๊ฐ€ ๋‹ค๋ฅธ ํŒจํ‚ท์„ ์ „์†ก ์ค‘์ด๋ผ๋ฉด ์ƒˆ๋กœ์šด ํŒจํ‚ท์€ ๋Œ€๊ธฐํ•ด์•ผ ํ•œ๋‹ค.
์ด ๊ณผ์ •์—์„œ ํ์ž‰ ์ง€์—ฐ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, ๋ฒ„ํผ๊ฐ€ ๊ฐ€๋“ ์ฐจ๋ฉด, ์ถ”๊ฐ€๋กœ ๋“ค์–ด์˜ค๋Š” ํŒจํ‚ท์€ ํŒจํ‚ท ์†์‹ค์ด ๋ฐœ์ƒํ•œ๋‹ค.

Forwarding and Routing

network-core์˜ ์ฃผ์š” ๊ธฐ๋Šฅ์ด๋‹ค.

๋ผ์šฐํ„ฐ๋Š” ํŒจํ‚ท์„ forwarding table์„ ํ†ตํ•ด ์–ด๋–ค ๋งํฌ๋กœ ๋ณด๋‚ผ์ง€ ๊ฒฐ์ •ํ•œ๋‹ค.
ํŒจํ‚ท์˜ ๋ชฉ์ ์ง€ IP ์ฃผ์†Œ๋ฅผ ํ™•์ธํ•˜์—ฌ ํ•ด๋‹นํ•˜๋Š” ๋งํฌ๋กœ ์ „๋‹ฌํ•œ๋‹ค. ์ด๋Ÿฌํ•œ ํ…Œ์ด๋ธ”์€ ๋ผ์šฐํŒ… ํ”„๋กœํ† ์ฝœ์— ์˜ํ•ด ์ž๋™์œผ๋กœ ์„ค์ •๋œ๋‹ค.

Forwarding

  • local action

Routing

  • global action : table์„ ๊ฒฐ์ •ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ชจ๋“  ๊ฑธ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

Forwarding Table

๊ฐ ๋ผ์šฐํ„ฐ๋Š” ๋ชฉ์ ์ง€ ์ฃผ์†Œ ๋˜๋Š” ๋ชฉ์ ์ง€ ์ฃผ์†Œ์˜ ์ผ๋ถ€๋ฅผ ๋ผ์šฐํ„ฐ์˜ ์ถœ๋ ฅ ๋งํฌ๋กœ ๋งคํ•‘ํ•ด์•ผ ํ•˜๋Š” ํฌ์›Œ๋”ฉ ํ…Œ์ด๋ธ”์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

 

๋ผ์šฐํ„ฐ๊ฐ€ ์ˆ˜์‹ ํ•œ ํŒจํ‚ท์„ ์–ด๋Š ๋งํฌ๋กœ ์ „๋‹ฌํ•˜๋Š”์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๊ณผ์ •

  1. ํŒจํ‚ท์ด ๋ผ์šฐํ„ฐ์— ๋„์ฐฉ
  2. ๋ผ์šฐํ„ฐ๋Š” ํŒจํ‚ท์˜ IP ์ฃผ์†Œ๋ฅผ ์กฐ์‚ฌ
  3. ํ•ด๋‹น ๋ชฉ์ ์ง€ ์ฃผ์†Œ๋ฅผ ์ด์šฉํ•ด forwarding table ๊ฒ€์ƒ‰
  4. ๊ทธ ํŒจํ‚ท์„ ์ถœ๋ ฅ ๋งํฌ๋กœ ๋ณด๋ƒ„

 

Packet Switching vs. Circuit Switching

  • ํŒจํ‚ท ์Šค์œ„์นญ: ๋งํฌ ์ž์›์„ ๋™์ ์œผ๋กœ ๊ณต์œ ํ•˜๋ฉฐ, ์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ๋”๋ผ๋„ ๋น„ํ™œ์„ฑ ์‚ฌ์šฉ์ž ์ž์›์„ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ.
    • Circuit ๊ณต์œ ํ•˜๋ฏ€๋กœ ์—ฌ๋Ÿฌ ์‚ฌ๋žŒ์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ํšŒ์„  ์Šค์œ„์นญ: ํ†ต์‹ ์ด ์‹œ์ž‘๋˜๋ฉด ์ผ์ •ํ•œ ์ž์›์„ ๊ณ ์ •์œผ๋กœ ํ• ๋‹นํ•˜์ง€๋งŒ, ์ž์›์ด ๋น„ํ™œ์„ฑ ์ƒํƒœ์ผ ๋•Œ๋„ ์‚ฌ์šฉ ๋ถˆ๊ฐ€ํ•จ.
    • ๊ฐœ์ˆ˜์˜ ์ œํ•œ์ด ์žˆ๊ณ , ๊ทธ๋ž˜์„œ ์‚ฌ์šฉ์ž ์ˆ˜๋„ ์ œํ•œ์ด ์žˆ๋‹ค.
    • shareํ•˜์ง€ ์•Š์•„์„œ ์•ˆ์ •์ ์ด์ง€๋งŒ, ์•ˆ์“ฐ๋Š” ์• ๋“ค์€ ๋†€๊ฒŒ ๋˜๋ฏ€๋กœ ๋น„ํšจ์œจ์ ์ด๋‹ค.
ํŒจํ‚ท ์Šค์œ„์นญ์€ ์‚ฌ์šฉ์ž๋“ค์ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›์ง€ ์•Š๋Š” ๋น„ํ™œ์„ฑ ์‹œ๊ฐ„ ๋™์•ˆ ์ž์›์„ ๋‹ค๋ฅธ ํ™œ์„ฑ ์‚ฌ์šฉ์ž์—๊ฒŒ ์žฌํ• ๋‹นํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ํšŒ์„  ์Šค์œ„์นญ๋ณด๋‹ค ์ž์› ํ™œ์šฉ์ด ํ›จ์”ฌ ๋” ํšจ์œจ์ ์ž„.

 

Circuit Switching : FDM and TDM

  • FDM (Frequency Division Multiplexing)
    • total frequence band๋ฅผ equivalํ•˜๊ฒŒ ๋‚˜๋ˆˆ๋‹ค.
    • ๊ฐ user์—๊ฒŒ allocate ํ•œ๋‹ค.
  • TDM (Time Division Multiplexing)
    • time divided into slots (๊ฐ™์€ ๋‹จ์œ„๋กœ ๋‚˜๋ˆˆ๋‹ค)
    • transmission time์ด FDM๋ณด๋‹ค ์งง๋‹ค.

์ธํ„ฐ๋„ท์˜ ๊ตฌ์กฐ : ๋„คํŠธ์›Œํฌ์˜ ๋„คํŠธ์›Œํฌ

  • ์ธํ„ฐ๋„ท์€ ์ˆ˜๋งŽ์€ ISP(์ธํ„ฐ๋„ท ์„œ๋น„์Šค ์ œ๊ณต์ž)๋“ค์ด ์„œ๋กœ ์—ฐ๊ฒฐ๋œ ๋„คํŠธ์›Œํฌ์˜ ๋„คํŠธ์›Œํฌ์ž„.
  • ๊ฐ ISP๋Š” ๊ณ ๊ฐ-์ œ๊ณต์ž ๊ด€๊ณ„๋ฅผ ํ˜•์„ฑํ•˜๋ฉฐ, ์ƒ์œ„ ๊ณ„์ธต์˜ ISP๋“ค์€ ์„œ๋กœ **ํ”ผ์–ด๋ง(์ง์ ‘ ์—ฐ๊ฒฐ)**ํ•˜์—ฌ ํŠธ๋ž˜ํ”ฝ์„ ๊ตํ™˜ํ•จ.
  • ์ฝ˜ํ…์ธ  ์ œ๊ณต์ž(์˜ˆ: ๊ตฌ๊ธ€)๋Š” ์ž์ฒด ๋„คํŠธ์›Œํฌ๋ฅผ ์šด์˜ํ•ด ์ƒ์œ„ ISP๋ฅผ ๊ฑฐ์น˜์ง€ ์•Š๊ณ  ์ง์ ‘ ์ ‘์†ํ•จ์œผ๋กœ์จ ๋น„์šฉ์„ ์ ˆ๊ฐํ•˜๊ณ  ์„ฑ๋Šฅ์„ ์ตœ์ ํ™”ํ•จ.
728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

1.2 Network edge: hosts, access network, physical media

Network edge

  • hosts : Clients and servers
  • servers often in data centers
  • ์ธํ„ฐ๋„ท ๊ตฌ์„ฑ ์š”์†Œ ์ค‘ ํ•˜๋‚˜์ธ๋ฐ, ์‚ฌ์šฉ์ž๊ฐ€ ์ธํ„ฐ๋„ท์— ์—ฐ๊ฒฐํ•˜๋Š” ๋ถ€๋ถ„์„ ์˜๋ฏธํ•œ๋‹ค.
  • ex) ์Šค๋งˆํŠธํฐ, ์ปดํ“จํ„ฐ, ํƒœ๋ธ”๋ฆฟ ๋“ฑ ์ฃผ๋กœ end system์œผ๋กœ ๋ถˆ๋ฆฐ๋‹ค.

Q. ์–ด๋–ป๊ฒŒ host๊ฐ€ internet์— connection ํ•˜๋Š”๊ฐ€?

  • Wifi, LTE, Desktop, LAN ๊ฐ™์€ ๊ฒƒ๋“ค์„ ์‚ฌ์šฉํ•œ๋‹ค. ์ด๋“ค์€ network๋ฅผ callํ•˜๊ณ , access network๋ฅผ ํ•œ๋‹ค.
  • access network : access network ํ•จ์œผ๋กœ์จ network core์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์ด๋ฅผ ํ†ตํ•ด user can access to the internet

Network core

ISP์— ์˜ํ•ด operate ๋œ๋‹ค. (like KT, LGU+, SK ๋“ฑ)

 

๋ฐ์ดํ„ฐ ์ „์†ก์„ ๋‹ด๋‹นํ•œ๋‹ค.

  • interconnected routers (forward packet to the destination)
  • network of networks
  • internet์˜ ์ค‘์‹ฌ๋ถ€ ์—ญํ• ์„ ํ•œ๋‹ค. ๋ฐ์ดํ„ฐ๋ฅผ ๋น ๋ฅด๊ณ  ํšจ์œจ์ ์œผ๋กœ ์ „๋‹ฌํ•˜๋Š” ๊ฒฝ๋กœ๋ฅผ ์ œ๊ณตํ•จ.

 

์ฃผ์š” access network์˜ ์œ ํ˜•

  1. DSL
    1. ์ „ํ™”์„ ์„ ์ด์šฉํ•ด ์ธํ„ฐ๋„ท์— ์ ‘์†ํ•˜๋Š” ๋ฐฉ์‹
    2. ๊ฐ ๊ฐ€์ •์˜ DSL ๋ชจ๋Ž€์ด ์ „ํ™” ์‹ ํ˜ธ์™€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„๋ฆฌํ•ด ์ธํ„ฐ๋„ท์œผ๋กœ ์ „๋‹ฌํ•จ.
  2. Cable network
    1. Cable ๋ชจ๋Ž€์„ ํ†ตํ•ด ์ธํ„ฐ๋„ท ์ ‘์†์ด ์ด๋ฃจ์–ด์ง
  3. FTTH
    1. ๊ด‘์ผ€์ด๋ธ”์„ ์‚ฌ์šฉํ•ด ๋งค์šฐ ๋น ๋ฅธ ์†๋„๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•จ.
  4. 5G
    1. 5G ๋„คํŠธ์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฌด์„ ์œผ๋กœ ์ฃผ๊ณ  ๋ฐ›๋Š” ๋ฐฉ์‹.
    2. ๊ด‘์ผ€์ด๋ธ” ๋Œ€์‹  ๊ณ ์† ๋ฌด์„  ์‹ ํ˜ธ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•œ๋‹ค.
  5. Ethernet and Wifi
    1. ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ(LAN) ๋ฐฉ์‹์œผ๋กœ, ์ด๋”๋„ท ์ผ€์ด๋ธ”์„ ํ†ตํ•ด ์œ ์„ ์œผ๋กœ ์—ฐ๊ฒฐ๋˜๊ฑฐ๋‚˜ Wifi๋ฅผ ํ†ตํ•ด ๋ฌด์„ ์œผ๋กœ ์—ฐ๊ฒฐ๋œ๋‹ค.

 

Links : physical media

  • How to connect end systems to edge router?
    • residential access ents to connect to internet
    • institutional access networks (school, company)
    • mobile access networks (Wifi, 4G/5G)
  • transmission rate
  • shared or dedicated access among users?
    • type์ธ๋ฐ, shared์ธ์ง€ dedicated์ธ์ง€
๋ฌผ๋ฆฌ์  ๋งค์ฒด๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์†ก์ˆ˜์‹  ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ์œ ๋„ ๋งค์ฒด(Guided Media)์™€ ๋น„์œ ๋„ ๋งค์ฒด(Unguided Media)๋กœ ๊ตฌ๋ถ„๋œ๋‹ค.

 

์œ ๋„ ๋งค์ฒด (guided media- wired)

๐Ÿ‘‰๐Ÿป ๊ผฌ์ž„์„  (Twisted Pair Copper Wire)

์ „ํ™” ๋ฐ LAN ์—ฐ๊ฒฐ์— ์ฃผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค. ์ €๋ ดํ•˜๊ณ  ๋ณดํŽธ์ ์œผ๋กœ ์‚ฌ์šฉ ๋˜๋Š” ๋งค์ฒด์ด๋ฉฐ, ๊ฐ€์ •์šฉ ์ธํ„ฐ๋„ท ์ ‘์†๊ณผ ํšŒ์‚ฌ ๋‚ด๋ถ€ ๋„คํŠธ์›Œํฌ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.

๐Ÿ‘‰๐Ÿป ๋™์ถ• ์ผ€์ด๋ธ” (Coaxial Cable)

์ผ€์ด๋ธ” TV ๋ฐ ์ธํ„ฐ๋„ท ๋„คํŠธ์›Œํฌ์—์„œ ์‚ฌ์šฉ๋œ๋‹ค. ๋†’์€ ๋ฐ์ดํ„ฐ ์ „์†ก๋ฅ ์„ ์ œ๊ณตํ•œ๋‹ค.

๐Ÿ‘‰๐Ÿป ๊ด‘์„ฌ์œ  (Fiber Optics)

๋น›์„ ์‚ฌ์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ์žฅ๊ฑฐ๋ฆฌ ์ „์†ก์— ์ฃผ๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ, ๋ฐ์ดํ„ฐ ์ „์†ก ์†๋„๊ฐ€ ๋งค์šฐ ๋น ๋ฅด๋‹ค.

 

๋น„์œ ๋„ ๋งค์ฒด (unguided media - wireless)

๐Ÿ‘‰๐Ÿป ๋ฌด์„  ์ „ํŒŒ (Terrestrial Radio Channels)

Wifi, ๋ชจ๋ฐ”์ผ ๋„คํŠธ์›Œํฌ์™€ ๊ฐ™์€ ๋ฌด์„  ํ†ต์‹ ์—์„œ ์‚ฌ์šฉ๋œ๋‹ค. ๋ฌผ๋ฆฌ์ ์ธ ์ผ€์ด๋ธ” ์—†์ด ์ „ํŒŒ๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•œ๋‹ค.

๐Ÿ‘‰๐Ÿป ์œ„์„ฑ (Satellite Channels)

์ง€๊ตฌ ๊ถค๋„์˜ ์œ„์„ฑ์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์›๊ฑฐ๋ฆฌ ์ง€์—ญ์—์„œ์˜ ์ธํ„ฐ๋„ท ์ ‘์†์— ์ฃผ๋กœ ์‚ฌ์šฉ๋œ๋‹ค.

 

๐Ÿ”— Access networks : cable-based access

์„œ๋กœ ๊ณต์œ (shared)ํ•˜๋ฏ€๋กœ, ์‚ฌ์šฉ์ž๊ฐ€ ๋งŽ์œผ๋ฉด ์•„์ฃผ ์†๋„๊ฐ€ ๋Š๋ ค์งˆ ์ˆ˜ ์žˆ๋‹ค.
  • ๋™์ถ•(coasial) cable๋กœ, wireless๋ณด๋‹ค stableํ•˜๋‹ค.
  • FDM (frequency division multiplexing) : different channels transmitted in different frequency bands
    • down stream, upstream channel ๋ชจ๋‘ ๊ณต์œ ๊ฐ€ ๋˜๊ธฐ ๋•Œ๋ฌธ์— FDM ํ”„๋กœํ† ์ฝœ์€ ์ „์†ก์„ ์กฐ์ •ํ•˜๊ณ  ์ถฉ๋Œ์„ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•˜๋‹ค.
  • splitter : it can transfer internet data packet to the cable modem.
    • cable modem converts the analog → digital
  • CMTS : Cable Modem Termination System
    • ๋งŽ์€ ๋‹ค์šด์ŠคํŠธ๋ฆผ ๊ฐ€์ •์— ์žˆ๋Š” ์ผ€์ด๋ธ” ๋ชจ๋Ž€์œผ๋กœ๋ถ€ํ„ฐ ์†ก์‹ ๋œ ์•„๋‚ ๋กœ๊ทธ ์‹ ํ˜ธ๋ฅผ ๋‹ค์‹œ ๋””์ง€ํ„ธ ํฌ๋งท์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์—ญํ• 
    • ์ฆ‰, DSL ๋„คํŠธ์›Œํฌ์˜ DSLAM๊ณผ ์œ ์‚ฌํ•œ ๊ธฐ๋Šฅ์„ ํ•จ
  • HFC : hybrid fiber coax
    • asymmetric (๋น„๋Œ€์นญ) : downstream์ด upstream๋ณด๋‹ค ํ›จ์”ฌ BPS๊ฐ€ ํฌ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ internet์—์„œ ๋ญ”๊ฐ€๋ฅผ download ๋ฐ›์„ ๋•Œ, ๋งŽ์€ ์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

๐Ÿ”— Access networks : digital subscriber line (DSL)

dedicated line์œผ๋กœ, ๋‹ค๋ฅธ ๊ฒƒ๋“ค๊ณผ sharedํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • DSLAM (Digital Subscriber Line Access Multiplexer)
    • ์ˆ˜๋ฐฑ-์ˆ˜์ฒœ๊ฐœ์˜ ๊ฐ€์ •๋“ค์ด DSLAM์— ์—ฐ๊ฒฐ๋œ๋‹ค.
      1. data์™€ ์ „ํ™” ์‹ ํ˜ธ๋ฅผ ๋ถ„๋ฆฌ
      2. data๋ฅผ ์ธํ„ฐ๋„ท์œผ๋กœ ์†ก์‹ 
  • Splitter
    • ๊ฐ€์ •์ชฝ์— ์กด์žฌํ•œ๋‹ค.
      • ๊ฐ€์ •์— ๋„์ฐฉํ•˜๋ฉด ๋ฐ์ดํ„ฐ์™€ ์ „ํ™” ์‹ ํ˜ธ๋ฅผ ๋ถ„๋ฆฌํ•œ๋‹ค.
      • data ์‹ ํ˜ธ๋ฅผ DSL๋ชจ๋Ž€์œผ๋กœ ์ „์†กํ•œ๋‹ค.
  • DSL vs DSLAM
    • DSL ๋ชจ๋Ž€์€ ์‚ฌ์šฉ์ž ์ง‘์—์„œ ์ธํ„ฐ๋„ท์— ์—ฐ๊ฒฐ๋˜๋Š” ๋ฌธ์ด๊ณ , DSLAM์€ ์ด ๋ฌธ๋“ค์„ ๋ชจ์•„์„œ ์ค‘์•™ ๋„คํŠธ์›Œํฌ๋กœ ์—ฐ๊ฒฐํ•˜๋Š” ๋Œ€ํ˜• ๋ถ„๊ธฐ์ 

๐Ÿ”— Access networks : fiber to the home (FTTH)

  1. ๊ฐ ๊ฐ€์ •์€ ONT(Optical Network Terminator)์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, ์ด๋Š” ์ง€์ •๋œ ๊ด‘์„ฌ์œ ๋กœ ์ด์›ƒ splitter์— ์—ฐ๊ฒฐ๋œ๋‹ค.
  2. Splitter(Optical splitter)๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ •์„ ํ•˜๋‚˜์˜ ๊ณต์œ  ๊ด‘์„ฌ์œ ๋กœ ๊ฒฐํ•ฉ, ์ด๋ฅผ ํ…”์ฝ”์˜ Central Office์— ์žˆ๋Š” OLT(Optimal Line Terminal)์— ์—ฐ๊ฒฐํ•œ๋‹ค.
  3. OLT๋Š” ๊ด‘์‹ ํ˜ธ์™€ ์ „๊ธฐ์‹ ํ˜ธ ๊ฐ„์˜ ๋ณ€ํ™˜์„ ์ œ๊ณต, ์ด๋Š” ํ…”์ฝ” ๋ผ์šฐํ„ฐ๋ฅผ ํ†ตํ•ด ์ธํ„ฐ๋„ท์— ์—ฐ๊ฒฐ๋œ๋‹ค.

๐Ÿ”— Access networks : home networks

  1. we have to subscribe telecommunication operation like KT, LGU+
  2. From the telecommunication operator to home, we can install the various access of internet like DSL, FTTH
  3. From the modem at our home, we can construct the various home networks

๐Ÿ”— Access networks : wireless access networks

Shared wireless access network connects end system to router

Wireless local area networks(WLANS)

  • ๊ฐ€๋Šฅํ•œ distance๊ฐ€ ์ œํ•œ๋ผ ์žˆ๋‹ค.
  • IEEE 802.11 b/g/n/ac/ax (Wifi)

Wide-area cellular access networks

  • local area network๋ณด๋‹ค coverage๊ฐ€ ํ›จ์”ฌ ๋„“๋‹ค.

Wireless local area vs. Wide-area

Mobility : cellular๋Š” mobility๋ฅผ ํ—ˆ์šฉํ•œ๋‹ค.

 

๐Ÿ”— Access networks : enterprise networks

๋Œ€๊ทœ๋ชจ ์กฐ์ง์—์„œ ๋‹ค์–‘ํ•œ ๋ถ€์„œ, ์œ„์น˜๋ฅผ ์—ฐ๊ฒฐํ•˜์—ฌ ๋ฐ์ดํ„ฐ์™€ ๋ฆฌ์†Œ์Šค๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ๊ณต์œ , ๊ด€๋ฆฌํ•œ๋‹ค.

  • mix of wired, wireless

 

์ฃผ์š” ๊ฐœ๋…

  • ์ธํ„ฐ๋„ท์€ ์ˆ˜์‹ญ์–ต ๋Œ€์˜ ๋””๋ฐ”์ด์Šค๊ฐ€ ์—ฐ๊ฒฐ๋œ ๋„คํŠธ์›Œํฌ๋กœ, ๋ฐ์ดํ„ฐ๋ฅผ ํŒจํ‚ท ๋‹จ์œ„๋กœ ๋‚˜๋ˆ„์–ด ์ „์†กํ•จ.
  • ๋ผ์šฐํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ์ค‘์š”ํ•œ ์žฅ์น˜. ๋ฐ์ดํ„ฐ๊ฐ€ ์–ด๋””๋กœ ๊ฐ€์•ผ ํ•˜๋Š”์ง€๋ฅผ ๊ฒฐ์ •.
  • ํŒจํ‚ท ์Šค์œ„์นญ์€ ๋ฐ์ดํ„ฐ๋ฅผ ์ž‘์€ ํŒจํ‚ท์œผ๋กœ ๋‚˜๋ˆ„์–ด ๋…๋ฆฝ์ ์œผ๋กœ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์ด๋ฉฐ, ๋„คํŠธ์›Œํฌ์˜ ํšจ์œจ์„ฑ์„ ๋†’์ž„.
  • ํ”„๋กœํ† ์ฝœ์€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›์„ ๋•Œ์˜ ๊ทœ์น™๊ณผ ํ–‰๋™์„ ์ •์˜ํ•˜๋ฉฐ, ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์˜ ํ•ต์‹ฌ์ž„.
728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

1.1 What is the Internet? What is a protocol?

Internet ๊ตฌ์„ฑ ์š”์†Œ

์ธํ„ฐ๋„ท์€ ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ๋กœ, ๊ฐ€์ • ๋„คํŠธ์›Œํฌ, ํšŒ์‚ฌ ๋„คํŠธ์›Œํฌ, ๋ชจ๋ฐ”์ผ ๋„คํŠธ์›Œํฌ ๋“ฑ์„ ํฌํ•จํ•œ ๋‹ค์–‘ํ•œ ๋„คํŠธ์›Œํฌ๋“ค์ด ์„œ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋‹ค. ์ด ๋„คํŠธ์›Œํฌ๋“ค์€ ISP(Internet Service Provider)๋ฅผ ํ†ตํ•ด ์„œ๋กœ ์—ฐ๊ฒฐ๋˜๊ณ , ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š”๋‹ค.

(์ด๋Ÿฐ ISP๋“ค์„ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ๊ฒƒ์„ IXP๋ผ๊ณ  ํ•œ๋‹ค.)

 

์ธํ„ฐ๋„ท์„ ๋ณด๋Š” ๊ด€์ ์€ ํฌ๊ฒŒ ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

1. nuts and bolts view

2. service view

 

1๏ธโƒฃ nuts and bolts view

์ „ ์„ธ๊ณ„์ ์œผ๋กœ ์ˆ˜์‹ญ์–ต ๊ฐœ์˜ ์ปดํ“จํŒ… ์žฅ์น˜๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ

Internet have various component. Host, Packet switches, communication links. They make networks and ISP connects the network. To run the internet, we need some communication rules, that is protocol

host = end system

  • ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ์— ์—ฐ๊ฒฐ๋œ ์ปดํ“จํŒ… ์žฅ์น˜
  • ์„œ๋ฒ„, ์ธํ„ฐ๋„ท์— ์—ฐ๊ฒฐ๋œ ๋ชจ๋“  ์ธํ„ฐ๋„ท ‘์‚ฌ๋ฌผ๋“ค’
  • Internet์˜ edge์—์„œ network app์„ ์‹คํ–‰ํ•œ๋‹ค.
  • communication link์™€ packet switch์˜ ๋„คํŠธ์›Œํฌ๋กœ ์—ฐ๊ฒฐ๋œ๋‹ค.

communication link

  • ๋‹ค์–‘ํ•œ ์ „์†ก๋ฅ (transmission rate)๋ฅผ ์ด์šฉํ•ด packet์„ ์ „์†กํ•œ๋‹ค.
  • transmission ๋‹จ์œ„ : bps (bits per second, ์ดˆ๋‹น ๋น„ํŠธ ์ˆ˜)
  • ๋™์ถ• ์ผ€์ด๋ธ”, ๊ตฌ๋ฆฌ์„ , ๊ด‘์ผ€์ด๋ธ”, ๋ผ๋””์˜ค ์ŠคํŽ™ํŠธ๋Ÿผ์„ ํฌํ•จํ•œ ๋‹ค์–‘ํ•œ ๋ฌผ๋ฆฌ ๋งค์ฒด๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

Packet

  • ์†ก์‹  ์ข…๋‹จ ์‹œ์Šคํ…œ์—์„œ ์ˆ˜์‹  ์ข…๋‹จ ์‹œ์Šคํ…œ์œผ๋กœ ๋ณด๋‚ด์ง„๋‹ค.
  • ์†ก์‹  ์ข…๋‹จ ์‹œ์Šคํ…œ์ด ๋ณด๋‚ด๊ณ ์ž ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ segment๋กœ ๋‚˜๋ˆ„๊ณ , ๊ฐ segment์— header๋ฅผ ๋ถ€์ฐฉํ•ด ์ˆ˜์‹  ์ข…๋‹จ ์‹œ์Šคํ…œ์œผ๋กœ ์ „์†กํ•œ๋‹ค.
  • ํŒจํ‚ท์€ ๋ชฉ์ ์ง€์—์„œ ์›๋ž˜์˜ ๋ฐ์ดํŠธ๋กœ ๋‹ค์‹œ ์กฐ๋ฆฝ๋œ๋‹ค.

Packet switch

๋ชฉ์  : ๋ฐ์ดํ„ฐ์˜ ๋น ๋ฅธ ์ „์†ก

  • ์ž…๋ ฅ ํ†ต์‹  ๋งํฌ ์ค‘ ํ•˜๋‚˜
  • ๋„์ฐฉํ•˜๋Š” ํŒจํ‚ท์„ ๋ฐ›์•„์„œ ์ถœ๋ ฅ ํ†ต์‹  ๋งํฌ์˜ ํ•˜๋‚˜๋กœ ๊ทธ ํŒจํ‚ท์„ ์ „๋‹ฌํ•œ๋‹ค.
    • ์ตœ์ข… ๋ชฉ์ ์ง€ ๋ฐฉํ–ฅ์œผ๋กœ ํŒจํ‚ท์„ ์ „๋‹ฌ
  • ๋Œ€ํ‘œ์ ์ธ ๋‘ ์ข…๋ฅ˜
    • link-layer switch : ๋ณดํ†ต ์ ‘์† ๋„คํŠธ์›Œํฌ์—์„œ ์‚ฌ์šฉ
    • router : ๋ณดํ†ต ๋„คํŠธ์›Œํฌ ์ฝ”์–ด์—์„œ ์‚ฌ์šฉ

 

Protocols

  • machines ์‚ฌ์ด์—์„œ communication ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•จ.
  • ์ด ํ”„๋กœํ† ์ฝœ์„ ๋”ฐ๋ฅด์ง€ ์•Š์œผ๋ฉด ์šฐ๋ฆฌ๋Š” Communication ํ•  ์ˆ˜ ์—†๋‹ค.
  • ๊ฐ€์žฅ ์ค‘์š”ํ•œ ํ”„๋กœํ† ์ฝœ ๋‘˜์„ ํ†ต์นญํ•˜์—ฌ TCP/IP๋ผ๊ณ  ํ•œ๋‹ค.
    • TCP : Transmission Control Protocol
    • IP : Internet Protocol
      • ๋ผ์šฐํ„ฐ์™€ ์ข…๋‹จ ์‹œ์Šคํ…œ ์‚ฌ์ด์—์„œ ์†ก์ˆ˜์‹  ๋˜๋Š” ํŒจํ‚ท ํฌ๋งท์„ ๊ธฐ์ˆ ํ•œ๋‹ค.
  • ํ‘œ์ค€ (Standards)
    • IETF (Internet Engineering Task Force)
      • ๊ตญ์ œ ์ธํ„ฐ๋„ท ํ‘œ์ค€ํ™” ๊ธฐ๊ตฌ
      • RFC (Requests for Comment) : IETF ํ‘œ์ค€ ๋ฌธ์„œ (์ œ๊ณต๋˜๋Š” docment๋ฅผ RFC๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค.
      • TCP, IP, HTTP, SMTP ๊ฐ™์€ ํ”„๋กœํ† ์ฝœ์„ ์ •์˜
  • 3๊ฐœ์˜ factors๋ฅผ ๊ฐ€์ง„๋‹ค.
    • format
    • order
    • actions
  • ๋ฉ”์‹œ์ง€์˜ format, order๋ฅผ ์ •์˜ํ•˜๊ณ  transmissionํ•˜๋Š” action์„ ์ˆ˜ํ–‰ํ•จ.
  • ์–ด๋–ป๊ฒŒ ์ผ ํ•˜๋ƒ๋ฉด,
    1. ๋จผ์ € TCP connection์„ ํ•œ๋‹ค (transfer the request message)
    2. ์„œ๋ฒ„๋Š” request๋ฅผ ๋ฐ›์œผ๋ฉด ์ด๋ฅผ ๋ฐ›์•„๋“ค์ผ์ง€ ๋ง์ง€๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.
    3. transmit some response to the client
      1. action when the server receive the request messages from the client
    4. TCP connection์ด established ๋˜๋ฉด, client can transmit this message

ISP (Internet Service Provider)

  • ํŒจํ‚ท ์Šค์œ„์น˜์™€ ํ†ต์‹  ๋งํฌ๋กœ ์ด๋ฃจ์–ด์ง„ ๋„คํŠธ์›Œํฌ
    • ์ด ISP๋ฅผ ํ†ตํ•ด network๊ฐ€ ์—ฐ๊ฒฐ๋  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด๋‹ค.
  • end system์—๊ฒŒ ๋‹ค์–‘ํ•œ ๋„คํŠธ์›Œํฌ ์ ‘์†์„ ์ œ๊ณตํ•œ๋‹ค.
  • CP(content provider)์—๊ฒŒ ์ธํ„ฐ๋„ท ์ ‘์†์„ ์ œ๊ณตํ•œ๋‹ค.
    • ์›น ์‚ฌ์ดํŠธ๋‚˜ ๋น„๋””์˜ค ์„œ๋ฒ„๋ฅผ ์ธํ„ฐ๋„ท์— ์ง์ ‘ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.
  • ISP๋“ค์˜ ์ƒํ˜ธ ์—ฐ๊ฒฐ
    • ์ธํ„ฐ๋„ท์€ ์ข…๋‹จ ์‹œ์Šคํ…œ์„ ์„œ๋กœ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒƒ์ด๋ฏ€๋กœ ์ข…๋‹จ ์‹œ์Šคํ…œ์— ์ ‘์†์„ ์ œ๊ณตํ•˜๋Š” ISP๋“ค๋„ ์„œ๋กœ ์—ฐ๊ฒฐ๋˜์–ด์•ผ๋งŒ ํ•œ๋‹ค.

 

2๏ธโƒฃ Service view

Function1 : Infrastructure

  • internet์ด ์šฐ๋ฆฌ์˜ request๋ฅผ transfer ํ•ด์ค€๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์šฐ๋ฆฌ๋Š” response๋ฅผ ๋ฐ›๋Š”๋‹ค.
  • request์™€ response๊ฐ€ Infrastructure์„ ํ†ตํ•ด ์ด๋ฃจ์–ด์ง„๋‹ค.

Function2: Programming interface

  • Infrastructure๋ฅผ ์“ฐ๊ธฐ ์œ„ํ•ด์„œ๋Š” we need to write something.
  • ์†ก์žฅ ๊ฐ™์€ ์—ญํ• ์„ ํ•œ๋‹ค.
    • ์šฐ๋ฆฌ๋Š” infrastructure๋ฅผ ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š์•„๋„ ๋œ๋‹ค. ๊ทธ์ € interface๋งŒ ์‹ ๊ฒฝ์“ฐ๋ฉด ๋œ๋‹ค.
  • hooks allowing sending/receiving apps to “connect” to, use Internet transport service.
    • ์•ฑ๋“ค์ด ์ธํ„ฐ๋„ท์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์—ฐ๊ฒฐํ•˜๋Š” ์ง€์ 
  • provides service options, analogous to postal service
    • ์šฐํŽธ์˜ ์†ก์žฅ ๊ฐ™์€ ์—ญํ• ์ด๋ผ๋Š” ๊ฒƒ.

 

 

์ฐธ๊ณ  ์ž๋ฃŒ : https://github.com/IT-Book-Organization/Computer-Networking_A-Top-Down-Approach/tree/main/Chapter_1/1.1%20%EC%9D%B8%ED%84%B0%EB%84%B7%EC%9D%B4%EB%9E%80%20%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80%3F

 

728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•
๋ฐ˜์‘ํ˜•

๋‹ค๋ฅธ ๋ธ”๋กœ๊ทธ๋“ค ๋ณด๋ฉด ์ง์ ‘ ๊ณต์‹๋ฌธ์„œ ๋ณด๋ฉด์„œ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•˜์‹œ๋˜๋ฐ,, ๋‚˜๋„ ๊ทธ๋ ‡๊ฒŒ ํ•˜๊ณ  ์‹ถ์€๋ฐ..

์‹œ๊ฐ„์ด ์ƒ๋‹นํžˆ ๋งŽ์ด ๊ฑธ๋ฆฌ๊ฒ ์ง€๋งŒ, ๋„์ „..ํ•ด๋ด์•ผ์ง€..

 

์ด์ „์— ์• ํ”Œ๋กœ๊ทธ์ธ์„ ๊ตฌํ˜„ํ•  ๋•Œ๋Š” ๊ทธ๋ƒฅ ๋ธ”๋กœ๊ทธ๋“ค ์ฐธ๊ณ ํ•ด์„œ ์ฝ”๋“œ๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , ๊ฐ€์ ธ์˜จ ์ฝ”๋“œ๋งŒ ๊ณต๋ถ€ํ•ด์„œ ๊ตฌํ˜„ํ–ˆ์—ˆ๋Š”๋ฐ

์‹œ๊ฐ„๋„ ์žˆ๊ฒ ๋‹ค, ์˜์š•๋„ ์žˆ๊ฒ ๋‹ค ํ•œ ๋ฒˆ ํ•ด๋ด์•ผ๊ฒ ๋‹ค.

 

๊ทธ๋‚˜์ €๋‚˜ ํ•œ๊ธ€ ๊ณต์‹๋ฌธ์„œ๋„ ์žˆ์œผ๋ฉด ๋„ˆ๋ฌด ์ข‹๊ฒ ๋‹ค.

ํ•œ๊ธ€ ๊ณต์‹๋ฌธ์„œ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๊ฒƒ๋ณด๋‹ค ๋‚ด๊ฐ€ ์˜์–ด๋ฅผ ๋” ๊ณต๋ถ€ํ•ด์„œ ์ž˜ํ•˜๋Š”๊ฒŒ ๋น ๋ฅด๋ ค๋‚˜..?

 

 

์ผ๋‹จ ํ•ด๋ณด์ž๊ตฌ..

์•„๋ž˜ ๊ณต์‹๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๊ตฌํ˜„ํ•œ ์• ํ”Œ๋กœ๊ทธ์ธ์ด๋‹ค !

 

https://developer.apple.com/documentation/sign_in_with_apple/implementing_user_authentication_with_sign_in_with_apple

 

Implementing User Authentication with Sign in with Apple | Apple Developer Documentation

Provide a way for users of your app to set up an account and start using your services.

developer.apple.com

 

 

1. Sign in with Apple ์ถ”๊ฐ€ํ•˜๊ธฐ ๋ฐ Identifier ๋“ฑ๋กํ•˜๊ธฐ

Targets → Signing & Capabilities → +Capability ๋ฅผ ๋ˆŒ๋Ÿฌ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

 

(์ด ๋•Œ, Apple developer ๊ตฌ๋…์„ ํ•˜์ง€ ์•Š๋Š” ๊ฐœ๋ฐœ์ž๋ผ๋ฉด, ํ•ด๋‹น ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์—†๋‹ค..ใ… ใ… )

 

๋‹ค์Œ์€ ์• ํ”Œ ๊ฐœ๋ฐœ์ž ์‚ฌ์ดํŠธ์—์„œ identifier๋ฅผ ๋“ฑ๋กํ•ด์ค˜์•ผ ํ•œ๋‹ค.

๊ฐœ๋ฐœ์ž ์‚ฌ์ดํŠธ์— ๋กœ๊ทธ์ธ์„ ํ•˜๊ณ , Account ํ•ญ๋ชฉ์—์„œ, Identifiers๋ฅผ ๋ˆŒ๋Ÿฌ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํŽ˜์ด์ง€์— ๋“ค์–ด๊ฐ„๋‹ค.

 

๋งŒ์•ฝ, ์ด ๊ณผ์ •์„ ์ง„ํ–‰ํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด.. ๋กœ๊ทธ์ธ์ด ๋˜์ง€ ์•Š๊ณ , ์ฝ˜์†”์— ์ถœ๋ ฅํ•ด๋„ ์ž๊พธ null ๊ฐ’์ด ๋‚˜์˜ค๊ฒŒ ๋  ๊ฒƒ์ด๋‹ค.

(์ €๋„ ์•Œ๊ณ ์‹ถ์ง€ ์•Š์•˜์–ด์š”..)

 

ํŒŒ๋ž€์ƒ‰ + ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ค€๋‹ค.

 

๊ทธ๋Ÿผ ์ด๋Ÿฐ ์ฐฝ์ด ๋œจ๊ฒŒ ๋˜๋Š”๋ฐ, App ID์™€ ๊ด€๋ จํ•œ ๋‚ด์šฉ์ด๋ฏ€๋กœ ์ด ์ƒํƒœ์—์„œ continue๋ฅผ ํ•ด์ค€๋‹ค.

 

์—ฌ๊ธฐ์„œ๋„ ๊ณ„์† continue๋ฅผ ํ•ด์ค€๋‹ค.

 

 

๊ทธ๋Ÿผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™”๋ฉด์ด ๋ณด์ธ๋‹ค.

 

Description: ํŠน์ˆ˜๋ฌธ์ž๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๊ณ , Identifier์— ๋Œ€ํ•œ ๊ฐ„๋‹จํ•œ ์„ค๋ช…์„ ์ ์œผ๋ฉด ๋œ๋‹ค.

Bundle ID: App์˜ TARGETS → Signing & Capabilities์—์„œ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

๋‚ด์šฉ์„ ์ฑ„์šฐ๊ณ , Sign In with Apple์„ ์ฐพ์•„ ์ฒดํฌํ•ด์ค€๋‹ค.

๊ทธ๋ฆฌ๊ณ , Edit์„ ๋ˆŒ๋Ÿฌ ์ง€๊ธˆ ์ง„ํ–‰์ค‘์ธ ํ”„๋กœ์ ํŠธ์˜ app id๋ฅผ ์„ ํƒํ•ด์ฃผ์—ˆ๋‹ค.

 

์ด๋Œ€๋กœ next๋ฅผ ๋ˆ„๋ฅด๊ณ , register๊นŒ์ง€ ํ–ˆ๋Š”๋ฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํŒ์—…์ด ๋ฐœ์ƒํ–ˆ๋‹ค.

 

์ฐพ์•„๋ณด๋‹ˆ, ์ด ์—๋Ÿฌ๋Š” Bundle ID ์•ž์— ํŒ€ ID(Apple์—์„œ ์ƒ์„ฑ๋œ)๋ฅผ ํฌํ•จํ•˜์ง€ ์•Š์„ ๋•Œ ์ƒ๊ธด๋‹ค๊ณ  ํ•œ๋‹ค.

๊ทธ๋ƒฅ ์ €๊ธฐ ์žˆ๋Š” ์ฃผํ™ฉ์ƒ‰ ๋ถ€๋ถ„์„ ๋ฒˆ๋“ค์•„์ด๋”” ๊ฐ€์žฅ ์•ž์— ๋ถ™์—ฌ๋„ฃ๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.

 

 

ํ›„ ์ด์ œ ์„ธํŒ…๋“ค์€ ๋ชจ๋‘ ๋๋‚ฌ๋‹ค !!

์• ํ”Œ๋กœ๊ทธ์ธ์„ ๊ตฌํ˜„ํ•  ์ฝ”๋“œ๋งŒ ์งœ๋ฉด ๋œ๋‹ค.

 

๊ณต์‹ ๋ฌธ์„œ์—์„œ ์ œ๊ณตํ•œ ์˜ˆ์ œ ์ฝ”๋“œ๋Š” ์Šคํ† ๋ฆฌ๋ณด๋“œ ๊ธฐ๋ฐ˜์ด์—ˆ๊ธฐ์— ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜๋Š” ์—†์—ˆ๋‹ค.

๋‚˜๋Š” UIKit์„ ์‚ฌ์šฉํ•˜๋˜, ์Šคํ† ๋ฆฌ๋ณด๋“œ๊ฐ€ ์•„๋‹Œ ์ฝ”๋“œ๋กœ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•˜๋Š”์ง€ ํ•ด๋ณด๊ฒ ๋‹ค !

 

 

 

2. AuthenticationServices import ํ•˜๊ธฐ

๋จผ์ € ์• ํ”Œ๋กœ๊ทธ์ธ ๊ตฌํ˜„์ด ํ•„์š”ํ•œ AuthenticationServices๋ฅผ ํŒŒ์ผ์— import ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

import AuthenticationServices

 

 

 

3. ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ

func setupAppleLoginButton() {
    // ASAuthorizationAppleIDButton์„ ์‚ฌ์šฉํ•ด ์• ํ”Œ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ์ƒ์„ฑ
    let appleLoginButton = ASAuthorizationAppleIDButton(type: .signIn, style: .whiteOutline)
    appleLoginButton.translatesAutoresizingMaskIntoConstraints = false
    appleLoginButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside)

    // ๋ฒ„ํŠผ์„ ํ™”๋ฉด์— ์ถ”๊ฐ€
    self.view.addSubview(appleLoginButton)

    // ์˜คํ† ๋ ˆ์ด์•„์›ƒ ์„ค์ •
    NSLayoutConstraint.activate([
        appleLoginButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
        appleLoginButton.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
        appleLoginButton.heightAnchor.constraint(equalToConstant: 50),
        appleLoginButton.widthAnchor.constraint(equalToConstant: 300)
    ])
}

 

์ด๋ ‡๊ฒŒ ์˜คํ† ๋ ˆ์ด์•„์›ƒ์œผ๋กœ ๋ฒ„ํŠผ์˜ ํฌ๊ธฐ์™€ ์œ„์น˜๋ฅผ ์žก์•„์ฃผ์—ˆ๋‹ค.

์• ํ”Œ์€ ์• ํ”Œ๋กœ๊ทธ์ธ API๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•Œ์•„์„œ ๋ฒ„ํŠผ์„ ๋””์ž์ธํ•ด์ฃผ๊ณ , default๋กœ ๋””์ž์ธ๋˜์–ด ์žˆ๋Š” ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์ƒ‰์ƒ, ๋””์ž์ธ์ด ์ด๋ฏธ ์ง€์ •๋˜์–ด ์žˆ์–ด ์ƒํ™ฉ์— ๋งž๊ฒŒ ์ ์ ˆํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜๋ผ๊ณ  HIG์—๋„ ๊ฐ€์ด๋“œ๋ผ์ธ์„ ์ œ์‹œํ•œ๋‹ค.

 

๋‚˜๋Š” ์ผ๋‹จ SignIn ํƒ€์ž…์œผ๋กœ ์•„์›ƒ๋ผ์ธ์ด ํฐ์ƒ‰์ธ ๋ฒ„ํŠผ์„ ๋งŒ๋“ค์—ˆ๋‹ค. 

ASAuthorizationAppleIDButton์ด๋ผ๋Š” ํ•จ์ˆ˜๋งŒ ๊ฐ€์ ธ์˜ค๋ฉด ๋ฐ”๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค !!

 

์ด์ œ ๋ฒ„ํŠผ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ, ํ˜ธ์ถœํ•  ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์ค˜์•ผํ•œ๋‹ค.

 

 

 

 

3. ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์• ํ”Œ๋กœ๊ทธ์ธ ๊ตฌํ˜„ํ•˜๊ธฐ

๋‚˜๋Š” ์ผ๋‹จ ๊ณต์‹๋ฌธ์„œ์— ์žˆ๋Š” handleAuthorizationAppleIDButtonPress ํ•จ์ˆ˜๋ฅผ ๊ทธ๋Œ€๋กœ ์—ฐ๊ฒฐํ•ด์ฃผ์—ˆ๋‹ค.

// apple id๋กœ ๊ถŒํ•œ ์š”์ฒญํ•˜๊ธฐ ์œ„ํ•œ ํ•จ์ˆ˜
@objc func handleAuthorizationAppleIDButtonPress() {
    // ์• ํ”Œ ID Provider ์ƒ์„ฑ (์• ํ”Œ๋กœ๊ทธ์ธ ์š”์ฒญ์„ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ASAuthorizationAppleIDProvider๊ฐ์ฒด์ž„)
    let appleIDProvider = ASAuthorizationAppleIDProvider()
    // ์• ํ”Œ ๋กœ๊ทธ์ธ์— ํ•„์š”ํ•œ request ๊ฐ์ฒด ์ƒ์„ฑํ•˜๊ธฐ
    let request = appleIDProvider.createRequest()
    // ์‚ฌ์šฉ์ž์—๊ฒŒ ์–ป๊ณ ์ž ํ•˜๋Š” ์ •๋ณด ์ง€์ •ํ•˜๊ธฐ (์ด๋ฆ„, ๋ฉ”์ผ)
    request.requestedScopes = [.fullName, .email]

    // ์• ํ”Œ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ์ด๋‹ค.
    let authorizationController = ASAuthorizationController(authorizationRequests: [request])
    // ๋กœ๊ทธ์ธ ๊ณผ์ •์˜ ์„ฑ๊ณต/์‹คํŒจ ๊ฒฐ๊ณผ๋ฅผ ์ฒ˜๋ฆฌํ•œ๋‹ค.
    authorizationController.delegate = self
    // ์ธ์ฆ ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์–ด๋–ค ํ™”๋ฉด์— ํ‘œ์‹œ๋ ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๋ถ€๋ถ„. ๋ณดํ†ต ํ˜„์žฌ ํ™”๋ฉด์„ ์ง€์ •ํ•œ๋‹ค.
    authorizationController.presentationContextProvider = self
    // ์• ํ”Œ๋กœ๊ทธ์ธ request ์‹œ์ž‘ !
    authorizationController.performRequests()
}

 

์ด๋ ‡๊ฒŒ ์กฐ๊ธˆ์€ ๋ณต์žกํ•ด๋ณด์ด์ง€๋งŒ, ์šฐ๋ฆฐ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ๊ด€๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ๋งŒ๋“ค์–ด ์—ฐ๊ฒฐํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ์• ํ”Œ๋กœ๊ทธ์ธ ๊ณผ์ •์ด ์ง„ํ–‰๋œ๋‹ค.

 

๋‚˜๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์• ํ”Œ๋กœ๊ทธ์ธ์„ ์™„๋ฃŒํ•˜๋ฉด, ๋กœ๊ทธ์ธ ํ•œ ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์„ ์„œ๋ฒ„์— ๋„˜๊ฒจ์ค˜์•ผ ํ•˜๊ณ , ์•ฑ ๋‚ด์— ์ €์žฅํ•ด์•ผ ํ•œ๋‹ค.

๊ทธ ์ „์—, ๋ฐ›์€ ์ •๋ณด๋ฅผ ์ž˜ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋„๋ก ์ฝ˜์†”์— ์ถœ๋ ฅํ•ด๋ณด์ž !

 

 

 

 

4. ๋กœ๊ทธ์ธ ์ •๋ณด ์ฝ˜์†”์— ์ถœ๋ ฅํ•˜๊ธฐ

๊ณต์‹๋ฌธ์„œ์—์„œ๋Š” ์„ฑ๊ณตํ–ˆ์„ ๋•Œ ์‚ฌ์šฉ์ž ๋ฐ์ดํ„ฐ๋ฅผ ํ‚ค์ฒด์ธ์— ์ €์žฅํ•˜๋ผ๊ณ  ํ•œ๋‹ค.

์ด๊ฒŒ ๋ฌด์Šจ๋ง์ธ์ง€ ์ดํ•ด๊ฐ€ ์ž˜ ์•ˆ๋ผ์„œ ์ง€ํ”ผํ‹ฐํ•œํ…Œ ๋ฌผ์–ด๋ดค๋‹ค.

 

์ข€ ๊ธธ๊ธด ํ•˜์ง€๋งŒ,, ์ดํ•ด๋Š” ๋๋‹ค.

ํ•„์ˆ˜๋Š” ์•„๋‹ˆ์ง€๋งŒ ๊ฐœ์ธ์ •๋ณด๋Š” ์†Œ์ค‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์—.. ํ‚ค์ฒด์ธ์— ์ €์žฅํ•ด ๋ณด์•ˆ์„ ๊ฐ•ํ™”ํ•˜๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ๋‹ค์‹œ ์‚ญ์ œํ•˜๊ณ  ์žฌ์„ค์น˜ํ•˜๊ฑฐ๋‚˜ ์•ฑ์„ ์ข…๋ฃŒํ•œ ๋’ค ๋‹ค์‹œ ๋“ค์–ด์™”์„ ๋•Œ ๋‹ค์‹œ ๋กœ๊ทธ์ธํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์„ ์—†์•จ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

 

์ง€๊ธˆ๊นŒ์ง€ ์• ํ”Œ๋กœ๊ทธ์ธ ๊ทธ์ € ์ฝ”๋“œ๋งŒ ๋„ฃ์–ด์„œ ๊ตฌํ˜„ํ•ด์™”๋Š”๋ฐ ์ด๋ ‡๊ฒŒ ๊ณต๋ถ€ํ•ด๋ณด๋‹ˆ,, ๋” ํŒŒ์•ผํ•  ๊ธธ์ด ์žˆ๋Š” ๊ฒƒ ๊ฐ™๋‹ค.

 

ํ‚ค์ฒด์ธ ์ €์žฅ๊นŒ์ง€ ํ•˜๋Š” ๊ณผ์ •์„ ๊ฒฝํ—˜ํ•ด๋ณด๊ณ  ์‹ถ๊ธฐ๋„ ํ•˜์ง€๋งŒ, ๋„ˆ๋ฌด ๋ณต์žกํ• ๊นŒ ๊ฒ์ด ๋‚˜๊ธฐ๋„ ํ•˜๊ณ , ์ง€๊ธˆ ๋กœ๊ทธ์ธ๋ณด๋‹จ ์ฃผ๊ธฐ๋Šฅ ๊ตฌํ˜„์ด ๋” ์šฐ์„ ์ด๊ธฐ์—..! ์ผ๋‹จ ๋‚œ userDefaults์— ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹์„ ์„ ํƒํ•˜๊ฒ ๋‹ค.

 

์กฐ๊ธˆ ๋” ์šฉ๊ฐํ•ด์ ธ์„œ ๋Œ์•„์˜ฌ๊ฒŒ..

 

 

 

๋‹ค์‹œ ๋Œ์•„์™€์„œ, ๋กœ๊ทธ์ธ ์ •๋ณด๋ฅผ ์ฝ˜์†”์— ์ถœ๋ ฅํ•ด๋ณด์ž.

๊ทธ ์ „์—, ํ•œ ๋ฒˆ ๋กœ๊ทธ์ธํ•˜๋ฉด ์ถœ๋ ฅํ•  ๋•Œ userIdentifier๋งŒ ๋ณด์—ฌ์ง€๊ธฐ ๋•Œ๋ฌธ์—, ๋ฐ›์•„์˜ด๊ณผ ๋™์‹œ์— UserDefaults์— ์ €์žฅํ•  ๊ฒƒ์ด๋‹ค.

 

// didCompleteWithAuthorization = ์• ํ”Œ๋กœ๊ทธ์ธ ํ›„ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ํ•จ์ˆ˜
// ์ด ํ•จ์ˆ˜๋Š” ์• ํ”Œ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๊ฐ€ ์™„๋ฃŒ๋œ ๋’ค ํ˜ธ์ถœ๋œ๋‹ค.
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
    switch authorization.credential {
    
    // case1: ์‚ฌ์šฉ์ž๊ฐ€ apple ID๋กœ ๋กœ๊ทธ์ธํ–ˆ์„ ๋•Œ ๋ฐ˜ํ™˜๋˜๋Š” ์ •๋ณด๋ฅผ ์ฒ˜๋ฆฌ
    case let appleIDCredential as ASAuthorizationAppleIDCredential:

        // Create an account in your system.
        let userIdentifier = appleIDCredential.user
        let fullName = appleIDCredential.fullName
        let email = appleIDCredential.email

        print("useridentifier: \(userIdentifier)")
        print("fullName: \(String(describing: fullName))")
        print("email: \(email ?? "failed")")

        // UserDefaults์— ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ ์ €์žฅ
        let defaults = UserDefaults.standard

        // Optional fullName ์ฒ˜๋ฆฌ
        if let givenName = fullName?.givenName, let familyName = fullName?.familyName {
            let completeName = "\(givenName) \(familyName)"
            defaults.set(completeName, forKey: "fullName")
            print("Saved fullName: \(completeName)")
        } else {
            defaults.set("", forKey: "fullName") // ์ด๋ฆ„์ด ์—†์„ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด๋กœ ์ €์žฅ
            print("Saved fullName as empty string")
        }

        if let email = email {
            defaults.set(email, forKey: "email")
            print("Saved email: \(email)")
        } else {
            defaults.set("", forKey: "email") // ์ด๋ฉ”์ผ์ด ์—†์„ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด๋กœ ์ €์žฅ
            print("Saved email as empty string")
        }

	// case2 : iCloud ํ‚ค์ฒด์ธ์— ์ €์žฅ๋œ ๊ฒƒ์„ ์‚ฌ์šฉํ•ด ๋กœ๊ทธ์ธํ•˜๋Š” ๋ฐฉ์‹ (์—ฌ๊ธฐ์„  ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ)	
    case let passwordCredential as ASPasswordCredential:

        // Sign in using an existing iCloud Keychain credential.
        let username = passwordCredential.user
        let password = passwordCredential.password

        print("passwordCredential = \(username)")
        print("passwordCredential = \(password)")

    default:
        break
    }
}

 

์œ„ ์ฝ”๋“œ๋Š” ๊ณต์‹๋ฌธ์„œ์—์„œ ๊ฐ€์ ธ์™€์„œ ์ถœ๋ ฅํ•˜๊ณ , UserDefaults์— ์ €์žฅํ•˜๋Š” ์ฝ”๋“œ๋งŒ ์ถ”๊ฐ€ํ–ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ์ฝ”๋“œ๋ฅผ ์งœ๊ณ , ๋นŒ๋“œ๋ฅผ ํ•ด๋ณด์ž !

 

์ด๋ฉ”์ผ ๊ฐ€๋ฆฌ๊ธฐ๋ฅผ ํ•˜๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‚˜์˜จ๋‹ค.

 

์• ํ”Œ ๋กœ๊ทธ์ธ์˜ "์ด๋ฉ”์ผ ๊ฐ€๋ฆฌ๊ธฐ" ๊ธฐ๋Šฅ์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ž์‹ ์˜ ์‹ค์ œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ๊ณต์œ ํ•˜์ง€ ์•Š๊ณ ๋„ ์• ํ”Œ ID๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค์— ๋กœ๊ทธ์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค.

๊ทธ๋ ‡๊ธฐ์— ์‚ฌ์šฉ์ž๊ฐ€ '์ด๋ฉ”์ผ ๊ฐ€๋ฆฌ๊ธฐ'๋กœ ๋กœ๊ทธ์ธ์„ ํ•˜๋ฉด, ์• ํ”Œ์€ ์‚ฌ์šฉ์ž๋ฅผ ๋Œ€์‹ ํ•ด ๋ฌด์ž‘์œ„๋กœ ์ƒ์„ฑ๋œ ํ”„๋ก์‹œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

user@privaterelay.appleid.com ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ๋กœ ๋ฉ”์ผ์ด ์ƒ์„ฑ๋œ๋‹ค.

 

์™œ ์•ฑ ๋‚ด์—์„œ ์ตœ์ดˆ ๋กœ๊ทธ์ธ ๋•Œ๋งŒ ์‚ฌ์šฉ์ž ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์ด ๋‚˜์˜ฌ๊นŒ?

์•ž์—์„œ ๋งํ–ˆ๋“ฏ, ๋ฐ›์•„์˜ด๊ณผ ๋™์‹œ์— UserDefault์— ์ €์žฅํ–ˆ๋˜ ์ด์œ ๋Š” ์ตœ์ดˆ ๋กœ๊ทธ์ธ๋•Œ๋งŒ ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

์™œ ๊ทธ๋Ÿฐ์ง€ ๊ถ๊ธˆํ•ด์„œ ์ฐพ์•„๋ดค๋‹ค.

 

๋ณด์•ˆ์— ์ฒ ์ €ํ•œ ์• ํ”Œ์€ ์• ํ”Œ ๋กœ๊ทธ์ธ์„ ํ†ตํ•ด ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์„ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์€ ์ฒ˜์Œ ๋กœ๊ทธ์ธํ•  ๋•Œ์—๋งŒ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•œ๋‹ค.

์ด๋Š” ์• ํ”Œ์ด ์‚ฌ์šฉ์ž์˜ ๊ฐœ์ธ ์ •๋ณด๋ฅผ ์ตœ์†Œํ•œ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ๋ฐฉ์‹์„ ์ฑ„ํƒํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋ผ๊ณ  ํ•œ๋‹ค.

  • ์ฒ˜์Œ ๋กœ๊ทธ์ธ ์‹œ ์ •๋ณด ์ œ๊ณต: ์• ํ”Œ ๋กœ๊ทธ์ธ ์ ˆ์ฐจ์—์„œ ์ฒ˜์Œ ๋กœ๊ทธ์ธ์„ ํ•  ๋•Œ, ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ์ด๋•Œ ์‚ฌ์šฉ์ž๊ฐ€ ์• ํ”Œ ID๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค์— ์ฒ˜์Œ ์—ฐ๊ฒฐ๋  ๋•Œ๋งŒ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ์ด ์• ํ”Œ์—์„œ ์ „๋‹ฌ๋œ๋‹ค.
  • ๋‹ค์Œ ๋กœ๊ทธ์ธ ์‹œ ์ด๋ฆ„๊ณผ ์ด๋ฉ”์ผ ์ œ๊ณต ๋ถˆ๊ฐ€: ์ดํ›„ ๋™์ผํ•œ ์• ํ”Œ ID๋กœ ๋กœ๊ทธ์ธํ•  ๋•Œ๋Š” ์• ํ”Œ์—์„œ ์ œ๊ณตํ•˜๋Š” userIdentifier (์• ํ”Œ ID ๊ณ ์œ  ์‹๋ณ„์ž)๋งŒ ์ „๋‹ฌ๋œ๋‹ค. ์ด๋ฆ„์ด๋‚˜ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๋‹ค์‹œ ์ œ๊ณต๋˜์ง€ ์•Š๋Š”๋‹ค. ์ด๋Š” ์‚ฌ์šฉ์ž ๋ฐ์ดํ„ฐ ๋ณดํ˜ธ ๋ฐ ํ”„๋ผ์ด๋ฒ„์‹œ ๊ฐ•ํ™”๋ฅผ ์œ„ํ•œ ์• ํ”Œ์˜ ์ •์ฑ…์ด๋‹ค.

ํ•˜์ง€๋งŒ, userIdentifier๋Š” ๊ณ„์† ๋ฐ›์•„์˜ด์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

์ด๋Š” ์• ํ”Œ ID ๊ณ ์œ  ์‹๋ณ„์ž๋กœ, ์ด๋ฅผ ์‚ฌ์šฉํ•ด ์‚ฌ์šฉ์ž๋ฅผ ์‹๋ณ„ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•จ์ด๋ผ๊ณ  ํ•œ๋‹ค.

 

์–ด์ฉ์ง€ ์•„๋ฌด๋ฆฌ ๋กœ๊ทธ์ธํ•ด๋„ null์ด ๋‚˜์˜ค๋”๋ผ๋‹ˆ..!

์ด๊ฑธ ๋ชจ๋ฅด๋ฉด ๊ตฌํ˜„์ด ์ž˜ ์•ˆ๋œ์ค„ ์•Œ๊ณ  ์‚ฝ์งˆ์„ ๊ฝค๋‚˜ ํ•  ๊ฒƒ ๊ฐ™๋‹ค !!

 

 

์ด์ œ ์• ํ”Œ๋กœ๊ทธ์ธ์€ ๋๋‚ฌ๋‹ค !!

 

๋‹ค์Œ์— ๋‹ค์‹œ ํ™”๋ฉด๋“ค์„ ๋ช‡๊ฐœ ๋งŒ๋“ค๊ณ  ๋‚˜์„œ, ์•ฑ ๋‚ด ์ ‘๊ทผ ํ•  ๋•Œ๋งˆ๋‹ค ๋กœ๊ทธ์ธ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•ด ์ ์ ˆํ•œ ํ™”๋ฉด์œผ๋กœ ์ด๋™์‹œํ‚ค๋Š” ์ž๋™๋กœ๊ทธ์ธ์„ ๊ตฌํ˜„ํ•˜๊ณ  ์ •๋ฆฌํ•ด๋ด์•ผ๊ฒ ๋‹ค !

 

 

ํ›„ ํž˜๋“ค์—ˆ๋‹ค.

 

728x90
๋ฐ˜์‘ํ˜•
728x90
๋ฐ˜์‘ํ˜•

์ง€๋‚œ ๊ธ€์— ์ด์–ด ์ด๋ฒˆ์—๋Š” DeviceActivity๋ฅผ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ๊ธ€์ด๋‹ค.

๋‹ค์Œ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜์˜€๋‹ค !

https://developer.apple.com/documentation/DeviceActivity

 

DeviceActivity | Apple Developer Documentation

Monitor device activity with your app extension while maintaining user privacy.

developer.apple.com

 

์ด๋ฒˆ ๊ธ€์€ ๋‚ด๊ฐ€ ์ง„ํ–‰ ์ค‘์ธ ํ”„๋กœ์ ํŠธ์—์„œ ์ƒ๋‹นํžˆ ์ค‘์š”ํ•œ ์ฃผ๊ธฐ๋Šฅ์— ๊ผญ ํ•„์š”ํ•œ framework์ด๋ฏ€๋กœ, ์ฐจ๊ทผ์ฐจ๊ทผ ๋”ฐ๋ผํ•˜๋ฉด์„œ ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

๊ทธ ์ „์—, ์ด framework๋Š” ์•ฑ ํ™•์žฅ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ด ์‚ฌ์šฉ์ž์˜ ํ”„๋ผ์ด๋ฒ„์‹œ๋ฅผ ์œ ์ง€ํ•˜๋ฉด์„œ, ๊ธฐ๊ธฐ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•œ๋‹ค.

 

์ด์ „ ๊ธ€๊ณผ ์กฐ๊ธˆ ๊ฒน์น˜๋Š” ๋ถ€๋ถ„์ด ์—†์ž–์•„ ์žˆ์ง€๋งŒ,

1. ํŠน์ • ์‹œ๊ฐ„๋™์•ˆ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•  ์ˆ˜ ์žˆ๋‹ค.

2. ํ™œ๋™์ด ๋ฏธ๋ฆฌ ์„ค์ •๋œ ํ•œ๊ณ„์— ๋„๋‹ฌํ•  ๋•Œ ๊ฒฝ๊ณ ๋ฅผ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

3. ์•ฑ๊ณผ ์›น์‚ฌ์ดํŠธ์—์„œ ์‚ฌ์šฉ๋œ ์‹œ๊ฐ„์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•œ๋‹ค.

 

์ด์ œ ๊ฐ๊ฐ์˜ Topic์„ ํ•˜๋‚˜์”ฉ ๋‹ค๋ค„๋ณด์ž !

 


 

Manage Activities

  • struct DeviceActivityEvent
    • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜, ์นดํ…Œ๊ณ ๋ฆฌ ๋˜๋Š” ์›น์‚ฌ์ดํŠธ ํ™œ๋™์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ด๋ฒคํŠธ
  • struct DeviceActivityName
    • ํ™œ๋™์˜ ๊ณ ์œ ํ•œ ์ด๋ฆ„์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  • struct DeviceActivitySchedule
    • ๊ธฐ๊ธฐ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ๋•Œ์˜ ์ผ์ • ๊ธฐ๋ฐ˜ ์Šค์ผ€์ค„์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  • struct DeviceActivityCenter
    • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ํ™•์žฅ์ด ์ผ์ •์— ๋”ฐ๋ผ ๊ธฐ๊ธฐ ํ™œ๋™ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ํด๋ž˜์Šค

 

Monitor Activity

  • class DeviceActivityMonitor
    • ์ผ์ •์— ๋”ฐ๋ผ ๊ธฐ๊ธฐ ํ™œ๋™์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋Š” ๊ฐ์ฒด

 

Errors

  • enum MonitoringError
    • ํ™œ๋™ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์‹œ์ž‘ํ•  ๋•Œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ค๋ฅ˜๋“ค์„ ๋‚˜์—ดํ•˜๋Š” ์—ด๊ฑฐํ˜•

 

Classes

  • class DeviceActivityAuthorization
    • ๊ธฐ๊ธฐ ํ™œ๋™ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์œ„ํ•œ ๊ถŒํ•œ ๋ถ€์—ฌ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค์ด๋‹ค.

 

Protocols

  • protocol DeviceActivityAuthorizing
    • ๊ธฐ๊ธฐ ํ™œ๋™ ๋ชจ๋‹ˆํ„ฐ๋ง์— ๋Œ€ํ•œ ๊ถŒํ•œ ๋ถ€์—ฌ๋ฅผ ์ •์˜ํ•˜๋Š” ํ”„๋กœํ† ์ฝœ์ด๋‹ค.
  • protocol DeviceActivityReportExtension
    • ๊ธฐ๊ธฐ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๊ณ ํ•˜๋Š” ์•ฑ extension์ด๋‹ค.
  • protocol DeviceActivityReportScene
    • ์‚ฌ์šฉ์ž ์ •์˜ ๊ธฐ๊ธฐ ํ™œ๋™ report scene์„ ์ •์˜ํ•˜๋Š” ํ”„๋กœํ† ์ฝœ์ด๋‹ค.

 

Structures

  • struct DeviceActivityData
    • ํŠน์ • DeviceActivityData.Device์—์„œ DeviceActivityData.User์˜ ํ™œ๋™์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  • struct DeviceActivityFilter
    • ๋ณด๊ณ ์„œ์— ํฌํ•จํ•  ๊ธฐ๊ธฐ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ํ•„ํ„ฐ๋งํ•˜๋Š” ํƒ€์ž….
  • struct DeviceActivityReport
    • ์‚ฌ์šฉ์ž์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜, ์นดํ…Œ๊ณ ๋ฆฌ ๋ฐ ์›น ๋„๋ฉ”์ธ ํ™œ๋™์„ ํ”„๋ผ์ด๋ฒ„์‹œ๋ฅผ ๋ณดํ˜ธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณด๊ณ ํ•˜๋Š” view์ด๋‹ค.
  • struct DeviceActivityReportBuilder
    • ํ•˜๋‚˜ ์ด์ƒ์˜ DeviceActivityReportScenes์„ ๊ฒฐํ•ฉํ•˜์—ฌ ๋‹จ์ผ ์žฅ๋ฉด์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒฐ๊ณผ ๋นŒ๋”.
  • struct DeviceActivityResults
    • ํ•„ํ„ฐ๋ง๋œ ๊ธฐ๊ธฐ ํ™œ๋™ ๊ฒฐ๊ณผ์˜ ๋น„๋™๊ธฐ sequence.

 

 

ํ”„๋กœ์ ํŠธ์— ๋ฐ˜์˜ํ•˜๊ธฐ

์ด์ œ xcode์— ํ”„๋กœ์ ํŠธ๋ฅผ ํŒŒ๊ณ , ํ•ด๋‹น api๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋Š” ๊ณผ์ •์„ ์ •๋ฆฌํ•˜๋ ค ํ•œ๋‹ค.

 

๋จผ์ €, ๊ด€๋ จ๋œ extension์„ ์„ค์น˜ํ•ด์ค€๋‹ค.

 

ํƒ€๊นƒ์—์„œ ํ•˜๋‹จ์˜ + ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ add target์„ ํ•ด์ค€๋‹ค.

 

 

๊ทธ๋Ÿผ, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํŒ์—…์ด ๋œจ๋Š”๋ฐ, ์ด ๋•Œ DeviceActivity Monitor Extension๊ณผ Device Activity Report Extension์„ ๊ฐ๊ฐ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

์ด๋ ‡๊ฒŒ ๋‘ ๊ฐœ์˜ extension์„ ๋ชจ๋‘ ์ถ”๊ฐ€ํ–ˆ๋‹ค๋ฉด, ์ด๋ ‡๊ฒŒ xcode์— ์ถ”๊ฐ€๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.



 

์ด์ œ extension์„ ์ถ”๊ฐ€ํ•˜์˜€์œผ๋ฉด, ๋‚˜์™€ ๊ฐ™์€ ๊ฒฝ์šฐ, ๋Œ€๋ถ€๋ถ„์˜ ์ฝ”๋“œ๋ฅผ UIKit์œผ๋กœ ์งค ์˜ˆ์ •์ด๊ธฐ์— SwiftUI ๊ธฐ๋ฐ˜์˜ api์™€ UIKit์„ ์„œ๋กœ ์—ฐ๊ฒฐํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

์ฆ‰, ๋‘ ๊ฐœ์˜ framework๋ฅผ ํ˜ผ์šฉํ•ด์„œ ์“ธ ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ์„ ์„ธํŒ… ํ•ด์•ผ ํ•œ๋‹ค.

 

 

UIKit๊ณผ SwiftUI ํ˜ผ์šฉํ•˜๊ธฐ

UIHostingController๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

ํ•˜์ง€๋งŒ, ์•„๋ฌด๋ฆฌ ์‚ฌ์šฉํ•ด์„œ ์—ฐ๊ฒฐ์„ ํ•ด๋„, ์ž๊พธ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” TotalActivityView๊ฐ€ scope์— ์—†๋‹ค๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ๋ณด์˜€๋‹ค.

๊ณ„์† ์„œ์น˜ํ•˜๊ณ , ์‚ฝ์งˆ์„ ํ•˜๋‹ค ๋ณด๋‹ˆ,, ๋‚ด๊ฐ€ extension๋“ค์„ add target์œผ๋กœ ํ•ด์คฌ์œผ๋ฏ€๋กœ,, ์–˜๋„ค๋“ค์„ ๋ชจ๋‘ ํƒ€๊นƒ์— ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ–ˆ๋‹ค.

 

์ง€๋‚œ ํ”„๋กœ์ ํŠธ ๋‹น์‹œ์—๋„ ์ด๊ฒƒ๋•Œ๋ฌธ์— ์‚ฝ์งˆ์„ ๊ฝค ํ–ˆ์—ˆ๋Š”๋ฐ.. ์•„์ฐจ์ฐจ ์ด๊ฑธ ๋˜ ์žŠ์—ˆ๋‹ค๋‹ˆ..

 

์˜ค๋ž˜ ์‚ฝ์งˆ ์•ˆํ•˜๊ณ  ์ง€๊ธˆ์ด๋ผ๋„ ์•Œ์•˜์œผ๋‹ˆ ๋‹คํ–‰์ด๋‹ค.

๋จผ์ €, viewController์˜ ์˜ค๋ฅธ์ชฝ inspector์—์„œ target์— ActivityReport๋ฅผ ์ฒดํฌํ•ด์ฃผ์—ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ , TotalActivityView์—์„œ๋„ ๋ฉ”์ธ ํ”„๋กœ์ ํŠธ ํƒ€๊นƒ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์—ˆ๋‹ค.

 

 

๊ทธ๋žฌ๋”๋‹ˆ, ์ด์ œ TotalActivityView๋ฅผ ์ž˜ ์ฐพ์•„ ๋นŒ๋“œ๊ฐ€ ์„ฑ๊ณตํ–ˆ๋‹ค.

๋งŒ์•ฝ ์•ˆ๋œ๋‹ค๋ฉด, ์ƒ๋‹จ์˜ Product -> Clean Build Folder๋ฅผ ๊ผญ ํ•˜๊ธธ!!

 

์•„์ฐจ์ฐจ ๊ทธ๋Ÿฐ๋ฐ ํ™”๋ฉด์—๋Š” ์•„๋ฌด๊ฒƒ๋„ ๋ณด์ด์ง€ ์•Š์•˜๋Š”๋ฐ, ๊ทธ ์ด์œ ๊ฐ€ SceneDelegate.swift ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค..

ํ˜„์žฌ๋Š” StoryBoard๋กœ ์—ฐ๊ฒฐ๋˜๋„๋ก ๋ผ ์žˆ์–ด ์ด๊ฑธ ๋ฐ”๊ฟ”์ค˜์•ผ ํ•œ๋‹ค.

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let windowScene = (scene as? UIWindowScene) else { return }

    let window = UIWindow(windowScene: windowScene)

    let viewController = MainViewController()

    window.rootViewController = viewController

    window.makeKeyAndVisible()

    self.window = window
}

 

์ด๋ ‡๊ฒŒ ํ•˜๊ณ  ์‹คํ–‰ํ•˜๋‹ˆ ํ™”๋ฉด์ด ์ž˜ ์—ฐ๊ฒฐ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค !

 

์ง€๊ธˆ์€ ์ž๋™์œผ๋กœ ์ œ๊ณต๋˜๋Š” view๋งŒ ์—ฐ๊ฒฐํ–ˆ๋Š”๋ฐ, ๊ทธ๋ ‡๊ธฐ์— ์‹ค์ œ ๊ธฐ๊ธฐ์—์„œ ์‚ฌ์šฉํ•œ ์•ฑ์— ๋Œ€ํ•œ ์‹œ๊ฐ„๋“ค์ด ๋‚˜์˜ค๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ, ๋‚ด๊ฐ€ ํ•ด๋‹น VC๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ๋„ฃ์€ argument ๊ฐ’์ด ๊ทธ๋Œ€๋กœ ๋ณด์—ฌ์ง€๊ณ ๋งŒ ์žˆ์—ˆ๋‹ค.

 

์œ„ ์‹คํ–‰ ๊ฒฐ๊ณผ๋Š” ๊ธฐ์กด์˜ extension์—์„œ ์ค€ ์ฝ”๋“œ๋ฅผ rootView๋กœ ์—ฐ๊ฒฐํ•ด ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ์ด๋‹ค.

 

์ด์ œ, ActivityReport๋ฅผ ์ง์ ‘ ์—ฐ๊ฒฐํ•ด์„œ ๋ณด์—ฌ์ค˜์•ผ ํ•œ๋‹ค !!

 

 

 

๊ทธ ์ „์—, ์Šคํฌ๋ฆฐํƒ€์ž„์œผ๋กœ ๊ธฐ๊ธฐ์— ์žˆ๋Š” ์ „์ฒด ์•ฑ์„ ๊ฐ€์ ธ์™€ ์ œํ•œ์‹œ์ผœ๋ณด์ž !

 

์†”์งํžˆ ๋งํ•˜๋ฉด,, ์—ฌ๊ธฐ์„œ ์‚ฝ์งˆ์„ ์ง„์งœ ์™•๋งŽ์ด ํ–ˆ๋‹ค.

๊ฒฐ๊ตญ ์ ‘๊ทผ ๊ถŒํ•œ์„ ๋จผ์ € ํ—ˆ์šฉํ•ด์ค˜์•ผํ–ˆ๋‹ค๋Š”๊ฑธ ๋’ค๋Šฆ๊ฒŒ ๊นจ๋‹ฌ์•˜๋‹ค..

 

1. ์Šคํฌ๋ฆฐํƒ€์ž„ ์ ‘๊ทผ ๊ถŒํ•œ ์š”์ฒญํ•˜๊ธฐ

๋จผ์ € ์ ‘๊ทผ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” family controls๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ด๋ ‡๊ฒŒ Family Controls๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.

์•„์ฐจ์ฐจ Family Controls์˜ ์ผ๋ถ€๋งŒ ์ฝ๊ณ  ๋‚ด ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ์“ฐ์ง€ ์•Š์„๊ฑฐ๋ผ๊ณ  ์ž๋ถ€ํ–ˆ๋Š”๋ฐ..ใ…‹ใ…Žใ…‹ใ…Ž

 

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        
    guard let windowScene = (scene as? UIWindowScene) else { return }

    // SwiftUI ๋ทฐ๋ฅผ ํ˜ธ์ŠคํŒ…ํ•˜๋Š” UIHostingController๋ฅผ ์ƒ์„ฑ - ์ฆ‰ SwiftUI ์—ฐ๊ฒฐํ•˜๊ธฐ
    let totalActivityView = TotalActivityView(totalActivity: "hello")
    let hostingController = UIHostingController(rootView: totalActivityView)

    // UIKit์˜ UIWindow ์„ค์ •
    window = UIWindow(windowScene: windowScene)
    window?.rootViewController = hostingController
    window?.makeKeyAndVisible()

    // ์Šคํฌ๋ฆฐํƒ€์ž„ ๊ถŒํ•œ ๊ถŒํ•œ ์š”์ฒญ
    Task {
        let center = AuthorizationCenter.shared
        do {
            try await center.requestAuthorization(for: .individual)
        } catch {
            print("Fail: \(error)")
        }
    }
}

 

์ด๋ ‡๊ฒŒ ๊ถŒํ•œ ์š”์ฒญ์„ ์—ฐ๊ฒฐํ•˜๋ฉด ๋œ๋‹ค !!

012

 

2. ๊ธฐ๊ธฐ์˜ ์•ฑ ๋ฆฌ์ŠคํŠธ ๋ณด์—ฌ์ฃผ๊ธฐ

์ด์ œ ๊ธฐ๊ธฐ์— ์žˆ๋Š” ๋ชจ๋“  ์•ฑ์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณด์—ฌ์ค˜์•ผ ํ•œ๋‹ค.

import UIKit
import SwiftUI
import FamilyControls

struct AppListView: View {

    // ์ƒํƒœ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด @State ์‚ฌ์šฉํ•˜๊ธฐ
    // FamilyActivitySelection()์€ ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ๊ฐ€์กฑ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ์ฒด.
    @State var selection = FamilyActivitySelection()

    // isPresented๋Š” familyActivityPicker๊ฐ€ ํ™”๋ฉด์— ํ‘œ์‹œ๋˜๋Š”์ง€ ํ†ต์ œํ•จ
    @State var isPresented = false

    var body: some View {
        
        // VStack์€ ์ˆ˜์ง์œผ๋กœ ๊ทธ๋ฆฌ๊ธฐ
        VStack {
            Button {
                // ๋ฒ„ํŠผ์ด ํด๋ฆญ๋˜๋ฉด isPresented ์ƒํƒœ๋ฅผ true๋กœ ์„ค์ •
                isPresented = true
            } label: {
                // ๋ฒ„ํŠผ์˜ ๋ ˆ์ด๋ธ” ์ง€์ •ํ•˜๊ธฐ
                Text("show app list")
            }
        }
        // .familyActivityPicker๋Š” family activity๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” Picker ํ™”๋ฉด์— ๋ณด์—ฌ์ฃผ๊ธฐ
        // isPresented๊ฐ€ true์ผ ๋•Œ Picker๊ฐ€ ํ‘œ์‹œ.
        // selection์€ ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•จ.
        .familyActivityPicker(isPresented: $isPresented, selection: $selection)
    }
}

์ด๋ ‡๊ฒŒ ์ฝ”๋“œ๋ฅผ ์งœ๋ฉด ๋˜๋Š”๋ฐ, ๋‚˜๋Š” SwftUI๋ฅผ ์ „ํ˜€ ์•Œ์ง€ ๋ชปํ•ด์„œ ์ฃผ์„์œผ๋กœ ์ •๋ฆฌ๋ฅผ ์ข€ ํ•ด๋’€๋‹ค.

 

๋‚˜๋Š” ์ƒˆ๋กœ์šด ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ๋ฆฌ์ŠคํŠธ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๋ถ€๋ถ„์„ ๊ตฌํ˜„ํ–ˆ๋Š”๋ฐ, ์ด ๋•Œ ๋นŒ๋“œ๋Š” ์‹คํŒจํ•˜๊ณ , ์‹คํŒจ ๋ฉ”์‹œ์ง€๊ฐ€ ์ž๊พธ ๋ณด์—ฌ์กŒ๋‹ค ์‚ฌ๋ผ์กŒ๋‹ค.

์‹ค์ˆ˜๋„ ๋ฐ˜๋ณต๋˜๋ฉด ์‹ค๋ ฅ์ธ๋ฐ ๋˜ ํƒ€๊นƒ ์„ค์ • ๋ฌธ์ œ์˜€๋‹ค.

 

์ง€๊ธˆ familyCotrol์„ ์‚ฌ์šฉํ•˜๋ ค ํ•˜๊ธฐ ๋•Œ๋ฌธ์— target์— activity report๋ฅผ ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๋นŒ๋“œํ•˜๋‹ˆ, ์ด๋ ‡๊ฒŒ ์ž˜ ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

01

 

์ด์ œ ๋ฆฌ์ŠคํŠธ์—์„œ ์„ ํƒํ•œ ์•ฑ๋“ค์„ ์ฝ˜์†”์— ์ถœ๋ ฅํ•ด๋ณด๊ณ , ์„ ํƒํ•œ ์•ฑ๋“ค์˜ ์‚ฌ์šฉ์„ ์ œํ•œํ•ด๋ณด์ž.

 

 

3. ์„ ํƒํ•œ ์•ฑ ์‚ฌ์šฉ ์ œํ•œํ•˜๊ธฐ

๋จผ์ € ์„ ํƒํ•œ ์•ฑ๋“ค์„ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋ชจ๋ธ์„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

import SwiftUI
import FamilyControls
import ManagedSettings

// ObservableObject ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•œ Model ํด๋ž˜์Šค ์ •์˜
class Model: ObservableObject {
    
    // ์ด ํด๋ž˜์Šค์˜ ๊ณต์œ  ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ (์‹ฑ๊ธ€ํ†ค ํŒจํ„ด)
    static var shared = Model()
    
    // ManagedSettingsStore์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์„ค์ •์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•จ
    let store = ManagedSettingsStore()
    
    // ์‚ฌ์šฉ์ž๊ฐ€ ์ œํ•œํ•˜๋ ค๋Š” ์•ฑ ๋ฐ ์นดํ…Œ๊ณ ๋ฆฌ ์„ ํƒ์„ ์ €์žฅํ•˜๋Š” ๋ณ€์ˆ˜, ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค UI ์—…๋ฐ์ดํŠธ
    @Published var selectedtoLimit: FamilyActivitySelection
    
    // ์ดˆ๊ธฐํ™” ๋ฉ”์„œ๋“œ: selectedtoLimit์„ ์ƒˆ๋กœ์šด FamilyActivitySelection ๊ฐ์ฒด๋กœ ์ดˆ๊ธฐํ™”
    init() {
        selectedtoLimit = FamilyActivitySelection()
    }
    
    // ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ์•ฑ๊ณผ ์นดํ…Œ๊ณ ๋ฆฌ์— ๋Œ€ํ•ด ์ฐจ๋‹จ ์ œํ•œ์„ ์„ค์ •ํ•˜๋Š” ํ•จ์ˆ˜
    func setShieldRestrictions() {
        // ์‚ฌ์šฉ์ž๊ฐ€ ์ œํ•œํ•  ์•ฑ๊ณผ ์นดํ…Œ๊ณ ๋ฆฌ ์„ ํƒ์„ ๊ฐ€์ ธ์˜ด
        let applications = Model.shared.selectedtoLimit
        
        // ์•ฑ ์ฐจ๋‹จ์„ ์„ค์ •, ์„ ํƒ๋œ ์•ฑ์ด ์—†์œผ๋ฉด nil๋กœ ์„ค์ •
        store.shield.applications = applications.applicationTokens.isEmpty ? nil : applications.applicationTokens
        
        // ์•ฑ ์นดํ…Œ๊ณ ๋ฆฌ ์ฐจ๋‹จ ์„ค์ •, ์„ ํƒ๋œ ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ์—†์œผ๋ฉด nil๋กœ ์„ค์ •
        store.shield.applicationCategories = applications.categoryTokens.isEmpty
        ? nil
        : ShieldSettings.ActivityCategoryPolicy.specific(applications.categoryTokens)
    }
}

 

 

์ด์ œ ๋ชจ๋ธ์„ ์ถ”๊ฐ€ํ–ˆ์œผ๋‹ˆ, ํ™”๋ฉด์„ ๊ทธ๋ฆฌ๋Š” ๋ถ€๋ถ„๋„ ๋ชจ๋ธ์— ๋‹ด๊ณ  ๋ชจ๋ธ ๋‹จ์œ„๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์กฐ๊ธˆ ์ˆ˜์ •ํ•ด์ค€๋‹ค.

struct AppListView: View {
    
    // ์ƒํƒœ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด @State ์‚ฌ์šฉํ•˜๊ธฐ
    // FamilyActivitySelection()์€ ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ๊ฐ€์กฑ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ์ฒด.
    @State var selection = FamilyActivitySelection()
    
    // isPresented๋Š” familyActivityPicker๊ฐ€ ํ™”๋ฉด์— ํ‘œ์‹œ๋˜๋Š”์ง€ ํ†ต์ œํ•จ
    @State var isPresented = false
    @EnvironmentObject var model: Model
    
    var body: some View {
        
        // VStack์€ ์ˆ˜์ง์œผ๋กœ ๊ทธ๋ฆฌ๊ธฐ
        VStack {
            Button {
                // ๋ฒ„ํŠผ์ด ํด๋ฆญ๋˜๋ฉด isPresented ์ƒํƒœ๋ฅผ true๋กœ ์„ค์ •
                isPresented = true
            } label: {
                // ๋ฒ„ํŠผ์˜ ๋ ˆ์ด๋ธ” ์ง€์ •ํ•˜๊ธฐ
                Text("show app list")
                // .familyActivityPicker๋Š” family activity๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” Picker ํ™”๋ฉด์— ๋ณด์—ฌ์ฃผ๊ธฐ
                // isPresented๊ฐ€ true์ผ ๋•Œ Picker๊ฐ€ ํ‘œ์‹œ.
                // selection์€ ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํ™œ๋™ ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ๋ธ์— ์ €์žฅํ•จ.
            }.familyActivityPicker(isPresented: $isPresented, selection: $model.selectedtoLimit)
        }
        // ์ดํ›„ ์„ ํƒํ•œ ์•ฑ๋“ค์— ๋Œ€ํ•œ shieldRestriction์ด ์‹คํ–‰๋œ๋‹ค.
        .onChange(of: model.selectedtoLimit, {
            Model.shared.setShieldRestrictions()
        })
    }
}

 

 

๊ทธ๋ฆฌ๊ณ , ์Šคํฌ๋ฆฐํƒ€์ž„์— ๋Œ€ํ•œ ๊ถŒํ•œ ์š”์ฒญ์„ AppDelegate๋กœ ๋„˜๊ฒจ์ค€๋‹ค.

// AppDelegate.swift

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
           
   guard let windowScene = (scene as? UIWindowScene) else { return }

   // `Model.shared`์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑ
   let model = Model.shared

   // SwiftUI์˜ AppListView๋ฅผ ์„ค์ •
   let contentView = AppListView().environmentObject(model)

   // ์ƒˆ๋กœ์šด UIWindow๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ดˆ๊ธฐ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ์„ค์ €
   let window = UIWindow(windowScene: windowScene)
   window.rootViewController = UIHostingController(rootView: contentView)
   self.window = window
   window.makeKeyAndVisible()
}

 

 

๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰์œผ๋กœ, SceneDelegate๋ฅผ ์ˆ˜์ •ํ•ด์ค€๋‹ค. ์—ฌ๊ธฐ์— ๋ชจ๋ธ์„ ๋‹ด๋„๋ก ์ˆ˜์ •ํ•˜๊ณ , ๊ถŒํ•œ ํ—ˆ์šฉ ๋ถ€๋ถ„์„ ์œ„์—์„œ ํ•œ ๊ฒƒ ์ฒ˜๋Ÿผ AppDelegate๋กœ ๋„˜๊ฒจ์คฌ๋‹ค.

// SceneDelegate.swift

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
           
   guard let windowScene = (scene as? UIWindowScene) else { return }

   // `Model.shared`์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑ
   let model = Model.shared

   // SwiftUI์˜ AppListView๋ฅผ ์„ค์ •
   let contentView = AppListView().environmentObject(model)

   // ์ƒˆ๋กœ์šด UIWindow๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ดˆ๊ธฐ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ๋กœ ์„ค์ €
   let window = UIWindow(windowScene: windowScene)
   window.rootViewController = UIHostingController(rootView: contentView)
   self.window = window
   window.makeKeyAndVisible()
}

 

์ด๋ ‡๊ฒŒ ํ•˜๊ณ , ์•ฑ์„ ์‹คํ–‰ํ•ด๋ณด์ž !

 

 

์‹คํ–‰ ๊ฒฐ๊ณผ

 

 

 

์•„๋‹ˆ ์ด๋ ‡๊ฒŒ ๊ฐ„๋‹จํ•œ ๊ธฐ์ˆ ๊ฒ€์ฆ์„ ๊ทธ๋•Œ๋Š” ์™œ๊ทธ๋ ‡๊ฒŒ ์‚ฝ์งˆํ•˜๊ณ  ํž˜๋“ค์–ดํ–ˆ์„๊นŒ..

์‹œ๊ฐ„์ด ์ด‰๋ฐ•ํ•˜๋‹ค๋Š” ์ด์œ ๋กœ reference๋ถ€ํ„ฐ ์ฐพ๊ณ , ๋ƒ…๋‹ค ์‹คํ–‰ํ•ด๋ณด๊ณ  ๋„˜์–ด๊ฐ”๋˜ ๊ณผ๊ฑฐ์˜ ๋‚˜.. ๋ฐ˜์„ฑํ•˜๋ผ..

 

์ด์ œ ์• ํ”Œ ๊ณต์‹๋ฌธ์„œ ๊ตฌ์กฐ๋„ ์–ด๋Š์ •๋„ ๊ฐ์ด ์žกํ˜”๊ณ , ์•„์ง ๊ทธ๊ฑธ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฝ”๋“œ๋Š” ๋ชป์งœ๊ฒ ์ง€๋งŒ,, ๋ญ,, ์•ž์œผ๋กœ ์ฐจ๊ทผ์ฐจ๊ทผ ํ•ด๋ด์•ผ๊ฒ ๋‹ค !!

 

๋‹ค์Œ ๊ธ€์—์„œ๋Š” ์ด์ œ ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์˜ ์ฃผ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด๋ด์•ผ์ง€ !

 

 

 

 

์ฐธ๊ณ ์ž๋ฃŒ

https://hongz-developer.tistory.com/246

 

728x90
๋ฐ˜์‘ํ˜•

+ Recent posts