I’ve been using streaming video solutions more, since we pared back our satellite TV package at home and have been saving the Netflix allotment for the kids.
But streaming performance has been lacking for me. I’ve frequently experienced [buffering] and [recalculating bandwidth] messages, and having streams just stop dead and freeze up.
I wondered if Comcast might be playing games, since they have a history of doing so and this competes with one of their other products, so I decided to check out Google’s tools that measure this possibility. Comcast is clean.
But the tools did help me find the actual cause: my TCP buffer receive size was set too low. Their network diagnostic tool revealed that 80% of the time my system was responsible for causing the delay, and only 20% of the time was the network at fault. After rejecting many forum suggestions I found as bizarre, I came across a decent O’Reilly article, which linked to an LBNL site with this recommended setting (for Mac OS X):
sysctl -w net.inet.tcp.win_scale_factor=8 sysctl -w kern.ipc.maxsockbuf=16777216 sysctl -w net.inet.tcp.sendspace=8388608 sysctl -w net.inet.tcp.recvspace=8388608
This increases the send and receive buffers to 8MB each and adjusts the kernel ipc buffer to accommodate. The first line is obsolete as of at least 10.4.11, which my video streaming system is on.
The last three lines above are a good way to test, and for permanence, create a file, /etc/sysctl.conf , with just the parameters, like this:
kern.ipc.maxsockbuf=16777216 net.inet.tcp.sendspace=8388608 net.inet.tcp.recvspace=8388608
After setting that, my videos are all streaming without errors and the Google test shows that now the network is my delay 80% of the time and my client side none.
Recent OSX (10.5.x) and Linux (2.6.17) have TCP buffer autotuning which might, in some cases, make the above unnecessary. The Linux version only sets 4MB buffers, though, which may or may not be enough depending on your bandwidth delay product. Some experimentation may be in order, look up the proper variables for your kernel version, the above is only tested on xnu 8.11.1.