Internet Protocol (IP)

Definition

  • Internet Protocol (IP), the network layer protocol, serves as the glue that holds together the whole Internet.

  • It provides logical addressing and best-effort delivery of packets from their source to their destination.

  • It may be described as:

    • Connectionless: does not establish a connection with the destination device before sending the packet. No control information needed (synchronizations, acknowledgements,. . . )

    • Best effort: does not guarantee reliable delivery (No guarantee of delivery, order, delay, duplication)

    • Media independent: does not depend on the physical transmission medium type. There are two IP versions in use today: IPv4 and IPv6

  • IP transmits data in small units known as packets or datagrams, which consist of two parts: a header field and a data field.

IPv4 Packet Header

  • IPv4 is the primary and most widely used communication protocol for the network layer

  • The IPv4 packet header:

    • Ensures proper packet delivery to the destination

    • Contains vital information for network layer processing in various fields Its information is used by all layer 3 devices that handle the packets

  • The header consists of a fixed 20-byte part and an optional variable-length part

  • Version: these 4 bits specify the IP protocol version of the created packet, either IPv4 the current version or IPv6 the new version.

  • Header length: utilizes 4 bits to indicate the position of the payload (Data) due to the potential variable number of options included in the header.

  • Type of service: this field allows a machine to specify the type of routing required in the form of: delay, bandwidth and reliability

  • Datagram length: refers to the total size of the IP datagram, including both header and data, measured in bytes. The field is 16 bits long, allowing a theoretical maximum size of 65,535 bytes.

  • Identifier, flags, fragmentation offset: represents IP fragmentation, which involves breaking large IP datagrams into smaller ones for independent forwarding. It includes three key fields: the 16-bit Identifier, which indicates the packet a fragment belongs to (with all fragments sharing the same value); the 3-bit Flags, which include DF (Don’t Fragment) to prevent fragmentation and MF (More Fragments) to indicate that there are additional fragments; and the Fragment offset, which specifies the fragment’s position in the original packet.

  • Time-to-live (TTL): is a field in packets that prevents them from circulating indefinitely in a network. Its value decreases by one with each router processing; if it reaches zero, the router must discard the packet.

  • Protocol: specifies the transport protocol, such as TCP or UDP, for the network layer to assign to the packet.

  • Header checksum: serves to identify errors within the header alone. It is important to recalculate the checksum with each jump, as at least one field will have changed, specifically the lifetime, which is decremented by one.

  • Source and destination IP address: indicate the IP address of the source and destination network interfaces.

  • Options: allow an IP header to be extended include services not defined in the original version

IP Address

  • To uniquely identify devices on the network, IP addresses are needed.

  • Every host and router on the Internet network has a unique IP address; two devices in the same network cannot have the same IP address.

  • An IP address is encoded in 32 bits and consists of two variable-length parts, the network part (Network_id) and the host (device) part (Host_id).

Warning

A host typically has one network interface, whereas a router has multiple interfaces, each connected to a different network. Each interface, whether on a host or a router, is assigned its own IP address, meaning that an IP address is specifically associated with the interface, not the host or router itself.

Devices connected to multiple networks possess distinct IP addresses for each network, meaning each device has a separate IP address for every network card.

Simple Network Example with IP Addressing
  • A network is a range of addresses.

  • All devices within a network share the same Network_id while possessing distinct Host_id.

Definition

  • The IP address is 32-bit divided in 4 blocks of 8 bits (4 bytes), usually represented in binary form.

\[ \underbrace{\underbrace{11000000}_{1^{\text{st}} \text{ byte}}\;.\;\underbrace{10101000}_{2^{\text{nd}} \text{ byte}}\;.\;\underbrace{01100100}_{3^{\text{rd}}\text{ byte}}\;.\;\underbrace{00000001}_{4^{\text{th}}\text{ byte}}}_{32 \text{ bits}} \]
  • IP addresses are displayed in dotted decimal notation, where each of the four bytes is represented in decimal form (0 to 255), separated by dots.

