Introducing SMCP
Tuesday, January 29, 2013 by darcoPosted in Technology, Projects, IPv6, 6LoWPAN
As some of you know, I've been working on a CoAP stack for embedded devices for some time now. Things have gotten to the point now where I'd like see if other people are interested in using it and/or contributing. So today I am announcing that I am making my first release: SMCP-0.6.
What is CoAP?
If you are wondering what CoAP is, a good explanation comes from the abstract of draft-ietf-core-coap-13:
The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks. The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as 6LoWPAN often have high packet error rates and a typical throughput of 10s of kbit/s. The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation.
CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types. CoAP easily interfaces with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead and simplicity for constrained environments.
What is SMCP?
The CoAP stack I have developed is called SMCP. It has the following features:
- draft-ietf-core-coap-13 compliant, including:
- Retransmission of confirmable transactions.
- Sending and receiving asynchronous CoAP responses.
- Duplicate packet detection.
- draft-ietf-core-block-10 for requesting large resources.
- draft-ietf-core-observe-07 for both observing resources and making resources observable by others.
- Virtual hosts, for implementing draft-ietf-core-groupcomm.
- Highly portable. Supports both BSD sockets and UIP/Contiki.
- Fully asynchronous I/O.
SMCP also comes with some useful tools:
smcpctl
— a powerful command line tool for browsing and configuring CoAP nodes. Familiar Unix-style commands (ls
,cat
,rm
, etc.) and tab-completion just work.smcpd
— a modular CoAP server, intended to make it easy to add CoAP support to existing servers. Includes a CoAP-to-HTTP proxy.smcp-plugtest-client
/smcp-plugtest-server
— For testing correctness and interoperability with other implementations.
Despite all of this, SMCP can be easily whittled down to the bare minimum requirements for an application. One of the goals of SMCP is to implement a full-featured CoAP stack, but
most embedded applications don't need all of these capabilities. Because of this,
SMCP is designed so that you can individually enable or disable features
depending on your needs (See src/smcp/smcp-opts.h
).
For example, SMCP has the ability to have more than once instance, but embedded
platforms will never need more than one. Passing around a reference to a
global variable that will never change is wasteful, so when compiled with
SMCP_EMBEDDED
turned on, we transparently (via some preprocessor magic) ignore
the reference to the SMCP instance from all of the functions that take it.
This makes it easy to use the same codebase for both embedded and non-embedded
applications. There are other configuration options for doing things like
limiting malloc()
usage, avoiding use of printf()
(and variants),
enabling/disabling observing, etc.
Getting Started
The best way to get started is to have a look at some example code which uses SMCP:
example-1.c
— Responding to a request.example-2.c
— Responding to a request for a specific resource.example-3.c
— Using the Node Router.example-4.c
— Making an observable resource.src/plugtest/*
— Plugtest implementations
Contiki Support
SMCP fully supports Contiki. To build the Contiki
examples, just make sure that the CONTIKI
environment variable is set point
to your Contiki root, like so:
$ cd contiki-src/examples/smcp-plugtest
$ make CONTIKI=~/Projects/contiki TARGET=minimal-net
API Docs and Mailing list
You can find an online version of the API documentation here: http://darconeous.github.com/smcp/doc/html/
I've also set up a mailing list: smcp-dev@googlegroups.com, https://groups.google.com/group/smcp-dev
What's next
There is still plenty of work to be done. The documentation needs to be improved. More platforms need to be tested. Bugs need to be found and fixed.
Things are quite usable and useful as they are, but they could be so much better. Which is why I'm releasing early. Please let me know your thoughts!