Implement 802.11b wireless gateway in Embedded Linux

Source: Internet
Author: User
In Embedded Linux, implement 802.11b wireless gateway-general Linux technology-Linux programming and kernel information. The following is a detailed description. The transmission media that constitute a wired network mainly relies on copper or optical cables. However, wired networks are subject to wiring restrictions in some cases, especially when connecting distant nodes, the cabling of dedicated communication lines is difficult, expensive, and time-consuming. This creates a bottleneck for the rapidly expanding network connection demand. The emergence of Wireless LAN overcomes the above shortcomings, so Wireless LAN has developed rapidly. 802.11b-based products have become the mainstream applications. These products use the 2.4 GHz band and can achieve 11 Mb/s access rate within a short distance. each access point can support access by multiple users at the same time. As a bridge between a wireless terminal and a wired network, a wireless gateway is an important part of an infinite LAN. The author focuses on how to implement the function of the wireless gateway on the embedded Linux system.

1. Basic principles of Embedded Linux

Embedded systems are application-oriented, computer-based, software and hardware can be reduced, and are suitable for dedicated computer systems with strict requirements on functions, reliability, cost, volume, and power consumption of application systems. Due to inherent hardware restrictions, the embedded system only has extremely few hardware resources. Generally, it is replaced by a small Disk on Chip or Disk on Module instead of a Disk.

Linux is completely feasible as an embedded operating system. It can process embedded tasks and user interfaces. It regards Linux as a continuous unity, from a microkernel with memory management, task switching, Time Service and its splitting to a complete server, supports all file systems and network services. As an embedded system, Linux has the advantages of being portable, stable, powerful, and easy to develop for many CPU and hardware platforms. As a software operating system that can be customized, Linux is an excellent resource for developing embedded devices in the future. Because the source code of Linux is open and easy to customize, it provides the basic kernel and the user interface required to complete embedded functions.

A small embedded Linux system requires three basic elements: Boot Tool, Linux microkernel (memory management, process management and transaction processing), and initialization process. If you want it to become a complete operating system and keep it small, you have to add hardware drivers, file systems, and one or more applications that provide the required functionality.

2. Implementation of 802.11b wireless network in Embedded Linux

Since Linux was initially developed for desktops and added some inherent restrictions on the hardware resources of embedded systems, it is necessary to implement wireless networks in Embedded Linux systems, you need to customize the Linux system to delete unnecessary parts of the wireless gateway, so as to streamline the system and reduce costs.

2.1 streamlined Kernel

Linux Kernel can be customized according to specific requirements. We use the 2.4.4 kernel. In the/usr/src/Linux directory, use make menuconfig to remove the Kernel support options for floppy and cdrom. Second extended fs (ext2) is the standard of the Linux File System, in addition to this option, remove the support for all other filesystems, remove the kernel's support for sound, and remove all character devices (char-acter devices.

At the same time, the AP application software and some specific functional requirements should be removed to leave support for the required driver in the kernel, specifically: ① A wireless gateway is connected to a wireless network and a wired network. Therefore, you must retain network support and TCP/IP stack support, keep the support for the most common R18139 drivers such as the ethernet card, and set Module items in the kernel; ② If the embedded system uses Disk On Chip, in the kernel, you also need to select the support for it: M-sys-tems drivers; ③ retain the support for specific functions in the kernel, such as using PPP (Point-to-Point Protocol ), the compiled kernel must support PPP.

After the configuration is complete, re-compile the kernel, modify the configuration file of the Linux boot tool lilo, and then start the kernel with the newly compiled kernel. Restart the computer. If everything runs normally, the kernel will be streamlined.

2.2 reduce the Linux File System

Embedded Linux is an operating system. Its main task is to manage system resources on computers and provide users with interfaces to use computers and their external devices. It aims to manage all hardware resources and provide an appropriate operating environment for the application software, therefore, some basic commands and directories must be kept while the embedded Linux system is greatly deleted and reduced.

These reserved commands and directories can be roughly divided into three types. One is required for Linux Startup. Important files include init and getty, and important directories and files include/etc/rc. d./etc/inittab. Some commands under the directory/bin and/sbin will be called at startup. If the command is deleted, add the command based on the error information during startup. The second type is reserved commands and directories used to complete some basic system functions. The simplest is to copy the command cp, enter and exit the command cd of the directory, and list the command ls in the directory, these commands complete the most basic functions of the operating system. Other commands must correspond to specific configuration files or directories that store configuration files to complete special functions. Of course, the specific functions should be determined based on the actual situation, and the necessary commands and corresponding directories or configuration files should be kept as much as possible to occupy as little storage space as possible when the function is completed. After the preceding reduction is completed, restart. If Linux can be started and run properly, it indicates that the initial Linux embedded system has been successfully structured. The last type is to enable the wireless gateway to work normally. The wireless gateway is started by running the script command pcmcia to load the compiled target file in the driver into the system as a module, linux provides depmod, insmod, rmmod, and other commands to ensure that appropriate modules are loaded in the correct order. Therefore, these commands must exist in the system, at the same time, the configuration file must be read when the wireless gateway is started. These configuration files notify wireless gateway of the driver-related parameter settings, so the directory of the configuration file/ect/pcmcia should be retained. With this, the wireless gateway can be started normally.

