Check out the new USENIX Web site. next up previous
Next: The Life of a Up: How Trickle Works Previous: A Simple Rate Limiting

The Mechanics of Library Interpositioning

Figure 1: libtrickle.so is preloaded in the application's address space, calls to recv() and send() are handled by libtrickle.so and passed down to libc.

\begin{picture}(0,0)%
\includegraphics{preloading.pstex}%
\end{picture}
@font
picture(3177,1824)(4264,-7198)

With very rare exceptions, network software for Unix-like systems uses the socket abstraction provided by the operating system. In reality, the socket abstraction is entirely contained in the system call layer with corresponding libc shimsA small software component used to provide an interface to another software component (a trivial ``adapter''). Thus, with the use of the link editor's preload functionality, we interposition the Trickle middleware at a convenient level of abstraction and we do so entirely in user space.

Using preload objects, we replace the BSD socket abstraction layer provided by libc. However, to successfully interposition the Trickle middleware, we must be able to call the original version of the very interface we have replaced. To resolve this issue, we need to take advantage of the second feature of the link editor we discussed: We simply explicitly resolve the libc shims and call them as needed. This is done by opening the actual object file that contains libc, and using the link-editor API to resolve the symbols needed. The location of the libc shared object is discovered in the configuration/compilation cycle, but could just as easily be discovered dynamically at run time. Figure 1 attempts to illustrate the mechanics of the interpositioning of the Trickle middleware.

In practice, preload objects are specified by the environment variable LD_PRELOAD. Trickle's command line utility, trickle, sets this environment variable to the object that contains Trickle's middleware. Additionally, it passes any parameters specified by the user in other environment variables in a well defined namespace. These parameters may include upstream or downstream rates to apply, as well as whether or not this instance of Trickle should collaborate with other instances of Trickle.


next up previous
Next: The Life of a Up: How Trickle Works Previous: A Simple Rate Limiting
Marius Eriksen 2005-02-24