A method and apparatus for generating and decoding a local area network interconnection code.

By simply shifting and summing the IP address, a short six-digit digital LAN interconnection code is generated, which solves the problem of inconvenient input of the screen projection code composed of letters, and achieves a faster and more convenient LAN connection.

CN116155854BActive Publication Date: 2025-03-25IGRS ENG LAB(SHENZHEN) LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310158161.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-20
Publication Date
2025-03-25
Estimated Expiration
2043-02-20

AI Technical Summary

Technical Problem

In the prior art, the screen projection code is composed of letters, and the input is inconvenient, which affects the speed and convenience of LAN connection.

Method used

By performing left shifting, summing and other calculations on the IP address, a short six-digit LAN interconnection code is generated to reduce the input complexity. The specific steps include obtaining the IP address, calculating the intermediate variable, recursively calculating the network verification code, and finally generating a six-digit LAN Internet code.

Benefits of technology

It simplifies the complexity of LAN connection input information, allowing users to connect to LAN more conveniently and quickly, and is suitable for LAN mobile phone screen projection and file transfer applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116155854B_ABST
    Figure CN116155854B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating a local area network interconnection code, and a decoding method and device. The method for generating a local area network interconnection code comprises the following steps: obtaining the IP address of the sending end; shifting the first byte of the IP address of the sending end left by 8 bits and summing it with the second byte to obtain an intermediate variable; recursively calculating the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sending end network check code; shifting the sending end network check code left by 16 bits, and summing it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain a six-digit local area network interconnection code. The present invention uses a short six-digit number to replace a twelve-digit IP address by performing simple shifting, summing and other calculations on the IP address, thereby reducing the complexity of the local area network connection input information, and the user can connect to the local area network more conveniently and quickly, and can be applied to local area network mobile phone screen projection and local area network file transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of wireless interconnection of local area networks, and in particular to a method and device for generating a local area network interconnection code, and a method and device for decoding a local area network interconnection code. Background Art

[0002] With the continuous development of electronic technology, wireless screen transmission or projection technology has gradually become one of the indispensable technologies for people's study and work. At present, during the screen transmission or projection process, the receiving terminal generates a connection code, and the sending terminal connects to the receiving terminal by inputting the connection code. However, the current Internet Protocol Version 4 (IPv4) is in the form of 12-bit characters, which has a large number of characters. Manual input is not convenient when a connection needs to be established, which affects the connection speed between devices during the screen transmission or projection process.

[0003] To this end, Chinese invention patent CN111355820A discloses a data transmission method, terminal and electronic device, which transcodes the IP address of the receiving terminal according to a preset mapping relationship, converts the IP address containing 12 numeric characters into an 8-bit connection code, reduces the number of characters, shortens the time for manually inputting the connection code, and makes the connection faster during screen projection or screen transmission. However, in this scheme, the mapping relationship is constructed in the order of 0-25 and AZ, and the screen projection code consists of letters, which is inconvenient to input.

[0004] In view of this, it is necessary to improve the existing LAN interconnection code generation method, use short numbers instead of IP addresses or complex projection codes, and reduce the complexity of LAN connection input information. Summary of the invention

[0005] In view of the above-mentioned defects, the technical problem to be solved by the present invention is to provide a method, device and medium for generating a local area network interconnection code, so as to solve the problem that the projection code in the prior art is composed of letters and is inconvenient to input.

[0006] To this end, the present invention provides a method for generating a local area network interconnection code, comprising the following steps:

[0007] Get the IP address of the sender;

[0008] Shift the first byte of the IP address of the sender left by 8 bits and sum it with the second byte to obtain an intermediate variable;

[0009] Recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sending end network check code, wherein the recursive end condition is that the recursive result is <= 9;

[0010] Shift the sender's network check code left by 16 bits, and sum it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain the six-digit LAN interconnection code.

[0011] In the above method, preferably, the IP address is in a dotted decimal format abcd composed of a first byte a, a second byte b, a third byte c and a fourth byte d.

[0012] In the above method, preferably, the maximum value of the LAN interconnection code is 655359.

[0013] In the above method, preferably, the intermediate variable is obtained by the following steps:

[0014] Convert the first byte a from decimal to binary;

