A secure data transmission method based on TCP / IP protocol

The TCP/IP protocol-based data transmission method addresses inefficiencies in multi-user web applications by using a JSON server and regular expressions to authenticate clients, improving network efficiency and reducing costs while ensuring secure communication.

CN110557380BActive Publication Date: 2024-12-10XINJIANG KERONG CLOUD DIGITAL TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201910726808.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-07
Publication Date
2024-12-10
Estimated Expiration
2039-08-07

AI Technical Summary

Technical Problem

Existing data acquisition methods in multi-user web applications using the B/S or C/S server structure are inefficient, scalable, and costly, leading to increased server load and operating costs, which affect the robustness and performance of the application.

Method used

A secure data transmission method based on the TCP/IP protocol that uses a JSON server to encapsulate data and employs regular expressions to distinguish packet headers and bodies, ensuring secure and efficient communication by adding a 32-bit UID for authentication, allowing clients to obtain database data in real time without login verification.

Benefits of technology

Improves network transmission efficiency, reduces operating costs, and ensures secure communication by authenticating valid clients, thereby enhancing the scalability and robustness of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110557380B_ABST
    Figure CN110557380B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of secure data transmission, and in particular to a secure data transmission method based on the TCP / IP protocol, comprising the following steps: establishing communication of the TCP / IP protocol between a server and a client; using a JSON server to send data to the server; the client obtains data from a database in real time, distinguishes a packet header and a data body of the sent data by using a regular expression, and then distinguishes various data in the packet header by using a regular expression to determine whether to perform a database operation. The present invention is used to obtain database data during network transmission based on the TCP / IP protocol, ensure reliable client links, prevent other applications from arbitrarily obtaining data, and also share the communication pressure of the main server, thereby improving efficient communication between the client and the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of secure data transmission, and in particular to a secure data transmission method based on TCP / IP protocol. Background Art

[0002] In the B / S or C / S server structure, data acquisition is a critical, limited and expensive resource, which is particularly prominent in multi-user web applications. Frequently obtaining database data through the server affects the scalability and robustness of the entire application and the performance indicators of the program. At the same time, it also adds too much load to the server, resulting in the need for better server hardware configuration and more bandwidth cost budget when building the server. This leads to a large increase in operating costs and reduced operating efficiency. In view of this, a secure data transmission method based on the TCP / IP protocol is provided to address the above problems. Summary of the invention

[0003] The purpose of the present invention is to provide a secure data transmission method based on the TCP / IP protocol. The method creates a new server based on the TCP / IP protocol for the client to obtain database data in real time, thereby ensuring secure and efficient communication between the user and the database, improving network transmission efficiency and reducing operating costs.

[0004] In order to achieve the above object, the present invention provides the following technical solutions:

[0005] A secure data transmission method based on TCP / IP protocol, comprising the following steps:

[0006] S1: Complete the TCP / IP protocol communication establishment between the server and the client;

[0007] S2: Use JSON server to send data to the server;

[0008] S3: The client obtains database data in real time, uses regular expressions to distinguish the packet header and data body of the sent data, and then uses regular expressions to distinguish various data in the packet header to determine whether to perform database operations.

[0009] Among them, in the step S1, the transmission process uses JSON format to encapsulate data; in the step S2, there are two ways to obtain data from the database, one is to directly send SQL statements to obtain, and the other is to obtain by sending command codes through negotiation.

[0010] The TCP / IP protocol between the server and the client in step S1 includes:

[0011] Each time a client logs in, the database generates a 32-bit UID in the user table and returns it to the client. The client saves the UID for subsequent data retrieval.

[0012] Wherein, in step S2, the JSON server sends data to the server to obtain database data, including the following steps:

[0013] S4: Create a Map table in the class. The primary key in the Map table is the client link sock value. The Map table is used to record the data sent by each link to determine whether it is a complete data.

