Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > TCP Keepalive

TCP Keepalive
Thread Tools
ink
Mac Elite
Join Date: May 2001
Location: Utah
Status: Offline
Reply With Quote
Apr 3, 2004, 01:10 AM
 
My cablemodem's NAT reaps "idle" connections quite rapidly. How can I change the keepalive settings for TCP under OSX, so that my router doesn't close them? I've found websites for how to do it with Windows and Linux; but can't seem to figure out where it's at in system ten.
     
tRr
Dedicated MacNNer
Join Date: Aug 2002
Location: Toronto
Status: Offline
Reply With Quote
Apr 3, 2004, 05:05 AM
 
Using the command "sysctl -a" under Terminal it lists a "net.inet.tcp.always_keepalive: 0" for me... I don't know if that's what you need though, but it sounds like it!

To change the value the syntax should be like this (and then obviously you can run "sysctl -a" again to check if it made the change)

sudo sysctl -w net.inet.tcp.always_keepalive=xx
Hope this helps!
     
ink  (op)
Mac Elite
Join Date: May 2001
Location: Utah
Status: Offline
Reply With Quote
Apr 3, 2004, 08:54 AM
 
Originally posted by tRr:
Using the command "sysctl -a" under Terminal it lists a "net.inet.tcp.always_keepalive: 0" for me... I don't know if that's what you need though, but it sounds like it!

To change the value the syntax should be like this (and then obviously you can run "sysctl -a" again to check if it made the change)



Hope this helps!
Perfect!

It works like a charm. I also had to tweak the net.inet.tcp.keepidle parameter as well (down to 60 seconds; which is fine for my desktop -- but I'd never do that on a busy machine/server!).

Is there a cannonical listing of all the kernel paramaters? I just used the Linux documentation because the names happened to match up to the proc filesystem more or less. Also, is this persistent across reboots, or do I have to put it in some initialization file for every time OSX comes back up?
     
tRr
Dedicated MacNNer
Join Date: Aug 2002
Location: Toronto
Status: Offline
Reply With Quote
Apr 3, 2004, 09:36 AM
 
It isn't persistent across reboots to my knowledge. If you want to hold your changes across reboots, the easiest way I know would be to download this program (and it'll be more or less done for you).

http://www.enigmarelle.com/sw/BroadbandOptimizer/

I always use the manual installation (just drop the folder into /Library/StartupItems/). Then just edit the file called "BroadbandOptimizer", and you should probably see what's it's trying to do right away if we have gone this far.

I wish I could help you with your other question (it sounds cool enough), but I'm suprised what I have told you so far has held together!!
     
ink  (op)
Mac Elite
Join Date: May 2001
Location: Utah
Status: Offline
Reply With Quote
Apr 3, 2004, 01:35 PM
 
Great; I just added the commands so that /Library/StartupItems/BroadbandOptimizer/BroadbandOptimizer looks like this now (for anyone who finds this thread in the future):


#!/bin/sh

##
# Broadband Optimizer
# optimize networking for broadband connection
##

. /etc/rc.common

#CheckForNetwork

StartService ()
{
ConsoleMessage "Starting Broadband Optimizer"

/usr/sbin/sysctl -w net.inet.tcp.sendspace=65536 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.recvspace=65536 > /dev/null
/usr/sbin/sysctl -w kern.ipc.maxsockbuf=524288 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.delayed_ack=0 > /dev/null
/usr/sbin/sysctl -w net.inet.udp.recvspace=73728 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.always_keepalive=1 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.keepidle=60 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.keepintvl=30 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.keepinit=60 > /dev/null

ConsoleMessage -S
}

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService "$1"


Thanks again for the pointers. I wonder how hard it would be to create a general-purpose kernel parameter tweaker for the System Preferences...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2