Fundatmental of Multicast

setting up multicast broadcast vlc video and verifying multicast traffic.

image loading ...

What is Multicast?

Multicast IP addresses fall under Class D (224.0.0.0/4). They are not assigned to individual devices but are used to identify multicast groups. Multicast is a method of communication where data is sent from one sender to multiple receivers in a network, but only to those who are interested in receiving it. This is different from unicast (one-to-one communication) and broadcast (one-to-all communication).

In IPv4, multicast addresses range from 224.0.0.0 to 239.255.255.255. These addresses are reserved for multicast groups.

image loading ...

Example: 224.0.0.1 is used for all systems on a subnet, while 224.0.0.5 is used by OSPF (Open Shortest Path First) routers.

Multicast Protocols

IGMP (Internet Group Management Protocol)

Manages the membership of hosts in a multicast group. Routers use IGMP to learn which hosts on their network wish to receive multicast traffic. IGMP has three versions (IGMPv1, IGMPv2, IGMPv3) with increasing functionality and flexibility.

PIM (Protocol Independent Multicast)

PIM is used to route multicast traffic between routers. It operates independently of any specific routing protocol.

Dense Mode (PIM-DM)` Assumes that all routers want to receive multicast traffic, flooding the network and then pruning branches where multicast traffic is not needed.

Sparse Mode (PIM-SM): Assumes that most routers do not want to receive multicast traffic. Traffic is only sent to routers that specifically request it, making it more efficient for large networks.

Multicast routing

Multicast Forwarding

Multicast traffic is forwarded through the network using multicast routing protocols like PIM. The data is replicated at routers as needed to reach multiple receivers.

Reverse Path Forwarding (RPF)

Ensures that multicast traffic is only forwarded along the best path back to the source, preventing loops and ensuring efficient delivery.

Example: Multicast in Action

Scenario: You are setting up a multicast network to stream a live event to multiple viewers. Your goal is to ensure that only those viewers who request the stream receive the data.

Steps Assign a Multicast Address / enable IGMP / Configure PIM

Configuring multicast on Cisco routers, including setting up PIM, configuring RP (Rendezvous Points), and verifying multicast traffic. Choose a multicast IP address for your stream, such as 239.2.2.2. Configure your routers to use IGMP so that they can track which hosts on each subnet want to receive the multicast stream.Enable PIM-SM on your routers to efficiently route the multicast traffic to only those routers that have requested it.

Router(config)# ip multicast-routing
Router(config-if)# int eth0/0
Router(config-if)# ip igmp version 3
Router(config-if)# ip pim sparse-mode
Router(config)# ip pim rp-address <RP-IP-Address>
 

Useful Commands:

Check PIM Neighbors: Displays a list of PIM neighbors, confirming that routers are communicating multicast information.

Router# show ip pim neighbor
 
PIM Neighbor Table
Mode: B - Bidir Capable, DR - Designated Router, N - Default DR Priority,
      P - Proxy Capable, S - State Refresh Capable, G - GenID Capable,
      L - DR Load-balancing Capable
Neighbor          Interface                Uptime/Expires    Ver   DR
Address                                                            Prio/Mode
192.168.1.1       Ethernet0/3              00:00:13/00:01:31 v2    1 / S P G
 
PIM Neighbor Table
Mode: B - Bidir Capable, DR - Designated Router, N - Default DR Priority,
      P - Proxy Capable, S - State Refresh Capable, G - GenID Capable,
      L - DR Load-balancing Capable
Neighbor          Interface                Uptime/Expires    Ver   DR
Address                                                            Prio/Mode
192.168.1.2       Ethernet0/3              00:27:26/00:01:21 v2    1 / DR S P G
 
Router# show ip mroute
 
IP Multicast Routing Table
Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected,
       L - Local, P - Pruned, R - RP-bit set, F - Register flag,
       T - SPT-bit set, J - Join SPT, M - MSDP created entry, E - Extranet,
       X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement,
       U - URD, I - Received Source Specific Host Report, 
       Z - Multicast Tunnel, z - MDT-data group sender, 
       Y - Joined MDT-data group, y - Sending to MDT-data group, 
       G - Received BGP C-Mroute, g - Sent BGP C-Mroute, 
       N - Received BGP Shared-Tree Prune, n - BGP C-Mroute suppressed, 
       Q - Received BGP S-A Route, q - Sent BGP S-A Route, 
       V - RD & Vector, v - Vector, p - PIM Joins on route, 
       x - VxLAN group
Outgoing interface flags: H - Hardware switched, A - Assert winner, p - PIM Join
 Timers: Uptime/Expires
 Interface state: Interface, Next-Hop or VCD, State/Mode
 
(*, 224.0.1.40), 00:01:32/00:02:01, RP 0.0.0.0, flags: DCL
  Incoming interface: Null, RPF nbr 0.0.0.0
  Outgoing interface list:
    Ethernet0/3, Forward/Sparse, 00:01:30/00:02:01
 
(*, 224.0.1.40), 00:03:23/00:02:37, RP 192.168.1.1, flags: SJPCL
  Incoming interface: Ethernet0/3, RPF nbr 192.168.1.1
  Outgoing interface list: Null
 
Router# show ip igmp groups
 
IGMP Connected Group Membership
Group Address    Interface                Uptime    Expires   Last Reporter   Group Accounted
224.0.1.40       Ethernet0/3              00:02:14  00:02:19  192.168.1.2  
Router# show ip pim rp mapping
 
PIM Group-to-RP Mappings
 
Group(s): 224.0.0.0/4, Static
    RP: 192.168.1.1 (?)
Router# show ip igmp interface
 
Ethernet0/3 is up, line protocol is up
  Internet address is 192.168.1.2/24
  IGMP is enabled on interface
  Current IGMP host version is 3
  Current IGMP router version is 3
  IGMP query interval is 60 seconds
  IGMP configured query interval is 60 seconds
  IGMP querier timeout is 120 seconds
  IGMP configured querier timeout is 120 seconds
  IGMP max query response time is 10 seconds
  Last member query count is 2
  Last member query response interval is 1000 ms
  Inbound IGMP access group is not set
  IGMP activity: 1 joins, 0 leaves
  Multicast routing is enabled on interface
  Multicast TTL threshold is 0
  Multicast designated router (DR) is 192.168.1.2 (this system)
  IGMP querying router is 192.168.1.1  
  Multicast groups joined by this system (number of users):
      224.0.1.40(1)

Test the Multicast Stream:

Use tools like VLC or multicast testing utilities to join the multicast group at 239.1.1.1 and verify that the stream is being delivered only to those hosts that request it.

Linux Multicast Tools

multicast tools available in Linux, including multicat, smcroute, and mcast for sending and receiving multicast streams.

Clear PIM Cache and Reset PIM

Router# clear ip pim rp-mapping
Router# clear ip pim neighbor
Router# clear ip pim interface ethernet 0/3 count

Create a Dockerized FFmpeg Container

# Dockerfile
 
FROM jrottenberg/ffmpeg:latest
 
# Example entrypoint for FFmpeg multicast streaming
ENTRYPOINT ["ffmpeg"]

Build the image docker build -t ffmpeg-multicast .

docker run --rm -it \
  --network host \
  -v ./:/media \
  ffmpeg-multicast \
  -re -stream_loop -1 -i /media/video.mp4 \
  -c:v libx264 -f mpegts "udp://239.1.1.1:1234?ttl=1"
 
vlc udp://@239.1.1.1:1234

kernel: iptables drops: IN=wlan0 OUT= MAC= SRC=10.8.8.8 DST=239.1.1.1 LEN=1500 TOS=0x00 PREC=0x00 TTL=1 ID=2717 DF PROTO=UDP SPT=42159 DPT=1234 LEN=1480

Reference

Multicat - multicast video

RFC 2365 - Administratively Scoped IP Multicast