Pages: [1]   Go Down
Author Topic: SNMP_Libraries  (Read 4623 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 Hello,

This is my first time in the forum so HI and here is my question:

I´m trying to develop an RMU (Remote Monitoring Unit) with the Duemilanove Arduino module. I have to read the data of different sensors using the Arduino microprocessor (ATmega328 in my case) and then i have to comunicate this data to the central computer through Ethernet (using the Arduinos Ethernet Shield). The point is, the software in the central computer works with SNMP protocol so my remote module must understand that protocol. Meaning that: when the central computer sends an SNMP packet, that packet goes in the TCP/IP packet, when it gets to my remote  module (trought Ethernet) the Ethernet Shield takes the data(SNMP packet) out of the TCP/IP packet, and sends it  to the Arduino microprocesor, so the microprocessor MUST UNDERSTAND SNMP PROTOCOL TO MAKE THE PROCESS EASY AND DECODE THE PACKET!!!...

And I can´t find ANY SNMP LIBRARY FOR ARDUINO!!!.. SO i would REALLY apreciate some help with this..


Thanks for the helP!!  smiley
Logged

Nova Scotia, CA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
A world that runs on bits and bytes!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SNMP relies on UDP/IP and not TCP/IP.
Logged

Common sense is not so common...

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 651
Posts: 50845
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SNMP is Simple Network Mail Protocol. Your computer is sending e-mail to your Arduino? I hope it's not expecting a reply in real time.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If youd search youd see my previous reply to this issue.
There is no snmp arduino lib yet.

Someone located a Microchip eth kit that has snmp.  
But it has to:
1. be ported to arduino. (and license checked, it may be for pics only)
2. be easily configurable by users.
3. interface - you want a interface to do other things, so this has to be added.
4. data - snmp sends out discretes, tables, and traps(msgs).  These all have to be configured/handled and interfaced.  traps are broadcast, but discretes are requested.
5. encryption - v3 uses various encryption, I do not know how much would be needed to handle v3 msgs. v2 is plaintext.

Is this all going to fit into 32kb?
IIRC Microchip says it takes 32kb for all of their network stuff.

I would love to work on this and be famous, but I'd rather have money ya know.?  In the words of Les Grossman - Loooottttss of money, and a G5.

Another approach would be to have a trap receiver get -> repackage ->  resend using a custom client/server,  a trap relay if you will.
A simple client/server anyone could write for arduino.



« Last Edit: August 24, 2010, 08:29:13 am by jmrobert » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SNMP == Simple Network MESSAGING Protocol.

The 'Simple' is a misnomer.

The tool uses UDP packets to send and receive data.  A host will listen for broadcast messages from clients, and collate the data.  Tools exist to setup a host to monitor many hundreds of clients and collate data.

A client may also offer up specific user defined datas upon request.  Messages/data types are defined in a text file, in a heirarchial manner with each vender buying a unique ID in the tree (the MIB file).

The first 2 incarnations passed msgs as plaintext, SNMPv3 offers encryption along woth even more complexity.

This tool originated "Joe's Rule of Thumb #1" :  
Any codebase that went thru >2 Universities is to be avoided at all costs...

Net-SNMP isn't too bad compared to the older codebases.

« Last Edit: August 24, 2010, 08:27:55 am by jmrobert » Logged

Nova Scotia, CA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
A world that runs on bits and bytes!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PaulS may have mistaken SNMP for SMTP.

SNMP is simple as per it's definition compared to other RPC (Remote Procedure Call - Get/Set) messaging protocols.  For example MODBUS/TCP.  It's simple because there is no CRC or Checksum, etc., packet creation and parsing is pretty straight forward provided you fully understand the protocol.  Since it is a standardized protocol SNMP RFC documentation is available on-line (http://www.faqs.org/rfcs/rfc1157.html).

I am in the process of writing a lightweight SNMP Agent incorporating SNMP V1 for the ardiuno, using the latest Ethernet library, using a wrapper around the ASocket library (basically porting some of my old SNMP Agent code written in another language).  I'll upload it to the arduino playground once a beta version is available.  The more who wish to test it and help out the merrier.

Quote
A client may also offer up specific user defined datas upon request.  Messages/data types are defined in a text file, in a heirarchial manner with each vender buying a unique ID in the tree (the MIB file).

For clarification to others; you don't have to buy a unique node id.  A manufacturer simply creates one outside of the predefined nodes.  An example will be provided with my SNMP Agent.

Quote
Net-SNMP isn't too bad compared to the older codebases.

NET-SNMP is huge since it incorporates all version e.g. 1 to 3 amongst allot of other great features.  Not to be sarcastic but please keep in mind that the Arduino platform is an MCU with limited ROM/RAM and not a CPU.  So there will certainly be a sacrifice e.g. features vs minimum requirements to minimize the library's footprint.

Eric
« Last Edit: August 24, 2010, 02:51:29 pm by LAVco » Logged

Common sense is not so common...

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know net-snmp will never fit.

Have you thought about using uIP as a base?


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm interested in SNMP on the Arduino.  Details are in my next post, since the forum software doesn't allow me to place URLs in my first post!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LAVco/Eric,

I'm using Arduino for an application that requires an SNMP v2c agent.  Right now, I'm doing the background reading, in preparation for implementation.  Rather than DIY, I'd prefer to use an existing library, or work with others to put one in place.  Is there any scope for cooperation?

One plan might be for me to wait until you upload your SNMP v1 code.  I can then grab it and help debug it.  In time, I might also be able to contribute by assisting with extending the v1 code to do SNMP v2c?

What is your expected time scale for uploading v1 code?  If necessary, I can help you get there.  I'm new to Arduino, but am experienced with microcontrollers in general. (I'm an Elec. Eng.) I'd encourage you to release early, so others can help!

Who else is interested in SNMP on the Arduino?  It has been mentioned several times before on this forum, but no code has appeared.   Maybe this is the time and place for all of us to get together and make it happen?

Regards
John
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SNMP == Simple Network Management Protocol

Most SNMP implementations are designed to offer access to a very large set of information (typically in a router or network host), called a "Management Information Base" (MIB)   There are standard MIBs to cover the usual items of interest to Network Management, but typically the standard data for a single interface would exceed the 32K total available in an Arduino.

It should be possible to implement a "tiny" SNMP to serve up a very limited amount of information, but it may not be able to offer enough info about itself to actually conform to the standard (and an SNMP client is likely to want a bunch of data), and it's not clear what the advantage of using SNMP would be compared to some trivial exchange of UDP or TCP packets (like "finger.")

SNMP is only "Simple" compared to its competitors from the same timeframe (CMIP and CMOT, IIRC.  From ISO.  The ISO protocols are all pretty much dead now; they were essentially too complex to implement, and the complexity didn't DO anything useful.)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Granted, a full blown SNMP implementation might be big, but that is not what I have in mind for my case.

The application I have in mind is managing components in low data rate radio networks in remote locations.  This is an area where there is a call for a very lightweight SNMP agent with a custom MIB, even if it is lightweight to the point of non-conformance with the standard.

Most of the common SNMP parameters don't have meaning for some of the gear being monitored and managed.  For example, an RF power amplifier might support queries about temperature and voltages, allow gain to be set and send a trap on an abnormal condition.  The value of SNMP, over an arbitrary protocol, is that it allows the unit to be handled by the same software that is managing the components containing full blown SNMP agents.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am willing to colloborate on a small snmp system.

Someone want to start a google.code area, or a private subversion or something?

Logged

Nova Scotia, CA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
A world that runs on bits and bytes!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great to see so many people interested in an Arduino SNMP Agent and to all other responses; correct, SNMP Agents can serve up a large number of MIB objects.  However, in theory and in practice, if the object doesn't exist we would respond with a friendly SNMP error - Object Not Found.  As per standard this is totally acceptable.  

Presently I am writing it directly in a sketch and will then create an object orientated approach once the base concepts work.  Packet parsing and construction are the tricky parts, well for me anyway, since I haven't seriously touched C in years.  I am porting C# code that I have written for other projects.  It would be pretty cool to use a similar object architecture as Net-SNMP since it's quite popular (i've used this package for many years with no problems) but a very stripped down version.  But memory being used is what I am watching.  I'm able to parse an incoming get-request packet and in the process of working on the outgoing response.  Parsing the OID string back to a byte array is where I am at.

I am going to create a new thread called Agentuino - Lightweight SNMP Agent for Arduino.  And yes, some help would be great.

The arduino can handle the basic RFC1213 objects (e.g. sysName, sysUpTime, etc.) along with a limited number of user defined objects.

Code:
/**
* Agentuino SNMP Agent Library Prototyping...
*
* Copyright 2010 Eric C. Gionet <lavco_eg@hotmail.com>
*
*/

// SNMP Agent - basic credentials
char getCommName[] PROGMEM   = "public";
char setCommName[] PROGMEM   = "private";
//
// RFC1213-MIB OIDs
char sysDescr[] PROGMEM      = "1.3.6.1.2.1.1.1.0";  // read-only  (DisplayString)
char sysObjectID[] PROGMEM   = "1.3.6.1.2.1.1.2.0";  // read-only  (ObjectIdentifier)
char sysUpTime[] PROGMEM     = "1.3.6.1.2.1.1.3.0";  // read-only  (TimeTicks)
char sysContact[] PROGMEM    = "1.3.6.1.2.1.1.4.0";  // read-write (DisplayString)
char sysName[] PROGMEM       = "1.3.6.1.2.1.1.5.0";  // read-write (DisplayString)
char sysLocation[] PROGMEM   = "1.3.6.1.2.1.1.6.0";  // read-write (DisplayString)
char sysServices[] PROGMEM   = "1.3.6.1.2.1.1.7.0";  // read-only  (Integer)
//
//
/* RFC1213 local values */
char locDescr[] PROGMEM      = "Agentuino, a light-weight SNMP Agent.";  // read-only (static)
char locObjectID[] PROGMEM   = "1.3.6.1.3.2009.0";                       // read-only (static)
long locUpTime               = 0;                                        // RTC is needed for this unless the NTP Time library is used
char locContact[20]          = "Eric Gionet";
char locName[20]             = "Agentuino";
char locLocation[20]         = "Nova Scotia, CA";
short locServices PROGMEM    = 7;                                        // read-only (static)

Flash library doesn't have a strcmp function that works (by all means correct me if I am wrong).

Code:
void loop()
{
  packetSize = socket.available();
  //
  if ( packetSize > 0 && packetSize <= SNMP_MAX_PACKET_LEN ) {
    //
    Serial << "UDP Packet Received Start.." << packetSize << " RAM:" << freeMemory() << endl;
    //
    packet = (byte *)malloc(sizeof(byte)*packetSize);
    //
    socket.read(packet, packetSize);
    //
    //
    //
    //for (int i = 0; i <= packetSize; i++) {
      //Serial << _HEX(packet[i]) << ":" << _DEC(packet[i]) << " " << packet[i] << "(" << i << ")" << endl;
      //Serial << _HEX(packet[i]) << ":" << _DEC(packet[i]) << "(" << i << ")" << endl;
    //}
    //
    char comm[SNMP_MAX_NAME_LEN]; // need dynamic mem alloc
    byte pduType;
    short version;
    long requestId;
    long error;
    long errorIndex;
    char oid[SNMP_MAX_OID_LEN]; // need dynamic mem alloc
    byte valueType;
    byte valueSize;
    byte value[SNMP_MAX_VALUE_LEN]; // careful...limited length - need dynamic mem alloc
    //
    parsePacket(&version, comm, &pduType, &requestId, &error, &errorIndex, oid, &valueType, &valueSize, value);
    //
    Serial << "Version:" << version << " Community:" << comm << " PDUType:" << _HEX(pduType) << " RequestID:" << requestId << " Error:" << error << " ErrorIndex:" << errorIndex << " OID:" << oid << endl;
    Serial << "Value-Type: " << _HEX(valueType) << " Value-Size: " << _HEX(valueSize) << endl;
    //
   // get-request
    if ( strcmp_P(oid, sysName) == 0 ) {
      Serial << "sysName..." << locName << endl;
      //
      // response packet - locName
    } else {
      // oid does not exist
      //
      // response packet - object not found
    }
    //
    free(packet);
    packetSize = 0;
    //
    Serial << "UDP Packet Received End..RAM:" << freeMemory() << endl;
  } else if ( packetSize > SNMP_MAX_PACKET_LEN ) {
    Serial << "Invalid SNMP Packet" << endl;
  }
}

Standard SNMP definitions and enums

Code:
#define SNMP_MIN_OID_LEN      2
#define SNMP_MAX_OID_LEN      128
#define SNMP_MAX_NAME_LEN      32
#define SNMP_MAX_VALUE_LEN      128  //??? should limit this
#define SNMP_MAX_PACKET_LEN     SNMP_MAX_VALUE_LEN + SNMP_MAX_OID_LEN  //???
//
typedef enum ASN_BER_BASE_TYPES {
      //   ASN/BER base types
      ASN_BER_BASE_UNIVERSAL        = 0x0,
      ASN_BER_BASE_APPLICATION = 0x40,
      ASN_BER_BASE_CONTEXT        = 0x80,
      ASN_BER_BASE_PUBLIC        = 0xC0,
      ASN_BER_BASE_PRIMITIVE        = 0x0,
      ASN_BER_BASE_CONSTRUCTOR = 0x20
};
//
typedef enum SNMP_PDU_TYPES {
      // PDU choices
      SNMP_PDU_GET        = ASN_BER_BASE_CONTEXT | ASN_BER_BASE_CONSTRUCTOR | 0,
      SNMP_PDU_GET_NEXT = ASN_BER_BASE_CONTEXT | ASN_BER_BASE_CONSTRUCTOR | 1,
      SNMP_PDU_RESPONSE = ASN_BER_BASE_CONTEXT | ASN_BER_BASE_CONSTRUCTOR | 2,
      SNMP_PDU_SET        = ASN_BER_BASE_CONTEXT | ASN_BER_BASE_CONSTRUCTOR | 3,
      SNMP_PDU_TRAP        = ASN_BER_BASE_CONTEXT | ASN_BER_BASE_CONSTRUCTOR | 4
};
//
typedef enum SNMP_TRAP_TYPES {
      //   Trap generic types:
      SNMP_TRAP_COLD_START             = 0,
      SNMP_TRAP_WARM_START             = 1,
      SNMP_TRAP_LINK_DOWN             = 2,
      SNMP_TRAP_LINK_UP             = 3,
      SNMP_TRAP_AUTHENTICATION_FAIL = 4,
      SNMP_TRAP_EGP_NEIGHBORLOSS    = 5,
      SNMP_TRAP_ENTERPRISE_SPECIFIC = 6
};
//
typedef enum SNMP_ERR_STS_CODES {
      SNMP_ERR_STS_NO_ERROR         = 0,
      SNMP_ERR_STS_TOO_BIG         = 1,
      SNMP_ERR_STS_NO_SUCH_NAME = 2,
      SNMP_ERR_STS_BAD_VALUE         = 3,
      SNMP_ERR_STS_READ_ONLY         = 4,
      SNMP_ERR_STS_GEN_ERROR         = 5
};
//
typedef enum SNMP_SYNTAXES {
      //   SNMP ObjectSyntax values
      SNMP_SYNTAX_SEQUENCE              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_CONSTRUCTOR | 0x10,
      //   These values are used in the "syntax" member of VALUEs
      SNMP_SYNTAX_BOOL              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 1,
      SNMP_SYNTAX_INT              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 2,
      SNMP_SYNTAX_BITS              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 3,
      SNMP_SYNTAX_OCTETS              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 4,
      SNMP_SYNTAX_NULL              = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 5,
      SNMP_SYNTAX_OBJECT_IDENTIFIER  = ASN_BER_BASE_UNIVERSAL | ASN_BER_BASE_PRIMITIVE | 6,
      SNMP_SYNTAX_INT32              = SNMP_SYNTAX_INT,
      SNMP_SYNTAX_IP_ADDRESS         = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 0,
      SNMP_SYNTAX_COUNTER              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 1,
      SNMP_SYNTAX_GAUGE              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 2,
      SNMP_SYNTAX_TIME_TICKS         = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 3,
      SNMP_SYNTAX_OPAQUE              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 4,
      SNMP_SYNTAX_NSAPADDR              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 5,
      SNMP_SYNTAX_COUNTER64              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 6,
      SNMP_SYNTAX_UINT32              = ASN_BER_BASE_APPLICATION | ASN_BER_BASE_PRIMITIVE | 7,
};
//
typedef struct SNMP_PDU {
      ASN_BER_BASE_TYPES type;
      long requestID;
      long errorStatus;
      long errorIndex;
      char oid[SNMP_MAX_OID_LEN];
      byte value[SNMP_MAX_VALUE_LEN];
        SNMP_SYNTAXES valueSyntax;
      // need pointers and callbacks to free varBindList and value memory
};
« Last Edit: August 26, 2010, 08:59:31 pm by LAVco » Logged

Common sense is not so common...

Pages: [1]   Go Up
Jump to: