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
- 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.
- 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.
- Implementation of Connectionless Service (Datagrams):
- Each packet is routed independently.
- Packets may take different paths and arrive out of order.
- Robust against router failures.
- 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.0to10.255.255.255 - Class B:
172.16.0.0to172.31.255.255 - Class C:
192.168.0.0to192.168.255.255
- Class A:
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.
- Calculate Bits needed: (where is bits borrowed).
- bits.
- New Mask:
- Old Mask:
255.255.255.0(/24) - New Mask:
255.255.255.192(/26) (Binary last octet: 11000000 = 192).
- Old Mask:
- 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
- Network ID:
- Subnet 2:
- Network ID:
192.168.10.64 - Broadcast:
192.168.10.127
- Network ID:
Example 2: CIDR Calculation
Given: IP 172.16.2.150 with Subnet Mask 255.255.255.224 (/27).
Find: The Network Address.
- Convert to Binary:
- IP (last octet 150):
10010110 - Mask (last octet 224):
11100000
- IP (last octet 150):
- Perform Bitwise AND:
10010110(150)11100000(224)--------10000000(128)
- Result: Network Address is
172.16.2.128.
7. IPv4 Header Format
The IPv4 header is generally 20 bytes long (without options).
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
- Extract Destination IP: The router looks at the Destination Address in the IP header.
- Routing Table Lookup: The router consults its routing table. The table maps network prefixes to "Next Hop" routers or interfaces.
- 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.5matches both192.168.1.0/24and192.168.0.0/16. The router chooses/24.
- Example: Dest
- Decrement TTL: The TTL field is reduced by 1. Calculate new Checksum.
- ARP: If the destination is on the local link, the router uses ARP to find the MAC address.
- 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.
- 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.
- Throughput: The actual rate at which data is successfully transferred (often less than bandwidth due to overhead and congestion).
- Packet Loss: The percentage of packets lost due to congestion (buffer overflow) or errors.
- 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
- Example:
- Simplified Header: Fixed 40-byte header. No checksum (relies on Link/Transport layers), no fragmentation by routers (source must fragment).
Abbreviation Rules
- Leading Zeros: Can be omitted in a block (
0db8->db8). - 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
- Example:
IPv6 Address Types
- Unicast: One-to-One. (Global Unicast, Link-Local
fe80::). - Multicast: One-to-Many. (Replaces Broadcast). Start with
ff. - Anycast: One-to-Nearest. Assigned to multiple nodes; routed to the topologically closest one.