A network traffic control method and system based on message content

By analyzing the message protocol packet by packet and removing the header and fill fields added by the protocol stack, the problem of message length calculation error in the existing technology is solved, high-precision flow control is achieved, and flow control errors are reduced.

CN119743541APending Publication Date: 2025-04-01CHINA CITIC BANK CO LTD

Patent Information

Application Number
CN202411774733.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

The prior art fails to effectively consider the message header and fill fields automatically added by the protocol stack in message traffic control, resulting in errors in message length calculation, especially when the effective message length transmitted by the user is small, the worse the accuracy of the flow control is.

Method used

By analyzing the packet-by-packet protocol, the packet headers and fill fields automatically added at each level of the protocol stack are removed step by step, thereby obtaining the actual user message size, reducing the impact of the packet headers and fill fields automatically added by the protocol stack on the actual length calculation of the packet.

Benefits of technology

The precise calculation of the message payload is realized, reducing the impact of the message header and fill fields automatically added by the protocol stack on the length calculation, greatly improving the accuracy of traffic control, and reducing the error relative to the native algorithm from 29.6% and 15.4% to 1%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119743541A_ABST
    Figure CN119743541A_ABST
Patent Text Reader

Abstract

The present invention relates to a network flow control method and system based on message content, the method comprising: obtaining a message entering a protocol stack and the message length of the message, and starting network flow control; parsing the protocol type of the message level by level based on the protocol stack layer to obtain the effective message length; determining the number of tokens required for sending the message based on the effective message length, and judging whether to send the message according to the number of tokens in a token bucket. By parsing the message protocol packet by packet, the message header and padding field automatically added by each level of the protocol stack are removed level by level, so as to obtain the actual user message size, accurately calculate the effective load of the message, reduce the influence of the message header and padding field automatically added by the protocol stack on the calculation of the effective message length, and improve the flow control accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network communication technology, and in particular to a network flow control method and system based on message content. Background Art

[0002] At present, message flow control is usually completed by using message buffer and token bucket mechanism. The token bucket periodically increases tokens at a specified rate. When each message is sent, it takes away the number of tokens equal to the message length. When the message is sent too fast, the number of tokens in the token bucket is insufficient, and the message will be buffered until the number of tokens in the token bucket is sufficient to send the message. Under the control of the token bucket, the message is sent evenly. Therefore, the accurate calculation of the message length is one of the important links that affect the accuracy of flow control.

[0003] The current optimization method mainly considers that the length of the message when it is cached is not necessarily the length that is finally sent out from the egress. Therefore, when the message forwarding behavior is determined, the correction value of the editing behavior executed on the device is calculated at the same time. When the token bucket deducts the message length, it needs to additionally deduct the correction value.

[0004] The relevant patents of the existing technology include CN117997843A-Traffic shaping method, device, electronic device and computer-readable medium. The method edits the message and determines the length of the processed message and then executes the token bucket deduction action to achieve accurate traffic shaping based on the actual length of the message. Although the current method takes into account the possible editing of the message from the cache to the sending process, it still does not take into account the message header and padding field automatically added by the protocol stack, resulting in errors in the calculation of the message length. In addition, the smaller the effective message length transmitted by the user, the worse the accuracy of the flow control. Summary of the invention

[0005] To address the deficiencies in the prior art, the present invention parses the message protocol packet by packet, removes the message headers and padding fields automatically added by the protocol stack at each level step by step, thereby obtaining a method for obtaining the actual user message size, reducing the influence of the message headers and padding fields automatically added by the protocol stack on the calculation of the actual message length, and improving the flow control accuracy.

[0006] To achieve the above objectives, the technical solutions adopted by the present invention include:

[0007] A network traffic control method based on message content, characterized by comprising:

[0008] S1. Get the message entering the protocol stack and the message length of the message, and turn on network traffic control;

[0009] S2. Parse the protocol type of the message step by step based on the protocol stack layer to obtain the effective message length;

[0010] S3. Determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

[0011] Further, the obtaining of the message entering the protocol stack and the message length of the message, and enabling network flow control, further includes:

[0012] If network flow control is not enabled, the received message is directly sent to the upper protocol stack, and the message to be sent is sent to the lower protocol stack.

[0013] Furthermore, the protocol stack layers from top to bottom are application layer, transport layer, network layer, and link layer.

