Skip to content
sehgalanuj edited this page Dec 4, 2013 · 2 revisions

Get Contiki OS

Clone the contiki-snmp repository based on Contiki 2.5.

git clone https://github.com/sehgalanuj/contiki-snmp.git

Build and Run Contiki-SNMP

The Contiki SNMP agent has been designed to take advantage of some memory management features available on the Atmel AVR platform, and as such runs best on the AVR Raven platform. However, in case you do not have access to this platform, you can also run it on the Minimal-Net platform provided by Contiki that simulates a node directly on your machine.

AVR Raven

The SNMP example provided in the repository is designed to work with the AVR Raven platform.

cd contiki-snmp/examples/snmpd-raven
make TARGET=avr-raven

If the compile was successful, you will now see an output that resembles the following:

AVR Memory Usage
----------------
Device: atmega128rfa1

Program:  102652 bytes (78.3% Full)
(.text + .data + .bootloader)

Data:      12810 bytes (78.2% Full)
(.data + .bss + .noinit)

EEPROM:       56 bytes (1.4% Full)
(.eeprom)

To upload this code to an AVR Raven, you may use the already included instructions inside the Makefile by using the following command:

make TARGET=avr-raven upload

This will upload the compiled hex file to flash memory and also the mac.eep file to the EEPROM. The contents of the mac.eep file will set the MAC address for your AVR Raven mote. By default, this is set to the EUI-64 address 02:11:22:FF:FE:17:D9:36. Please change the contents of the mac.eep file in case you wish to change the MAC address.

This also assumes that you are using the AVR JTAG ICE mkII programmer. If your programmer is different, please adjust the programming methodology accordingly by editing the upload section of the Makefile.

Your AVR Raven node is now programmed with a web-server and SNMP agent.

In order to be able to reach your node over the network, you will need to utilize some kind of a bridge device. We recommend using the AVR Raven USB Stick, which masquerades as the usb0 ethernet interface once plugged into a computer. Assuming this is the case, you must configure your computer to provide routing advertisements over the usb0 interface by editing the /etc/radvd.conf file to have the following contents:

interface usb0 {
    AdvSendAdvert on;
    AdvLinkMTU 1280;
    AdvCurHopLimit 128;
    AdvReachableTime 360000;
    MinRtrAdvInterval 100;
    MaxRtrAdvInterval 150;
    AdvDefaultLifetime 200;
    prefix AAAA::/64 {
        AdvOnLink on;
        AdvAutonomous on;
        AdvPreferredLifetime 4294967295;
        AdvValidLifetime 4294967295;
    };
};

This causes radvd to advertise the prefix aaaa:/64 over the usb0 interface. Before you can reach the node, you must also setup the appropriate routes:

sudo route add -6 aaaa::/64 usb0
sudo ip -6 address add aaaa::1/64 dev usb0
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo /etc/init.d/radvd start

The IP address of your AVR Raven node will be aaaa::11:22ff:fe17:d936, as constructed from the EUI-64 address. You can now perform regular SNMP requests to this mote as such:

snmpwalk -v 1 -c public udp6:[aaaa::11:22ff:fe17:d936]:1610 1

This causes all available objects to be listed, like:

SNMPv2-MIB::sysDescr.0 = STRING: System Description
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1234) 0:00:12.34
SNMPv2-MIB::system.11.0 = STRING: "Pointer to a string"
SNMPv2-MIB::system.13.0 = Timeticks: (4290535758) 496 days, 14:09:17.58
IF-MIB::ifNumber.0 = INTEGER: 3
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
SNMPv2-SMI::mib-2.1234.1.0 = INTEGER: 0
SNMPv2-SMI::mib-2.1234.2.0 = Gauge32: 0
End of MIB

Minimal Net

The SNMP example provided in the repository is designed to work with the Minimal-net platform.

cd contiki-snmp/examples/snmpd-minimal-net
make TARGET=minimal-net

To get the virtual node running on your machine, use the commands:

sudo ./snmp-server.minimal-net

You should see the output:

ifconfig tap0 up
IPv6 Address: [aaaa::206:98ff:fe00:232]

This causes the tap0 interface to be created on your machine, over which the virtual node will be reachable.

You must configure your computer to provide routing advertisements over the tap0 interface by editing the /etc/radvd.conf file to have the following contents:

interface tap0 {
    AdvSendAdvert on;
    AdvLinkMTU 1280;
    AdvCurHopLimit 128;
    AdvReachableTime 360000;
    MinRtrAdvInterval 100;
    MaxRtrAdvInterval 150;
    AdvDefaultLifetime 200;
    prefix AAAA::/64 {
        AdvOnLink on;
        AdvAutonomous on;
        AdvPreferredLifetime 4294967295;
        AdvValidLifetime 4294967295;
    };
};

This causes radvd to advertise the prefix aaaa:/64 over the tap0 interface. Before you can reach the node, you must also setup the appropriate routes:

sudo route add -6 aaaa::/64 tap0
sudo ip -6 address add aaaa::1/64 dev tap0
sudo sysctl -w net.ipv6.conf.all.forwarding=1
sudo /etc/init.d/radvd start

The IP address of your virtual node will be aaaa::206:98ff:fe00:232, as obtained from the output before. You can now perform regular SNMP requests to this mote as such:

snmpwalk -v 1 -c public udp6:[aaaa::206:98ff:fe00:232]:1610 1

This causes all available objects to be listed, like:

SNMPv2-MIB::sysDescr.0 = STRING: System Description
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1234) 0:00:12.34
SNMPv2-MIB::system.11.0 = STRING: "Pointer to a string"
SNMPv2-MIB::system.13.0 = Timeticks: (4290535758) 496 days, 14:09:17.58
IF-MIB::ifNumber.0 = INTEGER: 3
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
SNMPv2-SMI::mib-2.1234.1.0 = INTEGER: 0
SNMPv2-SMI::mib-2.1234.2.0 = Gauge32: 0
End of MIB
Clone this wiki locally