Method and device for counting link bandwidth
By introducing pulse generators and latch registers into link layer hardware and latch link layer statistical information, the problem of lack of real-time and authenticity of link bandwidth statistics in the prior art is solved, and zero error and real-time nature of link bandwidth statistics are achieved.
Patent Information
- Application Number
- CN202411622313.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In the prior art, when stating link bandwidth, software needs multiple clock cycles to read hardware registers through the CPU, resulting in traffic statistics that may seriously deviate from the timer moment, lacking real-timeness and authenticity.
By introducing a pulse generator into the link layer hardware, using the CPU to notify the pulse generator to generate pulses, and latch the timer value and flow statistics value at the pulse time, the software can read the exact latch value and calculate the link bandwidth.
It realizes zero error in link bandwidth statistics, has real-time performance, can truly reflect the bandwidth status of network equipment, and accurately evaluate network performance.
Smart Images

Figure CN119520292A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network transmission, and in particular to a method and device for counting link bandwidth. Background Art
[0002] Link bandwidth statistics play a vital role in network device management and are of great significance for network performance evaluation, optimization, and troubleshooting. Device administrators use link bandwidth to evaluate the transmission capacity of network links and determine whether the network data transmission capacity can meet business needs. Accurate link bandwidth information can reflect the actual transmission capacity of network links in real time, helping device administrators to formulate sophisticated load balancing strategies to ensure the reasonable allocation and efficient use of network resources.
[0003] From the perspective of the device chip, link bandwidth statistics are a collaborative process between software and hardware. The usual practice is for the software layer to obtain the data flow through the link layer over a period of time, and calculate the link data transmission volume per unit time to obtain the bandwidth. Figure 1 For example, when designing chip hardware, it is necessary to add statistical registers to the link layer. The software reads the statistical registers of the internal hardware of the link layer through the CPU (central processing unit) to obtain link traffic statistics, and then performs arithmetic calculations based on the time difference to obtain link bandwidth statistics.
[0004] However, in actual operation, it usually takes dozens or even hundreds of clock cycles for the software to read the internal hardware registers through the CPU. When there are many link layer statistical registers, the time difference corresponding to each counter (CNT) obtained by the software may reach milliseconds or even seconds. The obtained traffic statistics may seriously deviate from the corresponding timer time. The error in the statistical data obtained by the software causes the obtained link bandwidth statistics to lack real-time and authenticity. Summary of the invention
[0005] The purpose of the present application is to provide a method and device for counting link bandwidth, aiming to achieve accurate link bandwidth statistics.
[0006] According to a first aspect of the present application, a method for counting link bandwidth is provided, comprising:
[0007] When the software issues a read request for the first time, in response to the CPU notifying the pulse generator for the first time to generate a first pulse, and latching a first timing value corresponding to the first pulse moment, a first receiving flow value counted by the receiving end, and a first sending flow value counted by the sending end;
[0008] When the software issues a read request again, in response to the CPU notifying the pulse generator again to generate a second pulse, and latching a second timing value corresponding to the second pulse moment, a second receiving flow value counted by the receiving end, and a second sending flow value counted by the sending end;
[0009] Based on the first receiving traffic value, the first sending traffic value, the second receiving traffic value, and the second sending traffic value, a link bandwidth in a time period from the first timing value to the second timing value is determined.
[0010] In an optional implementation manner, before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value, the method further includes:
[0011] The first timing value, the first receiving flow value, and the first sending flow value are acquired in sequence through the CPU and the on-chip bus using a software program.
[0012] In an optional implementation manner, before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first timing value, the first received flow value, the first sent flow value, and the second timing value, the second received flow value, and the second sent flow value, the method further includes:
[0013] The second timing value, the second receiving flow value and the second sending flow value are sequentially acquired through the CPU and the on-chip bus using a software program.
[0014] In an optional implementation, determining the link bandwidth for a time period from the first timing value to the second timing value based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value further includes:
[0015] Calculate the link bandwidth using the following formula:
[0016]
[0017] Where T1 and T2 are the first timing value and the second timing value respectively, RX _ CNT _ T1, TX_CNT_T1, RX_CNT_T2, and TX_CNT_T2 are respectively the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
[0018] In an optional embodiment, the method further comprises:
[0019] According to the protocol requirements and the statistical requirements, the traffic of the receiving end and the traffic of the sending end are classified and counted.
[0020] According to a second aspect of the present application, a device for counting link bandwidth is provided, including:
[0021] A first statistical unit is used for generating a first pulse in response to the CPU notifying the pulse generator for the first time when the software issues a read request for the first time, and latching a first timing value corresponding to the first pulse moment, a first receiving flow value counted by the receiving end, and a first sending flow value counted by the sending end;
[0022] A second statistical unit is used for, when the software issues a read request again, responding to the CPU notifying the pulse generator again to generate a second pulse, and latching a second timing value corresponding to the second pulse moment, a second receiving flow value counted by the receiving end, and a second sending flow value counted by the sending end;
[0023] The determining unit is configured to determine a link bandwidth in a time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
[0024] In an optional implementation manner, the first statistical unit and the second statistical unit are further configured to:
[0025] The first pulse and the second pulse are generated by the built-in pulse generator of the chip when a notification from the CPU is received.
[0026] In an optional implementation manner, the determining unit is further configured to:
[0027] Before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value:
[0028] Using a latch register to latch the first timing value, the first receiving flow value, and the first sending flow value;
[0029] Using a software program to sequentially obtain the first timing value, the first receiving flow value, and the first sending flow value through the CPU and the on-chip bus;
[0030] Latching the second timing value, the second receiving flow value, and the second sending flow value using a latch register;
[0031] The second timing value, the second receiving flow value and the second sending flow value are sequentially acquired through the CPU and the on-chip bus using a software program.
[0032] In an optional implementation manner, the determining unit is further configured to:
[0033] Calculate the link bandwidth using the following formula:
[0034]
[0035] Where T1 and T2 are the first timing value and the second timing value respectively, RX _ CNT _ T1, TX _ CNT _ T1, RX _ CNT _ T2, TX _ CNT _ T2 are respectively the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
[0036] Compared with the related art, the technical solution of this application has the following advantages:
[0037] The statistics of the received and sent packet traffic used for bandwidth statistics are accurately aligned with the time, and zero error in link bandwidth statistics is achieved through accurate hardware traffic statistics; it is applicable to various communication protocols such as PCIE, Ethernet, InfiniBand, SAS, etc., and the method is highly portable; the solution of this application is an internal hardware design solution of the chip, which does not require complex operations of the system software and is friendly to chip firmware development; the bandwidth statistics are real-time, can truly reflect the bandwidth status of the network equipment, and accurately evaluate the performance status of the network.
[0038] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained through the structures and processes indicated in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. It is obvious that the drawings described below are certain 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.
[0040] Figure 1 It is a chip link layer hardware design architecture diagram based on relevant technologies.
[0041] Figure 2 is a timing diagram of the latch operation of the timer and the traffic statistics register according to the present application.
[0042] Figure 3 It is a flowchart of the method for counting link bandwidth according to the present application.
[0043] Figure 4 Chip link layer hardware design architecture diagram according to this application. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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.
[0045] As described above, the packet receiving and sending traffic acquisition method in the related art leads to real time deviation in bandwidth statistics, and this time deviation cannot be avoided. Especially in high-speed networks, the impact on link bandwidth statistics cannot be ignored, which may cause equipment administrators to misjudge transmission performance.
[0046] When counting the bandwidth of the link layer, the software needs to obtain the packet traffic for a period of time. The inventor found that if the packet traffic obtained by the software at time T1 is precisely aligned with time T1, and the packet traffic obtained at time T2 is precisely aligned with time T2, the accurate traffic bandwidth in the T1-T2 time period can be obtained, and then accurate bandwidth data can be obtained.
[0047] Based on the above analysis, the present application provides a method and device for counting link bandwidth. For example, Figure 2 As shown in the figure, the chip hardware implements the timer and RX / TX traffic statistics register. When the CPU notifies the pulse generator to latch the statistics, the internal hardware latches the timer and the traffic statistics corresponding to that moment, and the software can read the latched value without time difference at that moment. Therefore, the software can obtain the accurate RX / TX traffic statistics corresponding to T1 and T2 respectively, and then obtain the accurate bandwidth data of the T1-T2 time period.
[0048] See also Figure 3 Flow chart, illustratively, the method for counting link bandwidth provided by the present application includes:
[0049] Step 301: When the software issues a read request for the first time, in response to the first notification from the CPU, the pulse generator generates a first pulse and latches the first timing value corresponding to the first pulse moment, the first receiving flow value counted by the receiving end, and the first sending flow value counted by the sending end.
[0050] After the system is powered on and reset, the link layer is established and enters normal working state. At this time, the software can obtain internal link layer statistics through the CPU, the CPU notifies the pulse generator to generate a pulse, and the internal hardware latches the timer corresponding to the pulse moment, the RX flow value of the receiving end, and the TX flow value of the sending end.
[0051] like Figure 4 As shown, exemplarily, when the hardware is implemented inside the chip, a pulse generator, a timer, an RX traffic counter, a TX traffic counter and corresponding latch registers are set inside the chip. When the link layer works normally, the timer timer is timed according to the internal clock, the RX traffic counter is counted in real time according to the packet receiving situation, and the TX traffic counter is counted in real time according to the packet sending situation. The pulse generator generates a pulse when receiving a notification from the CPU, and latches the corresponding timer, RX traffic, and TX traffic into the latch register according to the pulse. The software obtains the latch values one by one through the CPU and the internal bus. At this time, the RX traffic value and TX traffic value obtained by the software are accurately aligned with the corresponding timer moment. The CPU notification method involved in the specific implementation method of the present application includes the CPU operating the control register of the pulse generator through the internal bus, or the CPU notifying the module to generate a pulse in the form of an interrupt.
[0052] The software obtains the latched timer, RX flow value, and TX flow value through the CPU and the internal bus, which are recorded as T1, RX_CNT_T1, and TX_CNT_T1 respectively.
[0053] Step 302: When the software issues a read request again, in response to the CPU notifying again, the pulse generator generates a second pulse, and latches the second timing value corresponding to the moment of the second pulse, the second receiving flow value counted by the receiving end, and the second sending flow value counted by the sending end.
[0054] Similarly, the software reads the internal link layer statistics through the CPU again, generates a pulse again in the chip, and latches the timer, RX traffic value, and TX traffic value corresponding to the pulse time again, which are recorded as T2, RX_CNT_T2, and TX_CNT_T2, respectively.
[0055] Step 303: Based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value, determine the link bandwidth of the time period from the first timing value to the second timing value.
[0056] After obtaining the above data, accurate bandwidth statistics within the time period can be obtained through arithmetic calculation.
[0057] For example, the calculation formula may be as follows:
[0058]
[0059] The above RX and TX traffic statistics counters can be classified into CNT 0 ~CNT x, can be classified according to protocol requirements and custom statistical requirements. For example, it can be classified according to the information type of the data packet, and the information type can be a data packet, a management packet, and a flow control packet. In an optional embodiment, it can be classified according to the quality level of the data packet, and the quality level can be a good packet, a bad packet, a retransmission packet, etc.
[0060] Accordingly, the traffic values in each time period are calculated by classification, and the link bandwidth is calculated as follows:
[0061] [(RX_CNT 0 _T2-RX_CNT 0 _T1)+(RX_CNT 1 _T2-RX_CNT 1 _T1)+…+(RX_CNT x _T2-RX_CNTx_T1)+(TX_CNT 0 _T2-TX_CNT 0 _T1)+(TX_CNT 1 _T2-TX_CNT 1 _T1)+…+(TX_CNT x _T2-TX_CNT x _T1)] / (T2-T1)
[0062] As a preferred embodiment, the hardware bit width of the on-chip timer should satisfy the time difference interval between T1 and T2, and the hardware bit width of the RX and TX counters should satisfy the traffic statistics within this period to prevent counting overflow.
[0063] It can be seen that the method for calculating link bandwidth statistics provided by this application has the following advantages over related technologies:
[0064] The bandwidth of the received and sent packet traffic is precisely aligned with the time, and zero error in link bandwidth statistics is achieved through accurate hardware traffic statistics; it is applicable to multiple communication protocols such as PCIE, Ethernet, InfiniBand, SAS, etc., and the method is highly portable; the solution of this application is an internal chip hardware design solution, which does not require complex operations of the system software and is friendly to chip firmware development; the statistical process is real-time, can truly reflect the bandwidth status of the network equipment, and accurately evaluate the performance status of the network.
[0065] Accordingly, the present application provides an exemplary device for counting link bandwidth in a second aspect, including:
[0066] A first statistical unit, configured to generate a first pulse by a pulse generator in response to a first notification from the CPU when the software issues a read request for the first time, and latch a first timing value corresponding to the first pulse moment, a first receiving flow value counted by the receiving end, and a first sending flow value counted by the sending end;
[0067] A second statistical unit is used for generating a second pulse by the pulse generator in response to the CPU notifying again when the software issues a read request again, and latching a second timing value corresponding to the second pulse moment, a second receiving flow value counted by the receiving end, and a second sending flow value counted by the sending end;
[0068] The determining unit is configured to determine a link bandwidth in a time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
[0069] The above-mentioned device can be implemented by the method for counting link bandwidth provided by the embodiment of the first aspect above. The specific implementation method can be found in the description of the embodiment of the first aspect, and will not be repeated here.
[0070] It is understood that the circuit structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily combine and adjust the structural features of the above embodiments according to the use requirements, and should not limit the concept of the present application to the specific details of the above examples.
[0071] Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that he or she may still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for calculating link bandwidth statistics, characterized in that: include: When the software issues a read request for the first time, in response to the first notification from the CPU, the pulse generator generates a first pulse, and latches a first timing value corresponding to the first pulse moment, a first receiving flow value counted by the receiving end, and a first sending flow value counted by the sending end; When the software issues a read request again, in response to the CPU notifying again, the pulse generator generates a second pulse, and latches a second timing value corresponding to the second pulse moment, a second receiving flow value counted by the receiving end, and a second sending flow value counted by the sending end; Based on the first receiving traffic value, the first sending traffic value, the second receiving traffic value, and the second sending traffic value, a link bandwidth in a time period from the first timing value to the second timing value is determined.
2. The method for calculating link bandwidth statistics according to claim 1, characterized in that: Before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value, the method further includes: The first timing value, the first receiving flow value, and the first sending flow value are acquired in sequence through the CPU and the on-chip bus using a software program.
3. The method for calculating link bandwidth statistics according to claim 1, characterized in that: Before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value, the method further includes: The second timing value, the second receiving flow value and the second sending flow value are sequentially acquired through the CPU and the on-chip bus using a software program.
4. The method for calculating link bandwidth statistics according to claim 1, characterized in that: The determining of the link bandwidth of the time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value further includes: Calculate the link bandwidth using the following formula: Where T1 and T2 are the first timing value and the second timing value respectively, RX _ CNT _ T1, TXCNTT1, RXCNTT2, and TXCNTT2 are respectively the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
5. The method for calculating link bandwidth statistics according to claim 1, characterized in that: The method further includes: According to the protocol requirements and the statistical requirements, the traffic of the receiving end and the traffic of the sending end are classified and counted.
6. A device for counting link bandwidth, characterized in that: include: A first statistical unit is used for generating a first pulse in response to the CPU notifying the pulse generator for the first time when the software issues a read request for the first time, and latching a first timing value corresponding to the first pulse moment, a first receiving flow value counted by the receiving end, and a first sending flow value counted by the sending end; A second statistical unit is used for, when the software issues a read request again, responding to the CPU notifying the pulse generator again to generate a second pulse, and latching a second timing value corresponding to the second pulse moment, a second receiving flow value counted by the receiving end, and a second sending flow value counted by the sending end; The determining unit is configured to determine a link bandwidth in a time period from the first timing value to the second timing value based on the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
7. The device for counting link bandwidth according to claim 6, characterized in that: The determining unit is further configured to: Before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value: The first timing value, the first receiving flow value, and the first sending flow value are acquired in sequence through the CPU and the on-chip bus using a software program.
8. The device for counting link bandwidth according to claim 6, characterized in that: The determining unit is further configured to: Before determining the link bandwidth of the time period from the first timing value to the second timing value based on the first received traffic value, the first sent traffic value, the second received traffic value, and the second sent traffic value: The second timing value, the second receiving flow value and the second sending flow value are sequentially acquired through the CPU and the on-chip bus using a software program.
9. The device for counting link bandwidth according to claim 6, characterized in that: The determining unit is further configured to: Calculate the link bandwidth using the following formula: Where T1 and T2 are the first timing value and the second timing value respectively, RX _ CNT _ T1, TX _ CNT _ T1, RX _ CNT _ T2, TX _ CNT _ T2 are respectively the first receiving flow value, the first sending flow value, the second receiving flow value, and the second sending flow value.
10. The device for counting link bandwidth according to claim 6, characterized in that: The device is further used for: According to the protocol requirements and the statistical requirements, the traffic of the receiving end and the traffic of the sending end are classified and counted.
Citation Information
Patent Citations
Network time protocol precision timestamping service
CN101449520A
Flow rate display device
JP1989311232A
Method and device for transmitting physical quantity data, and system and instrument for flow rate measurement
JP2001188983A