# What is Data Offset and its uses in TCP Header?

I was learning about TCP and came across Data offset. This was the answer I found.

" Data offset specifies the size of the TCP header in 32 bit words. The min. size header is 5 words and the max. is 15 words, thus giving the min. size of 20 bytes and max. of 60 bytes."

What is the word means ? 32 bit words, 5 words, 15 words. How they concluded the size as 20 bytes and 60 bytes.

The purpose of the data offset is to tell the upper layers where the data starts. As you point out, the TCP header can be anywhere from 5-15 words long. So you need to know where the header ends and the data begins.

in 32 bit words

means that in this context the `word` unit is defined as `32 bits`.

Since 1 byte = 8 bits, a word is 4 bytes.

So a header 5 words long is 20 bytes and a 15 words header is 60 bytes.

Even if this is an old post, I'd like to give an answer as an detailled answer was not yet priveded and it is still the first Google result. Correct me if I'm wrong, I'm still learning too.

The expression `word` is kind of confusing.

Data Offset means the WHOLE Header content. The Offset, after which the Data starts.

As the Header maximum size can be up to 60 bytes = 480bit. You can separate it into 20byte (160bit) minumum plus 40byte (320bit) maximum (optional).

AFTER the number of XY `words` the Data itself starts. Everything inbetween these `words` is still part of the Header. At the same time it defines the length of the `OPTIONS` field, as the part of the Header before `OPTIONS` is always 20 byte long (mandatory).

Data Offset itself is 4 bits long, that means you can have up to 16 values/words (2^4=16, where the 2 means => '1' and '0' with 4 possible combinations). Because you calculate with "32 bit long" words, every of these 16 values stands for one block of 32 words. 0000 does not count*, therefor 16-1=15 => 15*32 BIT= 60 Byte (total length)

At first sight it's a bit confusing that the size is defined in the "middle" of the Header describing itself. But you have to put it somewhere... So there's no better place.

*I'm not 100% sure about this one (why it is that way). My binary is not good enough. Someone can explain or correct if needed. But the Values itself are correct.