[0015] Shift the first binary byte left by 8 bits and then convert it to decimal;

[0016] Add the decimal value to the second byte b to obtain a decimal intermediate variable.

[0017] In the above method, preferably, the network check code of the sending end is obtained by recursive calculation, and the specific steps are as follows:

[0018] Step 301, calculate the sum of each digit of the intermediate variable to obtain the current recursive result;

[0019] Step 302, determine whether the current recursive result meets the recursive end condition;

[0020] Step 303, if the recursion end condition is met, the current recursion result is used as the sending end network verification code; otherwise, if the recursion end condition is not met, the sum of each digit of the current recursion result is calculated again, and then go to step 302.

[0021] The present invention also provides a device for generating a local area network interconnection code, comprising:

[0022] The receiving module is used to obtain the IP address of the sender;

[0023] An intermediate variable calculation module, used for shifting the first byte of the IP address of the sender left by 8 bits and summing it with the second byte to obtain an intermediate variable;

[0024] The network check code calculation module recursively calculates the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sending end network check code, and the recursive end condition is that the recursive result is less than or equal to 9;

[0025] The screen projection code generation module is used to shift the sending end network verification code left by 16 bits, and sum it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain a six-digit local area network interconnection code.

[0026] The present invention also provides a method for decoding a local area network interconnection code, which is applied to a receiving end and is used to decode a local area network interconnection code generated by the above-mentioned method for generating a local area network interconnection code, and comprises the following steps:

[0027] Get the LAN interconnection code of the sender;

[0028] Shift the LAN interconnection code of the sender right by 16 bits to obtain the LAN check code of the sender;

[0029] Get the IP address of the receiving end;

[0030] Shift the first byte of the receiving end's IP address left by 8 bits and sum it with the second byte to obtain an intermediate variable;

[0031] Recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end LAN check code, wherein the recursive end condition is that the recursive result <= 9;

[0032] Determine whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If they are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN. On the contrary, if they are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end.

[0033] Shift the receiving end LAN check code right by 16 bits, subtract the result from the sending end LAN interconnection code, and then shift the result left by 8 bits to get the third byte of the sending end IP address;

[0034] Shift the receiving end LAN check code right by 16 bits, shift the third byte of the receiving end IP address right by 16 bits, subtract the sum of the two from the sending end LAN interconnection code, and obtain the fourth byte of the sending end IP address;

[0035] The first byte and the second byte of the receiving end are combined with the calculated third byte and the fourth byte of the sending end IP address to obtain the sending end IP address.

[0036] In the above decoding method, preferably, the IP address of the sender and the IP address of the receiver are both in dotted decimal format abcd composed of the first byte a, the second byte b, the third byte c and the fourth byte d.

[0037] In the above decoding method, preferably, the maximum value of the local area network interconnection code is 655359.

[0038] The present invention also provides a decoding device for a local area network interconnection code, which is installed at a receiving end and comprises:

[0039] A first acquisition module is used to acquire a local area network interconnection code of a sending end;

[0040] The LAN check code calculation module shifts the LAN interconnection code of the sending end right by 16 bits to obtain the LAN check code of the sending end;

[0041] The second acquisition module is used to obtain the IP address of the receiving end;

[0042] An intermediate variable calculation module is used to shift the first byte of the IP address of the receiving end left by 8 bits and sum it with the second byte to obtain an intermediate variable;

[0043] The network check code calculation module recursively calculates the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end local area network check code, and the recursive end condition is that the recursive result is less than or equal to 9;

[0044] The judgment module is used to judge whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If the two are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN; on the contrary, if the two are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end;

[0045] The third byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, then subtract the result from the sending end LAN interconnection code, and then left-shift the result by 8 bits to obtain the third byte of the sending end IP address;

[0046] The fourth byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, right-shift the third byte of the receiving end IP address by 16 bits, and subtract the sum of the two from the sending end LAN interconnection code to obtain the fourth byte of the sending end IP address;

[0047] The combining module is used to combine the first byte and the second byte of the receiving end with the third byte and the fourth byte of the calculated IP address of the sending end to obtain the IP address of the sending end.

