LAN Audio

Pulseaudio set to RTP send
Couple of clients Pulseaudio set to RTP recieve

Issues

The bones of the setup work correctly, i.e. the audio media server sends out an audio stream and configured clients can play it ok, but there are a couple of problems:

  • Due to the way the network is currently configured, the multicast data gets sent to the Modem/Router/Wireless Access Point device as well. This floods the wireless connection with data and renders it unusable until the stream is switched off.
  • There is a substantial lag between the different clients playing the audio stream. All the clients need to have synchronous playback to avoid echo and/or reverberation effects when going from room to room.

Network Flooding

By default Pulseaudio the address 224.0.0.56 as the target for the RTP multicast stream. The switch I have (a TP-Link TP1600G-24TS) has the facility to do IGMP snooping to allow multicast data to be restricted to ports where clients have requested the stream, i.e. ports where no clients have requested streaming data will not get it. This seems to be the solution to the wireless flooding issue, and to this end I disabled the wireless on my router, and plugged a wireless access point into a free port on the switch.

After enabling IGMP snooping, MLD snooping, and Querier config, one would have expected RTP data to stop being sent to the access point port. Unfortunately this was not the case.

I eventually noticed that the Multicast Traffic Table function on the switch would only accept an IP address between 224.0.1.0 and 239.255.255.255 - Pulseaudio was not using a streaming address in this range. According to RFC5771, the 224.0.0.0 is for multicast to the local subnetwork only, which looks, to my limited knowledge of the subject, like the correct range to use, but suffers from not being filterable by the switch. To this end, I simply has Pulseaudio use 224.0.1.56 instead, and altered the default.pa configuration files on the server and clients to reflect this.

Simply using the 224.0.1.x subnet is probably not the right solution, but it works in this case. I should probably use one of the ad-hoc subnets (224.0.2.0 to 224.0.255.255, 224.3.0.0 to 224.4.255.255, 233.252.0.0 to 233.255.255.255) or the administratively scoped range (233.0.0.0 to 239.255.255.249), but for the time being I'll use the wrong subnet.

After far too much reading about Multicasting, it would seem that the range to use is the 239.255.0.0 to 239.255.255.255 range which is the Site Local Scope. The 224.0.0.x range is the Link Local range and is expected to be broadcast to all local hosts as it contains assorted protocols that clients/servers use to do multicasting. TP-Link is probably right not to allow blocking of this range. Why Pulseaudio uses a default in this range is unknown.

Synchronisation

Install ptpd and ntp on a server, and ptpd on clients on all the PCs - removing ntp from them if necessary. So the server uses NTP to set its clock, and PTPd (master) to synchronise the clients (slaves) with it.

Configuring Raspberry Pi for LAN Audio

Install OS

Download the minimal Raspian OS image from here, and unzip.

Write it to an SD card dd if=2017…img of=/dev/sdeX bs=4M status=progress

Configure OS

Plug Pi into a monitor, keyboard, and a network cable from the Linux PC. Insert SD card and boot.

IP address will be something like 169.254.1.214 - note this number.

Login to Pi as pi:raspberry.

sudo raspi-config

Interfacing Options | P2 SSH | Yes | Ok

Advanced Options | Expand Filesystem | Ok

Finish | Yes

Disconnect keyboard

Configure Pi Network

From Linux PC: ssh pi@169.254.1.214

Do cat /etc/network/interfaces

To see the current network settings. The line staring 'iface eth0' is the one to look for.

Just for testing purposes, I'll give the Pi a static IP (it's only connected to a single PC). Once testing and development has been done it will get an address via DHCP on the main network.

So:

nano /etc/network/interfaces and edit the 'iface eth0…' section to be like this:

auto eth0 iface eth0 inet static

address 192.168.0.160
netmask 255.255.255.0
gateway 192.168.0.2

Do ctrl+X to save and exit

sudo systemctl disable dhcpcd

sudo systemctl enable networking

Sudo nano /etc/hosts, edit 127.0.1.1 raspberrypi to have the desired hostname.

Sudo nano /etc/hostname

Reboot with sudo shutdown -r now

Change the Linux PC second IP address: ifconfig eth1 inet 192.168.0.11 netmask 255.255.255.0

Configure Pulseaudio

sudo apt update sudo apt upgrade sudo apt install joe pulseaudio pulseaudio-utils

Need to do the above before setting up the fixed IP above.

Since running Pulseaudio as a daemon will have it running as root, and this is a security issue, we'll set the RPi to autologin as 'pi'.

Use raspi-config to auto login: Boot Options | B2 Console Autologin

Advanced | Audio through 3.5mm Jack

Add /usr/bin/pulseaudio to the bottom of /home/pi/.profile

edit /etc/pulse/default.pa

load-module module-udev-detect tsched=0

load-module module-rtc-recv source_ip=239.x.y.z

edit daemon.conf

default-sample-rate = 48000

resample-method = src-sinc-fastest

default-fragments = 8

default-fragment-size-msec = 10

  • lan_audio.txt
  • Last modified: 2017/06/15 09:38
  • (external edit)