$Id$ Build, test the SNMP things for a small memory footprint system with eCos Content Foreword Build the eCos stuffs Run the snmpping Walk/set/get with net-snmp Off topic: Scotty/Tkinetd * Foreword It was a surprise for me what I was able to invoke on my small memory footprint system the real UNIX network things. I have got a board with an ARM7TDMI-S CPU from Olimex. There are 1M of a fast static RAM and 4M of an external Flash memory on the board. Any of the Linux distributives for embedded requires at the least 2M of RAM. But usually, you are able to hold only a Linux kernel on the 2M system. Do you want such a system? I don't think, I think what you want to have a Linux to get a GNU things for your embedded. IMHO, the 4 or 8M of RAM is a good start size to get a fun with Linux and GNU. But, what to do if you have no much of memory? There is the eCos home there (http://ecos.sourceware.org). eCos is yours. If you hear about eCos in first, read a brief article about eCos in a wikipedia: http://en.wikipedia.org/wiki/ECos. * Build the eCos stuffs I'm sorry, but here is a bash only. mkdir -p ~/snmp_test/ecos cd ~/snmp_test/ecos ecosconfig new net ecosconfig resolve ecosconfig add libsmnp snmpagent You can add the eCos `ramfs' package to hold smntpd settings in RAM FS, i.e. in /etc/snmp/snmpd.conf file. My board doesn't have enough of memory, so I don't use it. ecosconfig add ramfs So, what do we have? ecosconfig check I needn't the GDB mangling, because my board does have alone serial port (you can pass this step). cat >nomangler.ecm<<__eof cdl_option CYGSEM_HAL_DIAG_MANGLER { user_value None }; cdl_option CYGSEM_HAL_USE_ROM_MONITOR { user_value 0 Generic }; __eof ecosconfig import nomangler.ecm Note: If your board as mine does have 1M of RAM only, I wand to suggest you remove from the CYGBUILD_GLOBAL_CFALGS, CYGBUILD_GLOBAL_LDFLAGS the -g GCC flag and replace the -O2 GCC optimization flag by -Os flag (optimization for size). I collect the eCos .ecm files. And you? ecosconfig export _snmp.ecm ecosconfig resolve Now, prepare the eCos header files ecosconfig tree make headers Check one config file. Since 2006/07/27 anon cvs had held a patch for that config.h. less -p HAVE_GETTIMEOFDAY install/include/ucd-snmp/config.h If you notice something wrong there, fix that define. And yet another 2 cents, set the CYGNUM_SNMPAGENT_TESTS_ITERATIONS* values (install/include/pkgconf/snmpagent.h) to 999999, for example, instead of 1. Make the eCos libraries make Make our test. There is a snmpping there, but see on it as on a snmpd. make -C net/snmp/agent/current tests Install `snmpping' as you do as well. It's mine install -o tftpd -g tftpd \ install/tests/net/snmp/agent/current/tests/snmpping /tftpboot Do you have a Redboot? That's right. RedBoot> load snmpping Using default protocol (TFTP) Entry point: 0x81010040, address range: 0x81010000-0x8107adb8 RedBoot> Before to invoke that test, you can run a 'flood' ping to load the board's interface. It's optional. If you want it, fulfil this as root while true; do date ping -f -c 3001 192.168.0.123 sleep 5 ping -c 32 -s 2345 192.168.0.123 done * Run the snmpping RedBoot> go [cyg_net_init] Init: mbinit(0x00000000) [cyg_net_init] Init: cyg_net_init_devs(0x00000000) Init device 'cs8900a_eth0' [cyg_net_init] Init: loopattach(0x00000000) [cyg_net_init] Init: ifinit(0x00000000) [cyg_net_init] Init: domaininit(0x00000000) [cyg_net_init] Init: cyg_net_add_domain(0x81079098) New domain internet at 0x00000000 [cyg_net_init] Init: cyg_net_add_domain(0x81078a24) New domain route at 0x00000000 [cyg_net_init] Init: call_route_init(0x00000000) [cyg_net_init] Done Start PING test BOOTP[eth0] op: REQUEST htype: Ethernet hlen: 6 hops: 0 xid: 0x10f15678 secs: 0 flags: 0x80 hw_addr: 08:88:12:34:56:78 client IP: 0.0.0.0 my IP: 192.168.0.123 server IP: 192.168.0.33 gateway IP: 0.0.0.0 options: DHCP message: 3 REQUEST DHCP server id: 192.168.0.33 DHCP time 51: 300 DHCP time 58: 150 DHCP time 59: 262 subnet mask: 255.255.255.0 gateway: 192.168.0.33 domain server: 192.168.0.1 DHCP option: 37/55.9: 54 51 58 59 1 3 6 15 28 DHCP option: 39/57.2: 576 DHCP requested ip: 192.168.0.123 UCD-SNMP version 4.1.2 SNMP re-init function PING server 192.168.0.33 64 bytes from 192.168.0.33: icmp_seq=0, time=70ms 310 bytes from 192.168.0.33: icmp_seq=1, time=40ms 556 bytes from 192.168.0.33: icmp_seq=2, time=40ms 802 bytes from 192.168.0.33: icmp_seq=3, time=40ms 1048 bytes from 192.168.0.33: icmp_seq=4, time=40ms ... * Walk/set/get tests via SNMP protocol Some of the Linux distributives have the snmp* utilities. My Slackware doesn't have it. So, download, build, install a net-snmp package. There is a needed tarball on http://net-snmp.sourceforge.net. It's a GNU package, so we fulfil a build as usualy. zcat net-smtp-5.3.1.targ.gz | tar xf - cd net-smtp-5.3.1. configure make make install There is a `tkmib' there, you can try to build it cd perl perl Makefile.PL -NET-SNMP-IN-SOURCE=true make make install perl -MCPAN -e 'install Tk' Sorry, most of us catch an error here. Don't bother. We can use other SNMP tool instead the tkmib. Let's go for a SNMP-walk, but read, please, the snmp* man pages if you are a novice. SNMP walk snmpwalk -v 2c -c public $BOARD_IP system You should see something like this SNMPv2-MIB::sysDescr.0 = STRING: ucd-snmp-4.1.2/Red Hat eCos SNMPv2-MIB::sysObjectID.0 = OID: UCD-SNMP-MIB::unknown DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (151030) 0:25:10.30 SNMPv2-MIB::sysContact.0 = STRING: nobody@nowhere.net SNMPv2-MIB::sysName.0 = STRING: eCos SNMPv2-MIB::sysLocation.0 = STRING: SNMPv2-MIB::sysServices.0 = INTEGER: 72 SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01 SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.2 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities SNMPv2-MIB::sysORDescr.2 = STRING: The SNMP Management Architecture MIB. SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model. SNMPv2-MIB::sysORUpTime.1 = Timeticks: (3) 0:00:00.03 SNMPv2-MIB::sysORUpTime.2 = Timeticks: (3) 0:00:00.03 SNMPv2-MIB::sysORUpTime.3 = Timeticks: (3) 0:00:00.03 Here are the simplest monitors for our board It's the first monitor while true; do date snmpwalk -v 1 -c public $BOARD_IP system sleep 5 done and it's the second monitor watch snmpwalk -v 2c -c public $BOARD_IP system SNMP get snmpget -v 1 -c public $BOARD_IP system.sysName.0 SNMPv2-MIB::sysName.0 = STRING: eCos SNMP set snmpset -v 1 -c public $BOARD_IP system.sysName.0 s \ "eCos+SNMP" SNMPv2-MIB::sysName.0 = STRING: eCos+SNMP Check it snmpget -v 1 -c public $BOARD_IP system.sysName.0 SNMPv2-MIB::sysName.0 = STRING: eCos+SNMP And even more, the SNMP bulkget works too snmpbulkget -v2c -Cn1 -Cr5 -Os -c public $BOARD_IP system ifTable sysDescr.0 = STRING: ucd-snmp-4.1.2/Red Hat eCos ifIndex.1 = INTEGER: 1 ifIndex.2 = INTEGER: 2 ifDescr.1 = STRING: ifDescr.2 = STRING: (Loopback device) ifType.1 = INTEGER: ethernetCsmacd(6) Off topic: Scotty/Tkinetd In far, I recommend to use the Scotty/Tkinetd against the tkmib. There was the scotty svn tree https://subversion.eecs.iu-bremen.de/svn/schoenw/src/scotty. There was a nice Getting Started with Tkinetd by Mark Newnham there: http://www.eng.auburn.edu/users/doug/tkined.html You should have a Tcl/Tk 8.X is intalled on your host. The Tcl/Tk should been configured with an --enable-shared option. If you have no suitable Tcl/Tk. Here is a brief how to get it. Install Tcl/Tk get ftp://ftp.tcl.tk/pub/tcl8_4/tcl8.4.13-src.tar.gz ftp://ftp.tcl.tk/pub/tcl8_4/tk8.4.13-src.tar.gz unpack zcat tcl8.4.13-src.tar.gz | tar xf - zcat tk8.4.13-src.tar.gz | tar xf - build/install mkdir build_tcl cd build_tcl ../tcl8.4.13/unix/configure \ --enable-shared \ && make \ && make test make install cd .. mkdir build_tk cd build_tk ../tk8.4.13/unix/configure \ --with-tcl=/usr/local/lib \ --enable-shared \ && make make install Install scotty get svn co \ https://subversion.eecs.iu-bremen.de/svn/schoenw/src/scotty trunk build/install mkdir build_scotty cd build_scotty ../scotty/trunk/unix/configure \ --with-tcl=/usr/local/lib \ --with-tk=/usr/local/lib \ && make make install With the Tkinetd, you will be able to create a network topology and observe any device on net. It's simply to work with Tkinetd if you read that Getting Started from Mark Newnham. That's it. Have a fun! Sergei Gavrikov