WO2022247669A1 - 设备连接方法、装置及连接码生成方法 - Google Patents

设备连接方法、装置及连接码生成方法 Download PDF

Info

Publication number
WO2022247669A1
WO2022247669A1 PCT/CN2022/092987 CN2022092987W WO2022247669A1 WO 2022247669 A1 WO2022247669 A1 WO 2022247669A1 CN 2022092987 W CN2022092987 W CN 2022092987W WO 2022247669 A1 WO2022247669 A1 WO 2022247669A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
target
connection
address
value range
Prior art date
Application number
PCT/CN2022/092987
Other languages
English (en)
French (fr)
Inventor
李响
田楠
Original Assignee
广州视源电子科技股份有限公司
广州视睿电子科技有限公司
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 广州视源电子科技股份有限公司, 广州视睿电子科技有限公司 filed Critical 广州视源电子科技股份有限公司
Publication of WO2022247669A1 publication Critical patent/WO2022247669A1/zh

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

Definitions

  • the present application relates to the field of communication technologies, and in particular, to a device connection method and device, and a connection code generation method.
  • Each device on the Internet has an IP address. To realize the connection between two devices, you need to know the IP address of the other party and access the port of a specific service.
  • the function of the connection code is to encode the IP address and port serial number into recognizable continuous symbols (including numbers, letters, etc.), so that one device can conveniently display its own information to another device, thus connecting the two devices to connect.
  • connection codes generally have two forms of pure numbers and mixed numbers and letters.
  • the connection codes of pure numbers are usually longer in length, which wastes coding space; while the connection codes of mixed numbers and letters are shorter in length, but it will increase the length of the connection code. input difficulty, both of which are not conducive to the user experience.
  • the embodiment of the present application provides a device connection method, device and connection code generation method to at least solve the technical problems that the input length of the pure digital connection code is too long and the input of the connection code with mixed numbers and letters is inconvenient when the device is connected.
  • a device connection method including: acquiring target information of a first device in a target local area network, wherein the target information includes the IP address of the first device and the IP address used to communicate with The serial number of the target service port that the second device in the target local area network connects to; generate a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information, and each of the connection information includes a IP address and a service port serial number, the plurality of connection information includes the target information; sending the target connection code to the second device, and according to the target information corresponding to the target connection code and the target information The second device establishes a connection.
  • the target information further includes a target check code generated by the first device, and each piece of connection information further includes a check code.
  • a binary first code is generated according to the serial number of the target service port; a binary second code is generated according to the target check code; a binary third code is generated according to the IP address of the first device; The first code, the second code and the third code are combined to obtain a binary fourth code; the fourth code is converted from binary to decimal to obtain the target connection code.
  • a first value range of the available service port number of the first device divide the first value range into a first preset number of value ranges, and divide the smallest value range Range as the second value range, wherein, the second value range is the value range of the first code; judge whether the serial number of the target service port is within the second value range; if the If the serial number of the target service port is within the second value range, then generate the first code according to the serial number of the target service port; if the serial number of the target service port is not within the second value range, then 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.
  • the fourth value range is the value range of the second code; judge whether the target check code is within the fourth value range; if the target If the check code is within the fourth value range, then generate the second code according to the target check code; if the target check code is not within the fourth value range, then determine the second code
  • the second code is generated according to the second target value corresponding to the target check code in the range of four values.
  • the IP address type of the first device determines the IP address type of the first device, where the IP address type includes a class A address, a class B address, and a class C address, the class A address ranges from 10.0.0.0 to 10.255.255.255, and the class B address ranges 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.
  • a fifth value range of the byte is determined, and the fifth value range is equally divided into a third preset number of segment values range, taking the smallest value range as the sixth value range; judging whether the value of the byte is within the sixth value range; if the value of the byte is within the sixth value range If the value of the byte is not within the sixth value range, then the sub-code corresponding to the byte is generated according to the value of the byte; if the value of the byte is not within the sixth value range, then determine the The third target value corresponding to the value of the byte, and generate the sub-code corresponding to the byte according to the third target value; according to the sub-code corresponding to each byte of the IP address of the first device, determine The third code.
  • combining the subcodes corresponding to the 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 a class A address or For a Class B address, combine the subcodes corresponding to the last three bytes of the IP address of the first device to obtain the third code; when the IP address type of the first device is a Class C address , combining the subcodes corresponding to the last two bytes of the IP address of the first device to obtain the third code.
  • the target connection code is sent to the second device, and the second device parses the plurality of connection information corresponding to the target connection code; receiving the second device according to the plurality of connection information A plurality of connection requests sent by the connection information, wherein each of the connection information corresponds to one of the connection requests; determine whether the connection information corresponding to each of the connection requests is the same as the target information, and when the connection information and the Establishing a connection with the second device when the target information is the same.
  • a method for generating a connection code including: acquiring the target service port serial number, target check code, and IP address used in the first device for connecting to the second device;
  • the target service port serial number generates a binary first code, the first code corresponds to a plurality of service port serial numbers, and the multiple service port serial numbers include the target service port serial number; a binary code is generated according to the target check code
  • the second code, the second code corresponds to a plurality of check codes, the multiple check codes include the target check code; generate a binary third code according to the IP address of the first device, so
  • the third code corresponds to a plurality of IP addresses, and the plurality of IP addresses includes the IP address of the first device; the first code, the second code and the third code are combined to obtain a binary fourth code ; Convert the fourth code from binary to decimal to obtain the target connection code.
  • a device connection apparatus including: an acquisition module, configured to acquire target information of a first device in a target local area network, wherein the target information includes the first device The IP address of the target LAN and the sequence number of the target service port used to connect to the second device in the target local area network; the generation module is used to generate a target connection code according to the target information, wherein the target connection code corresponds to a plurality of Connection information, each of the connection information includes an IP address and a service port serial number, and the plurality of connection information includes the target information; a connection module, 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.
  • a non-volatile storage medium includes a stored program, wherein the non-volatile memory is controlled when the program is running.
  • the device where the storage medium is located executes the above-mentioned device connection method or connection code generation method.
  • first obtain the target information of the first device including the IP address and the serial number of the target service port used to connect with the second device; then generate a target connection code according to the target information, and the target connection code corresponds to multiple Connection information: sending the target connection code to the second device, determining the target information from multiple connection information corresponding to the target connection code in a retry manner, and establishing a connection with the second device according to the target information.
  • This application is based on the idea of exchanging time for space. By using one connection code to correspond to multiple connection information, the number of digits of the connection code is shortened by retrying to reduce the extra space occupied, thereby solving the problem of the input length of the pure digital connection code when the device is connected. It is too long, and the connection code with mixed numbers and letters is inconvenient to input technical problems.
  • FIG. 1 is a schematic flowchart of a device connection method according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for generating a connection code according to an embodiment of the present application
  • Fig. 3 is a schematic structural diagram of a device connection device according to an embodiment of the present application.
  • an embodiment of a device connection method is provided. It should be noted that the steps shown in the flow chart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and, although A logical order is shown in the flowcharts, but in some cases the steps shown or described may be performed in an order different from that shown or described herein.
  • Fig. 1 is a device connection method according to an embodiment of the present application. As shown in Fig. 1, the method includes the following steps:
  • Step S102 acquiring target information of the first device in the target LAN, wherein the target information includes the IP address of the first device and the sequence number of the target service port used to connect with the second device in the target LAN.
  • all available service ports of the first device may be numbered first, and then the serial number of the target service port used to connect with the second device is determined, and at the same time, the number of the service port of the first device is determined An IP address, using the IP address and the serial number of the target service port as the target information of the first device.
  • the target information also includes a target check code generated by the first device, the target check code is a number randomly generated by the first device within a preset value range, and the specific value range can be defined by the user. Such as 0-15.
  • the target verification code will be dynamically refreshed over time, that is, the first device will generate a new target verification code after a fixed period of time, so as to ensure the security of the 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 includes an IP address and a service port serial number, and the plurality of connection information includes the target information.
  • the target connection code is generated according to the target information, so the plurality of connection information corresponding to the target connection code must include the target information.
  • each connection information corresponding to the target connection code also includes a check code.
  • the process of generating the target connection code according to the target information is as follows, which includes steps S1040-S1048:
  • Step S1040 generating a binary first code according to the serial number of the target service port.
  • the value range, wherein, the second value range is the value range of the first code.
  • the first device has 4 available service ports, which are numbered 0, 1, 2, and 3 respectively, and the first value range is 0-3, which is divided into 2 segments on average to obtain the second value
  • the range is 0-1, and the generated first code will take a value within 0-1; assuming that the serial number of the target service port is 1, which is within the second value range of 0-1, then the binary first code will be generated directly based on 1
  • 1 in the first code can correspond to multiple service port serial numbers, which can indicate that the service port serial number is 1 or 3, and the specific meaning needs to be determined by retrying when connecting.
  • the first code that originally needs 2 bits (0-3 corresponds to binary 00-11) can be shortened to 1 bit (0-1 corresponds to binary 0-1) for representation.
  • the first code may not be generated, that is, the target information does not include the target service port serial number, and when the device is connected, it is directly and sequentially tried to communicate with multiple available service ports of the first device. connect.
  • Step S1042 generating a binary second code according to the target check code.
  • the value range is used as the fourth value range, wherein the fourth value range is the value range of the second encoding.
  • the target check code is in the fourth value range; if the target check code is in the fourth value range, then generate the second code according to the target check code; if the target check code is not in the fourth value range , then determine the second target value corresponding to the target check code in the fourth value range, and generate the second code according to the second target value.
  • the generated second code will take a value within 0-3; assuming that the target check code is 2, it is in If the fourth value range is 0-3, then the first binary code generated directly based on 2 is 10; assuming that the target check code is 6, which is not in the fourth value range 0-3, you need to determine its corresponding
  • the second code that originally required 4 bits (0-15 corresponds to binary 0000-1111) can be shortened to 3 bits (0-7 corresponds to binary 000-111) or even 2 bits (0-3 corresponds to binary 00-11) to express.
  • Step S1044 generating a third binary code according to the IP address of the first device.
  • IP address type of the first device can be determined first, where the IP address type includes a class A address, a class B address and Class C addresses, Class A addresses range from 10.0.0.0 to 10.255.255.255, Class B addresses range from 172.16.0.0 to 172.31.255.255, and Class C addresses range from 192.168.0.0 to 192.168.255.255. Contains four bytes.
  • the fifth value range of the byte determines the fifth value range into the value range of the third preset number of segments on average, divide the smallest segment
  • the value range is taken as the sixth value range; judge whether the value of the byte is within the sixth value range; if the value of the byte is within the sixth value range, generate the section corresponding to the sub-code; if the value of the byte is not within the sixth value range, then determine the third target value corresponding to the value of the byte in the sixth value range, and generate the corresponding sub-code according to the third target value Section corresponding to the sub-code; finally, according to the sub-code corresponding to each byte of the IP address of the first device, determine the third code, usually, the sub-code corresponding to the four bytes of the IP address of the first device combination to obtain the third code.
  • the determined fifth value range can be different, and the number of segments that can be equally divided into the fifth value range can also be different. If it is divided into one segment, it means directly Generate a binary subcode from the value of this byte.
  • the IP address type of the first device is a Class B address
  • the value range of the second byte is 16-31
  • 0-31 can be used as the fifth value range, divide it into 2 segments on average, and get the sixth value range of 0-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, determine its corresponding
  • the IP address is usually divided into areas from the front, 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, therefore, when determining the For the sub-code corresponding to the section, the fifth value range of the first two bytes can be divided into 2 segments on average, and the sub-code can be determined according to the above process; the fifth value range of the last two bytes can be divided into 1 segment on average , that is, generate a sub-code directly based on the value of the byte.
  • the first byte (that is, the flag) of a class A IP address is fixed at 10
  • the first byte of a class B IP address is fixed at 172
  • the first two bytes of a class C IP address The byte is fixed at 192.168. Therefore, when the IP address type of the first device is a class A address or a class B address, the subcodes corresponding to the last three bytes of the IP address of the first device are combined to obtain the third Encoding: when the IP address type of the first device is a Class C address, combining sub-codes corresponding to the last two bytes of the IP address of the first device to obtain a third code. When performing device connection, it is sufficient to directly determine the flag bit of the IP address by retrying.
  • the IP address of the first device is 192.168.126.128, which is a Class C address
  • the third code is 11111100000000.
  • Step S1046 combining the first code, the second code and the third code to obtain a binary fourth code.
  • Step S1048 converting the fourth code from binary to decimal to obtain the target connection code.
  • the generated check code is 15, and the IP address is 10.255.255.255. If these information are directly represented by the real value when generating the connection code, you can get The first code is 11, the second code is 1111, the third code is 000010101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  • each value range is equally divided into two segments when using the above-mentioned target connection code generation process, and the first byte of the IP address is omitted, then the first code is 1 and the second code is 111 respectively. , and the third code is 11111111111111111111111111111111111111. Combine them to get the fourth code 1111111111111111111111111111111111111111111111111111. It can be seen that the number of bits of the target connection code obtained through the above process is greatly shortened, reducing the extra space occupied.
  • Step S106 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.
  • the target connection code is sent to the second device, and the second device parses the multiple connection information corresponding to the target connection code; the multiple connection information sent by the second device according to the multiple connection information is received Request, wherein each connection information corresponds to a connection request; determine whether the connection information corresponding to each connection request is the same as the target information, and establish a connection with the second device when the connection information is the same as the target information.
  • the second device will reversely analyze the multiple connection information corresponding to the target connection code according to the target connection code generation process, and send a A connection request, trying to establish a connection with the first device; each time the first device receives a connection request, it will compare the connection information corresponding to the connection request with its own target information, if the two are the same, that is, the connection information includes the first
  • a device uses the sequence number of the target service port for connecting with the second device, the target verification code generated by the first device, and the IP address of the first device, a connection is established with the second device.
  • the serial number of the target service port used by the first device to connect to the second device is 3, the generated check code is 15, and the IP address is 10.255.255.255. It generates a connection code 33554431 according to the above connection code generation process and sends it to second device.
  • the second device reversely parses the connection code according to the above connection code generation process, first converts it into binary 111111111111111111111, and determines that the first code corresponding to the service port number is 1, then it is considered that the service port number of the first device may be 1, possibly If the second code corresponding to the check code is 111, it is considered that the check code of the first device may be 7 or 15; if the third code corresponding to the IP address is 11111111111111111111, it is considered that the IP address of the first device is The second byte of the address may be 127, it may be 255; the third byte may be 127, it may be 255; the fourth byte may be 127, it may be 255; because the second byte does not meet the B and C type addresses, Then it is determined as a class A address, and the first byte is 10; combine the above information to obtain multiple connection information, such as the service port number is 1, the check code is 7, and the IP address is 10.127.127.127. Wherein, since the first
  • the second device generates a corresponding connection request to try to connect with the first device according to each connection information, and keeps retrying.
  • the first device receives a connection request, it will compare the connection information corresponding to the connection request with its own target information. If the two are different, it will continue to judge the next connection request.
  • the device establishes a connection.
  • first obtain the target information of the first device including the IP address and the serial number of the target service port used to connect with the second device; then generate a target connection code according to the target information, and the target connection code corresponds to multiple Connection information: sending the target connection code to the second device, determining the target information from multiple connection information corresponding to the target connection code in a retry manner, and establishing a connection with the second device according to the target information.
  • This application is based on the idea of exchanging time for space. By using one connection code to correspond to multiple connection information, the number of digits of the connection code is shortened by retrying to reduce the extra space occupied, thereby solving the problem of the input length of the pure digital connection code when the device is connected. It is too long, and the connection code with mixed numbers and letters is inconvenient to input technical problems.
  • an embodiment of a method for generating a connection code is also provided. It should be noted that the steps shown in the flow chart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and , although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in an order different from that shown or described herein.
  • Fig. 2 is a device connection method according to an embodiment of the present application. As shown in Fig. 2, the method includes the following steps:
  • Step S202 acquiring the target service port serial number, target verification code and IP address of the first device for connecting with the second device.
  • all available service ports of the first device can be numbered first, and then the sequence number of the target service port used to connect with the second device can be determined; determine the target service port generated by the first device Check code.
  • the target check code is a number randomly generated by the first device within the preset value range. The specific value range can be defined by the user, such as 0-15.
  • the target check code will be Time dynamic refresh, that is, the first device will generate a new target check code after a fixed period of time to ensure the security of the device connection; at the same time, determine the IP address of the first device.
  • Step S204 generating a binary first code according to the serial number of the target service port, the first code corresponds to a plurality of serial numbers of the service port, and the serial numbers of the multiple service ports include the serial number of the target service port.
  • first obtain the first value range of the available service port serial number of the first device divide the first value range into a first preset number of value ranges, and use the smallest value range as the second value range.
  • the value range wherein, the second value range is the value range of the first code.
  • judge whether the sequence number of the target service port is in the second value range if the sequence number of the target service port is in the second value range, then generate the first code according to the sequence number of the target service port; if the sequence number of the target service port If it is not within the second value range, determine the first target value corresponding to the serial number of the target service port in the second value range, and generate the first code according to the first target value.
  • Step S206 generating a binary second code according to the target check code, the second code corresponds to a plurality of check codes, and the multiple check codes include the target check code.
  • the fourth value range is the value range of the second encoding. After. Then judge whether the target check code is in the fourth value range; if the target check code is in the fourth value range, then generate the second code according to the target check code; if the target check code is not in the fourth value range , then determine the second target value corresponding to the target check code in the fourth value range, and generate the second code according to the second target value.
  • Step S208 generating a third binary code 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.
  • the IP address type of the first device can be determined first, and each type of IP address includes four bytes; for any byte of the IP address of the first device, determine the byte The fifth value range of the fifth value range, the fifth value range is divided into the value range of the third preset number of segments, and the smallest value range is used as the sixth value range; determine whether the value of the byte is in the first within the six value range; if the value of the byte is within the sixth value range, then generate the subcode corresponding to the byte according to the value of the byte; if the value of the byte is not within the sixth value range , then determine the third target value corresponding to the value of the byte in the sixth value range, and generate the subcode corresponding to the byte according to the third target value; finally, according to each byte of the IP address of the first device The corresponding subcode determines the third code. Usually, the subcodes corresponding to the four bytes of the IP address of the first device are combined to obtain
  • the fifth value range determined may be different, and the number of segments that the fifth value range is equally divided may also be different. Section values generate binary subcodes.
  • the first byte (that is, the flag) of a class A IP address is fixed at 10
  • the first byte of a class B IP address is fixed at 172
  • the first two bytes of a class C IP address The byte is fixed at 192.168. Therefore, when the IP address type of the first device is a class A address or a class B address, the subcodes corresponding to the last three bytes of the IP address of the first device are combined to obtain the third Encoding: when the IP address type of the first device is a Class C address, combining sub-codes corresponding to the last two bytes of the IP address of the first device to obtain a third code. When performing device connection, it is sufficient to directly determine the flag bit of the IP address by retrying.
  • Step S210 combining the first code, the second code and the third code to obtain a binary fourth code.
  • Step S212 converting the fourth code from binary to decimal to obtain the target connection code.
  • the target service port serial number, target verification code and IP address used for connecting with the second device in the first device by obtaining the target service port serial number, target verification code and IP address used for connecting with the second device in the first device, and generating the first code according to the target service port serial number respectively, according to the target verification code
  • the code is verified to generate the second code
  • the third code is generated according to the IP address of the first device, wherein the number of digits of the code is shortened by making each code correspond to a plurality of information, thereby shortening the length of the target connection code obtained by the final combination, reducing The additional space is occupied, thereby solving the technical problems that the input length of the pure digital connection code is too long when the device is connected, and the input of the connection code mixed with numbers and letters is inconvenient.
  • the device includes an acquisition module 30, a generation module 32 and a connection module 34, wherein:
  • the acquiring module 30 is configured to acquire target information of the first device in the target LAN, wherein the target information includes the IP address of the first device and the sequence number of the target service port used to connect with the second device in the target LAN.
  • the generating module 32 is configured to generate a target connection code according to the target information, wherein the target connection code corresponds to a plurality of connection information, each connection information includes an IP address and a service port serial number, and the plurality of connection information includes 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.
  • each module in the device connection device in the embodiment of this application corresponds to the implementation steps of the device connection method in embodiment 1. Since the detailed description has been made in embodiment 1, some of the modules in this embodiment For details not shown, reference may be made to Embodiment 1, and details are not repeated here.
  • non-volatile storage medium includes a stored program, wherein, when the program is running, the device where the non-volatile storage medium is located is controlled to perform the above-mentioned device connection method or connection code generation method.
  • the device where the non-volatile storage medium is located is controlled to perform the following steps: Obtain the target information of the first device in the target local area network, wherein the target information includes the IP address of the first device and the IP address used to communicate with the target The sequence number of the target service port that the second device in the local area network connects to; generate the target connection code according to the target information, wherein, the target connection code corresponds to multiple connection information, and each connection information includes an IP address and a service port sequence number.
  • the connection information includes target information; the target connection code is sent to the second device, and a connection is established with the second device according to the target information corresponding to the target connection code.
  • the device where the non-volatile storage medium is located is controlled to perform the following steps: obtain the target service port serial number, target check code and IP address used in the first device to connect to the second device;
  • the target service port serial number generates a binary first code, and the first code corresponds to multiple service port serial numbers, and the multiple service port serial numbers include the target service port serial number; generates a binary second code according to the target check code, and the second code corresponds to multiple service port serial numbers.
  • a check code the multiple check codes include the target check code; generate a binary third code according to the IP address of the first device, the third code corresponds to multiple IP addresses, and the multiple IP addresses include the first device's IP address; combining the first code, the second code and the third code to obtain a binary fourth code; converting the fourth code from binary to decimal to obtain a target connection code.
  • the disclosed technical content can be realized in other ways.
  • the device embodiments described above are only illustrative.
  • the division of units can be a logical function division.
  • multiple units or components can be combined or integrated into Another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of units or modules may be in electrical or other forms.
  • a unit described as a separate component may or may not be physically separated, and a component shown as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed over multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disc, etc., which can store program codes. .

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

