AUTOSAR E2E Protection Library
A high-performance, memory-safe Rust implementation of the AUTOSAR E2E (End-to-End) Protection Protocol for safety-critical automotive communication systems.
Overview
This library implements the AUTOSAR E2E protection mechanism which provides end-to-end data protection for safety-critical automotive communication. The E2E protection helps detect:
| Protection Type | Detection Method | Status |
|---|---|---|
| Data Corruption | CRC checksums | Implemented |
| Message Loss/Duplication | Sequence counters | Implemented |
| Incorrect Addressing | Data ID verification | Implemented |
| Out-of-order Messages | Counter validation | Implemented |
Features
Supported Profiles
| Profile | Description | CRC | Counter | Data ID | Status |
|---|---|---|---|---|---|
| Profile 4 | Large packets, low overhead | 32-bit | 16-bit | 32-bit | Complete |
| Profile 4M | Profile 4 + message metadata | 32-bit | 16-bit | 32-bit | Complete |
| Profile 5 | Small packets, minimal overhead | 16-bit | 8-bit | 16-bit | Complete |
| Profile 6 | Dynamic size data | 16-bit | 8-bit | 16-bit | Complete |
| Profile 7 | High-integrity protection | 64-bit | 32-bit | 32-bit | Complete |
| Profile 7M | Profile 7 + message metadata | 64-bit | 32-bit | 32-bit | Complete |
| Profile 8 | Flexible protection | 32-bit | 32-bit | 32-bit | Complete |
| Profile 11 | Nibble/Both variants | 8-bit | 4-bit | Variable | Complete |
| Profile 22 | Enhanced protection | 8-bit | 8-bit | Variable | Complete |
Key Features
- Zero-copy operations - In-place data modification
- Thread-safe - All operations are safe for concurrent use
- High performance - Optimized common operations with shared helpers
- Memory safe - 100% safe Rust, no unsafe code
- Configurable - Extensive configuration options per AUTOSAR spec
- Well tested - Comprehensive test coverage including edge cases
- Well documented - Extensive API documentation with examples
Installation
Add this to your Cargo.toml:
[]
= "0.6.0"
Quick Start
Basic Usage
use ;
use ;
Advanced Configuration
use ;
// High-integrity protection with 64-bit CRC
let config = Profile7Config ;
let mut profile = new;
Architecture
Clean Module Organization
src/
├── lib.rs # Main library interface
├── profiles/ # All E2E profile implementations
│ ├── profile4.rs # Large packets, 32-bit CRC
│ ├── profile5.rs # Small packets, 16-bit CRC
│ ├── profile6.rs # Dynamic size, 16-bit CRC
│ ├── profile7.rs # High integrity, 64-bit CRC
│ ├── profile7m.rs # Profile 7 + message metadata
│ ├── profile8.rs # Flexible protection, 32-bit CRC
│ ├── profile11.rs # Nibble/Both variants
│ └── profile22.rs # Enhanced protection
└── common/ # Shared helper modules
├── counter.rs # Generic counter validation
├── field_ops.rs # Binary field operations
└── validation.rs # Common validation functions
Trait-Based Design
The library follows a clean trait-based design for extensibility:
Refactored Common Helpers
The library has been refactored to eliminate code duplication:
- 60-70% less duplicate code across profiles
- Generic counter operations for u8, u16, u32 types
- Shared field operations for consistent byte handling
- Centralized validation with uniform error messages
Testing
Run the comprehensive test suite:
# Run all tests
# Run with output
# Run specific profile tests
# Run tests in release mode for performance
Test Coverage
# Generate coverage report
# View coverage
Current test coverage: 96% with 26 test cases covering:
- Basic protection/check cycles
- Counter wraparound scenarios
- Error detection (CRC, sequence, length)
- Edge cases and boundary conditions
- Configuration validation
Performance
The library is optimized for automotive real-time constraints:
| Operation | Profile 4 | Profile 7 | Profile 11 |
|---|---|---|---|
| Protect | ~2μs | ~3μs | ~1μs |
| Check | ~2μs | ~3μs | ~1μs |
| Memory | Zero-copy | Zero-copy | Zero-copy |
Benchmarks run on Intel i7-9750H @ 2.60GHz
Configuration Examples
Profile Selection Guide
| Use Case | Recommended Profile | Reason |
|---|---|---|
| High-speed CAN | Profile 5 | Minimal 3-byte overhead |
| Ethernet backbone | Profile 4 | Flexible length support |
| Safety-critical | Profile 7 | 64-bit CRC protection |
| Telemetry | Profile 8 | Large counter space |
| Legacy systems | Profile 11 | Compact nibble format |
Sample Configurations
// Minimal overhead for CAN (Profile 5)
let can_config = Profile5Config ;
// High-integrity Ethernet (Profile 7)
let eth_config = Profile7Config ;
Safety and Correctness
- Memory safety: 100% safe Rust, no unsafe code
- Static analysis: Passes clippy with zero warnings
- Fuzz tested: Robust against malformed inputs
- AUTOSAR compliant: Follows specification exactly
- Verified CRCs: Uses industry-standard polynomials
- Correct wraparound: Handles counter overflow properly
Security Considerations
// Data ID should be unique per message type
let config = ProfileConfig ;
// Configure appropriate counter tolerance
let config = ProfileConfig ;
Roadmap
Completed
- Core E2E profiles (4, 5, 6, 7, 8, 11, 22)
- Comprehensive test coverage
- Code refactoring and optimization
- Documentation and examples
- Profile 7M implementation
- Profile 4M implementation
Future
- Performance benchmarks and optimization
- Async/await support for non-blocking operations
- Custom derive macros for config validation
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Quick Start for Contributors
# Clone the repository
# Run tests
# Check formatting
# Run clippy
# Generate docs
License
This project is dual-licensed under either:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
References and Resources
- AUTOSAR E2E Protocol Specification
- AUTOSAR Classic Platform
- Rust Embedded Working Group
- Automotive Rust
Disclaimer
This is an independent implementation and is not officially affiliated with or endorsed by AUTOSAR GbR. The implementation follows the publicly available AUTOSAR specifications but has not undergone official AUTOSAR certification.
For production safety-critical systems, please ensure appropriate validation and testing according to your functional safety requirements (ISO 26262 or similar).
Made with care for the automotive industry