A lightweight client-server based network telemetry system that captures TCP traffic data from clients, sends it to a central server, stores it in MongoDB, and visualizes it using a dashboard. Before everything i remind you to make .env files for the local_analyzer and the server folder that will contain the mongoDB credentials. Also all the three folders can we run on independent machines with the contraint of same LAN network.
The code now uses the OpenSLL to establish a secure connection on the socker and also has multi-client conneciton capabilities. It does not use threading since that restricts the number of the client to the no. of core the server had, therefore been modded to the use async function that use non blocking I/O for the handling of the client in a single loop.
The code now has a certificate generator file so be sure to download openSSL before run that file. Just need to input the server ip and the certs are generated for the client , server and even the CA certs are also signed.
Also remember to change the .env file in the client foldet. It has an .env file where you have to specify the server ip. It is needed to connect over the LAN.
This project consists of three main components:
- Client โ Captures network packets and sends telemetry data
- Server โ Receives, processes, and stores data
- Analyzer/Dashboard โ Visualizes the collected data
The system works in a LAN environment and helps monitor TCP-level activity such as sequence numbers, flags, and packet flow.
[ CLIENT ] ---> [ SERVER ] ---> [TLS-SSL] ---> [ DATABASE ] ---> [ DASHBOARD ]
Packet Capture TCP Socket OpenSSL MongoDB Streamlit UI
-
Client captures packets using raw sockets / packet sniffing
-
Extracts:
- Source IP
- Destination IP
- Sequence number
- Flags (SYN, ACK, FIN, etc.)
-
Sends this data to the server using TCP
-
Server receives and parses the data
-
Stores it in MongoDB
-
Dashboard fetches data from MongoDB
-
Displays graphs and logs
This project uses OpenSSL to implement RSA-based TLS/SSL secure communication. Follow the steps below to install and configure it before running the project.
-
Download from: https://slproweb.com/products/Win32OpenSSL.html
-
Install Win64 OpenSSL (Light version is enough)
-
Add this to your system
PATH:C:\Program Files\OpenSSL-Win64\bin -
Verify installation:
openssl version
sudo apt update
sudo apt install openssl libssl-devbrew install opensslCreate a folder named certs/ and run:
openssl genrsa -out ca.key 2048
openssl req -x509 -new -nodes -key ca.key \
-sha256 -days 365 -out ca.pemopenssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key \
-CAcreateserial -out server.pem -days 365 -sha256openssl genrsa -out client.key 2048
openssl req -new -key client.key -out client.csr
openssl x509 -req -in client.csr -CA ca.pem -CAkey ca.key \
-CAcreateserial -out client.pem -days 365 -sha256certs/
โโโ ca.pem
โโโ server.pem
โโโ server.key
โโโ client.pem (optional)
โโโ client.key (optional)
Start server:
python server.pyRun client:
python client.py- RSA (2048-bit) is used for secure key exchange
- TLS handles encryption after handshake
- Make sure server IP matches certificate (important for TLS)
- For local testing, self-signed certificates are acceptable
- Do NOT upload
.keyfiles in public repositories
Network_Analyzer/
โ
โโโ client/
โ โโโ client.py
โ โโโ requirements.txt
โ โโโ ca_cert.pem # โ COPY this from server (needed for TLS verify)
โ
โโโ local_analyzer/
โ โโโ __pycache__/
โ โโโ .env
โ โโโ .gitignore
โ โโโ analytics.py
โ โโโ dashboard.py
โ โโโ data_fetcher.py
โ โโโ report_logic.py
โ
โโโ server/
โ โโโ __pycache__/
โ โโโ .venv/
โ โโโ file_server/
โ โโโ .env
โ โโโ .gitignore
โ โโโ config.py
โ โโโ tcp_server.py
โ โโโ server.log
โ โโโ requirements.txt
โ โ
โ โโโ ca_cert.pem # โ GENERATED (CA certificate)
โ โโโ server_cert.pem # โ GENERATED (server certificate)
โ โโโ server_key.pem # โ GENERATED (server private key)
โ โโโ ca_key.pem # โ GENERATED (keep private, do not share)
โ โโโ ca_cert.srl # โ auto-generated by OpenSSL
โ
โโโ .gitignore
โโโ LICENSE
โโโ README.md
-
Generate all cert files using OpenSSL
-
Place them inside
server/:ca_cert.pemserver_cert.pemserver_key.pemca_key.pemca_cert.srl
-
Copy only:
ca_cert.pemโ intoclient/
- Server reads certs directly from its folder
- Client verifies server using
ca_cert.pem - Do NOT rename files (code depends on exact names)
- Do NOT move into subfolders (your code uses direct paths)
- Python 3.10+
- MongoDB (local or Atlas)
- pymongo
- socket
- streamlit
- python-dotenv
git clone <your-repo-url>
cd Network-Analyzer
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txt
Create a .env file in the root folder:
MONGO_URI=mongodb://localhost:27017/
DB_NAME=network_data
COLLECTION_NAME=packets
If using MongoDB Atlas, replace the URI accordingly.
Make sure MongoDB is running locally or accessible.
cd server
python tcp_server.py
โ Server will:
- Listen for incoming client connections
- Store incoming data in MongoDB
cd client
python client.py
โ Client will:
- Capture TCP packets
- Send structured data to server IP
client.py:
SERVER_IP = "YOUR_SERVER_IP"
Use:
ipconfig # Windows
cd local_analyzer
streamlit run dashboard.py
โ Opens browser:
http://localhost:8501
- Real-time packet monitoring
- TCP flag analysis (SYN, ACK, FIN)
- Sequence number tracking
- MongoDB-based storage
- Interactive dashboard using Streamlit
{
"src_ip": "192.168.1.5",
"dst_ip": "192.168.1.10",
"seq": 12345,
"flags": "SYN"
}
- Check
.envfile - Ensure MongoDB is running
- Verify URI format
- Ensure server IP is correct
- Check firewall settings
- Both systems must be on same LAN
- Verify database name and collection
- Check if server is inserting data
- Restart Streamlit
# Setup
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
# Run server
cd server
python tcp_server.py
# Run client
cd client
python client.py
# Run dashboard
cd local_analyzer
streamlit run dashboard.py
- Add UDP packet analysis
- Real-time streaming using WebSockets
- Alert system for suspicious traffic
- Authentication layer
Developed as part of a Computer Networks mini project.
This project is for educational purposes.