RTC.Blacker

专注RTC和音视频相关领域,支持开源,相关交流请关注微信公众号:blackerteam,或者发邮件到: blacker@rtc.help

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  88 随笔 :: 0 文章 :: 353 评论 :: 86万 阅读

本文主要介绍ICE与SDP交互过程中的一些知识,支持原创,文章来博客园RTC.Blacker,转载请说明出处。

用过libjingle模块的同学都知道连接过程中candidate的获取与连接流程,一边获取candidate,一边进行连接,所以整个过程很快,

但我们有时候用一些其他基于webrtc的产品来测试时发现很久才能看到对方的画面,这是啥原因呢?是不是程序有漏洞?

不是的,主要是他们采用了不同类型的ICE,详细区别见下图:

如上:右边就是libjingle所采用的ICE连接模式,左边是传统模式,主要差别就是candidate获取与建立连接的时间点不一样。

以下是traditional ICE下SDP交互的例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
sdpOffer:v=0
 o=- 1610437942022958275 2 IN IP4 127.0.0.1
 s=-
 t=0 0
 a=group:BUNDLE audio video
 a=msid-semantic: WMS WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs
 m=audio 49290 RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
 c=IN IP4 43.251.159.28
 a=rtcp:49290 IN IP4 43.251.159.28
 a=candidate:4011286938 1 udp 2122260223 172.16.36.4 49290 typ host generation 0
 a=candidate:4011286938 2 udp 2122260223 172.16.36.4 49290 typ host generation 0
 a=candidate:3671821981 1 udp 2122194687 192.168.232.1 49291 typ host generation 0
 a=candidate:3671821981 2 udp 2122194687 192.168.232.1 49291 typ host generation 0
 a=candidate:209874304 1 udp 2122129151 192.168.234.1 49292 typ host generation 0
 a=candidate:209874304 2 udp 2122129151 192.168.234.1 49292 typ host generation 0
 a=candidate:430735571 1 udp 2122063615 192.168.1.102 49293 typ host generation 0
 a=candidate:430735571 2 udp 2122063615 192.168.1.102 49293 typ host generation 0
 a=candidate:2710871402 1 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0
 a=candidate:2710871402 2 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0
 a=candidate:2488824429 1 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0
 a=candidate:2488824429 2 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0
 a=candidate:1107399024 1 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0
 a=candidate:1107399024 2 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0
 a=candidate:1462729763 1 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0
 a=candidate:1462729763 2 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0
 a=candidate:1179184719 1 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0
 a=candidate:1179184719 2 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0
 a=ice-ufrag:8HnoGRmjieejKco5
 a=ice-pwd:acjBERhAuMGJhSKh+QV1RfYc
 a=fingerprint:sha-256 42:01:CE:4C:B3:00:75:C1:3D:71:91:85:55:D9:89:16:1F:F8:DC:13:45:C6:01:20:73:50:3F:68:F7:9B:42:A3
 a=setup:actpass
 a=mid:audio
 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
 a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 a=sendrecv
 a=rtcp-mux
 a=rtpmap:111 opus/48000/2
 a=fmtp:111 minptime=10; useinbandfec=1
 a=rtpmap:103 ISAC/16000
 a=rtpmap:104 ISAC/32000
 a=rtpmap:9 G722/8000
 a=rtpmap:0 PCMU/8000
 a=rtpmap:8 PCMA/8000
 a=rtpmap:106 CN/32000
 a=rtpmap:105 CN/16000
 a=rtpmap:13 CN/8000
 a=rtpmap:126 telephone-event/8000
 a=maxptime:60
 a=ssrc:914767615 cname:I7njJbRyQNJXY+i8
 a=ssrc:914767615 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs fbe366c6-6ac9-44b2-866f-0c629c9d2e45
 a=ssrc:914767615 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs
 a=ssrc:914767615 label:fbe366c6-6ac9-44b2-866f-0c629c9d2e45
 m=video 49290 RTP/SAVPF 100 116 117 96
 c=IN IP4 43.251.159.28
 a=rtcp:49290 IN IP4 43.251.159.28
 a=candidate:4011286938 1 udp 2122260223 172.16.36.4 49290 typ host generation 0
 a=candidate:4011286938 2 udp 2122260223 172.16.36.4 49290 typ host generation 0
 a=candidate:3671821981 1 udp 2122194687 192.168.232.1 49291 typ host generation 0
 a=candidate:3671821981 2 udp 2122194687 192.168.232.1 49291 typ host generation 0
 a=candidate:209874304 1 udp 2122129151 192.168.234.1 49292 typ host generation 0
 a=candidate:209874304 2 udp 2122129151 192.168.234.1 49292 typ host generation 0
 a=candidate:430735571 1 udp 2122063615 192.168.1.102 49293 typ host generation 0
 a=candidate:430735571 2 udp 2122063615 192.168.1.102 49293 typ host generation 0
 a=candidate:2710871402 1 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0
 a=candidate:2710871402 2 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0
 a=candidate:2488824429 1 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0
 a=candidate:2488824429 2 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0
 a=candidate:1107399024 1 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0
 a=candidate:1107399024 2 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0
 a=candidate:1462729763 1 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0
 a=candidate:1462729763 2 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0
 a=candidate:1179184719 1 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0
 a=candidate:1179184719 2 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0
 a=ice-ufrag:8HnoGRmjieejKco5
 a=ice-pwd:acjBERhAuMGJhSKh+QV1RfYc
 a=fingerprint:sha-256 42:01:CE:4C:B3:00:75:C1:3D:71:91:85:55:D9:89:16:1F:F8:DC:13:45:C6:01:20:73:50:3F:68:F7:9B:42:A3
 a=setup:actpass
 a=mid:video
 a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
 a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 a=sendrecv
 a=rtcp-mux
 a=rtpmap:100 VP8/90000
 a=rtcp-fb:100 ccm fir
 a=rtcp-fb:100 nack
 a=rtcp-fb:100 nack pli
 a=rtcp-fb:100 goog-remb
 a=rtpmap:116 red/90000
 a=rtpmap:117 ulpfec/90000
 a=rtpmap:96 rtx/90000
 a=fmtp:96 apt=100
 a=ssrc-group:FID 1771045130 811642261
 a=ssrc:1771045130 cname:I7njJbRyQNJXY+i8
 a=ssrc:1771045130 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs 79fdc2d6-85c1-4d67-bd7e-44bbe6334926
 a=ssrc:1771045130 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs
 a=ssrc:1771045130 label:79fdc2d6-85c1-4d67-bd7e-44bbe6334926
 a=ssrc:811642261 cname:I7njJbRyQNJXY+i8
 a=ssrc:811642261 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs 79fdc2d6-85c1-4d67-bd7e-44bbe6334926
 a=ssrc:811642261 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs
 a=ssrc:811642261 label:79fdc2d6-85c1-4d67-bd7e-44bbe6334926
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
sdpAnser:v=0
 o=- 1610437942022958275 0 IN IP4 0.0.0.0
 s=Kurento Media Server
 c=IN IP4 0.0.0.0
 t=0 0
 a=group:BUNDLE audio video
 m=audio 49350 RTP/SAVPF 111 0
 c=IN IP4 115.28.63.56
 a=rtpmap:111 opus/48000/2
 a=rtpmap:0 PCMU/8000
 a=sendrecv
 a=rtcp:49350 IN IP4 115.28.63.56
 a=rtcp-mux
 a=ssrc:4085612173 cname:user2766977916@host-c2a1d0bb
 a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 a=mid:audio
 a=ice-ufrag:k69i
 a=ice-pwd:2OEh/hwoKondNA67xmXQ1s
 a=fingerprint:sha-256 00:C2:77:EF:2C:B1:73:01:10:29:3D:53:AB:81:29:59:F3:AA:9A:EB:91:B9:A8:F1:16:12:2D:6C:5A:5D:78:B2
 a=candidate:1 1 UDP 2013266431 115.28.63.56 49350 typ host
 a=candidate:2 1 UDP 2013266431 10.144.37.152 58353 typ host
 m=video 49350 RTP/SAVPF 100
 c=IN IP4 115.28.63.56
 b=AS:500
 a=rtpmap:100 VP8/90000
 a=sendrecv
 a=rtcp-fb:100 ccm fir
 a=rtcp-fb:100 nack
 a=rtcp-fb:100 nack pli
 a=rtcp-fb:100 goog-remb
 a=rtcp:49350 IN IP4 115.28.63.56
 a=rtcp-mux
 a=ssrc:1728895 cname:user2766977916@host-c2a1d0bb
 a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 a=mid:video
 a=ice-ufrag:k69i
 a=ice-pwd:2OEh/hwoKondNA67xmXQ1s
 a=fingerprint:sha-256 00:C2:77:EF:2C:B1:73:01:10:29:3D:53:AB:81:29:59:F3:AA:9A:EB:91:B9:A8:F1:16:12:2D:6C:5A:5D:78:B2
 a=candidate:1 1 UDP 2013266431 115.28.63.56 49350 typ host
 a=candidate:2 1 UDP 2013266431 10.144.37.152 58353 typ host
  
SDP answer received, setting remote description

搞懂了这两者的区别,相信对你理解ICE和SDP会有所帮助!

 

posted on   RTC.Blacker  阅读(5163)  评论(6编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示