Fossa is a multi-protocol networking library by Cesanta; the same company that gave the popular lightweight Mongoose web server to the world. Fossa implements a lot of useful networking protocols on top of plain TCP and UDP, such as

  • HTTP client & server

  • Websocket client & server

  • JSON-RPC client & server

  • MQTT client & broker

  • CoAP client & server

All of these are popular protocols often used in the Internet of Things, and this is exactly where picoTCP comes into play.

With the help of the picotcp-bsd library, picoTCP offers a BSD POSIX-compliant socket interface. This means it should be trivial to port existing networking libraries or applications using BSD sockets. But is it? Let’s take a look.

Fossa is written in C, aimed at embedded systems and (also) GPLv2 licensed. It uses a single thread, uses only non-blocking BSD socket calls and works using a polling function named “ns_mgr_poll” which should be called periodically. This will call the BSD-select function, in a non-blocking way as to multiplex I/O on file descriptors which are network sockets in this case. This allows you to wait for specific events on sockets with a single blocking or non-blocking call.

The great thing about our picotcp-bsd library is that it implements the select() function and can even run on a bare-metal system, i.e. without an operating system such as FreeRTOS or Linux.

The combination “bare metal + picoTCP + picotcp-bsd + Fossa” is quite powerful, allowing you to use a lot of application-level protocols on multiple BSD-sockets, while running a single-threaded system.

As a demonstrator for the integration of Fossa with picoTCP and picotcp-bsd, we implemented a simple RESTful web server using all of the above ingredients.

If you're interested to see how we've done this, hop over to GitHub: https://github.com/tass-belgium/fossa-demo

Instructions to build and run it are in the README. For more information specifically about Fossa you can visit their docs page.