Computer Networks Course

Internet Control Message Protocol (ICMP)

Comprehensive Study Guide for Undergraduate Students

🎯

Learning Objectives

Upon completion of this study module, students will be able to:

1

Understand ICMP Fundamentals

Explain the purpose, importance, and role of ICMP in the TCP/IP protocol suite

2

Analyze Packet Structure

Describe the ICMP message format, header fields, and data encapsulation

3

Identify Message Types

Differentiate between ICMP error messages and query messages

4

Implement Diagnostic Tools

Use ping and traceroute utilities for network troubleshooting

5

Troubleshoot Networks

Interpret ICMP messages to diagnose common network issues

6

Understand Security

Recognize ICMP-based attacks and security implications

📚

Theoretical Framework

1. Introduction to ICMP

The Internet Control Message Protocol (ICMP) is a network layer protocol used by network devices to send error messages and operational information indicating success or failure when communicating with another IP address. Defined in RFC 792, ICMP is an integral part of the Internet Protocol Suite.

Key Point: ICMP is not a transport layer protocol like TCP or UDP. It is a supporting protocol for IP that provides feedback about problems in the network environment. ICMP messages are encapsulated directly within IP datagrams.

2. ICMP Characteristics

3. ICMP Message Format

All ICMP messages share a common header structure followed by variable-length data:

ICMP Header Structure (8 bytes minimum)

Type
8 bits
Code
8 bits
Checksum
16 bits
Rest of Header
32 bits
Data Section
Variable

Type: Identifies the ICMP message type (e.g., 0=Echo Reply, 8=Echo Request)
Code: Provides additional context for the Type (e.g., Code 0=Network unreachable)
Checksum: Error detection for the ICMP message
Rest of Header: Content varies by message type
Data: Usually contains the IP header + first 8 bytes of original datagram

4. ICMP Message Categories

Type Name Description Common Codes
3 Destination Unreachable Generated by router when packet cannot be delivered 0=Net, 1=Host, 2=Protocol, 3=Port, 4=Fragmentation needed
5 Redirect Router informs host of better route 0=Network, 1=Host, 2=Service/Network, 3=Service/Host
11 Time Exceeded TTL reached zero or fragment reassembly timeout 0=TTL exceeded in transit, 1=Fragment reassembly timeout
12 Parameter Problem Error in IP header parameters 0=Pointer indicates error, 1=Missing option, 2=Bad length
Type Name Description Usage
0 Echo Reply Response to Echo Request ping command response
8 Echo Request Request for echo reply ping command request
13 Timestamp Request Request for timestamp information Network synchronization
14 Timestamp Reply Response to timestamp request Network delay measurement
17 Address Mask Request Request for subnet mask Configuration (rarely used)
18 Address Mask Reply Response to mask request Configuration (rarely used)
Type Name Description
30 Traceroute Experimental route tracing (deprecated in favor of UDP/ICMP methods)
37 Domain Name Request Request for domain name (experimental)
38 Domain Name Reply Response to domain name request (experimental)

5. Common ICMP Utilities

5.1 Ping (Packet Internet Groper)

The ping command uses ICMP Echo Request (Type 8) and Echo Reply (Type 0) messages to test reachability:

Ping Command Example
$ ping -c 4 google.com PING google.com (142.250.80.46) 56(84) bytes of data. 64 bytes from nrt13s55-in-f14.1e100.net (142.250.80.46): icmp_seq=1 ttl=117 time=23.4 ms 64 bytes from nrt13s55-in-f14.1e100.net (142.250.80.46): icmp_seq=2 ttl=117 time=24.1 ms 64 bytes from nrt13s55-in-f14.1e100.net (142.250.80.46): icmp_seq=3 ttl=117 time=23.8 ms 64 bytes from nrt13s55-in-f14.1e100.net (142.250.80.46): icmp_seq=4 ttl=117 time=24.0 ms --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 23.412/23.825/24.123/0.312 ms
Interpretation:
  • icmp_seq: Sequence number for matching requests/replies
  • ttl (Time To Live): Remaining hop count (117 indicates ~11 hops traversed)
  • time: Round-trip time in milliseconds
  • 0% packet loss: All packets successfully returned

5.2 Traceroute

traceroute (Linux) or tracert (Windows) uses ICMP Time Exceeded messages (Type 11) or Port Unreachable to trace routes:

Traceroute Mechanism
# How traceroute works: 1. Send packet with TTL=1 → First router returns ICMP Time Exceeded 2. Send packet with TTL=2 → Second router returns ICMP Time Exceeded 3. Continue until destination reached or max hops exceeded 4. Destination returns ICMP Port Unreachable (UDP) or Echo Reply (ICMP) $ traceroute google.com traceroute to google.com (142.250.80.46), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.234 ms 1.123 ms 1.089 ms 2 10.0.0.1 (10.0.0.1) 5.432 ms 5.321 ms 5.298 ms 3 core-router.isp.net (203.0.113.1) 10.123 ms 9.987 ms 10.045 ms ... 12 nrt13s55-in-f14.1e100.net (142.250.80.46) 23.412 ms 23.825 ms 24.123 ms

