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.2k
GNU AS簡介
wen_liao
0
1.2k
自由軟體和 Richard Stallman
wen_liao
0
2.3k
Hello world在那邊?背景說明 0
wen_liao
0
740
A successful Git branching model 導讀
wen_liao
0
670
GNU ld的linker script簡介
wen_liao
0
1.3k
Trace 程式碼之皮
wen_liao
0
890
淺談Debian套件打包
wen_liao
0
600
Other Decks in Technology
See All in Technology
Observability infrastructure behind the trillion-messages scale Kafka platform
lycorptech_jp
PRO
0
140
強化されたAmazon Location Serviceによる新機能と開発者体験
dayjournal
2
210
Navigation3でViewModelにデータを渡す方法
mikanichinose
0
220
Windows 11 で AWS Documentation MCP Server 接続実践/practical-aws-documentation-mcp-server-connection-on-windows-11
emiki
0
960
Clineを含めたAIエージェントを 大規模組織に導入し、投資対効果を考える / Introducing AI agents into your organization
i35_267
4
1.6k
250627 関西Ruby会議08 前夜祭 RejectKaigi「DJ on Ruby Ver.0.1」
msykd
PRO
2
270
rubygem開発で鍛える設計力
joker1007
2
200
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
3
470
生成AI活用の組織格差を解消する 〜ビジネス職のCursor導入が開発効率に与えた好循環〜 / Closing the Organizational Gap in AI Adoption
upamune
1
810
Microsoft Build 2025 技術/製品動向 for Microsoft Startup Tech Community
torumakabe
2
260
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
29
11k
How Community Opened Global Doors
hiroramos4
PRO
1
120
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
4 Signs Your Business is Dying
shpigford
184
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
For a Future-Friendly Web
brad_frost
179
9.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
We Have a Design System, Now What?
morganepeng
53
7.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
330
24k
Six Lessons from altMBA
skipperchong
28
3.8k
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