How to set up Wi-Fi



Introduction


I think I’m not mistaken if most of us have an Internet connection as follows: there is some fairly high-speed wired channel to the apartment (now gigabit is not uncommon), and in the apartment it is met by a router that distributes this Internet to customers, giving them "Black" ip and translating addresses.

Quite often, a strange situation is observed: with a high-speed wire, a very narrow wifi channel is heard from the router, not loading even half of the wire. At the same time, although formally Wi-Fi, especially in its ac version supports some huge speeds, when checking it turns out that either Wi-Fi connects at a lower speed, or connects, but does not issue speed in practice, or loses packets, or all together.

At some point, I also faced a similar problem, and decided to set up my Wi-Fi in a human way. Surprisingly, it took about 40 times longer than I expected. In addition, it somehow happened that all the instructions for setting up Wi-Fi that I found converged in one of two ways: in the first they suggested putting the router higher and straightening the antenna, for reading the second I lacked an honest understanding of spatial multiplexing algorithms .

Actually, this note is an attempt to fill the gap in the instructions. I’ll say right away that the problem has not been completely solved, despite decent progress, the stability of the connection could still be better, so I would be glad to hear the comments of my colleagues on the topic described.

Chapter 1:


So, the problem statement the

Wifi router proposed by the provider has ceased to cope with its duties: there are long (30 seconds or more) periods when ping does not pass to the access point, there are very long (about an hour) periods when the ping reaches the access point 3500 ms, there are long periods when the connection speed with the access point does not exceed 200 kbit / s.

Range scanning using the inSSIDer windows utility yields the image presented at the beginning of the article. In the district there are 44 Wifi SSIDs in the 2.4 GHz band and one network in the 5.2 GHz band.

Solution tools

Self-assembled computer Celeron 430, 2b Ram, SSD, fanless, two wireless network cards based on the Ralink rt2800pci chip, Slackware Linux 14.2, Hostapd from Git for September 2016.

The assembly of the router is beyond the scope of this article, although I note that the Celeron 430 performed well in fanless mode. I note that the current configuration is the last, but not final. Perhaps improvements are still feasible.

Solution

In fact, the solution should, for good, be to start hostapd with minimal configuration changes. However, experience so well confirmed the truth of the saying "it was smooth on paper, but forgot about the ravines" that it took to write this article to systematize knowledge of all the unobvious details. Also, I initially would like to avoid the low-level details for the harmony of presentation, but it turned out that this is impossible.

Chapter 2


Bit of theory

Frequencies


Wi-Fi is the standard for wireless networks. From the point of view of OSI L2, the access point implements a switch type hub, however, most often it is also combined with an OSI L3 router type switch, which leads to a fair amount of confusion.

We are most interested in the OSI L1 level, that is, in fact, the environment in which the packets go.

Wi-Fi is a radio system. As you know, a radio system consists of a receiver and a transmitter. In Wi-Fi, the access point and client device both take turns playing roles.

The Wi-Fi transmitter operates at a certain frequency. These frequencies are numbered, and each number corresponds to a certain frequency. Important: despite the fact that for any integer there is a theoretical correspondence to this number of a certain frequency, Wi-Fi can work only in limited frequency ranges (there are three, 2.4 GHz, 5.2 GHz, 5.7 GHz), and only on some of the numbers.

The full list of correspondences can be found in Wikipedia, but it’s important for us that when setting up the access point, you must specify on which channel the carrier frequency of our signal will be located.

An unobvious detail: not all Wi-Fi standards support all frequencies.

There are two Wi-Fi standards: a and b. “A” is older and works in the 5 GHz band, “b” is newer and works in the 2.4 GHz band. At the same time, b is slower (11 mbit instead of 54 mbit, that is, 1.2 megabytes per second instead of 7 megabytes per second), and the 2.4 GHz range already contains fewer stations. Why so is a mystery. It’s doubly a mystery why there are practically no access points of standard A in nature.

image
(The picture was taken from Wikipedia.)

image

(Actually, I’m cunning a little, because a still supports the 3.7 GHz frequency range. However, I have never seen a single device that knows anything about this range.)

Wait, you ask , but there are still 802.11g, n, ac standards, and it seems that they should just beat the speedy unfortunate a and b.