本申请公开了一种设备连接方法、装置及连接码生成方法。其中,设备连接方法包括:获取目标局域网中第一设备的目标信息,其中,目标信息中包括第一设备的IP地址以及用于与目标局域网中的第二设备进行连接的目标服务端口的序号;依据目标信息生成目标连接码,其中,目标连接码对应多个连接信息,每个连接信息中包括一个IP地址及一个服务端口序号,多个连接信息中包括目标信息;将目标连接码发送至第二设备,并依据目标连接码对应的目标信息与第二设备建立连接。本申请通过用一个连接码对应多个连接信息来缩短连接码长度,解决了设备连接时纯数字连接码输入长度过长,数字字母混合的连接码输入不便的技术问题。

Description

设备连接方法、装置及连接码生成方法 技术领域
本申请涉及通信技术领域,具体而言,涉及一种设备连接方法、装置及连接码生成方法。
背景技术
互联网中的每个设备都对应有一个IP地址,要实现两台设备的连接,就需要知道对方的IP地址并访问特定服务的端口。而连接码的作用就是将IP地址以及端口序号编码成可识别的连续符号(包括数字、字母等),这样一台设备就可以将自身信息便捷地展示给另一台设备,从而将两台设备进行连接。
相关技术中,连接码一般有纯数字以及数字字母混合两种形式,纯数字的连接码通常长度较长,较为浪费编码空间;而数字字母混合的连接码虽然长度稍短,但会提高连接码的输入难度,二者均不利于用户的使用体验。
针对上述的问题,目前尚未提出有效的解决方案。
发明内容
本申请实施例提供了一种设备连接方法、装置及连接码生成方法,以至少解决设备连接时纯数字连接码输入长度过长,数字字母混合的连接码输入不便的技术问题。
根据本申请实施例的一个方面,提供了一种设备连接方法,包括:获取目标局域网中第一设备的目标信息,其中,所述目标信息中包括所述第一设备的IP地址以及用于与所述目标局域网中的第二设备进行连接的目标服务端口的序号;依据所述目标信息生成目标连接码,其中,所述目标连接码对应多个连接信息,每个所述连接信息中包括一个IP地址及一个服务端口序号,所述多个连接信息中包括所述目标信息;将所述目标连接码发送至所述第二设备,并依据所述目标连接码对应的所述目标信息与所述第二设备建立连接。
可选地,所述目标信息中还包括所述第一设备生成的目标校验码,每个所述连接信息中还包括一个校验码。
可选地,依据所述目标服务端口的序号生成二进制的第一编码;依据所述目标校验码生成二进制的第二编码;依据所述第一设备的IP地址生成二进制的 第三编码;将所述第一编码、第二编码及第三编码进行组合,得到二进制的第四编码;将所述第四编码由二进制转化为十进制,得到所述目标连接码。
可选地,获取所述第一设备的可用服务端口序号的第一取值范围,将所述第一取值范围平均分为第一预设数量段取值范围,将其中最小的一段取值范围作为第二取值范围,其中,所述第二取值范围为所述第一编码的取值范围;判断所述目标服务端口的序号是否在所述第二取值范围内;若所述目标服务端口的序号在所述第二取值范围内,则依据所述目标服务端口的序号生成所述第一编码;若所述目标服务端口的序号不在所述第二取值范围内,则确定所述第二取值范围中与所述目标服务端口的序号对应的第一目标值,依据所述第一目标值生成所述第一编码。
可选地,获取所述第一设备的可用校验码的第三取值范围,将所述第三取值范围平均分为第二预设数量段取值范围,将其中最小的一段取值范围作为第四取值范围,其中,所述第四取值范围为所述第二编码的取值范围;判断所述目标校验码是否在所述第四取值范围内;若所述目标校验码在所述第四取值范围内,则依据所述目标校验码生成所述第二编码;若所述目标校验码不在所述第四取值范围内,则确定所述第四取值范围中与所述目标校验码对应的第二目标值,依据所述第二目标值生成所述第二编码。
可选地,确定所述第一设备的IP地址类型,其中,IP地址类型包括A类地址,B类地址和C类地址,A类地址范围为10.0.0.0至10.255.255.255,B类地址范围为172.16.0.0至172.31.255.255,C类地址范围为192.168.0.0至192.168.255.255。
可选地,对所述第一设备的IP地址的任意一个字节,确定所述字节的第五取值范围,将所述第五取值范围平均分为第三预设数量段取值范围,将其中最小的一段取值范围作为第六取值范围;判断所述字节的值是否在所述第六取值范围内;若所述字节的值在所述第六取值范围内,则依据所述字节的值生成与所述字节对应的子编码;若所述字节的值不在所述第六取值范围内,则确定所述第六取值范围中与所述字节的值对应的第三目标值,依据所述第三目标值生成与所述字节对应的子编码;依据所述第一设备的IP地址的各个字节所对应的子编码,确定所述第三编码。
可选地,将所述第一设备的IP地址的四个字节所对应的子编码进行组合,得到所述第三编码;或,在所述第一设备的IP地址类型为A类地址或B类地址 时,将所述第一设备的IP地址的后三个字节所对应的子编码进行组合,得到所述第三编码;在所述第一设备的IP地址类型为C类地址时,将所述第一设备的IP地址的后两个字节所对应的子编码进行组合,得到所述第三编码。
可选地,将所述目标连接码发送至所述第二设备,由所述第二设备解析所述目标连接码对应的所述多个连接信息;接收所述第二设备依据所述多个连接信息发送的多个连接请求,其中,每个所述连接信息对应一个所述连接请求;确定每个所述连接请求所对应的连接信息是否与所述目标信息相同,在所述连接信息与所述目标信息相同时与所述第二设备建立连接。
根据本申请实施例的另一方面,还提供了一种连接码生成方法,包括:获取第一设备中用于与第二设备进行连接的目标服务端口序号、目标校验码及IP地址;依据所述目标服务端口序号生成二进制的第一编码,所述第一编码对应多个服务端口序号,所述多个服务端口序号中包括所述目标服务端口序号;依据所述目标校验码生成二进制的第二编码,所述第二编码对应多个校验码,所述多个校验码中包括所述目标校验码;依据所述第一设备的IP地址生成二进制的第三编码,所述第三编码对应多个IP地址,所述多个IP地址中包括所述第一设备的IP地址;将所述第一编码、第二编码及第三编码进行组合,得到二进制的第四编码;将所述第四编码由二进制转化为十进制,得到目标连接码。
根据本申请实施例的另一方面,还提供了一种设备连接装置,包括:获取模块,用于获取目标局域网中第一设备的目标信息,其中,所述目标信息中包括所述第一设备的IP地址以及用于与所述目标局域网中的第二设备进行连接的目标服务端口的序号;生成模块,用于依据所述目标信息生成目标连接码,其中,所述目标连接码对应多个连接信息,每个所述连接信息中包括一个IP地址及一个服务端口序号,所述多个连接信息中包括所述目标信息;连接模块,用于将所述目标连接码发送至所述第二设备,并依据所述目标连接码对应的所述目标信息与所述第二设备建立连接。
根据本申请实施例的另一方面,还提供了一种非易失性存储介质,所述非易失性存储介质包括存储的程序,其中,在所述程序运行时控制所述非易失性存储介质所在设备执行上述的设备连接方法或连接码生成方法。
在本申请实施例中,首先获取第一设备的目标信息,包括IP地址以及用于与第二设备进行连接的目标服务端口的序号;然后依据目标信息生成目标连接码,目标连接码对应多个连接信息;将目标连接码发送至第二设备,采用重试 的方式从目标连接码对应的多个连接信息中确定出目标信息,依据目标信息与第二设备建立连接。本申请基于时间换空间的思想,通过用一个连接码对应多个连接信息,以重试的方式来缩短连接码的位数,减少额外空间占用,从而解决了设备连接时纯数字连接码输入长度过长,数字字母混合的连接码输入不便技术问题。
附图说明
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:
图1是根据本申请实施例的一种设备连接方法的流程示意图;
图2是根据本申请实施例的一种连接码生成方法的流程示意图;
图3是根据本申请实施例的一种设备连接装置的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
实施例1
根据本申请实施例,提供了一种设备连接方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中 执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
图1是根据本申请实施例的设备连接方法,如图1所示,该方法包括如下步骤:
步骤S102,获取目标局域网中第一设备的目标信息,其中,目标信息中包括第一设备的IP地址以及用于与目标局域网中的第二设备进行连接的目标服务端口的序号。
在本申请一些可选的实施例中,可以先对第一设备的所有可用服务端口进行编号,然后确定其中用于与第二设备进行连接的目标服务端口的序号,同时,确定第一设备的IP地址,将该IP地址与目标服务端口的序号作为第一设备的目标信息。
可选地,目标信息中还包括第一设备生成的目标校验码,该目标校验码为第一设备在预设的取值范围内随机生成的数字,具体取值范围可由用户进行定义,如0-15。在本申请一些可选的实施例中,目标校验码会随时间动态刷新,即第一设备会每隔一个固定的时间段后生成新的目标校验码,以保证设备连接的安全性。
步骤S104,依据目标信息生成目标连接码,其中,目标连接码对应多个连接信息,每个连接信息中包括一个IP地址及一个服务端口序号,多个连接信息中包括目标信息。
可以理解地,目标连接码是依据目标信息生成,因此目标连接码对应的多个连接信息中必然包括目标信息。其中,在目标信息中包括目标校验码时,目标连接码所对应的每个连接信息中还包括一个校验码。
在本申请一些可选的实施例中,依据目标信息生成目标连接码的过程如下,其包括步骤S1040-S1048:
步骤S1040,依据目标服务端口的序号生成二进制的第一编码。
具体地,先获取第一设备的可用服务端口序号的第一取值范围,将第一取值范围平均分为第一预设数量段取值范围,将其中最小的一段取值范围作为第二取值范围,其中,第二取值范围为第一编码的取值范围。
之后,再判断目标服务端口的序号是否在第二取值范围内;若目标服务端口的序号在第二取值范围内,则依据目标服务端口的序号生成第一编码;若目标服务端口的序号不在第二取值范围内,则确定第二取值范围中与目标服务端 口的序号对应的第一目标值,依据第一目标值生成第一编码。
例如,第一设备的可用服务端口有4个,分别将其编号为0、1、2、3,则第一取值范围为0-3,将其平均分为2段,得到第二取值范围为0-1,生成的第一编码将在0-1内取值;假设目标服务端口的序号为1,其在第二取值范围0-1内,则直接依据1生成二进制的第一编码为1;假设目标服务端口的序号为3,其不在第二取值范围0-1内,则需要先确定其对应的第一目标值为3-2=1(2表示第二取值范围中包括2个数),之后依据1生成二进制的第一编码为1。
可以发现,第一编码的1可对应多个服务端口序号,其既可以表示服务端口序号为1,也可以表示服务端口序号为3,具体的含义需要在连接时采用重试的方式确定。通过上述过程,就可以将原本需要2bit(0-3对应二进制00-11)的第一编码缩短为1bit(0-1对应二进制0-1)来表示。
在本申请一些可选的实施例中,还可以不生成第一编码,即目标信息中不包括目标服务端口序号,在进行设备连接时,直接依次与第一设备的多个可用服务端口尝试进行连接。
步骤S1042,依据目标校验码生成二进制的第二编码。
与生成第一编码的过程类似,先获取第一设备的可用校验码的第三取值范围,将第三取值范围平均分为第二预设数量段取值范围,将其中最小的一段取值范围作为第四取值范围,其中,第四取值范围为第二编码的取值范围。
之后。再判断目标校验码是否在第四取值范围内;若目标校验码在第四取值范围内,则依据目标校验码生成第二编码;若目标校验码不在第四取值范围内,则确定第四取值范围中与目标校验码对应的第二目标值,依据第二目标值生成第二编码。
例如,用户预设可用校验码的第三取值范围为0-15,将其平均分为2段,得到第四取值范围0-7,生成的第二编码将在0-7内取值;假设目标校验码为6,其在第四取值范围0-7内,则直接依据6生成二进制的第一编码为110;假设目标校验码为13,其不在第四取值范围0-7内,则需要先确定其对应的第二目标值为13-8=5(8表示第二取值范围中包括2个数),之后依据5生成二进制的第一编码为101。
若将第三取值范围0-15平均分为4段,得到第四取值范围0-3,生成的第二编码将在0-3内取值;假设目标校验码为2,其在第四取值范围0-3内,则直接依据2生成二进制的第一编码为10;假设目标校验码为6,其不在第四取值范 围0-3内,则需要先确定其对应的第二目标值为6-4=2(4表示第二取值范围中包括4个数),之后依据2生成二进制的第一编码为10;假设目标校验码为13,其不在第四取值范围0-3内,则需要先确定其对应的第二目标值为13-4-4-4=1,之后依据1生成二进制的第一编码为1。
通过上述过程,就可以将原本需要4bit(0-15对应二进制0000-1111)的第二编码缩短为3bit(0-7对应二进制000-111)甚至2bit(0-3对应二进制00-11)来表示。
步骤S1044,依据第一设备的IP地址生成二进制的第三编码。
在本申请一些可选的实施例中,可以对不同类型的IP地址采用不同的编码策略,因此可以先确定第一设备的IP地址类型,其中,IP地址类型包括A类地址,B类地址和C类地址,A类地址范围为10.0.0.0至10.255.255.255,B类地址范围为172.16.0.0至172.31.255.255,C类地址范围为192.168.0.0至192.168.255.255,其中,每类IP地址均包括四个字节。
之后,对第一设备的IP地址的任意一个字节,确定该字节的第五取值范围,将第五取值范围平均分为第三预设数量段取值范围,将其中最小的一段取值范围作为第六取值范围;判断该字节的值是否在第六取值范围内;若该字节的值在第六取值范围内,则依据该字节的值生成与该字节对应的子编码;若该字节的值不在第六取值范围内,则确定第六取值范围中与该字节的值对应的第三目标值,依据第三目标值生成与该字节对应的子编码;最后,依据第一设备的IP地址的各个字节所对应的子编码,确定第三编码,通常,将第一设备的IP地址的四个字节所对应的子编码进行组合,得到第三编码。
例如,第一设备的IP地址为192.168.126.128,则可以对每一字节均进行如下处理:确定第五取值范围为0-255,将其平均分为2段,得到第六取值范围为0-127;第一字节192不在第六取值范围0-127内,则确定其对应的第三目标值为192-128=64,之后依据64生成二进制的子编码为1000000;第二字节168不在第六取值范围0-127内,则确定其对应的第三目标值为168-128=40,之后依据40生成二进制的子编码为0101000;第三字节126在第六取值范围0-127内,则直接依据126生成二进制的子编码为1111110;第四字节128不在第六取值范围0-127内,则确定其对应的第三目标值为128-128=0,之后依据0生成二进制的子编码为0000000;最终,将四个字节对应的子编码组合,即得到28bit的第三编码1000000010100011111100000000,比原先的32bit缩短了4bit。
需要说明的是,对第一设备的IP地址的不同字节,所确定的第五取值范围可以不同,将第五取值范围平均划分的段数也可以不同,若划分为一段,即表示直接依据该字节的值生成二进制的子编码。
例如,第一设备的IP地址类型为B类地址时,由于第二字节的取值范围为16-31,因此,对第二字节进行处理时,可以将0-31作为第五取值范围,将其平均分为2段,得到第六取值范围为0-15;假设第一设备的IP地址为172.31.255.255,由于31不在第八取值范围0-15内,则确定其对应的第四目标值为31-16=15,之后依据15生成二进制的子编码为1111,其位数仅4bit。
由于IP地址通常从前段分区域,例如10.xx.xx.xx可能分为10.0.xx.xx-10.2.xx.xx和10.12.xx.xx-10.16.xx.xx,因此,在确定各字节对应的子编码时,可以将前两个字节的第五取值范围平均分为2段,按上述过程确定子编码;将后两个字节的第五取值范围平均分为1段,即直接依据字节的值生成子编码。
在本申请一些可选的实施例中,由于A类IP地址的第一字节(即标志位)固定为10,B类IP地址的第一字节固定为172,C类IP地址的前两字节固定为192.168,因此,在第一设备的IP地址类型为A类地址或B类地址时,将第一设备的IP地址的后三个字节所对应的子编码进行组合,得到第三编码;在第一设备的IP地址类型为C类地址时,将第一设备的IP地址的后两个字节所对应的子编码进行组合,得到第三编码。在进行设备连接时,直接采用重试的方式确定IP地址的标志位即可。
例如,第一设备的IP地址为192.168.126.128,为C类地址,则只需将其第三字节对应的子编码1111110和第四字节对应的子编码0000000进行组合,得到该IP地址对应的第三编码为11111100000000。
步骤S1046,将第一编码、第二编码及第三编码进行组合,得到二进制的第四编码。
步骤S1048,将第四编码由二进制转化为十进制,得到目标连接码。
假设第一设备用于与第二设备连接的目标服务端口序号为3,生成的校验码为15,IP地址为10.255.255.255,如果在生成连接码时直接用真实值表示这些信息,则得到的第一编码为11,第二编码为1111,第三编码为00001010111111111111111111111111,将其组合得到第四编码11111100001010111111111111111111111111共38bit,转化为十进制的目标连接码为270767489023,其位数为12bit。若在采用上述的目标连接码生成过程处理 时,确定每个取值范围均平均分为两段,且IP地址的第一字节省略,则分别得到第一编码为1,第二编码为111,第三编码为111111111111111111111,将其组合得到第四编码1111111111111111111111111共25bit,转化为十进制的目标连接码为33554431,其位数仅为8bit。可以看出,通过上述过程得到的目标连接码的位数被大大缩短,减少了额外的空间占用。
步骤S106,将目标连接码发送至第二设备,并依据目标连接码对应的目标信息与第二设备建立连接。
在本申请一些可选的实施例中,将目标连接码发送至第二设备,由第二设备解析目标连接码对应的多个连接信息;接收第二设备依据多个连接信息发送的多个连接请求,其中,每个连接信息对应一个连接请求;确定每个连接请求所对应的连接信息是否与目标信息相同,在连接信息与目标信息相同时与第二设备建立连接。
具体地,将目标连接码发送至第二设备后,第二设备会依据目标连接码生成过程反向解析该目标连接码对应的多个连接信息,并依据每个连接信息向第一设备发送一个连接请求,尝试与第一设备建立连接;第一设备每接收到一个连接请求后,会将该连接请求对应的连接信息与自身的目标信息进行比较,若二者相同,即连接信息中包括第一设备用于与第二设备进行连接的目标服务端口的序号、第一设备生成的目标校验码以及第一设备的IP地址时,则与第二设备建立连接。
例如,第一设备用于与第二设备连接的目标服务端口序号为3,生成的校验码为15,IP地址为10.255.255.255,其依据上述连接码生成过程生成连接码33554431,并发送给第二设备。第二设备依据上述连接码生成过程反向解析该连接码,首先将其转化为二进制1111111111111111111111111,确定服务端口序号对应的第一编码为1,则认为第一设备的服务端口序号可能为1,可能为3;确定校验码对应的第二编码为111,即认为第一设备的校验码可能为7,可能为15;确定IP地址对应的第三编码为111111111111111111111,则认为第一设备的IP地址第二字节可能为127,可能为255;第三字节可能为127,可能为255;第四字节可能为127,可能为255;由于第二字节不满足B、C类地址,则确定为A类地址,第一字节为10;将上述信息进行组合,即得到多个连接信息,如服务端口序号为1,校验码为7,IP地址为10.127.127.127。其中,由于第一设备与第二设备运行在同一局域网中,第二设备在解析IP地址的第一字节时,可 以优先考虑与自身IP地址的第一字节相同的字节。
第二设备依据每个连接信息生成一个对应的连接请求与第一设备尝试进行连接,并不断进行重试。第一设备每接收到一个连接请求后,会将该连接请求对应的连接信息与自身的目标信息进行比较,若二者不同,则继续判断下一个连接请求,若二者相同,则与第二设备建立连接。
在本申请实施例中,首先获取第一设备的目标信息,包括IP地址以及用于与第二设备进行连接的目标服务端口的序号;然后依据目标信息生成目标连接码,目标连接码对应多个连接信息;将目标连接码发送至第二设备,采用重试的方式从目标连接码对应的多个连接信息中确定出目标信息,依据目标信息与第二设备建立连接。本申请基于时间换空间的思想,通过用一个连接码对应多个连接信息,以重试的方式来缩短连接码的位数,减少额外空间占用,从而解决了设备连接时纯数字连接码输入长度过长,数字字母混合的连接码输入不便技术问题。
实施例2
根据本申请实施例,还提供了一种连接码生成方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
图2是根据本申请实施例的设备连接方法,如图2所示,该方法包括如下步骤:
步骤S202,获取第一设备中用于与第二设备进行连接的目标服务端口序号、目标校验码及IP地址。
在本申请一些可选的实施例中,可以先对第一设备的所有可用服务端口进行编号,然后确定其中用于与第二设备进行连接的目标服务端口的序号;确定第一设备生成的目标校验码,该目标校验码为第一设备在预设的取值范围内随机生成的数字,具体取值范围可由用户进行定义,如0-15,可选地,目标校验码会随时间动态刷新,即第一设备会每隔一个固定的时间段后生成新的目标校验码,以保证设备连接的安全性;同时,确定第一设备的IP地址。
步骤S204,依据目标服务端口序号生成二进制的第一编码,第一编码对应多个服务端口序号,多个服务端口序号中包括目标服务端口序号。
具体地,先获取第一设备的可用服务端口序号的第一取值范围,将第一取 值范围平均分为第一预设数量段取值范围,将其中最小的一段取值范围作为第二取值范围,其中,第二取值范围为第一编码的取值范围。之后,再判断目标服务端口的序号是否在第二取值范围内;若目标服务端口的序号在第二取值范围内,则依据目标服务端口的序号生成第一编码;若目标服务端口的序号不在第二取值范围内,则确定第二取值范围中与目标服务端口的序号对应的第一目标值,依据第一目标值生成第一编码。
步骤S206,依据目标校验码生成二进制的第二编码,第二编码对应多个校验码,多个校验码中包括目标校验码。
具体地,先获取第一设备的可用校验码的第三取值范围,将第三取值范围平均分为第二预设数量段取值范围,将其中最小的一段取值范围作为第四取值范围,其中,第四取值范围为第二编码的取值范围。之后。再判断目标校验码是否在第四取值范围内;若目标校验码在第四取值范围内,则依据目标校验码生成第二编码;若目标校验码不在第四取值范围内,则确定第四取值范围中与目标校验码对应的第二目标值,依据第二目标值生成第二编码。
步骤S208,依据第一设备的IP地址生成二进制的第三编码,第三编码对应多个IP地址,多个IP地址中包括第一设备的IP地址。
在本申请一些可选的实施例中,可以先确定第一设备的IP地址类型,每类IP地址均包括四个字节;对第一设备的IP地址的任意一个字节,确定该字节的第五取值范围,将第五取值范围平均分为第三预设数量段取值范围,将其中最小的一段取值范围作为第六取值范围;判断该字节的值是否在第六取值范围内;若该字节的值在第六取值范围内,则依据该字节的值生成与该字节对应的子编码;若该字节的值不在第六取值范围内,则确定第六取值范围中与该字节的值对应的第三目标值,依据第三目标值生成与该字节对应的子编码;最后,依据第一设备的IP地址的各个字节所对应的子编码,确定第三编码,通常,将第一设备的IP地址的四个字节所对应的子编码进行组合,得到第三编码。
其中,对第一设备的IP地址的不同字节,所确定的第五取值范围可以不同,将第五取值范围平均划分的段数也可以不同,若划分为一段,即表示直接依据该字节的值生成二进制的子编码。
在本申请一些可选的实施例中,由于A类IP地址的第一字节(即标志位)固定为10,B类IP地址的第一字节固定为172,C类IP地址的前两字节固定为192.168,因此,在第一设备的IP地址类型为A类地址或B类地址时,将第一 设备的IP地址的后三个字节所对应的子编码进行组合,得到第三编码;在第一设备的IP地址类型为C类地址时,将第一设备的IP地址的后两个字节所对应的子编码进行组合,得到第三编码。在进行设备连接时,直接采用重试的方式确定IP地址的标志位即可。
步骤S210,将第一编码、第二编码及第三编码进行组合,得到二进制的第四编码。
步骤S212,将第四编码由二进制转化为十进制,得到目标连接码。
在本申请实施例中,通过获取第一设备中用于与第二设备进行连接的目标服务端口序号、目标校验码及IP地址,并分别依据目标服务端口序号生成第一编码,依据目标校验码生成第二编码,依据第一设备的IP地址生成第三编码,其中,通过让每个编码对应多个信息来缩短编码的位数,从而缩短最终组合得到的目标连接码的长度,减少额外空间占用,进而解决了设备连接时纯数字连接码输入长度过长,数字字母混合的连接码输入不便技术问题。
实施例3
根据本申请实施例,还提供了一种用于实现上述设备连接方法的设备连接装置,如图3所示,该装置包括获取模块30,生成模块32以及连接模块34,其中:
获取模块30,用于获取目标局域网中第一设备的目标信息,其中,目标信息中包括第一设备的IP地址以及用于与目标局域网中的第二设备进行连接的目标服务端口的序号。
生成模块32,用于依据目标信息生成目标连接码,其中,目标连接码对应多个连接信息,每个连接信息中包括一个IP地址及一个服务端口序号,多个连接信息中包括目标信息。
连接模块34,用于将目标连接码发送至第二设备,并依据目标连接码对应的目标信息与第二设备建立连接。
需要说明的是,本申请实施例中的设备连接装置中的各模块与实施例1中的设备连接方法实施步骤一一对应,由于实施例1中已经进行了详尽的描述,本实施例中部分未体现的细节可以参考实施例1,在此不再过多赘述。
实施例4
根据本申请实施例,还提供了一种非易失性存储介质,该非易失性存储介质包括存储的程序,其中,在程序运行时控制非易失性存储介质所在设备执行 上述的设备连接方法或连接码生成方法。
可选地,在程序运行时控制非易失性存储介质所在设备执行实现以下步骤:获取目标局域网中第一设备的目标信息,其中,目标信息中包括第一设备的IP地址以及用于与目标局域网中的第二设备进行连接的目标服务端口的序号;依据目标信息生成目标连接码,其中,目标连接码对应多个连接信息,每个连接信息中包括一个IP地址及一个服务端口序号,多个连接信息中包括目标信息;将目标连接码发送至第二设备,并依据目标连接码对应的目标信息与第二设备建立连接。
可选地,在程序运行时控制非易失性存储介质所在设备执行实现以下步骤:获取第一设备中用于与第二设备进行连接的目标服务端口序号、目标校验码及IP地址;依据目标服务端口序号生成二进制的第一编码,第一编码对应多个服务端口序号,多个服务端口序号中包括目标服务端口序号;依据目标校验码生成二进制的第二编码,第二编码对应多个校验码,多个校验码中包括目标校验码;依据第一设备的IP地址生成二进制的第三编码,第三编码对应多个IP地址,多个IP地址中包括第一设备的IP地址;将第一编码、第二编码及第三编码进行组合,得到二进制的第四编码;将第四编码由二进制转化为十进制,得到目标连接码。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
以上仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。

