Beginner problems in Tikz (vertical lines, letters, …)

I'm new to Tikz and I'm trying to recreate this picture right here.

I've not gotten really far. I've been trying to this right here (note that the coordinates of dashedare definitely wrong, I didn't know how to set them).

\begin{tikzpicture}
\tikz{\draw (0,0) rectangle (7,0.75);}
\tikz{\draw [dashed] (0.5,0) -- (0.5,0.75);}
\end{tikzpicture}

But it doesn't seem to work no matter how I set the variables of dashed. Could someone please show me how to achieve this kind of picture? Also, I can't seem to add writing inside the box, I've tried so much now, that I've completely lost the overlook of what I've tried so far and what not.

• \tikz{..} is a shortform for \begin{tikzpicture} .. \end{tikzpicture}. Don't put the former inside the latter. – Torbjørn T. Dec 11 '17 at 20:18

Why TikZ? Just use a tabular.

\documentclass{article}

\begin{document}

\newcommand\mc{\multicolumn{1}}
\begin{tabular}{*7c}
2 & 1 & \multicolumn{5}{c}{509 bytes} \\
\hline
\mc{|c}{CircID} & \mc{|c}{CMD} & \multicolumn{5}{|c|}{DATA} \\
\hline
\\ % empty line
2 & 1 & 2 & 6 & 2 & 1 & 498 \\
\hline
\mc{|c}{CircID} & \mc{|c}{Relay} & \mc{|c}{StreamID} & \mc{|c}{Digest} & \mc{|c}{Len} & \mc{|c}{CMD} & \mc{|c|}{DATA} \\
\hline
\end{tabular}

\end{document}

• @AnneKunstmann If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and marking it as accepted answer (by clicking on the checkmark ✓). – Henri Menke Dec 11 '17 at 20:27