Patent ID: 8085766

Claim:
A network device for providing statistical sampling of packets at ports, the network device comprising: an ingress module configured to randomly select a packet at one of a plurality of ingress ports for statistical sampling; a memory management unit configured to store packets received from the ingress module; an egress module configured to receive the stored packets from the memory management unit and to randomly select a packet at one of a plurality of egress ports for statistical sampling; and a processing module configured to receive a copy of a selected packet from at least one of the ingress module or egress module, make a determination whether the copy of the selected packet was received from the ingress module or the egress module, and perform statistical flow processing on the packet, based on the determination, wherein if the copy of the packet is received by the processing module from the ingress module, a CPU operation code is set to a source value to indicate that the received copy of the packet is due to ingress sampling by the ingress module, and wherein if the copy of the packet is received from the egress module, a CPU operation code is set to a destination value to indicate that the received copy of the packet is due to egress sampling by the egress module.