Jaideep M. More

software engineer


Internet Protocol IP

Internet addressing and forwarding are important components of the Internet Protocol (IP).

Internet Protocol IP

Internet addressing and forwarding are important components of the Internet Protocol (IP).

netwokr_layer_functions

The Internet’s network layer has three major components.

  1. IP Protocol
  2. Routing Component
  3. Facility to report errors in datagrams and respond to requests of certain network layer information.

Datagram Format:

ip4_datagram

  1. Version#\texttt{Version\#} - 4b\texttt{4b} specify the IP Protocol version

  2. Header Length\texttt{Header Length} - 4b\texttt{4b} Header length is variable due to Options\texttt{Options}

  3. Type of Service\texttt{Type of Service} - 4b\texttt{4b} allows different types of IP datagrams (requiring low delay, high throughput) to be distinguished from each other

  4. Datagram Length\texttt{Datagram Length} - 16b\texttt{16b} is the total length of the IP Datagram (header + data\texttt{header + data}). Imposes an upper bound to the datagram length (65535B\texttt{65535B}).

  5. Identifier, FLG, Fragmentation Offset\texttt{Identifier, FLG, Fragmentation Offset} - These fields are related to IP Fragmentation.

  6. TTL\texttt{TTL} - 8b\texttt{8b} used to ensure that datagrams do not circulate forever in the network. The field is decremented by each router. If TTL == 0\texttt{TTL == 0} then drop then datagram.

  7. Upper Layer Protocol\texttt{Upper Layer Protocol} - Value indicates the specific transport layer protocol the data should be passed

  8. Header Checksum\texttt{Header Checksum} - Helps in detecting error bits in a received IP datagram Router computes the header checksum for each received IP dataframe and detects an error condition.

    Drop the datagram for which error is detected

    Checksum must be recomputed and stored again at each router, as TTL\texttt{TTL} field and Options\texttt{Options} may change

  9. SRC and DEST Address\texttt{SRC and DEST Address}

  10. Options\texttt{Options} - Allows IP header to be extended

  11. DATA\texttt{DATA}

IP Fragmentation:

Not all Link Layer protocols can carry network layer packets of the same size.

The maximum amount of data that a link layer frame can carry is called the maximum transmission unit MTU\texttt{MTU} and places a hard limit on the length of an IP datagram.

Problem is that each of the links along the route between the source and destination can have different MTU\texttt{MTU}s

The solution is to fragment the data in the IP datagram, encapsulate each of these smaller IP datagrams in a separate link layer frame and send these frames over the outgoing link. Each of these smaller datagrams is referred to as fragment\texttt{fragment}.

Reassembling datagrams in the routers would introduce significant complication into the protocol and reduce router performance. IPv4\texttt{IPv4} designers thus decided to put the job of reassembling data on the end-systems.

To allow destination hosts to perform these reassembly tasks, the designers of IP put Identification, FLG\texttt{Identification, FLG} and Fragmentation Offset\texttt{Fragmentation Offset} fields in the IP datagram header.

When a IP datagram header is created it is stamped with a Identification#\texttt{Identification\#}. When a router needs to fragment a datagram, each resulting datagram has the same Identification#\texttt{Identification\#} of the original datagram.

This helps the destination host to recognise fragments of the bigger original datagram.

The FLG\texttt{FLG} is used to identify if there are any more fragments of the datagram. FLG = 1\texttt{FLG = 1} means that there are succeeding fragments. FLG = 0\texttt{FLG = 0} means that it is the last fragment of the datagram

The Fragmentation Offset\texttt{Fragmentation Offset} field is used for ordering the fragments

IPv4 Addressing:

An IP Address is a N-bit address

  1. The first k\texttt{k} bits represent the NetworkID\texttt{NetworkID}
  2. The remaining 32 - k\texttt{32 - k} bits represent the HostID\texttt{HostID} in the network
Casting:

Ways to send the message is casting

  1. Unicast\texttt{Unicast}: 1-to-1\texttt{1-to-1}

  2. Broadcast\texttt{Broadcast}: 1-to-*\texttt{1-to-*}

    1. Limited Broadcast\texttt{Limited Broadcast}:

      From 1\texttt{1} host to all other hosts of the its own network

      The NetworkID\texttt{NetworkID} and HostID\texttt{HostID} part is set to 1s\texttt{1}s (255.255.255.255\texttt{255.255.255.255})

    2. Directed Broadcast\texttt{Directed Broadcast}:

      From 1\texttt{1} host to all other hosts of some other network

  3. Multicast\texttt{Multicast}: Done using Class D Addresses

