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

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.

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.

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:
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).
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.
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.

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.

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.

Related

Is it possible to access a Chromebook via ssh through USB?

My employer has asked me to prepare for testing several thousand Chromebooks (mix of models/manufacturers) to refurb/flip. This may be a recurring thing.
Most or all of these will be old enough that CCD will not be available. I'd like to connect a widget such as a Raspberry Pi to the USB and have it automate testing as much as possible.
I know I can use keyboard emulation to inject commands, but I'd like to get a crosh session running over USB so that I can read info from the DUT besides just controlling it.
Google shows bazillions of returns about using a Chromebook as an ssh terminal but what I'm looking for is the opposite. I'm prepared for the answer to be a simple "no" but I'm concerned because I can't find that anyone else has asked this question. I don't think I'm that creative, so I suspect my Goog-fu is weak.
The answer appears to be "no". However I solved it another way; using "gadget mode" I have a Raspberry Pi ZW enumerate as a keyboard and a serial port. I put the Chromebook into Developer mode, open a developer shell with ctrl/alt/F2, or on a PC/linux or Mac system open a terminal window and type "sudo su" (these have to be done manually). Then I have the RPi issue this bash command to identify the serial port "in the blind":
SERPORT=/dev/serial/by-id/$(ls /dev/serial/by-id) # Chromebook or PC/linux
(or)
SERPORT=$(ls /dev/cu.usbmodem*) # Mac
Now I can have the RPi inject commands via the keyboard, put ">$SERPORT" on the end of each command, and the output comes in the RPi gadget serial port. The RPi then packages the data and forwards it over WiFi to our CRM. It's working nicely for Chromebooks, PCs booted into linux, Mac desktops and Macbooks.
Edit:
The company I work for has actually turned this into a product and so I'm not sure how much detail I should share, but...
I learned my way around gadget mode on the RPi from this link. There are examples for setting up a keyboard and a serial port. Using the templates in that link, I made a device called /dev/hidg0 which emits keyboard scancodes from the RPi to the Chromebook. I also made a device called /dev/ttyGS0 which the Chromebook sees as a serial port.
So I send keystrokes with some python like:
with open("/dev/hidg0","bw") as hid:
hid.write(blah)
and then have the Chromebook send text to the serial port, which I then read by looking at /dev/ttyGS0
Hopefully this will be enough to get you started. I found the isticktoit link very helpful.

starting with nodemcu/esp8266 dev board

I have a esp dev board that I've been trying to get to work, but have faild miserably. after spending a few days trying I was able to 'flash' a firmware and up load code(to connect to my wifi) via arduino IDE. the problems are when I open the serial monitor the serial monitor window is nowhere to be seen(it refuses to show up on my desktop, but if I place my mouse over arduino IDE on the task bar I can see a tiny version of the window with what seems like the esp is supposed to tell me). I verified the wifi program was working with advanced ip scanner. The other problem is that when I try to use esplorer I am told the following:
Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...
Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
à‚3þÿÖ
ü
I've tried reseting via hardware and software and also saving a init.lua to the esp ( which I am told: Waiting answer from ESP - Timeout reached. Command aborted.)
Is there an easy step by step tutorial or something where I can get this thing to work in such a way that it is possible to develop with it? I dont care what language I have to use as long as I dont have to spend more time on trying to get the hardware to work. For something that is Arduino-like hardware it is significantly harder to do the simplest thing, a pic mcu is easier.es
If you are doing serious IoT thing then, I guess its better to go by Espressif IDE. There's a Freetos version also available which makes programming experience better.
To get started step by step you can check lot of videos on youtube, that's my preferred way of getting started. I found these three helpful to get started : here

iPad 1, iOS 5.1.1 jailbroken with redsn0w, works great, but since inetutils installed, getting network timeouts. How to adjust/fix?

