SNMP – the network monitoring protocol
A university network has hundreds of switches, routers, printers and servers. How does the administrator know which port has “gone down”, which link is 90% loaded, or that a printer has run out of paper? He does not visit every device one by one — he asks through SNMP, and the devices themselves also send a “signal”. Today you will get to know the SNMP architecture, the MIB and the OID tree, read snmpwalk results and write monitoring programs in Python that calculate link load.
Lesson goals and plan
By the end of the lesson you will…
- you can explain the SNMP architecture (manager, agent, MIB) and the role of UDP ports 161/162
- you can distinguish the SNMP operations (Get, GetNext, GetBulk, Set, Response, Trap, Inform)
- you can read the OID tree and find the main objects under 1.3.6.1.2.1 (mib-2) (sysDescr, sysUpTime, ifTable)
- you can compare SNMPv1, v2c and v3 in terms of security
- you can read snmpget/snmpwalk results and determine interface status and load
- you can write Python programs that calculate link load from counter values and “walk” along an OID
Plan (according to the syllabus)
- SNMP – the network monitoring protocol
An OID is like a station address on a metro map: 1.3.6.1.2.1.1.5.0 — “iso → org → dod → internet → mgmt → mib-2 → system → sysName”. You do not need to memorize the numbers — once you understand the tree, you can read any OID :ik-quti:
A monitoring system (such as Zabbix, PRTG or LibreNMS) asks the switches every minute: “what is the status of your port 24? How many bytes have passed?” And the moment a port goes down, the switch itself sends the message “linkDown!”. All of this happens through a single protocol — SNMP (Simple Network Management Protocol). Today you will learn the instruments of this “network medicine”.
Key terms
Theory reminder
| Operation | Direction | Role | Version |
|---|---|---|---|
GetRequest | Manager → agent | Request the value of a specific OID | v1+ |
GetNextRequest | Manager → agent | Request the next OID after the given one and its value — for “walking” along the tree (walk) | v1+ |
GetBulkRequest | Manager → agent | Get many following values in one request (for large tables) | v2c+ |
SetRequest | Manager → agent | Change a value (for example, shut down a port) | v1+ |
Response | Agent → manager | Reply to a request | v1+ |
Trap | Agent → manager | A message about an event, without confirmation | v1+ |
InformRequest | Agent → manager | A message that requires a confirmation (Response) | v2c+ |
| Version | Security | Note |
|---|---|---|
| SNMPv1 | Community string, in plain text | 32-bit counters; obsolete |
| SNMPv2c | Community string, in plain text | GetBulk, Inform, 64-bit counters (Counter64); still widespread today |
| SNMPv3 | USM: user, authentication (auth) and encryption (priv) | Modes: noAuthNoPriv, authNoPriv, authPriv. The recommended version |
SNMP – the network monitoring protocol
Three sample tasks: reading the OID tree, analyzing snmpwalk output and calculating link load from counters.
Sample task 1. The OID tree
All standard management objects are located under 1.3.6.1.2.1 (mib-2). Vendors’ own objects are under 1.3.6.1.4.1 (enterprises) — for example, Cisco’s number is 9.
| Name | OID | Meaning |
|---|---|---|
sysDescr.0 | 1.3.6.1.2.1.1.1.0 | Device description (model, OS version) |
sysUpTime.0 | 1.3.6.1.2.1.1.3.0 | Time since the agent started, in hundredths of a second (TimeTicks) |
sysContact.0 / sysName.0 / sysLocation.0 | …1.1.4.0 / …1.1.5.0 / …1.1.6.0 | Responsible person, device name, location |
ifNumber.0 | 1.3.6.1.2.1.2.1.0 | Number of interfaces |
ifDescr.N | 1.3.6.1.2.1.2.2.1.2.N | Name of interface N |
ifSpeed.N | 1.3.6.1.2.1.2.2.1.5.N | Speed, bit/s |
ifOperStatus.N | 1.3.6.1.2.1.2.2.1.8.N | Status: 1 — up, 2 — down |
ifInOctets.N / ifOutOctets.N | …2.2.1.10.N / …2.2.1.16.N | Bytes received / sent (Counter32) |
The trailing .0 is the instance of a scalar (single) object; for table objects the last number is the index (for example, the interface number). Walk along the tree below: click a node — its full OID appears; “GetNext” shows in what order the agent answers.
:ik-xarita: OID tree and GetNext simulator — the department switch
Sample task 2. snmpget and snmpwalk
Commands from the Net-SNMP package (the snmp package on Linux, also available for Windows). The agent on the switch is enabled with the snmp-server community public RO command.
$ snmpget -v2c -c public 192.168.10.2 SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysUpTime.0 SNMPv2-MIB::sysName.0 = STRING: KAFEDRA-SW1 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (93784512) 10 days, 20:30:45.12 $ snmpwalk -v2c -c public 192.168.10.2 IF-MIB::ifOperStatus IF-MIB::ifOperStatus.1 = INTEGER: up(1) IF-MIB::ifOperStatus.2 = INTEGER: down(2) IF-MIB::ifOperStatus.3 = INTEGER: up(1) $ snmpwalk -v2c -c public -On 192.168.10.2 1.3.6.1.2.1.2.2.1.10 .1.3.6.1.2.1.2.2.1.10.1 = Counter32: 3456789012 .1.3.6.1.2.1.2.2.1.10.2 = Counter32: 0 .1.3.6.1.2.1.2.2.1.10.3 = Counter32: 987654321 $ snmpget -v2c -c notogri 192.168.10.2 sysName.0 Timeout: No Response from 192.168.10.2.
- -v2c -c public
The version and the community string. An agent does not reply at all to a wrong community — so the error appears as a “Timeout” (the last example).
- Output format
MIB-NAME::object.index = TYPE: value. The-Onoption shows the numeric OID. - Timeticks
93784512 hundredths of a second = 937845.12 s = 10 days 20 hours 30 minutes 45.12 seconds. A small sysUpTime means the device was restarted recently!
- Interface status
ifOperStatus.2 = down(2) → the matching ifDescr.2 = Gi0/2 for index 2 — that port is not working.
Sample task 3. From a counter to link load
SNMP does not give a “speed” — it gives only a byte counter that keeps growing. The monitoring system reads it twice and divides the difference by the time:
Load (%) = (Δ bytes × 8) / (Δ time, s × ifSpeed) × 100. If the second value is smaller than the first, Counter32 has wrapped: Δ = second + 232 − first.
Example: Gi0/1 (1 Gbit/s), over a 300-second interval ifInOctets grew from 3,456,789,012 to 3,494,289,012. Δ = 37,500,000 bytes = 300,000,000 bits; in 300 s that is 1,000,000 bit/s = 1 Mbit/s; load = 0.1%.
The maximum of Counter32 is 4,294,967,295. If a 1 Gbit/s link is fully loaded, it wraps about every 34 seconds — several times within a 5-minute polling interval! That is why 64-bit ifHCInOctets (IF-MIB, ifXTable) in v2c/v3 is used for fast interfaces.
Traps: the device reports on its own
| Trap | When |
|---|---|
coldStart / warmStart | The agent restarted (power cycle / software reload) |
linkDown / linkUp | An interface went down / came up |
authenticationFailure | A request arrived with a wrong community — someone is “guessing the password” |
Cisco IOS — configuring an SNMP agentSwitch(config)# snmp-server community public RO 10 ! read-only, restricted by ACL 10 Switch(config)# snmp-server location 3-bino, 214-xona Switch(config)# snmp-server contact admin@adu.uz Switch(config)# snmp-server host 192.168.10.50 version 2c public ! trap receiver Switch(config)# snmp-server enable traps snmp linkdown linkup ! SNMPv3 (recommended): Switch(config)# snmp-server group MONITOR v3 priv Switch(config)# snmp-server user nms MONITOR v3 auth sha AuthParol2026 priv aes 128 PrivParol2026
Test runs: first predict, then check
Independent tasks
7 tasks — you write the “brain” of a monitoring system yourself. Use input() without a prompt.
Common mistakes
| Error | Consequence | Correct answer |
|---|---|---|
Leaving the default public/private community | A stranger reads everything about the device and, with RW, changes the configuration | A complex community + ACL, better still SNMPv3 authPriv |
| Sorting OIDs as text | “…10.10” comes before “…10.2” — the walk order breaks | Compare after converting to a tuple of numbers |
| Ignoring the Counter32 wrap | Negative or huge “jumps” on the graph | The wrap formula or 64-bit ifHC* counters |
| Opening only 161 in the firewall | Requests work, traps do not arrive | UDP 162 must be open on the manager side too |
| Thinking a timeout is only a network error | A wrong community goes undetected for a long time | Ping → UDP 161 → community → version: check one after another |
| Polling too fast (every second, thousands of OIDs) | The device’s processor gets overloaded | Usually an interval of 1–5 minutes, GetBulk |
Boss level
Boss level: your own snmpwalk
The agent’s MIB: the number of objects n, then n lines “OID TYPE value” (the value may contain spaces), unordered. The last line is the OID where the walk starts (the root of the subtree). Using only the GetNext logic, print all objects of the subtree in numerical order as “.OID = TYPE: value”. At the end print “So‘rovlar: K” (So‘rovlar = requests) — the number of GetNext requests sent (the last request, which went outside the subtree or returned endOfMibView, also counts). If the subtree is empty, only “So‘rovlar: 1”. +60 XP
Reinforcement
Review questions
Name the main parts of the SNMP architecture.
The manager (NMS) sends requests and receives traps; the agent is a program in the device; the MIB is the description of the objects; the protocol is UDP 161/162.
What is the difference between a MIB and an OID?
A MIB is a set of objects and their description (a dictionary); an OID is the numeric address of a particular object in the tree.
Explain the difference between Get, GetNext and GetBulk.
Get — the value of a specific OID; GetNext — the next OID and its value (for walk); GetBulk — many following values in one request (v2c+).
What is the difference between Trap and Inform?
Both are initiated by the agent; a Trap is not acknowledged, while an Inform requires a reply (confirmation) from the manager.
Compare SNMPv1, v2c and v3 in terms of security.
v1 and v2c — an open community; v3 — a user-based model with authentication and encryption (authPriv).
How is link load calculated via SNMP?
By reading ifInOctets/ifOutOctets twice: Δ bytes × 8 / Δ time / ifSpeed × 100%; the wrap is taken into account.
What is a Counter32 wrap and how is it avoided?
The counter starts again from 0 after 2³² − 1; it is corrected with the formula or the 64-bit ifHCInOctets is used.
Why is sysUpTime useful in monitoring?
It shows when the device last restarted; a sharp decrease of the value is a sign of a reboot.
Independent work
The independent-study topic in the course syllabus (the closest one): “Packet transmission, network topologies and network performance.” (6 hours) — in this lesson, from the angle of measuring network performance through SNMP monitoring. Complete the practical work for your variant and present the results with a table/graph.
| Criterion | Points |
|---|---|
| The practical work is done, results (screenshots, code) are present | 2 |
| OIDs, operations and versions are explained correctly | 1 |
| Performance indicators (load, status, uptime) are calculated and analyzed | 1 |
| The security aspect is taken into account, the write-up is orderly | 1 |
Summary
Your lesson results
Your results are saved in this browser. Read all the sections and complete the exercises and assignments.