100 likes | 216 Views
EPICS devSNMP Extensions. Euan Troup, Euan.Troup@csiro.au CSIRO Australia Telescope National Facility ASKAP Project Paul Wild Observatory. What Is devSNMP ?. devSNMP connects a set of objects on a network to an EPICS IOC SNMP is the Simple Network Management Protocol
E N D
EPICS devSNMP Extensions • Euan Troup, Euan.Troup@csiro.au • CSIRO Australia Telescope National Facility • ASKAP Project • Paul Wild Observatory
What Is devSNMP ? • devSNMP connects a set of objects on a network to an EPICS IOC • SNMP is the Simple Network Management Protocol • Found in routers, switches, embedded devices etc • Provides for set, get and notification messages • Existing version at http://www-mks2.desy.de/content/e4/e40/e41/e12212/index_ger.html • SNMP support based on Net-SNMP API http://www.net-snmp.org • Earlier versions of devSNMP only supported get, now supports SNMP set and notification messages (traps)
A Bit More SNMP • SNMP objects consist of an OID and a value • An OID is a numerical string in dotted decimal format such as .1.3.6.1.2.1.1.1 • Numeric OIDs are given a more descriptive name using MIB files • MIBS use ASN.1 to give structure to names • .1.3.6.1.2.1.1.1 becomes .iso.org.dod.internet.mgmt.mib-2.system.sysDescr • OID + value corresponds to EPICS PV name + value • SNMP includes basic data types similar to EPICS data types e.g. integer, octet string… • MIB file parsing is provided by the Net-SNMP library so you can abbreviate above to MIB-2::sysDescr
devSNMP Features And Extensions • devSNMP 1.03 supports ai, longin, stringin, waveform, longin with support for truncated 64-bit values (Counter64 SNMP type) • Added support for ao, longout, stringout • Support for I/O Intr processing of trap messages • Supported directly so no need for snmptrapd config • Overhead removed in asynch processing • Original used polling once per second per object • Now transaction only when requested • Can have updates faster than once per second • Explicit SNMP v1 support • Compile-time option for sending float or double data types directly over SNMP • Tested on Linux & OS X with Net-SNMP 5.4
devSNMP In Practice • Rabbit microcontroller • Analogue and digital I/O for monitor & control • Low power mode for data acquisition – low RFI • Wakes up periodically and sends stored data via SNMP trap • (Proposed) DC PSU monitor ATCA crate 4.5 kW DC supply with SNMP monitoring
How Do You Use It? • Patched source can be provided by Euan Troup, Euan.Troup@csiro.au • Compiles to a support library & soft IOC • Makefile for application needs the following added: USR_CFLAGS += `net-snmp-config --cflags` USR_CFLAGS += -DNETSNMP_NO_INLINE USR_LDFLAGS += `net-snmp-config –libs`
How Do You Use It (2)? • Use field (DTYP,"Snmp") • Instrument I/O setup e.g. field (INP,"@localhost public IF-MIB::ifInUcastPkts.1 Counter32: 11") for ai,longin,stringin and • Hostname of remote object • SNMP community name • MIB name to be converted to OID • Data type of object • Size of buffer for processing returned value • Same for output records • Add v1 to end of string for SNMP v1 support • If omitted defaults to SNMP v2c
How Does It Work? • Record processing pass 1 through device support sets record->pact = true, puts device private info on list of active requests, starts an asynch SNMP transaction and sends an epicsEvent to asynch read thread • Read thread waits on event which can be sent by any record then processes all outstanding requests using snmp_sess_select_info() call • After calling select() an SNMP callback function or timeout function is triggered • SNMP callback starts an EPICS callbackRequest() which starts record processing again and completes pass 2 through device support
How Does It Work (2)? • Trap support creates a separate thread listening on udp port 162 or specified using an environment variable • Port 162 is privileged under unix so root or suid executable is required • Records structures for records using I/O Intr scanning are put on a list which is traversed each time a trap is received • Thread receives traps and matches hostnames and OID for active records then uses callback mechanism to process the record • Records can be added or removed from trap processing by changing the SCAN field which uses get_ioint_info() device support function
Possible Future Developments • rbv (readback value) support for ao record • Make traps with multiple updates of database records atomic • Full support for Counter64 – probably requires 64-bit record in EPICS