Book Review: uC/TCP-IP by Christian Légaré


Book Review:


by Christian Légaré–uC-TCP-IP-by-Christian-L-gar-?c%20%20%20%20id=NL_CommsDesign

Clive Maxfield  11/30/2010 12:43 PM EST

I have to say that I am very, VERY impressed with the quality of books that are being written by the folks at Micriµm – the one I just finished reading on TCP-IP still has my head buzzing!

First of all, let’s remind ourselves that the guys and gals at Micriµm are famous for their Real-Time Operating System (RTOS) that is tailored for use in embedded systems. The latest incarnation of this RTOS is known as µC/OS-III (pronounced “Micro-C, O-S Three”), which is a state-of-the-art, scalable, ROMable, pre-emptive real-time kernel that manages an unlimited number of tasks. (Click Here to see my review of the book uC/OS-III The Real-Time Kernel by Jean Labrosse.)

Now, having an RTOS is great, but embedded systems increasingly require to be connected to other devices and to the outside world. And so we come to the Transmission Control Protocol (TCP) and the Internet Protocol (IP). These are commonly referred to together as TCP/IP, and they are the foundation of every networked device.

There are a bunch of books and other sources that explain the TCP/IP protocol stack in excruciating detail and provide mind-numbing minutiae as to how the TCP/IP protocols perform their magic. However, these sources almost invariably target systems with plenty of resources – they typically fail to address the challenges associated with resource-scarce embedded systems.
Furthermore, embedded systems often have real-time requirements that larger systems were not designed to handle. This means that, when used in an embedded system, in addition to following TCP/IP specifications, the TCP/IP stack must also keep a watchful eye towards the resource constraints inherent in the end product.
Since the first version of their real-time kernel was released in 1992, the folks at Micriµm started to receive an ever-increasing number of requests for a TCP/IP stack. In 2002 they evaluated the TCP/IP stacks that were available to the embedded community, but they couldn’t find anything that would properly complement their real-time kernel. Thus, they eventually concluded that they would need to create their own TCP/IP stack from the ground up.

As you can imagine, this was a huge undertaking that has taken them well over 15 engineer years to complete, but the result is µC/TCP-IP – which (in my humble opinion) is the best TCP/IP stack for embedded applications. Note that although µC/TCP-IP fully complements µC/OS-III, it has been created in such a way that it can be easily adapted to work with just about any real-time kernel.
We’ll talk about µC/TCP-IP in more detail in just a little while. But first, we should note that the book µC/TCP-IP is actually two books in one.

Part 1 commences an overview of the basics of networking,

the implementation challenges associated with embedding TCP/IP, Ethernet, IP Networking, Transport Protocols, Sockets, Services and Applications… and a whole bunch of other stuff.

Part 1 then goes on to introduce µC/TCP-IP and walk through various aspects of the µC/TCP- IP implementation and usage, including the µC/TCP- IP architecture, network device drivers, buffer management, socket programming, timer management, debug management, and the various µC/TCP- IP device driver APIs, API functions, and macros.

Part II makes use of the versatile µC/Eval-STM32F107 evaluation board, which is sold separately through Micrium (Click Here for more details). The application examples in Part II enable readers to develop their own prototypes using this expandable evaluation board.
This book is written for serious embedded systems programmers, consultants, hobbyists, and students interested in understanding the inner workings of a TCP/IP stack. µC/TCP-IP is not just a great learning platform, but also a full commercial-grade software package, ready to be part of a wide range of products.

Introducing µC/TCP-IP in a little more detail
OK, in order to introduce µC/TCP-IP in a little more detail, I can do no better than replicate the contents of Chapter 10 of the book, which I do so as follows with the kind permission of the folks at Micriµm:

Chapter 10: Introduction to μC/TCP-IP

μC/TCP-IP is a compact, reliable, high-performance TCP/IP protocol stack. Built from the ground up with Micriμm’sunique combination of quality, scalability and reliability, μC/TCP-IP, the result of many man-years of development, enables the rapid configuration of required network options to minimize time to market.

The source code for μC/TCP-IP contains over 100,000 lines of the cleanest, most consistent ANSI C source code available in a TCP/IP stack implementation. C was chosen since C is the predominant language in the embedded industry. Over 50% of the code consists of comments and most global variables and all functions are described. References to RFC (Request For Comments) are included in the code where applicable.