[0014] Furthermore, the protocol stack-based layer-by-layer parsing of the protocol type of the message includes:

[0015] Remove the message headers and padding fields added by each level of the protocol stack to obtain the actual message length encapsulated by each level of the protocol stack.

[0016] Further, the protocol type of the message is parsed based on the protocol stack level to obtain the effective message length, including:

[0017] S21. Parse the link layer protocol to obtain the actual message length of the link layer encapsulation;

[0018] S22. Determine whether the message contains a network layer protocol. If the message contains a network layer protocol, parse the network layer protocol to obtain the actual message length encapsulated by the network layer; if the message does not contain a network layer protocol, proceed to step S23;

[0019] S23. Determine whether the message contains a transport layer protocol. If the message contains a transport layer protocol, parse the transport layer protocol to obtain the actual message length of the transport layer encapsulation; if the message does not contain a transport layer protocol, proceed to step S24;

[0020] S24. Determine whether the message contains an application layer protocol. If the message contains an application layer protocol, parse the application layer protocol to obtain the actual message length encapsulated by the application layer; if the message does not contain an application layer protocol, proceed to step S25;

[0021] S25. The actual encapsulated message length finally obtained is the effective message length.

[0022] Further, determining the number of tokens required for sending the message based on the effective message length, and judging whether to send the message according to the number of tokens in the token bucket, includes:

[0023] Determine whether the number of tokens in the token bucket is greater than the number of tokens required for sending the message;

[0024] If the number of tokens in the token bucket is greater than the number of tokens required for sending the message, the message is sent after deducting the token length required for sending the message from the token bucket;

[0025] If the number of tokens in the token bucket is less than the number of tokens required for sending the message, the message is cached in a queue.

[0026] The present invention also relates to a network traffic control system based on message content, characterized in that it comprises:

[0027] A startup module is used to obtain the message entering the protocol stack and the message length of the message, and start network flow control;

[0028] A parsing module, used to parse the protocol type of the message level by level based on the protocol stack layer to obtain the effective message length;

[0029] The sending module is used to determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

[0030] The present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.

[0031] The present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;

[0032] The memory is used to store program instructions;

[0033] The processor is used to execute the above method by calling program instructions.

[0034] The present invention also relates to a computer program product, comprising a computer program and / or instructions, characterized in that the computer program and / or instructions implement the steps of the above method when executed by a processor.

[0035] The beneficial effects of the present invention are:

[0036] The network flow control method based on message content described in the present invention can accurately calculate the effective load of the message by parsing the message protocol packet by packet, removing the message header and padding field automatically added by the protocol stack at each level step by step, reducing the influence of the message header and padding field automatically added by the protocol stack on the calculation of the effective message length, and greatly improving the flow control accuracy. Compared with the error of 29.6% for flow control of 128-byte TCP messages and 15.4% for flow control of 256-byte UDP messages using the native algorithm, the error can be limited to 1% by using the method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in describing the embodiments of the present application.

[0038] Figure 1 A schematic diagram of a flow chart of a network traffic control method based on message content according to the present invention;

[0039] Figure 2 This is a schematic diagram of the structure of a network traffic control system based on message content of the present invention;

[0040] Figure 3 The figure is a schematic structural diagram of an electronic device of the present invention. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. It should be understood that the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments, and these embodiments are only used to illustrate the present application and are not used to limit the scope of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0042] During the operation of the online application system, data packets will be received from the Internet. After being processed by the protocol stack layer by layer, the packets enter the application system. The main processing logic of the protocol stack includes parsing the packet header, stripping the current protocol stack packet header and padding fields, and deciding whether to hand over the insulation to the next layer of the packet stack for processing based on the protocol type of the internal encapsulated packet. At the same time, the business logic processing of the application system will also generate data packets, which need to be processed by the protocol stack layer by layer before being sent to other network devices. At this time, the main processing logic of the protocol stack is to add the packet header and padding fields corresponding to this layer of the protocol stack, and hand them over to the next layer of the protocol stack for processing.

[0043] like Figure 1As shown, the embodiment of the present invention discloses a network traffic control method based on message content, and the steps of the process include:

[0044] Step S1: Obtain the message entering the protocol stack and the message length of the message, and enable network flow control.

[0045] In an embodiment of the present invention, obtaining a message entering a protocol stack and a message length of the message, and enabling network flow control, further includes:

