next up previous
Next: What to turn Up: No Title Previous: Introduction

Part 1: Socket Call Tracer

In this part you implement socktrace. The esqueleton for socktrace is in the directory /u/u3/603/96spring/project1/part1/socktrace. The core of socktrace is the shared library socktracelib.so that defines new socket calls ( socket(), connect(), etc.) that print the function name, the arguments and then call the original implementation of these calls ( _socket(), _connect(), etc.). Inside each new call the name, the arguments, and result of the call are printed to stderr.

To link socktracelib.so to an already compiled application the script socktrace defines the environment variable LD_PRELOAD to be ./socktracelib.so . This environment variable defines the libraries that the run-time linker loads before starting the execution of a program. In this way the old socket calls are replaced by the new ones. Later in the script, socktrace executes the application that is passed as argument. This application is automatically linked to ./socktracelib.so before it starts executing.

Copy /u/u3/603/96spring/project1/part1/socktrace to your directory and type make. The Makefile has everything needed to build the application.

To test socktrace you can run:

        > socktrace finger russo@ector
        > socktrace ftp ector
        > socktrace netscape

As you see, not all the socket calls are traced in socktracelib.cc . You have to insert more socket calls to make the tool complete. You should trace the following socket calls: socket(), socketpair(), listen(), shutdown(), setsockopt(), send(), getsockopt(), bind(), connect(), accept(), getpeername(), getsockname(), recv(), recvfrom(), recvmsg(), sendmsg(), and sendto().

Also print the arguments and results in a more readable way. For example host addreses should be printed as names. Constants should be printed with a symbolic name instead of numbers etc. The information printed and its format are important for your grade. If you are creative you can make socktrace to print at the end the number of times each call is invoked or to trace specific calls.





next up previous
Next: What to turn Up: No Title Previous: Introduction



Gustavo Rodriguez-Rivera
Tue Feb 13 16:34:51 EST 1996