forked from cosmos/ibc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacket-state-machine.tex
41 lines (34 loc) · 1.45 KB
/
packet-state-machine.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
\documentclass[tikz,10pt,border=10pt]{standalone}
\usepackage{textcomp}
\usepackage{xcolor}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzset{%
state/.style = {draw, thick, rectangle, node distance = 6cm}
}
\newcommand{\CA}[1]{\it{A} \textcolor{black}{\textsc{#1}}}
\newcommand{\CB}[1]{\it{B} \textcolor{black}{\textsc{#1}}}
\newcommand{\CS}[2]{\begin{tabular}{l}
\CA{#1} \\
\CB{#2}
\end{tabular}}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\draw
node [state, name=start, right = 0.5mm] {\CS{Unsent}{Unreceived}}
node [state, right of=start] (send) {\CS{Sent}{Unreceived}}
node [state, right of=send] (recv) {\CS{Sent}{Received}}
node [state, below of=send] (timeout) {\CS{Sent,TimedOut}{Unreceived}}
node [state, right of=timeout] (timeoutfinal) {\CS{Sent,TimedOut}{TimedOut}};
\draw node [state, name = key, right = 18cm, above = 2mm] {\begin{tabular}{l}
\it{Key} \\
\textcolor{blue}{Standard Flow} \\
\textcolor{red}{Timeout Flow} \\
\end{tabular}};
\draw[->, blue](start) edge node[yshift=3mm, xshift=1mm] {\textsc{sendPacket}} (send);
\draw[->, blue](send) edge node {\textsc{recvPacket}} (recv);
\draw[->, red](send) edge node {\textsc{timeoutPacket}} (timeout);
\draw[->, red](timeout) edge node {\textsc{recvTimeoutPacket}} (timeoutfinal);
\draw[color=black,thick](-1.5,-8) rectangle (20,2);
\node at (-0.5,1.5) [above=0.5mm, right=5mm] {\huge{\textsc{Packet State Machine}}};
\end{tikzpicture}
\end{document}