Unit 4 - Notes

CSE306

Unit 4: NETWORK LAYER: IP Addressing

1. Network Layer Design Issues

The Network Layer is responsible for the delivery of individual packets from the source host to the destination host, potentially crossing multiple networks (links).

Key Design Issues

  1. Store-and-Forward Packet Switching:
    • The network layer operates in an environment where a host transmits a packet to the nearest router.
    • The packet is stored there until it has fully arrived and the link implies it is free (verification of checksum may occur).
    • It is then forwarded to the next router in the path.
  2. Services Provided to the Transport Layer:
    • The services should be independent of the router technology.
    • The transport layer should be shielded from the number, type, and topology of the subnets present.
    • Network addresses should be uniform across LANs and WANs.
  3. Implementation of Connectionless Service (Datagrams):
    • Each packet is routed independently.
    • Packets may take different paths and arrive out of order.
    • Robust against router failures.
  4. Implementation of Connection-Oriented Service (Virtual Circuits):
    • A path is established before data packets are sent (setup phase).
    • All packets follow the same path.
    • Requires tear-down phase.

2. Network Layer Services

The Network Layer provides two primary types of services to the Transport Layer:

A. Connectionless Service (Datagram Approach)

  • Mechanism: Each packet (datagram) is treated as an independent entity.
  • Routing: Every packet contains the full destination address; routers decide the next hop for every packet individually based on current network conditions.
  • Reliability: Not guaranteed. Packets may get lost, duplicated, or arrive out of order.
  • Example: IP (Internet Protocol).

B. Connection-Oriented Service (Virtual Circuit Approach)

  • Mechanism: A logical connection (Virtual Circuit) is established between source and destination before data transfer.
  • Routing: Route is determined once during setup. All packets follow this path. Each packet carries a Virtual Circuit Identifier (VCI) rather than a full destination address.
  • Reliability: Typically higher; guarantees order of delivery.
  • Example: MPLS (Multiprotocol Label Switching), ATM.

3. IP Addressing: Classful

IP addresses (IPv4) are 32-bit unique identifiers assigned to network interfaces. In Classful Addressing, the IP address space is divided into five classes based on the leading bits.

Format: Dotted Decimal Notation (e.g., 192.168.1.1)

Address Classes

Class Leading Bits Network ID Host ID Range (First Octet) Use Case
A 0 8 bits 24 bits 0 – 127 Very Large Networks
B 10 16 bits 16 bits 128 – 191 Medium-sized Networks
C 110 24 bits 8 bits 192 – 223 Small Local Networks
D 1110 N/A N/A 224 – 239 Multicast Groups
E 1111 N/A N/A 240 – 255 Reserved/Experimental

Special Addresses

  • Network Address: Host bits are all 0s (e.g., 192.168.1.0).
  • Direct Broadcast Address: Host bits are all 1s (e.g., 192.168.1.255).
  • Loopback: 127.0.0.0/8 (Used for testing the TCP/IP stack on the local machine).
  • Private IPs (Non-routable on Internet):
    • Class A: 10.0.0.0 to 10.255.255.255
    • Class B: 172.16.0.0 to 172.31.255.255
    • Class C: 192.168.0.0 to 192.168.255.255

4. IP Addressing: Classless (CIDR)

Classless Inter-Domain Routing (CIDR) was introduced to solve the exhaustion of IP addresses and the growth of routing tables.

  • Concept: It eliminates the rigid boundary between Class A, B, and C.
  • Slash Notation: Uses Preix Length (/n) to indicate the number of bits used for the Network ID.
  • Example: 172.16.1.10/20
    • First 20 bits identify the network.
    • Remaining 12 bits (32 - 20) identify the host.
  • Block Allocation: ISPs assign blocks of addresses based on need, not class constraints.

5. Subnetting and Supernetting

Subnetting (Network Division)

The process of dividing a single large network into smaller logical subnetworks (subnets).

  • Mechanism: "Borrow" bits from the Host ID portion of the address and use them for the Subnet ID.
  • Benefits: Reduced broadcast traffic, improved security, organized network management.
  • Subnet Mask: A 32-bit number that masks the IP address and divides the IP into network address and host address.

Supernetting (Route Aggregation)

The inverse of subnetting. Combines multiple small contiguous networks into a single larger network.

  • Mechanism: "Borrow" bits from the Network ID to combine networks.
  • Goal: Reduces the size of routing tables in routers (Route Summarization).
  • Requirement: The networks must be contiguous and the number of networks combined must be a power of 2.

6. Subnetting Examples

Example 1: Class C Subnetting

Given: Network 192.168.10.0 (Class C default is /24).
Requirement: Create 4 subnets.

  1. Calculate Bits needed: (where is bits borrowed).
    • bits.
  2. New Mask:
    • Old Mask: 255.255.255.0 (/24)
    • New Mask: 255.255.255.192 (/26) (Binary last octet: 11000000 = 192).
  3. Block Size (Increment): .