Subnetting:

The process of diving the network into subnetworks

For dividing the network, bits are borrowed from the HostID\texttt{HostID} part

If we want to divide the network into 2\texttt{2} subnets then 1b\texttt{1b} will be borrowed. If we want to divide the network into 4\texttt{4} subnets then 2b\texttt{2b} will be borrowed.

Ex: Consider a Class C\texttt{Class C} Address NetworkId = 24b; HostID = 8b\texttt{NetworkId = 24b; HostID = 8b} For dividing the network into 4\texttt{4} subnets NetworkID = 24b; SubnetID = 2b; HostId = 6b\texttt{NetworkID = 24b; SubnetID = 2b; HostId = 6b}

Subnet Mask: 32b\texttt{32b} Mask is used to generate the NetworkID + SubnetID\texttt{NetworkID + SubnetID} from an IP Address. For the above example the Subnet Mask\texttt{Subnet Mask} will be

(11111111.11111111.11111111.11000000) ==> (255.255.255.192)\texttt{(11111111.11111111.11111111.11000000) ==> (255.255.255.192)}

To get the NetworkID + SubnetID\texttt{NetworkID + SubnetID} from the IP Address\texttt{IP Address} we do NetworkID + SubnetId = IP Address AND SubnetMask \texttt{NetworkID + SubnetId = IP Address AND SubnetMask }

Subnets can be formed inside a subnet leading to Variable Subnetting

In this case the SubnetMask\texttt{SubnetMask} will have more bits

CIDR - Classless Inter Domain Routing:

Improved IP Addressing System. makes IP Allocation more effecient.

a.b.c.d/n \texttt{a.b.c.d/n}

a.b.c.d\texttt{a.b.c.d} is regular dotted decimal representation; /n\texttt{/n} is network prefix and represents the #bits\texttt{\#bits} in NetworkID\texttt{NetworkID}.

Ex: for the IP Address 20.10.50.0/20\texttt{20.10.50.0/20}, the first 20b\texttt{20b} are for NetworkID\texttt{NetworkID} and remaining 32 - 20 = 12b\texttt{32 - 20 = 12b} are for HostID\texttt{HostID}.

Rules For a CIDR\texttt{CIDR} Block:

  1. All IP Address′s\texttt{IP Address}'s should be contigous
  2. Block Size should be a integral power of 2
  3. First IP Address\texttt{IP Address} should be divisible by the size of the block. So for a block size 2k\texttt{2}^\texttt{k} the first IP address should have least significant k\texttt{k} bits 0.
Supernetting:

Supernetting is the process of combining smaller networks into a single super network

Rules for Aggregation:

  1. Networks to be combined should be contiguous
  2. Block Size of each Network should be of the same size
  3. First NetworkID\texttt{NetworkID} should be divisible by the total size of the super net

DHCP - Dynamic Host Configuration Protocol

DHCP\texttt{DHCP} allows a host to obtain an IP address automatically. It can be configured such that a host receives the same IP address each time it connects to the network, or a host may be assigned a temporary IP address that will be different each time the host connects to the network.

DHCP\texttt{DHCP} also allows a host to learn additional information, such as the subnet mask, the address of the first-hop-router aka default gateway, and the address of its local DNS\texttt{DNS} server.

It is a client-server protocol. A client is typically a new arriving host waiting to obtain network configuration information.