Claims (12)

  1. 一种设备连接方法,其特征在于,包括:
    获取目标局域网中第一设备的目标信息,其中,所述目标信息中至少包括所述第一设备的IP地址以及用于与所述目标局域网中的第二设备进行连接的目标服务端口的序号;
    依据所述目标信息生成目标连接码,其中,所述目标连接码对应多个连接信息,每个所述连接信息中包括一个IP地址及一个服务端口序号,所述多个连接信息中包括所述目标信息;
    将所述目标连接码发送至所述第二设备,并依据所述目标连接码对应的所述目标信息与所述第二设备建立连接。
  2. 根据权利要求1所述的方法,其特征在于,所述目标信息中还包括所述第一设备生成的目标校验码,每个所述连接信息中还包括一个校验码。
  3. 根据权利要求2所述的方法,其特征在于,依据所述目标信息生成目标连接码,包括:
    依据所述目标服务端口的序号生成二进制的第一编码;
    依据所述目标校验码生成二进制的第二编码;
    依据所述第一设备的IP地址生成二进制的第三编码;
    将所述第一编码、第二编码及第三编码进行组合,得到二进制的第四编码;
    将所述第四编码由二进制转化为十进制,得到所述目标连接码。
  4. 根据权利要求3所述的方法,其特征在于,依据所述目标服务端口的序号生成二进制的第一编码,包括:
    获取所述第一设备的可用服务端口序号的第一取值范围,将所述第一取值范围平均分为第一预设数量段取值范围,将其中最小的一段取值范围作为第二取值范围,其中,所述第二取值范围为所述第一编码的取值范围;
    判断所述目标服务端口的序号是否在所述第二取值范围内;
    若所述目标服务端口的序号在所述第二取值范围内,则依据所述目标服务端口的序号生成所述第一编码;
    若所述目标服务端口的序号不在所述第二取值范围内,则确定所述第二取值范围中与所述目标服务端口的序号对应的第一目标值,依据所述第一目标值生成所述第一编码。
  5. 根据权利要求3所述的方法,其特征在于,依据所述目标校验码生成二进制的第二编码,包括:
    获取所述第一设备的可用校验码的第三取值范围,将所述第三取值范围平均分为第二预设数量段取值范围,将其中最小的一段取值范围作为第四取值范围,其中,所述第四取值范围为所述第二编码的取值范围;
    判断所述目标校验码是否在所述第四取值范围内;
    若所述目标校验码在所述第四取值范围内,则依据所述目标校验码生成所述第二编码;
    若所述目标校验码不在所述第四取值范围内,则确定所述第四取值范围中与所述目标校验码对应的第二目标值,依据所述第二目标值生成所述第二编码。
  6. 根据权利要求3所述的方法,其特征在于,依据所述第一设备的IP地址生成二进制的第三编码前,所述方法还包括:
    确定所述第一设备的IP地址类型,其中,IP地址类型包括A类地址,B类地址和C类地址,A类地址范围为10.0.0.0至10.255.255.255,B类地址范围为172.16.0.0至172.31.255.255,C类地址范围为192.168.0.0至192.168.255.255。
  7. 根据权利要求6所述的方法,其特征在于,依据所述第一设备的IP地址生成二进制的第三编码,包括:
    对所述第一设备的IP地址的任意一个字节,确定所述字节的第五取值范围,将所述第五取值范围平均分为第三预设数量段取值范围,将其中最小的一段取值范围作为第六取值范围;
    判断所述字节的值是否在所述第六取值范围内;若所述字节的值在所述第六取值范围内,则依据所述字节的值生成与所述字节对应的子编码;若所述字节的值不在所述第六取值范围内,则确定所述第六取值范围中与所述字节的值对应的第三目标值,依据所述第三目标值生成与所述字节对应的子编码;
    依据所述第一设备的IP地址的各个字节所对应的子编码,确定所述第三编码。
  8. 根据权利要求7所述的方法,其特征在于,依据所述第一设备的IP地址的各个字节所对应的子编码,确定所述第三编码,包括:
    将所述第一设备的IP地址的四个字节所对应的子编码进行组合,得到所述第三编码;或,
    在所述第一设备的IP地址类型为A类地址或B类地址时,将所述第一设备的IP地址的后三个字节所对应的子编码进行组合,得到所述第三编码;在所述第一设备的IP地址类型为C类地址时,将所述第一设备的IP地址的后两个字 节所对应的子编码进行组合,得到所述第三编码。
  9. 根据权利要求1所述的方法,其特征在于,将所述目标连接码发送至所述第二设备,并依据所述目标连接码对应的所述目标信息与所述第二设备建立连接,包括:
    将所述目标连接码发送至所述第二设备,由所述第二设备解析所述目标连接码对应的所述多个连接信息;
    接收所述第二设备依据所述多个连接信息发送的多个连接请求,其中,每个所述连接信息对应一个所述连接请求;
    确定每个所述连接请求所对应的连接信息是否与所述目标信息相同,在所述连接信息与所述目标信息相同时与所述第二设备建立连接。
  10. 一种连接码生成方法,其特征在于,包括:
    获取第一设备中用于与第二设备进行连接的目标服务端口序号、目标校验码及IP地址;
    依据所述目标服务端口序号生成二进制的第一编码,所述第一编码对应多个服务端口序号,所述多个服务端口序号中包括所述目标服务端口序号;
    依据所述目标校验码生成二进制的第二编码,所述第二编码对应多个校验码,所述多个校验码中包括所述目标校验码;
    依据所述第一设备的IP地址生成二进制的第三编码,所述第三编码对应多个IP地址,所述多个IP地址中包括所述第一设备的IP地址;
    将所述第一编码、第二编码及第三编码进行组合,得到二进制的第四编码;
    将所述第四编码由二进制转化为十进制,得到目标连接码。
  11. 一种设备连接装置,其特征在于,包括:
    获取模块,用于获取目标局域网中第一设备的目标信息,其中,所述目标信息中包括所述第一设备的IP地址以及用于与所述目标局域网中的第二设备进行连接的目标服务端口的序号;
    生成模块,用于依据所述目标信息生成目标连接码,其中,所述目标连接码对应多个连接信息,每个所述连接信息中包括一个IP地址及一个服务端口序号,所述多个连接信息中包括所述目标信息;
    连接模块,用于将所述目标连接码发送至所述第二设备,并依据所述目标连接码对应的所述目标信息与所述第二设备建立连接。
  12. 一种非易失性存储介质,其特征在于,所述非易失性存储介质包括存储 的程序,其中,在所述程序运行时控制所述非易失性存储介质所在设备执行权利要求1至9中任意一项所述的设备连接方法。
PCT/CN2022/092987 2021-05-26 2022-05-16 设备连接方法、装置及连接码生成方法 WO2022247669A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110579393.6A CN115412267A (zh) 2021-05-26 2021-05-26 设备连接方法、装置及连接码生成方法
CN202110579393.6 2021-05-26

Publications (1)

Publication Number Publication Date
WO2022247669A1 true WO2022247669A1 (zh) 2022-12-01

Family

ID=84156571

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/092987 WO2022247669A1 (zh) 2021-05-26 2022-05-16 设备连接方法、装置及连接码生成方法

Country Status (2)

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

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102017515A (zh) * 2008-04-25 2011-04-13 智能技术Ulc公司 用于协调在网络中与至少一个物理显示装置的数据共享的方法和系统
US20160248761A1 (en) * 2015-02-24 2016-08-25 Wowza Media Systems, LLC Token-based security for remote resources
CN107566453A (zh) * 2017-08-03 2018-01-09 广州视源电子科技股份有限公司 服务发现方法、装置、计算机可读存储介质和计算机设备
CN108848162A (zh) * 2018-06-15 2018-11-20 广州视源电子科技股份有限公司 显示设备的连接方法、显示设备及系统
CN108848164A (zh) * 2018-06-15 2018-11-20 广州视源电子科技股份有限公司 显示设备的连接方法、显示设备及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102017515A (zh) * 2008-04-25 2011-04-13 智能技术Ulc公司 用于协调在网络中与至少一个物理显示装置的数据共享的方法和系统
US20160248761A1 (en) * 2015-02-24 2016-08-25 Wowza Media Systems, LLC Token-based security for remote resources
CN107566453A (zh) * 2017-08-03 2018-01-09 广州视源电子科技股份有限公司 服务发现方法、装置、计算机可读存储介质和计算机设备
CN108848162A (zh) * 2018-06-15 2018-11-20 广州视源电子科技股份有限公司 显示设备的连接方法、显示设备及系统
CN108848164A (zh) * 2018-06-15 2018-11-20 广州视源电子科技股份有限公司 显示设备的连接方法、显示设备及系统