I have done a jailbreak on old iPad 1, using redsn0w. Has worked really well. Installed OpenSSH, and I can use Putty on Windows or SSH on Linux to login to my iPad, and of course, pscp or scp to migrate files to/from using Windows or Linux. Installed DOSbox (using DOSpad.deb file), and it works fine. But there was no "ping" on the basic jailbreak version, so I installed "inetutils", which provides all the GNU inet stuff (ping, ftp, inetd, rlogin, telnet) and then found "arp iconfig netstat route traceroute" in Network Commands. This makes an old tablet very, very useful. Really fine stuff, but I notice now that the iPad network access times out quickly. This is new behaviour, since the Cydia "inetutils" install. If I set the iPad down, after a few minutes, I cannot ping it from any machine on my LAN. I could, before I installed the networking utilities. Maybe a security feature? If so, can I back out the network stuff, and just have ssh access, and have it not timeout? I want to to be "alive" all the time.
Ok, found it. When you jailbreak an iPad ver. 1, running iOS 5.1.1, using Redsn0w, the initial install of the code that provides root access does not include standard inetutils. The original behaviour of the iPad 1, if configured with static ip values, meant that if was on, and the wifi was enabled, it would respond to a "ping", even if the screen was "asleep".
This ping-response was useful for diagnostic purposes. Initial install of the jailbreak code did not change this behaviour. But I could not "ping" out from the iPad to other machines since there was no ping.exe available, even after the jailbreak (this contrasts to Blackberry Playbooks, which had a "ping" utility, and would also respond to pings, even if "asleep").
So I downloaded the "inetutils" package from Cydia source Telesphoreo, and that provide a ping.exe, which could be used in console mode on the iPad. It worked fine, and is a very useful program.
But, if you set the iPad aside, after about 5 minutes, it would time out. It appears the wifi transmit function is just shutdown, and response to "ping" is explicitly disabled.
After much research and experiment, I've determined that you can re-activate the iPad "ping" response - remotely - by sending it an SSH query. Example:
[your_id#Linbox ~]$ ssh mobile#xxx.yyy.zzz.aaa
where xxx.yyy.zzz.aaa is your IPV4 address,
assuming you have configured your iPad with a static ip value. (I own a couple of class C ip ranges, so I have been using these for many years, in my work). The two defined userids after jailbreak are "mobile" and "root".
The new behaviour appears after you download and install all the newer "inetutils" utilities, and the "Network Commands" utilities, from the Telesphoreo source repository.
This behaviour change is actually a pretty good idea, as it discourages inappropriate usage of ping, and probably also saves battery life. But it is a change from previous operational characteristic. Another fellow went down this same rabbit-hole, and documented the solution on the "jailbreakqa.com" site, url below:
http://www.jailbreakqa.com/questions/192379/persistent-wi-fi-when-locked
Hope this info is useful.
Curious to see this query downvoted.. Lemmie say, having this old iPad run as a full-blown remote-accessable Linux box is very useful. Once jailbroken, one can scp files back and forth, install custom computational code locally, and basically have all your office on a small, thin, light tablet in a little briefcase. Most useful.
Very interesting post... just what i am looking for. I use an ipad 1/16g/3G for a display on my kitchen wall for displaying domotica info. This works well and using ssh i can have it turn on, display something and turn off.
I got myself another ipad 1/16gb wifi only and this one had the sleeping wifi problem. My first thought was that it had to do with the 3g chip.. that maybe this keeps the ipad alive while the other one goes to sleep. The 3G model doesn't have inetutils installed and still doesnt go to sleep. So there seems some merrit to my line of thoughts.
I installed the inetutils on the wifi only ipad and it seems like this solved this trick. I can ssh into it just fine.. even when it is in sleep mode. Thanks for your update.
The link in your post doesn't work anymore..

How to troubleshoot CAN bus communication

I am trying to connect ICP CON i-7565 (USB<->CAN interface) to a custom made device (supporting CAN2.0B, proved to work with PCL-841 card) Although I think I have configured BAUD and acceptance code/mask correctly I can see CAN no messages coming from the device (ICP provides a tool that should allow me to send and receive CAN messages).
I am new to CAN bus so I appreciate any help regarding how to identify the problem.
I-7565 might be wrong interface for me, I might have misconfigured it, or it is simply broken. Or I am just doing something wrong out of my ignorance. I don't think anyone can help me with my specific problem, so I am rather asking for general information on how are problems with CAN bus identified and analyzed. In TCP/IP for example, you would call ping, you'd recheck your ip and gateway settings etc. What do you do for CAN communication?
Additional info:
OS: Win7 64bit
connector: DB-9 with standard wiring (2,3,7)
Finally I tried to work with different USB<->CAN interface from different manufacturer and it worked like a charm. My old interface was either broken or incompatible for reasons unknown. While working on this problem I learned couple of things about CAN bus and so now I share what I think was the right answer to my original question: How to troubleshoot CAN bus communication?
read manual to your USB-CAN interface
install driver of your interface device and make sure it is working (check device manager, depending on the type of your device you will see new COM port added or new USB controller )
your device should be shipped with it's own test/analysis software (they might call it utility or similar), run it and check if it can connect to your device
CAN communication uses three wires that are referred to as High, Low and Ground and is usually connected with DB-9 connectors where High is linked to pin n. 7, Low to pin n. 2 and Ground to pin n. 3 or 5 - make sure this is connected correctly on both your USB interface and CAN device you want to communicate with
set properties of your connection, these are most of all: CAN type (2.0A or 2.0B) BAUD rate, Acceptance Code and Acceptance Mask
if you've done all of this and still you can see no CAN messages arriving in your utility program, check with a different USB-CAN interface or find some other way to test if your device is actually emitting CAN messages and your USB interface is in fact able to receive them. (this was actually my case)

Understanding the Android emulator: Testing images? Network connectivity dependencies?

To better clarify my generic question:
I have gotten the Android emulator to work by running a full "make full-eng" build, as per the Google documentation. However, I wanted to debug it, so once I ran the emulator, and called "$ adb shell dmesg" and routed that to an output text file, I found a couple of strange lines:
...
<4>goldfish_new_pdev goldfish_interrupt_controller at ff000000 irq -1
<4>goldfish_new_pdev goldfish_device_bus at ff001000 irq 1
<4>goldfish_new_pdev goldfish_timer at ff003000 irq 3
<4>goldfish_new_pdev goldfish_rtc at ff01000
So when you run the Android full build, it gives you Goldfish as the system image? I want to know if it's testing the things I want for Galaxy Nexus. The kernel was a modified maguro kernel (omap project) for Galaxy Nexus, that I put into the build tree. But the platform I want to be testing is IceCreamSandwich. Is the emulator testing this platform? (b/c the output in this log is leading me to believe it isn't) Or is the emulator testing a "generic" image?
Also, an important further question: I modified the kernel's "socket.h" file, to override the INET protocol with an undefined protocol (FINS). In theory the phone should boot up, but NO internet access. Does the phone emulator care what you do to the internet protocols? Does it use your host computer's networking capabilities?
One further follow-up: What processes/system-services/events (that are involved in booting to a stable state) of the phone DEPEND on the internet protocols of the traditional underlying network stack? (protocols being defined to set up the network sockets)
At the time I wrote the question I did not understand a few things and think I've learned a little while messing with the emulator at the "kernel level". First of all, the emulator tests the "goldfish kernel" (Linux version 2.6.29, with ARM architecture) of a "generic" phone brand. It's almost as if the emulator is a type of phone in of itself, and you cannot mix these image kernels. For example, I tried building a Nexus S crespo phone image with goldfish kernel (so in other words, no crespo kernel) and the phone just "hangs" at the Google splash-screen (at least it's not a boot-loop).
My research (FINS) worked on this emulator, but did not work on any of the 3 platforms supported on actual hardware: Nexus S, Galaxy Nexus, and Motorola Xoom. I am not sure why, given Google does not seems to give users the ability to debug at the lowest level of a phone (I'm sure the actual developers use such kinds of tools in building these phones/testing them). This leads to one major issue which answers my last follow-up: The Android Debug Bridge depends upon INET protocol. My emulator boots up successfully and runs as I want (no internet, b/c there is no INET), but these actual phones do NOT. My hypothesis is that: If INET is overridden with a protocol that is empty (in this case, that would be FINS, which intends to deal with INET at the userspace level, but this appears to be too late for the phone system to be satisfied), the ADB daemon (classified as a type of system service perhaps) cannot work/be connected to and Android hardware will crash because of this. The emulator I believe is more flexible than a real phone, as the hardware is perhaps virtually represented and does not have the same limitations as physical hardware does.
You can consult my wiki/documentation (part of my research team's larger site) of my struggle with the Android phone boot process for more details and my various attempts: http://finsframework.org/mediawiki/index.php/Alexander_G._Ororbia_II
If anyone ever figures out how to get a working boot log from a Nexus S, Galaxy Nexus, or Motorola Xoom that gets stuck in a "boot-loop" (without ADB), please let let me know, as I will be working on this problem for a while to come (and I will update my other Stack Overflow-Android questions to reflect this correction). Any corrections to my understanding would also be appreciated.
NOTE: This answer is editable, as I still think there is some way of getting the phone to produce boot logs on the host machine without the ADB daemon.

Resources