[0046] If network flow control is not enabled, the received message is directly sent to the upper protocol stack, and the message to be sent is sent to the lower protocol stack.

[0047] After the message enters the protocol stack, it is first determined whether network flow control is enabled. If network flow control is not enabled, the received message is directly sent to the upper protocol stack, and the message to be sent is sent to the lower protocol stack; if network flow control is enabled, step S2 is entered to calculate the message length.

[0048] Step S2: parse the protocol type of the message based on the protocol stack layer to obtain the effective message length.

[0049] Among them, in the TCP / IP model, it is usually divided into four layers, and the protocol stack layers from top to bottom are application layer, transport layer, network layer, and link layer.

[0050] In actual network communications, data is transmitted from the application layer downward at the sending end, with corresponding header information added at each layer until the link layer; at the receiving end, data is transmitted from the link layer upward to the application layer.

[0051] In an embodiment of the present invention, parsing the protocol type of the message level by level based on the layers of the protocol stack includes:

[0052] Remove the message headers and padding fields added by each level of the protocol stack to obtain the actual message length encapsulated by each level of the protocol stack.

[0053] In this embodiment of the present invention, step S2 includes:

[0054] Step S21. parse the link layer protocol to obtain the actual message length encapsulated by the link layer;

[0055] Step S22. Determine whether the message contains a network layer protocol. If the message contains a network layer protocol, parse the network layer protocol to obtain the actual message length encapsulated by the network layer. If the message does not contain a network layer protocol, proceed to step S23.

[0056] Step S23. Determine whether the message contains a transport layer protocol. If the message contains a transport layer protocol, parse the transport layer protocol to obtain the actual message length encapsulated by the transport layer. If the message does not contain a transport layer protocol, proceed to step S24.

[0057] Step S24. Determine whether the message contains an application layer protocol. If the message contains an application layer protocol, parse the application layer protocol to obtain the actual message length encapsulated by the application layer; if the message does not contain an application layer protocol, proceed to step S25;

[0058] Step S25: The actual encapsulated message length finally obtained is the effective message length.

[0059] During the message transmission process, each layer protocol can add its own header information. The message header information includes a frame type field, which can indicate the type of the upper layer protocol. The header information also includes the control information required by the layer protocol, which can process the data accordingly.

[0060] Step S3: Determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

[0061] In this embodiment of the present invention, step S3 includes:

[0062] Determine whether the number of tokens in the token bucket is greater than the number of tokens required for sending the message;

[0063] If the number of tokens in the token bucket is greater than the number of tokens required for sending the message, the message is sent after deducting the token length required for sending the message from the token bucket;

[0064] If the number of tokens in the token bucket is less than the number of tokens required for sending the message, the message is cached in a queue.

[0065] After the message enters the protocol stack, for the message with calculated effective length, first determine whether the number of tokens in the token bucket is greater than the number of tokens required to send the message. If so, deduct the number of tokens in the token bucket corresponding to the message length and then send the message. If not, first cache the message in the queue until the number of tokens in the token bucket is not less than the number of tokens required to send the message. After deducting the number of tokens in the token bucket corresponding to the message length, send the message.

[0066] like Figure 2 As shown, the embodiment of the present invention discloses a network traffic control system based on message content, and its structure includes:

[0067] A startup module is used to obtain the message entering the protocol stack and the message length of the message, and start network flow control;

[0068] A parsing module, used to parse the protocol type of the message level by level based on the protocol stack layer to obtain the effective message length;

[0069] The sending module is used to determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

[0070] By using this system, the above-mentioned operation processing method can be executed and the corresponding technical effects can be achieved.

[0071] In the embodiment of the present invention, a Windows PC is used as a client and an Ubuntu PC (Linux) is used as a server for testing, and the testing tool can use a flow simulation tool and a flow restriction tool. The effects of the present invention in different scenarios are given below.

[0072] Scene 1

[0073] The data link layer uses the Ethernet protocol, the network layer uses the IPV4 protocol, and the transport layer uses the TCP protocol, with a speed limit of 10Mbps.

[0074] Using the traditional method, the test results are shown in Table 1.

[0075] Table 1

[0076]

[0077] Using the method of the present invention, the test results are shown in Table 2.

[0078] Table 2

[0079]

[0080]

