How to enable sflow server

How to enable sflow server

SFLOW (Sampled Flow): 

SFlow is a sampling technology invented by InMon and has become an industry standard defined in RFC 3176. It is a Network monitoring technology that collects and analyzes traffic statistics based on packet sampling.  

 

Tested model & firmware version: 

  • Switch model name: 

Accton-AS5712-54X 

  • Community sonic version: 

202211.2 

 

TOPOLOGY: 

               

Configuration commands (sonic configurations) 

Note: Commands are to be executed in sudo mode. 

Step1: Configure the IP address for interfaces as per topology. 

Step2: Default sflow is disabled and enable the sflow in switch. 

root@sonic:/home/admin# config sflow enable 

Note: sometimes get this error: Failed to enable unit: Unit file /etc/systemd/system/sflow.service is masked . 

If service is masked. 

root@sonic:/home/admin# systemctl unmask  sflow.service 

root@sonic:/home/admin# systemctl enable  sflow.service 

root@sonic:/home/admin# systemctl start sflow.service 

 

Step3: Check the default sflow and interfaces information. 

Note: 

  1. By default, sflow is enabled on all interfaces at the interface level. 

  1. The default Polling Interval is 20. 

  1. The default sample rate based on interface speed. 

  • 1-in-1000 for a 1G link 

  • 1-in-10,000 for a 10G link 

  • 1-in-40,000 for a 40G link 

  • 1-in-50,000 for a 50G link 

  • 1-in-100,000 for a 100G link 

  • 1-in-400,000 for a 400G link 

  1. The default UDP port is 6343. 

root@sonic:/home/admin# show sflow 

  

sFlow Global Information: 

  sFlow Admin State:          up 

  sFlow Polling Interval:     default 

  sFlow AgentID:              default 

  

  0 Collectors configured: 

 

 root@sonic:/home/admin# show sflow interface 

 

sFlow interface configurations 

+-------------+---------------+-----------------+ 

| Interface   | Admin State   |   Sampling Rate | 

+=============+===============+=================+ 

| Ethernet0   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet1   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet2   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet3   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet4   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet5   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet6   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet7   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet8   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet9   | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet10  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet11  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet12  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet13  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet14  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet15  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet16  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet17  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet18  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet19  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet20  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet21  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet22  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet23  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet24  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet25  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet26  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet27  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet28  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet29  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet30  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet31  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet32  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet33  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet34  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet35  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet36  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet37  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet38  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet39  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet40  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet41  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet42  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet43  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet44  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet45  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet46  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet47  | up            |           10000 | 

+-------------+---------------+-----------------+ 

| Ethernet48  | up            |          100000 | 

+-------------+---------------+-----------------+ 

| Ethernet52  | up            |          100000 | 

+-------------+---------------+-----------------+ 

| Ethernet56  | up            |          100000 | 

+-------------+---------------+-----------------+ 

| Ethernet60  | up            |          100000 | 

+-------------+---------------+-----------------+ 

| Ethernet64  | up            |          100000 | 

+-------------+---------------+-----------------+ 

| Ethernet68  | up            |          100000 | 

+-------------+---------------+-----------------+ 

 

 

Step4: Add the Sflow collector. 

Note: A maximum of 2 collectors is allowed. 

root@sonic:/home/admin#  config sflow collector add Test1 10.1.1.2   

 

Step5: Configure the Sflow for interfaces. 

root@sonic:/home/admin# config sflow interface disable all 

root@sonic:/home/admin# config sflow interface enable Ethernet4 

root@sonic:/home/admin# config sflow interface enable Ethernet6 

 

Step6: Add the Agent id for sflow. 

Note: Only a single agent-id is allowed. If agent-id is not specified (with this CLI), an appropriate IP that belongs to the switch is used as the agent-id based on some simple heuristics. 

root@sonic:/home/admin# config sflow agent-id Ethernet48 

 

Step6: Configure the polling interval for sflow range to be 0 to 300 seconds. 

root@sonic:/home/admin# config sflow polling-interval 50 

 

Step7: Configure the sflow sampling-rate. 

root@sonic:/home/admin# config sflow interface sample-rate Ethernet4 1000 

root@sonic:/home/admin# config sflow interface sample-rate Ethernet6 2000 

 

Step8: Check the sflow and interface information in sonic. 

root@sonic:/home/admin# show sflow 

 

sFlow Global Information: 

  sFlow Admin State:          up 

  sFlow Polling Interval:     50 

  sFlow AgentID:              Ethernet48 

  

  1 Collectors configured: 

    Name: Test1               IP addr: 10.1.1.2       UDP port: 6343   VRF: default 

 

root@sonic:/home/admin# show sflow interface 

  

sFlow interface configurations 

+-------------+---------------+-----------------+ 

| Interface   | Admin State   |   Sampling Rate | 

+=============+===============+=================+ 

| Ethernet4   | up            |            1000 | 

+-------------+---------------+-----------------+ 

| Ethernet6   | up            |            2000 | 

+-------------+---------------+-----------------+ 

 

Step9: Send the Packets in TGEN (Traffic Generator) to switch and capture packets in sflow collector port. 

root@sonic:/home/admin# tcpdump -nei Ethernet48 

tcpdump: verbose output suppressed, use -v[v]... for full protocol decode 

listening on Ethernet48, link-type EN10MB (Ethernet), snapshot length 262144 bytes 

10:52:08.988470 14:44:8f:bc:a2:c8 > 14:44:8f:bc:a3:c8, ethertype IPv4 (0x0800), length 1330: 10.1.1.1.53611 > 10.1.1.2.6343: sFlowv5, IPv4 agent 10.1.1.1, agent-id 100000, length 1288 

 

Step10: Run the sflow docker and check the sflow packets in server. 

docker run -p 6343:6343/udp sflow/sflowtool 

 

 

    • Related Articles

    • How to Configure snmp in broadcom sonic

      SNMP Overview Simple Network Management Protocol (SNMP) is a widely used application-layer protocol that enables centralized monitoring and management of network devices such as switches, routers, and servers. It supports real-time alerts, ...
    • Is SONiC suitable for my use case?

      SONiC (Software for Open Networking in the Cloud) is designed to be a highly flexible and scalable network operating system, making it suitable for a wide range of use cases. Here are some scenarios where SONiC could be an excellent fit: 1. Data ...
    • How to configure snmp in community sonic

      SNMP Overview Simple Network Management Protocol (SNMP) is a widely used application-layer protocol that enables centralized monitoring and management of network devices such as switches, routers, and servers. It supports real-time alerts, ...
    • How to Configure Basic VRF Management

      VRF Management Objective This document explains how to configure Basic VRF (Virtual Routing and Forwarding) Management on SONiC-OS-4.4.2-Enterprise_Base. Management VRF provides a separate routing table specifically for out-of-band management ...
    • How to Configure MC-LAG (Multi-Chassis Link Aggregation)

      MC-LAG (Multi-Chassis Link Aggregation) Objective This document explains how to configure MC-LAG (Multi-Chassis Link Aggregation) between two switches and a host. MC-LAG provides link redundancy and load balancing by allowing two physical switches to ...