SNMP Protocol Tutorial
SNMP Protocol Tutorial
Chapter 23
23-2
The protocol
McGraw-Hill
ASN.1
SMI module is based on ANS.1 (Abstract Syntax Notation One) and BER (Basic Encoding rules). Therefore the following slides discuss these two standards.
23-3
From the networks perspective, application programs send messages to each other in a form of uninterpreted byte strings. From the application perspective these messages contain various kinds of data (arrays of integers, video frames, lines of text, digital images, sound tracks) that have some meaning. The problem is how to encode the data so that applications on the both sides of network are able to see the same data, i.e. understand their meaning. Another problem, is how to make this representation efficient. One way to achieve efficiency is to remove redundancies from data by compression. In addition, the data encoding (sometimes called: argument marshalling) must be language and platform independent. An important aspect of argument marshalling is the issue of byte ordering. A popular standard for data representation is Abstract Syntax Notation One (ASN.1)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
ASN.1 (cont.)
23-4
McGraw-Hill
ASN.1 (cont.)
ASN.1 is a formal notation used for describing data transmitted by telecommunications protocols, regardless of language implementation and physical representation of these data. ASN.1 is defined originally by CCITT (now ITU-T) in 1984 ISO (1985) has split the original ASN.1 into: ASN.1 - Abstract Syntax Notation, and BER - Basic Encoding Rules
23-5
McGraw-Hill
ASN.1 (cont.)
In order to describe data ANS.1 uses predefined (simple and aggregated) data types, and syntax for construction of new types. Examples of some pre-defined basic types: INTEGER (integer values), BOOLEAN (Boolean values), OBJECT IDENTIFIER (name of an information object) IA5String (string of US ASCII characters ), UniversalString (character strings) BIT STRING (bit strings of arbitrary length), OCTET STRING (bit strings whose length is multiple of 8), NumericString (string of digits and spaces) ............................ and aggregated (constructed) types:
23-6
SEQUENCE (structures), SEQUENCE OF (arrays, lists), CHOICE (choice between types) SET (an unordered collection of variables of different type) SET OF (an unordered collection of variables of the same type) McGraw-Hill . . . . . . . . . . . . . . . . . . . . . . . . . . . . The McGraw-Hill Companies, Inc., 2000
ASN.1 (cont.)
Example of a type assignment (new type definition):
AirlineFlight airline flight seats
23-7
::= SEQUENCE { IA5String, NumericString, SEQUENCE { maximum INTEGER, occupied INTEGER, vacant INTEGER}, airport SEQUENCE { origin IA5String, stop1 [0] IA5String OPTIONAL, stop2 [1] IA5String OPTIONAL, destination IA5String}, crewsize ENUMERATED { six (6), The value for cancel is not eight (8), supplied, therefore the ten (10)}, default value (FALSE) is cancel BOOLEAN DEFAULT FALSE
assumed
ASN.1 (cont.)
Example of decoding from ANS.1 to C:
ASN.1: PersonalInfo ::= SEQUENCE { married BOOLEAN, age INTEGER (123456..124000), name PrintableString} Would generate in C: typedef struct PersonalInfo { boolean married; int age; char *name; } PersonalInfo;
23-8
McGraw-Hill
ASN.1 (cont.)
Object Identifiers
23-9
Object identifiers are globally unique authoritatively assigned names of variables (objects) that can be remotely referenced (retrieved, changed, monitored). Since there are millions of such variables used in various areas (standards, internet, variables recognizable by networking devices, etc.) the names are hierarchically structured (similarly as file names in a file system, or domain names in DNS). According to ASN.1 the names are represented as sequence of integers separated with dots, for example:
Object Identifier 1.3.6.1.2.1.4.9 Object Name ipInDelivers Description A counter that shows the total number of input datagrams successfully delivered to IP user protocols A counter that shows the total number of received UDP datagrams for which there was no application at the destination port
The McGraw-Hill Companies, Inc., 2000
1.3.6.1.2.1.7.2
udpNoPorts
McGraw-Hill
23-10
The numbers in OID represent authorities responsible for assigning the subsequent numbers and names. For example:
1.3.6.1.2.1.7.1
ISO ISO-ident. Org. US DoD Internet udpInDatagrams UDP MIB2 management
McGraw-Hill
23-11
root
iso(1) org(3) dod(6) internet(1)
joint-iso-ccitt(2)
1.3.6.1
private(4)
directory(1)
enterprises(1)
1.3.6.1.2.1
system(1)
mgmt(2)
experimental(3)
mib(1)
ip(4) at(3) udp(7) icmp(5)
egp(8)
...
interfaces(2)
...
snmp(11)
...
McGraw-Hill
...
...
tcp(6)
...
...
...
...
The McGraw-Hill Companies, Inc., 2000
23-12
snmp(11)
udpInDatagrams(1)
1.3.6.1.2.1.7.5
udpInErrors(3)
udpTable(5)
udpNoPorts(2)
1.3.6.1.2.1.7.5.1.1 udpLocalAddress(1)
McGraw-Hill
BER
Basic Encoding Rules (BER)
23-13
In order to make the data described by ASN.1 syntax ready for transmission over the network, they have to be encoded by the rules that can be understood by both, sender and receiver. BER (which is part of ASN.1) specifies that each piece of data be encoded in a triplet:
McGraw-Hill
BER (cont.)
23-14
Data Type
INTEGER OCTET STRING NULL OBJECT IDENTIFIER SEQUENCE
Class
00 00 00 00 00
Format
0 0 0 0 1
Number
00010 00100 00101 00110 10000 .......
Tag (Hex)
02 04 05 06 30 .........
Tag (Dec)
2 4 5 6 48 ........
00 Universal (ANS.1) 01 Application wide (like SMI) 10 Context specific (the meaning can change from protocol to protocol) 11 Private (vendor specific)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
BER (cont.)
Example: INTEGER 14
23-15
McGraw-Hill
BER (cont.)
Encoding rules are applied at the presentation layer
23-16
McGraw-Hill
PER
Packet Encoding Rules
PER is very compressed encoding based on ANS.1 type information. Like BER, PER specifies how data should be encoded for transmission, independently of machine type, programming language, or representation within an application program. Unlike BER, tags are never transmitted, while lengths and values are not transmitted if known by both peers. PERs reason for existence is to conserve bandwidth. It is valuable in audio and video over the Internet, air-ground communication, radio-paging, or wherever bandwidth is critical. PER is used in H.323 multimedia standard.
23-17
McGraw-Hill
PER (cont.)
23-18
02 01 06
Application 2
PER
Application 1
Total of 24 bits
110
Application 2
SMI
ASN.1 is a huge and complex grammar mechanism. SNMP seeks to simplify to a smaller set of types/constructs and macros in order to facilitate the interoperability between managers/agents. Therefore SMI defines a subset of ASN.1. The retained types are: INTEGER OCTET STRING OBJECT IDENTIFIER NULL SEQUENCE, SEQUENCE OF SMI also adds some new types (see next slide for definitions): NetworkAddress IpAddress Counter Gauge TimeTicks Opaque SMI is recommended in RFC 1155, May 1990
McGraw-Hill
23-19
SMI (cont.)
Added types (in SMIv.1): New Type NetworkAddress Description
23-20
An address from one of possibly several protocol families. It is represented as CHOICE. Currently, only one protocol family, the Internet family, is present in this CHOICE. 32-bit internet address. It is represented as an OCTET STRING of length 4, in network byte-order. Non-negative integer which monotonically increases until it reaches a maximum value, when it wraps around and starts increasing again from zero. (maximum value is 2^321 = 4294967295). A non-negative integer, which may increase or decrease, but which latches at a maximum value. Maximum value is 2^32-1 = 4294967295. A non-negative integer which counts the time in 1/100th of a second since some epoch. Uninterpreted string
The McGraw-Hill Companies, Inc., 2000
IpAddress Counter
Gauge
TimeTicks Opaque
McGraw-Hill
SMI (cont.)
23-21
McGraw-Hill
MIB
23-22
MIB is a formal description of a set of network objects that can be managed using SNMP. Each object in MIB contains a unique identifier, objects type (INTEGER,), objects access level (read, read/write), size restrictions and range information. Objects in MIB are divided into several groups.
Administrative name of the system, name of the contact person, the system description, etc.. The type of technology for each interface, the estimate of current bandwidth, the interface state, statistics about incoming and outgoing traffic , The Address Translation Table, contains the address mappings (physical address, network address ) deprecated Configurations and statistics variables relevant to protocols IP, ICMP, TCP, UDP and EGP Variables that count incoming and outgoing SNMP messages (get-request, get-next-request, set-request, getresponse and trap) The McGraw-Hill Companies, Inc., 2000
McGraw-Hill
MIB (cont.)
23-23
AT Group (1.3.6.1.2.1.3.x)
atTable atEntry atIfIndex atPhysAddressIfIndex atNetAddress 1 1.1 1.1.1 1.1.2 1.1.3
McGraw-Hill
MIB (cont.)
Interface Group (1.3.6.1.2.1.2.x)
ifNumber ifTable ifEntry ifIndex ifDescr ifType ifMtu ifSpeed ifPhysAddress ifAdminStatus ifOperStatus ifLastChange ifInOctets ifInUcastPkts
McGraw-Hill
23-24
1 2 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.1.10 2.1.11
ifInNUcastPkts ifInDiscards ifInErrors ifOutOctets ifOutUcastPkts ifOutNUcastPkts ifOutDiscards ifOutErrors ifOutQLen ifSpecific
2.1.12 2.1.13 2.1.14 2.1.16 2.1.17 2.1.18 2.1.19 2.1.20 2.1.21 2.1.22
ifInUnknownProtos 2.1.15
MIB (cont.)
IP Group (1.3.6.1.2.1.4.x)
ipForwarding ipDefaultTTL ipInReceives ipInHdrErrors ipInAddrErrors ipForwDatagrams ipInUnknownProtos ipInDiscards ipInDelivers ipOutRequests ipOutDiscards ipOutNoRoutes ipReasmTimeout ipReasmReqds ipReasmOKs
McGraw-Hill
23-25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ipAdEntEntReasmMaxSize 20.1.5
MIB (cont.)
IP Group (cont.)
ipRouteTable ipRouteDest ipRouteIfIndex ipRouteMetric1 ipRouteMetric2 ipRouteMetric3 ipRouteMetric4 ipRouteNextHop ipRouteType ipRouteProto ipRouteAge ipRouteMask ipRouteMetric5 ipRouteInfo
McGraw-Hill
23-26
ARP table
22 22.1.1 22.1.3 22.1.4 23
21 21.1.1 21.1.2 21.1.3 21.1.4 21.1.5 21.1.6 21.1.7 21.1.8 21.1.9 21.1.10 21.1.11 21.1.12 21.1.13
ipNetToMediaPhysAddress 22.1.2
MIB (cont.)
TCP Group (1.3.6.1.2.1.6.x)
tcpRtoAlgorithm tcpRtoMin tcpRtoMax tcpMaxConn tcpActiveOpens tcpPassiveOpens tcpAttemptFails tcpEstabResets tcpCurrEstab tcpInSegs tcpOutSegs tcpRetransSets tcpConnTable tcpConnState tcpConnLocalAddress
McGraw-Hill
23-27
1 2 3 4 5 6 7 8 9 10 11 12 13 13.1.1 13.1.2
MIB (cont.)
ICMP Group (1.3.6.1.2.1.5.x)
icmpInMsgs icmpInErrors icmpInDestUnreachs icmpInTimeExcds icmpInParmProbs icmpInSrcQuenchs icmpInRedirects icmpInEchos icmpInEchoReps icmpInTimestamps icmpInAddrMasks icmpInAddrMaskReps icmpOutMsgs
McGraw-Hill
23-28
1 2 3 4 5 6 7 8 9 10 12 13 14
15 16 17 18 19 20 21 22
icmpInTimestampsReps 11
MIB (cont.)
Detailed description of MIB-2 is given in RFC 1213 (1991). Excerpt from RFC 1213: ...............................................................
23-29
ifOutDiscards OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of outbound packets which were chosen to be discarded even though no errors had been detected to prevent their being transmitted. One possible reason for discarding such a packet could be to free up buffer space ::= { ifEntry 19 } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipReasmReqds OBJECT-TYPE SYNTAX Counter ACCESS read-only STATUS mandatory DESCRIPTION "The number of IP fragments received which needed to be reassembled at this entity." ::= { ip 14 } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
MIB (cont.)
Every variable listed in the MIB must be identified when SNMP is making a reference to it (to fetch or set its value). Only leaf nodes are referenced. SNMP does not manipulate entire rows or columns of tables.
23-30
McGraw-Hill
MIB (cont.)
Referencing Tables
In order to reference a variable in a particular row an index should be appended to the variable OID. MIB doesnt use conventional indices (subscripts) to reference a row of table, it rather uses the associative memory approach. Therefore the index for a desired row is replaced with the value(s) of the variable(s) in that row:
23-31
variable OID.value.value.
It can use a single value or values of several fields separated by dots. For example the second field in the first row is referenced as:
1.3.6.1.2.1.7.5.1.2.181.23.45.14.23
Variable OID
McGraw-Hill
MIB (cont.)
Values Same variable, different instances
181.23.45.14 23
23-32
192.13.5.10
161
230.20.5.24
212
McGraw-Hill
MIB (cont.)
Indexing of table entries
23-33
McGraw-Hill
MIB (cont.)
Lexicographic ordering
The OIDs in MIB, including the instance identifiers, are in lexicographic order. Tables are ordered according to column-row rules. This will help in GetNextRequest command as shown later.
23-34
McGraw-Hill
MIB (cont.)
NOTICE: MIB is not the actual database itself. It only contains a collection of definitions which define properties of managed objects, but doesn't contain actual variable values. Therefore the MIB is sometimes called virtual information base. The SNMP client puts the SMI (ANS.1) identifier for the MIB variable it wants to get into request message, and it sends this message to the server. The server then maps this identifier into local variable (i.e. into a memory location where the value for this variable is stored), retrieves the current value held in this variable, and uses BER to encode the value it sends back to the client.
23-35
McGraw-Hill
SNMP
23-36
SNMP v.1 RFC 1157 (May 1990) SNMP v.2 RFC 1905 (January 1996) -- functional enhancements SNMP v.3 RFC 3410 (December 2002) -- adds security
Useful URLs: http://www2.rad.com/networks/1995/snmp/snmp.htm http://home.student.uu.se/j/jolo4453/projekt/tcpip1/snmp_sim.htm http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/snmp.htm
McGraw-Hill
SNMP (cont.)
Infrastructure for network management
Managers host runs SNMP client agent MIB manager MIB data
23-37
managed device
managed device
McGraw-Hill
managed device
The McGraw-Hill Companies, Inc., 2000
SNMP (cont.)
Devices that dont support SNMP can be managed via proxy agents. Proxy agent translates protocol interactions it receives from manager into whatever interactions are supported by foreign devices. real agent data manager MIB
managed device
23-38
real data agent SNMP Proprietary messages proxy MIB agent managed device real data agent managed device
McGraw-Hill
SNMP (cont.)
There are two ways to convey MIB info, commands:
23-39
Manager
Manager
request response
agent MIB Managed device
trap msg
agent MIB
Managed device
request/response mode
McGraw-Hill
trap mode
The McGraw-Hill Companies, Inc., 2000
SNMP (cont.)
SNMP Messages (v.3)
23-40
McGraw-Hill
SNMP (cont.)
SNMP Messages Message type
GetRequest GetNextRequest GetBulkRequest InformRequest SetRequest Response Trap
23-41
Function
Mgr-to-agent: get me data (instance, next in list, block) Mgr-to-Mgr: heres MIB value Mgr-to-agent: set MIB value Agent-to-mgr: value, response to request Agent-to-mgr: inform manager of exceptional event
McGraw-Hill
NOTICE: Messages are in SNMP jargon called PDUsThe McGraw-Hill Companies, Inc., 2000
SNMP (cont.)
SNMP Messages (notices):
23-42
The GetNextRequest command is used for reading subsequent table entries. The retrieved value is the value of the object following (in lexicographic order) the defined OID in the message. The command is useful in case when the manager doesn't know the table indices. However, for each piece of data a separate request has to be made, which results in longer time and increased traffic. GetBulkRequest is a newer PDU that can retrieve many data items in a single request. More efficient than GetNextRequest. Saves time and traffic. The Trap PDU is sent from the agent to the manager to report an event. For example, if the agent is rebooted, it informs the manager and reports the time of rebooting. Trap is an asynchronous notification of some significant event. InformRequest is sent from a manager for passing information to an application running in another manager. Response PDU is used to acknowledge the request. Used in hierarchical or distributed management where multiple managers are involved
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
GetRequest GetNextRequest SetRequest InformRequest Trap PDU type request id Sequence ID to match response with the request request id
SNMP (cont.)
(d) variable-bindings
23-43
error status
error index
value1
name2
value2
...
nameN
valueN
SNMP (cont.)
GetBulkRequest Example
23-44
GetBulkRequest(non-repeaters=2,max-repeaters=6,X,Y,TA,TB,TC) Manager issues request with six variable names; for the first two variable (non-repeaters=2), a single value is requested; for the remaining variables six successive values (max-repeaters=6) are requested.
Table
TA TB TC
Client
Agent returns single value for X, Y, and six rows of table : Response [X, Y, TA(1), TA(2), TA(3), TA(4), TA(5), TA(6),
McGraw-Hill
SNMP (cont.)
SNMP PDU is embedded into an SNMP message.
SNMP v.3 = 3
23-45
Unique message ID, Max message size that sender can handle, Message flags (report/authentication/privacy) Message security model (SNMPv1,v2c,USM Used to create a message digest Used only if PDU is encrypted
McGraw-Hill
23-46
SEQUENCE Length=31
NULL Value=0
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
23-47
Sequence length = 52 INTEGER, length=1, version=3 SEQUENCE, length=12 (Header) INTEGER, length=1, message ID=64 INTEGER, length=2, max size=1024 OCTET STRING, length=1, all flags=0 OCTET STRING, length=0, no security model OCTET STRING, length=0, no security parameter SEQUENC, length=31 (Data) GetRequest, length=29 (no encryption) INTEGER, length=4, Request ID=0x00010611 INTEGER, length=1, Error Status=0 INTEGER, length=1, Error Index=0 SEQUENCE, length 15 SEQUENCE, length 13 OBJECT IDENTIFIER, length=9, udpInDatagram (1.3.6.1.2.1.7.1.0) NULL, length=0
The McGraw-Hill Companies, Inc., 2000
23-48
Requests Responses
Traps
McGraw-Hill