SlideShare a Scribd company logo
1 of 28
Download to read offline
공봉식
2016.01.14
kongbong23@gmail.com
UPNP (UNIVERSAL PLUG AND PLAY)
우연히 UPNP 에 대해 듣게 되었다.
요즘엔 UPnP로 홀펀칭 없이 P2P 를 하더라..
까뮤즈 회사 제품 설명에서 이런 글을 봄.
그 전에.. 홀펀칭이란..
NAT 아래 있는 device 간 통신을 위해서 Port 를 뚫는 것.
NAT 아래 device 들은 private IP 를 할당 받는데
문제는 자신의 특정 포트가 어떤 public IP 의 어떤 port 로
Port forwarding 될지 모른다는 점이다.
Port Forwarding 이란
Internal IP, PORT 를 External IP, PORT 에 Mapping
1. 중계 서버를 두고 peer 들 중 누가 NAT 아래 있는지 확인한다.
중계 Server
Peer Peer
이 경우는 Public IP 를 아는 쪽으로 직접
연결한다.
2. 모두 NAT 아래에 있는 경우 – 중계 서버가 알고 있는 EndPoint 로
UDP 통신을 한다.
중계 Server
Peer Peer
UDP 통신을 한다.
UDP 는 순서 보장도 안되고 유실도 될 수 있기 때문에
Reliable UDP 를 소프트웨어적으로 구현해야 한다. (약간 삽질)
더 큰 문제는 이마저도 안되는 악질 NAT 들이 있다.
3. 이도 저도 안되면 중계 서버가 Relay 한다.
중계 Server
Peer Peer
Relay
UPnP 를 이용하면 External IP 와 Port 를 알 수 있다더라..
HOW?
UPnP (Universal Plug and Play)
컴퓨터에 USB 드라이브를 꽂으면 자동으로 인식 되듯이
네트워크 상에 Device 를 연결하면 자동으로 인식 되도록 하자.
Configuration 이 필요 없이 연결 즉시 사용 가능하고,
Device 간 연결이 용이하도록 하자.
스마트홈의 기본 기술로 사용하는 거 같음.
1. Addressing
Device 가 Network 에 들어오면 DHCP 로
동적 IP 를 할당 받는다
2. Advertising
UDP Broadcast 로 자신이 연결되었음을 알린다.
3. Discovery
UDP Broadcast 로 네트워크 상의 UPnP Device 들의
존재를 알려달라는 패킷을 보낸다.
패킷을 수신한 UPnP Device 들은 해당 EndPoint 로
자신의 존재를 알린다.
4. Action
SOAP 기능을 이용하여 해당 Device 가 제공하는
Action 을 수행한다.
5. Event Subscribing
해당 Event 에 Subscribe 하여서 Event 발생시
Notify 를 받는다.
그럼 이걸로 어떻게 External IP 를 알아오는가?
UPnP Device 중 IGD (Internet Gateway Device)
Type 이 있는데, IGD 들은
GetExternalIPAddress Action 을 가지고 있다.
그 뿐만 아니라
Learn the public (external) IP address
Requesting for a new public IP address
Enumerate existing port mappings
Add and remove port mappings
Assign lease times to mappings
과 같은 강력한 기능을 가지고 있다.
그래서 ARP HOOKING 처럼 패킷을 후킹할 수 있는
HACKING 도구로 사용될 수 있다.
여기까지가 이론 공부.. 실제로 IGD 를 이용하여 P2P 를 만들자
그러려고 했으나….
집 공유기가 IGD 를 지원안함…
(위키페디아에서는 많은 공유기가 지원하고 있다고 했는데…)
그래도 집 셋탑박스가 UPnP Device 로
Discovery 되어서 해당 셋탑박스가 제공하는
Get, SetVolumn Action 을 사용하는 프로그램을 만들어 봄.
1. Discovery
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST:upnp:rootdevice
MAN:"ssdp:discover“
MX:3
ASCII 형태의 위 전문을
UDP Port 239.255.255.250:1900
BroadCast 포트로 전송한다.
http/1.1 200 ok
cache-control: max-age=1810
date: tue, 12 jan 2016 16:27:39 gmt
ext:
location:
http://192.168.219.21:38400/description.xml
server: android/2.2 upnp/1.0 smartict/1.0
st: upnp:rootdevice
usn: uuid:fe28fde0-8522-bcb4-b767-
d7beb5b1f1ef::upnp:rootdevice
x-type: stb
그러면 아래와 같이 Device 정보가 담긴 응답이 온다.
Device Type
Service List
Service Description
Action 목록 중
SetVolume 과
GetVolume 을 발견
걍 SOAP 으로 아무 생각 없이 호출
우왕 쿡쿡 잘됨.
마크 주커버그가 육아휴직 내고
집에서 하고 있는게 이거겠지.
그러면서 끝.

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