6. ICMP in IPv6 (ICMPv6)

IPv6 uses a modified version of ICMP (ICMPv6, RFC 4443) with additional functionality:

7. Security Considerations

ICMP Security Risks:
  • ICMP Flood (Ping Flood): DoS attack overwhelming target with echo requests
  • Smurf Attack: Spoofing source address to send broadcast ping, amplifying traffic
  • ICMP Redirect Attacks: Malicious routers redirecting traffic through attacker
  • ICMP Tunneling: Encapsulating data within ICMP payload to bypass firewalls
  • Ping of Death: Oversized ICMP packets causing buffer overflows (historical)

8. ICMP vs. Other Protocols

Feature ICMP TCP UDP
Layer Network (3) Transport (4) Transport (4)
Connection Connectionless Connection-oriented Connectionless
Reliability Unreliable Reliable Unreliable
Addressing IP addresses IP + Port IP + Port
Primary Use Control/Diagnostic Data transfer Fast transmission
🔧

Laboratory Procedure

Experiment 1: Basic ICMP Operations with Ping

Objective

Understand ICMP echo request/reply mechanism and measure network latency.

Materials Required

Procedure

  1. Setup: Open two terminal windows. In one, start packet capture:
    Terminal 1 - Packet Capture
    $ sudo tcpdump -i any icmp -w icmp_capture.pcap # Or using Wireshark GUI with filter "icmp"
  2. Basic Ping: In the second terminal, ping a local host:
    Terminal 2 - Local Network Test
    $ ping -c 5 192.168.1.1 # Gateway $ ping -c 5 127.0.0.1 # Loopback
  3. Internet Ping: Test external connectivity:
    External Connectivity
    $ ping -c 5 8.8.8.8 # Google DNS $ ping -c 5 google.com # Domain name resolution test
  4. Parameter Variation: Test different packet sizes:
    Packet Size Variation
    $ ping -c 3 -s 56 8.8.8.8 # Default (64 bytes total) $ ping -c 3 -s 1000 8.8.8.8 # Large packet $ ping -c 3 -s 65507 8.8.8.8 # Maximum (near limit)
  5. TTL Analysis: Observe TTL behavior:
    TTL Examination
    $ ping -c 1 -t 1 8.8.8.8 # Windows: TTL=1 $ ping -c 1 -m 1 8.8.8.8 # Linux: TTL=1 (should fail) $ ping -c 1 -m 64 8.8.8.8 # Linux: TTL=64
  6. Capture Analysis: Stop capture and analyze in Wireshark:
    • Filter: icmp
    • Examine Type, Code, Checksum, Identifier, Sequence Number
    • Verify Data payload contains timestamp and random data

Expected Results

  • Local ping: RTT < 1ms, TTL 64 or 128
  • Gateway ping: RTT 1-5ms, TTL 64
  • Internet ping: RTT 20-100ms depending on distance
  • TTL=1 packets should fail with "Time to live exceeded"

Experiment 2: Route Tracing with ICMP

Objective

Trace network paths and understand ICMP Time Exceeded messages.

Procedure

  1. Basic Traceroute:
    Route Tracing
    $ traceroute google.com # Linux $ tracert google.com # Windows $ traceroute -I google.com # Force ICMP method (Linux)
  2. Protocol Comparison:
    Different Traceroute Methods
    $ traceroute -I google.com # ICMP echo (privileged) $ traceroute -T google.com # TCP SYN $ traceroute -U google.com # UDP (default on Linux)
  3. Analysis: Record:
    • Number of hops to destination
    • RTT variation per hop
    • Any timeouts or unreachable hops (* * *)
    • Geographic diversity of intermediate routers

Experiment 3: ICMP Error Message Analysis

Objective

Generate and analyze ICMP error conditions.

Procedure

  1. Destination Unreachable:
    Generate Port Unreachable
    $ nc -vz 192.168.1.1 99999 # Connect to closed/high port # Or use nmap: $ nmap -Pn -sU -p 33434 192.168.1.1
  2. Fragmentation Needed: Test with DF flag:
    Don't Fragment Test
    $ ping -c 1 -M do -s 1473 8.8.8.8 # Linux: DF bit set # Should receive "Frag needed and DF set" (Type 3, Code 4)
  3. Capture and Identify: In Wireshark, identify:
    • Type 3, Code 0: Network unreachable
    • Type 3, Code 1: Host unreachable
    • Type 3, Code 3: Port unreachable
    • Type 3, Code 4: Fragmentation needed

Experiment 4: ICMPv6 Operations

Objective

Compare ICMPv6 with ICMPv4 and understand Neighbor Discovery.

Procedure

  1. IPv6 Ping:
    IPv6 Connectivity
    $ ping6 -c 5 2001:4860:4860::8888 # Google IPv6 DNS $ ping6 -c 5 ipv6.google.com
  2. Neighbor Discovery: Observe Neighbor Solicitation/Advertisement:
    IPv6 Neighbor Discovery
    $ ip -6 neigh show # Show neighbor cache (Linux) $ ndp -a # macOS equivalent
  3. Compare Headers: Capture and compare ICMPv4 vs ICMPv6:
    • ICMPv6 Type 128/129 vs ICMPv4 Type 0/8
    • Additional ICMPv6 types for autoconfiguration
