Simulate Slow Internet Connection on a REAL device? [duplicate] - android

This question already has answers here:
Simulate low bandwidth in android
(11 answers)
Closed 8 years ago.
I need to test my application in conditions where even 2G Internet connectivity isn't at its full coverage (i.e. 2 bars instead of 4, 2G).
I prefer conducting these tests over WiFi.
Is there a way (programmatically or otherwise) to tell the Android OS on the real device to slow down or throttle Internet connection 56 Kbit/s?
Note: I know how to do this on the emulator. I'm looking for a way to do this on a real device.
Is this possible?

In one of your comments you mentioned that you have a DD-WRT router, which is really a tiny Linux box. So you may be able to get a way with the tc command:
tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 10mbit
tc class add dev $DEV parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip dst 195.96.96.97 flowid 1:1

It kind of depends on what you have on the upstream side. If you're transmitting some kind of test load, write a driver at the upstream end that does, in fact, slow itself down -- although sleep() is a bad choice. What you'll be writing is essentially a fairly hard real-time program if you hope to get anything resembling a real workload.
(When I say "a driver" btw , I don't mean necessarily a device driver, just some kind of driver program.)
But are you really trying to simulate a slow connection, or a degraded and noisy connection that has a low effective data rate?

Related

Why does using pyshark giving me inappropriate results with BLE PCAP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have limited experience with pyshark/scapy, such as capture Bluetooth low energy from sniffer devices. I have unsuccessfully searched for a solution. Any thoughts or suggestions on how to achieve this are welcome. Thanks in advance.
Setup:
I have two sniffer devices which are the Ubertooth one and nrf51-DK. A smartwatch with BLE 4.1 and Android smartphone. The platform is ubuntu 14.04.
Goal:
My goal is to capture the communication between the smartwatch and phone, during the operation of an app(for example: album or browser). All I need is the packet length, source, and destination address.
Current Status:
Initially, I started with nrf51-DK. It doesn't capture from the pairing process, so I bought the Ubertooth device, It shows the paring process, but it doesn't show any other useful components of communication between the two devices. But, there is something called "unknown", seen in the image below.
Wireshark with no Source and Destination in Unknown info
Questions:
1. Is it possible to capture at least 90% of the transmission between the smartwatch and smartphone?
The Wireshark didn't display any address(Source and Destination). Am I still able to decode "Unknow" by using pyshark/scapy?
Notes:
For question 1, I've looked around and found the following:
"This feature causes the MAC address within the advertising packets to be replaced with a random value that changes at timing intervals determined by the manufacturer. Any malicious device(s), placed at intervals along your travel route, would not be able to determine that the series of different, randomly generated MAC addresses received from your device actually relates to the same physical device. It actually looks like a series of different devices, thus, it will not be possible to track you using the advertised MAC address"
so I'm not really sure that the Ubertooth-one or other sniffer devices are able to capture 90% of the transmission.
For question 2, I have saved the PCAP file and trying using pyshark and scapy to display the source and destination address in python, but it doesn't contain an address:
cap = pyshark.FileCapture('Test_1.pcap')
print(cap[2].ip.src)
OUTPUT:
pyshark.tshark.tshar.TsharkNotFoundException: Tshark not found. Try adding its location to the configuration file.
I guess the version of my Wireshark is lower than the pyshark requirement. (current: 1.12.1). But, I have to use the older version of the Wireshark for my sniffer device. Therefore, I'm not really sure if the older version Wireshark cause the problem or the way I'm using pyshark is wrong.
question 2 update:
apt install tshark
I wanted to know if it is good practice to do so, and if not, what would be the best way to achieve this?
As long as the sniffer catches the CONNECT_IND packet (previously called CONNECT_REQ), it will be able to follow the whole connection. Naturally, some packets might be missed if the signal isn't good enough. If a channel map or connection parameter update takes place, it's vital that the sniffer gets this packet (otherwise it will lose sync with the connection).
The Bluetooth Device Address is not sent in every packet. It is only sent in the CONNECT_IND packet (and the advertisement packet).
The problem you have with Wireshark is probably because you decode it using the wrong plugin/decoding format. See the documentation for your sniffer.

Maximum output amperage from USB Smartphones

The Output voltage from an USB port is 5v, and it can't be changed, isn't it?!
But what is the maximum amperage that I can drain from a smartphone?
It depends on the battery, hardware or is limited by the OS?
There is difference between Android/iPhone/otherOS phones?
Can I control the output amperage with an App? And if the phone is rooted?
Important example what is the maximum amount of current that can provide Iphone 6 from USB?
The official maximum on current provided on USB 2 OTG port is 500mA and minimum is 8mA when the port is in Host mode.
Source http://www.usb.org/developers/onthego/otg1_0.pdf #2.5
The USB 2.0 specification allows the voltage output from a USB port to be anywhere between 4.40 V and 5.25 V, but it is typically 5 V.
While you could construct a USB port that has a different voltage, you should probably not do that because a normal USB device you plug into that port could malfunction or be damaged. It's unlikely that your phone provides a feature for changing the voltage of your USB port.
The USB specification allows devices to draw 100 mA from a USB port before they have reached the "configured" state (see Chapter 9 of the USB specification for more information about USB device states). Once the device is configured, it can draw more current, as long as it doesn't exceed the amount of current specified in its configuration descriptor.
If your phone does not get the device into the configured state by default, it might be possible to write an app to do it, thus allowing your device to draw more than 100 mA without violating the USB specification.
Not sure what you're trying to achieve...
An iPhone 6 can provide some (limited) power to devices plugged into its lightning port (it doesn't have a USB port).
There are cables that connect the phone to a host computer (or charger) over USB, but you're not going to get power out of the phone that way (only power into the phone).
A lightning connector uses active electronics inside the connector's cable to get the phone to assign functions to the different pins.
Moreover there's authentication involved, preventing you from making anything yourself for it without apple's involvement. You'd need to join the MFi program to get the needed documentation.
There's an NDA involved, and Apple is notorious about such things, so you're unlikely to find much reliable and/or verifiable info on the Lightning conector till you join the program.
See also here.
A list of USB standards and their voltage/current ratings is shown on wikipedia
The Nexus 5X and 6P seem to be the first phones to support power delivery via USB Type C connection: Link
However there is conflicting information on how well this is implemented.
Your goal of a 3A output current seems to be possible with USB-PD, but it would appear that no smartphones are currently supporting this.
Important example what is the maximum amount of current that can provide Iphone 6 from USB?
An iPhone with a Camera Connection Kit will limit you to 100 mA. If you connect a device that claims more than this in its descriptors, or tries to draw more than this, it will get cut off with an error:
As reported by this iPhone 6 and 6 plus may be able to supply a current of about 1 Ampere at the voltage at which they get charged. Though I can't be very sure about it unless the specification of the USB drive used are provided.
3A of currents seems to be way too much. If it would have been possible, they could have used it to charge mobile phones faster (I don't know if they do use 3A chargers or not, but this can be seen on their charger at the output tag ).
I would have not done such an experiment until and unless I was very sure about it.
Disclaimer : What ever experiment you do, you it do at your own risk. In the above answer I have just tried to explain what I would have done and have provided reason to back that.
Amperage drained from the power supply is proportional to these factors:
1- The net device's impedance(including battery and other feeder circuits).
2- Device's internal current limiter.
3- Power supply's maximum current limitation.
power supplies usually provide less amperage than it is dictated by the device. If they provide more of, their constant voltage, i.e. 5V, drops below its standard. Therefore, the limitation is posed by the supplies in the first place.
Devices, provide you with another current limiter to lower the risk of using failure of nonstandard power supplies. I'm not sure whether you can change the maximum threshold of internal current delimiter to drain more power or not, but I'm sure you can not change it in your power supply.

Streaming data from an Android device to a PC via USB

I need to stream a set of numbers, 6 floats, from an android device to a PC, to which it is connected by a USB cable. All the solutions I have found proposes using a WiFi connection. However, I have found that the latency caused by this is not acceptable. As such I have decided that I am going to hire someone to integrate the components, thus enabling direct communication. Until then, however, I want to try a variety of devices to see what works and the quickest way to "Integrate" two devices is by allowing them to share a (US)Buss. However, this is the one field I have zero experience with.
Do you make a socket and treat the connection as a network connection or is there another fancier way to achieve what I want? I have seen some talk about making a device driver for this purpose and I do not feel like crashing my OS 500 times again. I find it hard to believe that the android devices do not have some kind of driver already made that I can exploit.
The android code is written in Java, but it could be changed depending on what people suggest. The main chunk of mys system lies on the PC and is written in C++.
I need the latency of the stream to be as low as possible since the entire system needs to be as real time as possible. The limit is 15 ms between data acquisition on the device and the rendering of the simulation on the PC.
TL/DR: I need to stream data from a program on an android device to a PC with as little latency as possible; i.e. one way communication. As long as I can stream bytes I can design protocols and translate the bytes on the receiving end. My global cap is 15 ms and I need to stream continually updated 6 floats. What is the best way to achieve this?
Thank you in advance for your help.
Raw USB is probably not the way to go. USB is a device-oriented specification and cannot be used in a general send-arbitrary-bytes-across-a-wire way.
If Wi-Fi really is too slow, you could try purchasing an Android-compatible USB-Ethernet adaptor and connecting the device to the computer via a wired network connection, which might reduce the latency. Android recognises many types of these adaptors and you communicate over the network connection in the same way as other networks.
We ended up using the ADB brigde and it seems to be stable and fast enough for our purposes. All we had to do was to open a socket and connect with TCP. For some reason it fails when we try to connect with UDP, but I assume this might be due to ignorence on our part.

Android Wifi Direct Speed

I have been going over this Wifi Direct tutorial for Android:
Android Wi-Fi Peer-to-Peer
I created the Wifi Direct connection between two devices and I used java sockets to transfer a file, very much like the tutorial. However my transfer speed is usually around 11 Mbps, maybe a little less.
I was wondering if anyone has been able to get higher transfer rates(like 54 Mbps or 30Mbps) with Wifi Direct? I think it's supposed to be possible.
I am now working on some wifi-direct project and the speed really varies. Sometimes it could reach as much as 25Mbps but sometimes it is extremely slow - the worst time I experienced is that it took about 180 seconds to transfer only 2 MB. My opinion is that it highly depends on the wifi environment around the device.

> 20 GB traffic to image on site from AndroidDownloadManager - What is this? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Today I was perusing my munin graphs and logfiles on one of my VPSes running Apache, and I noticed that there was a huge amount of traffic for about a day and a half (averaging 1.2 MB/second of en0 throughput... not too nice for my monthly quotas), all from the same IP address, and all were for one of two files:
76.186.15.152 - - [21/Dec/2011:09:41:12 -0600] "GET /sites/lifeisaprayer.com/files/blog-images/squirrel-relax.gif HTTP/1.1" 200 250872 "-" "AndroidDownloadManager"
76.186.15.152 - - [21/Dec/2011:09:43:36 -0600] "GET /sites/lifeisaprayer.com/files/blog-images/crucifix-power-strip-20100831-120018.jpg HTTP/1.1" 200 93618 "-" "AndroidDownloadManager"
If a request comes from the Android browser, the user agent is something different (don't remember exactly what it is, but it's something like WebKit...).
My question is: what does AndroidDownloadManager represent, and what (wild speculation welcome) do you think could've spent that day and a half downloading the exact same image files about a million times, up to 20 times/second?
And why would all these requests be coming from the same IP address... I can't imagine someone had an android tablet or phone sitting around downloading 20ish GB of data. The battery would've died in about 30 minutes—shorter if it was on 4G LTE!
AndroidDownloadManager is an API apps can use to download files (it's used by Market I believe for instance.) This likely means you have an app installed responsible for this.
I can't imagine someone had an android tablet or phone sitting around
downloading 20ish GB of data. The battery would've died in about 30
minutes—especially if it was on 4G LTE!
Any agent (the device making the connection) can present any user agent string that it wants to your server. It doesn't mean that a mobile device made all or any of the requests; it just means that "AndroidDownloadManager" was in the User-Agent HTTP header.
And why would all these requests be coming from the same IP address
Denial of service attack? High value datacenters get bombarded with massive amounts of DOS and DDOS traffic. You may or may not be a "high value target", but sending millions of requests with a spoofed user agent string takes only minimal programming knowledge.
And if the attacker is malicious, they might identify a resource that is expensive to serve and target that to cause maximum damage.
Add a firewall rule (or talk to your host) to throttle or block traffic from that IP if it continues to be a problem. Keep in mind you might block wanted traffic as well depending on a variety of factors. It's also possible that the IP is spoofed.
For what it's worth, that IP looks to be from Texas, US:
http://ip-address-lookup-v4.com/ip/76.186.15.152
I just saw this behavior a few days ago. I had over 1500 requests for each of 4 50MB files over a 14.5 hour period. User agent was AndroidDownloadManager, they all came from a single IP address (OptusNet in Australia), and it appears that the entire file was downloaded each time (at least, my ISP thinks it sent the entire file). I like Joakim's theory.
I can't tell whether the IP address (58.111.194.x) is allocated to a phone or to a cable or DSL modem, because OptusNet provides all of those kinds of service. If it's a phone, maybe it stopped because the account ran out of money. Anyway, it looks like it's a rare thing, and I'll hope it doesn't happen again.
We just tested an app named Android Download Manager on a friends tablet, and the UserAgent string it is sending is "Dalvik/1.6.0 (Linux; U; Android 4.1.2; NookColor Build/JZO54K)". I'm guessing it might not be the same thing.

Categories

Resources