Also Published As

Publication number Publication date
CN115412267A (zh) 2022-11-29

Similar Documents

Publication Publication Date Title
CN109246129B (zh) 一种可验证客户端身份的sm2协同签名方法及系统
US5651069A (en) Software-efficient message authentication
USRE37178E1 (en) Method and apparatus for authentication of client server communication
WO2021057326A1 (zh) 数据编码方法、解码方法、编解码方法、设备及存储介质
CN111832067B (zh) 一种数据处理方法、装置和用于数据处理的装置
CN109474838B (zh) 一种数据处理方法、设备、系统及存储介质
CN110134889B (zh) 短链接生成方法、装置及服务器
KR20060063820A (ko) 프로세스 과정에서 암호화된 데이터의 위조 검출 데이터를발생시키는 장치 및 방법
CN108124202A (zh) 一种使流媒体服务器支持hls协议的方法
WO2021051941A1 (zh) 一种信息处理方法及装置
CN1921682A (zh) 增强通用鉴权框架中的密钥协商方法
US7990292B2 (en) Method for transmission of a digital message from a display to a handheld receiver
WO2022247669A1 (zh) 设备连接方法、装置及连接码生成方法
TW201228248A (en) Dynamic decoding lookup table generation method and electronic device applying the same
WO2005076522A1 (en) Methods for generating identification values for identifying electronic messages
CN111953497B (zh) 一种基于hmac算法的消息认证码生成装置及方法
CN110351289B (zh) 数据加密的方法及装置
CN112711683A (zh) 数据比对方法、装置及计算机设备
CN110913351B (zh) 组播控制方法、装置、网络设备及存储介质
CN110458566B (zh) 一种区块链的账户地址生成方法、系统、装置及计算机可读存储介质
JP2009169316A (ja) ハッシュ関数演算装置及び署名装置及びプログラム及びハッシュ関数演算方法
CN110266478B (zh) 一种信息处理方法、电子设备
CN109246385B (zh) 用于多方会议的通信方法及会议系统
CN109120740B (zh) 生成IPv6地址的服务器、系统及方法
CN115033544A (zh) 一种基于关系数值的数据压缩方法、装置、设备和介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22810396

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22810396

Country of ref document: EP

Kind code of ref document: A1