Tue 1 May 2007
Optimize network throughput on your Apple TV
Posted by lynxman under MacOS X, Wireless
[8] Comments
This is specially helpful if you are using your Apple TV wireless adapter instead of plugging it directly to the network with an Ethernet cable.
This small tweak assumes that you already have sshd access to your Apple TV, if not please check out AwkwardTV on how to do that.
I had some problems watching HD DivX files in my AppleTV, they were skipping frames and freezing in the most awkward moments, I have all of my files in a mac mini and shared on the network using AFP. The files are mounted in the Apple TV using the ATVFiles plugin and the aTV-ShareMounter plugin.
What needs to be added to give the network buffer enough buffer space on the network is tweak the kernel options at startup, that can be done as in Mac OS X editing the file /etc/sysctl.conf which in the Apple TV version of Mac OS X does not exist by default, you’ll have to create it, don’t worry I’ll put here two quick ways to do it.
How to edit /etc/sysctl.conf (if it does not exist)
First Option – The fast kamikaze strategy (will work for everybody, but be really careful!).
echo “kern.ipc.somaxconn=512″ > /etc/sysctl.conf
echo “net.inet.tcp.mssdflt=1460″ >> /etc/sysctl.conf
echo “net.inet.tcp.sendspace=98304″ >> /etc/sysctl.conf
echo “net.inet.tcp.recvspace=98304″ >> /etc/sysctl.conf
echo “kern.ipc.maxsockbuf=1048576″ >> /etc/sysctl.conf
echo “net.inet.udp.maxdgram=57344″ >> /etc/sysctl.conf
echo “net.inet.udp.recvspace=42080″ >> /etc/sysctl.conf
echo “net.local.stream.sendspace=98304″ >> /etc/sysctl.conf
echo “net.local.stream.recvspace=98304″ >> /etc/sysctl.conf
echo “net.inet.tcp.delayed_ack=0″ >> /etc/sysctl.conf
echo “net.inet.tcp.rfc1323=1″ >> /etc/sysctl.conf
echo “net.inet.tcp.rfc1644=1″ >> /etc/sysctl.conf
echo “net.inet.tcp.newreno=1″ >> /etc/sysctl.conf
Second Option – The slow wise monk strategy (this will work in all cases)
Edit a sysctl.conf in your computer (just be sure that if you’re in a Posix system you’re not editing your local /etc/sysctl.conf).
Add these values to the file
kern.ipc.somaxconn=512
net.inet.tcp.mssdflt=1460
net.inet.tcp.sendspace=98304
net.inet.tcp.recvspace=98304
kern.ipc.maxsockbuf=1048576
net.inet.udp.maxdgram=57344
net.inet.udp.recvspace=42080
net.local.stream.sendspace=98304
net.local.stream.recvspace=98304
net.inet.tcp.delayed_ack=0
net.inet.tcp.rfc1323=1
net.inet.tcp.rfc1644=1
net.inet.tcp.newreno=1
Copy it to your Apple TV through scp and make sure it ends up in its correct position at /etc/sysctl.conf on your Apple TV
The changes you do will be available on the next reboot, I find it better to do it this way so you’re 100% sure that all the changes are loaded at the same time.
I hope this solves Leo Laporte streaming problems to his Apple TV ;)
March 6th, 2008 at 1:10 pm
Thank you so much, I have been using the TV in exactly the same way, AFP files played over it’s Airport interface, and suffering the same annoying issues… You read my mind exactly as to what I suspected the problem was but you saved me looking up and figuring out what to set the variables to!
Many thanks!!!
March 8th, 2008 at 9:04 pm
Just wondering, are any of these values able to be safely increased any further? I’m down to maybe one skip per video I watch, so it wouldn’t need to be much of an increase?
Thanks!
April 30th, 2008 at 4:05 am
You forgot to put the “sudo” in front of the echo commands. An alternative to the following:
sudo echo “kern.ipc.somaxconn=512\
net.inet.tcp.mssdflt=1460\
net.inet.tcp.sendspace=98304\
net.inet.tcp.recvspace=98304\
kern.ipc.maxsockbuf=1048576\
net.inet.udp.maxdgram=57344\
net.inet.udp.recvspace=42080\ net.local.stream.sendspace=98304\ net.local.stream.recvspace=98304\
net.inet.tcp.delayed_ack=0\
net.inet.tcp.rfc1323=1\
net.inet.tcp.rfc1644=1\
net.inet.tcp.newreno=1″ > /etc/sysctl.conf
November 13th, 2008 at 1:36 pm
@Graham Booker
Oh thanks for the correction, I’ll modify the article accordingly :)
@DJLM It should be okay to increase them a bit, but I found that to have more dangers than gains, some of this kernel parameters don’t play well when increased beyond this limits so please make sure that you have a way to go back to your previous settings!
February 15th, 2009 at 5:27 pm
I get permission denied when I try this.
March 3rd, 2009 at 3:17 am
You rock! Cured my ATV hiccups!
July 22nd, 2009 at 1:24 am
Will this help at all for playing Hulu content?
Thanks,
-M@
December 2nd, 2009 at 11:23 pm
cant wait to give it a try.
Since this doesn’t exist on my ATV now,
can I just delete the new file if it f*cks thinngs up?