UPnP 발표자료

  • 2. 우연히 UPNP 에 대해 듣게 되었다. 요즘엔 UPnP로 홀펀칭 없이 P2P 를 하더라..
  • 3. 까뮤즈 회사 제품 설명에서 이런 글을 봄.
  • 4. 그 전에.. 홀펀칭이란.. NAT 아래 있는 device 간 통신을 위해서 Port 를 뚫는 것.
  • 5. NAT 아래 device 들은 private IP 를 할당 받는데 문제는 자신의 특정 포트가 어떤 public IP 의 어떤 port 로 Port forwarding 될지 모른다는 점이다.
  • 6. Port Forwarding 이란 Internal IP, PORT 를 External IP, PORT 에 Mapping
  • 7. 1. 중계 서버를 두고 peer 들 중 누가 NAT 아래 있는지 확인한다. 중계 Server Peer Peer 이 경우는 Public IP 를 아는 쪽으로 직접 연결한다.
  • 8. 2. 모두 NAT 아래에 있는 경우 – 중계 서버가 알고 있는 EndPoint 로 UDP 통신을 한다. 중계 Server Peer Peer UDP 통신을 한다.
  • 9. UDP 는 순서 보장도 안되고 유실도 될 수 있기 때문에 Reliable UDP 를 소프트웨어적으로 구현해야 한다. (약간 삽질) 더 큰 문제는 이마저도 안되는 악질 NAT 들이 있다.
  • 10. 3. 이도 저도 안되면 중계 서버가 Relay 한다. 중계 Server Peer Peer Relay
  • 11. UPnP 를 이용하면 External IP 와 Port 를 알 수 있다더라.. HOW?
  • 12. UPnP (Universal Plug and Play) 컴퓨터에 USB 드라이브를 꽂으면 자동으로 인식 되듯이 네트워크 상에 Device 를 연결하면 자동으로 인식 되도록 하자. Configuration 이 필요 없이 연결 즉시 사용 가능하고, Device 간 연결이 용이하도록 하자. 스마트홈의 기본 기술로 사용하는 거 같음.
  • 13. 1. Addressing Device 가 Network 에 들어오면 DHCP 로 동적 IP 를 할당 받는다
  • 14. 2. Advertising UDP Broadcast 로 자신이 연결되었음을 알린다.
  • 15. 3. Discovery UDP Broadcast 로 네트워크 상의 UPnP Device 들의 존재를 알려달라는 패킷을 보낸다. 패킷을 수신한 UPnP Device 들은 해당 EndPoint 로 자신의 존재를 알린다.
  • 16. 4. Action SOAP 기능을 이용하여 해당 Device 가 제공하는 Action 을 수행한다.
  • 17. 5. Event Subscribing 해당 Event 에 Subscribe 하여서 Event 발생시 Notify 를 받는다.
  • 18. 그럼 이걸로 어떻게 External IP 를 알아오는가? UPnP Device 중 IGD (Internet Gateway Device) Type 이 있는데, IGD 들은 GetExternalIPAddress Action 을 가지고 있다.
  • 19. 그 뿐만 아니라 Learn the public (external) IP address Requesting for a new public IP address Enumerate existing port mappings Add and remove port mappings Assign lease times to mappings 과 같은 강력한 기능을 가지고 있다.
  • 20. 그래서 ARP HOOKING 처럼 패킷을 후킹할 수 있는 HACKING 도구로 사용될 수 있다. 여기까지가 이론 공부.. 실제로 IGD 를 이용하여 P2P 를 만들자
  • 21. 그러려고 했으나…. 집 공유기가 IGD 를 지원안함… (위키페디아에서는 많은 공유기가 지원하고 있다고 했는데…)
  • 22. 그래도 집 셋탑박스가 UPnP Device 로 Discovery 되어서 해당 셋탑박스가 제공하는 Get, SetVolumn Action 을 사용하는 프로그램을 만들어 봄.
  • 23. 1. Discovery M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST:upnp:rootdevice MAN:"ssdp:discover“ MX:3 ASCII 형태의 위 전문을 UDP Port 239.255.255.250:1900 BroadCast 포트로 전송한다.
  • 24. http/1.1 200 ok cache-control: max-age=1810 date: tue, 12 jan 2016 16:27:39 gmt ext: location: http://192.168.219.21:38400/description.xml server: android/2.2 upnp/1.0 smartict/1.0 st: upnp:rootdevice usn: uuid:fe28fde0-8522-bcb4-b767- d7beb5b1f1ef::upnp:rootdevice x-type: stb 그러면 아래와 같이 Device 정보가 담긴 응답이 온다.
  • 26. Action 목록 중 SetVolume 과 GetVolume 을 발견
  • 27. 걍 SOAP 으로 아무 생각 없이 호출 우왕 쿡쿡 잘됨.
  • 28. 마크 주커버그가 육아휴직 내고 집에서 하고 있는게 이거겠지. 그러면서 끝.