RTL8188CUS AP and Client mode simultaneously with hostapd in Linux?

6

3

I'm trying to figure out how to set up my RTL8188CUS Wifi dongle to run in both AP and Client mode at the same time.

How can I do this in Linux?

I have hostapd running fine and I remember reading about AP+Client mode somewhere a while ago for the RTL8188, but I can't remember where.

Additional info

I'm on Debian 4.7.2-5 for ARM. Linux kernel 3.4.90+.

I found the following threads that might be of use and (I think) relevant:

Link 1: How do I use a single wireless adapter for both an access point and client on raspberry pi? Link 2: Creating WiFi Access point on a single interface in Linux

I tried the first first link, no success.

UPDATE

I have managed to get iw list to work on Debain 8 Jessie x64.

It outputs the following:

software interface modes (can always be added):

    * AP/VLAN
    * monitor

interface combinations are not supported

However according to Realteks release notes of their latest drivers they state that the RTL8188CUS supports concurrent modes such as STA+AP as of version 4.0.0_5967.20121201

Doesn't this contradict what iw list states?

If not, how would an STA+AP mode be achieved?

UPDATE I figured it out. Please see my answer for more info.

vaid

Posted 2016-02-04T19:42:51.523

Reputation: 3 309

Adding details of the distribution and version would probably help. – jcaron – 2016-02-07T15:50:15.973

@jcaron good idea. I updated. – vaid – 2016-02-07T17:38:58.797

You ought to investigate why the command 'iw dev wlan0 del' does not work, it is a standard command in Debian, and the arm architecture does have the iw package. You should have it already installed, by default that is. – MariusMatutiae – 2016-02-07T22:09:31.683

dang. how do I figure that out? – vaid – 2016-02-07T23:25:31.717

Answers

3

I managed to solve my problem after a couple of weeks of research.

Simple answer is;

The command iw does not find any indications of mixed modes on RTL chips. The reason being that the RTL drivers by default do not support mixed modes.

Realtek call this Concurrent modes, and the RTL drivers are by default compiled with the concurrent mode-related code commented out.

In order to compile the drivers with concurrent mode activated you need to simply uncomment 3 lines of code in their source code.

Concurrent modes supported are STA+STA, STA+AP, STA+P2P.

You can find my full back-story and full guide on how to compile the drivers and the RTL compatible HOSTAPD version on this link:

http://randomstuffidosometimes.blogspot.se/2016/03/rtl8192cu-and-rtl8188cus-in-station-and.html

vaid

Posted 2016-02-04T19:42:51.523

Reputation: 3 309

Thanks for the great research you did here. Now I'm trying to find a chip that does STA+AP simultaneous on different channels, possibly but not necessarily different bands. – awy – 2018-01-12T16:30:54.493

4

It depends on network cards. I do not own an RTL8188, so i cannot tell you off-hand, but I can show you how to find out.

You must issue the command

 iw list

and, among its abundant output, you will find something like:

Supported interface modes:
             * IBSS
             * managed
             * AP
             * AP/VLAN
             * monitor
    software interface modes (can always be added):
             * AP/VLAN
             * monitor
    valid interface combinations:
             * #{ managed } <= 1, #{ AP } <= 1,
               total <= 2, #channels <= 1, STA/AP BI must match
             * #{ managed } <= 2,
               total <= 2, #channels <= 1

AP mode is the Access Point mode, managed is the usual client mode, and this is for my card.

You must check that both AP and managed appear among the supported modes, then you must check the valid interface combinations: in my case, the first allowed combination is clearly that of a (simultaneous) AP and managed mode (but no more than one each), provided the same channel is used. It might be different in your case.

In order to make this work, you must have two distinct virtual interfaces on the same NIC. You do it as follows:

service network-manager stop
iw dev wlan0 del
iw phy phy0 interface add new0 type station
service network-manager start
iw phy phy0 interface add new1 type __ap
hostapd -B /etc/hostapd.conf

First I stop the network manager, which has its own way of messing everything up, then I rename new0 the virtual interface on the physical interface called phy0 (adapt it to your case if yours is not called phy0, you obtain the name from the output of iw list), restart the network manager so that I can connect the virtual interface new0 to whichever AP I have near me.

Now I can add a new interface of type AP on the same hardware (please notice the double underscore preceding ap in the command), lastly I start hostpad.

The configuration of hostapd and of routing/DNS/DHCP depends on your specific needs, and cannot be established a priori.

MariusMatutiae

Posted 2016-02-04T19:42:51.523

Reputation: 41 321

Thanks, but on the first command I get an error saying that the service network-manager does not exist. What should I do? I run no graphical software, my device is pure non-gui. – vaid – 2016-02-06T17:50:54.580

@vaid If you do not have a network-manager, that's no problem, just forget about it. You will have to learn how to connet via wifi from the CLI, that's all. – MariusMatutiae – 2016-02-06T18:06:31.393

Im sorry, you might have misunderstood me as I might have not been clear enough. I can connect to a network of my choice or run in AP mode as I wish, I know how to do that. I would like to figure out how to do both at the same time. Or am I misunderstanding you now? – vaid – 2016-02-06T20:53:30.050

It's weird iw listgives me no output, but iwlistdoes? Anyways iwlist gives me the following output: – vaid – 2016-02-06T20:59:24.693

[interface] scanning [essid NNN] [last] [interface] frequency [interface] channel [interface] bitrate [interface] rate [interface] encryption [interface] keys [interface] power [interface] txpower [interface] retry [interface] ap [interface] accesspoints – vaid – 2016-02-06T20:59:36.363

[interface] peers [interface] event [interface] auth [interface] wpakeys [interface] genie [interface] modulation – vaid – 2016-02-06T20:59:43.120

Btw, I can't run any of the commands you provided. For example iw dev wlan0 del gives me the error command failed: No such device (-19). But wlan0 does exist. What should I do? – vaid – 2016-02-07T07:43:21.317

@vaid What is the output of iwconfig? If that fails, of ifconfig? If that fails, of ip link show? – MariusMatutiae – 2016-02-07T08:03:43.183

please see the edit in my question. I added the output there since the text won't be properly formatted in a comment. – vaid – 2016-02-07T15:20:48.557

I have managed to figure out why iw list doesn't work, as you may have noticed on the other question. please read my edited question for more information. – vaid – 2016-03-09T05:36:44.363

I have now also figured out how to put an RTL8188CUS and RTL8192CU in STA+AP mode. I'll answer my own question once I've documented a step-by-step guide. – vaid – 2016-03-11T23:51:51.883