looking for alternative solution than IPFW for slowing down an internet connection
Asked Answered
F

4

20

I need to slow down (simulate bad) internet connection, I found some documentation where it was achieved by "ipfw pipe" command , the thing is that in latest MAC OS versions , ipfw was deprecated (and removed)...

I was wondering if there are any alternative to the ipfw API ? Does anyone know how latest Network Link Conditioner achieves it?

The original previous way which enabled to slow down an internet connection :

sudo ipfw pipe 1 config bw 56Kbit/s delay 200 plr 0.2

and to clear the pipe :

sudo ipfw delete 1

Thanks.

Fling answered 11/10, 2015 at 11:15 Comment(0)
M
3

I don't know much about Mac OS (I use Linux myself), but I'll give this a shot.

A bunch of digging established that ipfw seems unavailable, as you say.

I was also unable to find a way to use the Network Link Conditioner from the command line. Everything should be usable from the command line, so that's stupid.

One work around would be to try to access the NLC from within AppleScript. The following will get you started on toggling the NLC:

property thePane : "com.apple.Network-Link-Conditioner"  
tell application "System Preferences"  
activate  
  set the current pane to pane id thePane  
--delay 2  
end tell  
---  
tell application "System Events"  
  tell application process "System Preferences"  
  try  
  click ((checkboxes of window "Network Link Conditioner") whose description is "enable switch")  
  on error  
  click ((checkboxes of window "Network Link Conditioner") whose description is "enable switch")  
  end try  
  end tell  
end tell  

I think that you can run a script from the terminal with osascript <SCRIPT>.

As an alternative, Charles Proxy is a pay-to-use program that can be used to perform throttling, provided you can convince the software you are testing to connect to the proxy's port rather than directly to the internet. Maybe there are free proxy solutions out there somewhere?

Perhaps Squid would work in that regard. SquidMan seems to be an easy-ish way to install it for Mac. It looks as though DelayPools and or Client Bandwidth Limits might be useful for simulating a low speed connection, though I can't find evidence of people having used them for such.

Moskowitz answered 17/10, 2015 at 4:25 Comment(4)
This is a nice solution. I tried running the preference pane executable from the command line (/Library/PreferencePanes/Network Link Conditioner.prefPane/Contents/MacOS/Network Link Conditioner), but was getting the error exec format error: ./Network \Link \Conditioner. Which is weird, considering file Network\ Link\ Conditioner shows that it's a Mach-O universal binary with 2 architectures.Jaine
Is it possible to run the System preferences pane itself from the command line and switch into the NLC panel via AppleScript?Moskowitz
Theoretically you could open the NLC preference pane with open /Library/PreferencePanes/Network Link Conditioner.prefPane, or open the main System Preferences pane from the binary in the app's bundle /Applications/System\ Preferences.app/Contents/MacOS/System\ PreferencesJaine
In OS X El Captian 10.11.1 the script provided by @Moskowitz does not work for me. The script does flip the switch in the pane, however it does not affect the utility, the real on or off state doesn't change.Nephology
A
2

I found several solutions that might work. They come from some old threads, but they might help:

How to simulate slow internet connections on the mac

Apple has made a very handy official tool to slow down the network connections on you Mac for testing purposes.

The Network Link Conditioner preference is a free download from within Xcode (for Lion and later OS). Additionally, iOS has similar function accessible from within Xcode and iOS 6 or later.

How do I simulate a bad Wi-Fi connection on my iPad?

There are a few ways you can do this, depending on your situation:

  1. Move further away from your router. While this may seem a bit obvious, I realize that it isn't always possible while testing/debugging (for example, if you are working on a desktop computer).

  2. Put aluminum foil around the router and/or antenna. This will (partially) block some or all of the radio signals by creating a makeshift Faraday cage. The results you get will depend on the strength of your router signal, distance from the router, and other environmental factors.

  3. Set your router's wireless signal power to a lower setting. The method for doing this is different for each router, so you will have to look at the user guide for instructions on how to do this.

Slow down internet for iOS simulator

You can set the network to slow characteristic by testing on devices. Go to Settings -> Developer Settings -> Network Link Conditioner -> Enable. This is for iPhone/iPad running iOS 6

I don't know if the last one you can still do.

Applesauce answered 13/10, 2015 at 15:28 Comment(12)
thanks for the answers , but the first suggestion , is outdated api as I've already described , and the Network Link Conditioner is an UI tool , and I need some CLI / command line commands which are still supported ... Thanks anywayFling
If you feel as if this question is a duplicate, mark it as such. Don't post links to other StackOverflow posts as an answer...Jaine
@Fling any reason why you need CLI ? you configure the UI tool then you can test your tool knowing the connection is slow.Whiny
@Frédéric Henri - I need a cli commands in order to execute an automation tests which include connectivity scenarios as well, the tests are running automatically of course...Fling
@Fling Automator can do that even for application without UIWhiny
@Frédéric Henri , The thing is I want to control the networking during the test execution within the automation code / test , and by using Automator , it make the task much more complicate to synchronise the test and the Automator toolFling
@JAL: The poster has aggregated information from several answers, pulling out the important parts, and, in so doing, offered a novel response to what appears to be a difficult question and the OP has thanked the poster for it. You should not be so quick to judge. You should set a higher bar for rejecting people's contributions: if the problem isn't severe the benefits of deduplication should be weighed against the possibility of the community being perceived as hostile.Moskowitz
@Caleb: nice work pulling in the router configuration idea. It's simple and potentially effective.Moskowitz
@Richard: Cool, I'll copy-paste answers from other SO questions to answer bounty questions next time.Jaine
I don't know why, but there seems to be an up-vote/down-vote war on my answer: i.sstatic.net/uhd0m.png. I have 26 reps total from this answer 😕.Applesauce
This answer is just an aggregation of other answers from StackOverflow. In my option, you should have flagged this question as a duplicate of one of the above answers, rather than making your own answer as a collection of other StackOverflow answers.Jaine
meta.#309308Illtimed
F
0

I've used many methods in the past for slowing down network connections, among them:

  • performing a parallel download of some massive Linux ISO file;
  • physically pulling out the Ethernet cable (at one point, I actually toyed with the idea of building a push-button device that would sit between two cat5 cables and do this without having to physically disconnect the whole cable).
  • using ifconfig eth0 down ; sleep 1 ; ifconfig eth0 up.

Hopefully one or more of those methods will help.

Fornof answered 19/10, 2015 at 3:6 Comment(1)
thanks for the answer , the iconfig is great, but you cannot control how many packet you would like to "drop" , am I right ?Fling
S
0

If you're looking to slow down your network connection because you're doing testing/profiling work, one option is to get a specific device that can create network latency/noise.

For example Apposite Tech's mini2 WAN emulator allows you to change values for bandwidth and packet loss. You can roll your own device too using something like: http://wanem.sourceforge.net/ . It just depends on your needs, time and budget.

Splitlevel answered 20/10, 2015 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.