[0048] It can be seen from the above technical solutions that the method and device for generating and decoding a LAN interconnection code provided by the present invention solves the problem that the LAN interconnection code (screen projection code) in the prior art is composed of letters and is inconvenient to input. Compared with the prior art, the present invention has the following beneficial effects:

[0049] By performing simple calculations such as shifting and summing the IP address, a twelve - bit IP address is replaced with a short six - digit number, reducing the complexity of the input information for LAN connection. Users can connect to the LAN more conveniently and quickly, and it can be applied to functions such as mobile screen mirroring on the LAN and file transfer on the LAN. Brief Description of the Drawings

[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce and explain the drawings required for the description of the embodiments of the present invention or the prior art. Obviously, the drawings described below are only partial embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0051] Figure 1 Flowchart of a method for generating a LAN interconnection code provided by the present invention;

[0052] Figure 2 Flowchart of a method for decoding a LAN interconnection code provided by the present invention. Detailed Embodiments

[0053] The following will clearly and completely describe the technical solutions of the embodiments of the present invention in conjunction with the drawings of the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0054] To make a clearer explanation and illustration of the technical solutions and implementation methods of the present invention, the following introduces several preferred specific embodiments for implementing the technical solutions of the present invention.

[0055] It should be noted that the orientation terms such as "inside, outside", "front, back", and "left, right" in this article are expressed based on the product's usage state as the reference object. Obviously, the use of the corresponding orientation terms does not limit the protection scope of this solution.

[0056] In the present invention, the left - shift and right - shift algorithms are applied, where:

[0057] p<<q represents shifting the number p to the left by q bits. Usually, the number p is mostly represented in decimal. Therefore, during specific calculations, the number p is first converted to binary, and after the shift, it is converted back to decimal. For example: 10<<8 represents shifting the number 10 to the left by 8 bits. The specific algorithm is: first convert the number 10 to binary 1010, then shift it to the left by 8 bits to become 101000000000, and then convert it back to decimal, which is 2560. Therefore, 10<<8 = 2560.

[0058] The right shift algorithm is similar to the left shift algorithm and will not be described here.

[0059] See also Figure 1 , Figure 1 A flow chart of a method for generating a local area network interconnection code provided by the present invention.

[0060] like Figure 1 As shown, a method for generating a local area network interconnection code provided by the present invention is applied to a sending end and comprises the following steps:

[0061] Step 110, obtaining the IP address of the sender.

[0062] Usually, the IP address adopts the IPV4 address, which consists of four bytes, the first byte a, the second byte b, the third byte c and the fourth byte d, in dotted decimal format abcd. For example, in a specific application example, the sender IP = 192.168.10.100, then the first byte a = 192, the second byte b = 168, the third byte c = 10, and the fourth byte d = 100.

[0063] Step 120, shift the first byte a of the IP address of the sender left by 8 bits, and sum it with the second byte b to obtain an intermediate variable x. That is, the intermediate variable x=a<<8+b.

[0064] Specifically, the intermediate variable x can be obtained by the following steps:

[0065] Convert the first byte a from decimal to binary;

[0066] Shift the first binary byte a left by 8 bits and then convert it to decimal;

[0067] The decimal first byte after shifting is summed with the decimal second byte b to obtain a decimal intermediate variable x.

[0068] In the above specific application example, the intermediate variable x=192<<8+168=49152+168=49320.

[0069] Step 130, recursively calculate the sum of each digit of the intermediate variable x until the recursive end condition is met to obtain the sending end network check code M1, and the recursive end condition is that the current recursive result is <= 9.

[0070] The specific steps are as follows:

[0071] Step 301, calculate the sum of each digit of the intermediate variable x to obtain the current recursive result;

[0072] Step 302, determine whether the current recursive result meets the recursive end condition;

[0073] Step 303, if the recursion end condition is met, the current recursion result is used as the sending end network verification code; otherwise, if the recursion end condition is not met, the sum of each digit of the current recursion result is calculated again, and then go to step 302.

[0074] For the above specific application example, x=49320, first calculate the sum of each digit of the intermediate variable x, and obtain the first recursive result D1=4+9+3+2+0=18. Since the first recursive result D1=18>9, the recursive end condition is not met, then recursively calculate the sum of each digit of the first recursive result D1 again, and obtain the second recursive result D2=1+8=9. At this time, the second recursive result D2 meets the recursive end condition, and the sending end network check code M1=D2=9.

