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.
展开▼