├── .gitignore ├── LICENSE ├── README.md ├── RELEASE-NOTES.txt ├── build.gradle ├── gradle-run.sh ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── setversion.sh └── src ├── main ├── dist │ ├── EMS.properties │ ├── EMS.uds │ ├── TCU.properties │ ├── TCU.uds │ ├── gateway.properties │ ├── log4j2.xml │ ├── standard.uds │ └── start.sh └── java │ └── doip │ └── custom │ └── simulation │ ├── CustomEcu.java │ ├── CustomGateway.java │ └── Main.java └── test └── java └── doip └── custom └── simulation └── TestTemplate.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | /.classpath 7 | /.project 8 | /.settings/ 9 | /bin/ 10 | doip-simulation.log 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DoIP Custom Simulation 2 | This repository implements a DoIP simulation based on ISO 13400. It can be 3 | seen as an example how to implement a DoIP simulation. Please feel free 4 | to create a copy ofthis repository and adapt it to your needs. 5 | 6 | # Build 7 | The project used Gradle to build the software. The repository already includes 8 | the so called "Gradle Wrapper", so there is no need to install Gradle to 9 | build the project. The Gradle build tool will be automatically downloaded 10 | on the first build. 11 | 12 | To build the project run in a command line the following command: 13 | 14 | ./gradlew build 15 | 16 | This includes also execution of the unit tests. The result of the unit tests 17 | can be found in the folder build/reports/tests/test/ 18 | 19 | The JAR file which had been build can be found in folder build/libs 20 | 21 | The distribution package of the project can be found in folder 22 | build/distributions. This ZIP file or TAR file can be seen as a package what 23 | you can publish to the users to run the DoIP simulaton. 24 | 25 | With the following command the distribution will be unpacked and provides 26 | a setup where the simulation can be started directly: 27 | 28 | ./gradlew installDist 29 | 30 | The unpacked distribution can then be found in the folder 31 | build/install/doip-simulation/ 32 | 33 | This folder contains the shell script start.sh. Just run the script from the 34 | command line and pass as first argument a property file which includes the 35 | settings for the DoIP simulation. As an example there is the property file 36 | gateway.properties. Inside this file there are additional comments 37 | which describe each setting. 38 | 39 | The distribution contains the compiled JAR file for the custom DoIP 40 | simulation and its dependencies. In addition all files which are located in 41 | the folder src/main/dist will also be added to the distribution. 42 | 43 | # Open Issues 44 | * The settings for maxByteArraySizeLogging and maxByteArraySizeLookup are 45 | not yet used everywhere in the code 46 | * There are still some TODOs in the source code. Please check source code 47 | for TODOs. 48 | 49 | # Contact 50 | In case of finding bugs, suggestions for improvement or change requests 51 | please contact doip@wehnert.com 52 | 53 | 54 | -------------------------------------------------------------------------------- /RELEASE-NOTES.txt: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | 3 | DoIP - Diagnostics over IP 4 | Component: DoIP Custom Simulation 5 | 6 | ============================================================================== 7 | 8 | INTRODUCTION 9 | ============ 10 | The "DoIP Custom Simulation" is an executable Java program to simulate 11 | a DoIP gateway. This project can be seen as an example how to create 12 | a custom simulation. 13 | 14 | The source code is hosted at GitHub 15 | https://github.com/doip/doip-custom-simulation.git 16 | 17 | ============================================================================== 18 | 19 | Release Notes for Version: 1.2.0 20 | 21 | CHANGES 22 | ======= 23 | 24 | - Issue #25: Update to newer versins of dependencies 25 | 26 | - Issue #23: Fixed building problem 27 | 28 | - Issue #22: Update comments in config files 29 | 30 | ============================================================================== 31 | 32 | Release Notes for Version: 1.1.5 33 | 34 | NEW FEATURES 35 | ============ 36 | 37 | - Issue #18: Update reference to doip-simulation-1.4.1 and 38 | doip-junit-1.0.11 39 | 40 | - Issue #13: Integration of new doip-simulation-1.4.0. See release notes 41 | from doip-simulation-1.4.0 42 | 43 | - Issue #14: Adapt simulation files. The simulation will be tested 44 | within the project doip-tester. Therefore the simulation 45 | files need to match the expected result in the doip-tester. 46 | 47 | ============================================================================== 48 | 49 | Release Notes for Version: 1.1.4 50 | 51 | NEW FEATURES 52 | ============ 53 | 54 | - Issue #10: Integration of new doip-simulation and its dependencies: 55 | Gateway will now send announcement message at start up. 56 | Therefore two new properties had been added to property file 57 | 58 | - broadcast.address: Address to which the broadcast VAM will 59 | send to. 60 | - broadcast.enable: Can be set to true or false, it will control 61 | if initial VAM will be send out. 62 | 63 | FIXED BUGS 64 | ========== 65 | 66 | n/a 67 | 68 | CHANGES 69 | ======= 70 | 71 | n/a 72 | 73 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // doip-custom-simulation 2 | 3 | plugins { 4 | id 'java-library' 5 | id 'jacoco' 6 | id 'distribution' 7 | id 'eclipse' 8 | } 9 | 10 | group = 'com.github.com' 11 | version = '2.0.0' 12 | 13 | repositories { 14 | mavenCentral() 15 | maven { url 'https://jitpack.io' } 16 | } 17 | 18 | dependencies { 19 | implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.19.0' 20 | implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.19.0' 21 | 22 | implementation 'com.github.doip:doip-simulation-api:1.1.0' 23 | implementation 'com.github.doip:doip-simulation:2.0.0' 24 | implementation 'com.github.doip:doip-library:2.0.0' 25 | 26 | testImplementation 'com.github.starcode88:starcode88-jtest:1.2.1' 27 | 28 | testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' 29 | } 30 | 31 | jar { 32 | manifest { 33 | attributes ( 34 | 'Main-Class' : 'doip.custom.simulation.Main', 35 | 'Class-Path' : configurations.runtimeClasspath.collect { it.getName() }.join(' ') 36 | ) 37 | } 38 | } 39 | 40 | test { 41 | useJUnitPlatform() 42 | systemProperty 'log4j.configurationFile', 'src/main/dist/log4j2.xml' 43 | reports { 44 | junitXml { 45 | outputPerTestCase = true // defaults to false 46 | //mergeReruns = true // defaults to false 47 | } 48 | } 49 | } 50 | 51 | 52 | distributions { 53 | main { 54 | contents { 55 | into ('libs') { 56 | from (jar) 57 | from (configurations.runtimeClasspath) 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /gradle-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./gradlew run --args="src/main/dist/gateway.properties" 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doip/doip-custom-simulation/5953760a0df3512b2e20362c68845689c97c4734/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Use the maximum available, or set MAX_FD != -1 to use that value. 89 | MAX_FD=maximum 90 | 91 | warn () { 92 | echo "$*" 93 | } >&2 94 | 95 | die () { 96 | echo 97 | echo "$*" 98 | echo 99 | exit 1 100 | } >&2 101 | 102 | # OS specific support (must be 'true' or 'false'). 103 | cygwin=false 104 | msys=false 105 | darwin=false 106 | nonstop=false 107 | case "$( uname )" in #( 108 | CYGWIN* ) cygwin=true ;; #( 109 | Darwin* ) darwin=true ;; #( 110 | MSYS* | MINGW* ) msys=true ;; #( 111 | NONSTOP* ) nonstop=true ;; 112 | esac 113 | 114 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 115 | 116 | 117 | # Determine the Java command to use to start the JVM. 118 | if [ -n "$JAVA_HOME" ] ; then 119 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 120 | # IBM's JDK on AIX uses strange locations for the executables 121 | JAVACMD=$JAVA_HOME/jre/sh/java 122 | else 123 | JAVACMD=$JAVA_HOME/bin/java 124 | fi 125 | if [ ! -x "$JAVACMD" ] ; then 126 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 127 | 128 | Please set the JAVA_HOME variable in your environment to match the 129 | location of your Java installation." 130 | fi 131 | else 132 | JAVACMD=java 133 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 134 | 135 | Please set the JAVA_HOME variable in your environment to match the 136 | location of your Java installation." 137 | fi 138 | 139 | # Increase the maximum file descriptors if we can. 140 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 141 | case $MAX_FD in #( 142 | max*) 143 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 144 | # shellcheck disable=SC3045 145 | MAX_FD=$( ulimit -H -n ) || 146 | warn "Could not query maximum file descriptor limit" 147 | esac 148 | case $MAX_FD in #( 149 | '' | soft) :;; #( 150 | *) 151 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 152 | # shellcheck disable=SC3045 153 | ulimit -n "$MAX_FD" || 154 | warn "Could not set maximum file descriptor limit to $MAX_FD" 155 | esac 156 | fi 157 | 158 | # Collect all arguments for the java command, stacking in reverse order: 159 | # * args from the command line 160 | # * the main class name 161 | # * -classpath 162 | # * -D...appname settings 163 | # * --module-path (only if needed) 164 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 165 | 166 | # For Cygwin or MSYS, switch paths to Windows format before running java 167 | if "$cygwin" || "$msys" ; then 168 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 169 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 170 | 171 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 172 | 173 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 174 | for arg do 175 | if 176 | case $arg in #( 177 | -*) false ;; # don't mess with options #( 178 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 179 | [ -e "$t" ] ;; #( 180 | *) false ;; 181 | esac 182 | then 183 | arg=$( cygpath --path --ignore --mixed "$arg" ) 184 | fi 185 | # Roll the args list around exactly as many times as the number of 186 | # args, so each arg winds up back in the position where it started, but 187 | # possibly modified. 188 | # 189 | # NB: a `for` loop captures its iteration list before it begins, so 190 | # changing the positional parameters here affects neither the number of 191 | # iterations, nor the values presented in `arg`. 192 | shift # remove old arg 193 | set -- "$@" "$arg" # push replacement arg 194 | done 195 | fi 196 | 197 | 198 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 199 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 200 | 201 | # Collect all arguments for the java command; 202 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 203 | # shell script including quotes and variable substitutions, so put them in 204 | # double quotes to make sure that they get re-expanded; and 205 | # * put everything else in single quotes, so that it's not re-expanded. 206 | 207 | set -- \ 208 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 209 | -classpath "$CLASSPATH" \ 210 | org.gradle.wrapper.GradleWrapperMain \ 211 | "$@" 212 | 213 | # Stop when "xargs" is not available. 214 | if ! command -v xargs >/dev/null 2>&1 215 | then 216 | die "xargs is not available" 217 | fi 218 | 219 | # Use "xargs" to parse quoted args. 220 | # 221 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 222 | # 223 | # In Bash we could simply go: 224 | # 225 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 226 | # set -- "${ARGS[@]}" "$@" 227 | # 228 | # but POSIX shell has neither arrays nor command substitution, so instead we 229 | # post-process each arg (as a line of input to sed) to backslash-escape any 230 | # character that might be a shell metacharacter, then use eval to reverse 231 | # that process (while maintaining the separation between arguments), and wrap 232 | # the whole thing up as a single "set" statement. 233 | # 234 | # This will of course break if any of these variables contains a newline or 235 | # an unmatched quote. 236 | # 237 | 238 | eval "set -- $( 239 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 240 | xargs -n1 | 241 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 242 | tr '\n' ' ' 243 | )" '"$@"' 244 | 245 | exec "$JAVACMD" "$@" 246 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'doip-custom-simulation' 2 | -------------------------------------------------------------------------------- /setversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | version=$1 4 | 5 | if [ -z "$version" ] 6 | then 7 | echo "ERROR: Missing argument " 8 | exit 1 9 | fi 10 | 11 | # Modify build.gradle 12 | sed -i s/'version.*=.*'/'version = '\'"$version"\'/g build.gradle 13 | 14 | sed -i s/'doip-custom-simulation-.*'.'.*'.'.*'.jar/'doip-custom-simulation-'$version'.jar'/g src/main/dist/start.sh 15 | 16 | -------------------------------------------------------------------------------- /src/main/dist/EMS.properties: -------------------------------------------------------------------------------- 1 | # Name of the ECU, will be used for logging 2 | name=EMS 3 | 4 | # Physical address of the ECU 5 | address.physical=0xE001 6 | 7 | # Functional address of the ECU (not used at the moment) 8 | address.functional=0xE400 9 | 10 | # List of lookup files for UDS messages. Multiple files need to be separated by a semicolon. 11 | uds.files=standard.uds;EMS.uds -------------------------------------------------------------------------------- /src/main/dist/EMS.uds: -------------------------------------------------------------------------------- 1 | # Define here some request/response pairs for ECU specific responses -------------------------------------------------------------------------------- /src/main/dist/TCU.properties: -------------------------------------------------------------------------------- 1 | # See file EMS.properties for description of parameters 2 | name=TCU 3 | address.physical=0xE002 4 | address.functional=0xE400 5 | uds.files=standard.uds;TCU.uds -------------------------------------------------------------------------------- /src/main/dist/TCU.uds: -------------------------------------------------------------------------------- 1 | # Define here some request/response pairs for ECU specific responses -------------------------------------------------------------------------------- /src/main/dist/gateway.properties: -------------------------------------------------------------------------------- 1 | # Name of the gateway. It will be used for logging 2 | name = GW 3 | 4 | # Define here on which address the socket of the gateway will be bound to. 5 | # This might be required if your machine has multiple network addresses. 6 | # If the parameter is not set, then the gateway will receive messages 7 | # from all network interfaces 8 | # local.address = '192.168.178.20' 9 | 10 | # Defines the local port on which the gateway is listening. 11 | # For DoIP it is always 13400 12 | local.port = 13400 13 | 14 | # Broadcast address to which the vehicle announcement message will be sent 15 | broadcast.address = 255.255.255.255 16 | 17 | # Enable broadcast at startup 18 | broadcast.enable = true 19 | 20 | # Defines the maximum number of bytes of a message which will be printed to log files 21 | # If a message is longer it will be logged at the end with ... 22 | # With this performance can be increased because logging very long messages takes time. 23 | maxByteArraySize.logging = 64 24 | 25 | # Defines the maximum number of bytes which will be used for lookup tables 26 | # It takes long time to check regular expressions if messages are very long 27 | maxByteArraySize.lookup = 16 28 | 29 | # Entity ID of the gateway 30 | eid = E1 E2 E3 E4 E5 E6 31 | 32 | # Group ID of the gateway 33 | gid = A1 A2 A3 A4 A5 A6 34 | 35 | # VIN number as hex bytes 36 | vin.hex = 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 37 | 38 | # Logical address of the gateway 39 | logicalAddress = 0xE000 40 | 41 | # List of configuration files for the ECUs. The path to that files is relative from this file. 42 | # Multiple files need to be separated by a semicolon. 43 | ecu.files=EMS.properties;TCU.properties 44 | -------------------------------------------------------------------------------- /src/main/dist/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/main/dist/standard.uds: -------------------------------------------------------------------------------- 1 | # This file defines request/response pairs for UDS messages 2 | # Request and response are separated by a colon (:) 3 | # Spaces can be added between the characters, they will 4 | # be removed by the software before evaluating an expression. 5 | # The request will be treated as a Java regular expression. 6 | # The response must be a hex string, that means only characters 7 | # from 0-9 and A-F are allowed. 8 | 9 | ############################### 10 | # Service 0x10 # 11 | ############################### 12 | 13 | 10 01 : 50 01 00 32 01 F4 14 | 10 02 : 50 02 00 32 01 F4 15 | 10 03 : 50 03 00 32 01 F4 16 | 10 \w\w : 7F 10 10 17 | 18 | ############################### 19 | # Service 0x3E # 20 | ############################### 21 | 22 | 3E 00 : 7E 00 23 | 3E 80 : 24 | -------------------------------------------------------------------------------- /src/main/dist/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java -Dlog4j.configurationFile="log4j2.xml" -jar libs/doip-custom-simulation-2.0.0.jar "$@" 4 | -------------------------------------------------------------------------------- /src/main/java/doip/custom/simulation/CustomEcu.java: -------------------------------------------------------------------------------- 1 | package doip.custom.simulation; 2 | 3 | import doip.library.message.UdsMessage; 4 | import doip.simulation.EcuConfig; 5 | import doip.simulation.standard.StandardEcu; 6 | 7 | public class CustomEcu extends StandardEcu { 8 | 9 | public CustomEcu(EcuConfig config) { 10 | super(config); 11 | } 12 | 13 | @Override 14 | public boolean processRequestBeforeLookupTable(UdsMessage udsRequest) { 15 | // Here you can add some special handling for a UDS message 16 | // before the message will be handled by searching patterns 17 | // in the lookup table. 18 | 19 | // Return false means that message was not handled in this 20 | // function and that processing message shall be 21 | // continued by further functions (lookup table, normal message interpretation) 22 | 23 | return false; 24 | } 25 | 26 | @Override 27 | public boolean processRequestAfterLookupTable(UdsMessage request) { 28 | // If a message was not handled by the lookup table then message 29 | // processing will be handled within this function. 30 | 31 | // Default handling will be to send negative response with NRC 0x10 32 | return super.processRequestAfterLookupTable(request); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/doip/custom/simulation/CustomGateway.java: -------------------------------------------------------------------------------- 1 | package doip.custom.simulation; 2 | 3 | import doip.simulation.EcuConfig; 4 | import doip.simulation.GatewayConfig; 5 | import doip.simulation.standard.StandardEcu; 6 | import doip.simulation.standard.StandardGateway; 7 | 8 | public class CustomGateway extends StandardGateway { 9 | 10 | public CustomGateway(GatewayConfig config) { 11 | super(config); 12 | } 13 | 14 | @Override 15 | public StandardEcu createEcu(EcuConfig config) { 16 | return new CustomEcu(config); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/doip/custom/simulation/Main.java: -------------------------------------------------------------------------------- 1 | package doip.custom.simulation; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.util.LinkedList; 7 | 8 | import doip.library.exception.DoipException; 9 | import doip.library.properties.EmptyPropertyValue; 10 | import doip.library.properties.MissingProperty; 11 | import doip.simulation.GatewayConfig; 12 | 13 | public class Main { 14 | 15 | public static void main(String[] args) throws DoipException, MissingProperty, EmptyPropertyValue, IOException { 16 | 17 | boolean interactive = false; 18 | LinkedList propertyFiles = new LinkedList(); 19 | 20 | for (int i = 0; i < args.length; i++) { 21 | if ("-i".equals(args[i]) || "--interactive".equals(args[i])) { 22 | interactive = true; 23 | } else { 24 | propertyFiles.add(args[i]); 25 | } 26 | } 27 | 28 | if (propertyFiles.size() == 0) { 29 | System.out.println("No argument for property file was given."); 30 | System.exit(1); 31 | } 32 | 33 | 34 | int numberOfGateways = propertyFiles.size(); 35 | GatewayConfig configs[] = new GatewayConfig[numberOfGateways]; 36 | CustomGateway gateways[] = new CustomGateway[numberOfGateways]; 37 | 38 | int i = 0; 39 | for (String propertyFile : propertyFiles) { 40 | configs[i] = new GatewayConfig(); 41 | System.out.println("Load gateway configuration \"" + propertyFile + "\""); 42 | configs[i].loadFromFile(propertyFile); 43 | i++; 44 | } 45 | 46 | for (i = 0; i to terminate simulation"); 58 | reader.readLine(); 59 | } else { 60 | for(;;) { 61 | try { 62 | Thread.sleep(60000); 63 | } catch (InterruptedException e) { 64 | } 65 | } 66 | } 67 | 68 | for (i = 0; i < numberOfGateways; i++) { 69 | gateways[i].stop(); 70 | } 71 | System.out.println("... DoIP simulation finished."); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/doip/custom/simulation/TestTemplate.java: -------------------------------------------------------------------------------- 1 | package doip.custom.simulation; 2 | 3 | import org.junit.jupiter.api.BeforeAll; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.AfterEach; 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.junit.jupiter.api.AfterAll; 9 | import org.junit.jupiter.api.Test; 10 | 11 | /** 12 | * Template class for unit tests using junit. 13 | * It is required that the Java system property "log4j.configurationFile" needs to be set, 14 | * otherwise you will not see any log messages. 15 | */ 16 | public class TestTemplate { 17 | 18 | private static Logger logger = LogManager.getLogger(TestTemplate.class); 19 | 20 | @BeforeAll 21 | public static void setUpBeforeClass() throws Exception { 22 | logger.info("-----------------------------------------------------------------------------"); 23 | logger.info(">>> public static void setUpBeforeClass()"); 24 | 25 | // TODO: Implement me 26 | 27 | logger.info("<<< public static void setUpBeforeClass()"); 28 | logger.info("-----------------------------------------------------------------------------"); 29 | } 30 | 31 | @AfterAll 32 | public static void tearDownAfterClass() throws Exception { 33 | logger.info("-----------------------------------------------------------------------------"); 34 | logger.info(">>> public static void tearDownAfterClass()"); 35 | 36 | // TODO: Implement me 37 | 38 | logger.info("<<< public static void tearDownAfterClass()"); 39 | logger.info("-----------------------------------------------------------------------------"); 40 | } 41 | 42 | @BeforeEach 43 | public void setUp() throws Exception { 44 | logger.info("-----------------------------------------------------------------------------"); 45 | logger.info(">>> public void setUp()"); 46 | 47 | // TODO: Implement me 48 | 49 | logger.info("<<< public void setUp()"); 50 | logger.info("-----------------------------------------------------------------------------"); 51 | } 52 | 53 | @AfterEach 54 | public void tearDown() throws Exception { 55 | logger.info("-----------------------------------------------------------------------------"); 56 | logger.info(">>> public void tearDown()"); 57 | 58 | // TODO: Implement me 59 | 60 | logger.info("<<< public void tearDown()"); 61 | logger.info("-----------------------------------------------------------------------------"); 62 | } 63 | 64 | @Test 65 | public void test() { 66 | logger.info("#############################################################################"); 67 | logger.info(">>> test()"); 68 | 69 | // TODO: Implement me 70 | 71 | logger.info("<<< test()"); 72 | logger.info("#############################################################################"); 73 | } 74 | 75 | } 76 | --------------------------------------------------------------------------------