Throttle network bandwidth per application in Mac OS X

74,461

Solution 1

GUI:

CLI (no port-specific filtering but can be adapted):

These tools rely on ports or port ranges as a filter criterium. If you don't know what ports your application uses you can check its documentation or use lsof while the appplication is running to reveal the ports numbers.

sudo lsof -i -P

Most or all of the tools use ipfw which is officially deprecated in favor of pf, so not sure if these solutions will work on OS X 10.9 and beyond.

Solution 2

Old question, but I just got in the thick of a similar problem so I thought I'd reply.

The problem is probably actually due to traffic shaping at your ISP. They aggressively prioritize traffic to known content providers in an effort to provide better streaming service to customers. I'd argue they've gone a little too far in some cases - I just diagnosed a similar problem where a background iCloud photo upload was causing ping times in excess of 45000 ms.

In order to resolve the problem, you can simply reduce the amount of total bandwidth your computer will use in order to prevent the ISP's traffic shaping from completely robbing bandwidth from all other applications. Ironically, this will improve browsing performance on your own computer, in addition to obviously improving performance for other computers on your network. If for example you've got a 15Mbps downstream cap, you can limit your computer to only using 12Mbps of it, and the ISP algorithm will no longer see the need to shape your traffic as aggressively:

sudo ipfw pipe 1 config bw 12Mbits/s
sudo ipfw add 1 pipe 1 tcp from any to me

In my case, it was upstream bandwidth (capped at 1Mbps by my ISP) that was the limiting factor, so I ran the following, which solved my problem:

sudo ipfw pipe 1 config bw 768Kbits/s
sudo ipfw add 1 pipe 1 tcp from me to any

Note that these commands will only be effective until a restart, but to cancel the rule, just do the following:

ipfw delete 1

Solution 3

How about waterroof? It's an easy front end for IPFW. (And open source.)

Solution 4

Use IceFloor on [Mountain] Lion

Solution 5

In relation to the current developments for OS X 10.10, the ipfw executable commonly referred to, is no longer available. However, there is a pf executable, which can handle similar firewall configurations.

There is a GUI interface called "Murus" (http://www.murusfirewall.com), which you can use for configuring pf. As far as I understand, it also actively supports bandwidth limiting (from the UI).

[EDIT]

In case someone can not go without ipfw, you could try to compile it yourself. The source code (from FreeBSD) is available here: http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/ipfw/

Apple also publishes the source code of open source projects it uses(d). ipfw can be found here: http://www.opensource.apple.com/source/network_cmds/network_cmds-329.2.2/

Share:
74,461

Related videos on Youtube

Syed Ismail Ahamed
Author by

Syed Ismail Ahamed

a Public Sector Keyboard Jockey in cowboy land

Updated on September 17, 2022

Comments

  • Syed Ismail Ahamed
    Syed Ismail Ahamed almost 2 years

    I notice that iTunes seems to suck up all my bandwidth and doesn’t play nice with other applications that use the web when it's downloading. In fact, it doesn't even give itself enough bandwidth when browsing the iTunes Store while downloading large or many files (podcasts, TV shows, large apps, etc).

    I'm not concerned with getting all my downloads as soon as possible, they're really low priority, and I'd rather not have to do this while I'm awake, but I can't hit the refresh button if I'm in bed and forgot it already.

    Is there an application or tool via the Terminal to limit the download bandwidth that iTunes gets without also hindering web browsers or other applications?

    FOSS/GPL software is preferable, but pay software might be acceptable too.

    • Khaled Annajar
      Khaled Annajar almost 9 years
      Network Link Conditioner is very good to limit the bandwidth for all apps apple.stackexchange.com/questions/164959/…
    • Syed Ismail Ahamed
      Syed Ismail Ahamed almost 9 years
      This question has largely been made obsolete for my particular use. I rarely download content in iTunes on a regular basis (podcasts now using a third-party app on iPhone only, AppleTV for iTunes video purchases, and not syncing apps at all to the computer).
  • Syed Ismail Ahamed
    Syed Ismail Ahamed about 14 years
    I couldn't get trickle 1.0.6 or 1.0.7 to build. After running ./configure I get an error saying that libevent cannot be found. I installed libevent via MacPorts and got the same error when I tried again.
  • John T
    John T about 14 years
    @Kio versions > 1.06 do not build due to problems with the call to poll(). Older ones should work however.
  • Syed Ismail Ahamed
    Syed Ismail Ahamed about 14 years
    I downloaded trickle 1.0.5, ran "$ sudo ./configure" and got the following error just like before: "configure: error: libevent not found". I checked, and MacPorts has libevent installed. Besides, I'm not as fond of software that hasn't been updated in years.
  • Prof. Falken
    Prof. Falken about 13 years
    A video of someone doing just that on OSX: youtube.com/watch?v=VgwR230coOw
  • Syed Ismail Ahamed
    Syed Ismail Ahamed almost 10 years
    I find the FreeBSD man page for ipfw, but according to Wikipedia, ipfw was de-emphasized in OS X starting in 10.4 thru 10.5. I don't find ipfw on my installation of 10.10 today, and both Homebrew and MacPorts come up with no actively developed installations for ipfw.
  • Chris
    Chris almost 9 years
    ipfw was discontinued in os x, but there is pf
  • Chris
    Chris over 8 years
    This is outdated by now and uses ipfw, which is no longer available.
  • TopperHarley
    TopperHarley about 7 years
    Upvoted because exploring IceFloor led me to find Vallum, which allows me to block network access per app.
  • GJ.
    GJ. about 7 years
    doesn't seem to allow throttling at all
  • TopperHarley
    TopperHarley about 7 years
    @GJ. true, I haven't been able to see that ability either... so far I can only let an app have network access, or not. I've been setting up different profiles as "throttles" for my workaround to this.
  • Jon Schneider
    Jon Schneider over 5 years
    I was successfully able to configure Murus to throttle Skype 8 on OS X 10.14 Mojave using the instructions here: murusfirewall.com/forum/viewtopic.php?t=428
  • f01
    f01 about 5 years
    I tried this and it appears to work. This is now in beta 6 (beta 3 will not work anymore) -- murusfirewall.com/forum/viewtopic.php?f=2&t=1949 I like the Network Monitor that allows you to add to the firewall and do bandwidth throttling.
  • bomben
    bomben over 4 years
    ipfw seemed to be handy, but was removed for pf. does anyone know how to use pf in the same way as here:benlakey.com/2012/10/14/throttle-bandwidth-on-mac-os-x
  • bomben
    bomben over 4 years
    just discovered it is in the answer below.
  • Giovanni Luisotto
    Giovanni Luisotto over 3 years
    This does work and the app is very intuitive and simple to use. I actually bought the single user license.