I would like to scan for available networks, but I ran always into a timeout, no matter how high the timeout is.
My settings:
Raspberry Pi CM3
Quectel EC21
mmcli 1.14.2
multiroaming sim card
Output of the command:
# mmcli -m 0 --3gpp-scan --timeout=120
error: couldn't scan networks in the modem: 'Timeout was reached'
The modem is connected and the internet connection works.
I tried different timeouts (< 5 mins) but none of them work.
Background:
I have the feeling, that the operator of the sim card prefers his own networks even if there are better networks available. To test this I need to scan the networks and afterwards connect to them.
Could it be, that the scanning is disabled (by default?). And if so how the modem decides which network will be preferred?
EDIT: I tried the same command on my laptop (different modem + mmcli 1.20.2) and it worked without problems.
Related
I have a Raspberry Pi with a 4G USB dongle connected to it for internet access. Everything works on power-up, everything auto-connects and connectivity is established.
In fact if I leave the Raspberry Pi on my desk powered up it stays connected through the 4G dongle for weeks without any issues.
As soon as I leave my mobile cell area, connectivity drops out and does not recover. I also want to be able to unplug the USB 4G dongle and reconnect it and have the cell link auto recover. I am using USB-Modeswitch and wvdial.
Is there anyway I can get the 4G dongle to auto recover?
Thanks for reading.
Brodes.
OK I think I have found the solution I was looking for....
I created this script that sends 5 pings to the other end of a VPN tunnel. If the pings fail then the Raspberry Pi reboots.
#!/bin/bash
# This script checks for an active Internet connection by pinging.
# If the pings fail, it will reset the USB modem dongle.
ping -c5 10.8.0.1
let a=$?
if [ "$a" != "0" ]; then
/sbin/shutdown -r now Connection lost, rebooting...
fi
Then I created a cronjob to run this script every 2 minutes.
If anyone has a better idea please let me know.
Cheers,
Brodes.
I am using fauxmo to have Alexa trigger a script on a Raspberry Pi, which then triggers a BroadLink RM hub to send out IR and RF signals for my home theatre.
This has worked beautifully for a year or two, and yesterday it stopped. I did not touch anything, I swear!
I found out that fauxmo does no longer receive Alexa discovery requests.
When I ask Alexa (voice/web/app) to discover devices, it sends out SSDP M-SEARCH requests to 239.255.255.250 1900. I can verify this using Wireshark on a Windows laptop.
However, these requests do not seem to get to the Raspberry Pi anymore. I have tried with two Raspberries. Confirmed they are on they same WiFi network, which is Google Wifi (and confirmed Upnp is enabled). And I powercycled Alexa and Google Wifi.
I also sent M-SEARCH requests locally on the Raspberry Pi, and those are received.
window 1:
sudo tcpdump -n udp dst port 1900 -A
window 2 (on same Pi):
echo -e "M-SEARCH\r\nurn:Belkin:device:**" | nc.traditional -q 1 -u 239.255.255.250 1900
window 1 result:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes
02:06:41.485902 IP 192.168.86.247.45796 > 239.255.255.250.1900: UDP, length 31
E..;+.#...FO..V........l.'m.M-SEARCH
urn:Belkin:device:**
However, if I do this on 2 Pi's (window 1 on one, window 2 on the other), the request is not received. Actually, I also tried with another Ubuntu machine, so it's not specific to Pi.
I thought that it could be a general network issue, but then I would not see the Alexa requests on my Windows laptop.
I am at a loss - I did not make any code or configuration changes (actually it worked at the beginning of a movie "Alexa turn projector on", and it did not work after the end of the movie "Alexa turn projector off").
Wiring the Pi to the Google WiFi pod worked, I posted this at Google WiFi instead - https://support.google.com/wifi/thread/13904262
I wanna catch probe requests of mobile devices that are not connected to a network using monitor mode on Raspberry pi 3. I am using Raspbian OS. I used "Wifite" command but it only shows the mac addresses of access points and not of the non connected mobile device. I am a beginner in networking and Raspberry pi. Kindly guide me which commands should I use for this purpose?
You might try looking into sniff-probes.
It switches WiFi channels every two seconds and captures incoming packets using tcpdump.
I'm developing an embedded device which has access to the internet through LAN.
I'm in the testing phase now, and I would like to test how the device performs when the connection to the internet is poor.
Currently, the device is connected to a router through a hub, which I use to monitor the packets with Wireshark.
What's the best way to throttle down the internet speed of the device to mimic a scenario that may happen?
Can I do it through a PC? Do I need access to the router? If so, is it possible to limit the speed of each IP in the router interface?
Actually, a friend suggested that I will purchase a usb2lan ethernet card, and to bridge the PC lan connection to the embedded device, and then using a software QoS limiter. do you think it will work ?
If you have a Mac handy, Macs have kernel facility called dummynet built in, which you control through ipfw. It allows you to simulate a slow connection, randomly drop packets with certain probabilities, and more.
The same facility exists in Linux and other OSes.
From the dummynet homepage:
As of Feb.2010 we have released the third major version of dummynet,
which now runs on all main platforms: FreeBSD, Mac OS X as part of the
native distributions, and you can find Linux, OpenWRT and Windows
versions here.
It can do a lot for you:
limit the total incoming TCP traffic to 2Mbit/s, and UDP to 300Kbit/s
ipfw add pipe 2 in proto tcp
ipfw add pipe 3 in proto udp
ipfw pipe 2 config bw 2Mbit/s
ipfw pipe 3 config bw 300Kbit/s
limit incoming traffic to 300Kbit/s for each host on network 10.1.2.0/24.
ipfw add pipe 4 src-ip 10.1.2.0/24 in
ipfw pipe 4 config bw 300Kbit/s queue 20 mask dst-ip 0x000000ff
simulate an ADSL link to the moon:
ipfw add pipe 3 out
ipfw add pipe 4 in
ipfw pipe 3 config bw 128Kbit/s queue 10 delay 1000ms
ipfw pipe 4 config bw 640Kbit/s queue 30 delay 1000ms
You can try using "Fiddler"
You have options to simulate bad network (like old modems 33k or 56k)
You need to plug in your device to your PC and turn on the proxy (every request will be transfered through Fiddler)
Then you could test your code with a bad network then see what happening ;)
You may use (almost) any linux distribution from liveCd (like ubuntu, mandriva, others) to run it on any hardware you want, and use the kernel-based tool netem, aka "Network Emulation" with the "iproute2" package tools. It lets you control delays, package loss, corruption, duplication and other possible problems of wide area network.
There is list of most used simulations, like:
Rate control using Token Bucket Filter:
tc qdisc add dev eth0 root handle 1:0 netem delay 100ms
tc qdisc add dev eth0 parent 1:1 handle 10: tbf rate 256kbit buffer 1600 limit 3000
Delay all packets by fixed time: tc qdisc add dev eth0 root netem delay 100ms
Package loss: tc qdisc change dev eth0 root netem loss 0.1%
This is another OSX solution, have a look at the Network Link Conditioner.
The following quote is ripped from the following blog (All credit for the below should go to Matt Gemmell):
http://mattgemmell.com/2011/07/25/network-link-conditioner-in-lion/
Get the Hardware IO Tools for Xcode. To do this, go into the Xcode
menu, then choose “Open Developer Tool” and finally “More Developer
Tools…”. You’ll be taken to Apple’s developer downloads site; you
should download the “Hardware IO Tools for Xcode”.
The resulting disk image will contain (amongst other things) a
preference pane for System Preferences, called “Network Link
Conditioner”. Double-click the prefpane file and authenticate to allow
it to be installed. You’ll then see the pane in System Preferences.
You can choose from various different types of network conditions
using the Profile popup menu.
You can also add profiles of your own by clicking Manage Profiles,
either from scratch or via duplicating an existing profile.
Extremely handy for simulating less than optimal network conditions
while testing an app. Just don’t forget to switch it off afterwards!
I have an application that does a lot of binary data loading. I've encountered scenarios where an unstable 3G connection may intermittently cut out during the loading of some of this binary data, causing issues.
Is there any way, using the simulator or otherwise, to test for low-bandwidth/unstable connection scenarios?
I seem to recall Adobe Flash having bandwidth simulators in their test suite.
You can accomplish this by creating a wireless network on your Mac using Internet Sharing, degrading that interface using firewall rules, and connecting your iPhone to that network. This will actually work to debug any device that connects to a wireless network.
Using this technique, you can simulate extremely meager, lossy, or latent networks.
I use this technique instead of Apple's official Network Link Conditioner for a couple reasons:
Throttling can be applied only to specific connected devices, rather than affecting your development machine's network connection.
It can be scripted to simulate rapidly changing or "bursty" networks.
Unlike the Network Link Conditioner built into iOS, you can change the settings while your application remains in the foreground.
This uses ipfw's dummeynet feature. ipfw is technically deprecated in modern versions of OS X, but it still works fine. Unfortunately, pf (the replacement) doesn't yet support arbitrary packet delays. I'll update this answer if something changes.
Creating an awful Wi-Fi network
Plug into Ethernet if you aren't already.
Enable Internet Sharing in the Sharing pane of System Preferences. Choose to "Share your connection from: Ethernet" and check "Wi-Fi".
Get your phone connected to the network you just created and make sure you can browse the web.
Tell Mac OS's built-in firewall (ipfw) to ensure packets that have latency applied (pass through the "dummynet" in ipfw parlance) are still routed through the normal rules. This allows Internet Sharing to continue working:
phil#Nebula ~$ sudo sysctl -w net.inet.ip.fw.one_pass=0
net.inet.ip.fw.one_pass: 0 -> 0
Configure the low-quality pipe through which your iPhone's traffic will pass (14Kb/s throughput with 1% packet loss):
phil#Nebula ~$ sudo ipfw pipe 1 config bw 14KB/s
phil#Nebula ~$ sudo ipfw pipe 1 config plr 0.01
The next step varies depending on whether you're on Mountain Lion or below, or Mavericks.
For Mountain Lion (10.8) or below:
Route packets into the pipe, but only for traffic over your AirPort interface:
phil#Nebula ~$ sudo ipfw add 10 pipe 1 ip from any to any via en1
00010 pipe 1 ip from any to any via en1
Important: If you're using an Air or new MacBook Pro without a physical ethernet port, your AirPort interface will likely be called en0. Replace en1 with en0 above if that's the case.
For Mavericks (10.9):
Check the output of ifconfig and look for the bridge interface created by Internet Sharing:
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether xx:xx:xx:xx:xx:xx
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en4 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 6 priority 0 path cost 0
nd6 options=1<PERFORMNUD>
media: <unknown type>
status: inactive
bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=3<RXCSUM,TXCSUM>
ether xx:xx:xx:xx:xx:xx
inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en1 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 5 priority 0 path cost 0
media: autoselect
status: active
You want the bridge interface that has an IP address; in most cases, it will be bridge100.
Route packets into the pipe, but only for traffic over the bridge interface:
phil#Nebula ~$ sudo ipfw add 10 pipe 1 ip from any to any via bridge100
00010 pipe 1 ip from any to any via bridge100
Change bridge100 if it has a different name on your system.
Simulating a changing network
You can change the values 14KB/s and 0.01 in step 5 above to simulate different types of networks. You can also specify config delay 1000 to introduce a 1000ms delay. See the manpage for more options.
You can continue to reconfigure the pipe after adding the rule for it. For instance, to simulate nearing the edge of cellular coverage, issue this command while your app is running and connected (95% packet loss):
phil#Nebula ~$ sudo ipfw pipe 1 config plr 0.95
There is no need to run sudo ipfw add 10 … again after reconfiguring the pipe. You can script these changes to simulate an extremely dynamic network environment.
Cleaning up
You can issue sudo ipfw delete 10 to put everything back to normal, or just reboot.
Here is a great script I've used on OS X to throttle connection speed, or just turn it off, for any domain you want. I wish I could remember where I got it from to give credit.
Save the code to a file on your machine and name it "throttling". Then to run, just enter the below in terminal, and select from one of these speeds: [full|fast|medium|slow|wwdc|off].
"./throttling medium"
If you have the script set up to throttle localhost:3000 and stackoverflow.com, then loading up a page from either of those domains in your browser (or iphone simulator or whatever) will respond slower and load files slower. It's been really great for testing iphone connectivity bugs.
http://gist.github.com/499177
You could test a number of things if you turn 3G off and connect to wifi.
Log into your router and rate limit the mac address of your iphone. (to test slow connections)
Kill the power to the wifi when in the middle of downloading data
Reboot the wifi router when downloading so the phone has connection, loses it, and gets it again. ( to test different scenarios )
Happy Coding!
I read of someone testing with their iPhone connected by USB cable and the phone wrapped in aluminum foil to get the cellular signal reduced. You can turn off WiFi and 3G and just have Edge and then attenuate it with foil. Sounds crude but...
You could also use an iPhone 4 and hold in your hand to short the two antennas together ;-)
Chrome 38 includes network emulation in the device emulation settings. You can select from Offline, GPRS, EDGE, 3G, DSL and WiFi. Also emulates increased latency.
It's not as accurate as testing on a real device but it's much quicker to set up.
Well, low bandwidth is simple: turn off Wifi, turn off 3G. Cutting connection is also simple: turn on wifi, get connected, power off your wifi access point.
I guess you could connect to a Mac (if you had one) setup as a WiFi base station (ad-hoc network). Then on the Mac set up a "dummynet" bandwidth limit and/or high packet loss filter.
That's what I do to simulate the slower higher-latency DSL lines I am making software to setup for Macs.
On the iPhone you can't. One way would be to share your computer WIFI connection to your iPhone but to slow it down using a special application.
This blog post describes some approaches for that:
http://blog.aptivate.org/2010/01/23/make-sure-your-apps-work-in-the-field/