Skip to content

arshad1312/protocol_analyzer_c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Protocol Analyzer in C (libpcap)

A lightweight network protocol analyzer written in C using libpcap. This tool captures live packets from a network interface and analyzes IP-based network traffic, identifying common protocols such as TCP, UDP, and ICMP.

This project demonstrates low-level packet inspection and network protocol analysis, which are core concepts used in tools like Wireshark and other network security monitoring systems.


Features

  • Capture live network packets

  • Detect IP packets from Ethernet frames

  • Identify transport layer protocols

    • TCP
    • UDP
    • ICMP
  • Display source and destination IP addresses

  • Show packet length

  • Real-time packet monitoring


Technologies Used

  • C Programming
  • libpcap
  • Linux Networking APIs
  • Ethernet & IP Protocol Analysis

How It Works

  1. The program detects an available network interface.

  2. Using libpcap, it captures packets flowing through the network.

  3. The Ethernet header is inspected to identify IP packets.

  4. The IP header is parsed to extract:

    • Source IP address
    • Destination IP address
    • Transport protocol type (TCP / UDP / ICMP)
  5. Packet details are printed in real-time.

This simulates the basic packet analysis mechanism used in professional network monitoring tools.


Installation

Install the required dependency:

sudo apt install libpcap-dev

Compile

gcc analyzer.c -o analyzer -lpcap

Run

sudo ./analyzer

Root privileges are required to capture network packets.


Example Output

Listening on interface: eth0

===== IP Packet Detected =====
Source IP: 192.168.1.10
Destination IP: 142.250.183.14
Protocol: TCP
Packet Length: 74 bytes
-----------------------------

Learning Outcomes

Through this project I learned:

  • How packet capture works internally
  • Using libpcap for network packet monitoring
  • Understanding Ethernet and IP packet structures
  • Identifying transport layer protocols
  • Implementing a simple network protocol analyzer

Future Improvements

  • Display TCP and UDP port numbers
  • Detect HTTP and DNS traffic
  • Add packet filtering
  • Export captured packet information to log files
  • Extend the project into a full network packet analyzer

Disclaimer

This project is developed for educational and cybersecurity learning purposes only. Use it responsibly and only on networks where you have permission.


Author

Arshad S Cybersecurity Enthusiast | Network Security Learner

About

A simple network packet analyzer built in C with libpcap that captures live packets and analyzes IP-based protocols such as TCP, UDP and ICMP.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages