Skip to content
Ask AI

sFlow Configuration

sFlow is a network monitoring technology that collects network packet samples and sends them to a remote collector encapsulated in UDP packets.

sFlow technology implements the following two sampling methods:

Flow Sampling: This method samples data packets from interfaces with sFlow enabled according to a specific sampling method and ratio. It captures the first 128 bytes of the original packet, encapsulates it in an sFlow packet, and sends it to the collector. The current version only supports Flow Sampling.

Counter Sampling: The sFlow agent device periodically obtains traffic statistics from the interface and encapsulates them in an sFlow packet to be sent to the collector. The collector is only concerned with the number of packets on the interface and not the specific details of the packets.

Configuring sFlow Agent and sFlow Collector Information

Section titled “Configuring sFlow Agent and sFlow Collector Information”
OperationCommandDescription
Enter system configuration viewconfigure terminal
Enable sFlowsflow enable
Specify sFlow collector informationsflow collector name IP-address [port]
Specify sFlow agent informationsflow agent-id {ethernet|vlan|loopback} idSpecify the source IP address of the sFlow agent as a specific interface IP

The device supports two types of Flow sampling:

Interface-based Flow Sampling: Enable Flow sampling on an interface and set the sampling ratio. Packets in the specified sampling direction on this interface will be sampled according to the specified ratio.

OperationCommandDescription
Enter system configuration viewconfigure terminal
Enter interface configuration viewinterface ethernet id
Configure interface sampling ratesflow sample-rate number
OperationCommandDescription
View sFlow configuration informationshow sflow
View interface sampling ratesshow sflow interface

Network requirements

The PC is connected to the network through SwitchA, and the network administrator needs to monitor the traffic information of the PC to ensure the security of the network.

Procedure

  1. Configure SwitchA’s IP Address
sonic(config)# interface ethernet 1
sonic(config-if-1)# ip address 10.1.10.1/24
sonic(config)# interface ethernet 2
sonic(config-if-2)# ip address 10.1.20.1/24
sonic(config)# interface ethernet 3
sonic(config-if-3)# ip address 192.168.0.1/24
  1. Enable sFlow Functionality
sonic(config)# sflow enable
sonic(config)# sflow collector test 192.168.0.100
sonic(config)# sflow agent-id ethernet 3
  1. Enable Interface-based sFlow
sonic(config)# interface ethernet 1
sonic(config-if-1)# sflow sample-rate 10000