The DHCP\texttt{DHCP} protocol is a four step process:

  1. DHCP\texttt{DHCP} server discovery: The first task is to find a DHCP\texttt{DHCP} server. Done using DHCP discover message\texttt{DHCP discover message}, broadcasted (255.255.255.255\texttt{255.255.255.255}) by the client.

  2. DHCP\texttt{DHCP} server offer(s): A DHCP\texttt{DHCP} server receiving a DHCP\texttt{DHCP} discover message responds to the client with a DHCP offer message\texttt{DHCP offer message}, which is also broadcasted on the subnet. Each server offer message contains:

    1. transactionID\texttt{transactionID} of the received discover message
    2. IP Address\texttt{IP Address}
    3. Network Mask\texttt{Network Mask}
    4. IP Address Lease Time\texttt{IP Address Lease Time} - Amount of time for which the address is valid.
  3. DHCP\texttt{DHCP} Request: The client will choose form among one or more server offers and respond to its selected offer with a DHCP request message\texttt{DHCP request message}, echoing back the configuration parameters

  4. DHCP ACK\texttt{DHCP ACK}: The server responds to the DHCP request message\texttt{DHCP request message} with a DHCP ACK\texttt{DHCP ACK}, confirming the requested parameters.

NAT - Network Address Translation:

Private Addressing:

If we want to design a network for an institution such that messages can flow within the network but not outside, in such cases we use Private Addressing

Private IP Address Range:

  1. 10.0.0.0\texttt{10.0.0.0} to 10.255.255.255\texttt{10.255.255.255}
  2. 172.16.0.0\texttt{172.16.0.0} to 172.31.255.255\texttt{172.31.255.255}
  3. 192.168.0.0\texttt{192.168.0.0} to 192.168.255.255\texttt{192.168.255.255}

Private addresses only have meaning within a given network, how is addressing handled when packets are sent to or received from the global internet? The answer lies in NAT\texttt{NAT}.

NAT\texttt{NAT} router behaves to the outside world as a single device with a single IP Address\texttt{IP Address}. In essence, the NAT\texttt{NAT} router is hiding the details of the network from the outside world.

NAT_translation

NAT\texttt{NAT} router maintains a NAT Translation Table\texttt{NAT Translation Table}.

