Simple TCP pair

Revision as of 16:32, 12 April 2013 by Xemul (talk | contribs) (collapse tcp.c text)

This page describes step-by-step how to play with TCP dumping and restoring.

Compile and run simple TCP client and server

The below program is a simple echo server and a client, that pings server with increasing numbers once a second. In this howto we will dump and restore the client part.

So compile it and run server

# ./tcp-howto <some-port>

and on another terminal (for better output readability) -- the client

# ./tcp-howto 127.0.0.1 <some-port>

Try to dump the client

Create a directory for images (img-dir/ below) and dump the client

# crtools dump --tree <tcp-howto-client-pid> --images-dir img-dir/ -v 4 -o dump.log --shell-job --tcp-established

The --tcp-established option is a must, since client have active TCP connection and we should explicitly inform crtools about it.

The --shell-job option is also required, as the client was launched from shell and uses shell's session and terminal.

Then restore the client

It's done like this

# crtools restore --tree <tcp-howto-client-pid> --images-dir img-dir/ -v 4 -o rst.log --shell-job --tcp-established

That's it. After this in the terminal you launched crtools from you should see the contunuing output of the tcp client.