I want to produce network protocols, a very simplified example of which is depicted below:

A simple protocol

The protocol has two parties, each of which does some computation and then communicated with the other.

I can use a 3-column table, but I want to know if there is any better solution. Especially, whether there is any particular package for this, or any simple way to do it in TikZ.

  • 1
    Don't you think the image is a little too sparse? Visually it doesn't convey the message that the time is going downwards. I think the arrows need to have a target and a source. Of course I have no idea what are the specific practices of your field but still it can be a little intuitive. – percusse May 1 '12 at 21:02

Here is my simple solution using the method shown here:

\usetikzlibrary{matrix,shapes,arrows,positioning,chains, calc}

\matrix (m)[matrix of nodes, column  sep=2cm,row  sep=8mm, nodes={draw=none, anchor=center,text depth=0pt} ]{
Prover & & Verifier\\[-4mm]
Choose a random number & & \\[-7mm]
$r \in \{0,1\}^{*}.$ & & \\
 & Send $r$ & \\
& & Choose a random number  \\[-7mm]
& &$s \in \{0,1\}^{*}.$\\
 & Send $s$ & \\

\draw[shorten <=-1.5cm,shorten >=-1.5cm] (m-1-1.south east)--(m-1-1.south west);
\draw[shorten <=-1.5cm,shorten >=-1.5cm] (m-1-3.south east)--(m-1-3.south west);
\draw[shorten <=-1cm,shorten >=-1cm,-latex] (m-4-2.south west)--(m-4-2.south east);
\draw[shorten <=-1cm,shorten >=-1cm,-latex] (m-7-2.south east)--(m-7-2.south west);

EDIT The graphical result is:

enter image description here

  • 4
    It's always nice to have an image of the result. The standalone class or pdfcrop can help here. It is recommended to convert it to a PNG yourself before uploading. You can use \documentclass[png]{standalone} and then compile with pdflatex -shell-escape (needs Image Magic to be installed). – Martin Scharrer May 1 '12 at 20:35

Did you look at MSC (Message Sequence Charts) package in CTAN? I've never used but some of our students did it.

EDIT Your example could be done with some code like this

Choose a random number\\
\mess{Send $r$}{prover}{verifier}
Choose a random number\\
\mess{Send $s$}{verifier}{prover}

and the result (with xelatex because msc uses pstricks) is

enter image description here

The apperance is not so flexible because msc diagrams are normalized by ITU (International Telecomunication Union) and the package respects the format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.