Subnet Ranges:

  • Subnet 1:
    • Network ID: 192.168.10.0
    • First Host: 192.168.10.1
    • Last Host: 192.168.10.62
    • Broadcast: 192.168.10.63
  • Subnet 2:
    • Network ID: 192.168.10.64
    • Broadcast: 192.168.10.127

Example 2: CIDR Calculation

Given: IP 172.16.2.150 with Subnet Mask 255.255.255.224 (/27).
Find: The Network Address.

  1. Convert to Binary:
    • IP (last octet 150): 10010110
    • Mask (last octet 224): 11100000
  2. Perform Bitwise AND:
    • 10010110 (150)
    • 11100000 (224)
    • --------
    • 10000000 (128)
  3. Result: Network Address is 172.16.2.128.

7. IPv4 Header Format

The IPv4 header is generally 20 bytes long (without options).

TEXT
 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 Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Field Descriptions

  • Version (4 bits): Identifies IP version (e.g., 4).
  • IHL (Internet Header Length, 4 bits): Length of header in 32-bit words (Min value 5 = 20 bytes).
  • Type of Service (8 bits): Quality of Service parameters (Priority, delay, throughput). Now called Differentiated Services (DiffServ).
  • Total Length (16 bits): Total size of packet (Header + Data). Max 65,535 bytes.
  • Identification (16 bits): Unique ID to reassemble fragmented packets.
  • Flags (3 bits):
    • Bit 0: Reserved.
    • Bit 1: DF (Don't Fragment).
    • Bit 2: MF (More Fragments).
  • Fragment Offset (13 bits): Indicates where this fragment belongs in the original datagram.
  • Time to Live (TTL) (8 bits): Counter to prevent loops. Decremented by 1 at each router. If 0, packet is discarded.
  • Protocol (8 bits): Defines payload protocol (e.g., 6=TCP, 17=UDP, 1=ICMP).
  • Header Checksum (16 bits): Error checking for the header only.
  • Source/Destination IP (32 bits each): Address of sender and receiver.

8. Forwarding of IP Packets

Forwarding is the process where a router receives a packet on an input interface and moves it to the appropriate output interface.

The Mechanism

  1. Extract Destination IP: The router looks at the Destination Address in the IP header.
  2. Routing Table Lookup: The router consults its routing table. The table maps network prefixes to "Next Hop" routers or interfaces.
  3. Longest Prefix Match: If an IP address matches multiple entries in the routing table, the router uses the entry with the longest subnet mask (most specific match).
    • Example: Dest 192.168.1.5 matches both 192.168.1.0/24 and 192.168.0.0/16. The router chooses /24.
  4. Decrement TTL: The TTL field is reduced by 1. Calculate new Checksum.
  5. ARP: If the destination is on the local link, the router uses ARP to find the MAC address.
  6. Encapsulation: The packet is framed (Data Link Layer) and transmitted.

Delivery Types

  • Direct Delivery: The destination is on the same physical network as the deliverer.
  • Indirect Delivery: The destination is on a different network; the packet is passed to a default gateway or next-hop router.

9. Network Layer Performance

The performance of the network layer is measured using quantitative metrics.

  1. Delay (Latency): The time it takes for a packet to travel from source to destination.
    • Transmission Delay: Time to push bits onto the link ().
    • Propagation Delay: Time for signal to travel through the medium ().
    • Processing Delay: Time for router to inspect header and determine path.
    • Queueing Delay: Time spent waiting in the buffer.
  2. Throughput: The actual rate at which data is successfully transferred (often less than bandwidth due to overhead and congestion).
  3. Packet Loss: The percentage of packets lost due to congestion (buffer overflow) or errors.
  4. Jitter: The variation in packet arrival time. High jitter causes poor audio/video quality.

10. IPv6 Addressing

Developed to replace IPv4 due to address exhaustion.

Key Features

  • 128-bit Address Space: Theoretically addresses.
  • Hexadecimal Notation: 8 groups of 16 bits, separated by colons.
    • Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Simplified Header: Fixed 40-byte header. No checksum (relies on Link/Transport layers), no fragmentation by routers (source must fragment).

Abbreviation Rules

  1. Leading Zeros: Can be omitted in a block (0db8 -> db8).
  2. Zero Compression: Contiguous blocks of zeros can be replaced by :: (Double Colon). This can happen only once per address.
    • Example: 2001:db8:0:0:0:0:1:1 -> 2001:db8::1:1

IPv6 Address Types

  1. Unicast: One-to-One. (Global Unicast, Link-Local fe80::).
  2. Multicast: One-to-Many. (Replaces Broadcast). Start with ff.
  3. Anycast: One-to-Nearest. Assigned to multiple nodes; routed to the topologically closest one.