[0075] Step 140, shift the sending end network verification code M1 left by 16 bits, and sum it with the result of shifting the third byte c left by 8 bits and the fourth byte d to obtain a six-digit LAN interconnection code N. The LAN interconnection code N can be used as a screen projection code and applied to LAN mobile phone screen projection, LAN file transfer, etc.

[0076] The six-digit LAN interconnection code N corresponds to a 4-byte twelve-digit IP address, wherein the maximum value of the LAN interconnection code N = 9<<16+255<<8+255=655359. That is, the LAN interconnection code N = M1<<16+c<<8+d, and the maximum value of N is 655359.

[0077] For the above specific application example, N=M1<<16+c<<8+d=9<<16+10<<8+100=589824+2560+100=592484.

[0078] Therefore, the LAN interconnection code N of the sender's IP address 192.168.10.100 is 592484.

[0079] Based on the above-mentioned method for generating a local area network interconnection code, the present invention also provides a device for generating a local area network interconnection code, comprising:

[0080] The receiving module is used to obtain the IP address of the sender;

[0081] An intermediate variable calculation module, used for shifting the first byte of the IP address of the sender left by 8 bits and summing it with the second byte to obtain an intermediate variable;

[0082] The network check code calculation module recursively calculates the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sender network check code. The recursive end condition is that the current recursive result <= 9;

[0083] The screen projection code generation module is used to shift the sending end network verification code left by 16 bits, and sum it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain a six-digit local area network interconnection code.

[0084] In the above-mentioned device for generating the local area network interconnection code, the working mode of each module is consistent with the above-mentioned method for generating the local area network interconnection code, and will not be repeated here.

[0085] The present invention also provides a decoding method for a local area network interconnection code, which is applied to a receiving end and is used to decode a local area network interconnection code generated by the above-mentioned method for generating a local area network interconnection code, such as Figure 2 As shown, the following steps are included:

[0086] Step 210, obtaining the local area network interconnection code N generated by the sending end. For example, in the above specific example, the local area network interconnection code N generated by the sending end is 592484.

[0087] Step 220, right-shift the LAN interconnection code N generated by the sending end by 16 bits to obtain the sending end LAN check code M1, that is, the sending end LAN check code M1 = N>>16.

[0088] For the above specific application example, M1=N>>16=592484>>16=9.

[0089] Step 230, obtaining the IP address of the receiving end.

[0090] For example: the IP address IP1 of the first receiving end is 10.1.50.12, and the IP address IP2 of the second receiving end is 192.168.12.23.

[0091] Step 240, shift the first byte in the IP address of the receiving end left by 8 bits and sum it with the second byte to obtain an intermediate variable.

[0092] For the above specific application example, the intermediate variable x1 of the first receiving end is 10<<8+1=2560+1=2561;

[0093] The intermediate variable x2 of the second receiving end is 192<<8+168=49152+168=49320.

[0094] Step 250, recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end LAN check code, and the recursive end condition is that the recursive result <= 9.

[0095] Wherein, the receiving end LAN check code M2 ​​of the first receiving end is 5;

[0096] The specific algorithm is: 2+5+6+1=14, 1+4=5.

[0097] The receiving end LAN verification code M3 of the second receiving end is 9.

[0098] Step 260, determine whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If they are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN; conversely, if they are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end.

[0099] For the above specific application examples,

[0100] The receiving end LAN verification code M2=5 of the first receiving end is different from the LAN verification code M1=9 of the sending end, indicating that the first receiving end and the sending end are not in the same LAN and the two cannot communicate via the LAN.

[0101] The receiving end LAN verification code M3 of the second receiving end is 9, which is the same as the sending end LAN verification code M1=9, indicating that the second receiving end and the sending end are in the same LAN, and the first byte a and the second byte b of the sending end's IP address are the same as the first byte a2 and the second byte b2 of the receiving end's IP address. Therefore, the first byte a in the sending end's IP address is 192, and the second byte b is 168.

[0102] Step 270, right-shift the receiving end LAN check code M3 by 16 bits, subtract the result from the sending end LAN interconnection code N, and left-shift the result by 8 bits to obtain the third byte c of the sending end IP address. That is, the third byte c of the sending end IP address = (N-(M3<<16))>>8.