[0014] S5: After a complete piece of data is sent, first use the regular expression to distinguish the packet header and the data body, and then use the regular expression to distinguish the various data in the packet header;

[0015] S6: In the step S5, every two data in the header data form a group, and a total of eight groups are included; the first group of header data is the transmission type and security UID, the second group of header data is the transmission data structure, the third group of header data is the data length, the fourth group of header data is the link mode, the fifth group of header data is the data compression mode, the sixth group of header data is the transmission encoding, the seventh group of header data is the user agent, and the eighth group of header data is the IP and port;

[0016] S7: Determine whether the length of the third group of header data matches the length of the data body. If they match, perform database operations. If they do not match, check whether there is data loss. If data loss occurs, it is judged as a failure and returned. If data loss does not occur, continue to determine whether the UID in the first group of header data is consistent with the UID in the database. If they are consistent, perform database operations. If they are inconsistent, it is judged as a failure and returns empty data.

[0017] Wherein, directly sending SQL statements to obtain data includes the following steps:

[0018] S8: receiving the client's link;

[0019] S9: parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S10.

[0020] S10: If the first set of data is "exec sql without result", the data body represents an SQL statement;

[0021] S11: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S12. If it is inconsistent, return empty data;

[0022] S12: Send data to the database for execution.

[0023] S13: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

[0024] The step of acquiring data by sending a command code through negotiation includes the following steps:

[0025] S14: receiving a link from a client;

[0026] S15: Parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S16.

[0027] S16: If the first set of data is "exec sql without result", the data body represents the command code;

[0028] S17: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S18. If it is inconsistent, return empty data;

[0029] S18: Sending a command code to the database;

[0030] S19: After receiving the command code, the database first parses the data, and then executes the relevant command according to the command code to obtain the desired data;

[0031] S20: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

[0032] The beneficial effects of the present invention are as follows: the present invention creates a TCP / IP protocol server for the client to obtain database data in real time, and uses the TCP / IP protocol as the basic communication architecture of the Internet; obtains database data by sending data to the server using a JSON server. JSON data is a lightweight data exchange format based on a subset of ECMAScript, and uses a text format that is completely independent of the programming language to store and represent data, which is convenient for people to read and write, and is also easy for machines to parse and generate, and effectively improves network transmission efficiency; after the client connects to the JSON server, it directly sends data to obtain database data, and does not require login verification, which can improve operating efficiency, eliminate some cumbersome processes, and reduce operating costs; at the same time, in order to prevent other invalid clients or attackers from obtaining database data, a secure UID is added when transmitting data to authenticate a valid client link, thereby ensuring secure and efficient communication between users and databases. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1A flowchart of a method for implementing secure data transmission based on TCP / IP protocol in the present invention;

[0034] Figure 2 A flowchart of establishing a TCP / IP protocol between a server and a client in the present invention;

[0035] Figure 3 A flow chart of the steps of using a JSON server to send data to a server in the present invention;

[0036] Figure 4 This is a flow chart of the method for acquiring data from the database in the present invention. DETAILED DESCRIPTION

[0037] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0038] Unless otherwise specified in the following implementation cases, the technical means used are conventional means well known to those skilled in the art.

[0039] A secure data transmission method based on TCP / IP protocol, comprising the following steps:

[0040] S1: Complete the TCP / IP protocol communication establishment between the server and the client;

[0041] S2: Use JSON server to send data to the server;

[0042] S3: The client obtains database data in real time, uses regular expressions to distinguish the packet header and data body of the sent data, and then uses regular expressions to distinguish various data in the packet header to determine whether to perform database operations.

[0043] In the step S1, the transmission process uses JSON format to encapsulate data; in the step S2, there are two ways to obtain data from the database, one is to directly send SQL statements to obtain, and the other is to send command codes through negotiation to obtain.