10-1 Portable
μC/TCP-IP is ideal for resource-constrained embedded applications. The code was designed for use with nearly any CPU, RTOS, and network device. Although μC/TCP-IP can work on some 8 and 16-bit processors, μC/TCP-IP is optimized for use with 32 or 64-bit CPUs.

10-2 Scalable
The memory footprint of μC/TCP-IP can be adjusted at compile time depending on the features required, and the desired level of run-time argument checking appropriate for the design at hand. Since μC/TCP-IP is rich in its ability to provide statistics computation, unnecessary statistics computation can be disabled to further reduce the footprint.

10-3 Coding Standards
Coding standards were established early in the design of μC/TCP-IP. They include:

  • C coding style
  • Naming convention for #define constants, macros, variables and functions
  • Commenting
  • Directory structure

These conventions make μC/TCP-IP the preferred TCP/IP stack implementation in the industry, and result in the ability to attain third party certification more easily as outlined in the next section.

10-4 MISRA C
The source code for μC/TCP-IP follows Motor Industry Software Reliability Association (MISRA) C Coding Standards. These standards were created by MISRA to improve the reliability and predictability of C programs in safety-critical automotive systems. Members of the MISRA consortium include such companies as Delco Electronics, Ford Motor Company, Jaguar Cars Ltd., Lotus Engineering, Lucas Electronics, Rolls-Royce, Rover Group Ltd., and universities dedicated to improving safety and reliability in automotive electronics.

Full details of this standard can be obtained directly from the MISRA web site at:

10-5 Safety Critical Certification
μC/TCP-IP was designed from the ground up to be certifiable for use in avionics, medical devices, and other safety-critical products. Validated Software’s Validation Suite™ for μC/TCP-IP will provide all of the documentation required to deliver μC/TCP-IP as a pre-certifiable software component for avionics RTCA DO-178B and EUROCAE ED-12B, medical FDA 510(k), IEC 61508 industrial control systems, and EN-50128 rail transportation and nuclear systems. The Validation Suite, available through Validated Software, will be immediately certifiable for DO-178B Level A, Class III medical devices, and SIL3/SIL4 IEC-certified systems. For more information, check out the μC/TCP-IP page on the Validated Software web site at:

If your product is not safety critical, however, the presence of certification should be viewed as proof that μC/TCP-IP is very robust and highly reliable.
10-6 RTOS

μC/TCP-IP assumes the presence of an RTOS, yet there are no assumptions as to which RTOS to use with μC/TCP-IP.

The only requirements are that it:

  1. must be able to support multiple tasks
  2. must provide binary and counting semaphore management services
  3. must provide message queue services

μC/TCP-IP contains an encapsulation layer that allows for the use of almost any commercial or open source RTOS. Details regarding the RTOS are hidden from μC/TCP-IP. μC/TCP-IP includes the encapsulation layer for μC/OS-II and μC/OS-III real-time kernels.

10-7 Network Devices
μC/TCP-IP may be configured with multiple-network devices and network (IP) addresses. Any device may be used as long as a driver with appropriate API and BSP software is provided. The API for a specific device (i.e., chip) is encapsulated in a couple of files and it is quite easy to adapt devices to μC/TCP-IP (see Chapter 20, “Statistics and Error Counters” on page 361).
Although Ethernet devices are supported today, Micriμm is currently working on adding Point-to-Point Protocol (PPP) support to μC/TCP-IP.

10-8 μC/TCP-IP Protocols
μC/TCP-IP consists of the following protocols:

  • Device drivers
  • Network Interfaces (e.g., Ethernet, PPP (TBA), etc.)
  • Address Resolution Protocol (ARP)
  • Internet Protocol (IP)
  • Internet Control Message Protocol (ICMP)
  • Internet Group Management Protocol (IGMP)
  • User Datagram Protocol (UDP)
  • Transport Control Protocol (TCP)
  • Sockets (Micriμm and BSD v4)

10-9 Application Protocols
Micriμm offers application layer protocols as add-ons to μC/TCP-IP. A list of these network services and applications includes:

  • μC/DCHPc, DHCP Client
  • μC/DNSc, DNS Client
  • μC/HTTPs, HTTP Server (web server)
  • μC/TFTPc, TFTP Client
  • μC/TFTPs, TFTP Server
  • μC/FTPc, FTP Client
  • μC/FTPs, FTP Server
  • μC/SMTPc, SMTP Client
  • μC/POP3, POP3 Client
  • μC/SNTPc, Network Time Protocol Client

Any well-known application layer protocols following the BSD socket API standard can be used with μC/TCP-IP.