IOC Robotic's Lab

This is work in progress

Realtime options in Linux

Generic stock Linux kernel hasn't realtime capabilities as the kernel task scheduler can preempt any user task at any instant if other tasks with higher priority need the use of the processor. For this reason several solutions providing realtime capabilities to Linux have been proposed, being the following the more widely known:

RT-Preempt patch for the Linux Kernel
To be done
RTLinux is a hard realtime RTOS microkernel that runs the entire Linux operating system as a fully preemptive process. Theoretically is free software. However, a patent covering this technology was filed, and the unclear legal status surrounding this project is preventing its use within the free software projects.
Based on a different mechanism than RT-Linux to avoid the latter patented technology, this project makes use of the Aedos interrup pipeline wich introduces a hardware abstraction layer allowing deterministic handling of interrupts prior to sending them to the linux interrupt handling routines.
A fork of RTAI due to developer differences, its developing seems to be more active nowadays. This is the solution we've chosen.

Enabling Xenomai extensions into the Linux kernel

To be done

Realtime Networking

Networking, specially ethernet networking, poses great challenges to a realtime environment. With Ethernet, the communications are not deterministic because of the collision which can occur between several host on a network with a hub, or because of the unknown latency in the case of the switch. These collisions are unavoidable as they constitute the mechanism the network nodes use to gain access to the communication media shared between al network devices. This mechanism is known as CSMA/CD (Carrier Sense Multiple Access/Collision Detection).

To work around this, some slight modifications of the original ethernet standard have been proposed, being RTnet one of the most interestings at present. RTnet is a protocol stack which run between the Ethernet layer and the application layer (or IP layer). It aims, through the use of time intervals (time-slots), is to make deterministic communication, by substituting the CSMA/CD media access method by a TDMA (time division multiple access) strategy and prevent buffering packet in the network. RTnet is a software developed to run on Linux kernel with RTAI or Xenomai real-time extension. It exploits the real time kernel extension to ensure the determinism on the communication stack. In this aim, all the instructions related to this protocol makes use real time kernel functions rather than those of Linux, which bound latencies to the execution times and latencies of interruptions which provide deterministic's communication.

So, to be clear, RTnet achieves realtime networking by addressing two issues simultaneously:

  1. First, it works inside a realtime operating system (like Linux with Xenomai extensions) to ensure deterministic software processing of the incoming/outgoing data packets.
  2. Second, it uses a TDMA media access mechanism to avoid packet collisions into the physical media, which would lead to unpredictable communication delays. To achieve this an additional protocol layer called RTmac controls the media access. A dedicated Ethernet segment is required to guarantee bounded transmission delays, but RTnet also includes a mechanism to tunnel non real-time traffic like TCP/IP over RTmac, thus allowing a "single-cable" solution for connecting control systems. Interestingly, this TDMA mechanism is optional, as you can deactivate it if you don't need it, perhaps because your network won't have collisions by design. Although this may sound strange, this is just the case if you are using your computer to communicate with some slaves using the EtherCAT standard.

RTnet is an Open Soure hard real-time network protocol stack for Xenomai and RTAI (real-time Linux extensions). It makes use of standard Ethernet hardware and supports several popular NIC chip sets, including Gigabit Ethernet. Moreover, Ethernet-over-1394 support is available based on the RT-FireWire protocol stack.

RTnet implements UDP/IP, TCP/IP (basic features), ICMP and ARP in a deterministic way. It provides a POSIX socket API to real-time user space processes and kernel modules.

  • Using RTnet in our EtherCAT master computer.