[0044] The present invention creates a TCP / IP protocol-based server, and the server is linked to a client through a network. The network is not limited to a wide area network, a metropolitan area network or a local area network, and the client is not limited to a mobile phone, a tablet computer and a PC client, etc. The method of the present invention can be jointly executed by a client and a TCP / IP protocol server, and the construction of the TCP / IP protocol is completed by using the library function of the server, for example, Active represents the communication establishment state, SendtoIP is the IP address of the client, recedata is the receiving data buffer, senddata is the sending data buffer, Send_number is the number of data sent this time, Recvnumber is the number of received data, and Send is a flag; the TCP / IP protocol is used as the basic communication architecture of the Internet, and is used for the client to obtain database data in real time.

[0045] The present invention obtains database data by using a JSON server to send data to a server. JSON data is a lightweight data exchange format based on a subset of ECMAScript (js specification developed by the European Computer Association). It uses a text format that is completely independent of the programming language to store and represent data, which is easy for people to read and write, and is also easy for machines to parse and generate, and effectively improves network transmission efficiency.

[0046] like Figure 1 As shown, the TCP / IP protocol between the server and the client in step S1 includes:

[0047] Each time a client logs in, the database generates a 32-bit UID in the user table and returns it to the client. The client saves the UID for subsequent data retrieval.

[0048] When the client obtains database data in real time, in order to prevent other invalid clients or attackers from obtaining database data, a security UID is added during data transmission to authenticate a valid client link, thereby ensuring secure and efficient communication between the user and the database.

[0049] like Figure 2 As shown, in step S2, the JSON server sends data to the server to obtain database data, including the following steps:

[0050] S4: Create a Map table in the class. The primary key in the Map table is the client link sock value. The Map table is used to record the data sent by each link to determine whether it is a complete data.

[0051] S5: After a complete piece of data is sent, first use the regular expression to distinguish the packet header and the data body, and then use the regular expression to distinguish the various data in the packet header;

[0052] S6: In the step S5, every two data in the header data form a group, and a total of eight groups are included; the first group of header data is the transmission type and security UID, the second group of header data is the transmission data structure, the third group of header data is the data length, the fourth group of header data is the link mode, the fifth group of header data is the data compression mode, the sixth group of header data is the transmission encoding, the seventh group of header data is the user agent, and the eighth group of header data is the IP and port;

[0053] S7: Determine whether the length of the third group of header data matches the length of the data body. If they match, perform database operations. If they do not match, check whether there is data loss. If data loss occurs, it is judged as a failure and returned. If data loss does not occur, continue to determine whether the UID in the first group of header data is consistent with the UID in the database. If they are consistent, perform database operations. If they are inconsistent, it is judged as a failure and returns empty data.

[0054] In the present invention, after the client connects to the JSON server, it directly sends data to obtain database data. The length of the data sent by the client is not fixed and may be sent in multiple packets. Therefore, a Map table is established in the class, and the primary key in the Map table is the client link sock value; the Map table is used to record the data sent by each link to determine whether it is a complete data. After a complete data is sent, it is determined whether to execute the database operation. This process does not require login verification, which can improve operating efficiency, remove some cumbersome processes, and reduce operating costs.

[0055] like Figure 3 As shown, directly sending SQL statements to obtain data includes the following steps:

[0056] S8: receiving the client's link;

[0057] S9: parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S10.

[0058] S10: If the first set of data is "exec sql without result", the data body represents an SQL statement;

[0059] S11: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S12. If it is inconsistent, return empty data;

[0060] S12: Send data to the database for execution.

[0061] S13: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

[0062] like Figure 3 As shown, the acquisition of data by sending a command code through negotiation includes the following steps:

[0063] S14: receiving a link from a client;

[0064] S15: Parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S16.

[0065] S16: If the first set of data is "exec sql without result", the data body represents the command code;

[0066] S17: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S18. If it is inconsistent, return empty data;

[0067] S18: Sending a command code to the database;

[0068] S19: After receiving the command code, the database first parses the data, and then executes the relevant command according to the command code to obtain the desired data;