\[ \underbrace{11000000}_{192}\;.\;\underbrace{10101000}_{168}\;.\;\underbrace{01100100}_{100}\;.\;\underbrace{00000001}_{1} \]
  • Network_id: tell us to which “network” the IP address will belong

  • Host_id: uniquely identifies the network device

\[ \underbrace{\underbrace{11000000}_{192}\;.\;\underbrace{10101000}_{168}\;.\;\underbrace{01100100}_{100}}_{\text{Network\_id}}\;.\;\underbrace{\underbrace{00000001}_{1}}_{\text{Host\_id}} \]
  • IP addresses span from 0.0.0.0 to 255.255.255.255, with certain addresses reserved for special purposes and unavailable for general assignment.

What is the rationale behind the first 3 bytes denoting the Network_id and the final byte indicating the Host_id?

DefinitionThe Mask

  • Also called the Subnet Mask

  • Which bits belong to the network and which bits belong to the host

  • All the bits of the Network_id are set to 1.

  • All the bits of the Host_id are set to 0.

  • Expressed in dotted-decimal and prefix

\[ \text{The Host IP address:} \underbrace{192\;.\;168\;.\;100}_{\text{Network\_id}}\;.\;\underbrace{1}_{\text{Host\_id}} \]
\[ \text{The Mask (dotted-decimal): } \underbrace{\underbrace{11111111}_{255}\;.\;\underbrace{11111111}_{255}\;.\;\underbrace{11111111}_{255}}_{\text{Network\_id}}\;.\;\underbrace{\underbrace{00000000}_{0}}_{\text{Host\_id}} \]
\[ \text{The Mask (prefix): } /24 \]

IP Address Classes

  • To better understand how IP addresses are organized, they are classified into different categories known as IPv4 address classes.

  • Each class of IPv4 address comes with a predefined subnet mask known as the default mask.

    • Class A: 255.0.0.0

    • Class B: 255.255.0.0

    • Class C: 255.255.255.0

Warning

In classful IPv4 addressing, networks were categorized into fixed classes (A, B, and C) with specific sizes, which resulted in inefficient IP address usage as organizations received either an excess of unused addresses or insufficient addresses for their requirements.

Method

To address these limitations, a more flexible approach called subnetting was introduced, which allows the division of networks intosmaller, more manageables parts

IP Address Subnetting

DefinitionWhat Is Subnetting?

  • Subnetting is the process of dividing one IP block into multiple smaller logical networks without requesting new addresses from the ISP.

  • An IP address with subnetting concept is formed:

    • Network_id: the network identifier; the number of bits varies according to the IP class.

    • Subnet_id: the Subnet identifier with n bits size

    • Host_id: is the Host identifier; the number of HostID bits = 32 – (number of NetID bits + n)

Note

  • The creation of subnets reduces the size of routing tables. For example, a router on subnet N doesn’t need to know the addresses of devices on other subnets.

  • All it needs to do is perform a logical AND between the received packet address and the subnet mask in order to choose an output port.

Warning

Classful IPv4 utilized fixed default masks (A, B, C), leading to inefficient address allocation as large blocks were assigned unnecessarily. This caused rapid address depletion and poor utilization, exacerbated by the increasing size of routing tables due to the growing Internet.

Method

To mitigate address depletion and enhance Internet access for organizations, a classless addressing system termed CIDR (Classless Inter-Domain Routing) was implemented.

Classless Inter-Domain Routing CIDR

DefinitionClassless Inter-Domain Routing

  • An IP addressing system

  • Addresses are allocated in blocks of variable size.

  • It uses a slash (/) followed by a number to highlight the network part of an address, instead of using a subnet mask

\[ \texttt{a.b.c.d / n} \]
  • n = number of network prefix bits

  • 32 - p = number of host bits

\[ \texttt{EX: 128.7.192.0 / 19}\]
  • Binary representation:

\[ \underbrace{10000000.00000111.110}_{\text{Network\_id }(19\ bits)} \underbrace{00000.00000000}_{\text{Host\_id }(13\ bits)} \]