摘要 |
Disclosed are a sampling method and a network chip, the method comprising: when a network chip determines that it is necessary to perform sampling, the network chip performs an X-addition operation on a counter index upon reception of a message, and reads a return value of a counter, the return value containing the value of an overflow mark and a counter index after the X-addition operation, wherein X is a pre-set value, and the value of the overflow mark comprises: a first pre-set value or a second pre-set value, the first pre-set value indicating that the counter overflows after the X-addition operation, and the second pre-set value indicating that the counter does not overflow after the X-addition operation; the network chip judges whether the value of the overflow mark is the first pre-set value; and if the value of the overflow mark is the first pre-set value, the network chip performs sampling. |