MS Docs

Internet Protocol (IP)

The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing specifies which computer network path packets take over the network. IP is the primary protocol in the Internet Layer or Network Layer of the TCP/IP suite. IP has not been assigned a unique protocol number by the Internet Assigned Numbers Authority (IANA), but it is universally recognized as protocol number 4 for IPv4 and protocol number 41 for IPv6.

Overview

IP is responsible for addressing hosts and routing packets of data from a source host to a destination host. It operates at the Network Layer (Layer 3) of the OSI model. There are two major versions of IP in use:

Internet Protocol version 4 (IPv4)

IPv4 is a connectionless protocol used for packet-switching networks. It assigns a unique 32-bit address to each device connected to the network. These addresses are typically represented in dotted-decimal notation.

IPv4 Address Example

An IPv4 address consists of four octets (8-bit numbers) separated by periods. For example:

192.168.1.1

IPv4 also defines subnet masks, which are used to divide an IP address into network and host portions. For example:

255.255.255.0

IPv4 Header Structure

The IPv4 header contains information necessary for routing and delivery, including:


        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |Version|  IHL  |   Type of Service   |          Total Length         |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |         Identification            |Flags|      Fragment Offset    |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |         Time to Live      |  Protocol |         Header Checksum         |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                       Source IP Address                       |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                    Destination IP Address                     |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                    Options                    |    Padding    |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        

Internet Protocol version 6 (IPv6)

IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion. It uses 128-bit addresses, providing a vastly larger address space.

IPv6 Address Example

IPv6 addresses are typically represented in eight groups of four hexadecimal digits, separated by colons. Leading zeros can be omitted, and consecutive groups of zeros can be compressed to a double colon (::) once per address. For example:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

This can be simplified to:

2001:db8:85a3::8a2e:370:7334

IPv6 Header Structure

The IPv6 header is simpler than the IPv4 header, with a fixed size of 40 bytes. Some fields have been removed or moved to optional extension headers.


        0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |Version| Traffic Class |             Flow Label                |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |         Payload Length        |  Next Header  |  Hop Limit  |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                                                               |
        |                                                               |
        |                    Source Address                             |
        |                                                               |
        |                                                               |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                                                               |
        |                                                               |
        |                    Destination Address                        |
        |                                                               |
        |                                                               |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        

IPv4 vs IPv6

Key differences and improvements in IPv6 include:

IP Routing

IP routing is the process of selecting paths in a network along which to send network traffic. Routers use routing tables to determine the best path for a packet to reach its destination. Protocols like RIP, OSPF, and BGP are used to exchange routing information between routers.

Understanding IP protocols is fundamental to comprehending how data travels across the internet and within private networks.