WO2020142867A1 - Traffic shaping method and related device - Google Patents

Traffic shaping method and related device Download PDF

Info

Publication number
WO2020142867A1
WO2020142867A1 PCT/CN2019/070594 CN2019070594W WO2020142867A1 WO 2020142867 A1 WO2020142867 A1 WO 2020142867A1 CN 2019070594 W CN2019070594 W CN 2019070594W WO 2020142867 A1 WO2020142867 A1 WO 2020142867A1
Authority
WO
WIPO (PCT)
Prior art keywords
token
bucket
port
scheduling
amount
Prior art date
Application number
PCT/CN2019/070594
Other languages
French (fr)
Chinese (zh)
Inventor
杨一波
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201980065232.6A priority Critical patent/CN112805971B/en
Priority to PCT/CN2019/070594 priority patent/WO2020142867A1/en
Publication of WO2020142867A1 publication Critical patent/WO2020142867A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/22Traffic shaping

Definitions

  • the present invention relates to the field of communication technology, and in particular, to a traffic shaping method and related equipment.
  • the scheduler In the data transmission scenario, due to the limited sending capacity/bandwidth of the output port, the scheduler needs to ensure that the average bandwidth of the scheduled data cannot exceed the load bandwidth of the output port. It mainly consists of two parts. On the one hand, the scheduler is used to separate the data to be sent according to specific rules (such as calendar algorithm, weighted round robin (WRR), weighted fair queueing, weighted fair queueing, WFQ) etc.) dispatched to the output port. Taking calendar as an example, the output port scheduling specifications generally use time division multiplexing scheduling.
  • WRR weighted round robin
  • WFQ weighted fair queueing
  • the basic principle is that the user configures the calendar calendar table in advance, where the scheduling result of each scheduling is directly pre-configured, and the data structure is directly polled according to the working clock cycle during working hours For each data in the data, if other conditions are met (such as the traffic shaping conditions below, etc.), the scheduling result is directly obtained, otherwise the scheduling result is invalid this time, and the next data continues to be polled in the next clock cycle.
  • the other is to use traffic shaping to control the data output bandwidth of each port queue.
  • the industry has included a variety of methods to complete traffic shaping.
  • the token bucket mechanism is used to restrict data transmission.
  • the basic principle of token communication is shown in Figures 1A and 1B.
  • the data stream When the data stream needs to be output, it will first take out the number of tokens corresponding to the data size from the token bucket according to the size of the data to transmit data. That is to say, for data to be transmitted, there must be enough tokens in the token bucket. If the number of tokens is not enough, the data will be discarded or cached. This can limit the data flow to be less than or equal to the speed of token generation, thereby achieving the purpose of limiting traffic.
  • the average bandwidth of data transmission is equal to the bucket filling speed, and the bucket depth of the token bucket is the maximum transmission burst size. At present, the more frequently used token bucket filling scheme is the regular bucket filling.
  • the basic principle of timed bucket filling is that the filling time of each token bucket is fixed, and different bandwidths can be achieved by configuring different numbers of bucket filling tokens.
  • this algorithm at least the following data structures need to be introduced: the number of tokens in the current token bucket, the filling value per unit time, used to determine the time count of the filling time, and the maximum bucket depth of the token bucket. Considering that there are multiple ports in the device, it is logically that multiple ports set their respective token bucket control bandwidths.
  • a typical design is to share a token bucket circuit, store the data structure of different ports in different addresses of memory (such as static random-access memory (SRAM)), and fill the bucket with time-division multiplexing , Bucket deduction operation (that is, the operation of deducting tokens from the token bucket).
  • the bucket filling period needs to be greater than the number of ports, and each token bucket is filled at most once in each bucket filling period, so as to ensure that bucket filling requests of different ports do not conflict in time.
  • the typical value of the bucket filling period is: the bucket filling period is equal to min ⁇ port number r, 2 ⁇ q ⁇ , where q takes a value that satisfies 2 ⁇ q>r.
  • the embodiments of the present invention disclose a traffic shaping method and related equipment, which can significantly reduce the implementation cost.
  • an embodiment of the present application provides a traffic shaping method.
  • the method includes:
  • the device obtains the scheduling cycle of the scheduler and the bucket filling cycle of the token bucket, where the number of clock cycles included in the token bucket filling cycle is equal to the number of clock cycles included in the scheduler's scheduling cycle;
  • the device schedules the X output ports of the device according to the scheduling period and fills the token bucket according to the bucket filling period, wherein the first port occupies the scheduling period
  • the number of clock cycles is positively related to the ratio of the bandwidth of the first port to the total output bandwidth of the device.
  • the first port is any one of the output ports of the device, and X is greater than or A positive integer equal to 1.
  • the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth
  • the implementation cost of configuring a larger bucket depth is reduced.
  • the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
  • the device schedules the X output ports of the device according to the scheduling cycle and the token according to the bucket filling cycle Bucket filling, including:
  • the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
  • the token parameter further includes a second token parameter, where the second token parameter includes The remaining token amount K, the first token amount n1 and the flag bit parameters, wherein the initial value of the remaining token amount K in the second token and the remaining token amount K in the first token The initial value is different, the first token amount n1 in the second token is different from the first token amount n1 in the first token; the first token parameter is used in the first port
  • the bandwidth of the token bucket is used as the basis for filling the token bucket with the token bandwidth unchanged, and the second token parameter is used as a basis for filling the token bucket with the token bucket after the bandwidth of the first port is changed.
  • multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes.
  • This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order
  • the parameter types of the card parameters are the same, that is, the specific values may be different.
  • the parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
  • the device outputs X output ports of the device according to the scheduling period Scheduling and bucket filling the token bucket according to the bucket filling cycle include:
  • Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
  • a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle
  • the values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
  • an embodiment of the present application provides a traffic shaping device.
  • the device includes a processing unit, a scheduler, and X output ports.
  • X is a positive integer greater than or equal to 1, where:
  • the processing unit is configured to obtain a scheduling period of the scheduler and a bucket filling period of the token bucket, where the number of clock cycles included in the token bucket filling period and the clock period included in the scheduler scheduling period Equal number
  • a scheduler configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, wherein the first port occupies the scheduling period
  • the number of clock cycles is positively related to the proportion of the bandwidth of the first port in the total output bandwidth of the device, and the first port is any one of the X output ports.
  • the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth
  • the implementation cost of configuring a larger bucket depth is reduced.
  • the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
  • the scheduler is configured to schedule the X output ports according to the scheduling period and the order according to the bucket filling period Filling the bucket with a brand bucket, including:
  • the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
  • the token parameter further includes a second token parameter, where the second token parameter includes a remaining order The card amount K, the first token amount n1 and the mark bit parameters, wherein the initial value of the remaining token amount K in the second token is different from the initial value of the remaining token amount K in the first token, The first token amount n1 in the second token is different from the first token amount n1 in the first token; the first token parameter is used for the bandwidth of the first port unchanged Is used as a basis for token bucket to fill bucket tokens, and the second token parameter is used as a basis for token bucket to fill bucket tokens after the bandwidth of the first port is changed.
  • multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes.
  • This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order
  • the parameter types of the card parameters are the same, that is, the specific values may be different.
  • the parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
  • the scheduler is configured to check the X number according to the scheduling period
  • the scheduling of the output port and the bucket filling of the token bucket according to the bucket filling period include:
  • Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
  • a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle
  • the values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
  • the order The bucket filling cycle of the brand bucket is synchronized with the scheduling cycle of the scheduler. It can be understood that this can make the scheduling (along with buckling buckets) highly match the bucket filling, that is, the bucket filling is completed once when the scheduling is completed once per clock cycle, which can minimize the bucket depth.
  • the first The number of clock cycles h occupied by a port in the scheduling period satisfies the following formula:
  • H is the number of clock cycles included in the scheduling period
  • s1 is the bandwidth of the first port
  • S is the total output bandwidth
  • the scheduling period occupied by the first port is determined according to the ratio of the bandwidth of the first port to the total output bandwidth. In this way, the number of clock cycles and bandwidth occupied by each output port during scheduling can be made The actual needs are matched as much as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
  • the total amount of tokens m filled into the token bucket satisfies the following formula:
  • f is the working clock frequency of the device.
  • the total number of tokens required for the first port to fill the bucket during the scheduling period is determined according to the bandwidth of the first port. In this way, each output port can fill the tokens in the bucket during the scheduling process
  • the volume and its actual bandwidth requirements are matched as closely as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
  • the scheduling The number of clock cycles H included in the cycle satisfies the following formula:
  • S is the total output bandwidth of the device
  • t is the least common divisor of the bandwidth of each output port of the device
  • p is the total number of ports of each output port of the device
  • f is the operating clock frequency of the device .
  • the first term in the formula minimizes the waste of output port bandwidth
  • the second term ensures that each port can have a scheduling opportunity in each scheduling cycle
  • the third term can ensure that each time
  • the amount of bucket tokens is an integer, which can be realized by a simple circuit, that is, the implementation cost is reduced.
  • an embodiment of the present application provides a device including a processor, a storage device, an output device, and a motherboard, each device is connected to the motherboard through a bus or soldering or other electrical connection, and the output device includes a scheduler .
  • the processor controls the output device to perform traffic shaping and scheduling by calling the program stored in the memory.
  • an embodiment of the present application provides a computer-readable storage medium that stores program instructions, and when the program instructions run on a processor, implement the first aspect, or the first The method described in any possible implementation of aspects.
  • FIG. 1A is a schematic diagram of a principle of a token bucket provided by an embodiment of the present invention.
  • 1B is a schematic diagram of another principle of a token bucket provided by an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a data stream transmission provided by an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a data flow scheduling and shaping provided by an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a traffic shaping device provided by an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a traffic shaping method according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of yet another flow shaping device provided by an embodiment of the present invention.
  • the invention is applied to network equipment, and the network equipment mainly completes the functions of transmission and processing of network data frames.
  • a network switching device such as a switch, a router, etc.
  • the network device needs to complete functions such as data receiving input, forwarding, switching, traffic management, and traffic output.
  • a typical process is shown in Figure 3. Specifically, considering the length of data packets and the shortness of a data packet, and a device with multiple output ports of different rates at the same time, it is necessary to First, the longer data packets are sliced according to the internal processing data bit width of the device. After slicing, they enter different egress port queues according to different exits.
  • the scheduler sends the sliced data to each output port evenly according to the bandwidth of each output port, and finally the output circuit of the output port edits the data into a data frame that meets the output port protocol (that is, the exit is framed), and then sends To the downstream.
  • the embodiment of the present application provides a traffic shaping method, which mainly optimizes the scheduling shaping link in FIG. 3.
  • FIG. 4 is a device 40 provided by an embodiment of the present invention.
  • the device 40 can perform data transmission, and the processes shown in FIGS. 2 and 3 need to be performed during data transmission.
  • the device 40 includes a processor 401, a storage device 402, a random access memory (random access memory, RAM) 403, an output device 404, an input device 405, and a motherboard 406, wherein each device is connected by a bus or welding or other point connection On the motherboard 406.
  • the storage device 402 includes but is not limited to a read-only memory (read-only memory, ROM), an erasable programmable read-only memory (erasable programmable read only memory, EPROM), or a portable read-only memory (compact disc read-only memory) , CD-ROM), the storage device 402 is used for related instructions and data.
  • ROM read-only memory
  • EPROM erasable programmable read only memory
  • CD-ROM compact disc read-only memory
  • RAM403 is used to cache the data used in the traffic shaping and scheduling process. For example, there will be a frame data cache in the exit framing link shown in FIG. 3, and these data can be cached in RAM.
  • the output component 404 is used to perform traffic scheduling and traffic shaping operations under the control of the processor 401.
  • the output component may include a scheduler.
  • the scheduling algorithm used by the scheduler may be configured in the scheduler or in the processor 401. in;
  • the input component 405 is used to receive data transmitted from outside under the control of the processor 401.
  • the processor 401 may be one or more central processing units (CPU), or one or more field programmable logic gate arrays (FPGA), or one or more application specific integrated circuits (Application Specific (Integrated Circuit, ASIC), when the processor 401 is a CPU, the CPU may be a single-core CPU or a multi-core CPU.
  • the processor 401 is used to read the program codes stored in the storage device 402 and RAM to control the operation of each device, for example, to control the output component 404 and the input component 405 to perform data input and data output.
  • the device 40 may further include a user interface 407, and the user interface 407 may be used to access a keyboard, a mouse, a touch screen, etc., thereby supporting user interaction with the device 40.
  • FIG. 5 is a traffic shaping method provided by an embodiment of the present invention.
  • the method may be implemented based on the device shown in FIG. 4, or may be implemented based on other architectures.
  • the method includes but is not limited to the following steps:
  • Step S501 The device acquires the scheduling period of the scheduler and the bucket filling period of the token bucket.
  • a scheduling cycle usually includes one or more fixed clock cycles, and the scheduler can perform scheduling once per clock cycle, for example, if the scheduling cycle includes 3 clocks Period, then the scheduler can perform scheduling 3 times in the scheduling period.
  • a bucket filling cycle contains one or more clock cycles, in which the token bucket can be filled once per clock cycle. For example, if the bucket filling cycle includes 4 clock cycles, then within the bucket filling cycle The token bucket can be filled 4 times.
  • multiple schedules within a scheduling period correspond to multiple ports, and similarly multiple bucket fillings also correspond to token buckets assigned to multiple ports.
  • the number of clock cycles included in the bucket filling period of the token bucket is equal to the number of clock cycles included in the scheduling period of the scheduler, and is subsequently collectively referred to as a logical period. For example, if the filling cycle of the token bucket is 3 clock cycles, then the scheduling cycle of the scheduler is also 3 clock cycles, if the scheduling cycle of the scheduler is 10 clock cycles, then the filling of the token bucket The bucket cycle is also 10 clock cycles.
  • the scheduling logic cycle in the embodiment of the present application is synchronized with the bucket filling logic cycle, and the distribution results of the output ports corresponding to the clock cycles in the logic cycle are also synchronized, that is, each clock cycle in the logic cycle corresponds to a specific port Scheduling and each scheduling is accompanied by a bucket filling, then considering the multiple scheduling opportunities for a certain port scheduled by calendar in a logical cycle, the distribution strategy in multiple clock cycles is evenly distributed, and the token bucket is filled evenly , Token scheduling queue is also uniform, so it can minimize the barrel depth, thereby reducing traffic bursts.
  • the first clock cycle of the scheduling cycle and the first clock cycle of the bucket filling cycle are the same clock cycle
  • the last clock cycle of the scheduling cycle is the same as the last clock cycle of the bucket filling cycle. One clock cycle, and so on for the rest.
  • H represents the number of clock cycles included in the scheduling period
  • S represents the total output bandwidth of the device
  • t is the least common divisor of the bandwidth of each output port of the device
  • p is the total number of ports of each output port of the device
  • f is The operating clock frequency of the device.
  • the first term in Equation 1 indicates that the scheduling period is greater than or equal to the total output bandwidth/minimum port granularity. It can be understood that the minimum port granularity is equal to t*1G. For example, if the total output bandwidth of the device is 1200G and the bandwidth of the output port supported by the device is N*5G, the minimum common divisor of the bandwidth of each output port is 5, that is, the minimum port granularity is 5G, so according to the requirements of the first item , The scheduling cycle needs to be greater than or equal to 240 (that is, 240 clock cycles).
  • the scheduling period needs to be greater than or equal to 1200.
  • N is a positive integer. This first item minimizes the waste of bandwidth at the output port.
  • the second term in Equation 1 indicates that the number of clock cycles included in the scheduling cycle is greater than or equal to the total number of output ports of the device. For example, when the total number of ports is 10, the scheduling period is at least 10 (that is, 10 clock cycles), so as to ensure that each port can have a scheduling opportunity in each scheduling cycle (one clock cycle corresponds to one scheduling opportunity).
  • Equation 1 indicates that the bucket filling period should meet the token bucket filling requirement of 1G accuracy. For example, if the total output bandwidth of the device is 1200G and the working clock of the device is 1.2GHz, if the L*1G bandwidth needs to be accurately configured, an optional bucket filling period is 1350. The value is L*1125bit. If the period is slightly larger or slightly smaller than 1350, there is no guarantee that each bucket filling value is an integer, and the circuit is difficult to implement.
  • each bucket filling is L*10bit, and the obtained 10 is an integer, so it meets the accuracy requirements, so it will be
  • the barrel filling period is set to 12 to meet the requirements of the third item above.
  • the scheduling period in the embodiment of the present application needs to satisfy one or more of the three conditions in Formula 1 above. For example, all three items are satisfied. If these three items are required to be satisfied, then the same As an example to illustrate, the scheduling period of 1350 can meet the above three requirements, and the scheduling period of 1206 can also meet the above three requirements. It should be noted that, since the number of clock cycles included in the scheduling cycle and the number of clock cycles included in the bucket filling cycle in the embodiment of the present application are equal, if the scheduling cycle meets the requirements of the above three items, the bucket filling cycle also meets the above three Item requirements.
  • the device to obtain the bucket filling period and the scheduling period. For example, in one solution, the device automatically calculates the scheduling period and the bucket filling period according to the above conditions, and in another solution, the scheduling period and the bucket filling period are calculated manually according to the above conditions. And then configure it on the device.
  • the device automatically calculates the scheduling period and the bucket filling period according to the above conditions, and in another solution, the scheduling period and the bucket filling period are calculated manually according to the above conditions. And then configure it on the device.
  • the device automatically calculates the scheduling period and the bucket filling period according to the above conditions
  • the scheduling period and the bucket filling period are calculated manually according to the above conditions. And then configure it on the device.
  • no examples are given here.
  • Step S502 The device schedules the output port of the device according to the scheduling period and fills the token bucket according to the bucket filling period.
  • the number of clock cycles occupied by the first port in the scheduling period is positively correlated with the proportion of the bandwidth of the first port in the total output bandwidth of the device.
  • the first port is the Any one of the output ports of the device.
  • the bandwidth of the first port is equal to the total output bandwidth of the device, and the first port occupies all clock cycles in the scheduling period.
  • the number h of clock cycles occupied by the first port in the scheduling period satisfies Formula 2:
  • H is the number of clock cycles included in the scheduling period
  • s1 is the bandwidth of the first port
  • S is the total output bandwidth
  • the total output bandwidth of the device is 1200G
  • the total output bandwidth is composed of 10*100G+20*10G. That is, 10 ports with 100G bandwidth and 20 ports with 10G bandwidth, and the scheduling period is 1350.
  • each 100G bandwidth port occupies 112 clock cycles
  • each 10G bandwidth port occupies 11 clock cycles, and is used to schedule the port in the clock cycle occupied by each port data.
  • f is the working clock frequency of the device
  • s1 is the bandwidth of the first port
  • H is the scheduling period.
  • the token bucket is filled.
  • the total number of tokens m is 112500bit.
  • each clock cycle is filled with 1000 bits in a bucket, and in addition to these 111 clock cycles, the bucket is filled with 1500 bits in 1 clock cycle.
  • the token bucket is filled into the token bucket within 11 clock cycles of the first port.
  • the total number of tokens m is 11250bit. For example, in 10 clock cycles out of these 11 clock cycles, each clock cycle fills 1016 bits in a bucket, and in 10 clock cycles other than these 10 clock cycles fills 1090 bits in a bucket.
  • the clock period h occupied by each output port during the scheduling period and the total amount m of tokens to be filled in the clock period occupied by each port are introduced. Based on this, the first port is used as an example to describe how to schedule and fill a bucket.
  • the device configures a token parameter for the first port, the token parameter includes a first token parameter, and the first token parameter includes a remaining token
  • the amount K, the first token amount n1, and the marker bit parameter, the marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total amount of tokens m.
  • the first token amount n1 is a preset integer, and the integer can be made as close to m/h as possible.
  • each subsequent scheduling cycle may be scheduled according to the token parameters, and it is not necessary to configure each scheduling cycle.
  • the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, wherein the second The initial value of the remaining token amount K in the token is different from the initial value of the remaining token amount K in the first token, and the first token amount n1 in the second token is different from the first The first token amount n1 in the token is different; the first token parameter is used as a basis for the token bucket to fill the token when the bandwidth of the first port has not changed, the second token parameter It is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed. That is to say, when configuring token parameters, configure multiple sets of parameters, because the port bandwidth may change.
  • the scheduling and filling of the bucket are performed after the change, there may be problems. If the configuration is temporarily changed after the change, It will cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes.
  • This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order
  • the parameter types of the card parameters are the same, that is, the specific values may be different.
  • the parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
  • the device maps a value for token size for each clock cycle in the scheduling cycle; wherein, the h clock cycles correspond to The sum of the values is equal to the total amount of tokens m. Then, the device schedules the first port during the h clock cycles in the scheduling cycle, and then performs the token on the token according to the value corresponding to each clock cycle in the h clock cycles Bucket filling.
  • the h clock cycles include the first, third, sixth, and tenth in the scheduling cycle Clock cycles
  • the value 10 that is, the sum of the values mapped in these four clock cycles is 100.
  • the 20-bit token is filled according to the mapped value of 20
  • the 30-bit bucket is filled according to the mapped value of 30.
  • Cards when scheduling to the 6th clock cycle of the scheduling cycle, fill the bucket with 40bit tokens according to the mapped value of 40, and when scheduling to the 10th clock cycle of the scheduling cycle, fill the bucket with 10bits according to the mapped value of 10. brand.
  • the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured.
  • the large bucket depth reduces the implementation cost of configuring a larger bucket depth.
  • Buckle filling and bucket filling can be combined into one read and write, instead of one reading and writing of bucket filling and filling, which significantly reduces the complexity of reading and writing, that is, reduces the cache performance requirements of the memory used; on the other hand , Which reduces traffic bursts and improves the transmission performance of the device.
  • FIG. 6 is a schematic structural diagram of a traffic shaping device 60 according to an embodiment of the present invention.
  • the traffic shaping device 60 may include a processing unit 601, a scheduler 602, and X output ports 603 (FIG. 6 shows output ports 603 shows three examples), where:
  • the processing unit 601 is used to obtain the scheduling period of the scheduler 602 and the bucket filling period of the token bucket, wherein the number of clock cycles included in the token bucket filling period and the clock included in the scheduling period of the scheduler The number of cycles is equal;
  • the processing unit 601 may be one or more processors, and the processor may be a central processing unit CPU, or a field programmable logic gate array FPGA, or an application specific integrated circuit ASIC, and so on.
  • the scheduler 602 is configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, where the first port occupies the scheduling period
  • the number of clock cycles is positively related to the ratio of the bandwidth of the first port to the total output bandwidth of the device.
  • the first port is any one of the output ports of the device, and X is greater than or A positive integer equal to 1.
  • the X output ports may be X physical data transmission circuits respectively, or may be X logical data transmission circuits obtained by logically dividing one physical data transmission circuit.
  • the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth
  • the implementation cost of configuring a larger bucket depth is reduced.
  • the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
  • the scheduler configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, includes:
  • the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
  • the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, where , The initial value of the remaining token amount K in the second token is different from the initial value of the remaining token amount K in the first token, the first token amount n1 in the second token Different from the first token amount n1 in the first token; the first token parameter is used as a basis for the token bucket to fill the bucket token when the bandwidth of the first port has not changed, the The second token parameter is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed.
  • multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes.
  • This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order
  • the parameter types of the card parameters are the same, that is, the specific values may be different.
  • the parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
  • the scheduler configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, includes:
  • Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
  • a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle
  • the values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
  • the bucket filling period of the token bucket is synchronized with the scheduling period of the scheduler. It can be understood that this can make the scheduling (along with buckling buckets) highly match the bucket filling, that is, the bucket filling is completed once when the scheduling is completed once per clock cycle, which can minimize the bucket depth.
  • the number h of clock cycles occupied by the first port in the scheduling period satisfies the following formula:
  • H is the number of clock cycles included in the scheduling period
  • s1 is the bandwidth of the first port
  • S is the total output bandwidth
  • the scheduling period occupied by the first port is determined according to the ratio of the bandwidth of the first port to the total output bandwidth. In this way, the number of clock cycles and bandwidth occupied by each output port during scheduling can be made The actual needs are matched as much as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
  • the total number of tokens m filled into the token bucket satisfies the following formula:
  • f is the working clock frequency of the device.
  • the total number of tokens required for the first port to fill the bucket during the scheduling period is determined according to the bandwidth of the first port. In this way, each output port can fill the tokens in the bucket during the scheduling process
  • the volume and its actual bandwidth requirements are matched as closely as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
  • the number of clock cycles H included in the scheduling period satisfies the following formula:
  • S is the total output bandwidth of the device
  • t is the least common divisor of the bandwidth of each output port of the device
  • p is the total number of ports of each output port of the device
  • f is the operating clock frequency of the device .
  • the first term in the formula minimizes the waste of output port bandwidth
  • the second term ensures that each port can have a scheduling opportunity in each scheduling cycle
  • the third term can ensure that each time
  • the amount of bucket tokens is an integer, which can be realized by a simple circuit, that is, the implementation cost is reduced.
  • An embodiment of the present invention further provides a chip system.
  • the chip system includes at least one processor, a memory, and an interface circuit.
  • the memory, the transceiver, and the at least one processor are interconnected by a line.
  • the at least one memory There are instructions stored in it; when the instructions are executed by the processor, the method flow shown in FIG. 5 is realized.
  • An embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored, and when it runs on a processor, the method flow shown in FIG. 5 is implemented.
  • An embodiment of the present invention also provides a computer program product.
  • the computer program product runs on a processor, the method flow shown in FIG. 5 is realized.
  • a person of ordinary skill in the art may understand that all or part of the process in the method of the foregoing embodiments may be implemented by a computer program instructing related hardware.
  • the program may be stored in a computer-readable storage medium, and when the program is executed , May include the process of the N method embodiment described above.
  • the foregoing storage media include: ROM or random storage memory RAM, magnetic disks or optical disks and other N types of media that can store program codes.

Abstract

Embodiments of the present application provide a traffic shaping method and a related device. The method comprises: a device obtains a scheduling cycle of a scheduler and a bucket filling cycle of a token bucket, wherein the number of clock cycles included in the bucket filling cycle of the token bucket is equal to the number of clock cycles included in the scheduling cycle of the scheduler; and the device schedules the X output ports of the device according to the scheduling cycle and fills the token bucket according to the bucket filling cycle, wherein the number of clock cycles occupied by a first port in the scheduling cycle is positively related to the proportion of the bandwidth of the first port in the total output bandwidth of the device, the first port being any one of the output ports of the device, and X is a positive integer greater than or equal to 1. By using the embodiments of the present application, implementation costs can be significantly reduced.

Description

一种流量整形方法及相关设备Flow shaping method and related equipment 技术领域Technical field
本发明涉及通信技术领域,尤其涉及一种流量整形方法及相关设备。The present invention relates to the field of communication technology, and in particular, to a traffic shaping method and related equipment.
背景技术Background technique
在数据传输场景中,由于输出端口的发送能力/带宽有限,因此调度器需要保证调度出来的数据平均带宽不能够超过输出端口的承载带宽。主要包含两部分,一方面是使用调度器将各自的待发送数据,按照特定的规则(如日历(calendar)算法,加权循环调度算法(weighted round robin,WRR),加权公平排队(weighted fair queuing,WFQ)等)调度到输出端口。以calendar为例,输出端口调度的规格一般使用时分复用调度,其基本原理是用户事先配置日历calendar表,其中直接预先配置每一次调度的调度结果,工作时候按照工作时钟周期直接轮询数据结构中每个数据,如果其他条件满足(如下文的流量整形条件满足等)则直接得到调度结果,否则此次调度结果作废,下个时钟周期继续轮询下一个数据。In the data transmission scenario, due to the limited sending capacity/bandwidth of the output port, the scheduler needs to ensure that the average bandwidth of the scheduled data cannot exceed the load bandwidth of the output port. It mainly consists of two parts. On the one hand, the scheduler is used to separate the data to be sent according to specific rules (such as calendar algorithm, weighted round robin (WRR), weighted fair queueing, weighted fair queueing, WFQ) etc.) dispatched to the output port. Taking calendar as an example, the output port scheduling specifications generally use time division multiplexing scheduling. The basic principle is that the user configures the calendar calendar table in advance, where the scheduling result of each scheduling is directly pre-configured, and the data structure is directly polled according to the working clock cycle during working hours For each data in the data, if other conditions are met (such as the traffic shaping conditions below, etc.), the scheduling result is directly obtained, otherwise the scheduling result is invalid this time, and the next data continues to be polled in the next clock cycle.
另一方面是使用流量整形控制各个端口队列的数据输出带宽。业界已经包含有多种办法完成流量整形,典型是利用令牌桶机制对数据的发送进行限制,令牌通的基本原理如图1A和1B所示。当数据流需要输出时首先会根据数据的大小从令牌桶中取出与数据大小相当的令牌数量用来传输数据。也就是说要使数据被传输必须保证令牌桶里有足够多的令牌,如果令牌数量不够,则数据会被丢弃或缓存。这就可以限制数据流只能小于等于令牌生成的速度,从而达到限制流量的目的。根据令牌桶的机制,数据发送的平均带宽即等于填桶的速度,而令牌桶的桶深则为最大的发送突发尺寸。目前采用较多的令牌桶填桶方案是定时填桶。The other is to use traffic shaping to control the data output bandwidth of each port queue. The industry has included a variety of methods to complete traffic shaping. Typically, the token bucket mechanism is used to restrict data transmission. The basic principle of token communication is shown in Figures 1A and 1B. When the data stream needs to be output, it will first take out the number of tokens corresponding to the data size from the token bucket according to the size of the data to transmit data. That is to say, for data to be transmitted, there must be enough tokens in the token bucket. If the number of tokens is not enough, the data will be discarded or cached. This can limit the data flow to be less than or equal to the speed of token generation, thereby achieving the purpose of limiting traffic. According to the token bucket mechanism, the average bandwidth of data transmission is equal to the bucket filling speed, and the bucket depth of the token bucket is the maximum transmission burst size. At present, the more frequently used token bucket filling scheme is the regular bucket filling.
定时填桶的基本原理是,每一个令牌桶的填充时间固定,配置不同的填桶令牌个数即实现了不同的带宽。实现此算法需要至少引入如下的数据结构:当前令牌桶中令牌个数,单位时间填充值,用于判断填充时刻的时间计数,令牌桶最大桶深。考虑到设备中具有多个端口,因此逻辑上实际是多个端口分别设置各自令牌桶控制带宽。一种典型的设计是同享一个令牌桶电路,将不同端口的数据结构存放在存储器(例如静态随机存取存储器(static random-access memory,SRAM))的不同地址,时分复用进行填桶,扣桶操作(即从令牌桶中扣除令牌的操作)。此时填桶周期需要大于端口数,每一个填桶周期内各个令牌桶最多填充一次,从而保证不同端口的填桶诉求不会时间冲突。填桶周期的典型取值方式为,填桶周期等于min{端口数r,2^q},其中q取满足2^q>r的值。The basic principle of timed bucket filling is that the filling time of each token bucket is fixed, and different bandwidths can be achieved by configuring different numbers of bucket filling tokens. To implement this algorithm, at least the following data structures need to be introduced: the number of tokens in the current token bucket, the filling value per unit time, used to determine the time count of the filling time, and the maximum bucket depth of the token bucket. Considering that there are multiple ports in the device, it is logically that multiple ports set their respective token bucket control bandwidths. A typical design is to share a token bucket circuit, store the data structure of different ports in different addresses of memory (such as static random-access memory (SRAM)), and fill the bucket with time-division multiplexing , Bucket deduction operation (that is, the operation of deducting tokens from the token bucket). At this time, the bucket filling period needs to be greater than the number of ports, and each token bucket is filled at most once in each bucket filling period, so as to ensure that bucket filling requests of different ports do not conflict in time. The typical value of the bucket filling period is: the bucket filling period is equal to min{port number r, 2^q}, where q takes a value that satisfies 2^q>r.
在定时填桶的机制中,每个输出端口对应的逻辑桶需要间隔填桶周期才能够填桶一次,因此为了满足数据发送的平均带宽不会太小,每个填桶周期需要填桶较多的令牌。而一次性填充令牌数过多,会造成桶深变大,从而导致实现代价较高,如何合理进行填桶以降低实现代价是本领域的技术人员正在研究的技术问题。In the mechanism of timed bucket filling, the logical bucket corresponding to each output port needs to be filled once in the bucket filling period. Therefore, in order to meet the average bandwidth of data transmission, the bucket needs to be filled more every bucket filling period. Token. Too many one-time filling tokens will cause the bucket depth to become larger, resulting in a higher implementation cost. How to reasonably perform bucket filling to reduce the implementation cost is a technical problem being studied by those skilled in the art.
发明内容Summary of the invention
本发明实施例公开了一种流量整形方法及相关设备,能够显著降低了实现代价。The embodiments of the present invention disclose a traffic shaping method and related equipment, which can significantly reduce the implementation cost.
第一方面,本申请实施例提供一种流量整形方法,该方法包括:In a first aspect, an embodiment of the present application provides a traffic shaping method. The method includes:
设备获取调度器的调度周期和令牌桶的填桶周期,其中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等;The device obtains the scheduling cycle of the scheduler and the bucket filling cycle of the token bucket, where the number of clock cycles included in the token bucket filling cycle is equal to the number of clock cycles included in the scheduler's scheduling cycle;
所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,其中,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述设备的输出端口中的任意一个输出端口,X为大于或者等于1的正整数。The device schedules the X output ports of the device according to the scheduling period and fills the token bucket according to the bucket filling period, wherein the first port occupies the scheduling period The number of clock cycles is positively related to the ratio of the bandwidth of the first port to the total output bandwidth of the device. The first port is any one of the output ports of the device, and X is greater than or A positive integer equal to 1.
通过执行上述方法,将调度器的调度周期与令牌桶的填桶周期设置为相同,使得调度数据的速度与填桶令牌的速度相匹配,因此令牌桶不需要配置较大的桶深,一方面降低了配置较大桶深的实现代价,具体来说,由于调度周期与令牌桶的填桶周期设置为相同,因此每个时钟周期同时发生扣桶和填桶,因此扣桶和填桶可以合为一次读和写,而不是扣桶和填桶各一次读和写,显著降低了读写复杂度,即降低了对所使用的存储器的缓存性能要求;另一方面,减少了流量突发,提升了设备的传输性能。By executing the above method, the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth On the one hand, the implementation cost of configuring a larger bucket depth is reduced. Specifically, since the scheduling period and the token bucket filling period are set to be the same, the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
结合第一方面,在第一方面的第一种可能的实现方式中,所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, the device schedules the X output ports of the device according to the scheduling cycle and the token according to the bucket filling cycle Bucket filling, including:
为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m;Configure a token parameter for the first port, the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;When it is in turn to schedule the first port when scheduling the first port, and determine whether the current clock cycle is the clock cycle marked by the flag bit in the token parameter;
若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update Card amount minus the first token amount n1;
若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始化为所述令牌总量m。If yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the total token amount m.
在这种实现方式中,对第一端口只需配置剩余令牌量K、第一令牌量n1和标记参数即可,无需对第一端口的对应的每个时钟周期进行单独配置,降低了配置的复杂度,且这个流程实现起来比较简单,能够节省硬件和软件资源。In this implementation, only the remaining token amount K, the first token amount n1, and the marking parameters need to be configured for the first port, and there is no need to separately configure each corresponding clock cycle of the first port, which reduces The complexity of the configuration, and this process is relatively simple to implement, which can save hardware and software resources.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述令牌参数还包括第二令牌参数,其中,所述第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,所述第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the token parameter further includes a second token parameter, where the second token parameter includes The remaining token amount K, the first token amount n1 and the flag bit parameters, wherein the initial value of the remaining token amount K in the second token and the remaining token amount K in the first token The initial value is different, the first token amount n1 in the second token is different from the first token amount n1 in the first token; the first token parameter is used in the first port The bandwidth of the token bucket is used as the basis for filling the token bucket with the token bandwidth unchanged, and the second token parameter is used as a basis for filling the token bucket with the token bucket after the bandwidth of the first port is changed.
在这种实现方式中,在配置令牌参数时配置多套参数,因为端口带宽可能会发生变化,如果变化后还按照变化前的配置进行调度和填桶可能会出现问题,如果变化后临时进行配置也会导致一些时延,即端口带宽变化后无法立即执行调度和填桶操作。而这个可选方案 预先预估了端口可能发生什么样的变化,然后据此预先配置一套备用的令牌参数,即第二令牌参数,第二令牌参数中的参数类型与第一令牌参数的参数类型相同,就是具体数值可能不同,第二令牌参数中的参数能够满足端口带宽变化后的调度和填桶需求。In this implementation, multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes. This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order The parameter types of the card parameters are the same, that is, the specific values may be different. The parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
结合第一方面,或者第一方面的上述任一种可能的实现方式,在第一方面的第三种可能的实现方式中,所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:With reference to the first aspect, or any one of the foregoing possible implementation manners of the first aspect, in a third possible implementation manner of the first aspect, the device outputs X output ports of the device according to the scheduling period Scheduling and bucket filling the token bucket according to the bucket filling cycle include:
为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令牌总量m;Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。Scheduling the first port in the h clock cycles in the scheduling cycle, and filling the token bucket according to the value corresponding to each clock cycle in the h clock cycles .
在这种实现方式中,预先为调度周期内的每一个时钟周期映射一个数值,后续每次调度和填桶到每个时钟周期时都按照该时钟周期对应的数值来填桶,由于各个时钟周期之间的数值相互独立互不影响,因此即便在哪个时钟周期出现意外也不会对后续其他时钟周期内的填桶造成影响。In this implementation, a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle The values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
第二方面,本申请实施例提供一种流量整形设备,该设备包括理单元、调度器和X个输出端口,X为大于或者等于1的正整数,其中:In a second aspect, an embodiment of the present application provides a traffic shaping device. The device includes a processing unit, a scheduler, and X output ports. X is a positive integer greater than or equal to 1, where:
处理单元,用于获取所述调度器的调度周期和令牌桶的填桶周期,其中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等;The processing unit is configured to obtain a scheduling period of the scheduler and a bucket filling period of the token bucket, where the number of clock cycles included in the token bucket filling period and the clock period included in the scheduler scheduling period Equal number
调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,其中,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述X个输出端口中的任意一个输出端口。A scheduler, configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, wherein the first port occupies the scheduling period The number of clock cycles is positively related to the proportion of the bandwidth of the first port in the total output bandwidth of the device, and the first port is any one of the X output ports.
通过运行上述单元,将调度器的调度周期与令牌桶的填桶周期设置为相同,使得调度数据的速度与填桶令牌的速度相匹配,因此令牌桶不需要配置较大的桶深,一方面降低了配置较大桶深的实现代价,具体来说,由于调度周期与令牌桶的填桶周期设置为相同,因此每个时钟周期同时发生扣桶和填桶,因此扣桶和填桶可以合为一次读和写,而不是扣桶和填桶各一次读和写,显著降低了读写复杂度,即降低了对所使用的存储器的缓存性能要求;另一方面,减少了流量突发,提升了设备的传输性能。By running the above unit, the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth On the one hand, the implementation cost of configuring a larger bucket depth is reduced. Specifically, since the scheduling period and the token bucket filling period are set to be the same, the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
结合第二方面,在第二方面的第一种可能的实现方式中,该调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:With reference to the second aspect, in a first possible implementation manner of the second aspect, the scheduler is configured to schedule the X output ports according to the scheduling period and the order according to the bucket filling period Filling the bucket with a brand bucket, including:
为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m;Configure a token parameter for the first port, the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;When it is in turn to schedule the first port when scheduling the first port, and determine whether the current clock cycle is the clock cycle marked by the flag bit in the token parameter;
若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update Card amount minus the first token amount n1;
若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始 化为所述令牌总量m。If yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the total token amount m.
在这种实现方式中,对第一端口只需配置剩余令牌量K、第一令牌量n1和标记参数即可,无需对第一端口的对应的每个时钟周期进行单独配置,降低了配置的复杂度,且这个流程实现起来比较简单,能够节省硬件和软件资源。In this implementation, only the remaining token amount K, the first token amount n1, and the marking parameters need to be configured for the first port, and there is no need to separately configure each corresponding clock cycle of the first port, which reduces The complexity of the configuration, and this process is relatively simple to implement, which can save hardware and software resources.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述令牌参数还包括第二令牌参数,其中,第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the token parameter further includes a second token parameter, where the second token parameter includes a remaining order The card amount K, the first token amount n1 and the mark bit parameters, wherein the initial value of the remaining token amount K in the second token is different from the initial value of the remaining token amount K in the first token, The first token amount n1 in the second token is different from the first token amount n1 in the first token; the first token parameter is used for the bandwidth of the first port unchanged Is used as a basis for token bucket to fill bucket tokens, and the second token parameter is used as a basis for token bucket to fill bucket tokens after the bandwidth of the first port is changed.
在这种实现方式中,在配置令牌参数时配置多套参数,因为端口带宽可能会发生变化,如果变化后还按照变化前的配置进行调度和填桶可能会出现问题,如果变化后临时进行配置也会导致一些时延,即端口带宽变化后无法立即执行调度和填桶操作。而这个可选方案预先预估了端口可能发生什么样的变化,然后据此预先配置一套备用的令牌参数,即第二令牌参数,第二令牌参数中的参数类型与第一令牌参数的参数类型相同,就是具体数值可能不同,第二令牌参数中的参数能够满足端口带宽变化后的调度和填桶需求。In this implementation, multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes. This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order The parameter types of the card parameters are the same, that is, the specific values may be different. The parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
结合第二方面,或者第二方面的上述任一种可能的实现方式,在第二方面的第三种可能的实现方式中,所述调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:With reference to the second aspect, or any one of the foregoing possible implementation manners of the second aspect, in a third possible implementation manner of the second aspect, the scheduler is configured to check the X number according to the scheduling period The scheduling of the output port and the bucket filling of the token bucket according to the bucket filling period include:
为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令牌总量m;Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。Scheduling the first port in the h clock cycles in the scheduling cycle, and filling the token bucket according to the value corresponding to each clock cycle in the h clock cycles .
在这种实现方式中,预先为调度周期内的每一个时钟周期映射一个数值,后续每次调度和填桶到每个时钟周期时都按照该时钟周期对应的数值来填桶,由于各个时钟周期之间的数值相互独立互不影响,因此即便在哪个时钟周期出现意外也不会对后续其他时钟周期内的填桶造成影响。In this implementation, a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle The values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
结合第一方面,或者第一方面的上述任一可能的实现方式,或者第二方面,或者第二方面的上述任一种可能的实现方式,在一种可选的实现方式中,所述令牌桶的填桶周期与所述调度器的调度周期同步。可以理解,这样可以使得调度(伴随着扣桶)与填桶高度匹配,即每个时钟周期内完成一次调度的同时还完成一次填桶,能够最大限度地降低桶深。With reference to the first aspect, or any of the foregoing possible implementations of the first aspect, or the second aspect, or any of the foregoing possible implementations of the second aspect, in an optional implementation, the order The bucket filling cycle of the brand bucket is synchronized with the scheduling cycle of the scheduler. It can be understood that this can make the scheduling (along with buckling buckets) highly match the bucket filling, that is, the bucket filling is completed once when the scheduling is completed once per clock cycle, which can minimize the bucket depth.
结合第一方面,或者第一方面的上述任一可能的实现方式,或者第二方面,或者第二方面的上述任一种可能的实现方式,在一种可选的实现方式中,所述第一端口在所述调度周期中占用的时钟周期数h满足如下公式:With reference to the first aspect, or any of the foregoing possible implementations of the first aspect, or the second aspect, or any of the foregoing possible implementations of the second aspect, in an optional implementation, the first The number of clock cycles h occupied by a port in the scheduling period satisfies the following formula:
Figure PCTCN2019070594-appb-000001
Figure PCTCN2019070594-appb-000001
其中,H为所述调度周期包含的时钟周期数,s1为所述第一端口的带宽,S为所述总输出带宽。Where H is the number of clock cycles included in the scheduling period, s1 is the bandwidth of the first port, and S is the total output bandwidth.
在这种实现方式中,根据第一端口的带宽与总输出带宽的比值来确定第一端口占用的 调度周期,采用这种方式可以使得每个输出端口在调度时所占用的时钟周期数与其带宽实际需求尽量相匹配且各个输出端口之间相对均衡,最大限度了满足了整体的带宽需求。In this implementation, the scheduling period occupied by the first port is determined according to the ratio of the bandwidth of the first port to the total output bandwidth. In this way, the number of clock cycles and bandwidth occupied by each output port during scheduling can be made The actual needs are matched as much as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
结合第一方面,或者第一方面的上述任一可能的实现方式,或者第二方面,或者第二方面的上述任一种可能的实现方式,在一种可选的实现方式中,对所述第一端口进行调度所经历的h个时钟周期内,向所述令牌桶填桶的令牌总量m满足如下公式:With reference to the first aspect, or any one of the foregoing possible implementations of the first aspect, or the second aspect, or any one of the foregoing possible implementations of the second aspect, in an optional implementation, the During the h clock cycles that the first port has undergone scheduling, the total amount of tokens m filled into the token bucket satisfies the following formula:
m=s1*H/fm=s1*H/f
其中,f为所述设备的工作时钟频率。Where f is the working clock frequency of the device.
在这种实现方式中,根据第一端口的带宽来确定第一端口在调度期间所需填桶的总令牌量,采用这种方式可以使得每个输出端口在调度过程中填桶的令牌量与其带宽实际需求尽量相匹配且各个输出端口之间相对均衡,最大限度了满足了整体的带宽需求。In this implementation, the total number of tokens required for the first port to fill the bucket during the scheduling period is determined according to the bandwidth of the first port. In this way, each output port can fill the tokens in the bucket during the scheduling process The volume and its actual bandwidth requirements are matched as closely as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
结合第一方面,或者第一方面的上述任一可能的实现方式,或者第二方面,或者第二方面的上述任一种可能的实现方式,在一种可选的实现方式中,所述调度周期包含的时钟周期数H满足如下公式:With reference to the first aspect, or any one of the foregoing possible implementations of the first aspect, or the second aspect, or any one of the foregoing possible implementations of the second aspect, in an optional implementation, the scheduling The number of clock cycles H included in the cycle satisfies the following formula:
Figure PCTCN2019070594-appb-000002
Figure PCTCN2019070594-appb-000002
其中,S为所述设备的总输出带宽,t为所述设备的各个输出端口的带宽的最小公约数,p为所述设备的各个输出端口的端口总数,f为所述设备的工作时钟频率。Where S is the total output bandwidth of the device, t is the least common divisor of the bandwidth of each output port of the device, p is the total number of ports of each output port of the device, and f is the operating clock frequency of the device .
在这种实现方式中,公式中的第一项尽量减小了输出端口的带宽浪费,第二项保证了每个调度周期内每个端口能够有一次调度机会,第三项能够保证每次填桶令牌量为整数,可以通过简单的电路实现,即降低了实现成本。In this implementation, the first term in the formula minimizes the waste of output port bandwidth, the second term ensures that each port can have a scheduling opportunity in each scheduling cycle, and the third term can ensure that each time The amount of bucket tokens is an integer, which can be realized by a simple circuit, that is, the implementation cost is reduced.
第三方面,本申请实施例提供一种设备,该设备包括处理器、存储器件、输出器件和主板,各个器件通过总线或者焊接或者其他电连接方式连接在该主板上,该输出器件包括调度器。该处理器通过调用存储器中存储的程序这里来控制输出器件进行流量整形和调度。In a third aspect, an embodiment of the present application provides a device including a processor, a storage device, an output device, and a motherboard, each device is connected to the motherboard through a bus or soldering or other electrical connection, and the output device includes a scheduler . The processor controls the output device to perform traffic shaping and scheduling by calling the program stored in the memory.
第四方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有程序指令,当所述程序指令在处理器上运行时,实现第一方面,或者第一方面的任一可能的实现方式所描述的方法。According to a fourth aspect, an embodiment of the present application provides a computer-readable storage medium that stores program instructions, and when the program instructions run on a processor, implement the first aspect, or the first The method described in any possible implementation of aspects.
附图说明BRIEF DESCRIPTION
图1A是本发明实施例提供的一种令牌桶的原理示意图;1A is a schematic diagram of a principle of a token bucket provided by an embodiment of the present invention;
图1B是本发明实施例提供的又一种令牌桶的原理示意图;1B is a schematic diagram of another principle of a token bucket provided by an embodiment of the present invention;
图2是本发明实施例提供的一种数据流传输的流程示意图;2 is a schematic flowchart of a data stream transmission provided by an embodiment of the present invention;
图3是本发明实施例提供的一种数据流调度和整形的流程示意图;3 is a schematic flowchart of a data flow scheduling and shaping provided by an embodiment of the present invention;
图4是本发明实施例提供的一种流量整形设备的结构示意图;4 is a schematic structural diagram of a traffic shaping device provided by an embodiment of the present invention;
图5是本发明实施例提供的一种流量整形方法的流程示意图;5 is a schematic flowchart of a traffic shaping method according to an embodiment of the present invention;
图6是本发明实施例提供的又一种流量整形设备的结构示意图。6 is a schematic structural diagram of yet another flow shaping device provided by an embodiment of the present invention.
具体实施方式detailed description
下面结合本发明实施例中的附图对本发明实施例进行描述。The following describes the embodiments of the present invention with reference to the drawings in the embodiments of the present invention.
本发明应用于网络设备中,网络设备主要完成网络数据帧的传输,处理等功能。以网络交换设备(例如交换机,路由器等)为例,如图2所示,网络设备需要完成数据接收输入,转发,交换,流量管理,流量输出等功能。在数据的“输出”环节,一种典型的流程如图3所示,具体来说,考虑到数据包变有的长有的短,以及同时一个设备具有多个不同速率的输出端口,因此需要先将较长数据包按照设备内部处理数据位宽切片,切片后根据出口不同进入不同的出端口队列,期间还涉及到对端口队列进行调度整形。相应地,由调度器根据各个出端口的带宽均匀的将切片数据发送到各个出端口,最终由出端口的发送电路将数据编辑成满足出端口协议的数据帧(即出口成帧),从而发送到下游。本申请实施例提供一种流量整形方法,主要对图3中调度整形环节进行优化。The invention is applied to network equipment, and the network equipment mainly completes the functions of transmission and processing of network data frames. Taking a network switching device (such as a switch, a router, etc.) as an example, as shown in FIG. 2, the network device needs to complete functions such as data receiving input, forwarding, switching, traffic management, and traffic output. In the "output" link of data, a typical process is shown in Figure 3. Specifically, considering the length of data packets and the shortness of a data packet, and a device with multiple output ports of different rates at the same time, it is necessary to First, the longer data packets are sliced according to the internal processing data bit width of the device. After slicing, they enter different egress port queues according to different exits. During the period, it also involves scheduling and shaping the port queues. Correspondingly, the scheduler sends the sliced data to each output port evenly according to the bandwidth of each output port, and finally the output circuit of the output port edits the data into a data frame that meets the output port protocol (that is, the exit is framed), and then sends To the downstream. The embodiment of the present application provides a traffic shaping method, which mainly optimizes the scheduling shaping link in FIG. 3.
请参见图4,图4是本发明实施例提供的一种设备40,该设备40可以进行数据传输,在数据传输时需要执行图2、图3所示的流程。该设备40包括处理器401、存储器件402、随机存储记忆体(random access memory,RAM)403、输出器件404、输入器件405和主板406,其中,各个器件通过总线或者焊接或者其他点连接方式连接在该主板406上。Please refer to FIG. 4. FIG. 4 is a device 40 provided by an embodiment of the present invention. The device 40 can perform data transmission, and the processes shown in FIGS. 2 and 3 need to be performed during data transmission. The device 40 includes a processor 401, a storage device 402, a random access memory (random access memory, RAM) 403, an output device 404, an input device 405, and a motherboard 406, wherein each device is connected by a bus or welding or other point connection On the motherboard 406.
存储器件402包括但不限于是只读存储器(read-only memory,ROM)、可擦除可编程只读存储器(erasable programmable read only memory,EPROM)、或便携式只读存储器(compact disc read-only memory,CD-ROM),该存储器件402用于相关指令及数据。The storage device 402 includes but is not limited to a read-only memory (read-only memory, ROM), an erasable programmable read-only memory (erasable programmable read only memory, EPROM), or a portable read-only memory (compact disc read-only memory) , CD-ROM), the storage device 402 is used for related instructions and data.
RAM403用于缓存流量整形和调度过程中用到的数据,例如,在图3所示的出口成帧环节会有帧数据缓存,这些数据就可以缓存在RAM中。RAM403 is used to cache the data used in the traffic shaping and scheduling process. For example, there will be a frame data cache in the exit framing link shown in FIG. 3, and these data can be cached in RAM.
输出组件404用于在处理器401的控制下执行流量调度和流量整形操作,可选的,输出组件可包括调度器,调度器使用的调度算法可配置在调度器中也可配置在处理器401中;The output component 404 is used to perform traffic scheduling and traffic shaping operations under the control of the processor 401. Optionally, the output component may include a scheduler. The scheduling algorithm used by the scheduler may be configured in the scheduler or in the processor 401. in;
输入组件405用于在处理器401的控制下接收外界传输的数据。The input component 405 is used to receive data transmitted from outside under the control of the processor 401.
处理器401可以是一个或多个中央处理器(central processing unit,CPU),或者一个或多个现场可编程逻辑门阵列(field programmable gate array,FPGA),或者一个或多个专用集成电路(Application Specific Integrated Circuit,ASIC),在处理器401是一个CPU的情况下,该CPU可以是单核CPU,也可以是多核CPU。处理器401用于读取所述存储器件402和RAM中存储的程序代码来对各个器件的工作进行控制,例如,控制输出组件404和输入组件405的进行数据输入和数据输出。The processor 401 may be one or more central processing units (CPU), or one or more field programmable logic gate arrays (FPGA), or one or more application specific integrated circuits (Application Specific (Integrated Circuit, ASIC), when the processor 401 is a CPU, the CPU may be a single-core CPU or a multi-core CPU. The processor 401 is used to read the program codes stored in the storage device 402 and RAM to control the operation of each device, for example, to control the output component 404 and the input component 405 to perform data input and data output.
可选的,该设备40还可以包括用户接口407,该用户接口407可以用来接入键盘、鼠标、触摸屏等,从而支持用户与设备40进行交互。Optionally, the device 40 may further include a user interface 407, and the user interface 407 may be used to access a keyboard, a mouse, a touch screen, etc., thereby supporting user interaction with the device 40.
该设备40进行流量整形的更详细介绍可以参照图5所示的方法实施例。For a more detailed introduction of traffic shaping by the device 40, reference may be made to the method embodiment shown in FIG. 5.
请参见图5,图5是本发明实施例提供的一种流量整形方法,该方法可以基于图4所示的设备来实现,也可以基于其他架构来实现,该方法包括但不限于如下步骤:Please refer to FIG. 5. FIG. 5 is a traffic shaping method provided by an embodiment of the present invention. The method may be implemented based on the device shown in FIG. 4, or may be implemented based on other architectures. The method includes but is not limited to the following steps:
步骤S501:设备获取调度器的调度周期和令牌桶的填桶周期。Step S501: The device acquires the scheduling period of the scheduler and the bucket filling period of the token bucket.
具体地,以使用时分复用calendar调度器为例,通常一个调度周期包含固定的一个或 多个时钟周期,调度器在其中每个时钟周期可以进行一次调度,例如,假若调度周期包含3个时钟周期,那么在该调度周期内该调度器可以执行3次调度。同理,一个填桶周期包含一个或多个时钟周期,在其中每个时钟周期可以对令牌桶进行一次填桶,例如,假若填桶周期包含4个时钟周期,那么在该填桶周期内可以对令牌桶执行4次填桶。对于一个多输出端口的设备,一个调度周期内的多次调度对应分配到多个端口,同理多次填桶也对应分配到多个端口的令牌桶。Specifically, taking the time-division multiplex calendar scheduler as an example, a scheduling cycle usually includes one or more fixed clock cycles, and the scheduler can perform scheduling once per clock cycle, for example, if the scheduling cycle includes 3 clocks Period, then the scheduler can perform scheduling 3 times in the scheduling period. Similarly, a bucket filling cycle contains one or more clock cycles, in which the token bucket can be filled once per clock cycle. For example, if the bucket filling cycle includes 4 clock cycles, then within the bucket filling cycle The token bucket can be filled 4 times. For a device with multiple output ports, multiple schedules within a scheduling period correspond to multiple ports, and similarly multiple bucket fillings also correspond to token buckets assigned to multiple ports.
在本申请实施例中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等,后续统称为逻辑周期。例如,假若该令牌桶的填桶周期为3个时钟周期,那么该调度器的调度周期也是3个时钟周期,假若该调度器的调度周期为10个时钟周期,那么该令牌桶的填桶周期也是10个时钟周期。可选的,本申请实施例中的调度逻辑周期与填桶逻辑周期同步,逻辑周期内各个时钟周期对应各个输出端口的分配结果也同步,即逻辑周期内每个时钟周期对应某一个特定端口的调度且每一次调度都伴随着一次填桶,则考虑到calendar调度的针对某一个端口的多次调度机会在逻辑周期内多个时钟周期中的分布策略是均匀分配后,令牌桶填桶均匀,令牌调度出队也均匀,因此能够最大限度地降低桶深,从而降低流量突发。举例来说,该调度周期的第一个时钟周期与该填桶周期的第一个时钟周期为同一个时钟周期,该调度周期的最后一个时钟周期与该填桶周期的最后一个时钟周期为同一个时钟周期,其余以此类推。In the embodiment of the present application, the number of clock cycles included in the bucket filling period of the token bucket is equal to the number of clock cycles included in the scheduling period of the scheduler, and is subsequently collectively referred to as a logical period. For example, if the filling cycle of the token bucket is 3 clock cycles, then the scheduling cycle of the scheduler is also 3 clock cycles, if the scheduling cycle of the scheduler is 10 clock cycles, then the filling of the token bucket The bucket cycle is also 10 clock cycles. Optionally, the scheduling logic cycle in the embodiment of the present application is synchronized with the bucket filling logic cycle, and the distribution results of the output ports corresponding to the clock cycles in the logic cycle are also synchronized, that is, each clock cycle in the logic cycle corresponds to a specific port Scheduling and each scheduling is accompanied by a bucket filling, then considering the multiple scheduling opportunities for a certain port scheduled by calendar in a logical cycle, the distribution strategy in multiple clock cycles is evenly distributed, and the token bucket is filled evenly , Token scheduling queue is also uniform, so it can minimize the barrel depth, thereby reducing traffic bursts. For example, the first clock cycle of the scheduling cycle and the first clock cycle of the bucket filling cycle are the same clock cycle, and the last clock cycle of the scheduling cycle is the same as the last clock cycle of the bucket filling cycle. One clock cycle, and so on for the rest.
需要说明的是,本申请实施例中的填桶周期和调度周期包含的时钟周期数并非任意的周期,而是需要满足一定的条件,下面通过公式1例举几种条件以方便理解。It should be noted that the number of clock cycles included in the bucket filling period and the scheduling period in this embodiment of the present application is not an arbitrary period, but needs to meet certain conditions. The following uses Formula 1 to illustrate several conditions to facilitate understanding.
Figure PCTCN2019070594-appb-000003
Figure PCTCN2019070594-appb-000003
在公式1中,H表示调度周期包含的时钟周期数,S表示设备的总输出带宽,t为设备的各个输出端口的带宽的最小公约数,p为设备的各个输出端口的端口总数,f为设备的工作时钟频率。In Equation 1, H represents the number of clock cycles included in the scheduling period, S represents the total output bandwidth of the device, t is the least common divisor of the bandwidth of each output port of the device, p is the total number of ports of each output port of the device, and f is The operating clock frequency of the device.
公式1中的第一项表示调度周期大于或等于总输出带宽/最小端口粒度,可以理解,最小端口粒度等于t*1G。例如,假若设备的总输出带宽为1200G,设备支持的输出端口的带宽大小为N*5G,则各个输出端口带宽的最小公约数为5,即最小端口粒度为5G,因此按照第一项的要求,调度周期需要大于或者等于240(即240个时钟周期)。再如,假如设备的总输出带宽为1200G,设备支持的输出端口的带宽大小为5G开始按照1G粒度步进,则各个输出端口的带宽的最小公约数为1,即最小端口粒度为1G,因此按照第一项的要求,调度周期需要大于或者等于1200。N为正整数。该第一项尽可能地减小了输出端口的带宽浪费。The first term in Equation 1 indicates that the scheduling period is greater than or equal to the total output bandwidth/minimum port granularity. It can be understood that the minimum port granularity is equal to t*1G. For example, if the total output bandwidth of the device is 1200G and the bandwidth of the output port supported by the device is N*5G, the minimum common divisor of the bandwidth of each output port is 5, that is, the minimum port granularity is 5G, so according to the requirements of the first item , The scheduling cycle needs to be greater than or equal to 240 (that is, 240 clock cycles). As another example, if the total output bandwidth of the device is 1200G, and the bandwidth of the output port supported by the device is 5G, start at a 1G granularity step, then the minimum common divisor of the bandwidth of each output port is 1, that is, the minimum port granularity is 1G, so According to the requirements of the first item, the scheduling period needs to be greater than or equal to 1200. N is a positive integer. This first item minimizes the waste of bandwidth at the output port.
公式1中的第二项表示调度周期包含的时钟周期数要大于或者等于设备的输出端口的端口总数。例如,端口总数为10个时,调度周期至少为10(即10个时钟周期),这样才能保证每个调度周期内每个端口能够有一次调度机会(一个时钟周期对应一次调度机会)。The second term in Equation 1 indicates that the number of clock cycles included in the scheduling cycle is greater than or equal to the total number of output ports of the device. For example, when the total number of ports is 10, the scheduling period is at least 10 (that is, 10 clock cycles), so as to ensure that each port can have a scheduling opportunity in each scheduling cycle (one clock cycle corresponds to one scheduling opportunity).
公式1中的第三项表示填桶周期要满足1G精度的令牌填桶要求。例如,假若设备的总输出带宽为1200G,设备的工作时钟时1.2GHz,则如果需要精确的配置出L*1G的带宽, 则一个可选的填桶周期为1350,此时每一次填桶的值为L*1125bit,如果周期略大或略小与1350,则无法保证每一次填桶值是一个整数,电路难以实现。同理,如果需要精确的配置出L*1G的带宽,选择填桶周期为12,那么此时每一次填桶的值为L*10bit,其中得到的10为整数,因此满足精度要求,因此将填桶周期定为12能够满足上述第三项的要求。The third term in Equation 1 indicates that the bucket filling period should meet the token bucket filling requirement of 1G accuracy. For example, if the total output bandwidth of the device is 1200G and the working clock of the device is 1.2GHz, if the L*1G bandwidth needs to be accurately configured, an optional bucket filling period is 1350. The value is L*1125bit. If the period is slightly larger or slightly smaller than 1350, there is no guarantee that each bucket filling value is an integer, and the circuit is difficult to implement. Similarly, if the L*1G bandwidth needs to be accurately configured and the bucket filling period is 12, then the value of each bucket filling is L*10bit, and the obtained 10 is an integer, so it meets the accuracy requirements, so it will be The barrel filling period is set to 12 to meet the requirements of the third item above.
可选的,本申请实施例中的调度周期需要满足上述公式1的三项条件中的一项或者多项,例如,这三项都满足,如果要这三项要要求满足,那么同样以前面举的例子来说明,调度周期为1350可以满足上述三项的要求,调度周期为1206也可以满足上述三项的要求。需要说明的是,由于本申请实施例中的调度周期包含的时钟周期数与填桶周期包含的时钟周期数相等,因此,如果调度周期满足上述三项的要求,则填桶周期也满足上述三项的要求。Optionally, the scheduling period in the embodiment of the present application needs to satisfy one or more of the three conditions in Formula 1 above. For example, all three items are satisfied. If these three items are required to be satisfied, then the same As an example to illustrate, the scheduling period of 1350 can meet the above three requirements, and the scheduling period of 1206 can also meet the above three requirements. It should be noted that, since the number of clock cycles included in the scheduling cycle and the number of clock cycles included in the bucket filling cycle in the embodiment of the present application are equal, if the scheduling cycle meets the requirements of the above three items, the bucket filling cycle also meets the above three Item requirements.
设备获取填桶周期和调度周期的方式有很多,例如,一种方案中,设备根据上述条件自动计算调度周期和填桶周期,另外一种方案中,人为按照上述条件计算调度周期和填桶周期,然后配置到设备上。当然,还存在其他方案,此处不再一一举例。There are many ways for the device to obtain the bucket filling period and the scheduling period. For example, in one solution, the device automatically calculates the scheduling period and the bucket filling period according to the above conditions, and in another solution, the scheduling period and the bucket filling period are calculated manually according to the above conditions. And then configure it on the device. Of course, there are other solutions, no examples are given here.
步骤S502:所述设备根据所述调度周期对所述设备的输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶。Step S502: The device schedules the output port of the device according to the scheduling period and fills the token bucket according to the bucket filling period.
具体地,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述设备的输出端口中的任意一个输出端口。可选的,如果设备就只有该第一端口,那么第一端口的带宽即等于设备的总输出带宽,此时第一端口占用所述调度周期中的全部时钟周期。Specifically, the number of clock cycles occupied by the first port in the scheduling period is positively correlated with the proportion of the bandwidth of the first port in the total output bandwidth of the device. The first port is the Any one of the output ports of the device. Optionally, if the device has only the first port, the bandwidth of the first port is equal to the total output bandwidth of the device, and the first port occupies all clock cycles in the scheduling period.
在一种可选的方案中,第一端口在所述调度周期中占用的时钟周期数h满足公式2:In an optional solution, the number h of clock cycles occupied by the first port in the scheduling period satisfies Formula 2:
Figure PCTCN2019070594-appb-000004
Figure PCTCN2019070594-appb-000004
其中,H为所述调度周期包含的时钟周期数,s1为所述第一端口的带宽,S为所述总输出带宽。Where H is the number of clock cycles included in the scheduling period, s1 is the bandwidth of the first port, and S is the total output bandwidth.
举例来说,假设设备的总输出带宽为1200G,该总输出带宽由10*100G+20*10G构成。即10个100G带宽的端口和20个10G带宽的端口,并且调度周期为1350。For example, assume that the total output bandwidth of the device is 1200G, and the total output bandwidth is composed of 10*100G+20*10G. That is, 10 ports with 100G bandwidth and 20 ports with 10G bandwidth, and the scheduling period is 1350.
那么每个100G带宽的端口占用该调度周期的时钟周期数h为:
Figure PCTCN2019070594-appb-000005
Then the number of clock cycles h occupied by each 100G bandwidth port in this scheduling cycle is:
Figure PCTCN2019070594-appb-000005
那么每个10G带宽的端口占用该调度周期的时钟周期数h为:Then the number of clock cycles h that each 10G bandwidth port occupies in this scheduling cycle is:
Figure PCTCN2019070594-appb-000006
Figure PCTCN2019070594-appb-000006
总而言之,这30个端口占用的时钟周期之和不得超过一个调度周期。按照上面的举例,在调度周期1350内,每个100G带宽的端口占用112个时钟周期,每个10G带宽的端口占用11个时钟周期,在每个端口占用的时钟周期内用于为该端口调度数据。In short, the sum of the clock cycles occupied by these 30 ports must not exceed one scheduling cycle. According to the above example, in the scheduling period of 1350, each 100G bandwidth port occupies 112 clock cycles, each 10G bandwidth port occupies 11 clock cycles, and is used to schedule the port in the clock cycle occupied by each port data.
以上介绍了在调度周期内每个端口占用的时钟周期h,在该时钟周期h内还需要对令牌桶进行填桶,填桶的令牌量需要满足相应的条件,下面以第一端口为例来举例说明。可选的,在对所述第一端口进行调度所经历的h个时钟周期内,向所述令牌桶填桶的令牌总量m满足公式3:The above describes the clock period h occupied by each port during the scheduling period. In this clock period h, the token bucket needs to be filled. The amount of tokens filled in the bucket needs to meet the corresponding conditions. The following uses the first port as Examples to illustrate. Optionally, the total number of tokens m filled into the token bucket within the h clock cycles experienced by scheduling the first port satisfies formula 3:
m=s1*H/f         公式3m=s1*H/f Formula 3
在公式3中,f为所述设备的工作时钟频率,s1为第一端口的带宽,H为调度周期。In Formula 3, f is the working clock frequency of the device, s1 is the bandwidth of the first port, and H is the scheduling period.
举例来说,假若第一端口的带宽s1为100G,调度器的调度周期为1350,f为1.2GHz,那么,在第一端口进行调度所经历的112个时钟周期内,向令牌桶填桶的令牌总量m为112500bit。例如,在这112个时钟周期中的11个时钟周期内,每个时钟周期都填桶1000bit,在除这111个时钟周期外的1个时钟周期内填桶1500bit。For example, if the bandwidth s1 of the first port is 100G, the scheduling period of the scheduler is 1350, and f is 1.2 GHz, then in the 112 clock cycles that the first port performs scheduling, the token bucket is filled. The total number of tokens m is 112500bit. For example, in 11 of the 112 clock cycles, each clock cycle is filled with 1000 bits in a bucket, and in addition to these 111 clock cycles, the bucket is filled with 1500 bits in 1 clock cycle.
举例老说,假若第一端口的带宽s1为10G,调度器的调度周期为1350,f为1.2GHz,那么,在第一端口进行调度所经历的11个时钟周期内,向令牌桶填桶的令牌总量m为11250bit。例如,在这11个时钟周期中的10个时钟周期内,每个时钟周期都填桶1016bit,在除这10个时钟周期外的1个时钟周期内填桶1090bit。For example, if the bandwidth s1 of the first port is 10G, the scheduling period of the scheduler is 1350, and f is 1.2 GHz, then the token bucket is filled into the token bucket within 11 clock cycles of the first port. The total number of tokens m is 11250bit. For example, in 10 clock cycles out of these 11 clock cycles, each clock cycle fills 1016 bits in a bucket, and in 10 clock cycles other than these 10 clock cycles fills 1090 bits in a bucket.
上面以第一端口为例对各个输出端口在调度周期内占用的时钟周期h,及在每个端口占用的时钟周期内需填桶的令牌总量m进行了介绍。下面以此为基础,以第一端口为例举例讲述具体如何调度和填桶。Taking the first port as an example, the clock period h occupied by each output port during the scheduling period and the total amount m of tokens to be filled in the clock period occupied by each port are introduced. Based on this, the first port is used as an example to describe how to schedule and fill a bucket.
在一种可选的调度和填桶方案中,首先,设备为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m。然后,所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始化为所述令牌总量m。可以理解的是,该第一令牌量n1是一个预先设置的一个整数,可以尽量让该整数趋近m/h。采用这种方式,对第一端口只需配置剩余令牌量K、第一令牌量n1和标记参数即可,无需对第一端口的对应的每个时钟周期进行单独配置,降低了配置的复杂度,且这个流程实现起来比较简单,能够节省硬件和软件资源。In an optional scheduling and bucket filling scheme, first, the device configures a token parameter for the first port, the token parameter includes a first token parameter, and the first token parameter includes a remaining token The amount K, the first token amount n1, and the marker bit parameter, the marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total amount of tokens m. Then, it turns to schedule the first port when scheduling the first port within the scheduling period, and judge whether the current clock period is the clock period marked by the flag bit in the token parameter; If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update The card amount minus the first token amount n1; if yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the token The total amount m. It can be understood that the first token amount n1 is a preset integer, and the integer can be made as close to m/h as possible. In this way, only the remaining token amount K, the first token amount n1 and the marking parameters need to be configured for the first port, without separately configuring each corresponding clock cycle of the first port, which reduces the configuration Complexity, and this process is relatively simple to implement, which can save hardware and software resources.
可以理解的是,按照上述第一个步骤配置了令牌参数后,后续每个调度周期都根据该令牌参数进行调度即可,无需每个调度周期均进行配置。It can be understood that after the token parameters are configured according to the first step above, each subsequent scheduling cycle may be scheduled according to the token parameters, and it is not necessary to configure each scheduling cycle.
可选的,所述令牌参数还包括第二令牌参数,其中,所述第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,所述第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。也即是说,在配置令牌参数时配置多套参数,因为端口带宽可能会发生变化,如果变化后还按照变化前的配置进行调度和填桶可能会出现问题,如果变化后临时进行配置也会导致一些时延,即端口带宽变化后无法立即执行调度和填桶操作。而这个可选方案预先预估了端口可能发生什么样的变化,然后据此预先配置一套备用的令牌参数,即第二令牌参数,第二令牌参数中的参数类型与第一令牌参数的参数类型相同,就是具体数值可能不同,第二令牌参数中的参数能够满足端口带宽变化后的调度和填桶需求。Optionally, the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, wherein the second The initial value of the remaining token amount K in the token is different from the initial value of the remaining token amount K in the first token, and the first token amount n1 in the second token is different from the first The first token amount n1 in the token is different; the first token parameter is used as a basis for the token bucket to fill the token when the bandwidth of the first port has not changed, the second token parameter It is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed. That is to say, when configuring token parameters, configure multiple sets of parameters, because the port bandwidth may change. If the scheduling and filling of the bucket are performed after the change, there may be problems. If the configuration is temporarily changed after the change, It will cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes. This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order The parameter types of the card parameters are the same, that is, the specific values may be different. The parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
在又一种可选的调度和填桶方案中,首先,设备为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令 牌总量m。然后,设备在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。In yet another optional scheduling and bucket filling scheme, first, the device maps a value for token size for each clock cycle in the scheduling cycle; wherein, the h clock cycles correspond to The sum of the values is equal to the total amount of tokens m. Then, the device schedules the first port during the h clock cycles in the scheduling cycle, and then performs the token on the token according to the value corresponding to each clock cycle in the h clock cycles Bucket filling.
举例来说,假若第一端口对应的h个调度周期需要填桶的令牌总量为100bit,且这h个时钟周期包括调度周期中的第1个,第3个,第6个和第10个时钟周期,那么可以预先为该调度周期内的第1个时钟周期映射数值20,为第3个时钟周期映射数值30,为第6个时钟周期映射数值40,以及为第10个时钟周期映射数值10,即这4个时钟周期映射的数值之和为100。后续,在调度到调度周期的第1个时钟周期时按照映射的数值20来填桶20bit的令牌,在调度到调度周期的第3个时钟周期时按照映射的数值30来填桶30bit的令牌,在调度到调度周期的第6个时钟周期时按照映射的数值40来填桶40bit的令牌,在调度到调度周期的第10个时钟周期时按照映射的数值10来填桶10bit的令牌。For example, if the total number of tokens that need to be filled in buckets for the h scheduling cycles corresponding to the first port is 100 bits, and the h clock cycles include the first, third, sixth, and tenth in the scheduling cycle Clock cycles, you can map the value 20 for the first clock cycle in the scheduling cycle, the value 30 for the third clock cycle, the value 40 for the sixth clock cycle, and the value for the 10th clock cycle The value 10, that is, the sum of the values mapped in these four clock cycles is 100. Later, when scheduling to the first clock cycle of the scheduling cycle, the 20-bit token is filled according to the mapped value of 20, and when scheduling to the third clock cycle of the scheduling cycle, the 30-bit bucket is filled according to the mapped value of 30. Cards, when scheduling to the 6th clock cycle of the scheduling cycle, fill the bucket with 40bit tokens according to the mapped value of 40, and when scheduling to the 10th clock cycle of the scheduling cycle, fill the bucket with 10bits according to the mapped value of 10. brand.
在图5所描述的方法中,将调度器的调度周期与令牌桶的填桶周期设置为相同,使得调度数据的速度与填桶令牌的速度相匹配,因此令牌桶不需要配置较大的桶深,一方面降低了配置较大桶深的实现代价,具体来说,由于调度周期与令牌桶的填桶周期设置为相同,因此每个时钟周期同时发生扣桶和填桶,因此扣桶和填桶可以合为一次读和写,而不是扣桶和填桶各一次读和写,显著降低了读写复杂度,即降低了对所使用的存储器的缓存性能要求;另一方面,减少了流量突发,提升了设备的传输性能。In the method described in FIG. 5, the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured. The large bucket depth reduces the implementation cost of configuring a larger bucket depth. Specifically, since the scheduling period and the token bucket filling period are set to be the same, bucket deduction and bucket filling occur at the same time every clock cycle, so Buckle filling and bucket filling can be combined into one read and write, instead of one reading and writing of bucket filling and filling, which significantly reduces the complexity of reading and writing, that is, reduces the cache performance requirements of the memory used; on the other hand , Which reduces traffic bursts and improves the transmission performance of the device.
上述详细阐述了本发明实施例的方法,下面提供了本发明实施例的装置。以上从硬件结构的角度对设备进行了介绍,下面从软件功能的角度按照功能模块对设备进行介绍。The method of the embodiment of the present invention is described in detail above, and the device of the embodiment of the present invention is provided below. The above introduces the device from the perspective of hardware structure, and the following introduces the device from the perspective of software functions according to functional modules.
请参见图6,图6是本发明实施例提供的一种流量整形设备60的结构示意图,该流量整形设备60可以包括处理单元601、调度器602和X个输出端口603(图6以输出端口603为三个为例进行示意),其中:Please refer to FIG. 6. FIG. 6 is a schematic structural diagram of a traffic shaping device 60 according to an embodiment of the present invention. The traffic shaping device 60 may include a processing unit 601, a scheduler 602, and X output ports 603 (FIG. 6 shows output ports 603 shows three examples), where:
处理单元601用于获取所述调度器602的调度周期和令牌桶的填桶周期,其中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等;该处理单元601可以为一个或多个处理器,该处理器可以为中央处理器CPU,或者现场可编程逻辑门阵列FPGA,或者专用集成电路ASIC,等等。The processing unit 601 is used to obtain the scheduling period of the scheduler 602 and the bucket filling period of the token bucket, wherein the number of clock cycles included in the token bucket filling period and the clock included in the scheduling period of the scheduler The number of cycles is equal; the processing unit 601 may be one or more processors, and the processor may be a central processing unit CPU, or a field programmable logic gate array FPGA, or an application specific integrated circuit ASIC, and so on.
调度器602用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,其中,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述设备的输出端口中的任意一个输出端口,X为大于或者等于1的正整数。The scheduler 602 is configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, where the first port occupies the scheduling period The number of clock cycles is positively related to the ratio of the bandwidth of the first port to the total output bandwidth of the device. The first port is any one of the output ports of the device, and X is greater than or A positive integer equal to 1.
该X个输出端口可以分别为X个物理上的数据发送电路,也可以为对一个物理上的数据发送电路进行逻辑划分得到的X个逻辑上的数据发送电路。The X output ports may be X physical data transmission circuits respectively, or may be X logical data transmission circuits obtained by logically dividing one physical data transmission circuit.
通过运行上述单元,将调度器的调度周期与令牌桶的填桶周期设置为相同,使得调度数据的速度与填桶令牌的速度相匹配,因此令牌桶不需要配置较大的桶深,一方面降低了配置较大桶深的实现代价,具体来说,由于调度周期与令牌桶的填桶周期设置为相同,因此每个时钟周期同时发生扣桶和填桶,因此扣桶和填桶可以合为一次读和写,而不是扣桶和填桶各一次读和写,显著降低了读写复杂度,即降低了对所使用的存储器的缓存性能要求;另一方面,减少了流量突发,提升了设备的传输性能。By running the above unit, the scheduling period of the scheduler and the bucket filling period of the token bucket are set to be the same, so that the speed of the scheduling data matches the speed of the bucket filling token, so the token bucket does not need to be configured with a large bucket depth On the one hand, the implementation cost of configuring a larger bucket depth is reduced. Specifically, since the scheduling period and the token bucket filling period are set to be the same, the bucket deduction and bucket filling occur at the same time every clock cycle, so the bucket deduction and filling Buckets can be combined into one read and write, instead of deducting and filling buckets, which significantly reduces read and write complexity, that is, reduces the cache performance requirements of the memory used; on the other hand, reduces traffic Burst improves the transmission performance of the device.
在一种可能的实现方式中,所述调度器,用于根据所述调度周期对所述X个输出端口 进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:In a possible implementation manner, the scheduler, configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, includes:
为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m;Configure a token parameter for the first port, the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;When it is in turn to schedule the first port when scheduling the first port, and determine whether the current clock cycle is the clock cycle marked by the flag bit in the token parameter;
若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update Card amount minus the first token amount n1;
若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始化为所述令牌总量m。If yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the total token amount m.
在这种实现方式中,对第一端口只需配置剩余令牌量K、第一令牌量n1和标记参数即可,无需对第一端口的对应的每个时钟周期进行单独配置,降低了配置的复杂度,且这个流程实现起来比较简单,能够节省硬件和软件资源。In this implementation, only the remaining token amount K, the first token amount n1, and the marking parameters need to be configured for the first port, and there is no need to separately configure each corresponding clock cycle of the first port, which reduces The complexity of the configuration, and this process is relatively simple to implement, which can save hardware and software resources.
在又种可能的实现方式中,所述令牌参数还包括第二令牌参数,其中,所述第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,所述第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。In yet another possible implementation manner, the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, where , The initial value of the remaining token amount K in the second token is different from the initial value of the remaining token amount K in the first token, the first token amount n1 in the second token Different from the first token amount n1 in the first token; the first token parameter is used as a basis for the token bucket to fill the bucket token when the bandwidth of the first port has not changed, the The second token parameter is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed.
在这种实现方式中,在配置令牌参数时配置多套参数,因为端口带宽可能会发生变化,如果变化后还按照变化前的配置进行调度和填桶可能会出现问题,如果变化后临时进行配置也会导致一些时延,即端口带宽变化后无法立即执行调度和填桶操作。而这个可选方案预先预估了端口可能发生什么样的变化,然后据此预先配置一套备用的令牌参数,即第二令牌参数,第二令牌参数中的参数类型与第一令牌参数的参数类型相同,就是具体数值可能不同,第二令牌参数中的参数能够满足端口带宽变化后的调度和填桶需求。In this implementation, multiple sets of parameters are configured when configuring the token parameters, because the port bandwidth may change. If the configuration is changed and the bucket is filled according to the configuration before the change, there may be problems. If it is temporarily changed after the change The configuration will also cause some delay, that is, the scheduling and bucket filling operations cannot be performed immediately after the port bandwidth changes. This optional solution predicts in advance what kind of changes may occur on the port, and then pre-configures a set of spare token parameters according to this, namely the second token parameter, the parameter type in the second token parameter and the first order The parameter types of the card parameters are the same, that is, the specific values may be different. The parameters in the second token parameters can meet the scheduling and bucket filling requirements after the port bandwidth changes.
在又一种可能的实现方式中,所述调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:In yet another possible implementation manner, the scheduler, configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, includes:
为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令牌总量m;Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。Scheduling the first port in the h clock cycles in the scheduling cycle, and filling the token bucket according to the value corresponding to each clock cycle in the h clock cycles .
在这种实现方式中,预先为调度周期内的每一个时钟周期映射一个数值,后续每次调度和填桶到每个时钟周期时都按照该时钟周期对应的数值来填桶,由于各个时钟周期之间的数值相互独立互不影响,因此即便在哪个时钟周期出现意外也不会对后续其他时钟周期内的填桶造成影响。In this implementation, a value is mapped in advance for each clock cycle in the scheduling cycle, and each subsequent scheduling and bucket filling to each clock cycle will fill the bucket according to the value corresponding to the clock cycle, because each clock cycle The values are independent of each other and do not affect each other, so even in which clock cycle an accident occurs will not affect the bucket filling in other subsequent clock cycles.
在又一种可能的实现方式中,所述令牌桶的填桶周期与所述调度器的调度周期同步。可以理解,这样可以使得调度(伴随着扣桶)与填桶高度匹配,即每个时钟周期内完成一次调度的同时还完成一次填桶,能够最大限度地降低桶深。In yet another possible implementation manner, the bucket filling period of the token bucket is synchronized with the scheduling period of the scheduler. It can be understood that this can make the scheduling (along with buckling buckets) highly match the bucket filling, that is, the bucket filling is completed once when the scheduling is completed once per clock cycle, which can minimize the bucket depth.
在又一种可能的实现方式,所述第一端口在所述调度周期中占用的时钟周期数h满足如下公式:In yet another possible implementation manner, the number h of clock cycles occupied by the first port in the scheduling period satisfies the following formula:
Figure PCTCN2019070594-appb-000007
Figure PCTCN2019070594-appb-000007
其中,H为所述调度周期包含的时钟周期数,s1为所述第一端口的带宽,S为所述总输出带宽。Where H is the number of clock cycles included in the scheduling period, s1 is the bandwidth of the first port, and S is the total output bandwidth.
在这种实现方式中,根据第一端口的带宽与总输出带宽的比值来确定第一端口占用的调度周期,采用这种方式可以使得每个输出端口在调度时所占用的时钟周期数与其带宽实际需求尽量相匹配且各个输出端口之间相对均衡,最大限度了满足了整体的带宽需求。In this implementation, the scheduling period occupied by the first port is determined according to the ratio of the bandwidth of the first port to the total output bandwidth. In this way, the number of clock cycles and bandwidth occupied by each output port during scheduling can be made The actual needs are matched as much as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
在又一种可能的实现方式中,对所述第一端口进行调度所经历的h个时钟周期内,向所述令牌桶填桶的令牌总量m满足如下公式:In yet another possible implementation manner, within h clock cycles of scheduling the first port, the total number of tokens m filled into the token bucket satisfies the following formula:
m=s1*H/fm=s1*H/f
其中,f为所述设备的工作时钟频率。Where f is the working clock frequency of the device.
在这种实现方式中,根据第一端口的带宽来确定第一端口在调度期间所需填桶的总令牌量,采用这种方式可以使得每个输出端口在调度过程中填桶的令牌量与其带宽实际需求尽量相匹配且各个输出端口之间相对均衡,最大限度了满足了整体的带宽需求。In this implementation, the total number of tokens required for the first port to fill the bucket during the scheduling period is determined according to the bandwidth of the first port. In this way, each output port can fill the tokens in the bucket during the scheduling process The volume and its actual bandwidth requirements are matched as closely as possible and the output ports are relatively balanced, which maximizes the overall bandwidth requirements.
在又一种可选的实现方式中,所述调度周期包含的时钟周期数H满足如下公式:In yet another optional implementation manner, the number of clock cycles H included in the scheduling period satisfies the following formula:
Figure PCTCN2019070594-appb-000008
Figure PCTCN2019070594-appb-000008
其中,S为所述设备的总输出带宽,t为所述设备的各个输出端口的带宽的最小公约数,p为所述设备的各个输出端口的端口总数,f为所述设备的工作时钟频率。Where S is the total output bandwidth of the device, t is the least common divisor of the bandwidth of each output port of the device, p is the total number of ports of each output port of the device, and f is the operating clock frequency of the device .
在这种实现方式中,公式中的第一项尽量减小了输出端口的带宽浪费,第二项保证了每个调度周期内每个端口能够有一次调度机会,第三项能够保证每次填桶令牌量为整数,可以通过简单的电路实现,即降低了实现成本。In this implementation, the first term in the formula minimizes the waste of output port bandwidth, the second term ensures that each port can have a scheduling opportunity in each scheduling cycle, and the third term can ensure that each time The amount of bucket tokens is an integer, which can be realized by a simple circuit, that is, the implementation cost is reduced.
需要说明的是,各个单元的实现及有益效果还可以对应参照图4所示的方法实施例的相应描述。It should be noted that the implementation and beneficial effects of each unit may also correspond to the corresponding description of the method embodiment shown in FIG. 4.
本发明实施例还提供一种芯片系统,所述芯片系统包括至少一个处理器,存储器和接口电路,所述存储器、所述收发器和所述至少一个处理器通过线路互联,所述至少一个存储器中存储有指令;所述指令被所述处理器执行时,实现图5所示的方法流程。An embodiment of the present invention further provides a chip system. The chip system includes at least one processor, a memory, and an interface circuit. The memory, the transceiver, and the at least one processor are interconnected by a line. The at least one memory There are instructions stored in it; when the instructions are executed by the processor, the method flow shown in FIG. 5 is realized.
本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在处理器上运行时,实现图5所示的方法流程。An embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored, and when it runs on a processor, the method flow shown in FIG. 5 is implemented.
本发明实施例还提供一种计算机程序产品,当所述计算机程序产品在处理器上运行时,实现图5所示的方法流程得以实现。An embodiment of the present invention also provides a computer program product. When the computer program product runs on a processor, the method flow shown in FIG. 5 is realized.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述N方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等N种可存储程序代码的介质。A person of ordinary skill in the art may understand that all or part of the process in the method of the foregoing embodiments may be implemented by a computer program instructing related hardware. The program may be stored in a computer-readable storage medium, and when the program is executed , May include the process of the N method embodiment described above. The foregoing storage media include: ROM or random storage memory RAM, magnetic disks or optical disks and other N types of media that can store program codes.

Claims (17)

  1. 一种流量整形方法,其特征在于,包括:A traffic shaping method, which is characterized by including:
    设备获取调度器的调度周期和令牌桶的填桶周期,其中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等;The device obtains the scheduling cycle of the scheduler and the bucket filling cycle of the token bucket, where the number of clock cycles included in the token bucket filling cycle is equal to the number of clock cycles included in the scheduler's scheduling cycle;
    所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,其中,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述X个输出端口中的任意一个输出端口,X为大于或者等于1的正整数。The device schedules the X output ports of the device according to the scheduling period and fills the token bucket according to the bucket filling period, wherein the first port occupies the scheduling period The number of clock cycles is positively correlated with the ratio of the bandwidth of the first port to the total output bandwidth of the device, the first port is any one of the X output ports, and X is greater than or A positive integer equal to 1.
  2. 根据权利要求1所述的方法,其特征在于,所述令牌桶的填桶周期与所述调度器的调度周期同步。The method according to claim 1, wherein the bucket filling period of the token bucket is synchronized with the scheduling period of the scheduler.
  3. 根据权利要求1或2所述的方法,其特征在于,所述第一端口在所述调度周期中占用的时钟周期数h满足如下公式:The method according to claim 1 or 2, wherein the number h of clock cycles occupied by the first port in the scheduling period satisfies the following formula:
    Figure PCTCN2019070594-appb-100001
    Figure PCTCN2019070594-appb-100001
    其中,H为所述调度周期包含的时钟周期数,s1为所述第一端口的带宽,S为所述总输出带宽。Where H is the number of clock cycles included in the scheduling period, s1 is the bandwidth of the first port, and S is the total output bandwidth.
  4. 根据权利要求3所述的方法,其特征在于,对所述第一端口进行调度所经历的h个时钟周期内,向所述令牌桶填桶的令牌总量m满足如下公式:The method according to claim 3, wherein the total number of tokens m filled into the token bucket within the h clock cycles experienced by scheduling the first port satisfies the following formula:
    m=s1*H/fm=s1*H/f
    其中,f为所述设备的工作时钟频率。Where f is the working clock frequency of the device.
  5. 根据权利要求4所述的方法,其特征在于,所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:The method according to claim 4, wherein the device schedules the X output ports of the device according to the scheduling period and fills the token bucket according to the bucket filling period, including :
    为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m;Configure a token parameter for the first port, the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
    所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;When it is in turn to schedule the first port when scheduling the first port, and determine whether the current clock cycle is the clock cycle marked by the flag bit in the token parameter;
    若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update Card amount minus the first token amount n1;
    若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始化为所述令牌总量m。If yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the total token amount m.
  6. 根据权利要求5所述的方法,其特征在于,所述令牌参数还包括第二令牌参数,其中,所述第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,所述第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第 二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。The method according to claim 5, wherein the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a token Bit parameter, wherein the initial value of the remaining token amount K in the second token is different from the initial value of the residual token amount K in the first token, the first in the second token The token amount n1 is different from the first token amount n1 in the first token; the first token parameter is used to fill the bucket token as a token bucket when the bandwidth of the first port has not changed According to this, the second token parameter is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed.
  7. 根据权利要求4所述的方法,其特征在于,所述设备根据所述调度周期对所述设备的X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:The method according to claim 4, wherein the device schedules the X output ports of the device according to the scheduling period and fills the token bucket according to the bucket filling period, including :
    为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令牌总量m;Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
    在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。Scheduling the first port in the h clock cycles in the scheduling cycle, and filling the token bucket according to the value corresponding to each clock cycle in the h clock cycles .
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述调度周期包含的时钟周期数H满足如下公式:The method according to any one of claims 1-7, wherein the number H of clock cycles included in the scheduling period satisfies the following formula:
    Figure PCTCN2019070594-appb-100002
    Figure PCTCN2019070594-appb-100002
    其中,S为所述设备的总输出带宽,t为所述设备的各个输出端口的带宽的最小公约数,p为所述设备的各个输出端口的端口总数,f为所述设备的工作时钟频率。Where S is the total output bandwidth of the device, t is the least common divisor of the bandwidth of each output port of the device, p is the total number of ports of each output port of the device, and f is the operating clock frequency of the device .
  9. 一种流量整形设备,其特征在于,包括处理单元、调度器和X个输出端口,X为大于或者等于1的正整数,其中:A traffic shaping device, characterized by comprising a processing unit, a scheduler and X output ports, X is a positive integer greater than or equal to 1, wherein:
    所述处理单元,用于获取所述调度器的调度周期和令牌桶的填桶周期,其中,所述令牌桶的填桶周期包含的时钟周期数与所述调度器的调度周期包含的时钟周期数相等;The processing unit is configured to obtain a scheduling period of the scheduler and a bucket filling period of the token bucket, wherein the number of clock cycles included in the token bucket filling period and the scheduling period of the scheduler include The number of clock cycles is equal;
    所述调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,其中,第一端口在所述调度周期中所占用的时钟周期数与所述第一端口的带宽在所述设备的总输出带宽中所占的比重呈正相关,所述第一端口为所述X个输出端口中的任意一个输出端口。The scheduler is configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period, wherein the first port is set in the scheduling period The number of clock cycles occupied is positively related to the proportion of the bandwidth of the first port in the total output bandwidth of the device, and the first port is any one of the X output ports.
  10. 根据权利要求9所述的设备,其特征在于,所述令牌桶的填桶周期与所述调度器的调度周期同步。The device according to claim 9, wherein the token bucket filling cycle is synchronized with the scheduling cycle of the scheduler.
  11. 根据权利要求9或10所述的设备,其特征在于,所述第一端口在所述调度周期中占用的时钟周期数h满足如下公式:The device according to claim 9 or 10, wherein the number h of clock cycles occupied by the first port in the scheduling period satisfies the following formula:
    Figure PCTCN2019070594-appb-100003
    Figure PCTCN2019070594-appb-100003
    其中,H为所述调度周期包含的时钟周期数,s1为所述第一端口的带宽,S为所述总输出带宽。Where H is the number of clock cycles included in the scheduling period, s1 is the bandwidth of the first port, and S is the total output bandwidth.
  12. 根据权利要求11所述的设备,其特征在于,对所述第一端口进行调度所经历的h个时钟周期内,向所述令牌桶填桶的令牌总量m满足如下公式:The device according to claim 11, wherein the total number of tokens m filled into the token bucket in the h clock cycles experienced by scheduling the first port satisfies the following formula:
    m=s1*H/fm=s1*H/f
    其中,f为所述设备的工作时钟频率。Where f is the working clock frequency of the device.
  13. 根据权利要求12所述的设备,其特征在于,所述调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:The device according to claim 12, wherein the scheduler is configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period ,include:
    为所述第一端口配置令牌参数,所述令牌参数包括第一令牌参数,所述第一令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,所述标记位参数用于标记所述h个时钟周期内的一个时钟周期;所述剩余令牌量的初始值等于所述令牌总量m;Configure a token parameter for the first port, the token parameter includes a first token parameter, the first token parameter includes a remaining token amount K, a first token amount n1, and a mark bit parameter, the The marker bit parameter is used to mark one clock cycle within the h clock cycles; the initial value of the remaining token amount is equal to the total number of tokens m;
    所述调度周期内轮流到对所述第一端口调度时对所述第一端口进行调度,并判断当前时钟周期是否为所述令牌参数中的所述标记位所标记的时钟周期;When it is in turn to schedule the first port when scheduling the first port, and determine whether the current clock cycle is the clock cycle marked by the flag bit in the token parameter;
    若否,则向所述令牌桶填桶所述第一令牌量n1并更新所述令牌参数中的剩余令牌量K,其中,更新后的剩余令牌量等于更新前的剩余令牌量减去所述第一令牌量n1;If not, fill the token bucket with the first token amount n1 and update the remaining token amount K in the token parameter, where the updated remaining token amount is equal to the remaining order before the update Card amount minus the first token amount n1;
    若是,则向所述令牌桶填桶当前令牌量K,并将所述令牌参数中的剩余令牌量K初始化为所述令牌总量m。If yes, fill the token bucket with the current token amount K, and initialize the remaining token amount K in the token parameters to the total token amount m.
  14. 根据权利要求13所述的设备,其特征在于,所述令牌参数还包括第二令牌参数,其中,所述第二令牌参数包括剩余令牌量K、第一令牌量n1和标记位参数,其中,所述第二令牌中的剩余令牌量K的初始值与所述第一令牌中的剩余令牌量K的初始值不同,所述第二令牌中的第一令牌量n1与所述第一令牌中的第一令牌量n1不同;所述第一令牌参数用于在所述第一端口的带宽未改变时作为令牌桶填桶令牌的依据,所述第二令牌参数用于在所述第一端口的带宽发生改变后作为令牌桶填桶令牌的依据。The device according to claim 13, wherein the token parameter further includes a second token parameter, wherein the second token parameter includes a remaining token amount K, a first token amount n1, and a token Bit parameter, wherein the initial value of the remaining token amount K in the second token is different from the initial value of the residual token amount K in the first token, the first in the second token The token amount n1 is different from the first token amount n1 in the first token; the first token parameter is used to fill the bucket token as a token bucket when the bandwidth of the first port has not changed According to this, the second token parameter is used as a basis for the token bucket to fill the bucket token after the bandwidth of the first port is changed.
  15. 根据权利要求12所述的设备,其特征在于,所述调度器,用于根据所述调度周期对所述X个输出端口进行调度以及根据所述填桶周期对所述令牌桶进行填桶,包括:The device according to claim 12, wherein the scheduler is configured to schedule the X output ports according to the scheduling period and fill the token bucket according to the bucket filling period ,include:
    为所述调度周期内的每个时钟周期映射一个用于表征令牌量大小的数值;其中,所述h个时钟周期对应的数值之和等于所述令牌总量m;Mapping a value representing the amount of tokens for each clock cycle within the scheduling cycle; wherein the sum of the values corresponding to the h clock cycles is equal to the total number of tokens m;
    在所述调度周期中的所述h个时钟周期内对所述第一端口进行调度,并按照所述h个时钟周期内的每个时钟周期对应的所述数值对所述令牌桶填桶。Scheduling the first port in the h clock cycles in the scheduling cycle, and filling the token bucket according to the value corresponding to each clock cycle in the h clock cycles .
  16. 根据权利要求9-15任一项所述的设备,其特征在于,所述调度周期包含的时钟周期数H满足如下公式:The device according to any one of claims 9 to 15, wherein the number H of clock cycles included in the scheduling period satisfies the following formula:
    Figure PCTCN2019070594-appb-100004
    Figure PCTCN2019070594-appb-100004
    其中,S为所述设备的总输出带宽,t为所述设备的各个输出端口的带宽的最小公约数, p为所述设备的各个输出端口的端口总数,f为所述设备的工作时钟频率。Where S is the total output bandwidth of the device, t is the least common divisor of the bandwidth of each output port of the device, p is the total number of ports of each output port of the device, and f is the working clock frequency of the device .
  17. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有程序指令,当所述程序指令在处理器上运行时,实现权利要求1-8任一项所述的方法。A computer-readable storage medium, characterized in that program instructions are stored in the computer-readable storage medium, and when the program instructions run on a processor, the method according to any one of claims 1-8 is implemented .
PCT/CN2019/070594 2019-01-07 2019-01-07 Traffic shaping method and related device WO2020142867A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201980065232.6A CN112805971B (en) 2019-01-07 2019-01-07 Traffic shaping method and related equipment
PCT/CN2019/070594 WO2020142867A1 (en) 2019-01-07 2019-01-07 Traffic shaping method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/070594 WO2020142867A1 (en) 2019-01-07 2019-01-07 Traffic shaping method and related device

Publications (1)

Publication Number Publication Date
WO2020142867A1 true WO2020142867A1 (en) 2020-07-16

Family

ID=71520649

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/070594 WO2020142867A1 (en) 2019-01-07 2019-01-07 Traffic shaping method and related device

Country Status (2)

Country Link
CN (1) CN112805971B (en)
WO (1) WO2020142867A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113645148A (en) * 2021-07-01 2021-11-12 苏州裕太微电子有限公司 Traffic shaper token updating system and method for time-sensitive network
CN113810307A (en) * 2021-10-11 2021-12-17 上海微盟企业发展有限公司 Data flow control method, system and storage medium
CN117041162A (en) * 2023-10-09 2023-11-10 芯耀辉科技有限公司 Traffic shaping method and device

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113422736B (en) * 2021-06-16 2022-06-14 中移(杭州)信息技术有限公司 Request management method, device, equipment and storage medium based on token bucket
CN115378879A (en) * 2022-08-22 2022-11-22 Oppo广东移动通信有限公司 Data control method and related device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100080331A1 (en) * 2008-09-26 2010-04-01 Qualcomm Incorporated Method and apparatus for integrated clock mismatch compensation and packet loss concealment
CN105656800A (en) * 2014-12-05 2016-06-08 中兴通讯股份有限公司 Method and device for transmitting message
CN106850456A (en) * 2015-11-25 2017-06-13 卡雷公司 Token bucket flow limiters

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140112147A1 (en) * 2012-10-19 2014-04-24 Broadcom Corporation Refresh mechanism for a token bucket
CN104753809B (en) * 2013-12-25 2019-04-02 深圳市中兴微电子技术有限公司 The method and device of token is added in a kind of traffic shaping
CN105024942B (en) * 2015-05-29 2018-05-08 桂林电子科技大学 A kind of dynamic flow monitoring method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100080331A1 (en) * 2008-09-26 2010-04-01 Qualcomm Incorporated Method and apparatus for integrated clock mismatch compensation and packet loss concealment
CN105656800A (en) * 2014-12-05 2016-06-08 中兴通讯股份有限公司 Method and device for transmitting message
CN106850456A (en) * 2015-11-25 2017-06-13 卡雷公司 Token bucket flow limiters

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113645148A (en) * 2021-07-01 2021-11-12 苏州裕太微电子有限公司 Traffic shaper token updating system and method for time-sensitive network
CN113645148B (en) * 2021-07-01 2024-04-05 裕太微电子股份有限公司 Traffic shaper token updating system and method for time-sensitive network
CN113810307A (en) * 2021-10-11 2021-12-17 上海微盟企业发展有限公司 Data flow control method, system and storage medium
CN117041162A (en) * 2023-10-09 2023-11-10 芯耀辉科技有限公司 Traffic shaping method and device
CN117041162B (en) * 2023-10-09 2024-02-09 芯耀辉科技有限公司 Traffic shaping method and device

Also Published As

Publication number Publication date
CN112805971A (en) 2021-05-14
CN112805971B (en) 2022-07-12

Similar Documents

Publication Publication Date Title
WO2020142867A1 (en) Traffic shaping method and related device
JP5863076B2 (en) Method, apparatus, and system for reconstructing and reordering packets
CN110166380B (en) Method for scheduling message, first network device and computer readable storage medium
CN106817317B (en) Traffic management with ingress control
US8917740B2 (en) Channel service manager
CN106209679B (en) Method and apparatus for using multiple linked memory lists
EP1774714B1 (en) Hierarchal scheduler with multiple scheduling lanes
US7564790B2 (en) Method and system for shaping traffic in a parallel queuing hierarchy
US20100191814A1 (en) System-On-A-Chip Employing A Network Of Nodes That Utilize Receive Side Flow Control Over Channels For Messages Communicated Therebetween
CN111512602B (en) Method, equipment and system for sending message
US20100158005A1 (en) System-On-a-Chip and Multi-Chip Systems Supporting Advanced Telecommunication Functions
US20100162265A1 (en) System-On-A-Chip Employing A Network Of Nodes That Utilize Logical Channels And Logical Mux Channels For Communicating Messages Therebetween
US20100158023A1 (en) System-On-a-Chip and Multi-Chip Systems Supporting Advanced Telecommunication Functions
US20050135355A1 (en) Switching device utilizing internal priority assignments
US20100161938A1 (en) System-On-A-Chip Supporting A Networked Array Of Configurable Symmetric Multiprocessing Nodes
WO2010074872A1 (en) System-on-a-chip and multi-chip systems supporting advanced telecommunications and other data processing applications
TW201543848A (en) Packet scheduling in a network processor
US7843940B2 (en) Filling token buckets of schedule entries
CN109962859A (en) A kind of method for dispatching message and equipment
CN112866135A (en) Method for sending message, first network equipment and computer readable storage medium
EP1073251A2 (en) Packet buffer management
Benacer et al. A high-speed traffic manager architecture for flow-based networking
CN106487713A (en) A kind of service quality multiplexing method and device
US10079769B1 (en) Methods and apparatus for implementing dynamic rate controllers using linked list of rate programs
US8467401B1 (en) Scheduling variable length packets

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19908882

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19908882

Country of ref document: EP

Kind code of ref document: A1