looking for alternative solution than IPFW for slowing down an internet connection

五迷三道 提交于 2019-12-06 17:02:57

问题


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.


回答1:


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.




回答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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/33064329/looking-for-alternative-solution-than-ipfw-for-slowing-down-an-internet-connecti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!