But no, I will answer you. The g standard is a belated attempt to bring speed b to speed a, in the 2.4 GHz band. But why, you answer me, did you even remember about b? The answer is because despite the fact that the ranges of both b and g are called 2.4, in fact they are slightly different, and the range of b is one channel longer.

Standards n and ac in general are not related to ranges - they regulate speed, and nothing more. The point of the standard n can be both “in the base” a (and operate at 5 GHz), and “in the base” b and operate at 2.4 GHz. I don’t know about the ac standard point, because I haven’t seen it.

That is, when you buy an access point n, you need to look very carefully at what ranges this n works.

It is important that at one time, one Wi-Fi chip can work in only one band. If your access point claims that it can work in two at the same time, as, for example, they make free routers from the popular providers of Virgin or British Telecom, then it actually has two chips.

Channel width


Actually, I have to apologize because I said earlier that a certain range is longer than the other without explaining what is “longer”. Generally speaking, not only the carrier frequency, but also the width of the encoded stream is important for signal transmission. The width is what frequencies the signal can climb above and below the carrier. Usually (and fortunately, in Wi-Fi), the channels are symmetrical, centered on the carrier.

So in Wi-Fi there can be channels with a width of 10, 20, 22, 40, 80 and 160 MHz. At the same time, I never saw access points with a channel width of 10 MHz.

So, one of the most amazing features of Wi-Fi is that although the channels are numbered, they intersect. And not only with the neighbors, but already with channels through 3 from myself. In other words, in the 2.4 GHz band only access points operating on channels 1, 6 and 11 do not intersect with 20 MHz wide streams. In other words, only three access points can work side by side so as not to interfere with each other.

What is an access point with a channel width of 40 MHz? The answer is, and this is an access point that occupies two channels (disjoint).

Question: How many channels with a width of 80 and 160 MHz fit in the 2.4 GHz band?

Answer: Not a single one.

The question is, what does the channel width affect? I do not know the exact answer to this question; I could not verify it.

I know that if a network intersects with other networks, connection stability will be worse. 40 MHz channel width gives more crossovers and worse connection. According to the standard, if there are other access points working around the point, the 40 MHz mode should not be turned on.

Is it true that twice as large channel width doubles as much as possible throughput?
It seems to be, yes, but it is impossible to verify.

Question: If there are three antennas on my access point, is it true that it can create three spatial streams and triple the connection speed?

Answer: unknown. It may turn out that of the three antennas, two can only send, but not receive packets. And the signal speed will be unbalanced.

Question: So how many megabits does one antenna give?

Answer: You can look here en.wikipedia.org/wiki/IEEE_802.11n-2009#Data_rates The
list is strange and non-linear.

Obviously, the most important parameter is the MCS index, which precisely determines the speed.

Question: Where do such strange speeds come from?

Answer: There is such a thing as HT Capabilities. These are optional chips that can slightly correct the signal. Chips can be very useful: SHORT-GI adds a little bit of speed, about 20 Mbps, LDPC, RX STBC, TX STBC add stability (that is, they should reduce ping and packet loss). However, your hardware can easily not support them and at the same time be completely “honest” 802.11n.

Signal strength


The easiest way to deal with poor communications is to fry more power into the transmitter. In Wi-Fi, transmission power is up to 30 dBm.

Chapter 3


Solution of the problem

From the above vinaigrette, it would seem, we can draw the following conclusion: in Wi-Fi, you can implement two "modes" of functioning. "Improving speed" and "improving quality."

The first, it would seem, should say: take the most unoccupied channel, 40 MHz channel width, more antennas (preferably 4), and add more Capabilities.

The second - remove everything except the basic n-mode, turn on more power, and turn on those Capabilities that add stability.

Remembering once again the proverb about the ravines, we will describe what kind of roughness of the terrain is waiting for us when trying to implement plans 1 and 2.

Ravine zero


Although the Ralink rt2x00 family of chipsets are the most popular chipsets with support for the n standard and are found both in high price range cards (Cisco) and in the budget range (TRENDNET), and moreover, they look absolutely the same in lspci, they can have radically different functionality, in particular, support only the 2.4 band, only the 5 GHz band, or support incomprehensibly than the limited parts of both ranges. What are the differences - a mystery. It’s also a mystery why a three-antenna card only supports Rx STBC in two streams. And why they both do not support LDPC.

