Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 627ca23

Browse files
authored
Initial version (#1)
1 parent 2260a69 commit 627ca23

File tree

454 files changed

+141162
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

454 files changed

+141162
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ install_manifest.txt
99
compile_commands.json
1010
CTestTestfile.cmake
1111
_deps
12+
.idea/
13+
cmake-build-*/

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
set(CMAKE_CXX_STANDARD 20)
3+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
5+
project(imkcpp_root)
6+
7+
option(ENABLE_ASAN "Enable Address Sanitizer" ON)
8+
9+
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ENABLE_ASAN)
10+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
11+
message(FATAL_ERROR "Address Sanitizer is only supported by Clang")
12+
endif()
13+
14+
message(STATUS "Enabling Address Sanitizer")
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
17+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
18+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
19+
endif()
20+
21+
add_subdirectory(tests)
22+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
23+
add_subdirectory(benchmarks)
24+
endif()

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# imkcpp
2-
C++ implementation of KCP protocol with improvements ontop
2+
C++20 header-only implementation of KCP protocol with improvements ontop
3+
4+
# Why?
5+
- Upstream implementation is written in C and is hard to read and modify
6+
- Upstream implementation has type issues and depends on undefined behavior and compiler luck
7+
- Upstream implementation is missing several key features like knowing max packet size
8+
- Upstream implementation is poorly documented leaving users to guess how to use it and what parameters mean
9+
- Upstream repository seems to be abandoned (last release was 2020)
10+
- Upstream repository has no practical tests and benchmarks
11+
- Upstream repository has unmerged bugfixes like [this one](https://github.com/skywind3000/kcp/pull/291)
12+
13+
# Is this compatible with original KCP?
14+
Yes and no. At the current state, this implementation is compatible with original KCP on the byte level, however, window calculation for transmission has been changed, alongside with possible future updates breaking compatibility. Use with original KCP only at your own risk.
15+
16+
# How to use
17+
- Copy `imkcpp/include` to your project
18+
- Include `imkcpp.hpp` in your source code
19+
- Create and use `imkcpp::ImKcpp<size_t MTU>` object as you would use `ikcp` object
20+
21+
# Special thanks
22+
- [skywind3000](https://github.com/skywind3000) for the original [kcp](https://github.com/skywind3000/kcp) implementation
23+
- [TartanLlama](https://github.com/TartanLlama) for the [unexpected](https://github.com/TartanLlama/expected) implementation

benchmarks/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
set(CMAKE_CXX_STANDARD 20)
3+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
5+
project(imkcpp_benchmarks)
6+
7+
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORCE)
8+
9+
add_subdirectory(lib)
10+
11+
add_executable(imkcpp_benchmarks
12+
dummy.cpp
13+
)
14+
15+
include_directories(${CMAKE_SOURCE_DIR}/imkcpp/include)
16+
target_link_libraries(imkcpp_benchmarks benchmark::benchmark)

benchmarks/dummy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main() {
2+
return 0;
3+
}

benchmarks/lib/.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
PointerAlignment: Left
5+
...

benchmarks/lib/.clang-tidy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Checks: 'clang-analyzer-*,readability-redundant-*,performance-*'
3+
WarningsAsErrors: 'clang-analyzer-*,readability-redundant-*,performance-*'
4+
HeaderFilterRegex: '.*'
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: none
7+
User: user
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**System**
14+
Which OS, compiler, and compiler version are you using:
15+
- OS:
16+
- Compiler and version:
17+
18+
**To reproduce**
19+
Steps to reproduce the behavior:
20+
1. sync to commit ...
21+
2. cmake/bazel...
22+
3. make ...
23+
4. See error
24+
25+
**Expected behavior**
26+
A clear and concise description of what you expected to happen.
27+
28+
**Screenshots**
29+
If applicable, add screenshots to help explain your problem.
30+
31+
**Additional context**
32+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[FR]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if ! bazel version; then
2+
arch=$(uname -m)
3+
if [ "$arch" == "aarch64" ]; then
4+
arch="arm64"
5+
fi
6+
echo "Installing wget and downloading $arch Bazel binary from GitHub releases."
7+
yum install -y wget
8+
wget "https://github.com/bazelbuild/bazel/releases/download/6.3.0/bazel-6.3.0-linux-$arch" -O /usr/local/bin/bazel
9+
chmod +x /usr/local/bin/bazel
10+
else
11+
# bazel is installed for the correct architecture
12+
exit 0
13+
fi

0 commit comments

Comments
 (0)