0% found this document useful (0 votes)
24 views10 pages

How To Impliment SNMP in w5200

This document provides an overview of implementing the Simple Network Management Protocol (SNMP) using the W5200 device. It explains the structure of SNMP messages, the communication process between SNMP agents and managers, and includes practical examples of SNMP operations such as Get, Set, and Trap requests. Additionally, it outlines the necessary code and libraries for utilizing SNMP with the W5200, along with links for downloading relevant resources.

Uploaded by

Ravi Thakur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views10 pages

How To Impliment SNMP in w5200

This document provides an overview of implementing the Simple Network Management Protocol (SNMP) using the W5200 device. It explains the structure of SNMP messages, the communication process between SNMP agents and managers, and includes practical examples of SNMP operations such as Get, Set, and Trap requests. Additionally, it outlines the necessary code and libraries for utilizing SNMP with the W5200, along with links for downloading relevant resources.

Uploaded by

Ravi Thakur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

How to implement SNMP

(w5200 Application Notes)

©2011 WIZnet Co., Ltd. All Rights Reserved.


☞ For more information, visit our website at http://www.wiznet.co.kr

WFD 220 (WIZnet Co., Ltd.)


1. Introduction
Simple Network Management Protocol (SNMP) is an "Internet-standard protocol for managing

devices on IP networks. Devices that typically support SNMP include routers, switches, servers,

workstations, printers, modem racks, and more.”

SNMP is extremely easy for any programmer to understand. A gross over simplification can

explain the system simply. A network device runs an SNMP agent as a daemon process which

answers requests from the network. The agent provides a large number of Object Identifiers

(OIDs). An OID is a unique key-value pair. The agent populates these values and makes them

available. An SNMP manager (client) can then query the agents key-value pairs for specific

information. From a programming standpoint it's not much different than importing a ton of

global variables. SNMP OIDs can be read or written. While writing information to an SNMP

device is fairly rare, it is a method used by several management applications to control devices

(such as an administrative GUI for your switches). A basic authentication scheme exists in

SNMP, allowing the manager to send a community name (think clear text password) to

authorize reading or writing of OIDs. Most devices use the insecure community name "public".

SNMP communication is preformed via UDP on ports 161 and 162.

SNMP Manager Request (Get, Set) 161


MIB MIB
(Trap Daemon) SNMP Agent
Response

162 SNMP Agent MIB

Trap

SNMP Agent MIB

This application note show that how communicate between <SNMP agent> in w5200E01-M3

and <SNMP manager> in computer.

All codes and files mentioned in this document are available for download from

http://www.wiznet.co.kr/w5200/download.

WFD 220 (WIZnet Co., Ltd.) 1


2. SNMP Protocol
The SNMP message format specifies which fields to include in the message and in what order.

Ultimately, the message is made of several layers of nested fields. At the outer-most layer, the

SNMP message is a single field, of the Sequence type. The entire message is a Sequence of

three smaller fields: the SNMP Version (Integer), the SNMP Community String (Octet String),

and the SNMP PDU (GetRequest, or SetRequest).

Since the SNMP Version and SNMP Community String are primitive data types they are not built

from smaller fields (no more layers). However, the PDU is a complex data type made up of

several smaller fields (more layers). The PDU is composed of a Request ID (Integer), Error

(Integer), Error Index (Integer), and a Varbind List. A Varbind or Variable Binding is a Sequence

of two specific fields. The first field is an OID, which addresses a specific parameter. The

second field contains the Value of the specified parameter. In a SetRequest, Value must be the

same data type specified in the MIB for the parameter being set. In a GetRequest, Value is a

Null with length 0x00. This null data is a placeholder for the Value data that the SNMP agent

returns using the GetResponse PDU. Furthermore, as the name suggests, a Varbind List is a

Sequence of Varbinds. Finally, when a message is setting or getting a single parameter, the

Varbind List holds only one Varbind. For an explanation of each field in the SNMP message see

below table.