First ravine


In the 2.4 range, there are only three disjoint channels. We have already spoken on this subject and I will not repeat myself.

Second ravine


Not all channels allow you to increase the channel width to 40 MHz, moreover, the channel width the card will agree to depends on the chipset of the card, the manufacturer of the card, processor load and weather on Mars.

The third and largest ravine


Regulatory domain

If it was not enough for you to be happy that the Wi-Fi standards themselves are a noble vinaigrette, rejoice that every country in the world seeks to infringe and limit Wi-Fi in all sorts of different ways. We in the UK are still not so bad, unlike, say, those of the United States, where the Wi-Fi spectrum is regulated to impossibility.

So, the regulatory domain may require restrictions on the transmitter power, on the ability to run an access point on the channel, on acceptable modulation technologies on the channel, and also require some technologies for pacification of the spectrum, such as DFS(dynamic frequency selection), radar detection (which even each regdomain has its own, say, in the Americas is offered by the FCC almost everywhere, in Europe it is different, ETSI), or auto-bw (I don’t know what it is). However, with many of them, the access point will not start.

Many regulatory domains simply prohibit certain frequencies in principle.

You can set the regulatory domain with the command:

iw reg set NAME

The regulatory domain can not be set, but then the system will be guided by the union of all restrictions, that is, the worst option possible.

Fortunately, firstly, data on regulatory domains is publicly available on the kernel website:

git.kernel.org/cgit/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt

And you can search for them . In principle, it is probably possible to patch the kernel so that it ignores the regulatory domain, but it is necessary to rebuild the kernel, or at least the crda regulatory daemon.

Fortunately, the team iw phy infodisplays all the capabilities of our device, taking into account (!) The regulatory domain.

So, how do we fix our Wi-Fi?

First, find a country in which channel 13 is not prohibited. At least half the frequency path will be empty. Well, there are quite a few such countries, although some, without prohibiting it in principle, however, they prohibit either high speed n mode or the creation of an access point on it.

But one 13 channel is not enough for us - because we want a larger signal-to-noise ratio, which means we want to launch a point with a signal strength of 30. We are looking for, we are looking at CRDA, (2402 - 2482 @ 40), (30)channel 13, width 40 MHz, signal strength 30. There is such a country, New Zealand.

But what is it, at 5 GHz, DFS is required. In general, this is theoretically supported configuration, but for some reason does not work.

Optional task performed by people with advanced social skills:

Collect signatures / movement in support of accelerated re-licensing of Wi-Fi bands in ITU (well, or at least in your country) as a whole towards expansion. It’s real, some deputies (and candidates), eager for political points, will be happy to help you.

image

This is ravine number 4


The access point may not start in the presence of DFS, without explanation. So, which regulatory domain should we choose?

There is one! The freest country in the world, Venezuela. Its regulatory domain is VE.

A full 13 channels of the 2.4 range, with a power of 30 dBm, and a relatively relaxed 5 GHz range.

Task with an asterisk. If your apartment is completely in disaster, even worse than mine, there is a separate bonus level for you.

The regulatory domain "JP", Japan, allows you to do a unique thing: launch an access point on the mythical channel 14. True, only in mode b. (Remember, I said that there are still small differences between b and g?) Therefore, if everything is really bad for you, then channel 14 can be a salvation. But then again, it’s physically supported by few client devices and access points. And the maximum speed of 11 Mbps is somewhat discouraging.

Copy /etc/hostapd/hostapd.conf into two files, hostapd.conf.trendnet24 and hostapd.conf.cisco57 We

trivially correct /etc/rc.d/rc.hostapd so that two copies of hostapd are launched.

We indicate channel 13 in the first one. True, we indicate the signal width 20 MHz (capability 40-INTOLERANT), because firstly, we will be theoretically more stable, and secondly, “law-abiding” access points will simply not start at 40 MHz from - because of the clogged range. We put capability TX-STBC, RX-STBC12. We cry that the capabilities LDPC, RX-STBC123 are not supported, and SHORT-GI-40 and SHORT-GI-20, although they are supported and slightly improve speed, they also slightly reduce stability, which means we remove them.

