Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction of WIFI function in Linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "introduction to the function of WIFI in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Wifi module driver

The first step in using the system wifi feature is to determine the model of the device wifi module and install the appropriate driver. In embedded development, it is generally necessary to obtain the driver source code of the wifi module, and then cross-compile to build the driver module and install it using the insmod command.

In general, WIFI modules operate in two modes:

Station Mode: workstation mode, used to access AP such as routers

AP Mode: access point mode, which is used for access

The wifi driver code may be different for different modes, so you may need to install two driver modules to support these two modes. For details, please refer to the manual and guide documentation of the corresponding wifi module.

Main tools

There are two main wifi configuration tools used in Linux systems:

Wireless tools: includes tools such as iwconfig,iwlist,iwspy,iwpriv, and mainly configures wep encryption wifi

Wpa_supplicant: includes tools such as wpa_cli,wpa_supplicant, and mainly configures wpa encryption wifi

Because most of the commonly used wifi networks are encrypted using the wpa protocol, wpa_supplicant tools are used more, but in the management of wifi interfaces, wireless tools tools are still very useful.

Wireless tools

This toolkit is one of the user-level configuration tools of Linux Wireless Extensions (LWE). LWE is a tool for wireless network configuration under Linux, including kernel support, user layer configuration tools and driver interface support. At present, many wireless network cards support LWE, and mainstream Linux releases, such as Redhat Linux and Ubuntu Linux, have come with this configuration tool.

After compiling and building, commands are generated: iwconfg,iwlist,iwspy,iwpriv, etc. The use of these commands depends on the generated dynamic library file: libiw.so.29, so when copying these commands to the target machine, remember to copy the library file together to the system's lib directory, otherwise you will be prompted that the library file cannot be found.

Iwconfig is the most important tool of LWE, which can configure most of the parameters of wireless network card. Specific command parameters and options can be viewed and understood through the help command. Some of these parameters are explained as follows:

Essid: sets the ESSID (Extension Service Set ID) of the wireless network card. ESSID is used to distinguish different wireless networks. Normally, only wireless stations with the same ESSID can communicate with each other, unless you want to monitor the wireless network. The following argument is an ESSID string enclosed in double quotes, or any/on/off, and if the ESSID string contains any/no/off, you need to precede it with "- -".

Mode: sets the working mode of the wireless network card, which can be

Ad-hoc: peer-to-peer wireless network without AP

Managed: through a network of multiple AP, wireless devices can roam in this network

Master: set the wireless network card to an AP

Repeater: set to a wireless network relay device that can forward network packets

Secondary: AP/Repeater set as backup

Monitor: monitoring mode

Auto: work mode is automatically selected by wireless network card

Freq/channel: set the working frequency or channel of the wireless network card. Parameters less than 1000 are considered channels, and parameters greater than 10000 are considered frequency. Frequency unit is Hz, can be followed by k, M, G to change the order of magnitude, such as 2.4G. The channel starts at 1. Use the iwlist tool to view the frequencies and channels supported by the wireless network card. The parameter off/auto indicates that the wireless network automatically picks the frequency. Note: if it is in Managed mode, AP will indicate the working frequency of the wireless network card, so the parameter of this setting will be ignored. In Ad-hoc mode, only the set frequency is used to initiate the wireless network, and the frequency parameter of this setting will be ignored if you join the existing Ad-hoc network.

Ap: connect to a specified AP or wireless network, and the following parameters can be the MAC address of the AP or the identifier from the iwlist scan. If Ad-hoc, connect to an existing Ad-hoc network. Use the off parameter to let the wireless network card enter the automatic mode without changing the currently connected AP. Any/auto parameter, the wireless network card automatically selects the best AP. Note: if the wireless signal is low to a certain extent, the wireless network will enter the automatic selection AP mode.

