A Dynamic Adaptive Streaming over HTTP (DASH) client implementing Proximal Policy Optimization (PPO) for intelligent bitrate adaptation to maximize Quality of Experience (QoE).
This project implements an adaptive bitrate (ABR) algorithm using reinforcement learning to optimize video streaming quality. The system dynamically selects optimal bitrates based on network conditions, buffer levels, and user experience metrics while being tested in realistic network environments using Mahimahi network simulator.
The project consists of several key components:
- Reinforcement Learning Agent: PPO-based algorithm for bitrate selection
- DASH Client: HTTP-based streaming client with chunk-based video delivery
- Network Simulation: Mahimahi integration for realistic network testing
- QoE Optimization: Comprehensive reward system balancing quality, rebuffering, and smoothness
├── mahimahi.up # Mahimahi uplink network trace
├── mahimahi.down # Mahimahi downlink network trace
├── flask_server # Video streaming server implementation
├── video_size # Video chunk size configurations
├── streaming_environment.py # RL environment for DASH streaming
├── network_architecture.py # Neural network model definitions
├── model_evaluation.py # Model performance evaluation scripts
├── experience_buffer.py # Experience replay buffer for RL
├── adaptive_bitrate_trainer.py # PPO training implementation
├── trace_loader.py # Network trace loading utilities
├── test_environment.py # Testing and validation scripts
├── traces/ # Directory containing network traces
└── test_traces/ # Additional test network traces
- PPO Algorithm: Stable policy optimization for bitrate selection
- State Space: Buffer levels, bandwidth estimation, previous bitrates
- Action Space: Multiple bitrate options (300kbps, 600kbps, 1200kbps, etc.)
- Reward Function: Balances video quality, rebuffering, and bitrate switching
- Chunk-based Delivery: Efficient video segment streaming
- Multiple Bitrates: Adaptive quality selection
- Buffer Management: Intelligent prebuffering strategies
- Real-time Adaptation: Dynamic quality adjustment
- Mahimahi Integration: Realistic network condition simulation
- Variable Bandwidth: Testing under different network scenarios
- Latency Simulation: RTT and packet loss modeling
- Trace Replay: Real-world network trace analysis
- Python 3.8+
- PyTorch
- OpenAI Gym
- Flask
- Mahimahi Network Simulator
# Clone the repository
git clone <repository-url>
cd dash-abr-client
# Install Python dependencies
pip install torch torchvision
pip install gym flask numpy matplotlib
pip install opencv-python requests
# Install Mahimahi (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install mahimahi
# For other systems, visit: http://mahimahi.mit.edu/# Start training with default parameters
python adaptive_bitrate_trainer.py
# Train with custom network traces
python adaptive_bitrate_trainer.py --traces ./traces/ --episodes 1000# Start the video server
python flask_server
# Server will be available at http://localhost:5000# Run client with network simulation
mm-delay 20 mm-link mahimahi.up mahimahi.down python test_environment.py
# Test with custom traces
mm-delay 50 mm-link traces/trace1.up traces/trace1.down python streaming_environment.py# Evaluate trained model performance
python model_evaluation.py --model ./models/ppo_model.pth
# Generate performance plots and metrics
python model_evaluation.py --plot --output ./results/The system optimizes for:
- Video Quality: Average bitrate delivered
- Rebuffering: Minimize stalling events
- Smoothness: Reduce bitrate switching frequency
- QoE Score: Composite user experience metric
- Current buffer level (seconds)
- Estimated bandwidth (kbps)
- Previous chunk bitrate
- Chunk download time
- Remaining video duration
- Real-world network traces from various conditions
- Synthetic traces for controlled experiments
- Variable bandwidth scenarios (3G, 4G, WiFi)
# adaptive_bitrate_trainer.py
LEARNING_RATE = 3e-4
BATCH_SIZE = 64
EPOCHS = 1000
CLIP_RATIO = 0.2
GAMMA = 0.99# streaming_environment.py
BITRATES = [300, 600, 1200, 2400] # kbps
CHUNK_DURATION = 4 # seconds
BUFFER_TARGET = 10 # seconds- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request