[0069] S20: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

[0070] The present invention provides two data acquisition methods, one is to directly send SQL statements to acquire data, and the other is to send command codes through negotiation to acquire data, thereby ensuring a reliable visiting client connection.

[0071] The present invention is used to obtain database data during network transmission based on TCP / IP protocol, ensuring reliable client connection and preventing other applications from obtaining data at will; meanwhile, it can also share the communication pressure of the main server and improve the efficient communication between the client and the database.

[0072] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. All modifications, equivalent substitutions, improvements, etc. within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A secure data transmission method based on TCP / IP protocol, characterized in that: The following steps are involved: S1: Complete the TCP / IP protocol communication establishment between the server and the client; S2: Use JSON server to send data to the server. JSON is the format for storing and transmitting data. S3: The client obtains the database data in real time, uses regular expressions to distinguish the packet header and data body of the sent data, and then uses regular expressions to distinguish various data in the packet header to determine whether to perform database operations; In step S1, the transmission process uses JSON format to encapsulate data; in step S2, there are two ways to obtain data from the database, one is to directly send SQL statements to obtain, and the other is to send command codes through negotiation to obtain; The TCP / IP protocol between the server and the client in step S1 further includes the following contents: Each time a client logs in, the database generates a 32-bit UID in the user table and returns it to the client. The client saves the UID for subsequent data retrieval. In step S2, the JSON server sends data to the server to obtain database data, including the following steps: S4: Create a Map table in the class. The Map table is a data structure table. The primary key in the Map table is the client link sock value. The sock value is the communication with TCP / IP based on the client / server tool. The Map table is used to record the data sent from each link to determine whether it is a complete data. S5: After a complete piece of data is sent, first use the regular expression to distinguish the packet header and the data body, and then use the regular expression to distinguish the various data in the packet header; S6: In the step S5, every two data in the header data form a group, and a total of eight groups are included; the first group of header data is the transmission type and security UID, the second group of header data is the transmission data structure, the third group of header data is the data length, the fourth group of header data is the link mode, the fifth group of header data is the data compression mode, the sixth group of header data is the transmission encoding, the seventh group of header data is the user agent, and the eighth group of header data is the IP and port; S7: Determine whether the length of the third group of header data matches the length of the data body. If they match, perform database operations. If they do not match, check whether there is data loss. If data loss occurs, it is judged as a failure and returned. If data loss does not occur, continue to determine whether the UID in the first group of header data is consistent with the UID in the database. If they are consistent, perform database operations. If they are inconsistent, it is judged as a failure and returns empty data.

2. A secure data transmission method based on TCP / IP protocol according to claim 1, characterized in that: The direct sending of SQL statements to obtain data includes the following steps: S8: receiving the client's link; S9: parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S10. S10: If the first set of data is "exec sql without result", the data body represents an SQL statement; S11: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S12. If it is inconsistent, return empty data; S12: Send data to the database for execution. S13: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

3. The secure data transmission method based on TCP / IP protocol according to claim 1, characterized in that: The method of acquiring data by sending a command code through negotiation comprises the following steps: S14: receiving a link from a client; S15: Parse the data to determine whether the header data length matches the data body. If not, return failure. If yes, continue to execute S16. S16: If the first set of data is "exec sql without result", the data body represents the command code; S17: Determine whether the UID code is consistent with the UID code in the database. If it is consistent, continue to execute S18. If it is inconsistent, return empty data; S18: Sending a command code to the database; S19: After receiving the command code, the database first parses the data, and then executes the relevant command according to the command code to obtain the desired data; S20: Receive the data returned by the database and encapsulate it into JSON format and return it to the client.

Citation Information

Patent Citations

  • Multimedia data transmission system and application method thereof

    CN102340506A

  • Instant messaging data transmission method, client, server and system

    CN102882772A

  • B / s architecture-based data communication system and method, web server, and monitoring system

    WO2019028673A1