Field Description
A Sequence representing the entire SNMP message consisting of the SNMP
SNMP message
version, Community String, and SNMP PDU.
SNMP Version An Integer that identifies the version of SNMP. SNMPv1 = 0
An Octet String that may contain a string used to add security to SNMP
SNMP Community String
devices.
An SNMP PDU contains the body of the SNMP message. There are several
SNMP PDU types of PDUs. Three common PDUs are GetRequest, GetResponse,
SetRequest.

WFD 220 (WIZnet Co., Ltd.) 2


An Integer that identifies a particular SNMP request. This index is echoed
Request ID back in the response from the SNMP agent, allowing the SNMP manager to
match an incoming response to the appropriate request.
An Integer set to 0x00 in the request sent by the SNMP manager. The SNMP
agent places an error code in this field in the response message if an error
occurred processing the request. Some error codes include:
0x00 -- No error occurred
0x01 -- Response message too large to transport
Error
0x02 -- The name of the requested object was not found
0x03 -- A data type in the request did not match the data type in the SNMP
agent
0x04 -- The SNMP manager attempted to set a read-only parameter
0x05 -- General Error (some error other than the ones listed above)
If an Error occurs, the Error Index holds a pointer to the Object that caused
Error Index
the error, otherwise the Error Index is 0x00.
Varbind List A Sequence of Varbinds.
Varbind A Sequence of two fields, an Object ID and the value for/from that Object ID.
Object Identifier An Object Identifier that points to a particular parameter in the SNMP agent.
SetRequest PDU -- Value is applied to the specified OID of the SNMP agent.
GetRequest PDU -- Value is a Null that acts as a placeholder for the return
Value data.
GetResponse PDU -- The returned Value from the specified OID of the
SNMP agent.

The SNMP-related branches of the MIB tree are located in the internet branch, which contains

two main types of branches:

 Public branches (mgmt=2), which are defined by the Internet Engineering Task Force (IETF)

RFCs, are the same for all SNMP-managed devices.

 Private branches (private=4), which are assigned by the Internet Assigned Numbers

Authority (IANA), are defined by the companies and organizations to which these branches

are assigned.

The following figure shows the structure of the SNMP MIB tree. There are no limits on the width

and depth of the MIB tree.

WFD 220 (WIZnet Co., Ltd.) 3


Immediately beneath the root of the MIB tree, International Organization for Standardization

(iso), is the Organization (org) branch, followed by Department of Defense (dod), and then

Internet (internet). Management (mgmt), the main public branch, defines network management

parameters common to devices from all vendors. Underneath the Management branch is MIB-II

(mib-2), and beneath this are branches for common management functions such as system

management, printers, host resources, and interfaces.

The private branch of the MIB tree contains branches for large organizations, organized under

the enterprises branch. Each organization has a root branch node under this object. Each

organization creates its own subset of MIB branches and objects, which must comply with a

common definition of SNMP information known as Structure of Management Information (SMI).

SMI defines the allowed data types for MIB objects.

WFD 220 (WIZnet Co., Ltd.) 4


3. SNMP Get/Set/Trap Demo
[net-snmp version 5.7 package for windows] is used for this demo. You can download this

source code at http://www.net-snmp.org/.

(Net-SNMP is a suite of software for using and deploying the SNMP protocol. It contains a

generic client library, a suite of command line applications, a highly extensible SNMP agent, perl

modules and python modules.)

You can get the all net-snmp sample executable files, after building the project with Microsoft

Visual Studio. Of all net-snmp sample executable files, snmpget.exe, snmpset.exe,

snmpwalk.exe and snmptrapd.exe are used.

Trap
SNMP Manager w5200E01‐M3
System
(net‐snmp in PC) (192.168.11.251)
Request (Get, Set) Private MIB
(192.168.11.250)
Response

WFD 220 (WIZnet Co., Ltd.) 5


3.1 Trap Demo
First, launch the <snmptrapd.exe> in net-snmp package as below.

Reset the [w5200E01-M3] module.

Then, you can see the snmp trap packets as below in your PC.

WFD 220 (WIZnet Co., Ltd.) 6


3.2 Get Request Demo(system MIB)

WFD 220 (WIZnet Co., Ltd.) 7


3.2 Set Request Demo(Private MIB), LED On/Off Test

If you issue the command as below, LED of [w5200E01-M3] would be off.

