Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Network Layer Protocols and IP Addressing

Tech 1

Network Layer Service Models

Network layer provides connectionless, best-effort datagram service without reliability guarantees.

Virtual Circuit Service:

  • Guarantees reliable communication through connection establishment
  • Network ensures reliability
  • Connection setup required
  • Uses short virtual circuit identifiers after initial setup
  • All packets follow same route
  • Node failure affects all circuits through it
  • Packet ordering preserved
  • Error handling may be network or host responsibility

Datagram Service:

  • Best-effort delivery without reliability guarantees
  • Host ensures reliability
  • No connection setup
  • Each packet contains full destination address
  • Independent routing per packet
  • Node failure may cause packet loss and route changes
  • No packet ordering guarantees
  • Error handling by host

Internet Protocol Suite

Core IP companion protocols:

  • Address Resolution Protocol (ARP)
  • Internet Control Message Protocol (ICMP)
  • Internet Group Management Protocol (IGMP)

Virtual Internetworks

Logical interconnected networks appearing as unified network at network layer.

Intermediate connecting devices:

  • Physical layer: Repeaters
  • Data link layer: Bridges
  • Network layer: Routers
  • Above network layer: Gateways

Classful IP Addressing

IP address classification methods:

  • Class-based addressing (fundamental)
  • Subnetting (enhancement)
  • Supernetting/CIDR (modern classless approach)

Classful Address Structure: Fixed classes with network and host portions. Each IP address is globally unique.

Address classes:

  • A, B, C: Unicast addresses
  • D: Multicast addresses

Class A:

  • Maximum networks: 126 (2⁷-2)
  • First network: 1
  • Last network: 126
  • Maximum hosts per network: 16,777,214 (2²⁴-2)

Class B:

  • Maximum networks: 16,383 (2¹⁴-1)
  • First network: 128.1
  • Last network: 191.255
  • Maximum hosts per network: 65,534 (2¹⁶-2)

Class C:

  • Maximum networks: 2,097,151 (2²¹-1)
  • First network: 192.0.1
  • Last network: 223.255.255
  • Maximum hosts per network: 254 (2⁸-2)

IP Address Characteristics:

  • Hierarchical structure with network and host components
  • Identifies interface between host/router and link
  • Repeater/bridge-connected networks maintain single network ID
  • All networks with assigned network IDs are equal

IP vs Hardware Addressing

Hardware addresses operate at data link/physical layers, while IP addresses function at network layer and above as logical addresses.

Address Resolution Protocol

Maps IP addresses to hardware addresses. Source/destination IP remain constant while MAC addresses change per hop.

ARP Operation:

  1. Check ARP cache for target IP
  2. Broadcast ARP request if not found
  3. Target responds with ARP reply
  4. Cache mapping for future use

Entries have time-to-live. ARP resolves only local network mappings.

Common ARP Scenarios:

  • Host to local host
  • Host to remote network host
  • Router to local host
  • Router to remote network host

IP Datagram Format

Header Fields:

  1. Version (4 bits): IP protocol version
  2. Header Length (4 bits): Header size in 4-byte units
  3. Differentiated Services (8 bits): Quality of service indicators
  4. Total Length (16 bits): Entire datagram size
  5. Identification (16 bits): Fragmentation grouping
  6. Flags (3 bits): Fragmentation control (MF, DF)
  7. Fragment Offset (13 bits): Position in original datagram
  8. Time to Live (8 bits): Hop count limit
  9. Protocol (8 bits): Upper-layer protocol
  10. Header Checksum (16 bits): Header integrity check
  11. Source Address (32 bits)
  12. Destination Address (32 bits)

Variable options field (0-40 bytes). IPv6 uses fixed-length header.

Packet Forwarding Algorithm

def forward_packet(destination_ip, routing_table):
    network_address = extract_network(destination_ip)
    
    # Direct delivery check
    for local_net in directly_connected_networks:
        if network_address == local_net:
            return direct_delivery(destination_ip)
    
    # Specific host route
    if destination_ip in routing_table.host_routes:
        return routing_table.host_routes[destination_ip]
    
    # Network route
    if network_address in routing_table.network_routes:
        return routing_table.network_routes[network_address]
    
    # Default route
    if routing_table.default_route:
        return routing_table.default_route
    
    raise ForwardingError("No route available")

Subnetting and Supernetting

Subnet Addressing

Classful addressing limitations:

  • Poor address space utilizasion
  • Large routing tables
  • Inflexible allocation

