| Image title | % based on: https://tex.stackexchange.com/a/155416 (Posted by Ignasi, modified by community) and https://commons.wikimedia.org/wiki/File:TCP_CLOSE.svg (Clemente)
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{arrows,shadows,positioning}
\begin{document}
\begin{tikzpicture}[font=\sffamily,>=stealth',thick,
commentl/.style={text width=3cm, align=right},
commentr/.style={commentl, align=left},
packetinfo/.style={below, sloped, font=\scriptsize\sffamily, text width=3.2cm, align=center},]
\node[] (init) {\LARGE Client};
\node[right=1cm of init] (recv) {\LARGE Server};
% 3-way handshake: SYN, SYN-ACK, ACK
\draw[->] ([yshift=-1.3cm]init.south) coordinate (syn1o) -- ([yshift=-.7cm]syn1o-|recv) coordinate (syn1e)
node[pos=.25, above, sloped] {SYN}
node[pos=.25, packetinfo] {$\mathsf{seq=x}$};
\draw[->] ([yshift=-.3cm]syn1e) coordinate (synacko) -- ([yshift=-.7cm]synacko-|init) coordinate (synacke)
node[pos=.45, above, sloped] {SYN, ACK}
node[pos=.35, packetinfo] {$\mathsf{seq=y},$\\$\mathsf{ack=x+1}$};
\draw[->] ([yshift=-.3cm]synacke) coordinate (acko) -- ([yshift=-.7cm]acko-|recv) coordinate (acke)
node[pos=.65, above, sloped] {ACK}
node[pos=.65, packetinfo] {$\mathsf{seq=x+1},$\\$\mathsf{ack=y+1}$};
\draw[thick, solid, shorten >=-1cm] (init) -- (init|-acke);
\draw[thick, solid, shorten >=-1cm] (recv) -- (recv|-acke);
\draw[dotted] (init.255)--([yshift=2mm]init.255|-syn1o);
\draw[dotted] (recv.285)--([yshift=2mm]recv.285|-syn1e) coordinate[pos=.5] (aux1);
\draw[dotted] ([yshift=1mm]init.255|-synacke) --([yshift=-5mm]init.255|-acke) coordinate (aux2);
\node[below left = 0mm and 2mm of init.south, commentl]{\textbf{CLOSED}};
\node[left = 2mm of syn1o.west, commentl]{\textbf{SYN\_SENT}};
\node[below left = -4.5mm and 2mm of acko.west, commentl]{\textbf{ESTABLISHED}\\[-1.5mm]{\itshape connection}};
\node[below right = 0mm and 2mm of recv.south, commentr]{\textbf{CLOSED}};
\node[right = 2mm of recv|-aux1, commentr]{\textbf{LISTEN}};
\node[right = 2mm of synacko.west, commentr]{\textbf{SYN\_RECEIVED}};
\node[below right = -1mm and 2mm of acke.west, commentr]{\textbf{ESTABLISHED}\\[-1.5mm]{\itshape connection}};
\end{tikzpicture}
\end{document} |
|---|