Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
UPnP 1.0 簡介
Search
Wen_Liao
June 11, 2015
Technology
0
1.1k
UPnP 1.0 簡介
UPnP 1.0 簡介,歡迎Debug
Wen_Liao
June 11, 2015
Tweet
Share
More Decks by Wen_Liao
See All by Wen_Liao
COSCUP-2020-Linux 軟體組裝工和他的工具們
wen_liao
2
1.5k
開放街圖 自助旅行的好幫手
wen_liao
0
1.3k
GNU AS簡介
wen_liao
0
1.2k
自由軟體和 Richard Stallman
wen_liao
0
2.3k
Hello world在那邊?背景說明 0
wen_liao
0
750
A successful Git branching model 導讀
wen_liao
0
680
GNU ld的linker script簡介
wen_liao
0
1.3k
Trace 程式碼之皮
wen_liao
0
900
淺談Debian套件打包
wen_liao
0
620
Other Decks in Technology
See All in Technology
Shirankedo NOCで見えてきたeduroam/OpenRoaming運用ノウハウと課題 - BAKUCHIKU BANBAN #2
marokiki
0
180
Where will it converge?
ibknadedeji
0
200
【Oracle Cloud ウェビナー】クラウド導入に「専用クラウド」という選択肢、Oracle AlloyとOCI Dedicated Region とは
oracle4engineer
PRO
3
130
「AI駆動PO」を考えてみる - 作る速さから価値のスループットへ:検査・適応で未来を開発 / AI-driven product owner. scrummat2025
yosuke_nagai
3
810
英語は話せません!それでも海外チームと信頼関係を作るため、対話を重ねた2ヶ月間のまなび
niioka_97
0
130
GoでもGUIアプリを作りたい!
kworkdev
PRO
0
130
自動テストのコストと向き合ってみた
qa
0
220
AWS Top Engineer、浮いてませんか? / As an AWS Top Engineer, Are You Out of Place?
yuj1osm
2
210
AI駆動開発を推進するためにサービス開発チームで 取り組んでいること
noayaoshiro
0
250
能登半島地震で見えた災害対応の課題と組織変革の重要性
ditccsugii
0
420
AI時代こそ求められる設計力- AWSクラウドデザインパターン3選で信頼性と拡張性を高める-
kenichirokimura
3
290
成長自己責任時代のあるきかた/How to navigate the era of personal responsibility for growth
kwappa
4
310
Featured
See All Featured
How to Ace a Technical Interview
jacobian
280
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
30
2.7k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
The Language of Interfaces
destraynor
162
25k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
54
3k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
Code Reviewing Like a Champion
maltzj
526
40k
What's in a price? How to price your products and services
michaelherold
246
12k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Transcript
Wen Liao UPnP 1.0 簡介 台北市
Disclaimer 投影片資料為作者整理資料及個人意見,沒有經 過嚴謹確認,請讀者自行斟酌
測試環境
測試環境
測試環境
None
測試環境
關於UPnP • Universal Plug and Play ◦ 一種網路通訊協定 ◦ 目的:萬用遙控器
▪ 不用安裝Driver ▪ 不用安裝指定的軟體 ▪ 適用於所有支援UPnP的設備
萬用遙控器?? http://en.wikipedia.org/wiki/File:Remote_controls.JPG
萬用遙控器要處理的問題 • 以家電的遙控器比喻 ◦ 每個家電按鈕不同,功能不同,使用方式不同 ▪ 就算同一種家電,不同廠牌,甚至同廠牌不同型號 一樣有相同的問題 ◦ 要怎麼知道現在有那幾台設備可以用?
▪ A牌電風扇 ▪ B牌播放器 ▪ C牌電燈 ◦ 要怎麼知道設備狀態?
每個家電按鈕不同,功能不同,使用方式 不同 • 大家講好規矩 • 主導者:UPnP forum ▪ 很多大頭 ◦
規範Device control protocols ▪ AV ▪ 電燈控制 ▪ 印表機 ▪ …
要怎麼知道現在有那幾台設備可以用? • 遙控器大喊一聲看誰答話 • 設備有事沒事跟大家說我還活著,以及提供的 服務
要怎麼知道設備狀態? • 遙控器直接問 • 遙控器告訴設備說哪些狀態更動的時候要跟 我說,如 ◦ 播放器更動播放內容 ◦ ...
觀念 • 整個控制可以分成兩個角色 ◦ 遙控器 ◦ 設備 • 遙控器的按鈕,可以看成呼叫服務 ◦
將溫度設定成25度 ◦ 切到下一個頻道 • 接樓上,所以這是一個遠端呼叫的概念。洋人 的話就是remote procedure call,簡稱RPC
進入正題
正名 • Control point ◦ 你的遙控器啦 • Device ◦ 被遙控的東西
UPnP Networks Steps Addressing Discover Description Event Presentation http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/ Control
什麼鬼?請講中文好嘛?
講中文:Control point篇 • 知道自己在那邊。(跳過Auto IP,一言難盡) • 先知道自己是啥,以媒體播放器(media render)為例 ◦ 問看看網路上有沒有媒體播放器,有的請發聲
◦ 當然不是問完以後就沒事,搞不好上線後十三分鐘後 有另外一個媒體播放器上線,你也得知道吧? • 從剛才報數的媒體播放器中知道他有提供哪 些服務。 • 開工如訂閱媒體播放器的播放狀態、播放影 片,調整音量等 • Presentation呢?沒這東西(煙)
講中文:Device篇 • 知道自己在那邊。(跳過Auto IP,一言難盡) • 先知道自己是啥,以媒體播放器(media render)為例 ◦ 定期公佈,告訴大家,我是是媒體播放器唷。以下是我 的服務...
◦ 有人來問你是不是媒體播放器要回答我是 • 開工如處理播放影片,調整音量,接受訂閱 event當trigger時通知control point等 • Presentation呢?看實作,有的話,你可以用瀏 覽器連上去更改一些設定
名詞 • HTTP ◦ Hypertext Transfer Protocol • HTTPU ◦
U就是UDP • HTTPMU ◦ M是Multicast ◦ U還是UDP • HTTPD ◦ Daemon ,就是web server
名詞 • SSDP ◦ Simple Service Discovery Protocol • SOAP
◦ Simple Object Access protocol • GENA ◦ General Event Notification Architecture
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries 使用XML描述呼叫 遠端服務以及回傳 的結果 http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries 註冊要監聽的event以 及當event被觸發回傳 使用的通訊協定 http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries Device有設定Presentation URL的話總要有個提供網 頁的web server吧? http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries 通知大家 • Control point: ◦ 哪邊有「我要的服務」的device?有的話 該一聲 • Device ◦ 我還沒死 ◦ 我要閃人了 http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
無聊的方塊圖 TCP IP UDP HTTP HTTPU HTTPMU SOAP GENA HTTPD
SSDP UPnP Device Architecture Device Control Protocols APP/Libraries Device 回應 control point的詢問 http://upnp.org/sdcps-and-certification/standards/device-architecture-documents/
沒fu? 來看範例
Step 1: Control point 找到 Device
場景一:Device 自行宣傳
None
6個封包?那6個? • UPnP規範,device 自我宣傳要有 ◦ 3個root device ◦ 任意個embedded device
(不討論) ◦ 任意個service
來看封包: 淺紅底文字的是發送端封包 內容
Notification type Device advertisement: root device (1) Notification sub type
Unique service name Root device description URL!
Device advertisement: root device (2) UUID
Device advertisement: root device (3) device type
Device advertisement: AVT service
Device advertisement: CM service
Device advertisement: RCS service
場景二:Control point自 己問
None
None
Control point Device
先看Control Point封包
等待秒數 Search type: 這邊全找,也可以指定 特定type
插花:指名MediaServer和 MediaRender坐檯 (各一個封包)
再看Device response
Device response順序和 自我宣傳差別只有NT換 成ST以及沒有NTS描述 • NT: Notification type • ST:
Service type • NTS: Notification sub type
Service type Device response: root device (1)
Device response: root device (2)
Device response: root device (3)
Device response: AVT service
Device response: CM service
Device response: RCS service
場景三:Device 離線
基本上就是把場景一的keep alive換成 byebye。另外有規範要送超過兩次以避 免漏掉。 Device offline: root device (1)
Device offline: root device (2)
Device offline: root device (3)
Device offline: AVT Service
Device offline: CM Service
Device offline: RCS Service
Step 2: Control point 取得 Device資訊
很簡單,前面的封包都 有Location URL。 用瀏覽器開一下吧
UPnP 架構版號 Device 描述
UPnP 架構版本
Device描述 • 設備類型 • 產品資訊 • 辨別UUID • 提供服務 •
….
提供Icon給control point使用
None
提供的服務:AVT, CM, RCS
服務提供的資訊 Type 和ID使用UPnP 定的標準要遵守規範
服務提供的資訊 真正描述提供服務的 地方
服務提供的資訊 你要送命令的URL
服務提供的資訊 c 訂閱要監聽event的 URL
有Action name和paramter,像不像 function call啊? 開啟scpd.xml URL
來看封包: 淺紅底文字的是發送端封包 內容 淺藍底文字的是接收端 封包內容
Control point取得 Location URL HTTP GET HTTP Response Device description
Control point取得AVT的服務描述 HTTP GET HTTP Response Device description
device 服 務 視 覺 化
Step 3: Control point 控制 Device
以GetTransportInfo為例 參數 Instance ID 回傳目前 state、status和 播放速度
按下這個送出request 後的畫面
來看封包: 淺紅底文字的是發送端封包 內容 淺藍底文字的是接收端 封包內容
看封包時間:Contronl point的action Post到描述XML指定的control URL Action name 參數: Instance ID:0
看封包時間:Device repsonse 回傳state為Stop 回傳狀態為OK 播放速度為1
Step 3: Control point 取得 Device event資訊
直接看封包: 淺紅底文字的是發送端封包 內容 淺藍底文字的是接收端 封包內容
Control point 訂閱監聽事件 告訴Device event要往那 邊送 Subscription ID 還記得EventSubURL嗎?
Device 送出event,Control point回應 Subscription ID和上 頁相同 資料變動
Device 停止播放送出event,Control point回應 資料變動 Subscription ID和上 頁相同
Control point可以放棄註冊 還記得EventSubURL嗎? 要unsubscribe的 ID
總結 • UPnP 提供預先定義好的規範,讓不同的是設 備不需要驅動程式,特殊軟體就可以透過網路 操作 • UPnP透過SSDP讓control point能夠找出網路 的Device
• UPnP透過GENA讓control point能夠被動接受 device送出來的事件
參考資料 • UPnP Forum 文件 ◦ 包含MediaRender