Rate/bit: if the wireless network card supports multi-rate, you can set the rate of operation through this command. The parameters less than 1000 are defined by the specific wireless network card driver, which is generally the index value of the transmission rate, and the one greater than 1000 is the rate, unit bps, which can be followed by k, M, G to specify the quantity level. The auto parameter allows the wireless network card to automatically select the rate fixed parameter so that the wireless network card does not use the automatic rate mode.

Txpower: if the wireless network card supports multiple transmit power settings, use this parameter to set the transmission in dBm, and if specified as W (milliwatts), the conversion formula is: dBm=30+log (W). The parameter on/off turns on and off the transmitting unit, and auto and fixed specify whether the wireless automatically selects transmit power.

Sens: set the lower limit of reception sensitivity, below which the wireless network card thinks that the wireless network signal is too bad, different network cards will take different measures, and some modern wireless network cards will automatically choose a new AP. The positive parameter is raw data, which is directly sent to the wireless network card driver for processing, which is generally considered to be a percentage. A negative value represents a dBm value.

Retry: set the retransmission mechanism of the wireless network card. Limit 'value' specifies the maximum number of retransmissions; lifetime' value' specifies the maximum retry time in seconds, which can be specified in milliseconds and microseconds with m and u. If the wireless network card supports automatic mode, you can also attach min and max before limit and lifetime to specify the upper and lower limits.

Rts: specifies the RTS/CTS handshake method, which adds extra overhead to using RTS/CTS handshakes, but can improve performance if there are hidden wireless nodes in the wireless network or if there are many wireless nodes. The following parameters specify the size of a minimum packet that uses the mechanism, and if the value is equal to the maximum packet size, it is equivalent to prohibiting the use of the mechanism. You can use the auto/off/fixed parameter.

Frag: sets the shard size of the packet sent. Setting fragmentation will add extra overhead, but it can improve the packet arrival rate in a noisy environment. In general, this parameter is less than the maximum packet size, and some wireless cards that support Burst mode can set a value greater than the maximum packet size to allow Burst mode. You can also use the auto/fixed/off parameter.

Key/enc [ryption]: set the encryption key used by the wireless network card. Here is the encryption key that sets the WEP mode. If you want to use WPA, you need the wpa_supplicant toolkit. The key parameter can be a hexadecimal value in XXXX-XXXX-XXXX-XXXX or XXXXXXXX format, or an ASCII character in s:xxxxxx. If [index] is added before the key parameter, only the key corresponding to the index value is set, and the current key is not changed. Directly specify the [index] value to set which key is currently used. Specifies that on/off can control whether encryption mode is used. Open/restricted specifies the encryption mode, depending on the wireless network card, most wireless network cards' open mode does not use encryption and allows unencrypted packets to be received, and restricted mode uses encryption. Multiple key parameters can be used, but only the last one takes effect. The WEP key can be 40bit, represented by 10 hexadecimal digits or 5 ASCII characters, or 128bit, with 26 hexadecimal digits or 13 ASCII character tables.

Power: sets the power management mode of the wireless network card. Period 'value' specifies the wake-up period, and timeout' value' specifies the waiting time for entering sleep. These two parameters can be modified by min and max. These values are in seconds, and you can append m and u to specify milliseconds and microseconds. The off/on parameter specifies whether power management is allowed, and all/unicast/multicast specifies the type of packets that are allowed to wake up.

Commit: submit all parameter modifications to the wireless network card driver. Some wireless network card drivers will first cache the wireless network card parameter modification, and use this command to make the wireless network card parameter modification effective. However, it is generally not necessary to use this command, because the wireless Nic driver will eventually take effect after the modification of the parameters, which is generally used in debug.

Examples of common use of these tool commands:

Scan for available wireless networks

Iwlist [wifi-name] scanning

Wifi-name is the name of the wireless network card. For example, the network card eth0 is the default network card name of the system. Wifi-name can be viewed with ifconfig, generally ra0 (wireless network card), but ifconfig ra0 up is required.

Scan network information

Iwlist ra0 scan===

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report