DoIP Server and Client implementation with YAML configuration
Project description
DoIP Server
A Python implementation of DoIP (Diagnostics over Internet Protocol) server and client with comprehensive YAML configuration management.
๐ Quick Start
# Install dependencies
poetry install
# Run with hierarchical configuration
poetry run python src/doip_server/main.py --gateway-config config/gateway1.yaml
# Test UDP Vehicle Identification
python scripts/utilities/run_udp_client.py --verbose
# Test Functional Diagnostics
python scripts/test/test_functional_diagnostics.py
# Test Hierarchical Configuration
python -m pytest tests/test_hierarchical_configuration.py -v
# Run comprehensive test suite
poetry run pytest tests/ -v
๐ Documentation
Comprehensive documentation is available in the docs/ directory:
- ๐ Documentation Index - Complete documentation index
- ๐ Getting Started - Detailed project overview and setup
- โ๏ธ Configuration Guide - Complete configuration guide
- ๐ง API Reference - API reference and examples
- ๐งช Testing Guide - Testing guide and results
- ๐ Deployment Guide - Deployment and CI/CD guide
โจ Key Features
๐๏ธ Hierarchical Configuration System
- Multi-File Architecture: Gateway, ECU, and UDS services in separate files
- Dynamic ECU Loading: Add/remove ECUs at runtime without code changes
- Service Isolation: ECU-specific services with common service sharing
- Address Validation: Per-ECU source and target address validation
- Configuration Validation: Comprehensive validation with clear error reporting
๐ง Functional Diagnostics
- Broadcast Communication: Single request to multiple ECUs simultaneously
- Functional Addressing: Default 0x1FFF address for broadcast requests
- Service Filtering: Only ECUs supporting the service with functional addressing respond
- Efficient Diagnostics: Reduce network traffic and improve diagnostic efficiency
- Flexible Configuration: Per-service functional addressing support
๐ Advanced Features
- Response Cycling: Automatic cycling through multiple responses per UDS service
- UDP Vehicle Identification: Network discovery via UDP broadcasts
- Per-ECU Services: ECU-specific UDS service definitions
- Comprehensive Testing: 99.5% test pass rate with full core functionality
- Backward Compatibility: Support for legacy configuration formats
๐๏ธ Architecture
Hierarchical Configuration System
The DoIP server uses a sophisticated hierarchical configuration system that separates concerns into three main components:
config/
โโโ gateway1.yaml # Gateway network configuration & ECU references
โโโ ecu_engine.yaml # Engine ECU configuration (0x1000)
โโโ ecu_transmission.yaml # Transmission ECU configuration (0x1001)
โโโ ecu_abs.yaml # ABS ECU configuration (0x1002)
โโโ uds_services.yaml # UDS service definitions (common + ECU-specific)
Configuration Components
1. Gateway Configuration (gateway1.yaml)
- Network Settings: TCP/IP host, port, max connections, timeouts
- Protocol Configuration: DoIP version, inverse version
- ECU References: Dynamic list of ECU configuration files
- Response Codes: Gateway-level response configuration
- Logging & Security: Centralized logging and security settings
2. ECU Configurations (ecu_*.yaml)
- ECU Identity: Name, description, target address
- Functional Address: Broadcast address for functional diagnostics (default: 0x1FFF)
- Tester Addresses: Allowed source addresses per ECU
- Service References: Common services + ECU-specific services
- ECU-Specific Settings: Custom configuration per ECU
3. UDS Services Configuration (uds_services.yaml)
- Common Services: Available to all ECUs (Read VIN, Diagnostic Session Control, etc.)
- ECU-Specific Services: Engine, Transmission, ABS specific services
- Functional Addressing Support: Services marked for broadcast capability
- Response Cycling: Multiple response options per service
Configuration Flow Diagram
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DoIP Server Architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Gateway โ โ ECU Configurations โ โ
โ โ (gateway1.yaml)โ โ โ โ
โ โ โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โข Network โ โ โ Engine โ โTransmission โ โ โ
โ โ โข Protocol โ โ โ (0x1000) โ โ (0x1001) โ โ โ
โ โ โข ECU Refs โ โ โ โ โ โ โ โ
โ โ โข Logging โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ โ ABS โ โ โ
โ โ โ โ (0x1002) โ โ โ
โ โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ UDS Services Configuration โ โ
โ โ (uds_services.yaml) โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Common Services โ โ ECU-Specific Services โ โ โ
โ โ โ โ โ โ โ โ
โ โ โ โข Read VIN โ โ โข Engine Services โ โ โ
โ โ โ โข Session Ctrl โ โ โข Transmission Services โ โ โ
โ โ โ โข Tester Presentโ โ โข ABS Services โ โ โ
โ โ โ โข Vehicle Type โ โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Functional Diagnostics โ โ
โ โ โ โ
โ โ โข Functional Address: 0x1FFF โ โ
โ โ โข Broadcast to multiple ECUs โ โ
โ โ โข Service filtering by functional support โ โ
โ โ โข Efficient multi-ECU communication โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Benefits of Hierarchical Configuration
๐ฏ Separation of Concerns
- Gateway Configuration: Network and protocol settings centralized
- ECU Configuration: Individual ECU settings isolated and manageable
- Service Configuration: UDS services organized by category and ECU
๐ Dynamic Management
- Runtime ECU Loading: Add/remove ECUs without server restart
- Service Isolation: ECU-specific services don't interfere with others
- Easy Scaling: Add new ECUs by simply adding configuration files
๐ก๏ธ Enhanced Security & Validation
- Per-ECU Address Validation: Source addresses validated per ECU
- Service Authorization: Only authorized services available per ECU
- Configuration Validation: Comprehensive validation with clear error messages
๐ Improved Maintainability
- Modular Structure: Easy to understand and modify
- Clear Ownership: Each configuration file has a specific purpose
- Backward Compatibility: Legacy configurations still supported
๐ง Functional Diagnostics
Overview
The DoIP server supports functional diagnostics, enabling broadcast communication to multiple ECUs using a single request. This powerful feature allows clients to efficiently communicate with multiple ECUs simultaneously.
Key Concepts
Functional Addressing
- Functional Address: Special logical address (default:
0x1FFF) representing multiple ECUs - Broadcast Communication: Single request sent to multiple ECUs that support the service
- Service Filtering: Only ECUs supporting the requested UDS service with functional addressing respond
Physical vs Functional Addressing
- Physical Addressing: Direct communication with specific ECU using unique logical address
- Functional Addressing: Broadcast communication to multiple ECUs using shared functional address
Configuration
ECU Configuration
Each ECU configuration includes a functional address:
ecu:
name: "Engine_ECU"
target_address: 0x1000
functional_address: 0x1FFF # Broadcast address
tester_addresses: [0x0E00, 0x0E01, 0x0E02]
UDS Services Configuration
Services supporting functional addressing are marked:
common_services:
Read_VIN:
request: "0x22F190"
responses: ["0x62F1901020011223344556677889AABB"]
supports_functional: true # Enables broadcast capability
Usage Examples
Basic Functional Request
from doip_client.doip_client import DoIPClientWrapper
# Create client
client = DoIPClientWrapper(
server_host="127.0.0.1",
server_port=13400,
logical_address=0x0E00,
target_address=0x1000
)
# Connect and send functional request
client.connect()
response = client.send_functional_read_data_by_identifier(0xF190) # Read VIN
print(f"Response: {response.hex()}")
client.disconnect()
Functional vs Physical Comparison
# Physical addressing - Engine ECU only
response_physical = client.send_read_data_by_identifier(0xF190)
# Functional addressing - All ECUs that support it
response_functional = client.send_functional_read_data_by_identifier(0xF190)
Supported Services
Common Services (All ECUs)
Read_VIN- Vehicle Identification NumberRead_Vehicle_Type- Vehicle Type InformationDiagnostic_Session_Control- Session managementTester_Present- Keep-alive functionality
ECU-Specific Services
Engine_Diagnostic_Codes- Engine trouble codesTransmission_Diagnostic_Codes- Transmission trouble codesABS_Diagnostic_Codes- ABS trouble codes
Testing
# Test functional diagnostics
python scripts/test/test_functional_diagnostics.py
# Run functional demo
python -c "from doip_client.doip_client import DoIPClientWrapper; DoIPClientWrapper().run_functional_demo()"
๐ Test Status
- Unit Tests: 17/17 โ (100%)
- Hierarchical Config Tests: 21/21 โ (100%)
- Response Cycling Tests: 9/9 โ (100%)
- Legacy Integration Tests: 13/13 โ (100%)
- Client Extended Tests: 25/25 โ (100%)
- Main Module Tests: 12/12 โ (100%)
- Validate Config Tests: 15/15 โ (100%)
- Debug Client Tests: 30/30 โ (100%)
- Demo Tests: 5/6 โ (83% - 1 skipped)
- Overall: 185/186 tests passing (99.5% success rate)
๐ง Development
# Run tests
poetry run pytest tests/ -v
# Run specific test categories
poetry run pytest tests/test_doip_unit.py -v
poetry run pytest tests/test_hierarchical_configuration.py -v
poetry run pytest tests/test_response_cycling.py -v
๐ Documentation
For detailed documentation, see the docs/ directory or start with the Documentation Index.
For complete documentation and implementation details, see the docs/ directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file doip_server-0.2.1.tar.gz.
File metadata
- Download URL: doip_server-0.2.1.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b84fa45c955f33b6af6f596dc4fa345d913b779686e7dd64074c8c7cbb6514
|
|
| MD5 |
cbc0ca8dede4d5fd241a372df68833eb
|
|
| BLAKE2b-256 |
9ae00e9201a8bb3adb3107d2519af52d82fd784f755c781b402db38d45b87924
|
File details
Details for the file doip_server-0.2.1-py3-none-any.whl.
File metadata
- Download URL: doip_server-0.2.1-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09c9630c80e2386f7f8ac9892a67fddf7931b7618a7717992569e5c876330070
|
|
| MD5 |
1e4ccd002db033b493f61294500b69bf
|
|
| BLAKE2b-256 |
092cf18cec0da84a8d1320d4ab7fd73f71db111f742ea955bacccaf64ca16444
|