2.3 Implementation of the wireless gateway function

As shown in figure 1, the most important function required by the wireless gateway is to communicate with wireless nodes, bridge all wireless nodes, and achieve cross-network connection between the wireless network and the wired network.

  

(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // OS .yesky.com/imagelist/2007/133/9m866m5hz788.jpg'); ">

Configure the Linux kernel module and use PCMCIA CardService to drive PCMCIA. Run "make modeules" and "makemodeules_install" to generate and install the core module. In the standard release of "Linux kernel source code, the bridging and packet filtering functions (NetFiIi-ter) cannot work normally together. Therefore, to run the bridging and IPtables functions simultaneously on the same computer, the core source code needs to be patched. The related patches can be downloaded from http://bridge.sourceforge.net. In addition, to get the driver package for PCMCIA-CS 3.2.1 and PRISM2 HlostAP, port the driver for the PCMCIA-CS and PRISM2 HostAP. To complete this step, you must have a simple knowledge of compiling program source code in Linux, mainly using cross-compiler (GCC. Put the compiled module *. o file under/lib/modules/2.4.4/misc:, and use depmod-a to make this module a loadable module. The module is loaded with the insmod command, the rmmod command is used to uninstall the module, and the lsmod command can be used to view the status of all loaded modules. Finally, bridging wired and wireless NICs requires some basic knowledge about hardware and network configurations in Linux.

After the module is set up, build the bridging function. After the bridge is decompressed and all the compilation is successful, run the "ifconfig-a" command to view all network interfaces: lo -- local loopback device; ethO -- the first ethernet card; ethl -- the second ethernet card; wlan0 -- the wireless network card. Use "ifconfig" <设备> The "0. O.0.O" command changes the operation mode of all network interfaces except the lo device to force the system to enter the messy mode and receive all data packets. Then, run the "brctl addbr br0" command to add a bridge device named br0, then, use "bretl addif br0 ethO" and "brctl addif br0wlan0" to bind the wireless end to the wired end interface. Then, use ifeonfigbr0 192.168.2.18 up ''to enable the bridging device to take effect.

During Kernel configuration, select GeneraI setup ---> [] Sysctlsupport to display the ip_forward file in the/proc/sys/net/ipv4/File System of the Board, then provide the ena Program (added to etc/init. d/rcS in a sentence/bin/ena-e), change the default 0 in the ip_for-ward file to 1, this opens up the channel for data forwarding. Add iptables to support NAT (NetWork Ad-dress Translation ). Download the iptables-1.2.5 software from the Internet, execute make in the iptables-1.2.5 directory, after the compilation is passed, the generated Executable File iptables is added to ramdisk, and then burn to the board for configuration.

Iptables supports both Linux kernel and iptables commands:

① Kernel compilation options. Under the "Networkingoptions --->" option in the Kernel configuration menu, select the "NetWork packet filtering (replaces ipchains)" item, and in the "IP: select all options from the Netfilter Con-figuration ---> option.

② Support for iptables commands

#! /Bin/bash
# Enable port forwarding
Echo 1>/proc/sys/net/ipv4/ip_forward add forwarding rules: iptables-t nat-A POS-TROUTING-0 ethl-j MASOUERADE.

So far, all the work to build a wireless gateway has been completed.

3. Test Results

Test System 2 for building a wireless gateway.

  

(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // OS .yesky.com/imagelist/2007/133/j185v3yta8dd.jpg'); ">

Set the gateway of the upper computer to 172.17.248.169, and use VB 6.0 to develop an application for listening to the network on the upper computer. Write a client program on the wireless terminal side, responsible for sending and receiving client data, and adding routes from the gateway to the host computer on the wireless terminal side. Then, run the ping command on the host computer. The test result is as follows:

# Ping 192.168.6.100
PING 192.168.6.100 (192.168.6.100): 56 data bytes
64 bytes from 192.168.6.100: icmp_seq = 0 ttl = 255 time = 1.8 MS
64 bytes from 192.168.6.100: icmp_seq = 1 ttl = 255 time = 1.4 MS
64 bytes from 192.168.6.100: icmp_seq = 2 ttl = 255 time = 1.4 MS
64 bytes from 192.168.6.100: icmp_seq = 3 ttl = 255 time = 1.4 MS
--- 192.168.6.100 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 1.4/1.5/1.8 MS

Test result 3 of the communication between the host computer and the wireless terminal is shown.

  

(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // OS .yesky.com/imagelist/2007/133/sr7643j7cr7x.jpg'); ">

Conclusion

So far, the software implementation of the 802.11b wireless gateway in the embedded Linux system has basically ended. The test results show that the basic function of the wireless gateway is to communicate with the wireless terminal, bridge the wireless terminal, and achieve the connection between the wireless network and the wired network. The following describes how to further implement the application of the wireless network in the EPA (Ethernet for Plant Au-tomation) control network.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.