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
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.4k
開放街圖 自助旅行的好幫手
wen_liao
0
1.2k
GNU AS簡介
wen_liao
0
1.1k
自由軟體和 Richard Stallman
wen_liao
0
2.2k
Hello world在那邊?背景說明 0
wen_liao
0
690
A successful Git branching model 導讀
wen_liao
0
630
GNU ld的linker script簡介
wen_liao
0
1k
Trace 程式碼之皮
wen_liao
0
840
淺談Debian套件打包
wen_liao
0
470
Other Decks in Technology
See All in Technology
自動生成を活用した、運用保守コストを抑える Error/Alert/Runbook の一元集約管理 / Centralized management of Error/Alert/Runbook to minimize operational costs using automated code generation
biwashi
9
2.1k
ユーザーストーリーのレビューを自動化したみたの
bun913
1
300
Janus
bkuhlmann
0
490
コンパウンドスタートアップのためのスケーラブルでセキュアなInfrastructure as Codeパイプラインを考える / Scalable and Secure Infrastructure as Code Pipeline for a Compound Startup
yuyatakeyama
3
1.8k
最近たまに見かけるTiDBってなんだ? - Findy
pingcap0315
2
520
開発生産性向上サービスを作るFindyが自分たちで開発生産性を爆上げした組織づくりの歩み / Findy's path to boosting its own development productivity 2024-04-17
ma3tk
1
290
Databricks における 『MLOps』
databricksjapan
2
130
o11y入門_外形監視を利用したWebアプリケーションへの最適なモニタリング_TechBrew
k5k
2
100
転移学習とドメイン適応の基礎
kmatsui
2
570
NLP2024 参加報告LT ~RAGの生成評価と懇親戦略~ / nlp2024_attendee_presentation_LT_masuda
taro_masuda
1
190
4年前、あるじゃん老害エンジニアLT合戦に登壇、米国西海岸コンピュータ歴史博物館体験記の続編
toshi_atsumi
0
190
AWS を使う上で知っておきたいオンプレミス知識/aws-on-premise-essentials
emiki
1
4.1k
Featured
See All Featured
A better future with KSS
kneath
230
16k
Being A Developer After 40
akosma
56
580k
GraphQLとの向き合い方2022年版
quramy
30
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
124
32k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Rails Girls Zürich Keynote
gr2m
91
13k
Building a Scalable Design System with Sketch
lauravandoore
455
32k
Music & Morning Musume
bryan
40
5.6k
Into the Great Unknown - MozCon
thekraken
10
980
Building Better People: How to give real-time feedback that sticks.
wjessup
353
18k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
20
1.6k
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