Data transmission method, device and equipment, readable storage medium and program product
By acquiring and adjusting network policies on the terminal client, performing parameter processing and encoding conversion, the problem that different types of terminal clients cannot be compatible across platforms is solved, and efficient data interaction is achieved.
Patent Information
- Application Number
- CN202410015358.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2025-07-04
AI Technical Summary
Different types of terminal clients cannot achieve cross-platform compatibility due to different SDKs, and network policy adjustments cannot be made within the terminal clients, resulting in low data interaction efficiency.
By obtaining business requests and initial network policies, determining the data transmission status, obtaining the usage data of the application program interface, adjusting the network policy, performing parameter processing and encoding conversion, cross-platform compatible data transmission is achieved.
It realizes cross-platform compatibility of different types of terminal clients, balances resource usage, avoids data transmission exceptions, and improves data interaction efficiency.
Smart Images

Figure CN120263752A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies. Specifically, this application relates to a data transmission method, apparatus, device, readable storage medium, and program product. Background Art
[0002] In the prior art, different types of SDKs (Software Development Kits) are used on the clients of different types of terminals to communicate and interact with a business server through a gateway. Since the SDKs are all customized for a certain type of client, that is, different types of terminals correspond to different SDKs, cross-platform compatibility cannot be achieved. Due to the network restrictions of the terminal system operation, only specific domain names can be targeted. Therefore, network policy adjustment cannot be performed for a service within the client of the terminal, that is, the ability of the client of the terminal to perform service data interaction cannot be restricted. Thus, the efficiency of data interaction between the client of the terminal and the business server through the gateway is relatively low. Summary of the Invention
[0003] In view of the shortcomings of the existing methods, this application provides a data transmission method, apparatus, device, computer-readable storage medium, and computer program product to solve the problem of how to improve the efficiency of data interaction between the client of a terminal and a business server through a gateway.
[0004] In a first aspect, this application provides a data transmission method, which is executed by a client on a terminal and includes:
[0005] Obtain a service request and a preset initial network policy, where the initial network policy is used to restrict the ability of the client to perform service data interaction;
[0006] Based on the initial network policy, determine the data transmission status between the client and the gateway corresponding to the service request, where the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway;
[0007] If the data transmission status indicates an abnormality, obtain the usage data of the application program interface corresponding to the service request, and adjust the initial network policy based on the usage data to obtain a target network policy;
[0008] Based on the target network policy, perform parameter adjustment processing on the service-related parameters in the service request to obtain an adjusted service request;
[0009] Based on a preset target encoding and decoding protocol, perform encoding conversion processing on the adjusted service request to obtain an encoded and converted service request;
[0010] Send the transcoded service request to the service server through the gateway to enable service data interaction between the service server and the client. The service data is based on the target encoding and decoding protocol.
[0011] In one embodiment, based on the initial network policy, determine the data transmission status between the client and the gateway corresponding to the service request, including:
[0012] Determine the network type corresponding to the initial network policy;
[0013] If the network type is an operator network, adjust the initial network policy based on the network channel protocol of the operator network to obtain a processed network policy that conforms to the network channel protocol;
[0014] If the network type is a non-operator network, determine the initial network policy as the processed network policy;
[0015] Based on the processed network policy, determine the data transmission status between the client and the gateway corresponding to the service request;
[0016] Based on the usage data, perform policy adjustment on the initial network policy to obtain the target network policy, including:
[0017] Based on the usage data, perform policy adjustment on the processed network policy to obtain the target network policy.
[0018] In one embodiment, based on the initial network policy, determine the data transmission status between the client and the gateway corresponding to the service request, including:
[0019] Set the initial network policy to the first computing unit in the preset first cache pool;
[0020] Through the first computing unit, based on the initial network policy, perform detection and judgment processing on the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the initial network policy, determine that the data transmission status is abnormal;
[0021] In one embodiment, the first computing unit is determined in the following manner:
[0022] If it is determined that there is a reusable computing unit in the preset first cache pool, use the reusable computing unit in the cache pool as the first computing unit, where the reusable computing unit is a created and idle computing unit;
[0023] If it is determined that there is no reusable computing unit in the cache pool and the number of computing units in the working state is less than the preset number, create a new computing unit and use the new computing unit as the first computing unit;
[0024] If it is determined that there is no computing unit in the reuse state in the cache pool and the number of computing units in the working state is equal to the preset number, wait until there is a computing unit in the reuse state in the cache pool, and use the computing unit in the reuse state in the cache pool as the first computing unit.
[0025] In one embodiment, the initial network policy includes at least one of scheduling information of the application program interface of the gateway, data overload protection method, traffic information of the application program interface of the gateway, and data encryption and decryption method.
[0026] In one embodiment, the initial network policy includes a network policy related to at least one of the scheduling information or traffic information of the application program interface of the gateway;
[0027] Obtain the usage data of the application program interface corresponding to the service request, including:
[0028] Obtain the relevant data of the application program interface of the gateway for the service request;
[0029] Perform parsing processing on the relevant data to obtain the usage data of the application program interface corresponding to the service request. The usage data includes at least one of scheduling information or traffic information.
[0030] In one embodiment, based on the usage data, perform policy adjustment on the initial network policy to obtain the target network policy, including:
[0031] If the scheduling information includes that the application program interface for the service request is illegally called or continuously requested and called within a preset time period, adjust the scheduling information of the application program interface in the initial policy, determine the adjusted scheduling information of the application program interface, and the target network policy includes the adjusted scheduling information of the application program interface;
[0032] If the traffic information includes that the data traffic transmitted by the application program interface for the service request is greater than the preset traffic threshold, adjust the traffic information of the application program interface in the initial policy, determine the adjusted traffic information of the application program interface, and the target network policy includes the adjusted traffic information of the application program interface.
[0033] In one embodiment, based on the target network policy, perform parameter adjustment processing on the service-related parameters in the service request to determine the adjusted service request, including:
[0034] Intercept the export function corresponding to the service request through a preset hook function, and intercept the service-related parameters in the service request from the export function;
[0035] Based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters;
[0036] Based on the modified service-related parameters, an adjusted service request including the modified service-related parameters is obtained.
[0037] In one embodiment, obtain the service weight corresponding to the service request, where the service weight characterizes the importance of the service corresponding to the service request; based on the service weight, determine the target priority of the resource requirements corresponding to the service request; based on the modified service-related parameters, obtain an adjusted service request, including:
[0038] Based on the modified service-related parameters and the target priority, generate an adjusted service request including the modified service-related parameters and the target priority.
[0039] In one embodiment, based on the modified service-related parameters and the target priority, generate an adjusted service request including the modified service-related parameters and the target priority, including:
[0040] Obtain the control parameters issued by the service server, where the control parameters are used to limit the resource access speed and resource access duration of the client;
[0041] Based on the control parameters, the modified service-related parameters, and the target priority, generate an adjusted service request including the control parameters, the modified service-related parameters, and the target priority.
[0042] In one embodiment, obtaining the service weight corresponding to the service request includes:
[0043] Through a preset path search tool, perform path search processing on the service corresponding to the service request to determine the service weight corresponding to the service request, and the path corresponding to the service weight is the path through which data is transmitted from the client to the service server.
[0044] In one embodiment, based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters, and based on the modified service-related parameters, obtain an adjusted service request, including:
[0045] Determine the target computing unit, and set the target network policy in the target computing unit. Through the target computing unit, based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters, and based on the modified service-related parameters, obtain an adjusted service request.
[0046] In one embodiment, the target computing unit is determined by the following method:
[0047] If it is determined that there is a second computing unit in the reuse state in the preset second cache pool, then the second computing unit in the reuse state in the cache pool is used as the target computing unit, where the second computing unit in the reuse state is a created and idle computing unit;
[0048] If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is less than the preset number, then a new second computing unit is created and used as the target computing unit;
[0049] If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is equal to the preset number, then wait until there is a second computing unit in the reuse state in the cache pool, and use the second computing unit in the reuse state in the cache pool as the target computing unit.
[0050] In one embodiment, the target network policy is a policy based on a lightweight data exchange format; based on the target network policy by the target computing unit, the service-related parameters in the service request are modified or deleted to obtain the modified service-related parameters, including:
[0051] By the target computing unit, the target network policy is converted into a network policy of a target object data structure, and the target object data structure is a data structure supported by the target computing unit;
[0052] The network policy of the target object data structure is processed through instruction construction to obtain a control instruction, and the control instruction includes the network policy of the target object data structure;
[0053] Based on the network policy of the target object data structure in the control instruction, the service-related parameters in the service request are modified or deleted to obtain the modified service-related parameters.
[0054] In one embodiment, the target codec protocol includes a data codec protocol using an interface description language. Based on the preset target codec protocol, the adjusted service request is subjected to encoding conversion processing to obtain the encoded and converted service request, including:
[0055] The adjusted service request inherits the protocol class using the target codec protocol, and the modified service-related parameters in the adjusted service request are used to perform attribute assignment processing on the object of the protocol class corresponding to the adjusted service request to obtain the attribute value of the object and the corresponding binary object;
[0056] The binary object is encoded, and the write permission protection processing is performed on the attribute value of the object to determine the basic data based on the target codec protocol;
[0057] Based on the basic data, through serialization processing, determine the serialized binary object, and determine the serialized binary object as the service request after encoding conversion.
[0058] In a second aspect, the present application provides a data transmission device, which is applied to a client on a terminal and includes:
[0059] A first processing module, configured to obtain a service request and a preset initial network policy, where the initial network policy is used to limit the ability of the client to perform service data interaction;
[0060] A second processing module, configured to determine the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy, where the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway;
[0061] A third processing module, configured to, if the data transmission status indicates an abnormality, obtain the usage data of the application program interface corresponding to the service request, and perform policy adjustment on the initial network policy based on the usage data to obtain a target network policy;
[0062] A fourth processing module, configured to perform parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request;
[0063] A fifth processing module, configured to perform encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request;
[0064] A sixth processing module, configured to send the encoded and converted service request to a service server through a gateway, so that service data interaction is performed between the service server and the client, and the service data is data based on the target encoding and decoding protocol.
[0065] In a third aspect, the present application provides an electronic device, including: a processor, a memory, and a bus;
[0066] The bus is used to connect the processor and the memory;
[0067] The memory is used to store operation instructions;
[0068] The processor is configured to execute the data transmission method of the first aspect of the present application by calling the operation instructions.
[0069] In a fourth aspect, the present application provides a computer-readable storage medium, storing a computer program, where the computer program is used to execute the data transmission method of the first aspect of the present application.
[0070] Fifth aspect, the present application provides a computer program product, including a computer program which, when executed by a processor, implements the steps of the data transmission method in the first aspect of the present application.
[0071] The technical solutions provided in the embodiments of the present application have at least the following beneficial effects:
[0072] The client on the terminal obtains a service request and a preset initial network policy, where the initial network policy is used to limit the ability of the client to perform service data interaction; the client on the terminal determines the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy, and the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway; if the data transmission status indicates an abnormality, the client on the terminal obtains the usage data of the application program interface corresponding to the service request, and adjusts the initial network policy based on the usage data to obtain a target network policy; the client on the terminal performs parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request; the client on the terminal performs encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request; the client on the terminal sends the encoded and converted service request to the service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is based on the target encoding and decoding protocol. In this way, the data transmission between the client and the service server is based on the target encoding and decoding protocol (such as the tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (the technical solutions provided in the embodiments of the present application are implemented through the SDK), thus achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform service data interaction is limited, the use of resources in the service server by the client is balanced, and data transmission abnormalities are avoided; thereby improving the efficiency of data interaction between the client and the service server through the gateway. Description of the Drawings
[0073] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description in the embodiments of the present application.
[0074] Figure 1 It is a schematic diagram of the architecture of the data transmission system provided in the embodiments of the present application;
[0075] Figure 2 It is a schematic flowchart of a data transmission method provided in the embodiments of the present application;
[0076] Figure 3 It is a schematic diagram of data transmission provided in the embodiments of the present application;
[0077] Figure 4 Schematic diagram of data transmission provided by an embodiment of the present application;
[0078] Figure 5 Schematic diagram of data transmission provided by an embodiment of the present application;
[0079] Figure 6 Schematic diagram of data transmission provided by an embodiment of the present application;
[0080] Figure 7 Schematic diagram of data transmission provided by an embodiment of the present application;
[0081] Figure 8 Schematic diagram of data transmission provided by an embodiment of the present application;
[0082] Figure 9 Schematic diagram of data transmission provided by an embodiment of the present application;
[0083] Figure 10 Schematic flow chart of a data transmission method provided by an embodiment of the present application;
[0084] Figure 11 Schematic diagram of the structure of a data transmission device provided by an embodiment of the present application;
[0085] Figure 12 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0086] The embodiments of the present application will be described below with reference to the accompanying drawings in the present application. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions of the embodiments of the present application.
[0087] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation of other features, information, data, steps, operations, elements, components and / or their combinations supported by the technical field of the present application. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein can include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" indicates being implemented as "A", or being implemented as "B", or being implemented as "A and B".
[0088] It can be understood that in the specific embodiments of the present application, for data related to data transmission, when the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0089] To make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0090] The data transmission method provided by the embodiment of the present application is a data transmission method provided by an identification system, and this data transmission method is related to fields such as cloud technology and maps.
[0091] Artificial Intelligence (AI) is a theory, method, technology and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
[0092] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, autonomous driving, and intelligent transportation.
[0093] Intelligent Transportation System (ITS), also known as Intelligent Transportation System, effectively integrates advanced scientific and technological means (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) into transportation, service control, and vehicle manufacturing, strengthening the connection among vehicles, roads, and users, thus forming a comprehensive transportation system that ensures safety, improves efficiency, improves the environment, and saves energy.
[0094] To better understand and illustrate the solutions of the embodiments of this application, some technical terms involved in the embodiments of this application are briefly described below.
[0095] Tars protocol: The Tars protocol is implemented using an interface description language. The Tars protocol is a binary, extensible, code automatically generated, and multi-platform supported protocol, enabling objects running on different platforms and programs written in different languages to communicate with each other in the way of RPC (Remote Procedure Call).
[0096] Actor: An Actor is the most basic computing unit. An Actor can receive a message and perform calculations based on it; an Actor is an object that supports concurrent operations. An Actor encapsulates some data and behaviors and can be accessed by multiple tasks simultaneously; different from the traditional shared memory concurrent model, an Actor uses message passing to achieve concurrency. Each Actor has its own state and will not affect the states of other Actors when processing messages; an Actor not only provides concurrent security but also can effectively reduce the use of locks and improve the performance of the program.
[0097] Classification: Classification is a mechanism to extend the original class, adding new methods to an existing class without changing the original code.
[0098] Nginx: Nginx is a high-performance HTTP (Hypertext Transfer Protocol) and reverse proxy web server.
[0099] The solution provided by the embodiments of this application relates to cloud technology. The technical solution of this application will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0100] To better understand the solution provided by the embodiments of this application, the solution will be described below in combination with a specific application scenario.
[0101] In one embodiment, Figure 1 shows a schematic diagram of the architecture of a data transmission system applicable to the embodiments of this application. It can be understood that the data transmission method provided by the embodiments of this application can be applicable to but not limited to application scenarios such as Figure 1 shown.
[0102] In this example, as Figure 1 shown, the architecture of the data transmission system in this example may include but is not limited to a terminal 10, a server 20, a gateway 30, and a database 40. The terminal 10, the server 20, the gateway 30, and the database 40 can interact with each other through a network 50.
[0103] The client on the terminal 10 obtains a service request and a preset initial network policy, and the initial network policy is used to limit the ability of the client to perform service data interaction; the client on the terminal 10 determines the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy, and the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway; if the data transmission status indicates an abnormality, the client on the terminal 10 obtains the usage data of the application program interface corresponding to the service request, and adjusts the initial network policy based on the usage data to obtain a target network policy; the client on the terminal 10 performs parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request; the client on the terminal 10 performs encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request; the client on the terminal 10 sends the encoded and converted service request to the server 20 through the gateway 30 so that service data interaction can be performed between the server 20 and the client, and the service data is data based on the target encoding and decoding protocol. The server 20 can be a service server, and the database 40 can be used to store the initial network policy and the target network policy.
[0104] It is understandable that the above is only an example and this embodiment is not limited here.
[0105] Among them, terminals include but are not limited to smart phones (such as Android phones, iOS phones, etc.), mobile phone simulators, tablet computers, laptops, digital broadcast receivers, MIDs (Mobile Internet Devices), PDAs (Personal Digital Assistants), intelligent voice interaction devices, smart home appliances, car terminals, etc.
[0106] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0107] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, allowing various application systems to obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". From the user's perspective, the resources in the "cloud" are infinitely scalable and can be obtained at any time, used on demand, expanded at any time, and paid for by use.
[0108] As a provider of basic cloud computing capabilities, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0109] According to the logical function division, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on the PaaS layer. SaaS can also be deployed directly on IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
[0110] The so-called artificial intelligence cloud service is generally also referred to as AIaaS (AI as a Service, which means "AI as a service" in Chinese). This is a currently mainstream service mode of artificial intelligence platforms. Specifically, the AIaaS platform will split several common AI services and provide independent or packaged services in the cloud. This service mode is similar to opening an AI-themed mall: all developers can access and use one or more artificial intelligence services provided by the platform through the API interface. Some senior developers can also use the AI frameworks and AI infrastructure provided by the platform to deploy and operate their own exclusive cloud artificial intelligence services.
[0111] The above network can include but is not limited to: wired networks, wireless networks. Among them, the wired network includes: local area networks, metropolitan area networks, and wide area networks, and the wireless network includes: Bluetooth, Wi-Fi, and other networks that implement wireless communication. Specifically, it can also be determined based on the actual application scenario requirements and is not limited here.
[0112] See Figure 2 , Figure 2 shows a schematic flowchart of a data transmission method provided by an embodiment of the present application. Among them, this method can be executed by any electronic device, such as a terminal, etc.; as an optional implementation manner, this method can be executed by a terminal. For the convenience of description, in the description of some optional embodiments below, the client on the terminal will be used as an example of the execution subject of this method for illustration. As Figure 2 shown, the data transmission method provided by the embodiment of the present application includes the following steps:
[0113] S201, obtain a service request and a preset initial network policy, where the initial network policy is used to limit the ability of the client to perform service data interaction.
[0114] Specifically, services such as chatting, audio and video playback, etc., and service requests such as request for chatting, request for audio and video playback, etc. The preset initial network policy can be a network policy pre-set by operation and maintenance personnel. Network policies such as scheduling information of the API (Application Program Interface) of the gateway, data overload protection method, traffic information of the API of the gateway (such as API rate limiting of the gateway), data encryption and decryption method, etc.; the network policy can be implemented through user management, whitelist and blacklist management, setting recommendations, setting statistics, access duration, access rate, setting reviews, etc.
[0115] S202, based on the initial network policy, determine the data transmission status between the client and the gateway corresponding to the service request, where the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway.
[0116] Specifically, for the data transmission status, for example, within a certain time period, the data traffic between the client and the gateway corresponding to the service request exceeds the traffic specified in the initial network policy, indicating that there is an abnormality in the data transmission between the client and the gateway.
[0117] S203. If the data transmission status indicates an abnormality, obtain the usage data of the application program interface corresponding to the service request, and based on the usage data, adjust the initial network policy to obtain the target network policy.
[0118] Specifically, the usage data of the application program interface corresponding to the service request includes, for example, the scheduling information of the gateway's application program interface, the traffic information of the gateway's application program interface, etc.
[0119] S204. Based on the target network policy, perform parameter adjustment processing on the service-related parameters in the service request to obtain the adjusted service request.
[0120] Specifically, the service-related parameters include access control rules, traffic control rules, security policies, IP (Internet Protocol) addresses and subnet masks, DNS (Domain Name System) parameters, VLAN (Virtual Local Area Network) parameters, DHCP (Dynamic Host Configuration Protocol) parameters, network service parameters, etc. Among them, access control rules: define which users or devices can access specific network resources; traffic control rules: define the rules for controlling different types of network traffic, such as bandwidth limits and priority queuing; security policies: define network security policies, such as encryption, authentication, and data protection; IP addresses and subnet masks: define how IP addresses and subnet masks are allocated and used; DNS parameter settings: define DNS servers and domain name resolution rules; VLAN parameter settings: define the configuration and management rules of virtual local area networks (VLANs); DHCP parameter settings: define the configuration rules of dynamic host configuration protocol (DHCP) servers; network service parameter settings: define the configuration rules of network services, such as network time protocol (NTP) servers and file sharing services.
[0121] S205. Based on the preset target encoding and decoding protocol, perform encoding conversion processing on the adjusted service request to obtain the service request after encoding conversion.
[0122] Specifically, the target encoding / decoding protocol is, for example, a data encoding / decoding protocol using an interface description language. The data encoding / decoding protocol using an interface description language is, for example, the Tars protocol. For example, the service request after encoding conversion is a request based on the Tars protocol.
[0123] S206. Send the service request after encoding conversion to the service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is data based on the target encoding / decoding protocol.
[0124] Specifically, for example, the client sends the service request after encoding conversion to the service server through the gateway. The service server receives the service request after encoding conversion, and the service server performs service data interaction with the client through the gateway. The service data is based on the Tars protocol.
[0125] In the embodiment of the present application, the client on the terminal obtains a service request and a preset initial network policy. The initial network policy is used to limit the ability of the client to perform service data interaction; the client on the terminal determines the data transmission state between the client and the gateway corresponding to the service request based on the initial network policy. The data transmission state indicates whether there is an abnormality in the data transmission between the client and the gateway; if the data transmission state indicates an abnormality, the client on the terminal obtains the usage data of the application program interface corresponding to the service request, and adjusts the initial network policy based on the usage data to obtain a target network policy; the client on the terminal adjusts the service-related parameters in the service request based on the target network policy to obtain an adjusted service request; the client on the terminal performs encoding conversion processing on the adjusted service request based on a preset target encoding / decoding protocol to obtain a service request after encoding conversion; the client on the terminal sends the service request after encoding conversion to the service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is data based on the target encoding / decoding protocol. In this way, the data transmission between the client and the service server is based on the target encoding / decoding protocol (such as the Tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (implementing the technical solution provided in the embodiment of the present application through the SDK), thereby achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform service data interaction is limited, the use of resources in the service server by the client is balanced, and data transmission abnormalities are avoided; thereby improving the efficiency of data interaction between the client and the service server through the gateway.
[0126] In one embodiment, determining the data transmission state between the client and the gateway corresponding to the service request based on the initial network policy includes:
[0127] Determine the network type corresponding to the initial network policy;
[0128] If the network type is a carrier network, adjust the initial network policy based on the network channel protocol of the carrier network to obtain a processed network policy that conforms to the network channel protocol;
[0129] If the network type is a non-carrier network, determine the initial network policy as the processed network policy;
[0130] Based on the processed network policy, determine the data transmission status between the client and the gateway corresponding to the service request;
[0131] Perform policy adjustment on the initial network policy based on the usage data to obtain the target network policy, including:
[0132] Perform policy adjustment on the processed network policy based on the usage data to obtain the target network policy.
[0133] Specifically, for example, the client on the terminal is an APP (Application), the APP includes an SDK, and the APP implements the technical solutions provided in the embodiments of the present application through the SDK, such as Figure 3 As shown, the SDK includes a basic service layer, a detection layer, a presentation layer, and a function layer. The basic service layer, the detection layer, the presentation layer, and the function layer have refined divisions of labor and cooperate with each other; among them, the basic service layer includes cloud computing services, and the cloud computing services are used to provide a tars protocol channel; the detection layer is used to generate instructions (such as control instructions), call Actors (Actor objects), API detections, etc.; the presentation layer includes a network policy system, a background management system, etc. The transactions processed in the presentation layer tend to be custom rules, and the custom rules include implementation methods of network policies such as user management, whitelist and blacklist management, setting recommendations, setting statistics, access duration, access rate, setting reviews, etc. In the background management system, corresponding network policies can be configured for the custom rules to restrict the network access of the function layer. The background management system manages the control instructions, identity audits, resource transmission controls, etc. of the terminal, and the background management system can directly receive control instructions sent from the terminal where the administrator (such as an operation and maintenance personnel) is located; the function layer includes functional modules such as classification and Hook modules.
[0134] For example, as Figure 4As shown, the operation and maintenance personnel write the initial network policy and set the initial network policy to the background management system in the presentation layer. The background management system in the presentation layer sends the initial network policy to the network policy system in the presentation layer. The initial network policy is a policy based on the lightweight data exchange format, and the lightweight data exchange format can be JSON. The network type corresponding to the initial network policy is determined by the network policy system, that is, the network type is judged by the network policy system. The network type can be an operator (operator network) or a non-operator (non-operator network). The non-operator network is, for example, the WIFI (mobile hotspot) of a certain shopping mall. If the network type is an operator, the operator system is docked to generate a policy. That is, if the network type is an operator network, the initial network policy is adjusted based on the network channel protocol of the operator network to obtain a processed network policy that conforms to the network channel protocol. If the network type is a non-operator, a policy is generated. That is, if the network type is a non-operator network, the initial network policy is determined as the processed network policy.
[0135] For example, as Figure 4 shown, for policy injection, a detection Actor is generated according to the policy. That is, the processed network policy is set to the computing unit in the first cache pool, and this computing unit is the detection Actor. Based on the processed network policy, this computing unit detects, judges, and processes the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the processed network policy, the data transmission status is determined to be abnormal. The detection layer actively pushes the data transmission status indicating abnormality and receives the service request sent by the presentation layer to parse the API. That is, the detection layer obtains the usage data of the application program interface corresponding to the service request and adjusts the processed policy based on the usage data to obtain the target network policy.
[0136] For example, obtaining the usage data of the application program interface corresponding to the service request and adjusting the processed policy based on the usage data to obtain the target network policy includes:
[0137] Obtaining the relevant data of the application program interface for the service request in the gateway;
[0138] Performing parsing and processing on the relevant data, that is, as Figure 4 shown in the parsing API (Application Programming Interface), obtaining the usage data of the application program interface corresponding to the service request. The usage data includes at least one of scheduling information or traffic information;
[0139] If the scheduling information includes that the application programming interface for a service request is illegally called or continuously requested to be called within a preset time period, the scheduling information of the application programming interface in the processed policy will be adjusted to determine the adjusted scheduling information of the application programming interface, and the target network policy includes the adjusted scheduling information of the application programming interface;
[0140] If the traffic information includes that the data traffic transmitted by the application programming interface for a service request is greater than a preset traffic threshold, the traffic information of the application programming interface in the processed policy will be adjusted to determine the adjusted traffic information of the application programming interface, and the target network policy includes the adjusted traffic information of the application programming interface.
[0141] It should be noted that in the detection layer, Actor controls and multiplexes data transmission, optimizing the request speed and being able to detect abnormal traffic; the network policy system can set user-defined network policy rules, which is better for implementing the youth mode for TOC products (consumer-oriented products), and parents can remotely control their children's mobile phone's ability to use the network.
[0142] In one embodiment, based on the initial network policy, the data transmission status between the client and the gateway corresponding to the service request is determined, including:
[0143] Set the initial network policy to the first computing unit in the preset first cache pool;
[0144] Through the first computing unit, based on the initial network policy, detect, judge and process the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the initial network policy, determine that the data transmission status is abnormal;
[0145] In one embodiment, the first computing unit is determined in the following manner:
[0146] If it is determined that there is a computing unit in the multiplexing state in the preset first cache pool, use the computing unit in the multiplexing state in the cache pool as the first computing unit, where the computing unit in the multiplexing state is a created and idle computing unit;
[0147] If it is determined that there is no computing unit in the multiplexing state in the cache pool and the number of computing units in the working state is less than the preset number, create a new computing unit and use the new computing unit as the first computing unit;
[0148] If it is determined that there is no computing unit in the multiplexing state in the cache pool and the number of computing units in the working state is equal to the preset number, wait until there is a computing unit in the multiplexing state in the cache pool and use the computing unit in the multiplexing state in the cache pool as the first computing unit.
[0149] Specifically, the first cache pool is, for example, the cache pool in a business server; the first computing unit is, for example, an Actor. As Figure 5 shown, the state attributes of an Actor (Actor state) include new, working, and reusable (reusable state). For an activated task, a new Actor is created. This Actor starts working. After this Actor finishes working, it is set into the cache pool. For the next task, this Actor can be retrieved from the cache pool for reuse. For example, the initial network policy is set into the Actor in the first cache pool; based on the initial network policy, this Actor detects, judges, and processes the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the initial network policy, it is determined that the data transmission state is abnormal.
[0150] For example, the presentation layer sends a business request to the detection layer for a business operation; the detection layer multiplexes and detects data through an Actor. Each generated Actor is associated with a state attribute of state, and the state attribute includes new, working, and reusable states; for the business operation, for example, the data resources required for a certain marketing activity need to be accessed and downloaded through port 8083 under the domain name xxx.qq.com, and at the same time, the product data required for a certain live broadcast needs to be accessed and downloaded through port 8083 under xxx.qq1.com; after these two domain names (xxx.qq.com and xxx.qq1.com) are resolved by DNS, they are both at the main node of the server, so access conflicts will occur, and an Actor can be used to avoid this access conflict; the main node of the business server defines the maximum concurrency (the business requests that the main node can process in parallel at the same time. For example, if the maximum concurrency of the main node is 2, the main node can process 2 business requests in parallel). If the number N of business requests does not reach the maximum concurrency, then N Actors are created; if the number N of business requests is greater than the maximum concurrency, the Actor that has processed the business request is set to the reusable state, that is, the Actor that has processed the business request is set into the cache pool; when the main node receives the next business request, the detection layer retrieves the reusable Actor from the cache pool and continues to transmit data. For example, one Actor corresponds to one business request, and multiple Actors correspond to multiple business requests. The presentation layer sends multiple business requests to the detection layer; the maximum concurrency corresponding to the main node is 10. If there are 9 (N = 9) business requests, then 9 Actors are created; if there are 11 business requests, then 10 Actors are created first. When Actor1 among the 10 Actors finishes processing one request, Actor1 is set to reusable, and the 11th business request is processed through the reusable Actor1.
[0151] For example, if it is determined that there is an Actor in the reuse state in the preset first cache pool, the Actor in the reuse state in the cache pool is used as the first computing unit, where the Actor in the reuse state is a created and idle computing unit. For example, if it is determined that there is no Actor in the reuse state in the cache pool and the number of Actors in the working state is less than the preset number (maximum concurrency), a new Actor is created and used as the first computing unit. For example, if it is determined that there is no Actor in the reuse state in the cache pool and the number of Actors in the working state is equal to the preset number (maximum concurrency), wait until there is an Actor in the reuse state in the cache pool, and use the Actor in the reuse state in the cache pool as the first computing unit.
[0152] In one embodiment, the initial network policy includes at least one of scheduling information of the application program interface of the gateway, data overload protection method, traffic information of the application program interface of the gateway, and data encryption and decryption method.
[0153] Specifically, the scheduling information of the application program interface of the gateway, for example, the application program interface for a service request is illegally called, continuously requested and called within a preset time period, etc., the data overload protection method, for example, restricting the total traffic of service data within a preset time period, the traffic information of the application program interface of the gateway, for example, the data traffic transmitted by the application program interface for a service request is greater than the preset traffic threshold, and the data encryption and decryption method, for example, the service data encryption method and the service data decryption method.
[0154] In one embodiment, the initial network policy includes a network policy related to at least one of the scheduling information or traffic information of the application program interface;
[0155] Obtain the usage data of the application program interface corresponding to the service request, including:
[0156] Obtain the relevant data of the application program interface for the service request in the gateway;
[0157] Perform parsing processing on the relevant data to obtain the usage data of the application program interface corresponding to the service request, and the usage data includes at least one of scheduling information or traffic information.
[0158] In one embodiment, based on the usage data, perform policy adjustment on the initial network policy to obtain the target network policy, including:
[0159] If the scheduling information includes that the application program interface for the service request is illegally called or continuously requested and called within a preset time period, adjust the scheduling information of the application program interface in the initial policy, determine the adjusted scheduling information of the application program interface, and the target network policy includes the adjusted scheduling information of the application program interface;
[0160] If the traffic information includes that the data traffic transmitted by the application programming interface (API) for a service request is greater than a preset traffic threshold, the traffic information of the API in the initial policy is adjusted to determine the adjusted traffic information of the API, and the target network policy includes the adjusted traffic information of the API.
[0161] Specifically, the detection layer obtains the API configuration information of the presentation layer, and the usage data of the API corresponding to the service request includes the API configuration information. The API configuration information is as Figure 6 shown. The API configuration information includes basic information, advanced configuration, etc. The basic information includes interface type, access level, interface identifier, version, Chinese name of the interface, interface description, call method, routing method, message encoding, subsequent service URL (Uniform Resource Locator), group address, weight, etc. The advanced configuration includes signature verification, API authorization, etc. Among them, the weight represents the number of times the URL is accessed.
[0162] For example, if a certain API of the gateway is illegally called or continuously requested, the Actor is used to process the service data of the client request, so that the service data of the client request directly comes from the cache in the service server; if an exception occurs in the scheduling of a certain API of the gateway, the Actor is used to limit the traffic or block the source IP of the client request.
[0163] In one embodiment, based on the target network policy, parameter adjustment processing is performed on the service-related parameters in the service request to determine the adjusted service request, including:
[0164] Intercept the export function corresponding to the service request through a preset hook function, and intercept the service-related parameters in the service request from the export function;
[0165] Based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters;
[0166] Based on the modified service-related parameters, obtain the adjusted service request including the modified service-related parameters.
[0167] Specifically, for example, by using the hook function Hook to intercept the network request utility class NetClass in the client, and creating a request classification NetClass_Ext. Relevant functions are added in the request classification NetClass_Ext to receive and inject (set) network policies, and the network policies are associated with the business modules in the corresponding functional layers. For example, if the business module is a downloader, when downloading a certain file in the downloader, it is first determined whether the user logged in to the client has resource access rights through the corresponding associated network policy, and whether there are black / white lists is parsed from the URL to be downloaded; based on the overall network scheduling and running conditions of the client, the access duration, access speed, etc. are restricted.
[0168] For example, when a business request from the client is sent from the network request utility class NetClass, the Hook module (hook function) in the functional layer intercepts the export function corresponding to the business request, and forwards the business-related parameters in the business request intercepted from the export function to NetClass_Ext; NetClass_Ext will modify or delete the business-related parameters in the business request based on the target network policy injected from the presentation layer to the functional layer, and obtain the modified business-related parameters.
[0169] It should be noted that the adjusted business request includes a parameter, which is the modified business-related parameter.
[0170] In one embodiment, obtain the business weight corresponding to the business request, where the business weight represents the importance of the business corresponding to the business request; based on the business weight, determine the target priority of the resource requirements corresponding to the business request; based on the modified business-related parameters, obtain the adjusted business request, including: generating an adjusted business request including the modified business-related parameters and the target priority based on the modified business-related parameters and the target priority.
[0171] Specifically, for example, as Figure 4 shown, through the path search tool tracert in the presentation layer, perform path search processing for the business corresponding to the business request to determine the business weight corresponding to the business request. The path corresponding to the business weight is the path through which data is transmitted from the client to the business server. The presentation layer sends the business weight corresponding to the business request to the functional layer. Based on the business weight, determine the target priority of the resource requirements corresponding to the business request. There is a proportional relationship between the business weight and the target priority, that is, the greater the business weight, the higher the target priority. For example, a client has multiple businesses, and each business among the multiple businesses corresponds to a business weight. The business weight corresponding to business A among the multiple businesses is the largest, and the server preferentially satisfies the resource requirements of business A while adjusting the resource requirements of other businesses, such as throttling business B.
[0172] It should be noted that the adjusted service request includes two parameters, namely the modified service-related parameters and the target priority.
[0173] In one embodiment, based on the modified service-related parameters and the target priority, generating an adjusted service request including the modified service-related parameters and the target priority includes:
[0174] Obtain the control parameters issued by the service server, where the control parameters are used to limit the resource access speed and resource access duration of the client;
[0175] Based on the control parameters, the modified service-related parameters, and the target priority, generate an adjusted service request including the control parameters, the modified service-related parameters, and the target priority.
[0176] Specifically, for example, the framework related to the Nginx service in the service server will issue control parameters such as the number of concurrent IP addresses, the total number of request accesses, and traffic to the client, and the control parameters are used to limit the number of concurrent IP addresses, the total number of request accesses, traffic, etc.
[0177] For example, as Figure 7 shown, the function layer intercepts the network request utility class NetClass in the client through the hook function Hook and creates a request classification NetClass_Ext. Relevant functions are added in the request classification NetClass_Ext to receive and inject (set) network policies, and the network policies are associated with the service modules in the corresponding function layer. The service modules are, for example, Service 1, Service 2, and Service 3; for example, the service module is a downloader. In the downloader, when downloading a certain file, first determine whether the user logged in to the client has resource access rights through the corresponding associated network policy, and parse whether there is a black / white list from the URL to be downloaded; based on the overall network scheduling and running conditions of the client, limit the access duration, access speed, etc.; the framework related to the Nginx service in the service server will issue control parameters such as the number of concurrent IP addresses, the total number of request accesses, and traffic to the client; the limited access speed and access duration are jointly implemented by connecting the request classification NetClass_Ext to the framework related to the Nginx service.
[0178] It should be noted that the adjusted service request includes three parameters, namely the control parameters, the modified service-related parameters, and the target priority. By classifying the function layer, the ability of a certain service inside the client to use the network can be restricted or disabled in ways such as access duration, access rate, access whitelist, and access blacklist.
[0179] In one embodiment, obtaining the service weight corresponding to the service request includes:
[0180] Through a preset path search tool, perform path search processing on the service corresponding to the service request, determine the service weight corresponding to the service request, and the path corresponding to the service weight is the path through which data is transmitted from the client to the service server.
[0181] Specifically, the path search tool is, for example, tracert, and the service weight is directly proportional to the target priority, that is, the greater the service weight, the higher the target priority. For example, for a client with multiple services, each service corresponds to a service weight. Among the multiple services, the service weight corresponding to service A is the largest. The server preferentially satisfies the resource requirements of service A and adjusts the resource requirements of other services at the same time. For example, traffic limiting is performed on service B.
[0182] In one embodiment, based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters, and based on the modified service-related parameters, obtain the adjusted service request, including:
[0183] Determine the target computing unit, and set the target network policy into the target computing unit. Through the target computing unit, based on the target network policy, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters, and based on the modified service-related parameters, obtain the adjusted service request;
[0184] In one embodiment, the target computing unit is determined in the following manner:
[0185] If it is determined that there is a second computing unit in the reuse state in the preset second cache pool, then use the second computing unit in the reuse state in the cache pool as the target computing unit, where the second computing unit in the reuse state is a created and idle computing unit;
[0186] If it is determined that there is no second computing unit in the reuse state in the second cache pool, and the number of second computing units in the working state is less than the preset number, then create a new second computing unit and use the new second computing unit as the target computing unit;
[0187] If it is determined that there is no second computing unit in the reuse state in the second cache pool, and the number of second computing units in the working state is equal to the preset number, then wait until there is a second computing unit in the reuse state in the cache pool, and use the second computing unit in the reuse state in the cache pool as the target computing unit.
[0188] Specifically, the second cache pool is, for example, the cache pool in the service server; the second computing unit is, for example, Actor, such as Figure 5As shown in the figure, the state attributes of an Actor (Actor state) include newly created, working, and reused (reuse state). For an activated task, a new Actor is created, which starts working. After the Actor finishes working, it is set into the cache pool. For the next task, the Actor can be retrieved from the cache pool for reuse.
[0189] For example, the presentation layer sends a service request to the detection layer for a service operation; the detection layer uses Actors for data reuse and detection. Each generated Actor is associated with a state attribute of state, and the state attribute includes newly created, working, and reused states; for service operations, for example, the data resources required for a certain marketing campaign need to be accessed and downloaded through port 8083 under the domain name xxx.qq.com, and at the same time, the product data required for a certain live broadcast needs to be accessed and downloaded through port 8083 under xxx.qq1.com; after these two domain names (xxx.qq.com and xxx.qq1.com) are resolved by DNS, they are both at the main node of the server, so access conflicts will occur, and Actors can be used to avoid such access conflicts; the main node of the service server defines the maximum concurrency (the number of service requests that the main node can process in parallel at the same time. For example, if the maximum concurrency of the main node is 2, the main node can process 2 service requests in parallel). If the number N of service requests does not reach the maximum concurrency, then N Actors are created; if the number N of service requests is greater than the maximum concurrency, then the Actors that have completed the service requests are set to the reuse state, that is, the Actors that have completed the service requests are set into the cache pool; when the main node receives the next service request, the detection layer retrieves the reused Actors from the cache pool and continues to transfer data. For example, one Actor corresponds to one service request, and multiple Actors correspond to multiple service requests. The presentation layer sends multiple service requests to the detection layer; the maximum concurrency corresponding to the main node is 10. If there are 9 (N = 9) service requests, then 9 Actors are created; if there are 11 service requests, then 10 Actors are first created. After Actor1 among the 10 Actors finishes processing one request, Actor1 is set to the reuse state, and the 11th service request is processed through the reused Actor1.
[0190] For example, as Figure 4 shown in the figure, the detection layer determines whether there are reused Actors in the preset second cache pool. If it is determined that there are reused Actors in the preset second cache pool, then the reused Actors in the second cache pool are used as the target computing units, where the reused Actors are the created and idle computing units; if it is determined that there are no reused Actors in the second cache pool, then new Actors are created and the new Actors are used as the target computing units. For example, as Figure 4As shown, the detection layer determines whether the number of service requests is greater than the maximum concurrency. If it is determined that the number of service requests is greater (Yes indicates yes, and the abbreviation of Yes is Y) than the maximum concurrency, an Actor in the multiplexing state is set. For example, if the maximum concurrency is 10 and there are 11 service requests, 10 Actors are first created. When Actor1 among the 10 Actors finishes processing a request, Actor1 is set as an Actor in the multiplexing state, and the 11th service request is processed through the multiplexing state Actor1. If it is determined that the number of service requests is not (No indicates no, and the abbreviation of No is N) greater than the maximum concurrency, N Actors are created.
[0191] For example, if it is determined that there is no Actor in the multiplexing state in the cache pool and the number of Actors in the working state is less than the preset number (maximum concurrency), a new Actor is created and used as the target computing unit.
[0192] For example, if it is determined that there is no Actor in the multiplexing state in the cache pool and the number of Actors in the working state is equal to the preset number (maximum concurrency), wait until there is an Actor in the multiplexing state in the cache pool, and use the Actor in the multiplexing state in the cache pool as the target computing unit.
[0193] In one embodiment, the target network policy is a policy based on a lightweight data exchange format; based on the target network policy by the target computing unit, the service-related parameters in the service request are modified or deleted to obtain the modified service-related parameters, including:
[0194] Through the target computing unit, the target network policy is converted into a network policy of the target object data structure, and the target object data structure is the data structure supported by the target computing unit;
[0195] The network policy of the target object data structure is processed through instruction construction to obtain a control instruction, and the control instruction includes the network policy of the target object data structure;
[0196] Based on the network policy of the target object data structure in the control instruction, the service-related parameters in the service request are modified or deleted to obtain the modified service-related parameters.
[0197] Specifically, such as Figure 4As shown, the target object data structure is, for example, an Actor object data structure, and the lightweight data exchange format is, for example, JSON. Assigning a data structure to an Actor and constructing an instruction includes: through the target computing unit Actor, converting the target network policy into a network policy of the Actor object data structure, where the Actor object data structure is a data structure supported by the target computing unit Actor, and the target network policy is a policy based on JSON; and obtaining a control instruction through instruction construction processing of the network policy of the Actor object data structure, where the control instruction includes the network policy of the Actor object data structure.
[0198] In one embodiment, the target encoding and decoding protocol includes a data encoding and decoding protocol using an interface description language. Based on the preset target encoding and decoding protocol, performing an encoding conversion process on the adjusted service request to obtain the encoded and converted service request, including:
[0199] Inheriting the protocol class using the target encoding and decoding protocol for the adjusted service request, and using the modified service-related parameters in the adjusted service request to perform an attribute assignment process on the object of the protocol class corresponding to the adjusted service request to obtain the attribute value of the object and the corresponding binary object;
[0200] Performing an encoding process on the binary object and performing a write permission protection process on the attribute value of the object to determine the basic data based on the target encoding and decoding protocol;
[0201] Based on the basic data, through serialization processing, determining the serialized binary object, and determining the serialized binary object as the encoded and converted service request.
[0202] Specifically, the target encoding and decoding protocol includes the tars protocol. For example, as Figure 8 shown, the basic service layer provides cloud computing services constructed by the tars protocol and provides a tars protocol channel; the data of the client (such as the adjusted service request) obtains a tarsObj object (an object of the protocol class) by inheriting the TarsObjectV2 class (the protocol class of the target encoding and decoding protocol); using the set method provided by the JV2_PROP_GS_V2 macro to set the attribute value of the object for the attributes of the tarsObj object to obtain a binary object; encoding the binary object and protecting the write permission of the set attribute value of the object through the JV2_PROP_GS_V2 macro to obtain the data based on the tars protocol (such as the basic string under tars encoding), that is, the basic data based on the target encoding and decoding protocol; serializing the data based on the tars protocol through a script to obtain the serialized binary object; and the client sending the serialized binary object to the service server.
[0203] For example, data based on the Tars protocol, such as a string, whose first letter is 'V', 'M', or 'O', represents Vector, Map, and supported object types respectively. Vector, Map, and supported object types are container object types supported by the Tars protocol framework. If it is a Vector, the subsequent string is the additional information encoding of the object type in the Vector container. If it is a MAP container, the value of the first two characters of the subsequent string is equal to the string length (00, 99] of the type information encoding of the Key, followed by the type information encoding of the Key and the type information encoding of the Value. Non-container object types supported by the Tars protocol framework include: binary data, numeric types, strings, Tars objects, and their derived objects. The basic string under Tars encoding is, for example:
[0204] @property(nonatomic,retain,JV2_PROP_GS_V2(arg0,setArg0:))NSString*JV2_PROP_NM(o,0,arg0);
[0205] Among them, the difference between the basic string under this Tars encoding and an ordinary string is that the JV2_PROP_GS_V2 macro is used to protect the read and write permissions of parameter setting (the set method is to assign a property value to a property in an object) and value retrieval (the get method is to obtain a property value from an object), and the JV2_PROP_NM macro encrypts the property name in Tars. Among them, o, 0, and arg0 represent an object, the first property in a class, and using the arg0 parameter as the property name respectively. The basic string under this Tars encoding defines a property based on the Tars protocol as a non-atomic type (i.e., it can be accessed and operated on by multiple threads), a strong reference operation, and is the first string type data in the Tars protocol.
[0206] It should be noted that the basic service layer constructed based on Tars can quickly convert data types that conform to the system specification into data recognized by the Tars protocol, with higher efficiency in underlying transmission, can adapt to different types of terminals, and achieve true cross-platform.
[0207] In one embodiment, after sending the encoded and converted service request to the service server through the gateway, it further includes:
[0208] Receiving service data sent by the service server through the gateway;
[0209] Inheriting the protocol class that adopts the target encoding and decoding protocol for the service data, using the service data to perform property value retrieval processing on the object of the protocol class corresponding to the service data, and obtaining the property value of the object and the corresponding binary object;
[0210] Decode the binary object and perform read permission protection processing on the attribute values of the object to obtain the decoded binary object;
[0211] Based on the decoded binary object, through deserialization processing, obtain the processed data.
[0212] Specifically, the target encoding and decoding protocol includes the Tars protocol. For example, as Figure 9 shown, the basic service layer provides cloud computing services constructed by the Tars protocol and provides a Tars protocol channel; the client receives data (business data) sent by the business server, and this data obtains the tarsObj object by inheriting the TarsObjectV2 class; through the get method provided by the JV2_PROP_GS_V2 macro, obtain the attribute values of the tarsObj object (the get method is to obtain the attribute values from the object) to obtain the binary object; decode the binary object, and protect the read permission of the obtained object's attribute values through the JV2_PROP_GS_V2 macro to obtain the decoded binary object; deserialize the decoded binary object through a script to obtain an object of data types (string, integer, floating point), that is, the processed data.
[0213] It should be noted that the basic service layer constructed based on Tars can quickly convert data types that conform to the system specification into data recognized by the Tars protocol, with higher efficiency in underlying transmission, and can adapt to different types of terminals, achieving true cross-platform.
[0214] Applying the embodiments of the present application has at least the following beneficial effects:
[0215] Data transmission between the client and the business server is based on the target encoding and decoding protocol (such as the Tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (implementing the technical solutions provided in the embodiments of the present application through the SDK), thus achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform business data interaction is restricted, the use of resources in the business server by the client is balanced, and abnormal data transmission is avoided; thereby improving the efficiency of data interaction between the client and the business server through the gateway. The basic service layer constructed based on Tars can quickly convert data types that conform to the system specifications into data recognized by the Tars protocol, with higher efficiency in underlying transmission, and can adapt to different types of terminals, achieving true cross-platform; in the detection layer, the Actor is used to control and multiplex data transmission, optimizing the request speed and being able to detect abnormal traffic; the network policy system can set user-defined network policy rules, which is better for implementing the youth mode for TOC products (consumer-oriented products), and parents can remotely control the ability of their children's mobile phones to use the network; through the classification in the function layer, the ability of a certain service inside the client to use the network can be restricted or disabled in ways such as access duration, access rate, access whitelist, and access blacklist.
[0216] To better understand the method provided in the embodiments of the present application, the solutions of the embodiments of the present application will be further described below with reference to examples of specific application scenarios.
[0217] In one embodiment, the technical solutions provided in the embodiments of the present application are implemented through an SDK. This SDK is used to solve the policy control of network access in clients on terminals such as banks, securities, and insurance. When the terminal needs to interact with the gateway API, this SDK can simplify the data protocol and communication protocol of the gateway API, and implement network access restrictions on the services inside the client, thereby significantly improving the development efficiency and network communication efficiency.
[0218] In an embodiment of a specific application scenario, for example, in the business data transmission scenario, refer to Figure 10 , which shows the processing flow of a data transmission method. As Figure 10 shown, the processing flow of the data transmission method provided in the embodiments of the present application includes the following steps:
[0219] S901, the client on the terminal obtains a business request and a preset initial network policy.
[0220] Specifically, business requests such as requests for chatting, requests for audio and video playback, etc. The preset initial network policy can be a network policy pre-set by operation and maintenance personnel. Network policies include, for example, scheduling information of the API of the gateway, data overload protection methods, traffic information of the API of the gateway, data encryption and decryption methods, etc. Network policies can be implemented through user management, whitelist and blacklist management, setting recommendations, setting statistics, access duration, access rate, setting reviews, etc.
[0221] S902, the client determines the network type corresponding to the initial network policy; if the network type is an operator network, the client adjusts the initial network policy based on the network channel protocol of the operator network to obtain a processed network policy that conforms to the network channel protocol; if the network type is a non-operator network, the client determines the initial network policy as the processed network policy.
[0222] Specifically, for example, as Figure 4 shown, operation and maintenance personnel write the initial network policy and set the initial network policy to the background management system in the presentation layer. The background management system in the presentation layer sends the initial network policy to the network policy system in the presentation layer; the initial network policy is a policy based on a lightweight data exchange format, and the lightweight data exchange format can be JSON; the network type corresponding to the initial network policy is determined through the network policy system, that is, the network type is judged through the network policy system. The network type can be an operator (operator network) or a non-operator (non-operator network). A non-operator network is, for example, the WIFI (mobile hotspot) of a certain shopping mall; if the network type is an operator, connect to the operator system to generate a policy, that is, if the network type is an operator network, the initial network policy is adjusted based on the network channel protocol of the operator network to obtain a processed network policy that conforms to the network channel protocol; if the network type is a non-operator, generate a policy, that is, if the network type is a non-operator network, the initial network policy is determined as the processed network policy.
[0223] S903, the client sets the processed network policy to the computing unit in the cache pool. The computing unit detects, judges, and processes the data transmission between the client and the gateway based on the processed network policy. If the data transmission between the client and the gateway does not meet the processed network policy, it is determined that the data transmission state is abnormal.
[0224] Specifically, the processed network policy includes scheduling information of the application program interface of the gateway, data overload protection methods, traffic information of the application program interface of the gateway, data encryption and decryption methods, etc.
[0225] S904. If the data transmission status indicates an anomaly, the client obtains the usage data of the application programming interface corresponding to the service request, and adjusts the processed network policy based on the usage data to obtain the target network policy.
[0226] Specifically, obtain the relevant data of the application programming interface for the service request in the gateway; parse and process the relevant data to obtain the usage data of the application programming interface corresponding to the service request, where the usage data includes at least one of scheduling information or traffic information; if the scheduling information includes that the application programming interface for the service request is illegally called or continuously requested and called within a preset time period, then adjust the scheduling information of the application programming interface in the processed network policy to determine the adjusted scheduling information of the application programming interface, and the target network policy includes the adjusted scheduling information of the application programming interface; if the traffic information includes that the data traffic transmitted by the application programming interface for the service request is greater than the preset traffic threshold, then adjust the traffic information of the application programming interface in the processed network policy to determine the adjusted traffic information of the application programming interface, and the target network policy includes the adjusted traffic information of the application programming interface.
[0227] S905. The client intercepts the exit function corresponding to the service request through a preset hook function, and intercepts the service-related parameters in the service request from the exit function; and modifies or deletes the service-related parameters in the service request based on the target network policy to obtain the modified service-related parameters.
[0228] Specifically, for example, when the service request of the client is sent from the network request tool class NetClass, the Hook module (hook function) in the function layer intercepts the exit function corresponding to the service request, and forwards the service-related parameters in the service request intercepted from the exit function to NetClass_Ext; NetClass_Ext will modify or delete the service-related parameters in the service request accordingly based on the target network policy injected from the presentation layer to the function layer to obtain the modified service-related parameters.
[0229] S906. The client performs path search processing for the service corresponding to the service request through a path search tool, determines the service weight corresponding to the service request, and determines the target priority of the resource requirements corresponding to the service request based on the service weight.
[0230] Specifically, there is a proportional relationship between the service weight and the target priority, that is, the greater the service weight, the higher the target priority.
[0231] S907. The client obtains the control parameters issued by the framework related to the Nginx service in the service server, and the control parameters are used to limit the resource access speed, resource access duration, etc. of the client.
[0232] Specifically, for example, as Figure 7 shown, the functional layer intercepts the network request utility class NetClass in the client through the hook function Hook, and creates a request classification NetClass_Ext. Relevant functions are added to the request classification NetClass_Ext to receive and inject (set) network policies, and the network policies are associated with the business modules in the corresponding functional layer. The business modules are, for example, Business 1, Business 2, and Business 3. For example, if the business module is a downloader, when downloading a certain file in the downloader, it is first determined whether the user logged in to the client has resource access rights through the corresponding associated network policy, and whether there is a black / white list is parsed from the URL to be downloaded. Based on the overall network scheduling and running conditions of the client, the access duration, access speed, etc. are restricted. The framework related to the Nginx service in the business server will send control parameters such as the number of concurrent IP addresses, the total number of request accesses, and traffic to the client. The restricted access speed and access duration are jointly implemented by connecting the request classification NetClass_Ext to the framework related to the Nginx service.
[0233] S908, the client generates an adjusted service request including control parameters, modified service-related parameters, and a target priority based on the control parameters, modified service-related parameters, and target priority.
[0234] Specifically, the adjusted service request includes three parameters, which are the control parameter, the modified service-related parameter, and the target priority respectively.
[0235] S909, the client performs encoding conversion processing on the adjusted service request based on the tars protocol to obtain the encoded and converted service request, and sends the encoded and converted service request to the service server through the gateway.
[0236] Specifically, the adjusted service request inherits the protocol class that adopts the target encoding and decoding protocol, and uses the modified service-related parameters in the adjusted service request to assign attribute values to the object of the protocol class corresponding to the adjusted service request to obtain the attribute value of the object and the corresponding binary object; encodes the binary object, and performs write permission protection processing on the attribute value of the object to determine the basic data based on the target encoding and decoding protocol; based on the basic data, determines the serialized binary object through serialization processing, and determines the serialized binary object as the encoded and converted service request.
[0237] S910, the client receives the service data sent by the service server through the gateway, and performs encoding conversion processing on the service data based on the tars protocol to obtain the encoded and converted service data.
[0238] Specifically, the receiving service server receives service data sent by the gateway; inherits the protocol class using the target encoding and decoding protocol for the service data, uses the service data to perform attribute value extraction processing on the object of the protocol class corresponding to the service data, and obtains the attribute value of the object and the corresponding binary object; performs decoding processing on the binary object, and performs read permission protection processing on the attribute value of the object to obtain the decoded binary object; based on the decoded binary object, through deserialization processing, obtains the processed data.
[0239] It should be noted that, for example, the client communicates with the corresponding SDK in the service server through the SDK on the client.
[0240] Applying the embodiments of the present application has at least the following beneficial effects:
[0241] The data transmission between the client and the service server is based on the target encoding and decoding protocol (such as the tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (implement the technical solutions provided by the embodiments of the present application through the SDK), thereby achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform service data interaction is restricted, the use of resources in the service server by the client is balanced, and data transmission anomalies are avoided; thereby improving the efficiency of data interaction between the client and the service server through the gateway. Based on the basic service layer constructed by tars, it can quickly convert data types that conform to the system specification into data recognized by the tars protocol, with higher efficiency in underlying transmission, and can adapt to different types of terminals, achieving true cross-platform; in the detection layer, the Actor controls and multiplexes data transmission, optimizes the request speed, and can detect abnormal traffic; the network policy system can set user-defined network policy rules, which is better for implementing the youth mode for TOC products (consumer-oriented products), and parents can remotely control the ability of their children's mobile phones to use the network; through the classification of the function layer, the ability of a certain service inside the client to use the network can be restricted or disabled according to access duration, access rate, access whitelist, access blacklist, etc.
[0242] The embodiments of the present application also provide a data transmission device, which is applied to the client on the terminal. The structural schematic diagram of the data transmission device is as Figure 11 , the data transmission device 90 includes a first processing module 901, a second processing module 902, a third processing module 903, a fourth processing module 904, a fifth processing module 905, and a sixth processing module 906.
[0243] The first processing module 901 is configured to obtain a service request and a preset initial network policy, where the initial network policy is used to define the ability of the client to perform service data interaction;
[0244] The second processing module 902 is configured to determine the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy, where the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway;
[0245] The third processing module 903 is configured to, if the data transmission status indicates an abnormality, obtain the usage data of the application program interface corresponding to the service request, and perform policy adjustment on the initial network policy based on the usage data to obtain a target network policy;
[0246] The fourth processing module 904 is configured to perform parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request;
[0247] The fifth processing module 905 is configured to perform encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request;
[0248] The sixth processing module 906 is configured to send the encoded and converted service request to the service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is based on the target encoding and decoding protocol.
[0249] In one embodiment, the second processing module 902 is specifically configured to:
[0250] Determine the network type corresponding to the initial network policy;
[0251] If the network type is a carrier network, adjust the initial network policy based on the network channel protocol of the carrier network to obtain a processed network policy that conforms to the network channel protocol;
[0252] If the network type is a non-carrier network, determine the initial network policy as the processed network policy;
[0253] Based on the processed network policy, determine the data transmission status between the client and the gateway corresponding to the service request;
[0254] The third processing module 903 is specifically configured to:
[0255] Perform policy adjustment on the processed network policy based on the usage data to obtain a target network policy.
[0256] In one embodiment, the second processing module 902 is specifically configured to:
[0257] Set the initial network policy to the first computing unit in the preset first cache pool;
[0258] Based on the initial network policy, the first computing unit detects, judges, and processes the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the initial network policy, it is determined that the data transmission status is abnormal;
[0259] In one embodiment, the first computing unit is determined in the following manner:
[0260] If it is determined that there is a computing unit in the multiplexing state in the preset first cache pool, the computing unit in the multiplexing state in the cache pool is used as the first computing unit, where the computing unit in the multiplexing state is a created and idle computing unit;
[0261] If it is determined that there is no computing unit in the multiplexing state in the cache pool and the number of computing units in the working state is less than the preset number, a new computing unit is created and used as the first computing unit;
[0262] If it is determined that there is no computing unit in the multiplexing state in the cache pool and the number of computing units in the working state is equal to the preset number, wait until there is a computing unit in the multiplexing state in the cache pool, and use the computing unit in the multiplexing state in the cache pool as the first computing unit.
[0263] In one embodiment, the initial network policy includes at least one of the scheduling information of the application program interface of the gateway, the data overload protection method, the traffic information of the application program interface of the gateway, and the data encryption and decryption method.
[0264] In one embodiment, the initial network policy includes a network policy related to at least one of the scheduling information or traffic information of the application program interface of the gateway;
[0265] The third processing module 903 is specifically used for:
[0266] Obtain the relevant data of the application program interface for the service request in the gateway;
[0267] Parse and process the relevant data to obtain the usage data of the application program interface corresponding to the service request, where the usage data includes at least one of the scheduling information or traffic information.
[0268] The third processing module 903 is specifically used for:
[0269] If the scheduling information includes that the application programming interface for the service request is illegally called or continuously requested to be called within a preset time period, the scheduling information of the application programming interface in the initial policy is adjusted to determine the adjusted scheduling information of the application programming interface, and the target network policy includes the adjusted scheduling information of the application programming interface;
[0270] If the traffic information includes that the data traffic transmitted by the application programming interface for the service request is greater than the preset traffic threshold, the traffic information of the application programming interface in the initial policy is adjusted to determine the adjusted traffic information of the application programming interface, and the target network policy includes the adjusted traffic information of the application programming interface.
[0271] In one embodiment, the fourth processing module 904 is specifically configured to:
[0272] Intercept the exit function corresponding to the service request through a preset hook function, and intercept the service-related parameters in the service request from the exit function;
[0273] Modify or delete the service-related parameters in the service request based on the target network policy to obtain the modified service-related parameters;
[0274] Based on the modified service-related parameters, obtain an adjusted service request including the modified service-related parameters.
[0275] In one embodiment, the fourth processing module 904 is further configured to:
[0276] Obtain the service weight corresponding to the service request, where the service weight characterizes the importance of the service corresponding to the service request; determine the target priority of the resource requirements corresponding to the service request based on the service weight; based on the modified service-related parameters, obtain an adjusted service request, including:
[0277] Generate an adjusted service request including the modified service-related parameters and the target priority based on the modified service-related parameters and the target priority.
[0278] In one embodiment, the fourth processing module 904 is specifically configured to:
[0279] Obtain the control parameters issued by the service server, where the control parameters are used to limit the resource access speed and resource access duration of the client;
[0280] Generate an adjusted service request including the control parameters, the modified service-related parameters, and the target priority based on the control parameters, the modified service-related parameters, and the target priority.
[0281] In one embodiment, the fourth processing module 904 is specifically configured to:
[0282] Perform path search processing for the service corresponding to the service request through a preset path search tool, determine the service weight corresponding to the service request, and the path corresponding to the service weight is the path through which data is transmitted from the client to the service server.
[0283] In one embodiment, the fourth processing module 904 is specifically configured to:
[0284] Determine the target computing unit, set the target network policy into the target computing unit, and based on the target network policy through the target computing unit, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters, and based on the modified service-related parameters, obtain the adjusted service request;
[0285] In one embodiment, the target computing unit is determined in the following manner:
[0286] If it is determined that there is a second computing unit in the reuse state in the preset second cache pool, then use the second computing unit in the reuse state in the cache pool as the target computing unit, where the second computing unit in the reuse state is a created and idle computing unit;
[0287] If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is less than the preset number, then create a new second computing unit and use the new second computing unit as the target computing unit;
[0288] If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is equal to the preset number, then wait until there is a second computing unit in the reuse state in the cache pool, and use the second computing unit in the reuse state in the cache pool as the target computing unit.
[0289] In one embodiment, the target network policy is a policy based on a lightweight data exchange format;
[0290] The fourth processing module 904 is specifically configured to:
[0291] Through the target computing unit, convert the target network policy into a network policy of the target object data structure, where the target object data structure is the data structure supported by the target computing unit;
[0292] Perform instruction construction processing on the network policy of the target object data structure to obtain a control instruction, where the control instruction includes the network policy of the target object data structure;
[0293] Based on the network policy of the target object data structure in the control instruction, modify or delete the service-related parameters in the service request to obtain the modified service-related parameters.
[0294] In one embodiment, the target encoding and decoding protocol includes a data encoding and decoding protocol using an interface description language. The fifth processing module 905 is specifically configured to:
[0295] Inherit the protocol class using the target encoding and decoding protocol for the adjusted service request, and use the modified service-related parameters in the adjusted service request to perform attribute assignment processing on the object of the protocol class corresponding to the adjusted service request, to obtain the attribute value of the object and the corresponding binary object;
[0296] Perform encoding processing on the binary object, and perform write permission protection processing on the attribute value of the object to determine the basic data based on the target encoding and decoding protocol;
[0297] Based on the basic data, through serialization processing, determine the serialized binary object, and determine the serialized binary object as the service request after encoding conversion.
[0298] Applying the embodiments of the present application has at least the following beneficial effects:
[0299] The client on the terminal obtains a service request and a preset initial network policy, where the initial network policy is used to limit the ability of the client to perform service data interaction; the client on the terminal determines the data transmission state between the client and the gateway corresponding to the service request based on the initial network policy, and the data transmission state indicates whether there is an abnormality in the data transmission between the client and the gateway; if the data transmission state indicates an abnormality, the client on the terminal obtains the usage data of the application program interface corresponding to the service request, and adjusts the initial network policy based on the usage data to obtain a target network policy; the client on the terminal performs parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request; the client on the terminal performs encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain a service request after encoding conversion; the client on the terminal sends the encoded and decoded service request to the service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is data based on the target encoding and decoding protocol. In this way, the data transmission between the client and the service server is based on the target encoding and decoding protocol (such as the tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (implementing the technical solutions provided by the embodiments of the present application through the SDK), thereby achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform service data interaction is limited, the use of resources in the service server by the client is balanced, and data transmission abnormalities are avoided; thus, the efficiency of data interaction between the client and the service server through the gateway is improved.
[0300] An embodiment of the present application further provides an electronic device. The schematic structural diagram of the electronic device is as follows Figure 12 shown, Figure 12 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. Among them, the processor 4001 and the memory 4003 are connected, such as being connected through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as data sending and / or data receiving, etc. It should be noted that in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation to the embodiments of the present application.
[0301] The processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in combination with the disclosure of the present application. The processor 4001 may also be a combination that implements a computing function, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0302] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 12 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.
[0303] The memory 4003 may be a ROM (Read Only Memory), or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory), or other types of dynamic storage devices that can store information and instructions. It may also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, which is not limited herein.
[0304] The memory 4003 is used to store the computer program for implementing the embodiments of the present application and is controlled by the processor 4001 to execute. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
[0305] Among them, the electronic device includes but is not limited to: terminals, etc.
[0306] Applying the embodiments of the present application has at least the following beneficial effects:
[0307] The client on the terminal obtains a service request and a preset initial network policy, where the initial network policy is used to limit the ability of the client to perform service data interaction; the client on the terminal determines the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy, and the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway; if the data transmission status indicates an abnormality, the client on the terminal obtains the usage data of the application program interface corresponding to the service request, and adjusts the initial network policy based on the usage data to obtain a target network policy; the client on the terminal performs parameter adjustment processing on the service-related parameters in the service request based on the target network policy to obtain an adjusted service request; the client on the terminal performs encoding and conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request; the client on the terminal sends the encoded and decoded service request to the service server through the gateway, so that service data interaction can be performed between the service server and the client, and the service data is based on the target encoding and decoding protocol. In this way, the data transmission between the client and the service server is based on the target encoding and decoding protocol (such as the Tars protocol). Therefore, clients on multiple different types of terminals (such as terminals based on different operating systems) can use the same SDK (implement the technical solutions provided in the embodiments of the present application through the SDK), thereby achieving cross-platform compatibility; through the adjusted network policy, that is, the target network policy, for a certain service, the ability of the client to perform service data interaction is limited, the use of resources in the service server by the client is balanced, and data transmission abnormalities are avoided; thus, the efficiency of data interaction between the client and the service server through the gateway is improved.
[0308] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit that includes the function of the module or unit.
[0309] The embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.
[0310] The embodiments of the present application further provide a computer program product, including a computer program. When the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.
[0311] Based on the same principle as the method provided in the embodiments of the present application, the embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in any optional embodiment of the present application described above.
[0312] It should be understood that although the flowchart of the embodiments of the present application indicates each operation step by an arrow, the execution order of these steps is not limited to the order indicated by the arrow. Unless there is a clear description in this article, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart can be executed in other orders according to requirements. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times respectively. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of the present application do not limit this.
[0313] The above are only optional implementation manners of some implementation scenarios of the present application. It should be noted that for those of ordinary skill in the art, without departing from the technical concept of the solution of the present application, adopting other similar implementation means based on the technical idea of the present application also belongs to the protection scope of the embodiments of the present application.
Claims
1. A data transmission method, which is executed by a client on a terminal, characterized in that Including: Obtain a service request and a preset initial network policy, where the initial network policy is used to define the ability of the client to perform service data interaction; Based on the initial network policy, determine the data transmission status between the client and the gateway corresponding to the service request, where the data transmission status indicates whether there is an abnormality in the data transmission between the client and the gateway; If the data transmission status indicates an abnormality, obtain the usage data of the application programming interface corresponding to the service request, and perform policy adjustment on the initial network policy based on the usage data to obtain a target network policy; Based on the target network policy, perform parameter adjustment processing on the service-related parameters in the service request to obtain an adjusted service request; Based on a preset target encoding and decoding protocol, perform encoding conversion processing on the adjusted service request to obtain an encoded and converted service request; Send the encoded and converted service request to a service server through the gateway, so that service data interaction is performed between the service server and the client, and the service data is data based on the target encoding and decoding protocol.
2. The method according to claim 1, characterized in that The determining the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy includes: Determine the network type corresponding to the initial network policy; If the network type is an operator network, adjust the initial network policy based on the network channel protocol of the operator network to obtain a processed network policy that conforms to the network channel protocol; If the network type is a non-operator network, determine the initial network policy as the processed network policy; Based on the processed network policy, determine the data transmission status between the client and the gateway corresponding to the service request; The performing policy adjustment on the initial network policy based on the usage data to obtain a target network policy includes: Perform policy adjustment on the processed network policy based on the usage data to obtain a target network policy.
3. The method according to claim 1, characterized in that, The determining the data transmission status between the client and the gateway corresponding to the service request based on the initial network policy includes: Set the initial network policy to a first calculation unit in a preset first cache pool; Through the first calculation unit, based on the initial network policy, perform detection and judgment processing on the data transmission between the client and the gateway. If the data transmission between the client and the gateway does not meet the initial network policy, determine that the data transmission status is abnormal.
4. The method according to claim 3, characterized in that, The first calculation unit is determined by the following method: If it is determined that there is a reusable calculation unit in the preset first cache pool, use the reusable calculation unit in the cache pool as the first calculation unit, where the reusable calculation unit is a created and idle calculation unit; If it is determined that there is no reusable calculation unit in the cache pool and the number of working calculation units is less than a preset number, create a new calculation unit and use the new calculation unit as the first calculation unit; If it is determined that there is no computing unit in the reuse state in the cache pool and the number of computing units in the working state is equal to the preset number, wait until there is a computing unit in the reuse state in the cache pool, and use the computing unit in the reuse state in the cache pool as the first computing unit.
5. The method according to claim 1, characterized in that The initial network policy includes a network policy related to at least one of scheduling information or traffic information of the application program interface of the gateway; The obtaining of the usage data of the application program interface corresponding to the service request includes: Obtaining the relevant data of the application program interface of the gateway for the service request; Performing parsing processing on the relevant data to obtain the usage data of the application program interface corresponding to the service request, where the usage data includes at least one of scheduling information or traffic information.
6. The method according to claim 5, wherein The performing of policy adjustment on the initial network policy based on the usage data to obtain a target network policy includes: If the scheduling information includes that the application program interface for the service request is illegally called or continuously requested to be called within a preset time period, adjust the scheduling information of the application program interface in the initial policy, determine the adjusted scheduling information of the application program interface, and the target network policy includes the adjusted scheduling information of the application program interface; If the traffic information includes that the data traffic transmitted by the application program interface for the service request is greater than a preset traffic threshold, adjust the traffic information of the application program interface in the initial policy, determine the adjusted traffic information of the application program interface, and the target network policy includes the adjusted traffic information of the application program interface.
7. The method according to claim 1, characterized in that The performing of parameter adjustment processing on the service-related parameters in the service request based on the target network policy to determine an adjusted service request includes: Intercepting the export function corresponding to the service request through a preset hook function, and intercepting the service-related parameters in the service request from the export function; Modifying or deleting the service-related parameters in the service request based on the target network policy to obtain modified service-related parameters; Based on the modified service-related parameters, obtaining an adjusted service request including the modified service-related parameters.
8. The method according to claim 7, wherein The method further includes: Obtaining the service weight corresponding to the service request, where the service weight characterizes the importance of the service corresponding to the service request; Based on the service weight, determining the target priority of the resource requirements corresponding to the service request; The obtaining of the adjusted service request based on the modified service-related parameters includes: Generating an adjusted service request including the modified service-related parameters and the target priority based on the modified service-related parameters and the target priority.
9. The method according to claim 8, characterized in that, The generating of the adjusted service request including the modified service-related parameters and the target priority based on the modified service-related parameters and the target priority includes: Obtaining the control parameters issued by the service server, where the control parameters are used to limit the resource access speed and resource access duration of the client; Generate an adjusted service request including the control parameter, the modified service-related parameter, and the target priority based on the control parameter, the modified service-related parameter, and the target priority.
10. The method according to claim 8, wherein The obtaining of the service weight corresponding to the service request includes: Perform path search processing for the service corresponding to the service request through a preset path search tool to determine the service weight corresponding to the service request, and the path corresponding to the service weight is the path through which data is transmitted from the client to the service server.
11. The method according to any one of claims 7 to 10, characterized in that, Based on the target network policy, modify or delete the service-related parameters in the service request to obtain modified service-related parameters, and based on the modified service-related parameters, obtain an adjusted service request, including: Determine a target computing unit, set the target network policy into the target computing unit, and through the target computing unit, modify or delete the service-related parameters in the service request based on the target network policy to obtain modified service-related parameters, and based on the modified service-related parameters, obtain an adjusted service request.
12. The method according to claim 11, wherein The target computing unit is determined in the following manner: If it is determined that there is a second computing unit in the reuse state in a preset second cache pool, then use the second computing unit in the reuse state in the cache pool as the target computing unit, where the second computing unit in the reuse state is a created and idle computing unit; If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is less than a preset number, then create a new second computing unit and use the new second computing unit as the target computing unit; If it is determined that there is no second computing unit in the reuse state in the second cache pool and the number of second computing units in the working state is equal to the preset number, then wait until there is a second computing unit in the reuse state in the cache pool, and use the second computing unit in the reuse state in the cache pool as the target computing unit.
13. The method according to claim 11, wherein The target network policy is a policy based on a lightweight data exchange format; Through the target computing unit, modify or delete the service-related parameters in the service request based on the target network policy to obtain modified service-related parameters, including: Through the target computing unit, convert the target network policy into a network policy of a target object data structure, and the target object data structure is a data structure supported by the target computing unit; Through instruction construction processing, obtain a control instruction from the network policy of the target object data structure, and the control instruction includes the network policy of the target object data structure; Based on the network policy of the target object data structure in the control instruction, modify or delete the service-related parameters in the service request to obtain modified service-related parameters.
14. A data transmission device, which is applied to a client on a terminal, is characterized in that Includes: A first processing module, configured to obtain a service request and a preset initial network policy, where the initial network policy is used to define the ability of the client to perform service data interaction; A second processing module, configured to determine a data transmission status between the client and a gateway corresponding to the service request based on the initial network policy, where the data transmission status indicates whether there is an abnormality in data transmission between the client and the gateway; A third processing module, configured to, if the data transmission status indicates an abnormality, obtain usage data of an application program interface corresponding to the service request, and perform policy adjustment on the initial network policy based on the usage data to obtain a target network policy; A fourth processing module, configured to perform parameter adjustment processing on service-related parameters in the service request based on the target network policy to obtain an adjusted service request; A fifth processing module, configured to perform encoding conversion processing on the adjusted service request based on a preset target encoding and decoding protocol to obtain an encoded and converted service request; A sixth processing module, configured to send the encoded and converted service request to a service server through the gateway, so that service data interaction is performed between the service server and the client, where the service data is data based on the target encoding and decoding protocol.
15. An electronic device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-13.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1-13 are implemented.