CN110120987B - WiFi connection method and device - Google Patents

WiFi connection method and device Download PDF

Info

Publication number
CN110120987B
CN110120987B CN201810118969.7A CN201810118969A CN110120987B CN 110120987 B CN110120987 B CN 110120987B CN 201810118969 A CN201810118969 A CN 201810118969A CN 110120987 B CN110120987 B CN 110120987B
Authority
CN
China
Prior art keywords
character
address
preset
determining
nibble
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810118969.7A
Other languages
Chinese (zh)
Other versions
CN110120987A (en
Inventor
章浙锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201810118969.7A priority Critical patent/CN110120987B/en
Priority to PCT/CN2018/120311 priority patent/WO2019153869A1/en
Publication of CN110120987A publication Critical patent/CN110120987A/en
Application granted granted Critical
Publication of CN110120987B publication Critical patent/CN110120987B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/35Network arrangements, protocols or services for addressing or naming involving non-standard use of addresses for implementing network functionalities, e.g. coding subscription information within the address or functional addressing, i.e. assigning an address to a function
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5069Address allocation for group communication, multicast communication or broadcast communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/11Allocation or use of connection identifiers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the invention provides a WiFi connection method and a WiFi connection device, which are applied to first electronic equipment, wherein the method comprises the following steps: respectively encoding each character in a first character string and a second character string to obtain an IP address corresponding to each character, wherein the first character string is as follows: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment; mapping the IP address corresponding to each character into an MAC address; and periodically sending multicast frames with each MAC address obtained by mapping as a destination address, so that the second electronic equipment is accessed to the WiFi network according to the service set identification and the password obtained by grabbing and analyzing the multicast frames. By applying the scheme provided by the embodiment of the invention, the equipment can be rapidly accessed to the WiFi network.

Description

WiFi connection method and device
Technical Field
The invention relates to the technical field of wireless communication, in particular to a WiFi connection method and device.
Background
At present, various electronic devices are widely used, and in some cases, two electronic devices are required to be connected so that one of the two electronic devices controls the other electronic device, for example, a user usually connects a wearable device with a handheld device (such as a mobile phone) when using the wearable device so as to operate and control the wearable device through the handheld device.
In the prior art, the handheld device and the wearable device may be connected by WiFi, for example, the handheld device is used as a WiFi hotspot, and the wearable device is connected to the handheld device by the WiFi hotspot, or both the handheld device and the wearable device are connected to the same WiFi network, so that WiFi connection between the handheld device and the wearable device is achieved. That is, both of these approaches require the wearable device to access the WiFi network.
However, both of the two schemes for accessing the WiFi network require the user to manually configure the WiFi parameters (including SSID (Service Set Identifier) and PWD (Pass Word)) of the WiFi hotspot or the WiFi network on the wearable device, and the manner of manually configuring the WiFi parameters is troublesome, so that the wearable device cannot quickly access the WiFi network.
Disclosure of Invention
The embodiment of the invention aims to provide a WiFi connection method and device, electronic equipment and a computer readable storage medium, so that the equipment can be rapidly accessed to a WiFi network. The specific technical scheme is as follows:
in order to achieve the above object, an embodiment of the present invention provides a WiFi connection method, applied to a first electronic device, where the method includes:
respectively encoding each character in a first character string and a second character string to obtain an IP address corresponding to each character, wherein the first character string is as follows: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
mapping the IP address corresponding to each character into an MAC address;
and periodically sending multicast frames with each MAC address obtained by mapping as a destination address, so that the second electronic equipment is accessed to the WiFi network according to the service set identification and the password obtained by grabbing and analyzing the multicast frames.
Optionally, the step of encoding each character in the first character string and the second character string respectively to obtain the IP address corresponding to each character includes:
obtaining the IP address corresponding to each character in the first character string and the second character string according to the following modes:
determining the value of a first preset bit of an IP address corresponding to the character according to the type of the character string in which the character is located;
determining the value of a second preset bit of the IP address corresponding to the character according to the sequence number of the character in the character string;
and determining the value of a third preset bit of the IP address corresponding to the character according to the content of the character, wherein the sum of the bits of the first preset bit, the second preset bit and the third preset bit is determined by the mapping relation between the IP address and the MAC address.
Optionally, the number of the third preset bits is greater than or equal to 16 bits;
the step of determining a value of a third preset bit of the IP address corresponding to the character according to the content of the character includes:
encoding a character into two bytes according to a high nibble and a low nibble of a first code value, wherein the first code value is: the code value of the character corresponding to the preset coding rule;
and determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes.
Optionally, the step of encoding the character into two bytes according to the high nibble and the low nibble of the first code value includes:
determining a high nibble of a first byte of the two bytes according to a low nibble of a second code value, wherein the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
determining a low nibble of the first byte from a high nibble of a first code value;
determining a high nibble of a second byte of the two bytes according to the high nibble of the first code value;
determining a low nibble of the second byte from the low nibble of the first code value;
the step of determining a value of a third preset bit of the IP address corresponding to the character according to the encoded two bytes includes:
determining the first byte as a value of a first preset 8 bits in the third preset bits;
and determining the second byte as the value of a second preset 8 bits in the third preset bits.
Optionally, the method further includes:
and receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment, and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
In order to achieve the above object, an embodiment of the present invention further provides a WiFi connection apparatus, applied to a first electronic device, where the apparatus includes:
the encoding module is configured to encode each character in the first character string and the second character string respectively to obtain an IP address corresponding to each character, where the first character string is: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
the mapping module is used for mapping the IP address corresponding to each character into an MAC address;
and the sending module is used for periodically sending the multicast frame with each MAC address obtained by mapping as a destination address so that the second electronic equipment accesses the WiFi network according to the service set identifier and the password obtained by grabbing and analyzing the multicast frame.
Optionally, the encoding module includes:
the first determining submodule is used for determining the value of a first preset bit of the IP address corresponding to the character according to the type of the character string where the character is located;
the second determining submodule is used for determining the value of a second preset bit of the IP address corresponding to the character according to the sequence number of the character in the character string;
and the third determining submodule is used for determining the value of a third preset bit of the IP address corresponding to the character according to the content of the character, wherein the sum of the bits of the first preset bit, the second preset bit and the third preset bit is determined by the mapping relation between the IP address and the MAC address.
Optionally, the number of the third preset bits is greater than or equal to 16 bits;
the third determination submodule includes:
an encoding unit, configured to encode a character into two bytes according to a high nibble and a low nibble of a first code value, where the first code value is: the code value of the character corresponding to the preset coding rule;
and the determining unit is used for determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes.
Optionally, the encoding unit includes:
a first determining subunit, configured to determine, according to a low nibble of a second code value, a high nibble of a first byte of the two bytes, where the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
a second determining subunit, configured to determine, according to the high nibble of the first code value, a low nibble of the first byte;
a third determining subunit, configured to determine, according to the high nibble of the first code value, a high nibble of a second byte of the two bytes;
a fourth determining subunit, configured to determine a low nibble of the second byte according to the low nibble of the first code value;
the determination unit includes:
a fifth determining subunit, configured to determine the first byte as a value of a first preset 8 bits in the third preset bits;
a sixth determining subunit, configured to determine the second byte as a value of a second preset 8-bit of the third preset bit.
Optionally, the apparatus further comprises:
and the receiving module is used for receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
In order to achieve the above object, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any one of the WiFi connection methods applied to the first electronic equipment when the program stored in the memory is executed.
To achieve the above object, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements any one of the above-mentioned WiFi connection methods applied to a first electronic device.
According to the scheme provided by the embodiment of the invention, the first electronic equipment encodes each character in the service set identification and the password of the WiFi network to be accessed by the second electronic equipment into the IP address, maps the IP address into the MAC address, and then sends the multicast frame with each MAC address as the destination address, so that the second electronic equipment can capture and analyze the multicast frame to obtain the server identification and the password, and then access the WiFi network. Therefore, according to the scheme provided by the embodiment of the invention, the second electronic equipment can be quickly accessed to the WiFi network without manually configuring WiFi parameters on the second electronic equipment.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a WiFi connection method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart illustrating encoding of characters according to the embodiment shown in FIG. 1;
fig. 3 is a flowchart illustrating another WiFi connection method according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart illustrating the process of performing de-encoding on the IP address in the embodiment shown in FIG. 3;
fig. 5 is a schematic structural diagram of a WiFi connection apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of an encoding module in the embodiment shown in FIG. 5;
fig. 7 is a schematic structural diagram of another WiFi connection apparatus according to an embodiment of the present invention;
FIG. 8 is a block diagram of the parsing module of the embodiment shown in FIG. 7;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve the problems in the prior art, embodiments of the present invention provide a WiFi connection method, device electronic equipment, and computer-readable storage medium.
Next, taking an IP Address (Internet Protocol Address) with 32 bits and a MAC Address (Media Access Control Address) with 48 bits as an example, a description will be given of a conversion between an IP Address and a MAC Address in the embodiment of the present application.
In the data transmission method of multicast, the IP address is a D-type address at the head of 1110, which is composed of 1110 and a multicast group number, and ranges from 224.0.0.0 to 239.255.255.255, and there is a fixed rule for the conversion between the IP address of 32 bits and the MAC address of 48 bits, and the upper 24 bits of the MAC address are 01: 00: 5e, the 23 rd bit is 0, and the MAC address of the multicast frame can be formed by directly copying the lower 23 bits of the IP address to the lower 23 bits of the MAC address. Since the upper 4 bits of the IP address are 1110 and the lower 23 bits are copied to the lower 23 bits of the MAC address, 5 bits in the middle of the IP address are not used, so that the IP address and the MAC address are not in one-to-one correspondence, and one MAC address can map 32 IP addresses at most. However, 5 bits in the middle of the IP address can be set as fixed values, and mapping one MAC address to one IP address can be realized.
A WiFi connection method provided in the embodiments of the present invention is described below.
Referring to fig. 1, fig. 1 is a schematic flowchart of a WiFi connection method provided in an embodiment of the present invention, where the method is applied to a first electronic device, and includes the following steps:
s101, coding each character in the first character string and the second character string respectively to obtain an IP address corresponding to each character.
Wherein, the first character string is: the service set identifier of the WiFi network to which the second electronic device is to access, the second character string is: and the password of the WiFi network to be accessed by the second electronic equipment. The service set identification refers to a string of characters that uniquely names the WiFi network.
In one implementation, preset application software in the first electronic device may be used to encode the characters in the string, respectively, so as to obtain an IP address corresponding to each character. The manner in which the character is encoded to obtain the corresponding IP address is not described in detail.
That is, in this step, each character in the first character string and the second character string is encoded respectively to obtain an encoding result of each character, and then for each character, the encoding result of the character is used to obtain an IP address as the IP address corresponding to the character.
In one implementation, when the character is encoded, the character may be encoded according to a preset code table, and the encoding result of the character is obtained, for example, the preset code table may be an ASCII code table or the like.
In one implementation, the first electronic device may be an intelligent terminal such as a mobile phone, a computer, and a tablet computer, and the second electronic device may be an intelligent terminal such as a mobile phone, a computer, and a tablet computer, and certainly may also be a wearable device such as an intelligent bracelet, an intelligent watch, and intelligent glasses.
S102, mapping the IP address corresponding to each character into a MAC address.
As can be seen from the above description, in an implementation manner, the preset bits in the IP address may be directly copied to the preset bits of the MAC address, so as to obtain the mapped MAC address.
And S103, periodically sending the multicast frame with each MAC address obtained by mapping as a destination address, so that the second electronic equipment is accessed to the WiFi network according to the service set identifier and the password obtained by grabbing and analyzing the multicast frame.
In one implementation manner, the second electronic device may capture and analyze a multicast frame sent by the first electronic device in the air to obtain MAC addresses in each multicast frame, perform inverse mapping on each MAC address according to a mapping relationship between the IP address and the MAC address to obtain each IP address, perform inverse coding on each IP address to obtain characters corresponding to each IP address, determine a service set identifier and a password of the WiFi network to be accessed according to the characters corresponding to each IP address, and finally access the WiFi network according to the service set identifier and the password.
The scheme provided by the embodiment of the invention can be applied to various scenes. For example, the WiFi network to be accessed by the second electronic device is a WiFi network already accessed by the first electronic device itself, or the WiFi network to be accessed by the second electronic device is not a network currently accessed by the first electronic device, and in both application scenarios, the WiFi network needs to be created by relying on a router. For another example, if the first electronic device is a handheld device, the first electronic device may be used as a WiFi hotspot, and the second electronic device accesses the WiFi hotspot, at this time, the second electronic device may perform data transmission through a 3G or 4G network of the first electronic device, for example, upload data to the internet.
It can be understood that, after the second electronic device accesses the WiFi network, the first electronic device does not need to continue to send multicast frames with each MAC address as a destination address, and therefore, in order to save network resources, in an embodiment, the method may further include: and receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment, and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
In summary, in the solution provided in the embodiment of the present invention, the first electronic device encodes each character in the service set identifier and the password of the WiFi network to be accessed by the second electronic device as an IP address, and maps the IP address to an MAC address, and then sends a multicast frame with each MAC address as a destination address, so that the second electronic device can capture and analyze the multicast frame to obtain the server identifier and the password, thereby accessing the WiFi network. Therefore, according to the scheme provided by the embodiment of the invention, the second electronic equipment can be quickly accessed to the WiFi network without manually configuring WiFi parameters on the second electronic equipment.
When the second electronic device is a wearable device, the WiFi parameters are not conveniently configured on the wearable device, so that the wearable device can be accessed to the WiFi network by applying the scheme provided by the embodiment of the invention without configuring the WiFi parameters on the wearable device, and the scheme provided by the embodiment of the invention is convenient for the wearable device to access to the WiFi network. Further, if the first electronic device is a handheld device and the handheld device is used as a WiFi hotspot, and the wearable device needs to access the WiFi hotspot to realize WiFi connection between the two devices, any one of the handheld device and the wearable device can be quickly interconnected by applying the scheme provided by the embodiment of the present invention.
An implementation manner of encoding each character in the first character string and the second character string in step S101 to obtain an IP address corresponding to each character is described in detail below.
Specifically, as shown in fig. 2, the IP address corresponding to each character in the first character string and the second character string is obtained according to the following steps:
s1011, determining the value of a first preset bit of the IP address corresponding to the character according to the type of the character string where the character is located;
for any character to be encoded, if the character is in a first character string, the type of the character string in which the character is located is a service set identifier, and if the character is in a second character string, the type of the character string in which the character is located is a password;
s1012, determining the value of a second preset bit of the IP address corresponding to the character according to the sequence number of the character in the character string;
s1013, determining the value of a third preset bit of the IP address corresponding to the character according to the content of the character;
the sum of the first preset bit, the second preset bit and the third preset bit is determined by the mapping relation between the IP address and the MAC address. In one implementation, the mapping relationship between the IP address and the MAC address may be: mapping the IP address to the MAC address is to copy the lower 23 bits of the IP address directly to the lower 23 bits of the MAC address.
In one implementation, the bits used for identifying the encoding result of the character in the IP address can be determined according to the mapping relationship between the IP address and the MAC address and the total number of bits of the IP address.
For example, the IP address is 32 bits, and when the IP address is mapped to the MAC address, the lower 23 bits of the IP address are directly copied to the lower 23 bits of the MAC address, so that the lower 23 bits of the IP address can be used to identify the encoding result of the character, and the upper 9 bits of the IP address can be set as a fixed value. Since the upper 4 bits of the IP address are always 1110 in multicast, the upper 8 bits of the IP address can be set to a fixed value in the range of 224 to 239. While bit 23 of the IP address may also be set to a fixed value, for example to 0 or to 1.
In the bits used for identifying the encoding result of the character in the IP address, the first preset bit may be used for marking the category of the character string where the character is located, that is, whether the character is located in the service set identifier or the password, the second preset bit is used for marking the sequence number of the character in the character string, and the third preset bit is used for marking the specific content represented by the character.
For the first predetermined bit, for example, if the IP address is 32 bits and the lower 23 bits are used for identifying the encoding result of the character, 1 bit of the IP address may be used as the first predetermined bit, for example, the 22 nd bit, specifically: the 22 nd bit is 0, which indicates that the character string in which the character is located is the service set identifier, and the 22 nd bit is 1, which indicates that the character string in which the character is located is the password. Two bits in the IP address may also be used as a first preset bit, for example, bits 22 and 21, specifically: the 22 nd and 21 st bits are 00 to show that the character string in which the character is located is the service set identifier, and the 22 nd and 21 st bits are 01 to show that the character string in which the character is located is the password. Of course, in specific implementation, the number and the position of the first preset bit may be set as required, which is not limited in the embodiment of the present invention.
For the second predetermined bit, for example, if the IP address is 32 bits and the lower 23 bits are used for identifying the encoding result of the character, a plurality of bits of the lower 23 bits except the first predetermined bit may be used as the second predetermined bit. Taking the number of the second predetermined bit as 3 as an example, the second predetermined bit may be represented as 000 when the sequence number is 1, the second predetermined bit may be represented as 001 when the sequence number is 2, and so on. It is understood that the number of bits of the second predetermined bit is related to the number of characters that the character string can contain at most, and the greater the number of characters that the character string can contain at most, the greater the number of bits of the second predetermined bit. In a specific implementation, the number and the position of the second preset bit may be set as required, which is not limited in the embodiment of the present invention.
In one embodiment, the 23 rd to 16 th bits of the IP address are shown in table 1, wherein the 23 th bit is preset to be a fixed value of 0, the 22 th bit is used as a first preset bit, the 22 th bit is 0 when the character string in which the character is located is the service set identifier, the 22 th bit is 1 when the character string in which the character is located is the password, and the 21 st to 16 th bits are used as a second preset bit. That is, bits 23-16 of the IP address can be used to distinguish between SSID and PWD.
TABLE 1
Figure RE-GDA0001622770870000101
When encoding is performed in the manner shown in table 1, for the 2 nd character in the service set identifier, the 23 rd to 16 th bits in the IP address obtained after encoding are 000000001 (expressed as 1 in decimal), and for the 2 nd character in the password, the 23 th to 16 th bits in the IP address obtained after encoding are 010000001 (expressed as 65 in decimal).
For the third preset bit, the third preset bit is used to mark the specific content represented by the character, and in one implementation, the binary digit corresponding to the character under the preset encoding rule (such as ASCII encoding) may be searched for, and the searched binary digit is used as the value of the third preset bit. In this way, the number of the third predetermined bits may be determined by the predetermined encoding rule.
In another implementation manner, the preset number of the third preset bits may be greater than or equal to 16 bits, and then in the step S1013 of determining the value of the third preset bit of the IP address corresponding to the character according to the content of the character, the method may include:
encoding a character into two bytes according to a high nibble and a low nibble of a first code value, wherein the first code value is: the code value of the character corresponding to the preset coding rule;
and determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes.
The preset encoding rule may be ASCII encoding in which a code value corresponding to a character is composed of 8-bit binary digits, and the first 4 bits may be defined as a high nibble H of the code value and the last 4 bits may be defined as a low nibble L of the code value. For example, the character "M" in ASCII encoding corresponds to a code value of 0x4D (in hexadecimal notation), where 0x4 is the high nibble H and 0xD is the low nibble L.
In a specific implementation manner, the manner of encoding the high nibble and the low nibble of the first code value to obtain two bytes corresponding to the ith character can be as shown in table 2, table 3 and table 4, where H isiAnd LiAnd respectively representing the high nibble and the low nibble of the code value corresponding to the ith character in the ASCII encoding rule. In this particular implementation, only the rootThe character is encoded into two bytes according to the first code value.
As shown in table 2, the low nibble and the high nibble of the first code value are directly used as the high nibble of the first byte and the high nibble of the second byte, respectively, and the high nibble and the low nibble of the first code value are subjected to preset data processing and then are used as the low nibble of the first byte and the low nibble of the second byte, respectively.
As shown in table 3, the high nibble and the low nibble of the first code value are directly used as the low nibble of the first byte and the low nibble of the second byte, respectively, and the low nibble and the high nibble of the first code value are subjected to preset data processing and then are used as the high nibble of the first byte and the high nibble of the second byte, respectively.
As shown in table 4, the low nibble and the high nibble of the first code value are directly used as the high nibble of the first byte and the high nibble of the second byte, respectively, and the high nibble and the low nibble of the first code value are used as the low nibble of the first byte and the low nibble of the second byte, respectively.
TABLE 2
Byte sequence number High nibble Low nibble
First byte 2i Li Hi^(1%16)
Second byte 2i+1 Hi Li^(2%16)
TABLE 3
Byte sequence number High nibble Low nibble
First byte 2i Li^(2i%16) Hi
Second byte 2i+1 Hi^((2i+1)%16) Li
TABLE 4
Byte sequence number High nibble Low nibble
First byte 2i Li Hi
Second byte 2i+1 Hi Li
Since the number of the third preset bits is greater than or equal to 16 bits, the first byte and the second byte can be determined as values of 16 bits, and other remaining bits can be preset to be fixed values.
In another specific implementation manner, the character may be further encoded into two bytes according to the first code value and the second code value, where the second code value is: and the code value corresponding to the last character in the character string where the character is located in the preset encoding rule is encoded by using the first code value and the second code value, so that whether the sequence of the character is correct or not can be conveniently checked in the subsequent decoding process. The encoding of the character into two bytes according to the high nibble and the low nibble of the first code value may include:
determining the high nibble of the first byte of the two bytes according to the low nibble of a second code value, wherein the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
determining a low nibble of the first byte from a high nibble of a first code value;
determining a high nibble of a second byte of the two bytes according to the high nibble of the first code value;
determining a low nibble of the second byte from the low nibble of the first code value.
Correspondingly, the step of determining a value of a third preset bit of the IP address corresponding to the character according to the encoded two bytes may include:
determining the first byte as the value of the first preset 8 bits in the third preset bits;
and determining the second byte as the value of the second preset 8 bits in the third preset bits.
That is, after the first byte and the second byte are determined, the value of each bit in the first byte may be assigned to each bit in the first preset 8 bits in the third preset bits, and the value of each bit in the second byte may be assigned to each bit in the second preset 8 bits in the third preset bits.
In addition, the first preset 8 bits and the second preset 8 bits refer to: and 8 preset bits in the third preset bits, wherein the bits in the first preset 8 bits and the second preset 8 bits are not overlapped with each other.
Here, the above-mentioned "the previous character in the character string where the character is located" is further illustrated, and taking the character string "asdf" as an example, the previous character in the character string of the character s is a.
Taking a character string as an example, the ith character in the character string can be encoded into two bytes as shown in table 5, table 6 or table 7 by using the above encoding method, wherein Li-1And the low nibble represents the code value corresponding to the i-1 th character in the character string in the preset encoding rule. It will be appreciated that L is utilized in encodingi-1Encoding the ith character according to Li-1Determining the high nibble of the first byte to facilitate checking the byte by the high nibble of the first byte upon decodingCorrectness of sequence numbers. It should be noted that, taking the character string "asdf" as an example, since the character a is the first character in the character string and there is no character immediately preceding the character a in the character string, when encoding the first character a, L can be directly encodedi-1Set to 0 to determine the high nibble of the first byte.
TABLE 5
Byte sequence number High nibble Low nibble
First byte 2i Li-1 Hi^(2i%16)
Second byte 2i+1 Hi Li^((2i+1)%16)
TABLE 6
Byte sequence number High nibble Low nibble
First byte 2i Li-1^(2i%16) Hi
Second byte 2i+1 Hi^((2i+1)%16) Li
TABLE 7
Byte sequence number High nibble Low nibble
First byte 2i Li-1 Hi
Second byte 2i+1 Hi Li
And for each character, after the character is coded into two bytes, determining the value of a third preset bit of the IP address corresponding to the character according to the coded two bytes. When the number of the third preset bits is 16 bits, the first byte may be determined as a value of 8 higher bits among the 16 bits, and the second byte may be determined as a value of 8 lower bits among the 16 bits; when the number of the third preset bits is greater than 16 bits, for example, 18 bits, the first byte may be determined as a value of 0 to 7 bits of the 18 bits, the second byte may be determined as a value of 8 to 15 bits of the 18 bits, and the values of the 16 th and 17 th bits may be preset to be fixed values.
For example, for a string with service set identifier My, as shown in table 8, under the ASCII encoding rule, the code value corresponding to the character M is 0x4D, and the high nibble H of the code value corresponding to the character M is0And a low nibble L00x4 and 0xD, respectively, and the code value corresponding to the character y is 0x79, then the high nibble H of the code value corresponding to the character y1And a low nibble L10x7 and 0x9, respectively.
TABLE 8
Figure RE-GDA0001622770870000141
If the third predetermined bit of the IP address is set to 16 bits, when the third predetermined bit is encoded according to the above-mentioned method, as shown in table 9, the two bytes obtained after encoding the character M are respectively 0x04 and 0x5D (expressed in hexadecimal notation), wherein the first byte 0x04 is used as the value of the higher 8 bits in the third preset bit, the second byte 0x5D is used as the value of the lower 8 bits in the third preset bit, and by the encoding method of the first preset bit and the second preset bit of the IP address shown in table 1, finally, the IP address resulting from encoding the character M may be 239.0.4.93 (in decimal), the IP address encoded for the character y may be 239.1.247.73 (in decimal), when the hexadecimal system is converted into the decimal system, 0x04 is 4, 0x5D is 93, 0xF7 is 247, and 0x49 is 73.
TABLE 9
Figure RE-GDA0001622770870000142
As can be seen from table 7, during encoding, the high nibble of the byte with sequence number 2i +1 is formed by using the low nibble of the byte with sequence number 2i, and after decoding, the second electronic device can check the correctness of the sequence number of the current byte through the low nibble of the byte with the previous sequence number and the high nibble of the byte with the current sequence number, so as to avoid interference of a foreign data packet. It can be seen that the serial numbers of two adjacent bytes encoded in this way are related, and when an interfering data packet is received, the second electronic device can check the validity of the serial number through the previous byte.
By applying the encoding method in the embodiment shown in fig. 2, each character in the service set identifier and the password of the WiFi network is encoded into an IP address, which can improve the speed of the second electronic device analyzing the service set identifier and the password of the WiFi network, and further improve the speed of the second electronic device accessing the WiFi network. And the structure of the multicast IP address and the special corresponding relation between the multicast IP address and the MAC address are utilized to multicast the IP address obtained after the service set identification and the password are coded, so that the data volume transmitted during multicast is reduced, and the data to be transmitted is carried in an IP address mode, so that the method is safe and efficient.
In order to realize that the device quickly accesses the WiFi network, based on the above-mentioned WiFi connection method applied to the first electronic device, an embodiment of the present invention further provides a WiFi connection method, which is applied to the second electronic device, as shown in fig. 3, and includes the following steps:
s301, capturing each multicast frame periodically transmitted by the first electronic device.
S302, analyzing the captured multicast frames to obtain MAC addresses in each multicast frame, performing inverse mapping on each MAC address to obtain each IP address, performing inverse coding on each IP address to obtain characters corresponding to each IP address, and determining a service set identifier and a password of the WiFi network to be accessed according to the characters corresponding to each IP address.
Each IP address is obtained by the first electronic device respectively encoding each character in the first character string and the second character string, and the first character string is: the service set identifier, the second string is: a password.
After the multicast frame is analyzed to obtain the MAC address in the multicast frame, the IP address can be obtained by reflection according to the mapping relation between the IP address and the MAC address.
In an implementation manner, preset application software in the second electronic device may be used to analyze the multicast frame to obtain an IP address corresponding to each character.
Specifically, corresponding to the encoding manner in which the first electronic device encodes each character in the first character string and the second character string respectively to obtain the IP address corresponding to each character in the embodiment shown in fig. 2, the step of obtaining the character corresponding to each IP address by performing inverse encoding on each IP address in the embodiment of the present invention is shown in fig. 4, and may include:
inversely coding each IP address to obtain the character corresponding to each IP address according to the following steps:
s3021, determining the type of a character string where a character corresponding to the IP address is located according to the value of the first preset bit of the IP address;
s3022, determining the sequence number of the character corresponding to the IP address in the character string according to the value of the second preset bit of the IP address;
and S3023, determining the content of the character corresponding to the IP address according to the value of the third preset bit of the IP address.
Correspondingly, when the number of the third preset bits is greater than or equal to 16 bits, the step of determining the content of the character corresponding to the IP address according to the value of the third preset bits of the IP address may include:
determining two bytes according to the value of a third preset bit of the IP address;
determining a high nibble and a low nibble of the first code value from the determined two bytes; the first code value is a code value corresponding to characters corresponding to the IP address in a preset coding rule;
and determining the content of the character corresponding to the first code value consisting of the high nibble and the low nibble from the preset encoding rule as the content of the character corresponding to the IP address.
In a specific implementation manner, the step of determining two bytes according to a value of a third preset bit of the IP address may include:
determining the value of the first preset 8 bits in the third preset bits as the first byte in the two bytes;
and determining the value of the second preset 8 bits in the third preset bits as the second byte in the two bytes.
The determining the high nibble and the low nibble of the first code value according to the determined two bytes may include:
determining a high nibble of the first code value from a low nibble of the first byte;
the low nibble of the first code value is determined from the low nibble of the second byte.
For example, for the first byte and the second byte encoded in the encoding methods shown in tables 3, 4, 6, and 7, the lower nibble of the first byte may be directly determined as the upper nibble of the first code value and the lower nibble of the second byte may be determined as the lower nibble of the first code value during decoding.
For the first byte and the second byte encoded in the encoding method shown in table 2, during decoding, the corresponding inverse operation may be performed on the low nibble of the first byte to obtain the high nibble of the first code value, and the corresponding inverse operation may be performed on the low nibble of the second byte to obtain the low nibble of the first code value.
For the first byte and the second byte obtained by encoding in the encoding manner shown in table 5, during decoding, since the sequence number i of the character in the character string has been determined in step S3022, at this time, the low nibble of the first byte may be subjected to corresponding inverse operation according to the sequence number i to obtain the high nibble of the first code value, and the low nibble of the second byte may be subjected to corresponding inverse operation according to the sequence number i to obtain the low nibble of the first code value.
In addition, in order to check the correctness of the byte sequence number during decoding, before the step of determining the high nibble of the first code value according to the low nibble of the first byte, the content of one nibble can be determined according to the high nibble of the first byte in the two bytes, then whether the determined nibble is the same as the low nibble of the second code value is judged, if the determined nibble is the same as the low nibble of the second code value, the step of determining the high nibble of the first code value according to the low nibble of the first byte can be executed, the subsequent decoding step is carried out to obtain a correct character, and if the determined nibble is not the same as the low nibble of the first byte, the decoding step can be ended.
And S303, accessing the WiFi network according to the service set identifier and the password.
The scheme provided by the embodiment of the invention can be applied to various scenes. For example, the WiFi network to be accessed by the second electronic device is a WiFi network already accessed by the first electronic device itself, or the WiFi network to be accessed by the second electronic device is not a network currently accessed by the first electronic device, and in both application scenarios, the WiFi network needs to be created by relying on a router. For another example, if the first electronic device is a handheld device, the first electronic device may be used as a WiFi hotspot, and the second electronic device accesses the WiFi hotspot, at this time, the second electronic device may perform data transmission through a 3G/4G network of the first electronic device, for example, upload data to the internet.
It can be understood that, after the second electronic device accesses the WiFi network, the first electronic device does not need to continue to send multicast frames with each MAC address as a destination address, and therefore, in order to save network resources, in an embodiment, the method may further include: after accessing the WiFi network, feeding back information of successfully accessing the WiFi network to the first electronic device, so that the first electronic device finishes sending multicast frames with each MAC address obtained by mapping as a destination address.
In summary, in the solution provided in the embodiment of the present invention, the second electronic device captures and analyzes the multicast frame sent by the first electronic device, obtains the MAC address in each multicast frame, obtains each IP address by performing inverse mapping on each MAC address, obtains characters corresponding to each IP address by performing inverse coding on each IP address, and determines the service set identifier and the password of the WiFi network to be accessed according to the characters corresponding to each IP address, thereby accessing the WiFi network. Therefore, according to the scheme provided by the embodiment of the invention, the second electronic equipment can be quickly accessed to the WiFi network without manually configuring WiFi parameters on the second electronic equipment.
Corresponding to the above method embodiment applied to the first electronic device, an embodiment of the present invention further provides a WiFi connection apparatus, as shown in fig. 5, where the WiFi connection apparatus is applied to the first electronic device, and may include:
the encoding module 501 is configured to encode each character in a first character string and a second character string respectively to obtain an IP address corresponding to each character, where the first character string is: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
a mapping module 502, configured to map an IP address corresponding to each character into an MAC address;
a sending module 503, configured to periodically send a multicast frame with each MAC address obtained by mapping as a destination address, so that the second electronic device accesses the WiFi network according to the service set identifier and the password obtained by capturing and analyzing the multicast frame.
As a specific embodiment of the present invention, as shown in fig. 6, the encoding module 501 may include:
the first determining submodule 5011 is configured to determine, according to the type of the character string where the character is located, a value of a first preset bit of the IP address corresponding to the character;
the second determining submodule 5012 is configured to determine, according to the sequence number of the character in the character string, a value of a second preset bit of the IP address corresponding to the character;
the third determining submodule 5013 is configured to determine, according to content of a character, a value of a third preset bit of the IP address corresponding to the character, where a sum of the number of bits of the first preset bit, the second preset bit, and the third preset bit is determined by a mapping relationship between the IP address and the MAC address.
As a specific embodiment of the present invention, the number of the third preset bits is greater than or equal to 16 bits;
the third determining submodule 5013 may include:
an encoding unit, configured to encode a character into two bytes according to a high nibble and a low nibble of a first code value, where the first code value is: the code value of the character corresponding to the preset coding rule;
and the determining unit is used for determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes.
As a specific embodiment of the present invention, the encoding unit may include:
a first determining subunit, configured to determine, according to a low nibble of a second code value, a high nibble of a first byte of the two bytes, where the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
a second determining subunit, configured to determine, according to the high nibble of the first code value, a low nibble of the first byte;
a third determining subunit, configured to determine, according to the high nibble of the first code value, a high nibble of a second byte of the two bytes;
a fourth determining subunit, configured to determine a low nibble of the second byte according to the low nibble of the first code value;
accordingly, the determining unit may include:
a fifth determining subunit, configured to determine the first byte as a value of a first preset 8 bits in the third preset bits;
a sixth determining subunit, configured to determine the second byte as a value of a second preset 8-bit of the third preset bit.
As a specific embodiment of the present invention, the apparatus may further include:
and the receiving module is used for receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
According to the scheme provided by the embodiment of the invention, the second electronic equipment captures and analyzes the multicast frame sent by the first electronic equipment to obtain the MAC address in each multicast frame, each MAC address is subjected to inverse mapping to obtain each IP address, each IP address is subjected to inverse coding to obtain the character corresponding to each IP address, and the service set identifier and the password of the WiFi network to be accessed are determined according to the character corresponding to each IP address, so that the WiFi network is accessed. Therefore, according to the scheme provided by the embodiment of the invention, the second electronic equipment can be quickly accessed to the WiFi network without manually configuring WiFi parameters on the second electronic equipment.
Corresponding to the above method embodiment applied to the second electronic device, an embodiment of the present invention further provides a WiFi connection apparatus, as shown in fig. 7, where the WiFi connection apparatus is applied to the second electronic device, and the apparatus may include:
a grabbing module 701, configured to grab each multicast frame periodically sent by a first electronic device;
the analysis module 702 is configured to analyze the captured multicast frames to obtain MAC addresses in each multicast frame, perform inverse mapping on each MAC address to obtain each IP address, perform inverse coding on each IP address to obtain characters corresponding to each IP address, and determine a service set identifier and a password of the WiFi network to be accessed according to the characters corresponding to each IP address; each IP address is obtained by the first electronic device encoding each character in a first character string and a second character string, where the first character string is: the service set identifier, the second character string is: the password;
a connection module 703, configured to access the WiFi network according to the service set identifier and the password.
As a specific embodiment of the present invention, as shown in fig. 8, the parsing module 702 may include:
the first determining submodule 7021 is configured to determine, according to a value of a first preset bit of the IP address, a category of a character string in which a character corresponding to the IP address is located;
the second determining submodule 7022 is configured to determine, according to a value of a second preset bit of the IP address, a sequence number of a character corresponding to the IP address in the character string;
the third determining sub-module 7023 is configured to determine, according to a value of a third preset bit of the IP address, content of a character corresponding to the IP address.
As a specific embodiment of the present invention, the number of the third preset bits may be greater than or equal to 16 bits;
the third determining sub-module 7023 may include:
the first determining unit is used for determining two bytes according to the value of a third preset bit of the IP address;
a second determining unit for determining a high nibble and a low nibble of the first code value according to the determined two bytes; the first code value is a code value corresponding to characters corresponding to the IP address in a preset coding rule;
and the third determining unit is used for determining the content of the character corresponding to the first code value consisting of the high nibble and the low nibble from the preset encoding rule as the content of the character corresponding to the IP address.
As a specific embodiment of the present invention, the first determining unit may include:
a first determining subunit, configured to determine a value of a first preset 8-bit of the third preset bit as a first byte of two bytes;
a second determining subunit, configured to determine a value of a second preset 8-bit of the third preset bits as a second byte of the two bytes;
accordingly, the second determining unit may include:
a third determining subunit, configured to determine a high nibble of the first code value according to a low nibble of the first byte;
and the fourth determining subunit is used for determining the low nibble of the first code value according to the low nibble of the second byte.
As a specific embodiment of the present invention, the apparatus may further include:
a fifth determining subunit, configured to determine the first nibble according to the high nibble of the first byte before the third determining subunit determines the high nibble of the first code value according to the low nibble of the first byte;
a determining subunit, configured to determine whether the first nibble is the same as a lower nibble of a second code value, where the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule; and if the first and second determination subunits are the same, triggering the third determination subunit.
As a specific embodiment of the present invention, the apparatus may further include:
and the sending module is used for feeding back information of successfully accessing the WiFi network to the first electronic equipment after accessing the WiFi network so that the first electronic equipment finishes sending the multicast frame with each MAC address obtained by mapping as a destination address.
According to the scheme provided by the embodiment of the invention, the second electronic equipment captures and analyzes the multicast frame sent by the first electronic equipment to obtain the MAC address in each multicast frame, each MAC address is subjected to inverse mapping to obtain each IP address, each IP address is subjected to inverse coding to obtain the character corresponding to each IP address, and the service set identifier and the password of the WiFi network to be accessed are determined according to the character corresponding to each IP address, so that the WiFi network is accessed. Therefore, according to the scheme provided by the embodiment of the invention, the second electronic equipment can be quickly accessed to the WiFi network without manually configuring WiFi parameters on the second electronic equipment.
An embodiment of the present invention further provides an electronic device, as shown in fig. 9, which includes a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete mutual communication through the communication bus 904,
a memory 903 for storing computer programs;
the processor 901 is configured to implement the following steps when executing the program stored in the memory 903:
respectively encoding each character in a first character string and a second character string to obtain an IP address corresponding to each character, wherein the first character string is as follows: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
mapping the IP address corresponding to each character into an MAC address;
and periodically sending multicast frames with each MAC address obtained by mapping as a destination address, so that the second electronic equipment is accessed to the WiFi network according to the service set identification and the password obtained by grabbing and analyzing the multicast frames.
Therefore, the embodiment of the invention provides the electronic device, encodes each character in the service set identifier and the password of the WiFi network to be accessed by other electronic devices into the IP address, maps the IP address into the MAC address, and then sends the multicast frame with each MAC address as the destination address, so that other electronic devices can capture and analyze the multicast frame to obtain the server identifier and the password without manually configuring WiFi parameters on other electronic devices, and thus other electronic devices can be quickly accessed to the WiFi network.
For specific implementation and related explanation of each step of the method, reference may be made to the method embodiment shown in fig. 1, which is not described herein again.
In addition, other implementation manners of the WiFi connection method implemented by the processor 901 executing the program stored in the memory 903 are the same as the implementation manners mentioned in the foregoing method embodiment section, and are not described herein again.
An embodiment of the present invention further provides an electronic device, as shown in fig. 10, which includes a processor 101, a communication interface 102, a memory 103, and a communication bus 104, where the processor 101, the communication interface 102, and the memory 103 complete mutual communication through the communication bus 104,
a memory 103 for storing a computer program;
the processor 101 is configured to implement the following steps when executing the program stored in the memory 103:
capturing each multicast frame periodically sent by first electronic equipment;
analyzing the captured multicast frames to obtain MAC addresses in each multicast frame, performing inverse mapping on each MAC address to obtain each IP address, performing inverse coding on each IP address to obtain characters corresponding to each IP address, and determining a service set identifier and a password of the WiFi network to be accessed according to the characters corresponding to each IP address; each IP address is obtained by the first electronic device encoding each character in a first character string and a second character string, where the first character string is: the service set identifier, the second character string is: the password;
and accessing the WiFi network according to the service set identification and the password.
Therefore, the electronic device provided by the embodiment of the invention obtains the MAC address in each multicast frame by grabbing and analyzing the multicast frames sent by other electronic devices, obtains each IP address by inverse mapping each MAC address, obtains the character corresponding to each IP address by inverse coding each IP address, and determines the service set identifier and the password of the WiFi network to be accessed according to the character corresponding to each IP address without manually configuring WiFi parameters, thereby realizing fast access to the WiFi network.
For specific implementation and related explanation of each step of the method, reference may be made to the method embodiment shown in fig. 3, which is not described herein again.
In addition, other implementation manners of the WiFi connection method implemented by the processor 101 executing the program stored in the memory 103 are the same as the implementation manners mentioned in the foregoing method embodiment section, and are not described herein again.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
An embodiment of the present invention further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is enabled to execute the WiFi connection method applied to the first electronic device in the foregoing embodiments.
By operating the computer program product provided by the embodiment of the invention, each character in the service set identification and the password of the WiFi network to be accessed by other electronic equipment is coded into an IP address and mapped into an MAC address, and then the multicast frame with each MAC address as a destination address is sent, so that other electronic equipment can grab and analyze the multicast frame to obtain the server identification and the password, and the WiFi parameters do not need to be manually configured on other electronic equipment, and the other electronic equipment can be quickly accessed to the WiFi network.
An embodiment of the present invention further provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is enabled to execute the WiFi connection method applied to the second electronic device in the foregoing embodiments.
By operating the computer program product provided by the embodiment of the invention, the multicast frames sent by other electronic equipment are captured and analyzed to obtain the MAC addresses in each multicast frame, each IP address is obtained by inverse mapping of each MAC address, characters corresponding to each IP address are obtained by inverse coding of each IP address, and the service set identification and the password of the WiFi network to be accessed are determined according to the characters corresponding to each IP address, so that the WiFi network can be accessed quickly without manually configuring WiFi parameters.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus, the electronic device, and the computer-readable storage medium embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some portions of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (6)

1. A WiFi connection method is applied to a first electronic device and comprises the following steps:
respectively encoding each character in a first character string and a second character string to obtain an IP address corresponding to each character, wherein the first character string is as follows: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
mapping the IP address corresponding to each character into an MAC address;
periodically sending multicast frames with each MAC address obtained by mapping as a destination address, so that the second electronic equipment is accessed to the WiFi network according to the service set identification and the password obtained by grabbing and analyzing the multicast frames;
the step of respectively encoding each character in the first character string and the second character string to obtain the IP address corresponding to each character includes:
obtaining the IP address corresponding to each character in the first character string and the second character string according to the following modes:
determining the value of a first preset bit of an IP address corresponding to the character according to the type of the character string in which the character is located;
determining the value of a second preset bit of the IP address corresponding to the character according to the sequence number of the character in the character string;
determining a value of a third preset bit of the IP address corresponding to the character according to the content of the character, wherein the sum of the bits of the first preset bit, the second preset bit and the third preset bit is determined by the mapping relation between the IP address and the MAC address;
the number of the third preset bits is more than or equal to 16 bits;
the step of determining a value of a third preset bit of the IP address corresponding to the character according to the content of the character includes:
encoding a character into two bytes according to a high nibble and a low nibble of a first code value, wherein the first code value is: the code value of the character corresponding to the preset coding rule;
determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes;
wherein said step of encoding the character into two bytes according to the high nibble and the low nibble of the first code value comprises:
determining a high nibble of a first byte of the two bytes according to a low nibble of a second code value, wherein the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
determining a low nibble of the first byte from a high nibble of a first code value;
determining a high nibble of a second byte of the two bytes according to the high nibble of the first code value;
determining a low nibble of the second byte from the low nibble of the first code value;
the step of determining a value of a third preset bit of the IP address corresponding to the character according to the encoded two bytes includes:
determining the first byte as a value of a first preset 8 bits in the third preset bits;
and determining the second byte as the value of a second preset 8 bits in the third preset bits.
2. The method of claim 1, further comprising:
and receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment, and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
3. A WiFi connection device applied to a first electronic device, the device comprising:
the encoding module is configured to encode each character in the first character string and the second character string respectively to obtain an IP address corresponding to each character, where the first character string is: the service set identifier of the WiFi network to which the second electronic device is to access, where the second character string is: a password of a WiFi network to be accessed by the second electronic equipment;
the mapping module is used for mapping the IP address corresponding to each character into an MAC address;
a sending module, configured to periodically send a multicast frame with each MAC address obtained through mapping as a destination address, so that the second electronic device accesses the WiFi network according to the service set identifier and the password obtained by capturing and analyzing the multicast frame;
wherein the encoding module comprises:
the first determining submodule is used for determining the value of a first preset bit of the IP address corresponding to the character according to the type of the character string where the character is located;
the second determining submodule is used for determining the value of a second preset bit of the IP address corresponding to the character according to the sequence number of the character in the character string;
the third determining submodule is used for determining the value of a third preset bit of the IP address corresponding to the character according to the content of the character, wherein the sum of the first preset bit, the second preset bit and the third preset bit is determined by the mapping relation between the IP address and the MAC address;
the number of the third preset bits is more than or equal to 16 bits; the third determination submodule includes:
an encoding unit, configured to encode a character into two bytes according to a high nibble and a low nibble of a first code value, where the first code value is: the code value of the character corresponding to the preset coding rule;
the determining unit is used for determining the value of a third preset bit of the IP address corresponding to the character according to the two coded bytes;
wherein the encoding unit includes:
a first determining subunit, configured to determine, according to a low nibble of a second code value, a high nibble of a first byte of the two bytes, where the second code value is: the code value corresponding to the last character in the character string where the character is located in the preset encoding rule;
a second determining subunit, configured to determine, according to the high nibble of the first code value, a low nibble of the first byte;
a third determining subunit, configured to determine, according to the high nibble of the first code value, a high nibble of a second byte of the two bytes;
a fourth determining subunit, configured to determine a low nibble of the second byte according to the low nibble of the first code value;
the determination unit includes:
a fifth determining subunit, configured to determine the first byte as a value of a first preset 8 bits in the third preset bits;
a sixth determining subunit, configured to determine the second byte as a value of a second preset 8-bit of the third preset bit.
4. The apparatus of claim 3, further comprising:
and the receiving module is used for receiving the information of successfully accessing the WiFi network fed back by the second electronic equipment and finishing sending the multicast frame with each MAC address obtained by mapping as a destination address.
5. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-2 when executing a program stored in the memory.
6. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-2.
CN201810118969.7A 2018-02-06 2018-02-06 WiFi connection method and device Active CN110120987B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810118969.7A CN110120987B (en) 2018-02-06 2018-02-06 WiFi connection method and device
PCT/CN2018/120311 WO2019153869A1 (en) 2018-02-06 2018-12-11 Wifi connection method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810118969.7A CN110120987B (en) 2018-02-06 2018-02-06 WiFi connection method and device

Publications (2)

Publication Number Publication Date
CN110120987A CN110120987A (en) 2019-08-13
CN110120987B true CN110120987B (en) 2021-03-26

Family

ID=67519449

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810118969.7A Active CN110120987B (en) 2018-02-06 2018-02-06 WiFi connection method and device

Country Status (2)

Country Link
CN (1) CN110120987B (en)
WO (1) WO2019153869A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114697258B (en) * 2022-04-11 2024-07-02 网易(杭州)网络有限公司 Data communication method, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104065765A (en) * 2014-07-09 2014-09-24 杭州古北电子科技有限公司 WIFI data transmitting method and system and related method thereof
CN104660726A (en) * 2015-02-03 2015-05-27 普联技术有限公司 Network configuration method, device and system for intelligent device
CN105101102A (en) * 2015-07-01 2015-11-25 北京奇虎科技有限公司 Multicast transmission method, information extraction method and corresponding terminal and equipment
CN106973124A (en) * 2017-03-02 2017-07-21 深圳壹秘科技有限公司 Network connection collocation method and its electronic installation

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8023513B2 (en) * 2009-02-24 2011-09-20 Fujitsu Limited System and method for reducing overhead in a wireless network
CN105119957A (en) * 2015-07-10 2015-12-02 普联技术有限公司 Information transmission method and device used for intelligent device
US10355923B2 (en) * 2015-11-02 2019-07-16 Mobitv, Inc. Self-configuration of wireless connections
CN105515845A (en) * 2015-11-30 2016-04-20 青岛海尔智能家电科技有限公司 Data transmission method, data receiving method, data transmitting end and data receiving end
CN107371219B (en) * 2016-05-13 2020-08-25 华为终端有限公司 WiFi configuration method, WiFi mobile terminal and WiFi equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104065765A (en) * 2014-07-09 2014-09-24 杭州古北电子科技有限公司 WIFI data transmitting method and system and related method thereof
CN104660726A (en) * 2015-02-03 2015-05-27 普联技术有限公司 Network configuration method, device and system for intelligent device
CN105101102A (en) * 2015-07-01 2015-11-25 北京奇虎科技有限公司 Multicast transmission method, information extraction method and corresponding terminal and equipment
CN106973124A (en) * 2017-03-02 2017-07-21 深圳壹秘科技有限公司 Network connection collocation method and its electronic installation

Also Published As

Publication number Publication date
CN110120987A (en) 2019-08-13
WO2019153869A1 (en) 2019-08-15

Similar Documents

Publication Publication Date Title
WO2021057889A1 (en) Data processing method and apparatus, electronic device, and storage medium
US20150131445A1 (en) Similarity matching method and related device and communication system
CN111970353A (en) Data processing method and device for heterogeneous equipment in Internet of things of cloud computing platform
WO2017000915A1 (en) Multicast transmission method, information extraction method and corresponding terminal and device
CN108363588B (en) Method for realizing interaction between web and native function, electronic device and readable storage medium
CN106656998B (en) server communication method and device
CN104618316A (en) Method, device and system of safety verification
CN103368977A (en) Network connection method and terminal equipment
CN109246189B (en) Network data distribution method and device, storage medium and server
CN110120987B (en) WiFi connection method and device
CN112422485B (en) Communication method and device of transmission control protocol
CN114244842B (en) Secure resource scheduling method and device, electronic equipment and storage medium
CN109413227B (en) IPv4 user access IPv6 network intercommunication device and equipment based on multi-IPv 6 network
CN115729879A (en) Data frame format, chip communication method and chip
CN110677827B (en) Network distribution method, device, system, electronic equipment and storage medium
CN113055420B (en) HTTPS service identification method and device and computing equipment
CN111277447A (en) Method and system for carrying out weight sequencing on multi-channel link
CN109446052B (en) Verification method and device for application program
CN107835198B (en) Method and device for PPTP traversal in IPv4-IPv6 intercommunication scene and electronic equipment
WO2022111326A9 (en) Data transmission method and apparatus, electronic device and storage medium
CN111315026A (en) Channel selection method, device, gateway and computer readable storage medium
CN112019357B (en) Network configuration method, device, equipment and system
CN106776497A (en) Information processing method and information processor
WO2020103578A1 (en) Domain name query method, and related product
CN112583662A (en) Host survival detection method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant