Simple TCP pair
This page describes step-by-step how to play with TCP dumping and restoring.
Compile and run simple TCP client and server[edit]
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.
Expandtcp-howto.c
|
---|
Compile it and run the server:
# ./tcp-howto <some-port>
On another terminal (for better output readability) run the client:
# ./tcp-howto 127.0.0.1 <some-port>
Try to dump the client[edit]
Create a directory for images (img-dir/
below) and dump the client
# criu dump --tree <tcp-howto-client-pid> --images-dir img-dir/ -v4 -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[edit]
It's done like this
# criu restore --images-dir img-dir/ -v4 -o rst.log --shell-job --tcp-established
That's it. After this in the terminal you launched criu from you should see the continuing output of the tcp client.