snmpset -v 1 -c public 192.168.11.251 .1.3.6.1.4.1.0.2.0 i 0

And if you issue the command as below, LED of [w5200E01-M3] would be on.

snmpset -v 1 -c public 192.168.11.251 .1.3.6.1.4.1.0.2.0 i 1

3.4 Walk Demo

WFD 220 (WIZnet Co., Ltd.) 8


4. Example of use of SNMP Library
dataEntryType snmpData[] ={
// SysDescr Entry
{8, {0x2b, 6, 1, 2, 1, 1, 1, 0},
SNMPDTYPE_OCTET_STRING, 30, {"WIZnet Embedded SNMP Agent"},
NULL, NULL},
// SysObjectID Entry
{8, {0x2b, 6, 1, 2, 1, 1, 2, 0},
SNMPDTYPE_OBJ_ID, 8, {"₩x2b₩x06₩x01₩x02₩x01₩x01₩x02₩x00"},
NULL, NULL},
// SysUptime Entry
{8, {0x2b, 6, 1, 2, 1, 1, 3, 0},
SNMPDTYPE_TIME_TICKS, 0, {""},
currentUptime, NULL},
// sysContact Entry
{8, {0x2b, 6, 1, 2, 1, 1, 4, 0},
SNMPDTYPE_OCTET_STRING, 30, {"[email protected]"},
NULL, NULL},
// sysName Entry
{8, {0x2b, 6, 1, 2, 1, 1, 5, 0},
SNMPDTYPE_OCTET_STRING, 30, {"http://www.wiznet.co.kr"},
NULL, NULL},
// Location Entry
{8, {0x2b, 6, 1, 2, 1, 1, 6, 0},
SNMPDTYPE_OCTET_STRING, 30, {"4F Humax Village"},
NULL, NULL},
// SysServices
{8, {0x2b, 6, 1, 2, 1, 1, 7, 0},
SNMPDTYPE_INTEGER, 4, {""},
NULL, NULL},
// WIZnet LED
{8, {0x2b, 6, 1, 4, 1, 0, 1, 0},
SNMPDTYPE_OCTET_STRING, 30, {""},
getWIZnetLed, NULL},
{8, {0x2b, 6, 1, 4, 1, 0, 2, 0},
SNMPDTYPE_INTEGER, 4, {""},
NULL, setWIZnetLed}
};

void getWIZnetLed(void *ptr, uint8 *len)


{
if ( wiznetLedStatus==0 ) *len = sprintf((int8 *)ptr, "LED Off");
else *len = sprintf((int8 *)ptr, "LED On");
}

void setWIZnetLed(int32 val)


{
wiznetLedStatus = val;
if ( wiznetLedStatus==0 ) LED3_onoff(OFF); // LED in the W5200-EVB
else LED3_onoff(ON);
}

void UserSnmpDemo()
{
WDEBUG("₩r₩n₩r₩nStart UserSnmpDemo");
SnmpXInit();

{
dataEntryType enterprise_oid = {8, {0x2b, 6, 1, 4, 1, 0, 0x10, 0}, SNMPDTYPE_OBJ_ID,
8, {"₩x2b₩x06₩x01₩x04₩x01₩x00₩x10₩x00"}, NULL, NULL};

dataEntryType trap_oid1 = {8, {0x2b, 6, 1, 4, 1, 0, 11, 0}, SNMPDTYPE_OCTET_STRING,


30, {""}, NULL, NULL};
dataEntryType trap_oid2 = {8, {0x2b, 6, 1, 4, 1, 0, 12, 0}, SNMPDTYPE_INTEGER,
4, {""}, NULL, NULL};

strcpy((int8*)trap_oid1.u.octetstring, "Alert!!!");
trap_oid2.u.intval = 123456;

SnmpXTrapSend("192.168.11.250", "192.168.11.251", "public", enterprise_oid, 1, 0, 0);


SnmpXTrapSend("192.168.11.250", "127.0.0.0", "public", enterprise_oid, 6, 0, 2, &trap_oid1, &trap_oid2);
}

SnmpXDaemon();
}

WFD 220 (WIZnet Co., Ltd.) 9

You might also like