True, for fans, you can patch hostapd so that the force_ht40 option appears, but in my case it makes no sense.

If you are in a strange situation when access points turn on and turn off, then for special gourmets you can rebuild hostapd with the ACS_SURVEY option, and then the point will first scan the range and select the least “noisy” channel. Moreover, in theory, it should even be able to switch at will from one channel to another. True, this option did not help me, alas :-(.

So, our two points in one building are ready, we start the service:

/etc/rc.d/rc.hostapd start

The points start successfully, but ...

But the one that works on the 5.7 range is not visible from the tablet. What the hell is this?

Ravine number 5


The damned regulatory domain works not only on the access point, but also on the receiving device.

In particular, my Microsoft Surface Pro 3, although made for the European market, basically does not support the 5.7 range. I had to switch to 5.2, but here at least 40 MHz mode was started.

Ravine number 6


Everything started up. The points started, 2.4 shows the speed of 130 Mbps (would be SHORT-GI, it would be 144.4). Why a card with three antennas supports only 2 spatial streams is a mystery.

Ravine number 7


Start up something, and sometimes ping jumps to 200, and that's it.

And the secret is not hiding at the access point. The fact is that, according to Microsoft's rules, Wi-Fi card drivers themselves must contain software for searching for networks and connecting to them. It’s just like in the good old days when a 56k modem was supposed to have a dialer (which we all changed to Shiva, because the dialer that came with Internet Explorer 3.0 as standard was too terrible) or the ADSL modem should have a client PPPoE.

But those who do not have a standard utility (that is, everyone in the world!), Microsoft took care of it by making the so-called “Wi-Fi auto configuration”. This auto-configuration cheerfully spits on the fact that we are already connected to the network and scans the range every X seconds. In Windows 10, there is not even a “refresh network” button. It works fine while there are two or three networks around. And when there are 44 of them, the system freezes and issues a few seconds of ping 400.

You can turn off "Auto-configuration" with the command:

netsh wlan set autoconfig enabled=no interface="???????????? ????"
pause

Personally, I even made myself two batch files “turn on autoscan” and “turn off autoscan” on the desktop.

Yes, please note that if you have Russian Windows, then most likely the network interface will have a name in Russian in the IBM CP866 encoding.

Sammari


I rolled up a rather long sheet of text, and should have completed it with a brief summary of the most important things:

1. An access point can work in only one range: 2.4 or 5.2 or 5.7. Choose carefully.
2. The best regulatory domain is VE.
3. The iw phy info, iw reg get commands will show you what you can.
4. Channel 13 is usually empty.
5. ACS_SURVEY, 20 MHz channel width, TX-STBC, RX-STBC123 will improve the signal quality.
6. 40 MHz, more antennas, SHORT-GI will increase speed.
7. hostapd -dddtK allows you to run hostapd in debug mode.
8.For fans, you can rebuild the core and CRDA, increasing the signal strength and removing the restrictions of the regulatory domain.
9. Wi-Fi auto search in Windows is disabled with the netsh wlan set autoconfig enabled = no interface = "???????????? ????" command
10 . Microsoft Surface Pro 3 does not support the 5.7 GHz band.

Afterword


I found most of the materials used in writing this manual either in google or in the mana for iw, hostapd, hostapd_cli.

In fact, the problem was NOT RESOLVED. At times, ping still jumps to 400 and stands at that level, even for the “empty” range of 5.2 GHz. Therefore:

I’m looking for a Wi-Fi band spectrum analyzer in Moscow, equipped with an operator, with whom I could check what the problem is and whether it is that there is a very important and secret military institution nearby, which no one knows about.

P.S


Wi-Fi operates at frequencies from 2 GHz to 60 GHz (less common formats). This gives us a wavelength of 150mm to 5mm. (Why do we even measure the radio in frequencies, and not in wavelengths? It’s also more convenient!) I generally have an idea to buy wallpaper from a metal grid at a quarter wavelength (1 mm is enough) and make a Faraday cage to guarantee isolate from neighboring Wi-Fi, and at the same time from all other radio equipment, such as DECT phones, microwave ovens and road radars (24 GHz). One trouble - GSM / UMTS / LTE phones will also block, but you can select a stationary charging point for them near the window.

I will be glad to answer your questions in the comments.

Also popular now: