Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


❑ ack_seqholds a sequence number used when acknowledging receipt of TCP packets.
❑ doffstands fordata offsetand specifies the length of the TCP header structure, which is not
always the same owing to the variable nature of some of the options.
❑ reservedis not available (and should therefore always be set to 0).
❑ urg(urgent),ack(acknowledgment),psh(push),rst(reset),syn(synchronize), andfinarecontrol
flagsused to check, establish, and terminate connections.
❑ windowtells the connection partner how many bytes it can send before the receiver buffer will be
full. This prevents backlog when fast senders communicate with slow receivers.
❑ checksumis the packet checksum.
❑ optionsis a variable-length list of additional connection options.
❑ The actualdata(or payload) follows the header. Theoptionsfield may bepaddedbecause the
data entry must always start at a 32-bit position (to simplify handling).

The header is implemented in thetcphdrdata structure. The system endianness must be noted because
a split byte field is used.


<tcp.h>
struct tcphdr {
__be16 source;
__be16 dest;
__be32 seq;
__be32 ack_seq;
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u16 res1:4,
doff:4,
fin:1,
syn:1,
rst:1,
psh:1,
ack:1,
urg:1,
ece:1,
cwr:1;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u16 doff:4,
res1:4,
cwr:1,
ece:1,
urg:1,
ack:1,
psh:1,
rst:1,
syn:1,
fin:1;
#else
#error "Adjust your <asm/byteorder.h> defines"
#endif
__be16 window;
__sum16 check;
__be16 urg_ptr;
};
Free download pdf