What is an IP Header?

Reading time: 7 min read
Jalluri Sirisha
Written by
Jalluri Sirisha

Updated · Nov 17, 2023

Jalluri Sirisha
Computer Networks Expert, VPN Expert | Joined June 2023 | LinkedIn
Jalluri Sirisha

Sirisha is a networking enthusiast with a bachelor's degree in computer science and engineering. She... | See full bio

Girlie Defensor
Edited by
Girlie Defensor

Editor

Girlie Defensor
Joined June 2023
Girlie Defensor

Girlie is an accomplished writer with an interest in technology and literature. With years of experi... | See full bio

Techjury is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more.

IP headers play an essential role on the Internet. They ensure the data sent to the destination and received from it is complete, correct, and in order.

Cisco defines an IP header as something that “contains the information required to route data on the Internet and has the same format regardless of the type of data being sent.”

This article will cover everything you need to know about an IP header. Read on.

Key Takeaways

  • IP headers include vital details such as source and destination addresses, packet length, IP version, and time-to-live (TTL), ensuring precise data transmission.
  • Effective routing and delivery of packets are enabled by IP headers, promoting orderly data exchange across the Internet.
  • IPv4 headers consist of 13 fields, whereas IPv6 headers comprise 8 fields—showcasing variations in size and address capacity.
  • Collaborating with protocols like TCP, IP headers contribute to reliable and sequential data transmission.
  • Familiarity with IP headers is crucial for optimizing data exchange, proficient packet handling, and mitigating transmission complications.

Understanding IP Header and How It Works

An IP header refers to the information included at the beginning of an IP packet. 

This information includes details such as:

  • IP version
  • Packet length
  • IP addresses (Source and Destination)
  • Time-to-live

If you're unfamiliar with IP packets, they are the tiniest messages exchanged on the web. 

You can think of these packets as actual packages. A package contains two things: the content inside and the label outside.

The contents inside are the data you receive and send to another server. Meanwhile, the label outside is the header. 

An IP packet header gives information to describe the data in the packet for accurate receiving, processing, and returning. 

With the details, you can ensure proper and efficient sending and delivery.

In a Nutshell

The IP header holds vital information for IP packets—including IP version, packet length, IP addresses, and time-to-live. It ensures accurate packet handling and efficient delivery.

IP Header Fields

You'll find several header fields depending on the version of IP. Each header field includes essential information about the transferred data. 

Since IPv4 and IPv6 have different headers, take a closer look at each one:

IPv4 Header Field

You can find 13 fields in an IPv4 header. Here's what the IP address header format looks like on an IPV4:

IPv4 Header

To better understand IPv4 header fields, check out the table below:

Field Name

Field Size

Function/s

Version

4 bits

Describes the IP version used in the packet

Header length

4 bits

Shows the header's length because the size varies every time

TOS
(Type of Service)

8 bits

Explains the service necessary for the packet 


(some types are throughput, precedence, delay, and reliability)

Total Length

16 bits

Determines the packet's entire size

(65,535 is the max limit)

Identification

16 bits

Shows the identification number

(only when a device cannot send the data into one packet)

Flag

3 bits

Allows fragmentation on the packet 


(1st bit is 0; 2nd bit determines if it needs fragments; 3rd bit tells whether more fragments remain after the current one)

Offset

13 bits

Shows which part of the original packet a fragment belongs

TTL or Time to Live

8 bits

Tells the time or number of hops a packet can do before discarding

Protocol

8 bits

Specifies the protocol's upper layer and instructs the receiver on how to process the packet

Checksum

16 bits

Checks the header's validity at every hop

(If the verification fails, the packet gets discarded.)

Source address

32 bits

Shows the IP address of the source of the data or request

Destination address

32 bits

Indicates the IP address of the destination of the data or request

Options (Optional Field)

40 bits

Specifies options like the route the packets need to go through

IPv6 Header Field

An IPv6 header only has 8 fields. The address size in this header is four times bigger than IPv4, but the header itself is only two times bigger.

Here's what an IP address header format looks like on an IPV6:IPv6 Header

Check out how each field works using the table below:

Field Name

Field Size

Function/s

Version

4 bits 

Describes the IP version used in the packet

Traffic class

8 bits

Same as the TOS field in an IPv4 header 


(The first 6 bits tell the service for the packet while the last 2 bits are for ECN)

Flow label

20 bits

