Summary of the invention
The object of the present invention is to provide a kind of cordless communication network method of attachment, it is convenient, quick that it connects the equipment wireless network, improves the excellent perception degree that the user uses.
A kind of cordless communication network method of attachment for realizing that the object of the invention provides comprises at least two equipment, and described equipment has a wireless network card interface and/or cordless communication network device at least; Also comprise a wireless network jockey, described wireless network jockey is linked into a wherein equipment by the wireless network card interface of described equipment, and, realize that described at least two equipment connect by cordless communication network by inserting described cordless communication network device;
It comprises the following steps:
Step S100 is provided with all wireless network card interfaces that can connect in the wireless network jockey, and wireless network connects parameter;
Step S200 is connected to equipment and powers at the wireless network jockey, behind fan-in network name and the password, searches the wireless network card interface that described equipment can connect;
Step S300 will find out all wireless network card interface lists that described equipment can connect;
Step S400 selects a wireless network card interface in the wireless network card interface list, detects the connectivity of wireless network card interface;
Step S500 after detecting cordless communication network and can connecting, judges whether cordless communication network connects; If connect, then withdraw from and return; Otherwise, when not having cordless communication network to connect, carry out cordless communication network and connect.
More preferably, described cordless communication network method of attachment also comprises the steps:
Step S600 behind time of advent cordless communication network connect hours T, returns step S400, detects the connectivity of wireless network card interface again; Wherein, time T 〉=120 second.
More preferably, among the described step S200, search the wireless network card interface that described equipment can connect, comprise the steps:
Step S210 searches available wireless network card interface, judges whether that success finds the wireless network card interface that can connect, and searches the IP address interface name of the available wireless communication network interface of output;
Step S220 searches the IP address interface name of output, obtains the IP address by the character string filter method.
More preferably, among the described step S400, detect the connectivity of wireless network card interface, comprise the steps:
Step S410 after selecting the wireless network card interface, according to corresponding IP address, judges the mode of operation of cordless communication network; If normal mode of operation then forwards step S420 to; Otherwise, judge with after the debug address of presetting is consistent, forward step S500 to;
Step S420 if the mode of operation of equipment is a normal mode of operation, then searches and obtains the device gateway IP address of corresponding network;
When searching the device gateway IP address of corresponding network, if search successfully, then corresponding cordless communication network has connectivity, forwards step S430 to; Otherwise corresponding cordless communication network does not have connectivity, forwards step S450 to;
Step S430, if obtain the gateway ip address success, corresponding cordless communication network has connectivity, promptly network can be used, and then the corresponding apparatus gateway ip address is carried out continuous probe;
The IP address of continuous probe device gateway X time; If the number of times of surveying logical device gateway is less than X time, then wireless network can not connect, and does not have availability, forwards step S450 to; Otherwise the number of times of surveying the IP address of logical device gateway equals X time, and wireless network has connectivity, has availability, forwards step S440 to;
Step S440, if the logical gateway success of continuous probe, then wireless network has connectivity, carries out the detection of signal strength signal intensity;
Carry out the detection of signal strength signal intensity,, do not have connectivity, forward step S450 to if signal strength signal intensity then a little less than the network signal, does not reach preset strength less than-YdBm; Otherwise network signal reaches preset strength, has connectivity, forwards step S500 to;
Step S450, if cordless communication network can not connect communication, promptly it does not have connectivity, then judges whether to reach connectivity and detects number of times K;
Detect number of times if reach connectivity, then sleep M after second, return step S420, carry out network next time and connect whether available detection;
Step S460, reached connectivity detection number of times K if connectivity detects number of times, then this cordless communication network does not have connectivity, returns step S300, from the wireless network card interface, select another wireless network card interface to detect, until there not being the wireless network card interface to detect.
More preferably, among the described step S500, carry out cordless communication network and connect, comprise the steps:
Step S510 starts wireless network card;
Step S520 after starting wireless network card and cordless communication network, according to the mode of operation and the wireless network IP address of wireless network, searches the wireless network of coupling, finishes network and connects.
The invention has the beneficial effects as follows: cordless communication network method of attachment of the present invention, it is by interface detecting and configuration interface, and the wireless network of finishing equipment connects, and it is convenient, quick that the equipment wireless network is connected, need not user intervention, improve the excellent perception degree that the user uses.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, cordless communication network method of attachment of the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
As shown in Figure 1, as a kind of embodiment, the wireless network connecting method of the embodiment of the invention comprises at least two equipment, and described equipment has a wireless network card interface and/or cordless communication network device at least; Also comprise a wireless network jockey, described wireless network jockey is linked into described equipment by the wireless network card interface of described equipment, and by inserting described cordless communication network device, realizes that described at least two equipment connect by cordless communication network.
Described equipment can be personal computer, also can be embedded device, or other have a wireless network card interface and/or a cordless communication network device can be by the independent equipment that data are handled of DSP or single-chip microcomputer.
Described wireless network card interface can be a USB interface, also can be the CF card, or the network interface of other memory devices;
Described cordless communication network device, it can be the device that has wireless communication module, as gsm communication module, WIFI communication module, bluetooth (Bluetooth) communication module etc., it can be connected to the equipment that other have the radio communication device of same kind by default cordless communication network.
Described wireless network jockey, can be that PCMCIA, Compact Flash (CF) card, USB dish etc. are various can insert described equipment by the relevant device interface, and the wireless communication module of the wireless network connection that can on the described device of back execution batch processing (automatically performing) that powers on, store, the storage device that can connect by cordless communication network between feasible at least two equipment.
As a kind of embodiment, as shown in Figure 1, the wireless network connecting method of the embodiment of the invention comprises the steps:
Step S100 is provided with all wireless network card interfaces that can connect in the wireless network jockey, and wireless network connects parameter;
Described wireless network connects parameter and comprises gateway ip address corresponding under the wireless network card interface normal mode of operation, the gateway ip address that debugging mode is corresponding down, the length of one's sleep M, stand-by period N, connectivity detects number of times K, the number of times X of PING wireless network, signal strength values Y etc.;
Preferably, the gateway ip address that described debugging mode is corresponding down is 192.168.1.1;
Stand-by period N is 2~4 seconds (s);
Sleeping eyes time M is 8~11 seconds (s);
It is 2~10 times that connectivity detects number of times K;
The number of times X of PING wireless network is 2~4 times;
Signal strength signal intensity Y is 55~65.
Step S200 is connected to equipment and powers at the wireless network jockey, behind fan-in network name and the password, searches the wireless network card interface that described equipment can connect;
If there is not attachable wireless network card interface (also claiming wireless communication network interface), then stand-by period N searches attachable wireless network card interface after second once more.
Step S300 will find out all wireless network card interface lists that described equipment can connect;
Step S400 selects a wireless network card interface in the wireless network card interface list, detects the connectivity of wireless network card interface, promptly detects corresponding cordless communication network and whether can connect communication;
When whether the detection cordless communication network can connect communication, the device gateway of the cordless communication network that connects according to this interface also connects detection (PING) and signal strength condition etc., judge its connectivity, finally detect the availability of cordless communication network;
Step S500 can connect detecting cordless communication network, promptly wireless network connect available after, judge whether cordless communication network connects; If connect, then withdraw from and return; Otherwise, when not having cordless communication network to connect, carry out cordless communication network and connect.
Preferably, described wireless network connecting method also comprises the steps:
Step S600 behind time of advent cordless communication network connect hours T, returns step S400, detects the connectivity of wireless network card interface again.
Preferably, described time T 〉=120 second (s).
In step S200, search the wireless network card interface that described equipment can connect, comprise the steps:
Step S210 searches available wireless network card interface, judges whether that success finds the wireless network card interface that can connect, and searches the IP address interface name of the available wireless communication network interface of output;
As a kind of embodiment, can utilize iwconfig order and ifconfig order can search available wireless network card interface.
By the iwconfig command lookup, judge whether to obtain wireless network card interface name; If can obtain, then corresponding wireless network can connect, and promptly the wireless network card interface can be used; Otherwise, can't obtain the IP address, then corresponding cordless communication network can not connect, and promptly the wireless network card interface is unavailable;
In the LINUX system, can search all wireless network card interfaces by utilizing the iwconfig order.Eth1 for example.
// wireless network card interface eth1 describes
lo no?wireless?extensions.
eth1 Ralink?STA?ESSID:″******″Nickname:″RT2870STA″
Mode:Managed Frequency=2.412 GHz Access?Point:
00:1D:73:B1:FC:3D
Bit?Rate=54Mb/s
RTS?thr:off Fragment?thr:off
Encryption?key:E9AC-5857-EE73-5039-34BF-7500-DA4B-A3D5
Link?Quality=100/100?Signal?level:-45dBm Noise?level:-83dBm
As a kind of embodiment, the wireless network card interface that the iwconfig command lookup can be used is as follows:
// following be script command
IFACE=iwconfig?2>&1|grep-v-n″no?wireless″|awk′{print?$1}′|awk-F:′{print?$2}′
|grep?0|head-n?1
The output result of //iwconfig order.
The execution result of // this section script obtains wireless network card name: IFACE=eth1
Iwconfig2〉﹠amp; 1 is an output redirection order, and the output of its iwconfig is redirected to the standard output layer from the standard error layer.
As a kind of embodiment, the form of described ifconfig eth1 output is as follows:
eth1 Link?encap:Ethernet?HWaddr?00:E0:4C:CF:00:82
Inet addr:192.168.11.141 //the IP address
Bcast:192.168.11.255
Mask:255.255.255.0
Step S220 searches the IP address interface name of output, obtains the IP address by the character string filter method.
As a kind of embodiment, the IP address interface name with ifconfig command lookup output obtains the IP address by the character string filter method, is achieved as follows:
ip=$(ifconfig?$IFACE|grep″inet?addr″|head-n?1|awk-F:′{print$2}′|awk?′{print$1}′)
Above Ming Ling data result: ip=192.168.11.141
As shown in Figure 2, in step S400, detect the connectivity of wireless network card interface, comprise the steps:
Step S410 after selecting the wireless network card interface, according to corresponding IP address, judges the mode of operation of cordless communication network; If normal mode of operation then forwards step S420 to; Otherwise, judge with after the debug address of presetting is consistent, forward step S500 to;
According to corresponding IP address, the mode of operation of judging corresponding cordless communication network is normal mode of operation or debugging mode.
As a kind of embodiment, as described in step S100, set in advance an IP address, 192.168.11 for example, this address can be called debug address.
The IP address and the debug address that successfully obtain are compared, if identical, then would be debugging mode; Otherwise, be normal mode of operation.
Step S420 if the mode of operation of equipment is a normal mode of operation, then searches and obtains the device gateway IP address of corresponding network;
When searching the device gateway IP address of corresponding network, if search successfully, then corresponding cordless communication network has connectivity, forwards step S430 to; Otherwise corresponding cordless communication network does not have connectivity, forwards step S450 to;
In the embodiment of the invention, as a kind of embodiment, by route command lookup and the device gateway IP address that obtains corresponding network.
route|grep-q?default|awk′{print$2}′
This order is found default route by the mode of searching routing table, i.e. gateway IP.
Step S430, if obtain the gateway ip address success, corresponding cordless communication network has connectivity, promptly network can be used, and then the corresponding apparatus gateway ip address is carried out continuous probe (PING);
In the embodiment of the invention, as a kind of embodiment, the IP address of continuous probe (PING) device gateway X time; If the number of times of surveying logical device gateway is less than X time, then wireless network can not connect, and does not have availability, forwards step S450 to; Otherwise the number of times of surveying the IP address of logical device gateway equals X time, and wireless network has connectivity, has availability, forwards step S440 to;
PING (Packet Internet Grope, the Internet packets survey meter) is used for the program of test network connection amount.Ping sends an ICMP echo request message and whether receives desirable ICMP (Internet ControlMessage Protocol, Internet Control Message Protocol) Echo Reply to destination and report.Whether unobstructed it be the order that is used for checking network or network connection speed.
Step S440, if the logical gateway success of continuous probe (PING), then wireless network has connectivity, carries out the detection of signal strength signal intensity;
As a kind of embodiment, in the embodiment of the invention, carry out the detection of signal strength signal intensity, if signal strength signal intensity then a little less than the network signal, does not reach preset strength less than-YdBm, do not have connectivity, forward step S450 to; Otherwise network signal reaches preset strength, has connectivity, forwards step S500 to.
As a kind of embodiment, in the embodiment of the invention, utilize the Iwlist order to realize that the signal strength signal intensity (Signal Level) that obtains the current wireless network detects;
For example: iwlist eth1 peers //eth1 is the wireless network card interface
The result is as follows:
00:1D:73:B1:FC:3D:Quality:100/100 Signal?level:-41dBm?Noise?level:-92dBm
00:23:EA:7E:CD:90:Quality:7/100 Signal?level:-87dBm?Noise?level:-82dBm
00:24:13:0B:3F:A0:Quality:63/100 Signal?level:-65dBm?Noise?level:-92dBm
00:1B:11:5B:67:34:Quality:52/100 Signal?level:-69dBm?Noise?level:-92dBm
If the signal strength signal intensity of input is greater than-YdBm, then this wireless network can be strong, and performance is good, forwards step S500 to; , otherwise described wireless network performance is bad, returns again and detects.
Step S450, if cordless communication network can not connect communication, promptly it does not have connectivity, then judges whether to reach connectivity and detects number of times K;
Detect number of times if reach connectivity, then sleep M after second, return step S420, carry out network next time and connect whether available detection;
Step S460, reached connectivity detection number of times K if connectivity detects number of times, then this cordless communication network does not have connectivity, returns step S300, from the wireless network card interface, select another wireless network card interface to detect, until there not being the wireless network card interface to detect.
As shown in Figure 3, among the described step S500, carry out cordless communication network and connect, comprise the steps:
Step S510 starts wireless network card;
As a kind of embodiment, in the embodiment of the invention, utilize Ifconfig eth1 up order to start wireless network card.
Step S520 after starting wireless network card and cordless communication network, according to the mode of operation and the wireless network IP address of wireless network, searches the wireless network of coupling, finishes network and connects.
According to wireless network IP address, search the wireless network of coupling; If search wireless network, then return step S510 less than coupling; If find the wireless network of coupling, then carry out the configuration of network;
Preferably, described step S520 comprises the steps:
Step S521 when the mode of operation of wireless network is normal mode of operation, then according to wireless network IP address, finds the wireless network of coupling, resolves network parameter, carries out network configuration, finishes network and connects;
As a kind of embodiment, in the embodiment of the invention, described step S521 comprises the following steps:
Step S5211 mates according to network name, then a series of AP of coupling is decomposed into the one group character string relevant with AP to a series of character strings according to keyword; In this group character string, obtain the signal strength signal intensity of AP, according to signal strength signal intensity these character strings are sorted then; Analyze encryption method then,, select the configuration network parameter, carry out network configuration according to encryption method;
As a kind of embodiment, by iwlist or wpa_cli tool scans, the wireless network in the scanning one's respective area parses a set of network parameters, is achieved as follows:
Iwlist eth1 scanning // wireless network scanning
The similar following table of // result
eth1 Scan?completed:
Cell?01-Address:00:1D:73:B1:FC:3D
Protocol:802.11b/g
ESSID:″ejitec″
Mode:Managed
Frequency:2.412GHz(Channel?1)
Quality:100/100Signal?level:-37dBm?Noise?level:-92dBm
Encryption?key:on
Bit?Rates:54Mb/s
IE:WPA?Version?1
Group?Cipher:TKIP
Pairwise?Ciphers(1):TKIP
Authentication?Suites(1):PSK
Cell?02-Address:00:23:EA:7E:CD:90
ra0 Scan?completed:
Cell?01-Address:00:1D:73:B1:FC:3D
Protocol:802.11b/g
ESSID:″ejitec″
Mode:Managed
Frequency:2.412GHz(Channel?1)
Quality:100/100 Signal?level:-43dBm?Noise?level:-92dBm
Encryption?key:on
Bit?Rates:54Mb/s
IE:WPA?Version?1
Group?Cipher:TKIP
Pairwise?Ciphers(1):TKIP
Authentication?Suites(1):PSK
Cell?02-Address:00:23:EA:7E:CD:90
Protocol:802.11b/g
ESSID:″ChinaNet″
Mode:Managed
Frequency:2.412GHz(Channel?1)
Quality:18/100Signal?level:-83dBm?Noise?level:-78dBm
Encryption?key:off
Bit?Rates:54Mb/s
Cell?03-Address:00:1B:11:5B:67:34
Protocol:802.11b/g
ESSID:″default″
Mode:Managed
Frequency:2.437GHz(Channel?6)
Quality:31/100Signal?level:-77dBm?Noise?level:-72dBm
Encryption?key:on
Bit?Rates:54Mb/s
IE:WPA?Version?1
Group?Cipher:TKIP
Pairwise?Ciphers(1):TKIP
Authentication?Suites(1):PSK
Cell?04-Address:00:24:13:0B:3F:A0
Protocol:802.11b/g
ESSID:″ChinaNet″
Mode:Managed
Frequency:2.437GHz(Channel?6)
Quality:83/100 Signal?level:-57dBm?Noise?level:-92dBm
Encryption?key:off
Bit?Rates:54Mb/s
。。。。。。
ESSID: " ejitec " this delegation is a network name
This delegation of Cell 01-Address:00:1D:73:B1:FC:3D is the AP address.
IE:WPA?Version?1
Group?Cipher:TKIP
Pairwise?Ciphers(1):TKIP
Authentication?Suites(1):PSK
In the embodiment of the invention, mate according to network name earlier, then a series of AP of coupling are decomposed into the one group character string relevant with AP to a series of character strings according to keyword Cell xx; In this group character string, obtain the signal strength signal intensity of AP, according to signal strength signal intensity these character strings are sorted then; Analyze encryption method then,, select the configuration network parameter, carry out network configuration according to encryption method.
Usually, the wireless network cipher mode is divided into three kinds: do not have and encrypt WEP, WPA (WPA2)
WPA2 is the upgrade version of WPA.
Wherein WPA/wPA2 comprises certification mode again, and one has 2 kinds: PSK, EAP
Certification mode has defined the client and server end and how to have linked up password.
PSK: licensing mode in advance, Pre-Share Key.
EAP: expansion licensing mode.Extensible?Authentication?Protocol。Generally be used for large enterprise.
Also have cipher mode, be divided into three kinds: WEP, TKIP, AES
The result who resolves will analyze current cipher mode, authentication mode, cryptographic algorithm exactly.
For example, to a group of above-mentioned string matching network name " ejitec ", the result who resolves
ssid=″ejitec″
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
bssid=”00:1D:73:B1:FC:3D”
signal=37
The content of the configuration file that arrangement is come out is wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
network={
ssid=″ejitec″
bssid=00:1D:73:B1:FC:3D
scan_ssid=1
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk=″1262528888″
}
Since parsed the configuration information that all need, carried out the configuration of cordless communication network according to configuration information.
As a kind of embodiment, describedly carry out the configuration of cordless communication network according to configuration information, be achieved as follows: wpa_supplicant-i$IFACE-B-c wpa_supplicant.conf
As a kind of embodiment, in the embodiment of the invention, utilize WPA (Wi-Fi ProtectedAccess, Wi-Fi Protected Access) instrument to carry out network configuration, be achieved as follows:
The main order of wpa_supplicant//network configuration.
Killall wpa_supplicant//kill process
Sleep 2//sleep 2 seconds
Ifonfig eth1 up // startup network interface card
Sleep 2//sleep 2 seconds
Wpa_supplicant-i eth1-B-c//configuration file
Step S5212 according to IP distribution state and user's fan-in network name and password, upgrades routing table, finishes cordless communication network and connects;
If static IP then directly according to the IP address that finds, upgrades routing table, finish cordless communication network and connect;
If dynamic IP then according to DHCP mode distributing IP address, is upgraded routing table, finish cordless communication network and connect.
If the pattern of dynamic assignment IP address, then by equipment (client) by DHCP application IP address, obtain the IP address after, upgrade routing table, finish cordless communication network and connect.
DynamicHost is provided with agreement (Dynamic Host Configuration Protocol, DHCP) be the procotol of a local area network (LAN), the work of use udp protocol mainly contains two purposes: give the internal network keeper as the means of all computers being made central management to the user for internal network or Internet service provider's automatic IP address allocation.
As a kind of embodiment, application IP address, and upgrade routing table, be achieved as follows:
Dhclient eth1 // application obtains the IP address.
Route add default gateway SERVER_IP eth1//renewal routing table.
Wherein, SERVER_IP is for ordering the character string of output to get by resolving ifconfig.
Eth1 is the interface name.
For example
route?add?default?gateway?192.168.11.1?eth1
Step S522 when if the mode of operation of wireless network is debugging mode, then according to wireless network IP address, seeks the strongest point to point network of signal, and network name is resolved, and after successfully parsing network name, finishes wireless communication and connect.
As described in step S100, default IP address is 192.168.1.1, and under debugging mode, equipment can only be operated under point-to-point (Ad-Hoc) pattern.
Under this pattern, do not need WAP (wireless access point) (Access Point, AP) participate in, two radio node direct communications, manual assignment must be ordered by ifconfig in the IP address of these two radio nodes, when these two node configuration are ad hoc mode, and set after the IP address, just can direct communication.
During the IP address setting, two radio nodes are at the same network segment, and for example the IP address setting of one of them is 192.168.1.1, and then another can be set to 192.168.1.2.
As long as at the same network segment, and they are set to " point-to-point " pattern, and according to existing technology as can be known, two radio nodes just can intercom mutually.
The embodiment of the invention wireless network connected system and device and method, it is by interface detecting and configuration interface, and the wireless network of finishing equipment connects, and it is convenient, quick that the equipment wireless network is connected, need not user intervention, improve the excellent perception degree that the user uses.It has following advantage: 1) restart when hotspot, perhaps swinging of signal regularly reconnects automatically.2) can operate in the embedded environment simultaneously or in the common computer.3) 2 kinds of operational modes, general mode and debugging modes are arranged.In the general mode, the user-specified network name, the input password can be realized from being dynamically connected network.4) in the time of in operating in debugging mode, wireless network card enters ad hoc mode (Ad-Hoc) automatically, and it is the strongest wireless signal of search ambient signals automatically, if also be ad hoc mode, then connects automatically; Under debugging mode, wireless network automatically disposes, and network name and password do not need input.Particularly under the situation that the user knows nothing surrounding environment, two wireless devices can pass through debugging mode, and are directly interconnected, need not any configuration, very convenient.
Should be noted that at last that obviously those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these revise and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification.