\tikzstyle{pkt}=[
  fill,
  below=-.5\baselineskip,
  font=\scriptsize,
  draw,
  dash pattern=on 2pt off 2pt,
]
\tikzstyle{clipkt}=[pkt,
  below left=-.5\baselineskip and 0cm,
  pos=0.05,
]
\tikzstyle{devpkt}=[pkt,
  below right=-.5\baselineskip and 0cm,
  pos=0.05,
]
\begin{tikzpicture}[
  every node/.style={fill=white, font=\small},
  every picture/.style=ultra thin,
  >=latex,
  semithick
]

\def\bot{-16}
\def\top{0}
\def\dev{-5}
\def\cli{5}
\newlength{\ypos}
\newlength{\yypos}
\setlength{\ypos}{0cm}
\setlength{\yypos}{.5cm}
\def\advanceby#1{%
  \addtolength{\ypos}{#1}%
  \addtolength{\yypos}{#1}%
  \global\ypos=\ypos% // see https://tex.stackexchange.com/questions/119730
  \global\yypos=\yypos%
}

%% Header
\draw (\cli,\top) node[draw]{Client} -- (\cli,\bot);
\draw (\dev,\top) node[draw]{Device} -- (\dev,\bot);

\advanceby{.75cm}
\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+<stream>+};
\advanceby{1cm}
\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+<stream>+};

\advanceby{1cm}
\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt,text width=5cm]{
\begin{verbatim}
<iq type='get' id='1'
    to='dev@device.local/res'
    from='client@client.local'>
  <req xmlns='urn:xmpp:sn' seqnr='1'
      momentary='true'>
    <node nodeId='Device04'/>
    <field name='Energy'/>
    <field name='Power'/>
  </req>
</iq>
\end{verbatim}
\advanceby{9\baselineskip}
};

\advanceby{1cm}
\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=6cm]{
\begin{verbatim}
<iq type='result' id='1'
    from='dev@device.local'
    to='client@client.local/res'>
  <accepted xmlns='urn:xmpp:sn' seqnr='1'/>
</iq>
\end{verbatim}
\advanceby{4\baselineskip}
};

\advanceby{1cm}
\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt,text width=7cm]{
\begin{verbatim}
<message from='dev@device.local'
    to='client@client.local/res'>
  <fields xmlns='urn:xmpp:sn' seqnr='1' done='true'>
    <node nodeId='Device04'>
      <timestamp value='2013-03-07T22:03:15'>
        <numeric name='Energy' momentary='true'
          value='12345.67' unit='MWh'/>
        <numeric name='Power' momentary='true'
          value='239.4' unit='W'/>
      </timestamp>
    </node>
  </fields>
</message>
\end{verbatim}
\advanceby{12\baselineskip}
};

\advanceby{1cm}
\draw[->] (\cli,-\ypos) -- (\dev,-\yypos) node[clipkt]{\verb+</stream>+};
\advanceby{1cm}
\draw[->] (\dev,-\ypos) -- (\cli,-\yypos) node[devpkt]{\verb+</stream>+};
\end{tikzpicture}
% vim: set ft=tex et ts=2 sw=2 :
