which type of commands should I use for drawing network packet formats like this
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<+
|V=2|P|X| CC |M| PT | sequence number | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| timestamp | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| synchronization source (SSRC) identifier | |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
| contributing source (CSRC) identifiers | |
| .... | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| RTP extension (OPTIONAL) | |
+>+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| | payload ... | |
| | +-------------------------------+ |
| | | RTP padding | RTP pad count | |
+>+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<+
| ~ SRTP MKI (OPTIONAL) ~ |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| : authentication tag (RECOMMENDED) : |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| |
+- Encrypted Portion* Authenticated Portion ---+
Should I use matrices, tables or rectangle nodes with relative positioning?
A similar task would be to draw something like this:
I managed to do this with the following code but I am not sure if this is the best solution.
\begin{figure}[h]
\centering
\tikzstyle{rect}=[rectangle,minimum width=6cm,minimum height=1cm,draw=black,outer sep=0pt]
\tikzstyle{base rect}=[rect,minimum width=12cm,outer sep=0pt]
\tikzstyle{text rect}=[rectangle,minimum width=6cm,align=center,outer sep=0pt]
\tikzstyle{multipart rect}=[rectangle split,rectangle split horizontal,rectangle split parts = 2,inner xsep = 0.0mm,outer sep=0pt,
draw=black,align=center,minimum width=6cm,minimum height=1cm]
\begin{tikzpicture}
% ip
\node (IP) [base rect,fill=gray!20] {IP};
% media plane
\node (UDP) [rect,fill=blue!20,above left=0.0cm of IP.north] {UDP};
\node (ICE) [rect,fill=purple!20,above=0.0cm of UDP] {ICE, STUN, TURN} ;
\node (DTLS) [rect,fill=orange!20,above=0.0cm of ICE] {DTLS} ;
\node (SRTP) [multipart rect,rectangle split part fill={green!20,yellow!20},above=0.0cm of DTLS] {\nodepart[text width=3cm]{one} SRTP \nodepart[text width=3cm]{two} SCTP} ;
\node [text rect,above=0.0cm of SRTP]{Media Plane};
% signaling plane
\node (TCP) [rect,fill=blue!20,above right=0.0cm of IP.north]{TCP};
\node (TLS) [rect,fill=purple!20,above=0.0cm of TCP] {TLS};
\node (HTTP) [rect,fill=orange!20,above=0.0cm of TLS] {HTTP};
\node (WS) [rect,fill=green!20,above=0.0cm of HTTP] {WS/Other};
\node (SDP) [multipart rect,above=0.0cm of WS,rectangle split part fill={gray!20,yellow!20}] {\nodepart[text width=3cm]{one} SDP \nodepart[text width=3cm]{two} SIP/XMPP/\\Other};
\node [text rect,above=0.0cm of SDP]{Signaling Plane};
\end{tikzpicture}
\caption{WebRTC stack.}
\label{fig:webrtc-stack}
\end{figure}


bytefieldpackage instead oftikz. Some examples: https://tex.stackexchange.com/a/604681/1952, https://tex.stackexchange.com/a/270341/1952 – Ignasi Aug 28 '21 at 10:55WebRTC stacklooks pretty easy but still quite hard to implement in tikz so I though I am missing some obvious options.@Ignasi
– mikeProgrammer Aug 28 '21 at 11:05bytefieldlooks awesome! Thanks!