next up previous contents
Next: TCP header Up: Packet construction Previous: Packet construction   Contents

IPv4 header

The macro IP_HDR builds an IPv4 header, as defined in [RFC791]. The macro IP_PCK is synonymous to IP_HDR, except that it also sets the protocol to ETH_P_IP with ``default'' priority.

\begin{displaymath}
\begin{tabular}{\vert cccccccccccccccccccccccccccccccc\vert}...
...{\vert c\vert}{{\bf global} 10.0.0.2} \\
\hline
\end{tabular}\end{displaymath}

Note that $ip_src and $ip_dst are of type ``IPv4 address''.

The following flags are used for handling IP fragments:

\begin{displaymath}
\begin{tabular}{\vert c\vert c\vert c\vert}
\multicolumn{1}...
...p\_DF} & {\tt\$ip\_MF} \\
0 & 0 & 0 \\
\hline
\end{tabular}\end{displaymath}

Example:

$ip_dst = 1.2.3.4

send IP_PCK($ip_tos=0xe0 $ip_proto=46)
  /* pretend this is RSVP */



Martin A. Brown 2003-11-06