[0081] The Ethernet message header is 14 bytes, the IPv4 message header is 20 bytes (excluding the custom padding field), and the TCP message header is 20 bytes, so the total number of protocol headers is 54 bytes.

[0082] If the user sends 1460 bytes of data, plus the protocol headers of each layer, the message size becomes 1514 bytes when it reaches the network interface for sending, which increases by 3.57%;

[0083] If the user sends 256 bytes of data, plus the protocol headers of each layer, the message size becomes 310 bytes when it reaches the network interface for sending, which increases by 17.42%;

[0084] If the user sends 128 bytes of data, plus the protocol headers of each layer, the message size becomes 182 bytes when it reaches the network interface for sending, which is an increase of 29.67%.

[0085] It can be seen that the measured error is basically consistent with the error introduced by the message header.

[0086] Scene 2

[0087] The data link layer uses the Ethernet protocol, the network layer uses the IPV4 protocol, and the transport layer uses the UDP protocol, with a speed limit of 10Mbps.

[0088] Using the traditional method, the test results are shown in Table 3.

[0089] Table 3

[0090]

[0091] Using the method of the present invention, the test results are shown in Table 4.

[0092] Table 4

[0093]

[0094]

[0095] The Ethernet message header is 14 bytes, the IPv4 message header is 20 bytes (excluding the custom padding field), and the UDP message header is 8 bytes, so the protocol headers are 42 bytes in total. For different data sizes sent by users:

[0096] If the user sends 1024 bytes of data, plus the protocol headers of each layer, the message size becomes 1066 bytes when it reaches the network interface for sending, which increases by 3.94%;

[0097] If the user sends 512 bytes of data, plus the protocol headers of each layer, the message size becomes 554 bytes when it reaches the network interface for sending, which increases by 7.58%;

[0098] If the user sends 256 bytes of data, plus the protocol headers of each layer, the message size becomes 298 bytes when it reaches the network interface for sending, which is an increase of 14.09%.

[0099] It can be seen that the measured error is basically consistent with the error introduced by the message header.

[0100] Experimental results show that compared with the native algorithm's 128-byte TCP message flow control error of 29.6% and 256-byte UDP message flow control error of 15.4%, the message content-based network flow control method of the present invention can basically limit the flow control error to within 1%.

[0101] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the method in the above embodiment, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all the steps in the method in the above embodiment are implemented.

[0102] The embodiment of the present invention further provides an electronic device for executing the above method, as a device for implementing the method, and its structure is as follows: Figure 3 As shown, the electronic device 300 includes: a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, such as through a bus 302. Optionally, the electronic device 300 may also include a transceiver 304. It should be noted that in actual applications, the transceiver 304 is not limited to one. It is understandable that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the specific structure of the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. Optionally, the electronic device may also include a display screen 305 for displaying images, or receiving user operation instructions when necessary.

[0103] The processor 301 is applied in the embodiment of the present application to implement the method shown in the above method embodiment. The transceiver 304 may include a receiver and a transmitter. The transceiver 304 is applied in the embodiment of the present application to implement the function of the electronic device of the embodiment of the present application communicating with other devices when executed.

[0104] Processor 301 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 may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 301 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0105] The processor 301 may also include one or more processing units, for example, the processor 301 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU). Among them, different processing units may be independent devices or integrated into one or more processors. Among them, the controller may be the nerve center and command center of the electronic device 300. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory may also be set in the processor 301 for storing instructions and data. In some embodiments, the memory in the processor 301 is a high-speed cache memory. The memory may store instructions or data that the processor 301 has just used or circulated. If the processor 301 needs to use the instruction or data again, it may be directly called from the memory. Repeated access is avoided, the waiting time of the processor 301 is reduced, and the efficiency of the system is improved.

[0106] The processor 301 can run the method provided in the embodiment of the present application. The processor 301 can include different devices. For example, when a CPU and a GPU are integrated, the CPU and the GPU can cooperate to execute the method provided in the embodiment of the present application, for example, part of the algorithm in the method is executed by the CPU, and another part of the algorithm is executed by the GPU to obtain faster processing efficiency.

[0107] The bus 302 may include a path to transmit information between the above components. The bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 302 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0108] The memory 303 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, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or may include a high-speed random access memory, or may include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0109] Optionally, the memory 303 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 301. The processor 301 is used to execute the application code stored in the memory 303 to implement the method provided in any embodiment of the present application.

