1

i would represent the communication flow between a client and a server by using Tikz. The communication flow is reported in the image.

Communication flow

Based on this, i started to use Tikz to design this flow in my work. The current code is:

  \begin{tikzpicture}[node distance=2cm,auto,>=stealth']
\node[] (server) {Server};
\node[left = of server] (client) {Client};
\node[below of=server, node distance=5cm] (server_ground) {};
\node[below of=client, node distance=5cm] (client_ground) {};
%
\draw (client) -- (client_ground);
\draw (server) -- (server_ground);
\draw[->] ($(client)!0.25!(client_ground)$) -- node[above,scale=1,midway]{m_1} ($(server)!0.25!(server_ground)$);
\draw[<-] ($(client)!0.35!(client_ground)$) -- node[above,scale=1,midway]{Response m_1} ($(server)!0.35!(server_ground)$);
\draw[->] ($(client)!0.45!(client_ground)$) -- node[above,scale=1,midway]{m2} ($(server)!0.45!(server_ground)$);
\end{tikzpicture}

But i'm not able to design the dot below m2 and m3 and also the line on the right related to the Time.

Can you help me please?

Bestregards,

1 Answer 1

2

Welcome! Instead of all these coordinate computations I would set up a local coordinate system in which (0,0) is the the (client_ground) coordinate and (1,1) is the tip of the arrow pointing to server. Other than that I'd use positioning and arrows.meta.

\documentclass[tikz,border=3mm]{standalone}
\definecolor{myblue}{RGB}{85,114,193}
\tikzset{Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
    line width=1pt,
    dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
    shorten >=0.3em,shorten <=0.3em},
    Dotted/.default=5}
\usetikzlibrary{arrows.meta,calc,positioning}
\begin{document}
\begin{tikzpicture}[auto,>=Triangle,font=\sffamily]
\node (server) {Server};
\node[base left=4cm  of server] (client) {Client};
\coordinate[below=6cm of server] (server_ground);
\coordinate[below=6cm of client] (client_ground);
%
\draw[line width=2pt,myblue] (client) -- (client_ground)
 (server) -- (server_ground);
\begin{scope}[line width=3pt,draw=myblue,shift={(client_ground)},
    nodes={above},declare function={t1=0.85;r1=0.6;t2=0.45;t3=0.1;},
    x={($(server_ground)-(client_ground)$)},y={($(client.south)-(client_ground)$)}]
 \draw[->] (0,t1) -- node{$m_1$} (1,t1);
 \draw[->] (1,r1) -- node{response $m_1$} (0,r1);
 \draw[->] (0,t2) -- node(m2){$m_2$}  (1,t2);
 \draw[->] (0,t3) -- node(m3) {$m_3$}  (1,t3);
 \draw[-,Dotted=8,line width=4pt, shorten <=5pt] (m2) -- (m3);
 \draw[semithick,<->] (1.1,t3) -- (1.1,t2) node[midway,right]{Time};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks a lot, this is exactly what i searched.
    – Auron
    Apr 8, 2020 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .