This translation is older than the original page and might be outdated. See what has changed.

IPTV / UDP-Multicast

Viele Provider vertreiben IPTV-Services, normalerweise per IPv4-Multicast. Diese Seite soll dabei helfen, “Standard”-Setups herzustellen.

Wenn ein Host UDP-Multicast-Pakete empfangen will, muss dieser der sogenannten “UDP-Multicast-Gruppe” beitreten. Genau das wird durch das IGMP-Protokoll definiert. Wenn ein Host dieser Gruppe beigetreten ist, wird der gesamte Netzwerkverkehr durch broadcast L2 frames an diese Gruppe gesendet. Dieses Detail ist wichtig, denn gewöhnliche Netzwerkbrücken geben alle Datenpakete an alle Ports weiter. So if you use Linux to bridge wireless and wired networks (usual scenario for home LANs) and you subscribe to a multicast group from one of the wired clients, the wireless will be hogged too. Luckily, starting from 2.6.34, the kernel has IGMP snooping feature for the software bridges (disabled by default in OpenWrt) which should prevent unnecessary traffic on ports that were not actually subscribing.

Another important consideration is that multicasting over wireless doesn't usually work as one might expect since it uses the lowest possible bitrate (to enable all clients to “hear” it) and also employs special tricks for power-saving. Basically, this makes multicasting useless for IPTV.

Thanks to IGMP snooping, igmpproxy should no longer cause wifi hogging and so you can have both igmpproxy and udpxy configured and running, accessing IPTV over wifi with udpxy when needed.

Please note, that IGMP snooping is only available when kmod-bridge package is installed.

If your client is behind NAT, it can't subscribe to multicast directly, so it needs some kind of proxy to do it for him. OpenWrt comes with igmpproxy utility to do that automatically.

First you need to install package - opkg install igmpproxy

You need to edit /etc/config/igmpproxy.conf according to your setup:

config igmpproxy
        option quickleave 1

config phyint
        option network wan
        option direction upstream
        list altnet 10.254.0.0/16

config phyint
        option network lan
        option direction downstream

If you're not sure what to specify for altnet, comment it out and look for the igmpproxy output in the log (or on stdout if you start it in debug mode - you can simply test by igmpproxy -d /etc/igmpproxy.conf), it'll say something like Warn: The source address 10.254.16.66 for group 233.32.240.222, is not in any valid net for upstream VIF. and so you'll learn the multicast source address for your ISP.

Firewall

You also need to allow IGMP from wan interface and to forward multicast traffic by something like this:

config rule
        option src      wan
        option proto    igmp
        option target   ACCEPT
config rule
        option src      wan
        option proto    udp
        option dest     lan
        option dest_ip  224.0.0.0/4
        option target   ACCEPT
        option family   ipv4

This is an alternative way which allows you to access udp multicast streams over TCP connection. As such, it works nicely both over wired and wireless links.

You can start it with something like:

#!/bin/sh /etc/rc.common
# Copyright (C) 2010 OpenWrt.org

START=99
STOP=10

IGMP_OPTS="-p 8080 -a 192.168.2.1"
IGMP_BIN="/usr/bin/udpxy"
PID_F="/var/run/udpxy.pid"

start() {
        echo "Starting udpxy"
        start-stop-daemon -S -x $IGMP_BIN -p $PID_F -b -m -- $IGMP_OPTS
}

stop() {
        echo "Stopping udpxy"
        start-stop-daemon -K -x $IGMP_BIN -p $PID_F -q
}

This tells udpxy to use port 8080 to accept http connections and to bind to interface which has 192.168.2.1 address (br-lan in my case).

Now when you want to access e.g. rtp://@239.64.64.58:1234 , you can tell your player to connect to http://192.168.2.1:8080/udp/239.64.64.58:1234 and it'll just work.

Firewall

As with igmpproxy you need to accept IGMP traffic and also you need to allow it for INPUT:

config rule
        option src      wan
        option proto    igmp
        option target   ACCEPT
config rule
        option src      wan
        option proto    udp
        option dest_ip  224.0.0.0/4
        option target   ACCEPT

Using igmpproxy and udpxy together

When using igmpproxy together with udpxy, firewall rules must be combined. You need three firewall rules:

config rule
        option src      wan
        option proto    igmp
        option target   ACCEPT
config rule
        option src      wan
        option proto    udp
        option dest     lan
        option dest_ip  224.0.0.0/4
        option target   ACCEPT
config rule
        option src      wan
        option proto    udp
        option dest_ip  224.0.0.0/4
        option target   ACCEPT

With IGMP snooping, multicast forwarding is disabled for bridges. One pure bridge solution is to disable multicast_snooping.

Add the following in /etc/rc.local

echo "0" > /sys/devices/virtual/net/br-lan/bridge/multicast_snooping

Replace br-lan with your actual bridge interface, sometimes also called br0.

This will forward all multicast packets to all ports on your bridge, making igmpproxy or udpxy unnecessary. In large networks, this may not be desirable.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2018/06/07 19:12
  • by tmomas