📝

Laboratory Report Guidelines

Report Structure

A professional laboratory report on ICMP should follow this structure:

1

Title Page

  • Experiment title: "ICMP Protocol Analysis"
  • Course name and code
  • Student name and ID
  • Date of experiment
  • Instructor name
2

Abstract/Executive Summary

  • Brief overview (150-200 words)
  • Objectives stated clearly
  • Key findings summarized
  • Main conclusions highlighted
3

Introduction/Theory

  • ICMP protocol overview
  • Relevant RFC references (792, 4443)
  • Message types and formats
  • Relationship to IP layer
  • Practical applications
4

Equipment & Materials

  • Hardware specifications
  • Operating system and version
  • Software tools (Wireshark version, etc.)
  • Network topology description
5

Procedure/Methodology

  • Step-by-step experimental steps
  • Command syntax used
  • Parameters and flags explained
  • Diagrams of setup
  • Justification for methods chosen
6

Results & Data

  • Raw data tables
  • Screenshots of packet captures
  • Wireshark packet analysis
  • Statistical summaries
  • RTT measurements and averages
7

Analysis & Discussion

  • Interpretation of ICMP types observed
  • TTL analysis and hop count
  • Latency variation explanation
  • Error message causes identified
  • Comparison with theoretical expectations
8

Conclusions

  • Objectives achieved (yes/no)
  • Key learnings summarized
  • Practical implications
  • Limitations of study
  • Recommendations for future work
9

References

  • RFC 792 (ICMPv4)
  • RFC 4443 (ICMPv6)
  • Textbook citations
  • Software documentation
  • Academic papers (IEEE format)
10

Appendices

  • Complete packet capture files (.pcap)
  • Command output logs
  • Configuration details
  • Additional screenshots

Writing Standards

Technical Writing Requirements:
  • Use third person passive voice (e.g., "The packet was captured..." not "I captured the packet...")
  • All measurements must include units (ms, bytes, hops)
  • Precision: Report RTT to 3 decimal places (e.g., 23.456 ms)
  • Tables: Numbered with captions (Table 1: Ping Statistics)
  • Figures: Numbered with descriptive captions below image
  • Code/Commands: Use monospaced font, clearly separated from text

Data Presentation Standards

Table Format Example

Destination Packet Size (bytes) RTT Min (ms) RTT Avg (ms) RTT Max (ms) Packets Lost (%) TTL
127.0.0.1 (Loopback) 56 0.042 0.045 0.051 0 64
192.168.1.1 (Gateway) 56 1.234 1.456 1.789 0 64
8.8.8.8 (Google DNS) 56 23.412 24.123 25.678 0 117

Common Mistakes to Avoid

  • Incomplete packet analysis: Always identify Type, Code, Checksum, and payload
  • Missing context: Explain WHY certain ICMP types were generated
  • Unlabeled screenshots: Every image needs figure number and description
  • Ignoring errors: Discuss failed pings and timeouts as they indicate network issues
  • Confusing layers: Remember ICMP is Layer 3, not Layer 4
  • Security oversights: Mention ICMP security implications in discussion

Grading Rubric (Typical)

Component Weight Criteria
Theoretical Understanding 20% Accuracy of protocol description, RFC compliance
Experimental Procedure 20% Clarity, reproducibility, appropriate methods
Data Collection 20% Completeness, accuracy, appropriate tools used
Analysis & Interpretation 25% Depth of analysis, correct interpretation of results
Presentation 15% Formatting, grammar, professional appearance

Self-Assessment Checklist

Before submitting your laboratory report, verify that you can confidently answer these questions:

Conceptual Understanding

  • Can I explain why ICMP is considered Layer 3?
  • Do I understand the difference between Type and Code fields?
  • Can I identify ICMP messages from a hex dump?
  • Do I know which ICMP types are errors vs. queries?

Practical Skills

  • Can I use ping with various flags (-s, -i, -c, -t)?
  • Can I interpret traceroute output correctly?
  • Can I filter ICMP in Wireshark?
  • Can I calculate expected TTL values?

Troubleshooting

  • Can I diagnose "Destination Unreachable"?
  • Do I understand "Time Exceeded" scenarios?
  • Can I identify fragmentation issues?
  • Do I know when ICMP is blocked by firewalls?

Advanced Topics

  • Can I compare ICMPv4 and ICMPv6?
  • Do I understand ICMP security vulnerabilities?
  • Can I explain Path MTU Discovery?
  • Do I know common ICMP-based attacks?
Study Tips:
  1. Practice packet analysis with Wireshark sample captures
  2. Create flashcards for ICMP Type/Code combinations
  3. Set up a test network to generate various ICMP errors
  4. Read RFC 792 and RFC 4443 for authoritative information
  5. Review network troubleshooting case studies involving ICMP