Skip to content
Search

Simple Network Management Protocol

lastmod 2026-02-24created 2018-07-2615 edits

Simple Network Management Protocol (SNMP) is an Internet standard protocol used to collect and manage information from devices on IP networks, and to modify that information to change device behavior. Typical devices that support SNMP include routers, switches, servers, workstations, printers, modem racks, and so on.

SNMP is widely used in network management for network monitoring. SNMP lets you manage the status and configuration of managed systems in the form of variables in a Management Information Base. These variables can be queried remotely by management programs and, in some cases, their values can also be set remotely.

There are three major versions of SNMP in current use: SNMPv1 is the earliest version, and the later SNMPv2 and SNMPv3 are improved versions in terms of performance, flexibility, and security.

SNMP is part of the Internet protocol suite as defined by the Internet Engineering Task Force. The Internet protocol suite consists of standards for network management, including an application layer protocol, a database schema, and a set of data objects.

Projects

Tutorials

Content from L4 Switch#Network engineer Hwanyeong's tech blog: Understanding L4 switches easily

  1. Understanding SNMP easily #1 - Easy_to_understand_SNMP_1.pdf (SNMP)
  2. Understanding SNMP easily #2 - Easy_to_understand_SNMP_2.pdf (SNMP)

How to check router network traffic capacity

The most standard way is to query the router's interface traffic via SNMP (Simple Network Management Protocol).

Install pysnmp-lextudio:

pip install pysnmp-lextudio
# pip install pysnmp-lextudio --break-system-packages  ## 조심히 사용해라

Query router interface traffic:

from pysnmp.hlapi import *

def get_interface_traffic(host, community='public'):
    """
    Fetch router interface traffic via SNMP
    SNMP를 통해 라우터 인터페이스 트래픽 조회
    """
    # ifHCInOctets (1.3.6.1.2.1.31.1.1.1.6) - 수신 바이트
    # ifHCOutOctets (1.3.6.1.2.1.31.1.1.1.10) - 송신 바이트
    # ifSpeed (1.3.6.1.2.1.2.2.1.5) - 인터페이스 최대 속도 (bps)
    oids = {
        'ifDescr':      '1.3.6.1.2.1.2.2.1.2',
        'ifSpeed':      '1.3.6.1.2.1.2.2.1.5',
        'ifHCInOctets': '1.3.6.1.2.1.31.1.1.1.6',
        'ifHCOutOctets':'1.3.6.1.2.1.31.1.1.1.10',
    }

    for oid_name, oid in oids.items():
        iterator = nextCmd(
            SnmpEngine(),
            CommunityData(community),
            UdpTransportTarget((host, 161)),
            ContextData(),
            ObjectType(ObjectIdentity(oid)),
            lexicographicMode=False
        )
        for errorIndication, errorStatus, errorIndex, varBinds in iterator:
            if errorIndication or errorStatus:
                print(f"Error: {errorIndication or errorStatus}")
                break
            for varBind in varBinds:
                print(f"{oid_name}: {varBind[1]}")

get_interface_traffic('192.168.1.1')

Key points to check

  1. Interface bandwidth (maximum capacity)
    • SNMP OID ifSpeed or ifHighSpeed — the physical maximum speed of the interface
    • Example: for a 1Gbps port, 1,000,000,000 (bps)
  2. Current traffic usage (utilization)
    • Dividing the difference in ifHCInOctets / ifHCOutOctets between two points in time by the time interval gives the current throughput: 사용률(%) = (ΔOctets × 8) / (Δtime × ifSpeed) × 100

See also

Favorite site

author Zer0 sitemap