PCAP Replaya Backend - Flask API for PCAP file replay
2.7K
A modern web application for replaying network packet capture (PCAP) files using tcpreplay. Built with React frontend, Flask backend, and fully containerized with Docker.
curl -sSL https://raw.githubusercontent.com/blink-zero/pcap-replaya/main/quick-deploy.sh | sudo bash
# Download production configuration
curl -sSL https://raw.githubusercontent.com/blink-zero/pcap-replaya/main/docker-compose.prod.yml -o docker-compose.yml
# Start the application
sudo docker-compose up -d
cd pcap-replaya-deploy
curl -sSL https://raw.githubusercontent.com/blink-zero/pcap-replaya/main/update.sh | sudo bash
sudo docker-compose pull
sudo docker-compose down
sudo docker-compose up -d
.pcap, .pcapng, .caphttp://localhost:5000/api
No authentication required for local deployment.
| Method | Endpoint | Description |
|---|---|---|
GET | /health | Application health status |
GET | /version | Application version information |
GET | /interfaces | List available network interfaces |
GET | /system/status | System resource status (CPU, memory, disk) |
GET | /system/capabilities | System capabilities and tcpreplay features |
| Method | Endpoint | Description |
|---|---|---|
POST | /upload | Upload PCAP file (multipart/form-data) |
GET | /upload/status/{file_id} | Get upload status |
GET | /upload/download/{file_id} | Download PCAP file |
DELETE | /upload/cleanup/{file_id} | Clean up uploaded file |
| Method | Endpoint | Description |
|---|---|---|
POST | /replay/start | Start PCAP replay |
POST | /replay/stop | Stop current replay |
GET | /replay/status | Get current replay status |
GET | /replay/history | Get replay history (paginated) |
POST | /replay/validate | Validate replay configuration |
| Method | Endpoint | Description |
|---|---|---|
POST | /manipulation/modify | Modify packets in PCAP |
GET | /manipulation/templates | Get modification templates |
| Method | Endpoint | Description |
|---|---|---|
GET | /logs/recent | Get recent log entries |
GET | /logs/stats | Get logging statistics |
curl -X POST http://localhost:5000/api/replay/start \
-H "Content-Type: application/json" \
-d '{
"file_id": "uuid-of-uploaded-file",
"interface": "eth0",
"speed": 2.0,
"speed_unit": "multiplier",
"continuous": false,
"loop": 1,
"preload_pcap": false
}'
curl -X POST http://localhost:5000/api/upload \
-F "[email protected]"
curl "http://localhost:5000/api/replay/history?limit=20&offset=0&search=test&status=completed"
{
"replay_id": "uuid",
"status": "running",
"progress_percent": 45.2,
"packets_sent": 1250,
"bytes_sent": 892400,
"elapsed_time": 12.5,
"packets_per_second": 100.0,
"continuous": false,
"loop_count": 1
}
{
"message": "File uploaded successfully",
"file_id": "uuid",
"filename": "example.pcap",
"file_size": 1048576,
"pcap_info": {
"packet_count": 1000,
"duration": 30.5,
"file_format": "pcap",
"protocols": ["IP", "TCP", "UDP"]
}
}
{
"history": [
{
"id": "uuid",
"filename": "example.pcap",
"file_id": "file-uuid",
"status": "completed",
"started_at": "2025-08-08T15:30:00Z",
"duration": 25.3,
"packets_sent": 1000,
"config": {
"interface": "eth0",
"speed": 2.0,
"speed_unit": "multiplier",
"continuous": false
}
}
],
"total_count": 50,
"limit": 20,
"offset": 0,
"has_more": true
}
Connect to: ws://localhost:5000
| Event | Description | Data |
|---|---|---|
replay_status | Replay status updates | {status, replay_id, message} |
replay_progress | Real-time progress | {progress_percent, packets_sent, ...} |
log_stream | Live log streaming | {level, message, timestamp} |
| Variable | Description | Default |
|---|---|---|
FLASK_ENV | Flask environment | production |
UPLOAD_FOLDER | Upload directory | /tmp/pcap_uploads |
LOG_LEVEL | Logging level | INFO |
SECRET_KEY | Flask secret key | Auto-generated |
MAX_ANALYSIS_PACKETS | Max packets to analyze | 1000000 |
The application uses host networking and privileged containers for network interface access.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React FrontendβββββΊβ Flask Backend βββββΊβ tcpreplay β
β β β β β β
β β’ File Upload β β β’ API Endpoints β β β’ Packet Replay β
β β’ Config UI β β β’ File Handling β β β’ Speed Control β
β β’ Progress Mon. β β β’ WebSocket β β β’ Interface Mgmtβ
β β’ History View β β β’ Process Mgmt β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.py
cd frontend
npm install
npm start
git clone https://github.com/blink-zero/pcap-replaya.git
cd pcap-replaya
sudo docker-compose up --build
# Ensure Docker has necessary privileges
sudo docker-compose down
sudo docker-compose up --build
# Check tcpreplay in container
docker-compose exec backend tcpreplay --version
# View logs
docker-compose logs -f
# Check system status
docker-compose exec backend python -c "
import psutil
print(f'CPU: {psutil.cpu_percent()}%')
print(f'Memory: {psutil.virtual_memory().percent}%')
"
# Test tcpreplay
docker-compose exec backend tcpreplay --version
This project is licensed under the MIT License - see the LICENSEβ file for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)docker-compose logs -f for debuggingContent type
Image
Digest
sha256:33fca292eβ¦
Size
161 MB
Last updated
about 1 year ago
docker pull blinkzero/pcap-replaya-backend