3 using the 6lowpan / ipv6 code on end nodes, 4 ipso app example, Avr2070 – Atmel AVR2070 User Manual

Page 25

Advertising
background image

AVR2070

25

8240B-AVR-06/09

6.3 Using the 6LoWPAN / IPv6 Code on End Nodes

The 6LoWPAN / IPv6 API is documented using the Doxygen documentation system.
What follows is an overview of how the example application works, and is not the full
API documentation. Refer to Appendix C for the entire API documentation.

The code is designed primarily to pass data around using the UDP protocol. The user
application can send data to any arbitrary IP address, or the user can respond to an
incoming UDP packet.

A user function is called when a UDP packet is received by the node. The user is told
the source port, the destination port, the pointer to memory where the payload is
stored, and the size of the payload. To send data back to the device, the user simply
replaces the payload with what they wish to send, and returns how much data they
have placed in the payload. The stack will automatically send this message back to
the source IP address, with the destination and source ports swapped. Since most
UDP-based protocols function this way, implementation is made quick and easy.

If more control is required, functions to create an arbitrary UDP packet are provided.
Also provided are functions for generating ICMP echo requests destined to any
arbitrary address. The stack will automatically respond to any incoming echo requests
with an echo response.

6.4 IPSO App Example

The IPSO App demo showcases a wireless sensor reporting system. It uses UDP and
allows simple control of end nodes. Running the demo will require the 'netcat6'
program, which should come with most Linux distributions. This can be checked by
attempting to run the 'nc6' command.

To run the demo, the AVR devices must be built with APP set to ‘IPSO’ in addition to
IPv6 being enabled. The ping demo should still work, and provides a good sanity
check.

Note:
To communicate with other IPv6 nodes outside the local network, a
native IPv6 connection, or IPv6 tunnel end point, is required. A tunnel
can be created by using a tunnel broker such as Hurricane Electric
(

www.he.net

).

Windows users can find copies of netcat6.exe available online at

www.sphinx-

soft.com/tools/index.html

.

Netcat6 is used to simply send and receive raw packets; in this case it is being used
for UDP. By typing any ASCII character and pressing enter results in a UDP packet
being sent with whatever was typed as the payload. For example, if a user typed
'hello' and pressed enter, then netcat6 will send a UDP packet with the payload as 6
bytes: 0x68, 0x65, 0x65, 0x6C, 0x6F, 0x0A. This is ASCII for "hello" followed by a
new-line. If the node responds by sending “Hi There” in ASCII, that will be printed
back to the first node.

This allows simple communication with a node without the need for special software.
Communication with a node operates like a wireless serial port. The only difference is
the node is physically located across the world, and not connected to a local
computer with a wire.

Advertising