[HN Gopher] Simultaneous AP and Client Mode Wi-Fi on Raspberry P... ___________________________________________________________________ Simultaneous AP and Client Mode Wi-Fi on Raspberry Pi Zero W Author : lukicdarkoo Score : 211 points Date : 2020-08-23 10:36 UTC (12 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | reactchain wrote: | Has anyone noticed a shortage of Pi Zeros recently? It seems | everywhere has run out of stock. | capableweb wrote: | Recently? I've seen a shortage (in EU shops (Pi Zero W | specifically)) since it was launched and seems it's not getting | better either. | kingosticks wrote: | Comes and goes. As it happens they are back in at | https://shop.pimoroni.com/products/raspberry-pi-zero-w | (limited to 1 per order). | LeoPanthera wrote: | I think this is intentional. The Pi Zero is mostly a marketing | device. It's advertised at $5 but unless you happen to have a | physical store selling them near you, it's not really $5 | because the shipping is never free and you can only ever by | one. So it's more like $15. | | Still not a crazy price, of course, I just dislike the | misleading advertising. | mleo wrote: | More time to tinker at home? Over the course of a couple weeks, | I purchased four a two months back. A project I worked on | inspired at least another person in my office to buy one. | wil421 wrote: | My local microcenter has been jammed packed since the | pandemic started. I also purchased 2 a few months back and a | bunch of accessories. | rootsudo wrote: | Always, it's been "limit:1" but you can buy the different kits, | even from the same vendor but not for $5. | basilfx wrote: | I've been using a similar solution, but I had quite some problems | using AP and client mode at the same time. The WiFi chip inside | the RPi Zero W (BCM43430) only supports AP and client mode on the | same channel. If you setup an AP first, then connect to a client | network, hostapd will update the channel of the AP, but clients | will notice a disconnect. There are also issues with the firmware | blob (see https://github.com/raspberrypi/firmware/issues/1403) in | AP mode that haven't been solved yet. | watchdogtimer wrote: | What I did on a similar project using a different board was | scan all the APs in the area first, get the band of the AP with | the strongest signal, then bring up the device AP using that | band. I figured the AP with the strongest signal is the closest | AP and the one you most likely want to connect to. | cptskippy wrote: | This is perfect for hotels whose TV sucks and their wifi has | those captive portals so you can't use a Chromecast, Firestick, | or Roku. | | It just needs a captive portal of its own when the client side is | disconnected. | non-entity wrote: | Just curious, but I was trying to help someone with a Raspberry | Pi Zero W wifi issue the other day and had trouble finding sny | info about the wireless chipset used. I couldn't find it listen | anywhere on the site, or several tech review sites, only | extremely useless information on the 802.11 versions support. If | it recall correctly, it didn't even show up in the schematica. | Luckily wikipedia had the name of the chipset used, but I don't | get it. Why does their official documentation seem to be so | secretive? | dc_count wrote: | It's not secretive, it's just that most people are not very | interested in the exact type of Wi-Fi chipset used. | | You can see the chipset name (BCM43430) on dmesg: | $ dmesg | grep brcmfmac [ 26.488164] brcmfmac: F1 | signature read @0x18000000=0x1541a9a6 [ 26.512759] | brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio | for chip BCM43430/1 [ 26.513315] usbcore: registered | new interface driver brcmfmac [ 26.539406] brcmfmac | mmc1:0001:1: Direct firmware load for | brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.txt | messe wrote: | Whatever happened to ad-hoc mode? | cordite wrote: | I haven't considered this since the days of Nintendo DS picto | chat. | capableweb wrote: | Not sure exactly what you're referring to, did the author | explain in the past they rather want ad-hoc network setup or | something? | | Otherwise, ad-hoc is different from AP+Client, as ad-hoc is | only between two devices (at least from what I gather) while | AP+Client would allow a distributed network where clients are | interconnected. | jiggunjer wrote: | I thought ad-hoc is N devices, optionally decentralized. This | could emulate that. | ausjke wrote: | ad-hoc in general runs a different path inside kernel module, | which is normally not supported as well as AP/client mode, so, | while many chips can do ah-hoc in theory, in software side it | is a difference story | mschuster91 wrote: | It's extremely rare that one gets to a working ad-hoc setup... | it's a chicken-egg problem. Drivers, firmware, software and UI | support are bad, so no one uses it, so development is an | afterthought, rinse and repeat. | punnerud wrote: | How to get faster internet at a hotel: Have 4-5 of these | connected and talking with the hotels WiFi, and one who share | Internet with you. All the traffic goes to a server you have at | home that "join+proxy" the traffic. Based on the idea that every | user have a limited bandwidth, combining multiple will give you | higher speed. | woleium wrote: | or just route over icmp or dns | ngcc_hk wrote: | Why is that not easy and widely used as nearly all devices we | used like camera (dslr to car camera) and remote controller all | resolved to stop WiFi and switch to another mode etc to connect. | caust1c wrote: | Partially because of chip capabilities, and partially because | understanding networking is hard. | | I don't think most chips can do this fwiw, but it's definitely | cheap enough now that cameras and IoT devices will probably | start doing it everywhere. | 7ewis wrote: | Would this be good for something like connecting the Pi to a VPN | for say Canada, then broadcasting an SSID for it. | | Then connecting a Fire TV Stick or Chromecast to this AP, and | tricking it into letting you stream Canadian Netflix or DAZN etc. | gzu wrote: | I was interested in setting up something similar (as a novelty) | to cheaply bypass an untrusted network. | | Untrusted Wifi > RasPi Client > OpenVPN > AP | | How would you go about routing the VPN device between client | and AP? | derefr wrote: | Maybe it was just an arbitrary example, but really, there's no | reason to want Canadian Netflix. We only get about half the | stuff the US does. | | Also, we have the same "content can't be offered here by | Netflix because the local IP license has been bought out by a | different owner" problem that the US and many other places | does; but in Canada's case, most of those local IP owners are | conservative dinosaur media companies, who either haven't | managed, or haven't bothered, to set up their own alternative | streaming services yet. They just... hold the licenses, doing | nothing with them. Hoarding them, like a dragon. So there are | many shows you just can't stream in Canada at all, no matter | who you're willing to pay. | yeswecatan wrote: | Sounds like it would work. I may give that a try. Now to find a | VPN for Canada... | | edit: Now that I think about it, what's the difference between | using the Pi as an AP and using it as a DNS server? | Raed667 wrote: | A bit off topic: | | I'm looking for a project that starts with an AP. Once someone | connected to it; it opens a web page to configure the client | (choose which WIFI from a list, and type the password). | | It connects to the chosen WIFI and shuts down the AP. | | Anyone here did something similar to that? | ncrmro wrote: | ESP-32 + captive portal? | | https://github.com/tonyp7/esp32-wifi-manager | flak48 wrote: | Yep. I didn't do it with a RasPi but with a Chinese chip I | found off AliExpress | | Managed to strip down OpenWRT so it would fit in the meager | 16MB RAM/8MB flash. In the init script (a bash script) just | checked if a wifi network was configured previously (creds | stored in a file). | | If configured, try to connect to the network for 10 seconds. If | it couldn't connect, then switch to AP mode and start a | lightHTTPd server listening on 192.168.0.1:80. | | The only files it served was a simple index.html with some JS | that called a bash script via CGI that used a openwrt bash | library to scan and list the available wifi networks. | | Then a HTML form to choose an SSID and enter the password, upon | submit call another bash file to connect to the network (switch | to client mode) with a timeout. If it fails, the bash would | switch back to AP mode. | | Polling in JS to check if the connection was successful (by | checking if AP mode becomes active again) | voltagex_ wrote: | WifiManager for the ESP8266/ESP32 will do that. | jiggunjer wrote: | This is basically what a chromecast does? | Raed667 wrote: | Exactly, I want to replicate that behavior in Raspberry Pi. | savrajsingh wrote: | Starting point: https://github.com/balena-io/wifi-connect | numpad0 wrote: | I've seen Raspberry Pi images from Ubiquity Robotics(not | Ubiquiti Networks) having similar daemon called "pifi" for | command line operation, but this one looks nicer | nebalee wrote: | https://github.com/davesteele/comitup does this. No idea how | well it works, I have not tried it yet. | kingosticks wrote: | https://github.com/billz/raspap-webgui | sdfhbdf wrote: | I've looked at the links posted here and the repo but I fail to | find what is the use case for this? | jonpurdy wrote: | I use a Pi Zero W + extra USB wifi to share modern wifi with my | legacy PowerBook 2400c + 802.11b PCMCIA card. | | This setup could let me do it without the USB wifi hanging off | the USB OTG adaptor. | | * This is not secure but it's fine for my vintage computing | hobby | lostapathy wrote: | I use a pi this way so I can join my pi to hotel wifi (or | similar) then join my iPad to the pi's network - which lets me | ssh into the pi to access software there while both devices | have internet access. | rootsudo wrote: | I do the same with a pocket wifi router, and clone the mac | address. So, nifty and interesting case for the pi too! | Thanks! | gumby wrote: | Ever stay at a hotel that charges for wifi access on a per | device basis? | BossingAround wrote: | I've never stayed at a hotel that'd charge extra for wifi. | Airports and planes thoug, sure. | dboreham wrote: | No, but it's not uncommon to find hotel internet that has a | fairly low device count limit. The place I use WiFi repeaters | is on airplanes, to avoid the hassle of re-authenticating | every time I switch between phone and tablet and laptop. | post_break wrote: | A perfect MITM device that is tiny and can be hidden somewhere | is my first use case. Micro pineapple. | opencl wrote: | It could be used as a range extender, though not a very good | one. | | Probably a better use case would be connecting older devices | like the Nintendo DS that don't support WPA2 to your network | without forcing all of your other devices onto WEP. | sleavey wrote: | Why not a very good one? In terms of range (with the PCB | antenna)? Or does the Pi firmware not support some modern | 802.11 standards or what? | flaviu2 wrote: | I'd guess the hardware is the problem. Most antennas I've | seen on access points are larger than the entire Pi Zero W. | While I'm no radio expert, I'd expect APs to use the | smaller antennas if they were capable of being as good as | bigger antennas. | sleavey wrote: | Ah, that reminds me of an article someone here linked to | a few years ago: [1]. That claims the efficiency is -3.5 | dB compared to a typical -1.25 dB dipole in dedicated | wireless equipment. Not bad; the difference is only a | factor of ~2 in power for x8 reduction in size. | | [1] https://www.embedded-computing.com/articles/a-lesson- | in-wire... | zamadatix wrote: | Well 2 things really. Yeah the hardware is a bit garbage as | it only goes up to 802.11n only on 2.4 GHz and it's also a | 1x1 with a poor antenna. The big thing though is it | requires you use the same channel which is disastrous for | repeater performance. | | Ideally you'd have 802.11ac/ax with 2 separate PHYs each | with 4x4 (even if the clients are 1x1 or 2x2 the additional | beamforming helps) set to two separate channels. | | That's not to say it won't function well enough in a pinch | but I wouldn't seek this out as a permanent answer if I | were buying new. | muppet_frog wrote: | ...sounds like it costs _much_ more than the $10 pi0... | | I imagine the OP's use case of IoT did not require huge | amounts of bandwidth. | zamadatix wrote: | "That's not to say it won't function well enough in a | pinch but I wouldn't seek this out as a permanent answer | if I were buying new." | | Like I said this functions fine, as is evident by it | having been posted, but the question was why it wasn't a | very good repeater not was it a functional use of an | existing pi 0 laying around. | | It's also not the best you could do buying new if that is | what you had to do as ~$16 will get you a 2x2 802.11n | repeater that functions much better, has external | antennas, and has an ethernet port too. Not $10 but it's | also enclosed and doesn't need a power supply or uSD. | ~$30 will get you decent AC repeaters you could use | outside of a singular IoT project. Less for either if | you're willing to go used. The ideal 4x4 ax double phy | wireless repeater is indeed going to be more than a pi 0 | but it was an example of what makes a repeater good (to | the question) not what should have been purchased for | this project. | | Again nothing wrong with the solution used here, that's | not where my comment was pointed. | agarzenm wrote: | The use case is in the title. You can use it as a wireless | repeater. A more interesting use case would be ethernet over | USB and a wireless AP with another interface for client | monitoring via airmon. | karmicthreat wrote: | I use this for configuration on some equipment I sell. The unit | has a local web server that lets you configure IP, ID | information. It works as a captive portal. Then you just plug | your ethernet cable in and its good to go. (I use a Pi 3 in the | product). | BossingAround wrote: | I wonder what's the use case other than a poor wifi extender, or | niche cases of sharing one connection between multiple devices | where you pay per connection. | | Though I do wonder whether you can add a proper wifi antenna and | make the RPI an 'ok' wifi extender. That might be a viable | option, provided the performance is ok. | EricE wrote: | Or provide a gateway for wireless devices that don't support | WPA2 Enterprise? Interesting.... | cmxch wrote: | Initial configuration/management for the device in question. | TaylorAlexander wrote: | Would be good for a robot you can ssh in to at home and still | connect when out in the field. | noncoml wrote: | VPN access point | dcminter wrote: | The pithier article (linked to from the above) is at | | https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simul... | lukicdarkoo wrote: | The script is heavily based on the article. Full credit to the | article! | | For everybody interested in details, the article gives useful | insights on configuration automated by the script. | djsumdog wrote: | I noticed the script was using the same MAC address for the ap0 | adapter. From that blog post... | | > A number of tutorials I found claimed that the address for | the virtual AP must be different from the primary MAC address. | I found there to be no difference in behavior, but you should | be able to change the last byte, for example, to give your | client and AP different MACs. | | huh ... You'd think this could cause interference, but I guess | not if they have different SSIDs and passwords. | brendawalsh wrote: | Any idea why systemd was not able to be reliably used, and had to | use cron? | | Is there a 'fix' for that ? | | edit: This was not meant to be offensive. I was simply hoping | somebody could offer how it could be used with systemd and remove | the reliance on cron. | Nextgrid wrote: | I think it's just a shortcut because of lack of experience with | systemd (this is not intended to be offensive btw - if cron is | already installed and you save time by just using what you | know, why not?). I would be very surprised if cron could do | something that can't be done with systemd timers. | brendawalsh wrote: | I saw the apt install cron, and wondered what the solution | w/out cron entailed. | lukicdarkoo wrote: | I suspected that the network wasn't ready, so I configured | the service start after network without much luck. I didn't | go further than that. | Nextgrid wrote: | Systemd can be very powerful and you can even depend on | individual devices being added/removed. I'm pretty sure you | can even replace the udev rules with a systemd equivalent | if you tried hard enough. | lukicdarkoo wrote: | No idea! I spent some time debugging it, but it just does't | make sense it works with cron and not with systemd. Let me know | if you have any idea where to look! | nottorp wrote: | Because systemd does many things badly instead of one thing | well :) | Dahoon wrote: | So in short a poor range extender or a way to do MitM. | op03 wrote: | The Offline Wikipedia/Stackexchange project (Kiwix) has similar | devices for kids classrooms/libraries in rural areas with no | internet - https://www.kiwix.org/en/downloads/kiwix-hotspot/ | shubhamjain0594 wrote: | Thanks for this. | | I had built [similar | repository](https://github.com/computationalprivacy/unveil-pi- | data-colle...) as a part of wifi data capture and visualisation | experiment ([Project | UNVEIL](https://github.com/computationalprivacy/unveil- | deployment)) but it used external antenna. | | Any links on how does underlying hardware work to enable | simultaneous connections? | lioeters wrote: | Here's the article which the posted GitHub project is based on. | | https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simul... | | > At this point, we should be able to connect a device to our | Raspberry Pi Zero W's AP SSID, while we also have our RPi | connect to another access point for internet access, and we | should be able to access the internet from that device through | our RPi. | | The "simultaneous" aspect seems to be achieved by having two | devices: wlan0 and ap0, the latter created by udev. | sorenjan wrote: | Can this be used as a range extender if you use the same SSID and | password for the access point as the net you're connecting to? | Would other clients silently roam between the two (or more) | networks using the same name and password? | jiggunjer wrote: | I think it would need to spoof the same MAC as the original AP | too. | est31 wrote: | No, the identification method of an extended service set is | the SSID, aka the network name. Just set up the same SSID and | password on both APs, and put them onto the same ip layer | network. Your device will roam the networks automatically. | Each AP should get its own MAC otherwise they will think | packets sent to the other AP was meant for them. WiFi is | robust enough to deal with noise like e.g. bluetooth, so it | might survive it, but I doubt it'd support two STAs with the | same BSSID communicating with each other. | | https://en.wikipedia.org/wiki/Service_set_(802.11_network) | voltagex_ wrote: | How do you do this with most consumer devices? The only AP | I've seen do it successfully is the AsusWRT series - Media | Extender mode seems to be transparent. If I try it with | anything else I'll end up with two seperate networks, e.g. | 192.168.8.0/24 connected to 10.1.1.0/24 (I actually have a | GL.inet AR750S in this configuration right now) | jonathonlui wrote: | If you can wire the 2 AP via a LAN, then this is how I've | used cheap consumer wifi APs which are usually combo | AP+router devices: | | The first AP is connecting to internet gateway through | its WAN port. This AP does the networking stuff like | DHCP, NAT, etc. | | The other wifi APs are configured to be AP-only, i.e. | disable DHCP. Use same wifi SSID and auth settings as the | first AP. Then connect the APs using their LAN ports. | | Client devices should now connect to the AP with the best | signal. | | But if the client is already connected to an AP and a | better-signal AP is available, many clients won't | automatically connect to the better AP. This is because | the client don't know that the other AP is the same | network. So if you move around you may need to trigger | the client to disconnect and reconnect. | | This can be solved with APs that have a "mesh" feature | which can instruct connected clients to reconnect to a | better AP in the same network using | https://en.wikipedia.org/wiki/IEEE_802.11k-2008 but AFAIK | mesh systems from different manufacturers aren't | interoperable. | not_exactly__ wrote: | I'd like to know this too please :) | [deleted] ___________________________________________________________________ (page generated 2020-08-23 23:00 UTC)