Suppose a host (10.0.0.1\texttt{10.0.0.1}) makes a requests a WebPage on WebServer (Port# = 80\texttt{Port\# = 80}) with IP Address 128.119.40.186\texttt{128.119.40.186}

The host chooses a random port, suppose Port# = 3345\texttt{Port\# = 3345}, and sends the datagram into the LAN.

The NAT\texttt{NAT} router receives the datagram, generates a new Port#\texttt{Port\#} say 5001\texttt{5001}, replaces the Port#\texttt{Port\#} and the source IP address with its WAN-side IP address (138.76.29.7)\texttt{(138.76.29.7)}.

NAT\texttt{NAT} also adds an entry in its translation table. Response on (138.76.29.7:5001), Forward to (10.0.0.1:3345)\texttt{Response on (138.76.29.7:5001), Forward to (10.0.0.1:3345)}

When the response datagram arrives, NAT\texttt{NAT} router uses the Destination IP Address\texttt{Destination IP Address} and Port#\texttt{Port\#} to index the translation table to obtain the appropriate IP Address\texttt{IP Address} and destination Port#\texttt{Port\#}.

ICMP - Internet Control Message Protocol:

ICMP\texttt{ICMP} is used by hosts and routers to communicate network-layer information to each other. The most typical use of ICMP\texttt{ICMP} is for error reporting.

ICMP\texttt{ICMP} is often considered part of the IP\texttt{IP} but architecturally lies above IP\texttt{IP}, as ICMP\texttt{ICMP} messages are carried inside IP\texttt{IP} datagrams

ICMP\texttt{ICMP} messages have a type\texttt{type} and a code\texttt{code} field, and contain the header\texttt{header} and the first 8B\texttt{8B} of the IP\texttt{IP} datagram for which the ICMP\texttt{ICMP} message is being sent.

PING Program:

  1. source host sends an ECHO Request ICMP: Type=8; Code=0\texttt{ICMP: Type=8; Code=0} message to the destination host
  2. destination host responds with ECHO REPLY ICMP: Type=0; Code=0\texttt{ICMP: Type=0; Code=0} message to the source host.

traceroute Program:

traceroute

Used to determine the name and the addresses of the routers between source and destination hosts

Implemented using ICMP\texttt{ICMP} messages.

  1. Source sends series of ordinary IP\texttt{IP} datagrams to destination with increasing order of the TTL\texttt{TTL} field.
TTL = 0, 1, 2,...\texttt{TTL = 0, 1, 2,...}
  1. When the nthn^{\text{th}} datagram arrives at the nthn^{\text{th}} router, TTL=0\texttt{TTL=0}, thus the datagram has to be discarded and a ICMP\texttt{ICMP} message is send back to the source with network information.

Thus information is incrementally collected about each router

IPv6

A prime motivation for this effort was the realisation that the 32b\texttt{32b} IP address space was beginning to be used up. The designers of IPv6\texttt{IPv6} took this oppotunity to tweak and augment other aspects of the IPv4\texttt{IPv4}.

The most important changes introduced in IPv6\texttt{IPv6} are evident in the datagram format:

  1. Expanded Addressing Capabilities:

    IP\texttt{IP} address size is 128b\texttt{128b}. This ensures that the world won’t run out of IP\texttt{IP} addresses.

    In addition to the unicast and multicast addresses, IPv6\texttt{IPv6} has introduced anycast address, which allows a datagram to be delivered to any one of a group of hosts.

  2. Streamlined 40B\texttt{40B} header:

    The 40B\texttt{40B} fixed length header allows for faster processing of the IP\texttt{IP} datagram.

  3. Flow labeling and priority:

    IPv6\texttt{IPv6} has an elusive definition of a flow and states that this allows labelling of packets for which sender request special handling requirements.

    It is possible that the traffic carried by a high-priority user (premium subscriber) might also be treated as a flow.

IPv6\texttt{IPv6} Datagram Format:

ip6_datagram

  1. Version\texttt{Version}: 4b\texttt{4b} field identifies the IP\texttt{IP} version.
  2. Traffic Class\texttt{Traffic Class}: 8b\texttt{8b} field is similar in spirit to the TOS\texttt{TOS}
  3. Flow Label\texttt{Flow Label}: 20b\texttt{20b} field is used to identify the flow of the datagram
  4. Payload Length\texttt{Payload Length}: 16b\texttt{16b} value is treated as unsigned integer giving the number of bytes in the IPv6\texttt{IPv6} datagram following the fixed 40B\texttt{40B} header.
  5. Next Header\texttt{Next Header}: field is similar in spirit to the Protocol\texttt{Protocol} field
  6. Hop Limit\texttt{Hop Limit}: Similar to TTL\texttt{TTL} field
  7. SRC and DEST Address\texttt{SRC and DEST Address}: various formats of IPv6\texttt{IPv6} address
  8. Data\texttt{Data}

Fragmentation and Reassembly:

IPv6\texttt{IPv6} does not allow for fragmentation and reassembly. If an IPv6\texttt{IPv6} datagram received by a router is too large to be forwarded, the router simply drops the datagram and sends a ICMP\texttt{ICMP} error message.

Header Checksum:

Because transport layer and link layer protocols in the internet layers perform checksumming, the designers of IP\texttt{IP} felt this was redundant.

Transitioning from IPv4 to IPv6:

IPv6\texttt{IPv6} systems can be made backward compatible, so they can send, route and receive IPv4\texttt{IPv4} datagrams however, already deployed IPv4\texttt{IPv4} systems are not capable of handling IPv6\texttt{IPv6} datagrams.

Probably the most straightforward way to introduce IPv6\texttt{IPv6} capable nodes is a dual-stack approach where, IPv6\texttt{IPv6} nodes also have a complete IPv4\texttt{IPv4} implementation. Such a node can operate on both IPv4 and IPv6\texttt{IPv4 and IPv6} datagrams.

ip_tunnelling

While using dual-stack approach, it is possible that two IPv6\texttt{IPv6}-capable nodes would have to communicate using IPv4\texttt{IPv4}. This happens when the two nodes are intervened by IPv4\texttt{IPv4} nodes.

An alternative to the dual-stack approach is called tunnelling. We refer to the intervening set of IPv4\texttt{IPv4} nodes between two IPv6\texttt{IPv6} routers as a tunnel.

Tunnelling works as follows:

  1. The IPv6\texttt{IPv6} sending node takes the entire IPv6\texttt{IPv6} and puts it in the data field of the IPv4\texttt{IPv4} datagram.
  2. The IPv6\texttt{IPv6} node on the receiving side of the tunnel extracts the IPv6\texttt{IPv6} datagram and then routes it if it had received the IPv6\texttt{IPv6} datagram from a directly connected IPv6\texttt{IPv6} neighbour.