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

TCP header

The macro TCP_HDR builds a TCP header, as defined in [RFC793]. The macro TCP_PCK prepends an IPv4 header to the TCP header.

\begin{displaymath}
\begin{tabular}{\vert cccccccccccccccccccccccccccccccc\vert}...
...rt}{0} &
\multicolumn{16}{c\vert}{0} \\
\hline
\end{tabular}\end{displaymath}

The TCP flags can either be set through $tcp_flags, or through the variables below. The values of $tcp_flags and the single-bit variables are simply or-ed, so setting $tcp_flags and any of the single-bit variables to a value other than zero may not yield the desired result.

\begin{displaymath}
\begin{tabular}{\vert c\vert c\vert c\vert c\vert c\vert c\v...
...tcp\_FIN} \\
0 & 0 & 0 &
0 & 0 & 0 \\
\hline
\end{tabular}\end{displaymath}

Example:

$tcp_sport=3445 /* ephemeral port */
$tcp_dport=80   /* HTTP */

send IP_HDR($ip_proto=IPPROTO_TCP $ip_tos=0xb8)
     TCP_HDR($tcp_SYN=1)
send TCP_PCK($ip_tos=0xb8 $tcp_SYN=1) /* equivalent */



Martin A. Brown 2003-11-06