Throttle network bandwidth per application in Mac OS X

38

15

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.

dotHTM

Posted 2010-04-02T01:36:40.743

Reputation: 1 534

1

Network Link Conditioner is very good to limit the bandwidth for all apps http://apple.stackexchange.com/questions/164959/bandwidth-limiting-in-yosemite?newreg=5894cad163ab4e6aba82748a29b60e0d#164964

– Khaled Annajar – 2015-07-26T14:48:10.267

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). – dotHTM – 2015-09-03T20:49:48.223

Answers

10

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.

Stefan Schmidt

Posted 2010-04-02T01:36:40.743

Reputation: 498

ipfw seemed to be handy, but was removed for pf. does anyone know how to use pf in the same way as here:http://benlakey.com/2012/10/14/throttle-bandwidth-on-mac-os-x/ – Ben – 2020-01-03T16:51:38.780

just discovered it is in the answer below. – Ben – 2020-01-03T16:52:01.243

5

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

John Mileham

Posted 2010-04-02T01:36:40.743

Reputation: 51

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. – dotHTM – 2014-09-24T14:08:05.753

2ipfw was discontinued in os x, but there is pf – Chris – 2015-09-03T12:59:46.513

4

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

Ben Chun

Posted 2010-04-02T01:36:40.743

Reputation: 41

4

Use IceFloor on [Mountain] Lion

GJ.

Posted 2010-04-02T01:36:40.743

Reputation: 8 151

I'm downvoting this answer after discovering that IceFloor is more protocol-centered than app-centered. So if I want to restrict just a certain app it's hard. – knocte – 2015-06-17T09:39:01.247

Upvoted because exploring IceFloor led me to find Vallum, which allows me to block network access per app. – skplunkerin – 2017-04-10T22:19:25.877

3

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/

Chris

Posted 2010-04-02T01:36:40.743

Reputation: 988

1

I was successfully able to configure Murus to throttle Skype 8 on OS X 10.14 Mojave using the instructions here: http://murusfirewall.com/forum/viewtopic.php?t=428

– Jon Schneider – 2019-01-16T17:10:13.670

2

This is a really perverse thought, but you might be able to use Mac OS X's built-in ipfw and dummynet to write rules to do this. See the man pages for those tools.

Spiff

Posted 2010-04-02T01:36:40.743

Reputation: 84 656

A video of someone doing just that on OSX: http://www.youtube.com/watch?v=VgwR230coOw

– Prof. Falken contract breached – 2011-06-08T09:42:33.203

1

trickle is what you're after.

The only issues are that it does not support executables utilizing kqueue, and it does not support statically linked executables. iTunes should be fine.

John T

Posted 2010-04-02T01:36:40.743

Reputation: 149 037

1I 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. – dotHTM – 2010-04-02T14:00:56.353

@Kio versions > 1.06 do not build due to problems with the call to poll(). Older ones should work however. – John T – 2010-04-02T22:00:40.617

4I 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. – dotHTM – 2010-04-04T00:35:09.717

1

http://github.com/zquestz/throttled this might be what you're after if you've not found it yet.

Robbie

Posted 2010-04-02T01:36:40.743

Reputation: 11

This is outdated by now and uses ipfw, which is no longer available. – Chris – 2015-10-12T13:21:22.913

0

I recently found (and still trialing) Vallum to have control over my apps:

It's a macOS Application Firewall that allows you to restrict what apps can use the internet. It's really slick so far, I just created a Default Profile that allows everything that I want to have access, and a Mobile Hotspot Profile that restricts more apps when I'm on the go.


Update: I haven't been able to "throttle" bandwidth for apps using Vallum, only setup different profiles where I restrict more/less apps.

skplunkerin

Posted 2010-04-02T01:36:40.743

Reputation: 101

3doesn't seem to allow throttling at all – GJ. – 2017-04-11T15:35:47.307

@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. – skplunkerin – 2017-04-18T16:10:52.007

0

The best way to throttle bandwidth on macOS is using Dummynet, which is built into the macOS kernel and works with the pf packet filter. In my opinion the only way to effectively tune bandwidth on a per-process basis is to identify which local ports are bound by the process and then create the corresponding pf dummynet rules. As far as I know the only macOS app that offers this option is Scudo (I'm the developer of Scudo, Vallum and Murus). Scudo 1.0 beta 3 is currently available for free, more info about Scudo per-process bandwidth tuning can be found here: http://www.murusfirewall.com/forum/viewtopic.php?f=2&t=1919&p=3281#p3281

Hany El Imam

Posted 2010-04-02T01:36:40.743

Reputation: 11

I tried this and it appears to work. This is now in beta 6 (beta 3 will not work anymore) -- http://www.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.

– f01 – 2019-04-17T11:42:19.850