A Java-based network traffic analysis tool that reads .pcap files, decodes packets across multiple network layers, reconstructs communication flows, and performs Deep Packet Inspection (DPI) to identify application-level traffic such as Google, YouTube, Netflix, WhatsApp, GitHub, and more.
Network communication occurs through packets that travel across different layers of the TCP/IP stack. Understanding these packets is essential for network monitoring, troubleshooting, traffic analysis, and cybersecurity.
This project analyzes offline packet captures (.pcap files) by parsing packet headers, extracting protocol information, tracking network flows, and classifying traffic using DPI techniques.
Unlike traditional packet analyzers that depend on native libraries such as libpcap, this implementation is written entirely in Java, making it platform-independent and easy to run on any system with Java installed.
- Reads and processes standard
.pcapfiles - Parses Ethernet frames
- Decodes IPv4 packets
- Extracts TCP and UDP header information
- Displays packet metadata in a human-readable format
-
Reconstructs network conversations
-
Uses Five-Tuple identification:
- Source IP Address
- Destination IP Address
- Source Port
- Destination Port
- Protocol
-
Tracks:
- Packet count
- Byte count
- Flow duration
- Activity timestamps
Traffic classification is performed using multiple techniques:
Extracts hostnames from TLS Client Hello packets.
Example:
www.youtube.com
Extracts domains from HTTP requests.
Example:
Host: github.comParses DNS traffic to identify requested domains.
Example:
api.whatsapp.com
Fallback classification using well-known ports.
| Port | Service |
|---|---|
| 80 | HTTP |
| 443 | HTTPS |
| 53 | DNS |
| 22 | SSH |
- Ethernet
- IPv4
- TCP
- UDP
The analyzer can identify traffic related to:
- YouTube
- Netflix
- Telegram
- Discord
- Spotify
- GitHub
- Zoom
- TikTok
- Cloudflare
- Amazon AWS
- Microsoft Azure
- Apple iCloud
- Generic HTTP / HTTPS / DNS Traffic
+------------------+
| Main.java |
+---------+--------+
|
v
+------------------+
| PcapReader |
+---------+--------+
|
v
+------------------+
| PacketParser |
+---------+--------+
|
+----------------+----------------+
| |
v v
+------------------+ +------------------+
| ParsedPacket | | DpiEngine |
+------------------+ +---------+--------+
|
v
+------------------+
| ConnectionTracker|
+------------------+
src/main/java/com/packetanalyzer/
├── Main.java
│
├── model/
│ ├── RawPacket.java
│ ├── ParsedPacket.java
│ ├── FiveTuple.java
│ ├── Connection.java
│ └── AppType.java
│
├── reader/
│ └── PcapReader.java
│
├── parser/
│ └── PacketParser.java
│
└── dpi/
├── DpiEngine.java
├── ConnectionTracker.java
└── SNIExtractor.java
Responsible for:
- Reading PCAP global headers
- Detecting byte order
- Extracting raw packet data
- Creating packet objects
Responsible for:
- Ethernet parsing
- IPv4 parsing
- TCP parsing
- UDP parsing
- Payload extraction
Maintains active network flows using Five-Tuple identifiers and updates flow statistics for every packet processed.
Performs traffic classification using:
- TLS SNI inspection
- HTTP Host inspection
- DNS query analysis
- Port heuristics
Extracts:
- TLS Server Name Indication (SNI)
- HTTP Host headers
- DNS domain names
| Technology | Purpose |
|---|---|
| Java 11+ | Core Development |
| Maven | Build Automation |
| ByteBuffer | Binary Packet Parsing |
| Java Collections | Flow Management |
| OOP Principles | System Design |
git clone https://github.com/yourusername/java-packet-analyzer.git
cd java-packet-analyzermvn clean packagejava -jar packet-analyzer.jar traffic.pcapjava -jar packet-analyzer.jar traffic.pcap 100java -jar packet-analyzer.jar traffic.pcap 0 --dpi====================================
Packet Analyzer
====================================
Packet #1
Source IP: 192.168.1.100
Destination IP: 142.250.185.206
Protocol: TCP
Source Port: 54552
Destination Port: 443
[DPI] Application: Google
- Parsing binary packet structures in Java
- Handling different PCAP byte-order formats
- Reconstructing network flows efficiently
- Extracting TLS SNI information without external libraries
- Designing a modular DPI classification engine
- Managing flow state and statistics at scale
This project provided hands-on experience with:
- Computer Networking
- TCP/IP Protocol Stack
- Packet Analysis
- Deep Packet Inspection (DPI)
- Network Flow Reconstruction
- Binary Data Processing
- Java Collections Framework
- Object-Oriented System Design
- IPv6 Support
- PCAPNG Support
- Live Packet Capture
- GUI Dashboard
- Traffic Visualization
- Export Reports (JSON / CSV)
- Advanced DPI Signatures
- Real-Time Monitoring