CN115412267A - Equipment connection method, device and connection code generation method - Google Patents

Equipment connection method, device and connection code generation method Download PDF

Info

Publication number
CN115412267A
CN115412267A CN202110579393.6A CN202110579393A CN115412267A CN 115412267 A CN115412267 A CN 115412267A CN 202110579393 A CN202110579393 A CN 202110579393A CN 115412267 A CN115412267 A CN 115412267A
Authority
CN
China
Prior art keywords
code
target
connection
address
value range
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.)
Pending
Application number
CN202110579393.6A
Other languages
Chinese (zh)
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.)
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Guangzhou Shirui Electronics Co Ltd
Original Assignee
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Guangzhou Shirui Electronics 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 Guangzhou Shiyuan Electronics Thecnology Co Ltd, Guangzhou Shirui Electronics Co Ltd filed Critical Guangzhou Shiyuan Electronics Thecnology Co Ltd
Priority to CN202110579393.6A priority Critical patent/CN115412267A/en
Priority to PCT/CN2022/092987 priority patent/WO2022247669A1/en
Publication of CN115412267A publication Critical patent/CN115412267A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/02Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
    • H04L63/0227Filtering policies
    • H04L63/0236Filtering by address, protocol, port number or service, e.g. IP-address or URL
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/1066Session management
    • H04L65/1069Session establishment or de-establishment
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/1066Session management
    • H04L65/1083In-session procedures
    • H04L65/1095Inter-network session transfer or sharing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/75Indicating network or usage conditions on the user display
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Multimedia (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a device connection method, a device and a connection code generation method. The equipment connection method comprises the following steps: acquiring target information of first equipment in a target local area network, wherein the target information comprises an IP address of the first equipment and a serial number of a target service port for connecting with second equipment in the target local area network; generating a target connection code according to target information, wherein the target connection code corresponds to a plurality of connection information, each connection information comprises an IP address and a service port serial number, and the plurality of connection information comprises the target information; and sending the target connection code to the second equipment, and establishing connection with the second equipment according to the target information corresponding to the target connection code. According to the method and the device, the length of the connection code is shortened by using one connection code to correspond to a plurality of connection information, and the technical problems that the input length of a pure digital connection code is too long and the input of a digital-letter mixed connection code is inconvenient when equipment is connected are solved.

Description

Equipment connection method, device and connection code generation method
Technical Field
The present application relates to the field of communications technologies, and in particular, to a device connection method, an apparatus, and a connection code generation method.
Background
Each device in the internet corresponds to an IP address, and to realize the connection between two devices, it is necessary to know the IP address of the opposite party and access a port of a specific service. The connection code is used for coding the IP address and the port serial number into recognizable continuous symbols (including numbers, letters and the like), so that one device can conveniently display the information of the device to the other device, and the two devices are connected.
In the related technology, the connection code generally has two forms of pure numbers and mixed number letters, and the pure number connection code is usually longer in length and wastes coding space; although the length of the connection code mixed by numbers and letters is slightly shorter, the input difficulty of the connection code is improved, and the connection code are not beneficial to the use experience of a user.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the application provides a device connection method, a device and a connection code generation method, and aims to at least solve the technical problems that the input length of a pure digital connection code is too long and the input of a digital-letter mixed connection code is inconvenient when devices are connected.
According to an aspect of an embodiment of the present application, there is provided a device connection method including: acquiring target information of first equipment in a target local area network, wherein the target information comprises an IP address of the first equipment and a serial number of a target service port for connecting with second equipment in the target local area network; generating a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information, each connection information comprises an IP address and a service port serial number, and the plurality of connection information comprises the target information; and sending the target connection code to the second equipment, and establishing connection with the second equipment according to the target information corresponding to the target connection code.
Optionally, the target information further includes a target check code generated by the first device, and each piece of the connection information further includes a check code.
Optionally, a binary first code is generated according to the serial number of the target service port; generating a binary second code according to the target check code; generating a binary third code according to the IP address of the first equipment; combining the first code, the second code and the third code to obtain a binary fourth code; and converting the fourth code from binary system to decimal system to obtain the target connection code.
Optionally, a first value range of the serial number of the available service port of the first device is obtained, the first value range is averagely divided into a first preset number segment value range, and the smallest segment value range is taken as a second value range, wherein the second value range is the value range of the first code; judging whether the serial number of the target service port is in the second value range or not; if the serial number of the target service port is in the second value range, generating the first code according to the serial number of the target service port; if the serial number of the target service port is not in the second value range, determining a first target value corresponding to the serial number of the target service port in the second value range, and generating the first code according to the first target value.
Optionally, a third value range of the available check code of the first device is obtained, the third value range is averagely divided into a second preset number segment value range, and the smallest segment value range is used as a fourth value range, wherein the fourth value range is the value range of the second code; judging whether the target check code is in the fourth value range or not; if the target check code is in the fourth value range, generating the second code according to the target check code; and if the target check code is not in the fourth value range, determining a second target value corresponding to the target check code in the fourth value range, and generating the second code according to the second target value.
Optionally, an IP address type of the first device is determined, where the IP address type includes a class a address, a class B address, and a class C address, the class a address range is 10.0.0.0 to 10.255.255.255, the class B address range is 172.16.0.0 to 172.31.255.255, and the class C address range is 192.168.0.0 to 192.168.255.255.
Optionally, determining a fifth value range of the bytes for any byte of the IP address of the first device, averagely dividing the fifth value range into third preset number segment value ranges, and taking the smallest segment value range as a sixth value range; judging whether the value of the byte is in the sixth value range or not; if the value of the byte is in the sixth value range, generating a sub-code corresponding to the byte according to the value of the byte; if the value of the byte is not in the sixth value range, determining a third target value corresponding to the value of the byte in the sixth value range, and generating a sub-code corresponding to the byte according to the third target value; and determining the third code according to the sub-codes corresponding to all bytes of the IP address of the first equipment.
Optionally, combining sub-codes corresponding to four bytes of the IP address of the first device to obtain the third code; or when the IP address type of the first device is an a-type address or a B-type address, combining sub-codes corresponding to the last three bytes of the IP address of the first device to obtain the third code; and when the IP address type of the first equipment is the C-type address, combining the sub-codes corresponding to the last two bytes of the IP address of the first equipment to obtain the third code.
Optionally, the target connection code is sent to the second device, and the second device parses the multiple pieces of connection information corresponding to the target connection code; receiving a plurality of connection requests sent by the second device according to the plurality of connection information, wherein each piece of connection information corresponds to one connection request; and determining whether the connection information corresponding to each connection request is the same as the target information, and establishing connection with the second equipment when the connection information is the same as the target information.
According to another aspect of the embodiments of the present application, there is also provided a connection code generating method, including: acquiring a target service port serial number, a target check code and an IP address which are used for being connected with second equipment in first equipment; generating a binary first code according to the target service port serial number, wherein the first code corresponds to a plurality of service port serial numbers, and the plurality of service port serial numbers comprise the target service port serial number; generating a binary second code according to the target check code, wherein the second code corresponds to a plurality of check codes, and the check codes comprise the target check code; generating a binary third code according to the IP address of the first device, wherein the third code corresponds to a plurality of IP addresses, and the IP addresses comprise the IP address of the first device; combining the first code, the second code and the third code to obtain a binary fourth code; and converting the fourth code from binary system to decimal system to obtain the target connection code.
According to another aspect of the embodiments of the present application, there is also provided an apparatus connecting device, including: an obtaining module, configured to obtain target information of a first device in a target local area network, where the target information includes an IP address of the first device and a sequence number of a target service port used for connecting to a second device in the target local area network; a generating module, configured to generate a target connection code according to the target information, where the target connection code corresponds to multiple pieces of connection information, each piece of connection information includes an IP address and a service port serial number, and the multiple pieces of connection information include the target information; and the connection module is used for sending the target connection code to the second equipment and establishing connection with the second equipment according to the target information corresponding to the target connection code.
According to another aspect of the embodiments of the present application, a non-volatile storage medium is further provided, where the non-volatile storage medium includes a stored program, and when the program runs, the device where the non-volatile storage medium is located is controlled to execute the device connection method or the connection code generation method described above.
In the embodiment of the application, first, target information of a first device is obtained, wherein the target information comprises an IP address and a serial number of a target service port for connecting with a second device; then generating a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information; and sending the target connection code to the second equipment, determining target information from a plurality of connection information corresponding to the target connection code in a retry mode, and establishing connection with the second equipment according to the target information. This application trades the thought in space based on time, through corresponding a plurality of connection information with a connection code to the number of bits of connection code is shortened to the mode of retry, reduces extra space and occupies, thereby pure number connection code input length overlength when having solved equipment connection, the inconvenient technical problem of connection code input of digit letter mixture.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flow chart diagram of a device connection method according to an embodiment of the present application;
fig. 2 is a flowchart illustrating a connection code generation method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a device connecting apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all 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 application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the accompanying drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be implemented in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
In accordance with an embodiment of the present application, there is provided an embodiment of a device connection method, it should be noted that the steps shown in the flowchart of the drawings may be performed in a computer system such as a set of computer executable instructions, and that while a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in an order different than here.
Fig. 1 is a device connection method according to an embodiment of the present application, and as shown in fig. 1, the method includes the steps of:
step S102, obtaining target information of a first device in a target local area network, wherein the target information comprises an IP address of the first device and a serial number of a target service port for connecting with a second device in the target local area network.
In some optional embodiments of the present application, all available service ports of the first device may be numbered first, then the serial number of the target service port used for connecting with the second device is determined, and at the same time, the IP address of the first device is determined, and the IP address and the serial number of the target service port are used as the target information of the first device.
Optionally, the target information further includes a target check code generated by the first device, where the target check code is a number randomly generated by the first device within a preset value range, and a specific value range may be defined by a user, for example, 0 to 15. In some optional embodiments of the present application, the target check code may be dynamically refreshed over time, that is, the first device may generate a new target check code every other fixed time period, so as to ensure the security of device connection.
Step S104, generating a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information, each connection information comprises an IP address and a service port serial number, and the plurality of connection information comprises the target information.
It is understood that the target connection code is generated according to the target information, and therefore the target information is necessarily included in the connection information corresponding to the target connection code. When the target information comprises the target check code, each piece of connection information corresponding to the target connection code also comprises a check code.
In some optional embodiments of the present application, the process of generating the target connection code according to the target information includes steps S1040-S1048:
step S1040, a binary first code is generated according to the sequence number of the target service port.
Specifically, a first value range of the serial number of the available service port of the first device is obtained, the first value range is averagely divided into a first preset number segment value range, and the smallest segment value range is used as a second value range, wherein the second value range is the value range of the first code.
Then, judging whether the serial number of the target service port is in a second value range; if the serial number of the target service port is in the second value range, generating a first code according to the serial number of the target service port; and if the serial number of the target service port is not in the second value range, determining a first target value corresponding to the serial number of the target service port in the second value range, and generating a first code according to the first target value.
For example, 4 available service ports of the first device are respectively numbered as 0, 1, 2, and 3, the first value range is 0-3, the first value range is averagely divided into 2 segments, the second value range is 0-1, and the generated first code takes values within 0-1; if the serial number of the target service port is 1 and is within a second value range of 0-1, a binary first code is directly generated as 1 according to 1; assuming that the sequence number of the target service port is 3 and is not within the second value range 0-1, it needs to first determine that the corresponding first target value is 3-2=1 (2 indicates that the second value range includes 2 numbers), and then generate the binary first code as 1 according to 1.
It can be seen that 1 of the first code may correspond to a plurality of service port sequence numbers, which may indicate that the service port sequence number is 1, or may indicate that the service port sequence number is 3, and the specific meaning needs to be determined by retry at the time of connection. Through the above process, the first code which originally needs 2 bits (0-3 corresponds to binary 00-11) can be shortened to 1bit (0-1 corresponds to binary 0-1) for representation.
In some optional embodiments of the present application, the first code may not be generated, that is, the target information does not include the serial number of the target service port, and when performing device connection, the first code may directly and sequentially attempt to connect with a plurality of available service ports of the first device.
Step S1042, a binary second code is generated according to the target check code.
Similar to the process of generating the first code, a third value range of the available check code of the first device is obtained, the third value range is averagely divided into a second preset number segment value range, and the smallest segment value range is used as a fourth value range, wherein the fourth value range is the value range of the second code.
And then. Judging whether the target check code is in a fourth value range or not; if the target check code is in the fourth value range, generating a second code according to the target check code; and if the target check code is not in the fourth value range, determining a second target value corresponding to the target check code in the fourth value range, and generating a second code according to the second target value.
For example, a user presets a third value range of the available check code to be 0-15, the third value range is divided into 2 sections on average, a fourth value range of 0-7 is obtained, and the generated second code takes values within 0-7; if the target check code is 6 and is within the fourth value range of 0-7, a binary first code 110 is directly generated according to 6; assuming that the target check code is 13 and is not within the fourth value range 0-7, it needs to first determine that the corresponding second target value is 13-8=5 (8 indicates that the second value range includes 2 numbers), and then generate the binary first code 101 according to 5.
If the third value range 0-15 is averagely divided into 4 sections, a fourth value range 0-3 is obtained, and the generated second code takes values within 0-3; if the target check code is 2 and is within the fourth value range of 0-3, directly generating a binary first code 10 according to 2; assuming that the target check code is 6 and is not within the fourth value range 0-3, it needs to first determine that the corresponding second target value is 6-4=2 (4 indicates that the second value range includes 4 numbers), and then generate a binary first code 10 according to 2; assuming that the target check code is 13 and is not within the fourth value range 0-3, it is required to first determine that the corresponding second target value is 13-4-4-4=1, and then generate a binary first code 1 according to 1.
Through the above process, the second code originally needing 4 bits (0-15 corresponding to binary 0000-1111) can be shortened to 3 bits (0-7 corresponding to binary 000-111) or even 2 bits (0-3 corresponding to binary 00-11) for representation.
Step S1044 is to generate a binary third code according to the IP address of the first device.
In some optional embodiments of the present application, different encoding strategies may be applied to different types of IP addresses, and therefore, the IP address type of the first device may be determined first, where the IP address type includes a class a address, a class B address, and a class C address, the class a address range is 10.0.0.0 to 10.255.255.255, the class B address range is 172.16.0.0 to 172.31.255.255, the class C address range is 192.168.0.0 to 192.168.255.255, and each class IP address includes four bytes.
Then, for any byte of the IP address of the first device, determining a fifth value range of the byte, averagely dividing the fifth value range into a third preset number segment value range, and taking the smallest segment value range as a sixth value range; judging whether the value of the byte is in a sixth value range or not; if the value of the byte is in the sixth value range, generating a sub-code corresponding to the byte according to the value of the byte; if the value of the byte is not in the sixth value range, determining a third target value corresponding to the value of the byte in the sixth value range, and generating a sub-code corresponding to the byte according to the third target value; finally, the third code is determined according to the sub-codes corresponding to the bytes of the IP address of the first device, and usually, the sub-codes corresponding to the four bytes of the IP address of the first device are combined to obtain the third code.
For example, if the IP address of the first device is 192.168.126.128, the following processing may be performed for each byte: determining the fifth value range to be 0-255, and averagely dividing the fifth value range into 2 sections to obtain a sixth value range of 0-127; if the first byte 192 is not within the sixth value range 0 to 127, the third target value corresponding to the first byte 192 is determined to be 192 to 128=64, and then the binary sub-code is generated to be 1000000 according to 64; if the second byte 168 is not within the sixth value range 0-127, it is determined that the corresponding third target value is 168-128=40, and then a binary sub-code 0101000 is generated according to 40; if the third byte 126 is in the sixth value range 0-127, the binary sub-code 1111110 is directly generated according to the third byte 126; if the fourth byte 128 is not within the sixth value range 0-127, it is determined that the corresponding third target value is 128-128=0, and then the binary sub-code is generated as 0000000 according to 0; finally, the sub-codes corresponding to the four bytes are combined to obtain a 28-bit third code 1000000010100011111100000000, which is 4 bits shorter than the original 32 bits.
It should be noted that, for different bytes of the IP address of the first device, the determined fifth value ranges may be different, and the number of segments obtained by averagely dividing the fifth value ranges may also be different, and if the fifth value ranges are divided into one segment, it means that the binary sub-code is directly generated according to the value of the byte.
For example, when the IP address type of the first device is a class B address, since the value range of the second byte is 16 to 31, when the second byte is processed, 0 to 31 may be used as the fifth value range, and the fifth value range is averagely divided into 2 segments, so that the sixth value range is 0 to 15; assuming that the IP address of the first device is 172.31.255.255, since 31 is not in the eighth value range 0-15, it is determined that the corresponding fourth target value is 31-16=15, and then a binary sub-code 1111 is generated according to 15, where the bit number is only 4 bits.
Since the IP address is usually partitioned from the previous segment, for example, 10.xx.xx.xx may be divided into 10.0.xx.xx-10.2.xx.xx and 10.12.xx.xx-10.16.xx.xx, the fifth value range of the first two bytes may be divided into 2 segments on average when determining the sub-code corresponding to each byte, and the sub-code is determined according to the above process; and averagely dividing the fifth value range of the last two bytes into 1 segment, namely directly generating the sub-code according to the value of the bytes.
In some optional embodiments of the present application, since the first byte (i.e., the flag bit) of the class a IP address is fixed to 10, the first byte of the class B IP address is fixed to 172, the first two bytes of the class c IP address are fixed to 192.168, when the IP address type of the first device is the class a address or the class B address, sub-codes corresponding to the last three bytes of the IP address of the first device are combined to obtain a third code; and when the IP address type of the first equipment is the C-type address, combining the sub-codes corresponding to the last two bytes of the IP address of the first equipment to obtain a third code. When the device is connected, the zone bit of the IP address can be determined directly by adopting a retry mode.
For example, if the IP address of the first device is 192.168.126.128 and the first device is a C-type address, the sub-code 1111110 corresponding to the third byte and the sub-code 0000000 corresponding to the fourth byte need only be combined to obtain the third code 11100000000 corresponding to the IP address.
Step S1046, combining the first code, the second code, and the third code to obtain a binary fourth code.
And step S1048, converting the fourth code from binary to decimal to obtain the target connection code.
Assuming that the serial number of the target service port used by the first device for connecting with the second device is 3, the generated check code is 15, the ip address is 10.255.255.255, if the information is directly represented by the real value when the connection code is generated, the obtained first code is 11, the second code is 1111, the third code is 00001010111111111111111111111111111111111111111, the combination of the first code and the third code is 38 bits of the fourth code 11111100001010111111111111111111111111111111111111111111, the target connection code converted into decimal is 270767489023, and the number of bits is 12 bits. If it is determined that each value range is equally divided into two segments and the first byte of the IP address is omitted when the target connection code generation process is adopted, the first code is 1, the second code is 111, the third code is 111111111111111111111 are obtained respectively, the first code, the second code and the third code are combined to obtain the fourth code 1111111111111111111111111111111111 which has 25 bits in total, and the target connection code converted into the decimal code is 33554431, and the number of bits of the target connection code is only 8 bits. It can be seen that the number of bits of the target connection code obtained through the above process is greatly shortened, and the extra space occupation is reduced.
And step S106, sending the target connection code to the second equipment, and establishing connection with the second equipment according to the target information corresponding to the target connection code.
In some optional embodiments of the present application, the target connection code is sent to the second device, and the second device parses a plurality of connection information corresponding to the target connection code; receiving a plurality of connection requests sent by second equipment according to a plurality of connection information, wherein each connection information corresponds to one connection request; and determining whether the connection information corresponding to each connection request is the same as the target information or not, and establishing connection with the second equipment when the connection information is the same as the target information.
Specifically, after the target connection code is sent to the second device, the second device reversely analyzes a plurality of connection information corresponding to the target connection code according to the target connection code generation process, and sends a connection request to the first device according to each connection information to try to establish connection with the first device; after receiving a connection request, the first device compares connection information corresponding to the connection request with its own target information, and if the connection information is the same as the target information, that is, the connection information includes a serial number of a target service port used by the first device to connect with the second device, a target check code generated by the first device, and an IP address of the first device, then the first device establishes a connection with the second device.
For example, the serial number of the target service port used by the first device to connect with the second device is 3, the generated check code is 15, the ip address is 10.255.255.255, and the connection code is generated according to the connection code generation process 33554431 and sent to the second device. The second device reversely analyzes the connection code according to the connection code generation process, firstly converts the connection code into binary 1111111111111111111111111111, and determines that the first code corresponding to the service port serial number is 1, and then considers that the service port serial number of the first device may be 1, and may be 3; determining that the second code corresponding to the check code is 111, that is, considering that the check code of the first device may be 7, and may be 15; determining that the third code corresponding to the IP address is 111111111111111111111, and considering that the second byte of the IP address of the first device may be 127, and may be 255; the third byte may be 127, may be 255; the fourth byte may be 127, may be 255; the second byte does not satisfy B and C type addresses, the address is determined to be an A type address, and the first byte is 10; and combining the information to obtain a plurality of connection information, wherein the service port serial number is 1, the check code is 7, and the IP address is 10.127.127.127.127. Because the first device and the second device operate in the same local area network, the second device can preferentially consider the same bytes as the first bytes of the own IP address when resolving the first bytes of the IP address.
The second device generates a corresponding connection request according to each connection information to attempt to connect with the first device, and continuously retries. And after receiving a connection request, the first device compares the connection information corresponding to the connection request with the target information of the first device, if the connection information is different from the target information, the first device continues to judge the next connection request, and if the connection information is the same as the target information, the first device establishes connection with the second device.
In the embodiment of the application, first, target information of a first device is obtained, wherein the target information comprises an IP address and a serial number of a target service port for connecting with a second device; then generating a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information; and sending the target connection code to the second equipment, determining target information from a plurality of connection information corresponding to the target connection code in a retry mode, and establishing connection with the second equipment according to the target information. This application trades the thought in space based on time, through corresponding a plurality of connection information with a connection code to the number of bits of connection code is shortened to the mode of retry, reduces extra space and occupies, thereby pure digital connection code input length overlength when having solved equipment connection, the inconvenient technical problem of connection code input of digit-letter mixture.
Example 2
There is also provided, in accordance with an embodiment of the present application, an embodiment of a connection code generation method, it should be noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions, and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
Fig. 2 is a method for connecting devices according to an embodiment of the present application, as shown in fig. 2, the method including the steps of:
step S202, a target service port serial number, a target check code and an IP address which are used for being connected with the second equipment in the first equipment are obtained.
In some optional embodiments of the present application, all available service ports of the first device may be numbered first, and then a serial number of a target service port used for connecting with the second device is determined; determining a target check code generated by the first device, where the target check code is a number randomly generated by the first device within a preset value range, where the specific value range may be defined by a user, for example, 0 to 15, and optionally, the target check code may be dynamically refreshed over time, that is, the first device may generate a new target check code every other fixed time period, so as to ensure security of device connection; at the same time, the IP address of the first device is determined.
Step S204, a binary first code is generated according to the target service port serial number, the first code corresponds to a plurality of service port serial numbers, and the plurality of service port serial numbers include the target service port serial number.
Specifically, a first value range of the serial number of the available service port of the first device is obtained, the first value range is averagely divided into a first preset number segment value range, and the smallest segment value range is used as a second value range, wherein the second value range is the value range of the first code. Then, judging whether the serial number of the target service port is in a second value range; if the serial number of the target service port is in the second value range, generating a first code according to the serial number of the target service port; and if the serial number of the target service port is not in the second value range, determining a first target value corresponding to the serial number of the target service port in the second value range, and generating a first code according to the first target value.
Step S206, a binary second code is generated according to the target check code, the second code corresponds to a plurality of check codes, and the plurality of check codes includes the target check code.
Specifically, a third value range of the available check code of the first device is obtained, the third value range is averagely divided into a second preset number segment value range, and the smallest segment value range is used as a fourth value range, wherein the fourth value range is the value range of the second code. And then. Judging whether the target check code is in a fourth value range; if the target check code is in the fourth value range, generating a second code according to the target check code; and if the target check code is not in the fourth value range, determining a second target value corresponding to the target check code in the fourth value range, and generating a second code according to the second target value.
Step S208, a binary third code is generated according to the IP address of the first device, where the third code corresponds to multiple IP addresses, and the multiple IP addresses include the IP address of the first device.
In some optional embodiments of the present application, the IP address type of the first device may be determined first, where each type of IP address includes four bytes; determining a fifth value range of any byte of the IP address of the first device, averagely dividing the fifth value range into a third preset number segment value range, and taking the smallest segment value range as a sixth value range; judging whether the value of the byte is in a sixth value range or not; if the value of the byte is in the sixth value range, generating a sub-code corresponding to the byte according to the value of the byte; if the value of the byte is not in the sixth value range, determining a third target value corresponding to the value of the byte in the sixth value range, and generating a sub-code corresponding to the byte according to the third target value; and finally, determining a third code according to the sub-codes corresponding to the bytes of the IP address of the first device, and generally combining the sub-codes corresponding to the four bytes of the IP address of the first device to obtain the third code.
The determined fifth value ranges may be different for different bytes of the IP address of the first device, and the number of segments into which the fifth value ranges are divided on average may also be different.
In some optional embodiments of the present application, since the first byte (i.e., the flag bit) of the class a IP address is fixed to 10, the first byte of the class B IP address is fixed to 172, the first two bytes of the class c IP address are fixed to 192.168, when the IP address type of the first device is the class a address or the class B address, sub-codes corresponding to the last three bytes of the IP address of the first device are combined to obtain a third code; and when the IP address type of the first equipment is the C-type address, combining the sub-codes corresponding to the last two bytes of the IP address of the first equipment to obtain a third code. When the device is connected, the zone bit of the IP address can be determined by directly adopting a retry mode.
Step S210, the first code, the second code, and the third code are combined to obtain a binary fourth code.
And S212, converting the fourth code from binary system to decimal system to obtain the target connection code.
In the embodiment of the application, a target service port serial number, a target check code and an IP address used for being connected with a second device in a first device are obtained, a first code is generated according to the target service port serial number, a second code is generated according to the target check code, and a third code is generated according to the IP address of the first device, wherein the number of bits of the codes is shortened by enabling each code to correspond to a plurality of pieces of information, so that the length of the target connection code obtained by final combination is shortened, extra space occupation is reduced, and the technical problems that the input length of a pure digital connection code is too long and the input of a connection code with mixed numbers and letters is inconvenient when the devices are connected are solved.
Example 3
According to an embodiment of the present application, there is also provided an apparatus for implementing the apparatus connection method, as shown in fig. 3, the apparatus includes an obtaining module 30, a generating module 32, and a connecting module 34, where:
an obtaining module 30, configured to obtain target information of a first device in a target local area network, where the target information includes an IP address of the first device and a sequence number of a target service port used for connecting to a second device in the target local area network.
The generating module 32 is configured to generate a target connection code according to the target information, where the target connection code corresponds to multiple pieces of connection information, each piece of connection information includes an IP address and a service port serial number, and the multiple pieces of connection information include the target information.
The connection module 34 is configured to send the target connection code to the second device, and establish a connection with the second device according to the target information corresponding to the target connection code.
It should be noted that, each module in the device connection apparatus in this embodiment corresponds to a step in the device connection method in embodiment 1 one to one, and since the detailed description is already performed in embodiment 1, some details that are not shown in this embodiment may refer to embodiment 1, and are not described herein again.
Example 4
According to the embodiment of the application, a nonvolatile storage medium is further provided, and the nonvolatile storage medium includes a stored program, wherein when the program runs, a device where the nonvolatile storage medium is located is controlled to execute the device connection method or the connection code generation method.
Optionally, the apparatus in which the non-volatile storage medium is controlled when the program is running executes the following steps: acquiring target information of first equipment in a target local area network, wherein the target information comprises an IP address of the first equipment and a serial number of a target service port for connecting with second equipment in the target local area network; generating a target connection code according to target information, wherein the target connection code corresponds to a plurality of connection information, each connection information comprises an IP address and a service port serial number, and the plurality of connection information comprises the target information; and sending the target connection code to the second equipment, and establishing connection with the second equipment according to the target information corresponding to the target connection code.
Optionally, the apparatus in which the non-volatile storage medium is controlled during program execution performs the following steps: acquiring a target service port serial number, a target check code and an IP address which are used for being connected with second equipment in first equipment; generating a binary first code according to the sequence number of the target service port, wherein the first code corresponds to a plurality of service port sequence numbers, and the plurality of service port sequence numbers comprise the sequence number of the target service port; generating a binary second code according to the target check code, wherein the second code corresponds to a plurality of check codes, and the check codes comprise the target check code; generating a binary third code according to the IP address of the first device, wherein the third code corresponds to a plurality of IP addresses, and the plurality of IP addresses comprise the IP address of the first device; combining the first code, the second code and the third code to obtain a binary fourth code; and converting the fourth code from binary system to decimal system to obtain the target connection code.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, a division of a unit may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or may not be executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, or portions or all or portions of the technical solutions that contribute to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (12)

1. A device connection method, comprising:
acquiring target information of first equipment in a target local area network, wherein the target information at least comprises an IP address of the first equipment and a serial number of a target service port for connecting with second equipment in the target local area network;
generating a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information, each connection information comprises an IP address and a service port serial number, and the plurality of connection information comprises the target information;
and sending the target connection code to the second equipment, and establishing connection with the second equipment according to the target information corresponding to the target connection code.
2. The method of claim 1, wherein the destination information further includes a destination check code generated by the first device, and each of the connection information further includes a check code.
3. The method of claim 2, wherein generating a target connection code based on the target information comprises:
generating a binary first code according to the serial number of the target service port;
generating a binary second code according to the target check code;
generating a binary third code according to the IP address of the first equipment;
combining the first code, the second code and the third code to obtain a binary fourth code;
and converting the fourth code from binary system to decimal system to obtain the target connection code.
4. The method of claim 3, wherein generating a binary first code according to the sequence number of the target service port comprises:
acquiring a first value range of the serial number of the available service port of the first device, averagely dividing the first value range into a first preset number segment value range, and taking the smallest segment value range as a second value range, wherein the second value range is the value range of the first code;
judging whether the serial number of the target service port is in the second value range or not;
if the serial number of the target service port is in the second value range, generating the first code according to the serial number of the target service port;
if the serial number of the target service port is not in the second value range, determining a first target value corresponding to the serial number of the target service port in the second value range, and generating the first code according to the first target value.
5. The method of claim 3, wherein generating a binary second code from the target check code comprises:
acquiring a third value range of the available check code of the first device, averagely dividing the third value range into a second preset number segment value range, and taking the smallest segment value range as a fourth value range, wherein the fourth value range is the value range of the second code;
judging whether the target check code is in the fourth value range or not;
if the target check code is in the fourth value range, generating the second code according to the target check code;
if the target check code is not in the fourth value range, determining a second target value corresponding to the target check code in the fourth value range, and generating the second code according to the second target value.
6. The method of claim 3, wherein before generating the binary third code according to the IP address of the first device, the method further comprises:
and determining the IP address type of the first device, wherein the IP address type comprises a class A address, a class B address and a class C address, the range of the class A address is 10.0.0.0 to 10.255.255.255, the range of the class B address is 172.16.0.0 to 172.31.255.255, and the range of the class C address is 192.168.0.0 to 192.168.255.255.
7. The method of claim 6, wherein generating a binary third code based on the IP address of the first device comprises:
determining a fifth value range of the bytes for any byte of the IP address of the first device, averagely dividing the fifth value range into a third preset number segment value range, and taking the minimum segment value range as a sixth value range;
judging whether the value of the byte is in the sixth value range or not; if the value of the byte is in the sixth value range, generating a sub-code corresponding to the byte according to the value of the byte; if the value of the byte is not in the sixth value range, determining a third target value corresponding to the value of the byte in the sixth value range, and generating a sub-code corresponding to the byte according to the third target value;
and determining the third code according to the sub-codes corresponding to all bytes of the IP address of the first equipment.
8. The method of claim 7, wherein determining the third code according to the sub-codes corresponding to the bytes of the IP address of the first device comprises:
combining sub-codes corresponding to four bytes of the IP address of the first device to obtain a third code; or the like, or, alternatively,
when the IP address type of the first equipment is an A-type address or a B-type address, combining the sub-codes corresponding to the last three bytes of the IP address of the first equipment to obtain a third code; and when the IP address type of the first equipment is the C-type address, combining the sub-codes corresponding to the last two bytes of the IP address of the first equipment to obtain the third code.
9. The method of claim 1, wherein sending the target connection code to the second device and establishing a connection with the second device according to the target information corresponding to the target connection code comprises:
sending the target connection code to the second equipment, and analyzing the plurality of connection information corresponding to the target connection code by the second equipment;
receiving a plurality of connection requests sent by the second device according to the plurality of connection information, wherein each connection information corresponds to one connection request;
and determining whether the connection information corresponding to each connection request is the same as the target information, and establishing connection with the second device when the connection information is the same as the target information.
10. A connection code generation method, comprising:
acquiring a target service port serial number, a target check code and an IP address which are used for being connected with second equipment in first equipment;
generating a binary first code according to the target service port serial number, wherein the first code corresponds to a plurality of service port serial numbers, and the plurality of service port serial numbers comprise the target service port serial number;
generating a binary second code according to the target check code, wherein the second code corresponds to a plurality of check codes, and the check codes comprise the target check code;
generating a binary third code according to the IP address of the first device, wherein the third code corresponds to a plurality of IP addresses, and the IP addresses comprise the IP address of the first device;
combining the first code, the second code and the third code to obtain a binary fourth code;
and converting the fourth code from binary system to decimal system to obtain the target connection code.
11. An apparatus connecting device, comprising:
an obtaining module, configured to obtain target information of a first device in a target local area network, where the target information includes an IP address of the first device and a sequence number of a target service port used for connecting to a second device in the target local area network;
a generating module, configured to generate a target connection code according to the target information, where the target connection code corresponds to multiple pieces of connection information, each piece of connection information includes an IP address and a service port serial number, and the multiple pieces of connection information include the target information;
and the connection module is used for sending the target connection code to the second equipment and establishing connection with the second equipment according to the target information corresponding to the target connection code.
12. A non-volatile storage medium, comprising a stored program, wherein when the program runs, a device in which the non-volatile storage medium is located is controlled to execute the device connection method according to any one of claims 1 to 9.
CN202110579393.6A 2021-05-26 2021-05-26 Equipment connection method, device and connection code generation method Pending CN115412267A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110579393.6A CN115412267A (en) 2021-05-26 2021-05-26 Equipment connection method, device and connection code generation method
PCT/CN2022/092987 WO2022247669A1 (en) 2021-05-26 2022-05-16 Device connection method and apparatus, and method for generating connection code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110579393.6A CN115412267A (en) 2021-05-26 2021-05-26 Equipment connection method, device and connection code generation method

Publications (1)

Publication Number Publication Date
CN115412267A true CN115412267A (en) 2022-11-29

Family

ID=84156571

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110579393.6A Pending CN115412267A (en) 2021-05-26 2021-05-26 Equipment connection method, device and connection code generation method

Country Status (2)

Country Link
CN (1) CN115412267A (en)
WO (1) WO2022247669A1 (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8862731B2 (en) * 2008-04-25 2014-10-14 Smart Technologies Ulc Method and system for coordinating data sharing in a network with at least one physical display device
US9135412B1 (en) * 2015-02-24 2015-09-15 Wowza Media Systems, LLC Token-based security for remote resources
CN107566453B (en) * 2017-08-03 2021-02-09 广州视源电子科技股份有限公司 Service discovery method, device, computer readable storage medium and computer equipment
CN108848164B (en) * 2018-06-15 2022-02-25 广州视源电子科技股份有限公司 Display device connection method, display device and system
CN108848162B (en) * 2018-06-15 2021-11-23 广州视源电子科技股份有限公司 Display device connection method, display device and system

Also Published As

Publication number Publication date
WO2022247669A1 (en) 2022-12-01

Similar Documents

Publication Publication Date Title
CN110134889B (en) Short link generation method and device and server
CN110264172B (en) Transaction processing method and device based on blockchain
CN109493054B (en) Multi-chain information management method, device, storage medium and block chain identity analyzer
US10360354B1 (en) Method and apparatus of performing distributed steganography of a data message
CN112632484A (en) Software authorization method and device and computer equipment
CN113742709A (en) Information processing method and device, readable medium and electronic equipment
CN112218133B (en) Screen projection code generation method and device and terminal equipment
CN115412267A (en) Equipment connection method, device and connection code generation method
CN111130791B (en) Data signature method, electronic device and computer readable storage medium
CN111225077A (en) Network distribution method, device and system for Internet of things equipment
CN110913351B (en) Multicast control method, device, network equipment and storage medium
CN114422209B (en) Data processing method, device and storage medium
CN110618989A (en) Information processing method, information processing device and related product
JP2009169316A (en) Hash function operational device, signature device, program and hash function operational method
CN113542308A (en) Information processing method, system and storage medium, electronic device
CN115208570A (en) Encryption method and device based on dynamic replacement of secret key
CN111355821A (en) Connection code generation method, device, electronic device and storage medium
CN111385797B (en) WiFi network distribution method, device, apparatus and storage medium
CN110458566B (en) Block chain account address generation method, system and device and computer readable storage medium
CN110545107B (en) Data processing method and device, electronic equipment and computer readable storage medium
CN112711683A (en) Data comparison method and device and computer equipment
CN112182593A (en) Data processing method and device and electronic equipment
CN109145645B (en) Method for protecting short message verification code in android mobile phone
CN110247912B (en) Data processing method and device
CN113343269B (en) Encryption method and device

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