Labels the packets in the same group to ensure the data is in order 


(usually for real-time data like video or audio)

Payload length

16 bits

Tells the packet's size


(with the highest value being 65,535)

Next header

8 bits

Shows the first extension header type or determines the upper layer protocol 


(like UDP or TCP)

Hop limit

8 bits

Determines the number of hops a packet can do before discarding

Source address

128 bits

Shows the IP address of the source of the data or request

Destination address

128 bits

Indicates the IP address of the destination of the data or request

IPv4 and IPv6 Header

The headers for the two IP types differ in many ways. For a better comparison, here's a side-by-side comparison between IPv4 and IPv6 headers:

IPv4 Header

IPv4 Header 

IPv6 Header

IPv6 Header

Here's a breakdown of their differences in every comparable aspect:

Field Number

An IPv4 header includes 13 fields, while an IPv6 header only has 8. 

Some fields, like the identification field in IP headers, are only available in an IPv4 header.

Size

Despite having more fields, IPv4 headers are smaller—at around 20 to 60 bytes. It will only be more massive if you use the options field, which rarely happens.

Meanwhile, IPv6 headers are twice as big as IPV4 at around 40 bytes. Unlike the expandable IPv4 header, this one has a fixed size.

Address Size

The main difference between the two headers is the space for the IP address size.

An IPv4 header has a 32-bit field, covering 4.29* 10^9 addresses. On the contrary, an IPv6 header has a 128-bit field, which can cover 3.4 * 10^38 addresses.

Use of checksums or flags

The IPv4 header has a field for flags or checksums, while the IPv6 header has none. It means IPv6 does not use such fields.

Here’s a table to summarize the differences between the headers of the two versions of IP: 

Aspect

IPv4 Header

IPv6 Header

Field Number

13 fields

8 fields

Size

Smaller
(20-60 bytes)

Larger
(around 40 bytes)

Address Size

32-bit field
(covers 4.29*10^9 addresses)

128-bit field
(covers 3.4*10^38 addresses)

Use of Checksums or Flags

Includes field for flags or checksums

None

TCP Header vs. IP Header

Transmission Control Protocol (TCP) works with IP to show how data exchange happens on the web. 

With different tasks and purposes, the headers of TCP and IP differ from each other. 

To understand their difference, here's a comparison:

TCP Header 

TCP Header 

IP Header

IP Header

 

Here are the main differences between the TCP and IP headers:

Field Number

A TCP header includes only 10 fields (with one optional field), while an IP header has 13. 

However, when compared with an IPv6 header, a TCP has more fields since IP’s latest version only has 8.

Header Size

TCP and IPv4 headers have the same size of 20 to 60 bytes. 

Comparing a TCP header to an IPv6 header, TCP is smaller because IPv6 has 40 bytes.

Purpose

The IP sends each packet to its destination. Meanwhile, TCP ensures the transmission is correct, complete, and orderly. 

When combined, they work as TCP/IP.

Options Field

TCP has a higher capacity in its options field, up to 320 bits. 

Meanwhile, IPv4's options field can only have up to 32 bits. Moreover, IPv6 has no optional field.

Below is a table to sum up the distinctions between the two headers: 

Aspect

TCP Header

IP Header

Field Number

10 fields
(with 1 optional field )

13 fields

Header Size

20 to 60 bytes

20 to 60 bytes

Purpose

Secures the quality of transmission

Sends packets to destination

Options Field

Up to 320 bits

Up to 32 bits
(IPv4 only)

Conclusion

IP headers contain details ensuring efficient, correct, and orderly data exchange. 

With these, every piece of data you send and receive will be detailed and accurate. 

As a result, the servers can understand the data, its source, and the process it needs. These headers have different layouts depending on the versions. 

Nonetheless, every type of header shares the same purpose. It ensures the data exchange will be smooth, error-free, fast, and orderly.

FAQs.


What is the header for TCP?

The TCP header is the protocol’s initial 24 bits. This contains the data sets and conditions of a TCP socket. It checks the communication between two endpoints of the protocol.

How long is an IP header?

The length of an IP header can range from a minimum of 20 bytes to a maximum of 60 bytes, which comes with 32-bit increments.

What are flags in TCP?

Flags in TCP represent the state of connection. It is also used to supply more information for troubleshooting or take control of a specific connection. 

SHARE:

Facebook LinkedIn Twitter
Leave your comment

Your email address will not be published.