[0103] In the above specific application example, the third byte of the IP address of the sender is c=(592484-(9<<16))>>8=(592484-589824)>>8=2660>>8=10.

[0104] Step 280, right-shift the receiving end LAN check code M3 by 16 bits, right-shift the third byte c2 of the receiving end IP address by 16 bits, and subtract the sum of the two from the sending end LAN interconnection code N to obtain the fourth byte of the receiving end IP address. That is, the fourth byte d = N-(M3<<16)-(c2<<8).

[0105] In the above specific application example, d=592484-(9<<16))-(10<<8)=592484-589824-2560=100.

[0106] Step 290, combining the first byte and the second byte of the receiving end with the calculated third byte and fourth byte of the sending end IP address to obtain the sending end IP address.

[0107] In the above specific application example, the IP address of the sender obtained by decoding is 192.168.10.100, which is the same as the real IP address of the sender.

[0108] Based on the above LAN interconnection code generation and decoding method, the receiving end can decode the input six-digit LAN interconnection code to obtain the IP address of the sending end, thereby establishing a LAN connection with the sending end.

[0109] Based on the above-mentioned method for decoding the local area network interconnection code, the present invention also provides a decoding device for the local area network interconnection code, which is installed at the receiving end and includes:

[0110] A first acquisition module is used to acquire a local area network interconnection code of a sending end;

[0111] The LAN check code calculation module is used to right-shift the LAN interconnection code of the sending end by 16 bits to obtain the LAN check code of the sending end;

[0112] The second acquisition module is used to obtain the IP address of the receiving end;

[0113] An intermediate variable calculation module is used to shift the first byte of the IP address of the receiving end left by 8 bits and sum it with the second byte to obtain an intermediate variable;

[0114] The network check code calculation module is used to recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end LAN check code. Among them, the recursive end condition is that the recursive result <= 9;

[0115] The judgment module is used to judge whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If the two are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN; on the contrary, if the two are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end;

[0116] The third byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, then subtract the result from the sending end LAN interconnection code, and then left-shift the result by 8 bits to obtain the third byte of the sending end IP address;

[0117] The fourth byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, right-shift the third byte of the receiving end IP address by 16 bits, and subtract the sum of the two from the sending end LAN interconnection code to obtain the fourth byte of the sending end receiving end IP address;

[0118] The combining module is used to combine the first byte and the second byte of the receiving end with the third byte and the fourth byte of the calculated IP address of the sending end to obtain the IP address of the sending end.

[0119] Based on the description of the above specific embodiments, the method and device for generating the local area network interconnection code, and the method and device for decoding the local area network interconnection code provided by the present invention have the following advantages compared with the prior art:

[0120] First, the twelve-digit IP address is converted into a short six-digit number, which reduces the complexity of entering information for LAN connection and allows users to connect to the LAN more conveniently and quickly.

[0121] Second, the algorithm uses simple shifting, summing and other calculations. The algorithm is simple, easy to implement, and has fast generation and decoding speeds.

[0122] Finally, it should be noted that the terms "comprises", "includes" or any other variants thereof as used herein are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0123] The present invention is not limited to the above-mentioned optimal implementation mode. Anyone should be aware that any structural changes made under the inspiration of the present invention, and any technical solutions that are the same or similar to the present invention, fall within the protection scope of the present invention.

Claims

1. A method for generating a local area network interconnection code, characterized in that: The following steps are involved: Get the IP address of the sender; Shift the first byte of the IP address of the sender left by 8 bits and sum it with the second byte to obtain an intermediate variable; Recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sending end network check code, wherein the recursive end condition is that the recursive result is <= 9; Shift the sender network check code left by 16 bits, and sum it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain a six-digit LAN interconnection code; The IP address is in dotted decimal format abcd composed of the first byte a, the second byte b, the third byte c and the fourth byte d; The intermediate variables are obtained by the following steps: Convert the first byte from decimal to binary; Shift the first binary byte left by 8 bits and then convert it to decimal; Add it to the second byte of the decimal system to get the decimal intermediate variable; Recursively calculate the sender network check code. The specific steps are as follows: Step 301, calculate the sum of each digit of the intermediate variable to obtain the current recursive result; Step 302, determine whether the current recursive result meets the recursive end condition; Step 303: If the recursion end condition is met, the current recursion result is used as the sending end network verification code; Otherwise, if the recursive end condition is not satisfied, the sum of each digit of the current recursive result is calculated again, and the process goes to step 302 .