[0110] The memory 303 can be used to store computer executable program codes, which include instructions. The processor 301 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the memory 303. The memory 303 may include a program storage area and a data storage area. Among them, the program storage area may store the code of the operating system, application program, etc. The data storage area may store data created during the use of the electronic device 300 (such as images, videos, etc. collected by the camera application), etc.

[0111] The memory 303 may also store one or more computer programs corresponding to the method provided in the embodiment of the present application. The one or more computer programs are stored in the above-mentioned memory 303 and are configured to be executed by the one or more processors 301. The one or more computer programs include instructions, and the above-mentioned instructions can be used to execute each step in the above-mentioned corresponding embodiment.

[0112] Of course, the code of the method provided in the embodiment of the present application can also be stored in an external memory. In this case, the processor 301 can run the code of the method stored in the external memory through the external memory interface, and the processor 301 can control the running process.

[0113] The display screen 305 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 300 may include 1 or N display screens 305, where N is a positive integer greater than 1. The display screen 305 can be used to display information input by a user or information provided to a user and various graphical user interfaces (GUI). For example, the display screen 305 can display photos, videos, web pages, or files.

[0114] The electronic device provided in the embodiment of the present application is applicable to any embodiment of the above method. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.

[0115] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0116] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0117] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0119] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A network traffic control method based on message content, characterized in that: include: S1. Get the message entering the protocol stack and the message length of the message, and turn on network traffic control; S2. Parse the protocol type of the message step by step based on the protocol stack layer to obtain the effective message length; S3. Determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

2. The method according to claim 1, characterized in that The step of obtaining the message entering the protocol stack and the message length of the message and starting network flow control further includes: If network flow control is not enabled, the received message is directly sent to the upper protocol stack, and the message to be sent is sent to the lower protocol stack.

3. The method according to claim 1, characterized in that The protocol stack layers from top to bottom are application layer, transport layer, network layer, and link layer.

4. The method according to claim 1, characterized in that The protocol stack-based layer-by-layer parsing of the protocol type of the message includes: Remove the message headers and padding fields added by each level of the protocol stack to obtain the actual message length encapsulated by each level of the protocol stack.

5. The method according to claim 1, characterized in that The step of parsing the protocol type of the message based on the protocol stack layer to obtain the effective message length includes: S21. Parse the link layer protocol to obtain the actual message length of the link layer encapsulation; S22. Determine whether the message contains a network layer protocol. If the message contains a network layer protocol, parse the network layer protocol to obtain the actual message length encapsulated by the network layer; if the message does not contain a network layer protocol, proceed to step S23; S23. Determine whether the message contains a transport layer protocol. If the message contains a transport layer protocol, parse the transport layer protocol to obtain the actual message length of the transport layer encapsulation; if the message does not contain a transport layer protocol, proceed to step S24; S24. Determine whether the message contains an application layer protocol. If the message contains an application layer protocol, parse the application layer protocol to obtain the actual message length encapsulated by the application layer; if the message does not contain an application layer protocol, proceed to step S25; S25. The actual encapsulated message length finally obtained is the effective message length.

6. The method according to claim 1, characterized in that The determining the number of tokens required for sending the message based on the effective message length, and judging whether to send the message according to the number of tokens in the token bucket, comprises: Determine whether the number of tokens in the token bucket is greater than the number of tokens required for sending the message; If the number of tokens in the token bucket is greater than the number of tokens required for sending the message, the message is sent after deducting the token length required for sending the message from the token bucket; If the number of tokens in the token bucket is less than the number of tokens required for sending the message, the message is cached in a queue.

7. A network traffic control system based on message content, characterized in that: include: A startup module is used to obtain the message entering the protocol stack and the message length of the message, and start network flow control; A parsing module, used to parse the protocol type of the message level by level based on the protocol stack layer to obtain the effective message length; The sending module is used to determine the number of tokens required for sending the message based on the effective message length, and determine whether to send the message according to the number of tokens in the token bucket.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store program instructions; The processor is configured to execute the method according to any one of claims 1 to 6 by calling program instructions.

10. A computer program product comprising a computer program and / or instructions, characterized in that: When the computer program and / or the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Traffic shaping method and device, electronic equipment and computer readable medium

    CN117997843A

Cited By

  • Website fingerprint defense-oriented online message-level traffic simulation method and system, and storage medium

    CN122348865A