Subnet Concept: Borrow host bits for subnet addressing.

Subnet Masks:

  • Identify network/subnet portion of IP address
  • Network/subnet bits set to 1, host bits to 0
  • IP AND Subnet Mask = Network Address

Subnet count: 2^k - 2 (where k = subnet bits), excluding all-zeros and all-ones.

Subnet Forwarding: Routing tables include destination network, subnet mask, and next hop.

Classless Inter-Domain Routing

Eliminates classful addressing concepts. Uses variable-length network prefixes.

CIDR Features:

  • Flexible network/host boundary
  • Address blocks with contiguous IP ranges
  • Route aggregation reduces routing table size

Longest Prefix Match: Most specific route (longest prefix) takes precedence.

Internet Control Message Protocol

Reports errors and exceptional conditions.

Message Types:

  • Error Reporting: Destination unreachable, time exceeded, parameter problem, redirect
  • Query: Echo request/reply, timestamp request/reply

ICMP Error Reporting Restrictions:

  • No errors about error messages
  • No errors for fragment subsequences
  • No errors for multicast packets
  • No errors for special addresses

Applications:

  • Ping: Connectivity testing using echo requests
  • Traceroute: Path discovery using TTL expiration

Routing Protocols

Autonomous Systems

Networks under single technical administration using:

  • Interior Gateway Protocols (within AS)
  • Exterior Gateway Protocols (between AS)

Routing Information Protocol

Distance-vector protocol with maximum 15 hops.

RIP Characteristics:

  • Exchange information with immediate neighbors only
  • Share entire routing table
  • Periodic updates
  • Slow convergence for network failures

Distance Vector Algorithm:

def update_routing_table(received_table, neighbor_address):
    updated_table = routing_table.copy()
    
    for route in received_table:
        # Adjust metric for hop to neighbor
        route.metric += 1
        route.next_hop = neighbor_address
        
        if route.destination not in updated_table:
            updated_table.add(route)
        elif route.next_hop == neighbor_address:
            updated_table.replace(route)
        elif route.metric < updated_table[route.destination].metric:
            updated_table.replace(route)
    
    return updated_table

Open Shortest Path First

Link-state protocol using flooding for updates.

OSPF Features:

  • Sends link-state information to all routers
  • Updates only on topology changes
  • Fast convergence
  • Hierarchical area structure
  • Supports variable-length subnet masks
  • Multiple equal-cost paths
  • Authentication capabilities

OSPF Packet Types:

  1. Hello
  2. Database description
  3. Link-state request
  4. Link-state update
  5. Link-state acknowledgment

IPv6 Protocol

IPv6 Header

Key Improvements:

  • 128-bit addresses
  • Fixed 40-byte header
  • Flow labeling for QoS
  • Extension headers for options

Header Fields:

  • Version (4 bits)
  • Traffic Class (8 bits)
  • Flow Label (20 bits)
  • Payload Length (16 bits)
  • Next Header (8 bits)
  • Hop Limit (8 bits)
  • Source Address (128 bits)
  • Destination Address (128 bits)

IPv6 Addressing

Address Notation:

  • Colon-hexadecimal format
  • Zero compression with :: (once per address)
  • IPv4 compatibility: ::192.168.1.1

Address Types:

  • Unicast
  • Multicast
  • Anycast

IPv4 to IPv6 Transition

Dual Stack: Hosts/routers run both protocols simultaneously.

Tunneling: Encapsulate IPv6 packets in IPv4 for traversal through IPv4 networks.

ICMPv6

Combines ARP and IGMP functionality into ICMPv6.

Message categories:

  • Error messages
  • Informational messages
  • Neighbor discovery
  • Multicast listener discovery

Virtual Private Networks

Emulate private networks over public infrastructure using encryption.

VPN Types:

  • Site-to-sitte: Connect multiple locations
  • Remote access: Mobile employee connectivity

Network Address Translation

Maps private addresses to public IP addresses.

NAT Operation:

  • Replaces source address with public IP for outgoing traffic
  • Replaces destination address with private IP for incoming traffic
  • Requires connection initiation from private network

NAPT (Network Address Port Translation): Multiple hosts share single public IP using port differentiation.

Multi-Protocol Label Switching

Uses labels for efficient packet forwarding across various network protocols.

Key Features:

  • Connection-oriented label switching
  • Protocol independence
  • Traffic engineering capabilities

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.