How jaf666/tooltfg works
Project Type and Purpose
• This is an open-source command-line tool (“toolTFG”) written in Python whose purpose is to simulate SOME/IP messages using the Scapy packet-crafting library.
• It reads ECU and service configuration from JSON files, performs service discovery and packet parsing, then uses Scapy to inject or sniff SOME/IP frames over a VLAN-configured network.
File Structure Analysis
• Top level
• README.md – high-level description
• data/ – JSON definitions
• src/ – core Python modules
• vlan/ – shell scripts for VLAN setup
• src/
• main.py – orchestration entry point
• parser.py – parses JSON configs, incoming packets
• serviceDiscovery.py – handles SOME/IP service discovery logic
• __init__.py – package marker
• data/
• ecu_data.json – ECU payload/config definitions
• services.json – SOME/IP service definitions
• vlan/
• check_interfaces.sh – verifies NICs & VLAN tagging
• vlan3.sh – applies VLAN ID 3 configuration
README Insights
• Confirms: Python + Scapy + JSON for simulating SOME/IP
• Data/configuration layer
• Core logic modules
• External dependencies (Scapy, OS network stack)
• Environment setup scripts
a. Main Components
1. CLI/Orchestrator: src/main.py
2. Configuration Layer: data/*.json
3. Parser Module: src/parser.py
4. Service Discovery Module: src/serviceDiscovery.py
5. Packet Engine: Scapy library
6. VLAN Setup Scripts: vlan/*.sh
7. Network Interface & OS Stack
8. External ECU or Test Network (optional)
b. Relationships & Data Flow
• User (CLI) → main.py
• main.py reads JSON files (→ parser.py)
• parser populates internal data structures → serviceDiscovery
• serviceDiscovery triggers Scapy calls → raw SOME/IP packets
• Packets exit via OS network stack → VLAN-tagged NIC → test network or ECU
• VLAN scripts run (manually or via main) to prepare the OS NIC before injection
c. Architectural Patterns & Principles
• Modular separation: orchestration vs parsing vs discovery vs packet engine
• Data-driven design: JSON configs decouple code from test scenarios
• Single responsibility: each module has one clear function
d. Key Technologies & Libraries
• Python 3.x
• Scapy for packet construction & sniffing
• JSON for configuration
• Bash for VLAN network setup