2. The method according to claim 1, characterized in that The maximum value of the LAN interconnection code is 655359.

3. A device for generating a local area network interconnection code for implementing the generation method described in claim 1, characterized in that: include: The receiving module is used to obtain the IP address of the sender; An intermediate variable calculation module, used for shifting the first byte of the IP address of the sender left by 8 bits and summing it with the second byte to obtain an intermediate variable; The network check code calculation module recursively calculates the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the sending end network check code, and the recursive end condition is that the recursive result is less than or equal to 9; The screen projection code generation module is used to shift the sending end network verification code left by 16 bits, and sum it with the result of shifting the third byte left by 8 bits and the fourth byte to obtain a six-digit local area network interconnection code.

4. A method for decoding a local area network interconnection code, applied to a receiving end, for decoding a local area network interconnection code generated by the method for generating a local area network interconnection code according to claim 1, characterized in that: The following steps are involved: Get the LAN interconnection code of the sender; Shift the LAN interconnection code of the sender right by 16 bits to obtain the LAN check code of the sender; Get the IP address of the receiving end; Shift the first byte of the receiving end's IP address left by 8 bits and sum it with the second byte to obtain an intermediate variable; Recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end LAN check code, wherein the recursive end condition is that the recursive result <= 9; Determine whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If they are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN. On the contrary, if they are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end. Shift the receiving end LAN check code right by 16 bits, subtract the result from the sending end LAN interconnection code, and then shift the result left by 8 bits to get the third byte of the sending end IP address; Shift the receiving end LAN check code right by 16 bits, shift the third byte of the receiving end IP address right by 16 bits, subtract the sum of the two from the sending end LAN interconnection code, and obtain the fourth byte of the sending end IP address; The first byte and the second byte of the receiving end are combined with the calculated third byte and the fourth byte of the sending end IP address to obtain the sending end IP address.

5. The decoding method according to claim 4, characterized in that: The IP address of the sending end and the IP address of the receiving end are both in dotted decimal format abcd composed of the first byte a, the second byte b, the third byte c and the fourth byte d.

6. The method according to claim 4, characterized in that The maximum value of the LAN interconnection code is 655359.

7. A decoding device for a local area network interconnection code for implementing the decoding method of claim 4, installed at a receiving end, characterized in that: include: A first acquisition module is used to acquire a local area network interconnection code of a sending end; The LAN check code calculation module is used to right-shift the LAN interconnection code of the sending end by 16 bits to obtain the LAN check code of the sending end; The second acquisition module is used to obtain the IP address of the receiving end; An intermediate variable calculation module is used to shift the first byte of the IP address of the receiving end left by 8 bits and sum it with the second byte to obtain an intermediate variable; The network check code calculation module is used to recursively calculate the sum of each digit of the intermediate variable until the recursive end condition is met to obtain the receiving end local area network check code, and the recursive end condition is that the recursive result is less than or equal to 9; The judgment module is used to judge whether the LAN verification code of the receiving end is the same as the LAN verification code of the sending end. If the two are different, it means that the sending end and the receiving end are not in the same LAN and the two cannot communicate in the LAN; on the contrary, if the two are the same, the first byte and the second byte of the IP address of the sending end are the same as the first byte and the second byte of the IP address of the receiving end; The third byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, then subtract the result from the sending end LAN interconnection code, and then left-shift the result by 8 bits to obtain the third byte of the sending end IP address; The fourth byte calculation module is used to right-shift the receiving end LAN check code by 16 bits, right-shift the third byte of the receiving end IP address by 16 bits, and subtract the sum of the two from the sending end LAN interconnection code to obtain the fourth byte of the sending end IP address; The combining module is used to combine the first byte and the second byte of the receiving end with the third byte and the fourth byte of the calculated IP address of the sending end to obtain the IP address of the sending end.

Citation Information

Patent Citations

  • Data transmission method, terminal and electronic equipment

    CN111355820A