A method, device, server and medium for controlling flow
By calculating the average channel bandwidth value and the actual bandwidth value, the sending and receiving of SMB traffic is controlled, which solves the problem of uneven bandwidth distribution in the SMB multi-channel multi-thread system and improves the utilization rate of network bandwidth and the balance of traffic.
Patent Information
- Application Number
- CN202211027128.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-25
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-08-25
AI Technical Summary
When multiple clients process large files at the same time, the existing SMB multi-channel and multi-thread system reaches the limit of network bandwidth, leading to lags in access by other clients, uneven bandwidth distribution, and low utilization.
By obtaining the total bandwidth value of the physical link and the total number of SMB channels of all clients, the average channel bandwidth value is calculated, and based on the current client channel number and actual bandwidth value, the sending and receiving of traffic is controlled to achieve balanced distribution of traffic and efficient utilization of bandwidth. .
It achieves balanced distribution of traffic and efficient utilization of bandwidth, avoids the problem that a single client occupies too much bandwidth and causes other clients to be unable to use SMB sharing services normally, and improves the overall network bandwidth utilization.
Smart Images

Figure CN115378877B
Abstract
Description
Technical Field
[0001] The present application relates to the field of servers, and in particular to a method, device, server and medium for controlling traffic. Background Art
[0002] Samba multi-channel multi-threading is an SMB data stream processing system that utilizes the multi-channel characteristics of Server Message Block (SMB) by establishing multiple Transmission Control Protocol (TCP) connections between the client and the server, and placing each TCP connection processing into a separate working thread. Multiple TCP connections can ensure the maximum utilization of network bandwidth, and multiple channel threads can ensure that the server can concurrently process the SMB data streams received by each channel.
[0003] When several clients continuously read and write large files in an SMB working environment, the traffic will easily reach the network bandwidth limit, and more other clients will experience obvious lags when accessing. The current common Quality of Service (QOS) bandwidth solution is to set a fixed control threshold to limit the traffic upper limit of a single client, such as using an exclusive method. The exclusive method sets a fixed amount of bandwidth to only one or several fixed clients, and the remaining bandwidth is allocated to other clients. In this way, if the fixed-amount client does not fully use the bandwidth, the idle data link cannot be allocated to other clients, resulting in the bandwidth in multiple SMB client scenarios cannot be fully utilized, and a few clients occupy a large amount of bandwidth, and the remaining clients cannot use the SMB sharing service normally, that is, the traffic distribution is unbalanced and the bandwidth utilization rate is low.
[0004] It can be seen that how to achieve balanced distribution of traffic and improve bandwidth utilization is a technical problem that people in this field need to solve urgently. Summary of the invention
[0005] The purpose of this application is to provide a method, device, server and medium for controlling traffic, so as to achieve balanced distribution of traffic and improve bandwidth utilization.
[0006] In order to solve the above technical problems, the present application provides a method for controlling flow, including:
[0007] Get the total bandwidth value of the physical link and the total number of SMB channels of all clients;
[0008] Obtain an average channel bandwidth value according to the total bandwidth value and the total number of SMB channels;
[0009] Obtaining an average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client;
[0010] Obtaining the actual bandwidth value of the current client;
[0011] The sending and receiving of traffic is controlled according to the relationship between the actual bandwidth value and the average total bandwidth value.
[0012] Preferably, before obtaining the actual bandwidth value of the current client, the method further includes:
[0013] When receiving the channel connection initiated by the client, establishing a UNIX SOCKET connection between the current SMB service subprocess and the SMB control subprocess;
[0014] Adding a response processing interface of the current SOCKET handle to the EPOLL event of the current SMB service subprocess;
[0015] When the current SMB service subprocess receives the access request sent by the client, the number of the current SMB service subprocess, the number of the current channel, and the requested data length are sent to the SMB control subprocess.
[0016] Preferably, after sending the number of the current SMB service subprocess, the number of the current channel, and the requested data length to the SMB control subprocess, the method further includes:
[0017] When receiving the UNIX SOCKET connection initiated by the SMB service subprocess, establishing a SOCKET handle and registering the SOCKET handle in the EPOLL event;
[0018] Obtaining the service sub-process number corresponding to the SMB service sub-process according to the SOCKET handle;
[0019] Create a HASH summary table according to the business sub-process number;
[0020] When receiving the data flow information sent by the SMB service subprocess, parsing the data flow information to obtain the process number of the current SMB service subprocess, the channel number of the current SMB service subprocess, and the data flow information of each channel of the channel of the current SMB service subprocess;
[0021] According to the process number of the current SMB service sub-process, searching the HASH summary table for the corresponding current SMB service sub-process node;
[0022] Appending the data flow information of each channel of the current SMB service subprocess to the current SMB service subprocess node in a chain structure to form a new HASH summary table;
[0023] Correspondingly, obtaining the actual bandwidth value of the current client includes:
[0024] Traversing the new HASH summary table at a fixed frequency;
[0025] The actual bandwidth value of the current client is obtained according to the new HASH summary table.
[0026] Preferably, the fixed frequency is 1s, and acquiring the actual bandwidth value of the current client according to the new HASH summary table includes:
[0027] Obtain the current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value from the new HASH summary table;
[0028] Acquire the actual bandwidth value of each of the channels according to the current flow value and the previous flow value;
[0029] Obtaining the sum of actual bandwidth values of each of the channels;
[0030] The sum of the actual bandwidth values of the channels is used as the actual bandwidth value of the current client.
[0031] Preferably, the controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value comprises:
[0032] In the case where the actual bandwidth value is greater than the average total bandwidth value, the feedback result mark is set as a signal for refusing to receive the traffic; the signal for refusing to receive the traffic is fed back to the SMB service subprocess; a rejection instruction is sent to the SOCKET handles of each channel of the SMB service subprocess; and each channel of the SMB service subprocess is controlled to temporarily close the reception of the traffic according to the rejection instruction;
[0033] When the actual bandwidth value is less than the average total bandwidth value, the feedback result mark is set as a signal allowing the traffic to be received; the signal allowing the traffic to be received is fed back to the SMB business sub-process; an allow instruction is sent to the SOCKET handles of each channel of the SMB business sub-process; and each channel of the SMB business sub-process is controlled to normally receive the traffic according to the allow instruction.
[0034] Preferably, after sending a rejection instruction to the SOCKET handles of each channel of the SMB service subprocess, and before controlling each channel of the SMB service subprocess to temporarily close the reception of the traffic according to the rejection instruction, the method further includes:
[0035] Get the current receiving status of the channel;
[0036] When the current receiving state is a rejection state, ignoring the rejection instruction;
[0037] In the case where the current receiving state is the allowing state, the step of controlling each channel of the SMB service subprocess to temporarily close the receiving of the traffic according to the reject instruction is entered;
[0038] Correspondingly, after sending the allow instruction to the SOCKET handles of each channel of the SMB service subprocess, and before controlling each channel of the SMB service subprocess to normally receive the traffic according to the allow instruction, the method further includes:
[0039] Obtain the current receiving state of the channel;
[0040] When the current receiving state is the allowing state, ignoring the allowing instruction;
[0041] When the current receiving state is the rejecting state, the step of controlling each channel of the SMB service subprocess to normally receive the traffic according to the allowing instruction is entered.
[0042] Preferably, after controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value, the method further comprises:
[0043] Outputs prompt information for indicating the collection and issuance status.
[0044] In order to solve the above technical problems, the present application also provides a flow control device, comprising:
[0045] The first acquisition module is used to obtain the total bandwidth value of the physical link and the total number of SMB channels of all clients;
[0046] A second acquisition module is used to acquire an average channel bandwidth value according to the total bandwidth value and the total number of SMB channels;
[0047] A third acquisition module, configured to acquire an average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client;
[0048] A fourth acquisition module is used to obtain the actual bandwidth value of the current client;
[0049] The control module is used to control the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value.
[0050] In order to solve the above technical problems, the present application also provides a server, including:
[0051] Memory for storing computer programs;
[0052] The processor is used to implement the steps of the above-mentioned method for controlling flow when executing the computer program.
[0053] In order to solve the above technical problem, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method for controlling flow are implemented.
[0054] The method for controlling traffic provided by the present application includes: obtaining the total bandwidth value of the physical link and the total number of SMB channels of all clients; obtaining the average channel bandwidth value based on the total bandwidth value and the total number of SMB channels; obtaining the average total bandwidth value of the current client based on the average channel bandwidth value and the number of channels of the current client; obtaining the actual bandwidth value of the current client; and controlling the sending and receiving of traffic based on the relationship between the actual bandwidth value and the average total bandwidth value. In this method, the average channel bandwidth value is obtained based on the total bandwidth value of the physical link and the total number of SMB channels of all clients, so that the bandwidth is evenly distributed among all SMB channels; bandwidth is allocated to the current client based on the number of channels of the current client, so that the bandwidth utilization of the current client can reach a relatively balanced state as much as possible, thereby improving the bandwidth utilization; in addition, the sending and receiving of traffic is controlled based on the relationship between the actual bandwidth value and the average total bandwidth value, so that the traffic can be maximized as much as possible.
[0055] In addition, the present application also provides a device, a server, and a computer-readable storage medium for controlling traffic, which have the same or corresponding technical features as the above-mentioned method for controlling traffic, and have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0057] Figure 1 A flow chart of a method for controlling flow provided in an embodiment of the present application;
[0058] Figure 2 A structural diagram of a flow control device provided in one embodiment of the present application;
[0059] Figure 3 A structural diagram of a server provided in another embodiment of the present application;
[0060] Figure 4 A schematic diagram of the submodule composition of an SMB service subprocess and an SMB control subprocess provided in an embodiment of the present application;
[0061] Figure 5 A flowchart of a method for processing adaptive traffic balancing provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0063] The core of this application is to provide a method, device, server and medium for controlling traffic, so as to achieve balanced distribution of traffic and improve bandwidth utilization.
[0064] Samba multi-channel multi-threading is an SMB data stream processing system that utilizes the multi-channel characteristics of SMB, establishes multiple TCP connections between the client and the server, and processes each TCP connection separately in a working thread. Multiple TCP connections can ensure the maximum utilization of network bandwidth, and multiple channel threads can ensure that the server processes the SMB data stream received by each channel concurrently. The Samba service adopts a multi-process architecture, that is, a working mode of one main process + multiple business sub-processes. The main process is used to listen to the SMB connection of port 445. When a new client connection is received, a sub-process is created using the fork interface for the client alone. In addition, there are other sub-processes such as file change notification, file printing, and transparent fault service, which are used to perform various specific tasks.
[0065] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Figure 1 A flow chart of a method for controlling flow provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0066] S10: Obtain the total bandwidth value of the physical link and the total number of SMB channels of all clients.
[0067] The flow control method of the present application is mainly applied to storage servers. When a client requests data from a storage server, it is first necessary to establish a physical link between the client and the storage server. The bandwidth of a physical link refers to the number of bits that can be transmitted per second on each link. When multiple clients request data from a storage server, it is usually necessary to establish multiple physical links, and then the storage server transmits data to each client through the physical link. The client establishes multiple TCP connections with the server, and processes each TCP connection separately in an SMB data stream processing system of a working thread. Multiple TCP connections can ensure maximum utilization of network bandwidth, and multiple channel threads can ensure that the server concurrently processes the SMB data streams received by each channel. The number of SMB channels of each client may be the same or different. In order to distribute the traffic to each channel as evenly as possible, it is necessary to first obtain the total bandwidth value of the physical link and the total number of SMB channels of all clients.
[0068] S11: Obtain an average channel bandwidth value according to the total bandwidth value and the total number of SMB channels.
[0069] In the above steps, the total bandwidth value of the physical link and the total number of SMB channels of all clients are obtained. The bandwidth value of each channel can be obtained by dividing the total bandwidth value of the physical link by the total number of SMB channels, that is, the average channel bandwidth value here.
[0070] S12: Obtain an average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client.
[0071] In the above steps, the total bandwidth value is evenly distributed to each channel. In practice, since the number of channels established by each client may be different, the total amount of bandwidth that needs to be evenly distributed is also different. The data transmission rate of different channels of a single client may fluctuate above and below the average channel bandwidth. In order to avoid unnecessary data flow oscillation caused by positive and negative adjustments of a single client under different processing channels at the same time, the decision is made here based on the total bandwidth value of all channels of the client. Therefore, the average total bandwidth value of the current client can be obtained by multiplying the average channel bandwidth value by the number of channels of the current client.
[0072] S13: Obtain the actual bandwidth value of the current client;
[0073] S14: Control the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value.
[0074] The average total bandwidth value of the current client is obtained in the above steps, which can be considered as the theoretical bandwidth value of each client. In fact, the current client itself has an actual bandwidth value. If the actual bandwidth value is already greater than the calculated average total bandwidth value, there is no need to allocate traffic to the current client, and the current client does not need to receive traffic allocated by the storage server; if the actual bandwidth value is less than the calculated average total bandwidth value, traffic can be allocated to the current client, and the current client also needs to be allowed to receive traffic allocated by the storage server.
[0075] The method for controlling traffic provided in this embodiment includes: obtaining the total bandwidth value of the physical link and the total number of SMB channels of all clients; obtaining the average channel bandwidth value based on the total bandwidth value and the total number of SMB channels; obtaining the average total bandwidth value of the current client based on the average channel bandwidth value and the number of channels of the current client; obtaining the actual bandwidth value of the current client; and controlling the sending and receiving of traffic based on the relationship between the actual bandwidth value and the average total bandwidth value. In this method, the average channel bandwidth value is obtained based on the total bandwidth value of the physical link and the total number of SMB channels of all clients, so that bandwidth is evenly distributed among all SMB channels; bandwidth is allocated to the current client based on the number of channels of the current client, so that the bandwidth utilization of the current client can reach a relatively balanced state as much as possible, thereby improving bandwidth utilization; in addition, the sending and receiving of traffic is controlled based on the relationship between the actual bandwidth value and the average total bandwidth value, so that traffic can be maximized as much as possible.
[0076] In implementation, after the client sends a request to the storage server, in order to facilitate understanding of the request status of each client, a preferred implementation is that before obtaining the actual bandwidth value of the current client, the method for controlling traffic further includes:
[0077] When receiving the channel connection initiated by the client, a UNIX SOCKET connection is established between the current SMB service subprocess and the SMB control subprocess;
[0078] Add the response processing interface of the current SOCKET handle to the EPOLL event of the current SMB service subprocess;
[0079] When the current SMB service subprocess receives the access request sent by the client, the number of the current SMB service subprocess, the number of the current channel, and the requested data length are sent to the SMB control subprocess.
[0080] Statistics and collection of data traffic of each SMB business sub-process; after the SMB business sub-process is started, a single channel is used by default to process SMB business. If the Windows client SMB protocol version is greater than 3.0, multiple channel connections can be established between the client and the server; when the SMB data copy action is triggered, the client automatically initiates a new SMB channel connection, and then the server-side SMB business sub-process creates a separate thread to process the SMB channel connection.
[0081] When a new channel connection appears, the traffic information collection module automatically initiates a UNIX SOCKET connection to the SMB control child process. If the connection is successful, a response processing interface of the current SOCKET handle is added to the EPOLL event of the current child process.
[0082] When there is an SMB service access request, each channel receives the client SMB request separately, and according to the size of the received SMB request message, packages the SMB service process number (Process Identification, PID), the current channel number, and the data receiving rate of the current channel into a separate data structure, and then sends it to the SMB control subprocess.
[0083] The client provided in this embodiment sends a request to the SMB service subprocess, and then the SMB service subprocess packages the data and sends it to the SMB control subprocess. By collecting the traffic, the request status of each client can be understood.
[0084] In the above steps, the SMB service subprocess collects the flow information and then sends it to the SMB control subprocess. Similarly, in order to obtain the request status of each client in the SMB control subprocess, the preferred implementation is that after sending the number of the current SMB service subprocess, the number of the current channel, and the requested data length to the SMB control subprocess, the method for controlling the flow also includes:
[0085] When receiving a UNIX SOCKET connection initiated by the SMB service child process, a SOCKET handle is established and registered in the EPOLL event;
[0086] Get the service sub-process number corresponding to the SMB service sub-process according to the SOCKET handle;
[0087] Create a HASH summary table based on the business sub-process number;
[0088] When receiving the data flow information sent by the SMB service subprocess, parsing the data flow information to obtain the process number of the current SMB service subprocess, the channel number of the current SMB service subprocess, and the data flow information of each channel of the channel of the current SMB service subprocess;
[0089] According to the process number of the current SMB service sub-process, the corresponding current SMB service sub-process node is searched in the HASH summary table;
[0090] Append the data flow information of each channel of the current SMB service sub-process to the current SMB service sub-process node in a chain structure to form a new HASH summary table;
[0091] Correspondingly, obtaining the actual bandwidth value of the current client includes:
[0092] Traverse the new HASH summary table at a fixed frequency;
[0093] Get the actual bandwidth value of the current client based on the new HASH summary table.
[0094] The SMB control subprocess is directly started during the initialization of the main process. It contains a UNIX SOCKET submodule. The UNIX SOCKET submodule uses EPOLL loop to listen to each UNIX SOCKET connection. Whenever a SOCKET connection is received, a SOCKET handle is automatically established, and the SOCKET connection handle is registered in the EPOLL event. At the same time, the process PID of the SMB business subprocess is obtained according to the SOCKET handle. After the SOCKET relationship is established, the SMB business subprocess is equivalent to the client process of the SMB control subprocess. The SMB control subprocess stores the mapping relationship between the process PID and the process SOCKET handle in a global HASH summary table with the client subprocess PID as the keyword, so that when the feedback result is sent to the client subprocess, the corresponding SOCKET handle can be found according to the process number. When a SOCKET connection initiated by multiple channels of the same client is received again, the new SOCKET handle is stored in a chain structure under the data node corresponding to the current client PID.
[0095] When receiving the data flow information sent by the SMB business sub-process, first parse out the process PID, process channel number ChannelID, and data flow value FlowBytes, then use the process PID as the index, find the corresponding node in the HASH table, and append the flow information of each channel to the HASH node of the corresponding sub-process PID in a chain structure, and finally form a new HASH summary table.
[0096] When obtaining the actual bandwidth value of the current client, the new HASH summary table can be traversed, and the actual bandwidth value of the current client can be obtained according to the traffic information recorded in the new HASH summary table.
[0097] The present embodiment provides a method for aggregating the client's request information in a HASH table in the SMB control subprocess, so that the client subprocess PID can be used as a keyword to conveniently aggregate the traffic information of each channel. After the HASH table is established, it is convenient to find the corresponding SOCKET handle according to the PID when sending feedback results to the client subprocess, thereby improving the efficiency of controlling traffic.
[0098] Using the HASH summary table established in the above steps, the actual bandwidth value of the current client can be obtained according to the HASH summary table. Assuming that the fixed frequency is selected as 1s, the actual bandwidth value of the current client obtained according to the new HASH summary table includes:
[0099] Obtain the current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value from the new HASH summary table;
[0100] Get the actual bandwidth value of each channel based on the current flow value and the previous flow value;
[0101] Get the sum of the actual bandwidth values of each channel;
[0102] The sum of the actual bandwidth values of each channel is taken as the actual bandwidth value of the current client.
[0103] In practice, a timer can be used to obtain the real-time bandwidth value of the current client. The timer submodule is used to periodically calculate the total traffic value of business data. Since the lengths of different SMB request messages are different, in order to avoid the increase in calculation amount and frequent switching of the control process caused by frequent changes in data rate, the timer submodule selects the size of the SMB data collected in units of 1 second. For each PID and each channel data node used in the traversal process, the last traffic value last_val and the current traffic value current_val are saved. The difference between the current traffic value and the last traffic value can be used to calculate the bandwidth rate of the current PID and the current channel; when all channels under the same PID data node are traversed, the total bandwidth rate of the SMB business subprocess corresponding to the current PID can be calculated, which is the actual total bandwidth of the SMB business subprocess. It should be noted that since the current traffic value will be continuously overwritten by new data sent from the UNIX SOCKET connection of each channel, the current traffic value is immediately stored in the last traffic value field after accumulation.
[0104] The method for obtaining the real-time bandwidth value of the current client provided in this embodiment is that after each timer cycle arrives, the acquisition timer submodule reads and accumulates the data flow values of all SMB channels on each HASH node in a traversal manner. Since the timer cycle is set to 1 second, at this time, the accumulated result is equivalent to the real-time bandwidth value of the current client. Therefore, the real-time bandwidth value of the current client can be obtained conveniently and quickly.
[0105] In implementation, the control of traffic reception and transmission based on the relationship between the actual bandwidth value and the average total bandwidth value includes:
[0106] When the actual bandwidth value is greater than the average total bandwidth value, the feedback result mark is set as a signal for refusing to receive traffic; the signal for refusing to receive traffic is fed back to the SMB service subprocess; a rejection instruction is sent to the SOCKET handles of each channel of the SMB service subprocess; and each channel of the SMB service subprocess is controlled to temporarily close the reception of traffic according to the rejection instruction;
[0107] When the actual bandwidth value is less than the average total bandwidth value, the feedback result mark is set as a signal allowing traffic to be received; the signal allowing traffic to be received is fed back to the SMB business sub-process; an allow instruction is sent to the SOCKET handle of each channel of the SMB business sub-process; and each channel of the SMB business sub-process is controlled to receive traffic normally according to the allow instruction.
[0108] In the method for controlling the reception and transmission of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value provided in this embodiment, by feeding back the result and deciding whether to receive or reject the traffic, the traffic is finally received or rejected according to the decision result, so that the reception or rejection of the traffic can be controlled more reasonably.
[0109] In practice, when deciding whether to allow or deny the current client to receive traffic, it may be necessary to consider the current receiving state of the channel, and then reasonably control the reception or rejection of traffic. Therefore, a preferred implementation is that after sending a rejection instruction to the SOCKET handles of each channel of the SMB service subprocess, before controlling each channel of the SMB service subprocess to temporarily close the reception of traffic according to the rejection instruction, the method for controlling traffic also includes:
[0110] Get the current receiving status of the channel;
[0111] When the current receiving state is the rejection state, the rejection instruction is ignored;
[0112] When the current receiving state is the allowing state, the step of controlling each channel of the SMB service subprocess to temporarily close the receiving of traffic according to the reject instruction is entered;
[0113] Correspondingly, after sending the permission instruction to the SOCKET handles of each channel of the SMB service subprocess, before controlling each channel of the SMB service subprocess to normally receive traffic according to the permission instruction, the method for controlling traffic also includes:
[0114] Get the current receiving status of the channel;
[0115] When the current receiving state is the allowing state, the allowing instruction is ignored;
[0116] When the current receiving state is a rejection state, the process proceeds to a step of controlling each channel of the SMB service subprocess to receive traffic normally according to the permission instruction.
[0117] After the SMB channel is established, the current state of the channel may be either allowed or denied. The feedback received from the SMB control subprocess may be either allowed or denied, thus forming four combined adjustments.
[0118] a. The current receiving state is allowed, and the permission signal is received, and the feedback result is ignored;
[0119] b. The current receiving state is allowed. When a rejection signal is received, the service socket receiving of the channel is closed. At this time, the entire connection is not closed, but the reading operation will not be triggered temporarily.
[0120] c. The current receiving state is rejected, and the permission signal is received, and the service socket receiving of the channel is opened;
[0121] d. The current receiving state is rejection. A rejection signal is received and the feedback result is ignored.
[0122] This embodiment provides that after receiving the feedback result, the sending and receiving of the traffic is controlled in consideration of the current receiving state of the channel, so that the control of the traffic can be achieved more reasonably.
[0123] In implementation, in order to facilitate users to understand the sending and receiving of traffic, a preferred implementation mode is that after controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value, the method for controlling traffic further includes:
[0124] Outputs prompt information for indicating the collection and issuance status.
[0125] There is no limitation on the method, content, frequency, etc. of the prompt information, as long as the receiving and sending status can be prompted. Preferably, different prompt methods can be used for allowing and rejecting receiving, so that the user can quickly distinguish the receiving and sending status of the traffic according to the prompt information.
[0126] In the above embodiments, the method for controlling the flow is described in detail, and the present application also provides embodiments of the device and server for controlling the flow. It should be noted that the present application describes the embodiments of the device part from two perspectives, one is based on the perspective of the functional module, and the other is based on the perspective of the hardware.
[0127] Figure 2 This is a structural diagram of a flow control device provided in an embodiment of the present application. This embodiment is based on the perspective of functional modules and includes:
[0128] The first acquisition module 10 is used to obtain the total bandwidth value of the physical link and the total number of SMB channels of all clients;
[0129] The second acquisition module 11 is used to acquire the average channel bandwidth value according to the total bandwidth value and the total number of SMB channels;
[0130] The third acquisition module 12 is used to acquire the average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client;
[0131] The fourth acquisition module 13 is used to obtain the actual bandwidth value of the current client;
[0132] The control module 14 is used to control the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value.
[0133] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0134] The device for controlling traffic provided in this embodiment obtains the total bandwidth value of the physical link and the total number of SMB channels of all clients through the first acquisition module; obtains the average channel bandwidth value according to the total bandwidth value and the total number of SMB channels through the second acquisition module; obtains the average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client through the third acquisition module; obtains the actual bandwidth value of the current client through the fourth acquisition module; and controls the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value through the control module. In this device, the average channel bandwidth value is obtained according to the total bandwidth value of the physical link and the total number of SMB channels of all clients, so that the bandwidth is evenly distributed among all SMB channels; the bandwidth is allocated to the current client according to the number of channels of the current client, so that the bandwidth utilization of the current client can reach a relatively balanced state as much as possible, thereby improving the bandwidth utilization; in addition, the sending and receiving of traffic is controlled according to the relationship between the actual bandwidth value and the average total bandwidth value, so that the traffic can be maximized as much as possible.
[0135] Figure 3This is a structural diagram of a server provided in another embodiment of the present application. This embodiment is based on the hardware perspective, such as Figure 3 As shown, the server includes:
[0136] A memory 20, used for storing computer programs;
[0137] The processor 21 is used to implement the steps of the method for controlling flow mentioned in the above embodiment when executing the computer program.
[0138] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0139] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the method for controlling the flow disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the above-mentioned method for controlling the flow, etc.
[0140] In some embodiments, the server may further include a display screen 22 , an input / output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0141] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on the server, and may include more or fewer components than shown in the figure.
[0142] The server provided in the embodiment of the present application includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the following method: a method for controlling traffic, with the same effect as above.
[0143] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0144] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0145] The computer-readable storage medium provided in the present application includes the above-mentioned method for controlling flow, and the effect is the same as above.
[0146] In order to enable those skilled in the art to better understand the technical solution of the present application, Figure 4 And attached Figure 5 The above application is further described in detail. Figure 4 A schematic diagram of the submodule composition of an SMB service subprocess and an SMB control subprocess provided in an embodiment of the present application. Figure 4As shown, the schematic diagram includes an SMB control subprocess and two SMB business subprocesses. The two SMB business subprocesses are the first SMB business subprocess and the second business subprocess. The SMB business subprocess includes an SMB business information collection module 1 and an SMB transceiver rate control module 2; the SMB control subprocess includes an SMB flow information summary module 3, a HASH summary table, an SMB flow information decision module 4, and an SMB flow control result feedback module 5. The HASH summary table can facilitate the SMB flow information decision module 4 to make decisions on flow information.
[0147] Starting from the SMB traffic information collection module processing flow, the steps involved include the following:
[0148] Step 1: Start the SMB service main process on the storage node, then fork the SMB control subprocess from the main process, and start the UNIX SOCKET socket monitoring in the SMB control subprocess. The listening socket file path is / var / run / smb / flow.socket;
[0149] Step 2: The Windows client mounts the SMB service, and the SMB service main process forks an SMB business subprocess, which then establishes a TCP connection channel.
[0150] Step 3: The SMB traffic information collection module initiates a connection to the socket monitored by the SMB control subprocess. After the connection is successful, the socket handle returned by the connection is registered in the EPOLL event.
[0151] Step 4: When the SMB service subprocess receives the SMB request initiated by the Windows client, after successfully reading an SMB request, it calculates the length of the read data, and then sends the process PID, channel number ChannelID, and data length to the SMB control subprocess in real time;
[0152] Step 5: If the Windows client initiates a new channel connection during the data reading and writing process, repeat steps 2 to 4.
[0153] The SMB traffic information aggregation module is located in the SMB control subprocess. On the one hand, it is used to accept UNIX SOCKET connections from each channel of the SMB business subprocess, and on the other hand, it is used to aggregate the traffic statistics of each SMB business subprocess. The specific processing steps are as follows:
[0154] Step 1: When receiving a UNIX SOCKET connection initiated by an SMB service subprocess, register a processing interface based on the successfully connected SOCKET handle and obtain the PID of the SMB service subprocess;
[0155] Step 2: Use the business subprocess PID as the keyword and add the business subprocess as a separate data node to the HASH summary table maintained by itself;
[0156] Step 3: When a traffic transmission request is received from a business sub-process PID, the process PID, channel number ID, and received data length information are parsed and then added to the chain sub-node corresponding to the channel number of the PID data node.
[0157] Step 4: If the SMB service subprocess has multiple channels, the SMB control subprocess further adds multiple channel nodes to the current PID data node in the HASH summary table, and updates the total number of global SMB channels saved by itself;
[0158] When the SMB control subprocess starts, in addition to monitoring the UNIX SOCKET connection of the specified local path file, a 1-second period timer is started at the same time to execute the functional logic of the SMB traffic information decision module;
[0159] Step 1: The traffic information decision module traverses the HASH summary table every other counting cycle, which includes a double-layer loop traversal. The outer loop is used to traverse the PID data nodes corresponding to each SMB business sub-process, and the inner loop is used to traverse each chain channel node under each PID data node;
[0160] Step 2: When traversing to the data node of the specified PID and the specified channel, directly accumulate the current traffic statistics of the data node, and at the same time record and increment the total number of channels during the traversal process;
[0161] a. For each data node of each channel of each PID used in the traversal process, the last flow value last_val and the current flow value current_val are saved. The difference between the current flow value and the last flow value is used to calculate the bandwidth rate of the current PID and the current channel;
[0162] b. After all channels under the same PID data node are traversed, the total bandwidth rate of the SMB service subprocess corresponding to the current PID can be calculated;
[0163] c. Since the current flow value will be continuously overwritten by new data sent from each channel UNIX SOCKET connection, the current flow value is immediately stored in the previous flow value field after accumulation;
[0164] d. Based on the total bandwidth information of the physical link, divided by the total number of channels, the maximum allowable average bandwidth of each channel can be obtained; the average channel bandwidth multiplied by the number of channels of the corresponding PID data node can be obtained to obtain the maximum allowable bandwidth of the corresponding business subprocess;
[0165] Step 3: According to the actual total bandwidth of the SMB service subprocess and the maximum allowed total bandwidth calculated in step 2 b and d, decide how to feedback to the client. If the actual total bandwidth is greater than the maximum allowed total bandwidth, set the feedback result mark as a rejection signal; otherwise, set the feedback result as an allow signal;
[0166] After the traversal process, the flow information decision module calls the flow control result feedback module for each PID node that has been processed according to the processing result and sends it to the SMB business sub-process.
[0167] Step 1: The flow control result feedback module determines the processing result of each PID node. If it is a permission signal, it sends a permission instruction to the SOCKET handles of all channels under the PID node, indicating that all channels of the current SMB service subprocess can receive data normally;
[0168] Step 2: If it is a rejection signal, a rejection instruction is sent to the SOCKET handles of all channels under the PID node, instructing the SMB service subprocess to temporarily close data reception;
[0169] The SMB transceiver rate control module sets the working mode of the service socket by calling the EPOLL control interface;
[0170] Step 1: After the SMB channel is established, the SMB transceiver rate control module sets the initial data receiving state of the channel to allow;
[0171] Step 2: After receiving the feedback results from the control subprocess, it is divided into four combinations for adjustment;
[0172] The current receiving state is allowed, and the permission signal is received, and the feedback result is ignored;
[0173] The current receiving state is allowed. When a rejection signal is received, the service socket receiving of the channel is closed. At this time, the entire connection is not closed, but the reading operation will not be triggered temporarily.
[0174] The current receiving state is rejected. After receiving the permission signal, the service socket receiving of this channel is started.
[0175] The current receiving state is rejection. A rejection signal is received and the feedback result is ignored.
[0176] Figure 5 A flowchart of a method for processing adaptive traffic balancing provided in an embodiment of the present application.
[0177] like Figure 5 As shown, the method includes:
[0178] S15: SMB multi-channel establishment;
[0179] S16: Initiate UNIX SOCKET connection;
[0180] S17: Send PID, channel ID, data, and traffic;
[0181] S18: traffic collection and aggregation;
[0182] S19: flow mean calculation;
[0183] S20: SMB service control.
[0184] It can be seen that the processing method for adaptive traffic balancing provided in this embodiment adopts the method of separating the SMB control subprocess and the business subprocess. In the decision-making process of the SMB control subprocess, the maximum bandwidth of the entire physical link is calculated, allocated and controlled, and the total number of SMB channels is used as a weight. The maximum bandwidth allowed by different clients is determined according to the total number of established SMB channels; finally, different SMB business data flow receiving modes are adopted according to the average bandwidth result and the actual total bandwidth result of the business process, so as to play an adaptive balancing adjustment role on the overall bandwidth usage of all SMB clients on the storage node.
[0185] The above is a detailed introduction to a method, device, server and medium for controlling traffic provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
[0186] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A method for controlling flow, characterized in that: include: Get the total bandwidth value of the physical link and the total number of SMB channels of all clients; Obtain an average channel bandwidth value according to the total bandwidth value and the total number of SMB channels; Obtaining an average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client; Obtaining the actual bandwidth value of the current client; Controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value; Before obtaining the actual bandwidth value of the current client, the method further includes: When the current SMB service subprocess receives the access request sent by the client, the number of the current SMB service subprocess, the number of the current channel, and the requested data length are sent to the SMB control subprocess; When receiving the data flow information sent by the SMB service subprocess, parsing the data flow information to obtain the data flow information of each channel of the channel of the current SMB service subprocess; Obtaining the actual bandwidth value of the current client includes: Obtain the current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value; Acquire the actual bandwidth value of each of the channels according to the current flow value and the previous flow value; Obtaining the sum of actual bandwidth values of each of the channels; The sum of the actual bandwidth values of the channels is used as the actual bandwidth value of the current client.
2. The method for controlling flow according to claim 1, characterized in that: Before obtaining the actual bandwidth value of the current client, the method further includes: When receiving the channel connection initiated by the client, establishing a UNIX SOCKET connection between the current SMB service subprocess and the SMB control subprocess; Add a response processing interface of the current SOCKET handle to the EPOLL event of the current SMB service subprocess.
3. The method for controlling flow according to claim 2, characterized in that: After sending the number of the current SMB service subprocess, the number of the current channel, and the requested data length to the SMB control subprocess, the method further includes: When receiving the UNIX SOCKET connection initiated by the SMB service subprocess, establishing a SOCKET handle and registering the SOCKET handle in the EPOLL event; Obtaining the service sub-process number corresponding to the SMB service sub-process according to the SOCKET handle; Create a HASH summary table according to the business sub-process number; When receiving the data flow information sent by the SMB service sub-process, parsing the data flow information to obtain the process number of the current SMB service sub-process and the channel number of the current SMB service sub-process; According to the process number of the current SMB service sub-process, searching the HASH summary table for the corresponding current SMB service sub-process node; Appending the data flow information of each channel of the current SMB service subprocess to the current SMB service subprocess node in a chain structure to form a new HASH summary table; Correspondingly, obtaining the actual bandwidth value of the current client includes: Traversing the new HASH summary table at a fixed frequency; The actual bandwidth value of the current client is obtained according to the new HASH summary table.
4. The method for controlling flow according to claim 3, characterized in that: The fixed frequency is 1s, and the obtaining of the current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value includes: The current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value are obtained from the new HASH summary table.
5. The method for controlling flow according to claim 4, characterized in that: The step of controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value includes: In the case where the actual bandwidth value is greater than the average total bandwidth value, the feedback result mark is set as a signal for refusing to receive the traffic; the signal for refusing to receive the traffic is fed back to the SMB service subprocess; a rejection instruction is sent to the SOCKET handles of each channel of the SMB service subprocess; and each channel of the SMB service subprocess is controlled to temporarily close the reception of the traffic according to the rejection instruction; When the actual bandwidth value is less than the average total bandwidth value, the feedback result mark is set as a signal allowing the traffic to be received; the signal allowing the traffic to be received is fed back to the SMB business sub-process; an allow instruction is sent to the SOCKET handles of each channel of the SMB business sub-process; and each channel of the SMB business sub-process is controlled to normally receive the traffic according to the allow instruction.
6. The method for controlling flow according to claim 5, characterized in that: After sending a rejection instruction to the SOCKET handles of each channel of the SMB service subprocess, and before controlling each channel of the SMB service subprocess to temporarily close the reception of the traffic according to the rejection instruction, the method further includes: Get the current receiving status of the channel; When the current receiving state is a rejection state, ignoring the rejection instruction; In the case where the current receiving state is the allowing state, the step of controlling each channel of the SMB service subprocess to temporarily close the receiving of the traffic according to the reject instruction is entered; Correspondingly, after sending the allow instruction to the SOCKET handles of each channel of the SMB service subprocess, and before controlling each channel of the SMB service subprocess to normally receive the traffic according to the allow instruction, the method further includes: Obtain the current receiving state of the channel; When the current receiving state is the allowing state, ignoring the allowing instruction; When the current receiving state is the rejecting state, the step of controlling each channel of the SMB service subprocess to normally receive the traffic according to the allowing instruction is entered.
7. The method for controlling flow according to any one of claims 1 to 6, characterized in that: After controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value, the method further includes: Outputs prompt information for indicating the collection and issuance status.
8. A flow control device, characterized in that: include: The first acquisition module is used to obtain the total bandwidth value of the physical link and the total number of SMB channels of all clients; A second acquisition module is used to acquire an average channel bandwidth value according to the total bandwidth value and the total number of SMB channels; A third acquisition module, configured to acquire an average total bandwidth value of the current client according to the average channel bandwidth value and the number of channels of the current client; A fourth acquisition module is used to obtain the actual bandwidth value of the current client; A control module, used for controlling the sending and receiving of traffic according to the relationship between the actual bandwidth value and the average total bandwidth value; Also includes: When the current SMB service subprocess receives the access request sent by the client, the number of the current SMB service subprocess, the number of the current channel, and the requested data length are sent to the SMB control subprocess; When receiving the data flow information sent by the SMB service subprocess, parsing the data flow information to obtain the data flow information of each channel of the channel of the current SMB service subprocess; The fourth acquisition module is specifically used to obtain the current flow value corresponding to each channel under the process number of the current SMB service subprocess and the previous flow value of the current flow value; Acquire the actual bandwidth value of each of the channels according to the current flow value and the previous flow value; Obtaining the sum of actual bandwidth values of each of the channels; The sum of the actual bandwidth values of the channels is used as the actual bandwidth value of the current client.
9. A server, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for controlling flow as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for controlling flow as claimed in any one of claims 1 to 7 are implemented.
