安装pimd

1
apt install pimd

拓扑

TOPO

配置ospf

参考《linux网络1_ospf》分别对routeA和routeB进行ospf功能配置,或者设置默认路由,使得组播源、接收端1、接收端2这三者之间能两两相互ping通

搭建组播源与接收端

参考《vlc组播测试Server及Client使用》

配置RouterA

1
2
3
4
5
6
7
8
9
10
11
# root @ routerA in / [14:27:40]
$ grep -v "^#" /etc/pimd.conf
phyint eth2 disable #重要:关掉不参与组播功能的端口,免得影响组播
phyint eth3 disable #重要:关掉不参与组播功能的端口,免得影响组播
phyint eth4 disable #重要:关掉不参与组播功能的端口,免得影响组播
bsr-candidate priority 5
rp-candidate time 30 priority 20 #动态选举汇聚点RP路由器(也可设置为静态RP,但所有路由必须设置同一个)
spt-threshold packets 0 interval 100

# root @ routerA in / [14:27:47]
$ systemctl restart pimd.service

配置RouterB

1
2
3
4
5
6
7
8
9
10
11
# root @ routerB in / [14:33:40]
$ grep -v "^#" /etc/pimd.conf
phyint eth2 disable #重要:关掉不参与组播功能的端口,免得影响组播
phyint eth3 disable #重要:关掉不参与组播功能的端口,免得影响组播
phyint eth4 disable #重要:关掉不参与组播功能的端口,免得影响组播
bsr-candidate priority 5
rp-candidate time 30 priority 20 #动态选举汇聚点RP路由器(也可设置为静态RP,但所有路由必须设置同一个)
spt-threshold packets 0 interval 100

# root @ routerB in / [14:33:47]
$ systemctl restart pimd.service

调试

1
2
$ journalctl -u pimd.service
...

查看结果

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
# root @ routerA in / [15:04:54]
$ ip mroute show to 239.255.255.249
(10.2.1.2, 239.255.255.249) Iif: eth0 Oifs: eth1

# root @ routerA in / [15:05:01]
$ pimd --show-routes
Virtual Interface Table ======================================================
Vif Local Address Subnet Thresh Flags Neighbors
--- --------------- ------------------ ------ --------- -----------------
0 10.2.1.1 10.2.1/24 1 DR NO-NBR
1 30.1.1.2 30.1.1/24 1 DR PIM 30.1.1.1
2 192.168.255.1 192.168.255 1 DISABLED
3 10.2.1.1 register_vif0 1

Vif SSM Group Sources

Multicast Routing Table ======================================================
----------------------------------- (*,G) ------------------------------------
Source Group RP Address Flags
--------------- --------------- --------------- ---------------------------
INADDR_ANY 239.255.255.249 30.1.1.2 WC RP
Joined oifs: ....
Pruned oifs: ....
Leaves oifs: .l..
Asserted oifs: ....
Outgoing oifs: .o..
Incoming : ...I

TIMERS: Entry JP RS Assert VIFS: 0 1 2 3
0 45 0 0 0 0 0 0
----------------------------------- (S,G) ------------------------------------
Source Group RP Address Flags
--------------- --------------- --------------- ---------------------------
10.2.1.2 239.255.255.249 30.1.1.2 SPT CACHE SG
Joined oifs: ....
Pruned oifs: ....
Leaves oifs: .l..
Asserted oifs: ....
Outgoing oifs: .o..
Incoming : I...

TIMERS: Entry JP RS Assert VIFS: 0 1 2 3
175 30 0 0 0 0 0 0
...

routerA的组播路由表出现了 (10.2.1.2, 239.255.255.249) Iif: eth0 Oifs: eth1

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
# root @ routerB in / [15:08:16]
$ ip mroute show to 239.255.255.249
(30.1.1.2, 239.255.255.249) Iif: eth1 Oifs: eth0

# root @ routerB in / [15:10:21]
$ pimd --show-routes
Virtual Interface Table ======================================================
Vif Local Address Subnet Thresh Flags Neighbors
--- --------------- ------------------ ------ --------- -----------------
0 10.1.1.1 10.1.1/24 1 DR NO-NBR
1 30.1.1.1 30.1.1/24 1 PIM 30.1.1.2
2 192.168.20.1 192.168.20 1 DISABLED
3 192.168.30.1 192.168.30 1 DISABLED
4 10.1.1.1 register_vif0 1

Vif SSM Group Sources

Multicast Routing Table ======================================================
----------------------------------- (*,G) ------------------------------------
Source Group RP Address Flags
--------------- --------------- --------------- ---------------------------
INADDR_ANY 239.255.255.249 30.1.1.2 WC RP
Joined oifs: .....
Pruned oifs: .....
Leaves oifs: l....
Asserted oifs: .....
Outgoing oifs: o....
Incoming : .I...

TIMERS: Entry JP RS Assert VIFS: 0 1 2 3 4
0 40 0 0 0 0 0 0 0
----------------------------------- (S,G) ------------------------------------
Source Group RP Address Flags
--------------- --------------- --------------- ---------------------------
30.1.1.2 239.255.255.249 30.1.1.2 SPT CACHE SG
Joined oifs: .....
Pruned oifs: .....
Leaves oifs: l....
Asserted oifs: .....
Outgoing oifs: o....
Incoming : .I...

TIMERS: Entry JP RS Assert VIFS: 0 1 2 3 4
190 45 0 0 0 0 0 0 0

routerB的组播路由表出现了 (30.1.1.2, 239.255.255.249) Iif: eth1 Oifs: eth0

备注:可以看到routerA和routerB的汇聚点选举结果为 RP Address:30.1.1.2

测试组播通路

接收端1和接收端2上面的vlc都能播放udp://@239.255.255.249:1249的视频。