#keywords SSDP,discovery,upnp,network,HTTPU,M-SEARCH,multicast #title SSDP(Simple Service Discovery Protocol) [wiki:Home 대문] / [wiki:CategoryNetwork 네트웍], [wiki:CategoryProgramming 프로그래밍] / [wiki:SimpleServiceDiscoveryProtocol SSDP(Simple Service Discovery Protocol)] ---- == [wiki:SimpleServiceDiscoveryProtocol SSDP(Simple Service Discovery Protocol)] == * 작성자 조재혁([mailto:minzkn@minzkn.com]) * 고친과정 2011년 6월 14일 : 처음씀 [[TableOfContents]] == 개요 == [wiki:SimpleServiceDiscoveryProtocol SSDP(Simple Service Discovery Protocol)]은 Microsoft와 HP에 의해서 1999년 [^http://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt IETF Internet draft]에 기술되었으며 uPnP의 탐색을 구현하기 위한 기반이 됩니다. 이것은 HTTPU Protocol을 이용하여 Text기반으로 되어 있습니다. HTTPU는 HTTP Protocol([^http://www.ietf.org/rfc/rfc2616.txt RFC2616: Hypertext Transfer Protocol -- HTTP/1.1])을 UDP로 전송하는 형태의 Protocol입니다. 여기서 UDP는 Unicast와 Broadcast 및 Multicast가 사용될 수 있습니다. 이 문서는 표준을 엄격히 서술하는 것이 아니며 통상적인 범용구현을 위하여 나름 재해석한 내용을 담고 있습니다. 표준과 다른 부분도 있을수 있으니 이점 유념하도록 합니다. === SSDP 기본요건 === SSDP는 HTTP 1.1([^http://www.ietf.org/rfc/rfc2616.txt RFC2616: Hypertext Transfer Protocol -- HTTP/1.1]) 의 4.1 "generic message"를 준수한 header field format 부분을 이용하여 정의되며 TCP대신에 UDP를 사용합니다. (이 문서에서는 UDP를 사용하는 HTTP Protocol을 HTTPU라고 부르기로합니다. - [^https://tools.ietf.org/id/draft-goland-http-udp-00.txt Multicast and Unicast UDP HTTP Messages]) 또한 message body는 사용하지 않지만 만약에 message body가 수신된다면 이를 무시할수 있도록 정의합니다. 각각의 SSDP message는 하나의 시작줄(Start-Line, 첫번째 줄)을 갖어야 하며 적어도 다음의 3가지중 하나이어야 합니다. (공통적으로 "HTTP/1.1"을 포함하여야 하는 것을 알수 있으며 HTTP 1.1 하위 버젼과의 호환성을 유지해야 합니다.) {{{#!plain NOTIFY * HTTP/1.1\r\n M-SEARCH * HTTP/1.1\r\n HTTP/1.1 200 OK\r\n }}} UPnP에서는 BOOTID.UPNP.ORG, CONFIGID.UPNP.ORG, NEXTBOOTID.UPNP.ORG, SEARCHPORT.UPNP.ORG 을 추가적인 SSDP header field 로 정의하고 있으며 하기와 같이 사용자가 추가적으로 정의하여 사용할수 있도록 하고 있습니다. {{{#!plain field-name = token “.” domain-name Example vendor-defined SSDP header fields: myheader.philips.com: “some value” myheader.sony.com: “other value” }}} 어떠한 장비를 검색(Search)하고자 한다면 HTTPU Protocol의 Method를 '''M-SEARCH'''(Multcast 기반의 SSDP) 또는 '''B-SEARCH'''(Broadcast 기반의 SSDP) 로 전송하게 되며 장비 스스로 네트웍에 자신의 정보를 전파(Advertisement)하려면 Method로 '''NOTIFY'''를 사용할 수 있습니다. 탐색을 위해서 Multicast를 사용하게 되는데 '''M-SEARCH''' 는 다음과 같은 Multicase zone과 Port를 사용해야 합니다. * 239.255.255.250:1900 (IPv4 admin-local {{{[local administrative scope]}}}) * [FF02::C]:1900 (IPv6 link-local) * [FF05::C]:1900 (IPv6 site-local) * [FF08::C]:1900 (IPv6 organization-local) * [FF0E::C]:1900 (IPv6 global) 또한 Broadcast를 사용한 '''B-SEARCH''' 는 다음과 같은 Broadcast 주소와 Port를 사용할수도 있습니다. (이 사항은 UPnP에서 확장한 개념인 [^http://developer.lgappstv.com/TV_HELP/index.jsp?topic=%2Flge.tvsdk.references.book%2Fhtml%2FUDAP%2FUDAP%2FM+SEARCH+Request.htm LG의 UDAP protocol]에서 [^http://developer.lgappstv.com/TV_HELP/topic/lge.tvsdk.references.book/html/UDAP/UDAP/Extensions%20B%20SEARCH.htm?path=4_0_0_1_2#_Toc353804387 확장]으로써 정의하고 있습니다.) * 255.255.255.255:1990 (IPv4 broadcast for '''B-SEARCH''') Microsoft의 경우는 Event notification과 Event subscriptions시에는 port번호를 2869번으로 로 사용한다고 알려져 있으며 오래전 구현사항에는 5000을 사용한다고 합니다. ([^http://support.microsoft.com/default.aspx?scid=kb;en-us;832017 참고]) SSDP의 Port 번호는 임의로 바꿀수 있는 방법이 정의되어 있는데 SSDP의 header field 에 SEARCHPORT.UPNP.ORG을 사용하여 나타내 주어야 합니다. === 전파(Advertisement) === * Protocol stack || [wiki:uPnP uPnP (Universal Plug and Play)] Vendor || || [wiki:uPnP uPnP (Universal Plug and Play)] Forum || || [wiki:uPnP uPnP (Universal Plug and Play)] Device Architecture || || SSDP || || UDP || || IP || === 검색(Search) === * 검색요청: Multicast 주소 239.255.255.250:1900 으로 하기포맷에 맞춰서 UDP를 송출하면 해당 송신포트로 UPnP 장비로부터 응답을 받게 됩니다. {{{#!plain M-SEARCH * HTTP/1.1\r\n HOST: 239.255.255.250:1900\r\n MAN: "ssdp:discover"\r\n MX: <호스트로부터 응답에 응할수 있는 초단위의 최대 시간을 지정합니다. 일반적으로 3초 이상을 권장합니다.>\r\n ST: <검색에 대응하는 서비스를 URN형식으로 지정합니다.>\r\n USER-AGENT: / UPnP/1.1 /\r\n \r\n }}} * ST {{{#!plain ssdp:all Search for all devices and services. upnp:rootdevice Search for root devices only. uuid:device-UUID Search for a particular device. device-UUID specified by UPnP vendor. See section 1.1.4, “UUID format and RECOMMENDED generation algorithms” for the MANDATORY UUID format. urn:schemas-upnp-org:device:deviceType:ver Search for any device of this type where deviceType and ver are defined by the UPnP Forum working committee. urn:schemas-upnp-org:service:serviceType:ver Search for any service of this type where serviceType and ver are defined by the UPnP Forum working committee. urn:domain-name:device:deviceType:ver Search for any device of this type where domain-name (a Vendor Domain Name), deviceType and ver are defined by the UPnP vendor and ver specifies the highest supported version of the device type. Period characters in the Vendor Domain Name MUST be replaced with hyphens in accordance with RFC 2141. urn:domain-name:service:serviceType:ver Search for any service of this type where domain-name (a Vendor Domain Name), serviceType and ver are defined by the UPnP vendor and ver specifies the highest supported version of the service type. Period characters in the Vendor Domain Name MUST be replaced with hyphens in accordance with RFC 2141. }}} * 전파(NOTIFY) 예시 {{{#!plain NOTIFY * HTTP/1.1\r\n HOST: 239.255.255.250:1900\r\n CACHE-CONTROL: max-age=120\r\n DATE: Wed, 24 Aug 2016 10:58:00 GMT\r\n LOCATION: http://192.168.13.110:8888/descriptor.xml\r\n SERVER: Linux/2.6.29.6 UPnP/1.1 mzloader/5.0.1.3\r\n NT: urn:schemas-upnp-org:device:MediaServer:1\r\n USN: uuid:2cc2176e-699e-11e6-ef59-ec438b0186a6::urn:schemas-upnp-org:device:MediaServer:1\r\n NTS: ssdp:alive\r\n \r\n }}} * 검색요청(M-SEARCH) 예시 {{{#!plain M-SEARCH * HTTP/1.1\r\n HOST: 239.255.255.250:1900\r\n MAN: "ssdp:discover"\r\n MX: 3\r\n ST: ssdp:all\r\n USER-AGENT: Linux/3.0.0 UPnP/1.1 HWPORT-CLIENT/1.0.0\r\n \r\n }}} * 응답(M-SEARCH Reply) 형식 {{{#!plain HTTP/1.1 200 OK\r\n CACHE-CONTROL: max-age = <호스트의 정보가 유효할수 있는 최대 초단위의 시간이며 172800 보다 크게 지정하도록 한다.>\r\n DATE: <호스트가 응답할때 시점의 시간>\r\n EXT: \r\n LOCATION: <자세한 정보를 제공하는 HTTP접속주소>\r\n SERVER: / UPnP/1.1 /\r\n ST: <요청받았던 ST내용>\r\n USN: <호스트의 서비스에 대응하는 UUID와 ST의 조합>\r\n \r\n }}} * 응답(M-SEARCH Reply) 예시 {{{#!plain HTTP/1.1 200 OK\r\n CACHE-CONTROL: max-age=172800\r\n DATE: Wed Jul 15 10:10:00 2014 GMT\r\n EXT: \r\n LOCATION: http://192.168.13.110:80/upnp/descriptor?target=this.xml\r\n SERVER: Linux/3.0.0-r1 UPnP/1.1 HWPORT-DEVICE/1.0.0\r\n ST: upnp:rootdevice\r\n USN: uuid:862c2cba-65a7-11e4-ad55-000c293e0367::upnp:rootdevice\r\n \r\n }}} * device description (LOCATION에 명시된 HTTP 주소에서 제공하는 XML내용) 예시 {{{#!plain 1 0 http://192.168.13.110:8888/ urn:schemas-upnp-org:device:MediaServer:1 / HWPORT-STB(100006) HWPORT DevGroup http://www.hwport.com/ HWPORT-STB Product HWPORT-STB MODEL HWPORT-STB Series http://www.hwport.com/ 100006 uuid:502245a8-698f-11e6-f089-ec438b0186a6 }}} * 위 예시를 구현하여 탐색기에서 보여지는 모습 [attachment:SSDPTEST.png] == 참고자료 == * [^https://tools.ietf.org/html/draft-cai-ssdp-v1-03 IETF draft: Simple Service Discovery Protocol/1.0] * [wiki:uPnP uPnP (Universal Plug and Play)] * [^http://www.ietf.org/rfc/rfc2616.txt RFC2616: Hypertext Transfer Protocol -- HTTP/1.1] * [^https://tools.ietf.org/id/draft-goland-http-udp-00.txt Multicast and Unicast UDP HTTP Messages] * [^http://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol] * [^http://support.microsoft.com/default.aspx?scid=kb;en-us;832017] * [^http://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt] * [^http://developer.lgappstv.com/TV_HELP/index.jsp?topic=%2Flge.tvsdk.references.book%2Fhtml%2FUDAP%2FUDAP%2FM+SEARCH+Request.htm]