Skip to content
Open

3.0 #82

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
4f65e7e
wip
nathhB Aug 10, 2024
76a675a
wip
nathhB Sep 11, 2024
eda66ce
wip
nathhB Oct 19, 2024
dbb49b4
wip
nathhB Oct 3, 2025
d0c91ae
rework message system
nathhB Oct 25, 2025
fd36320
remove client table, fix msg id issue
nathhB Nov 1, 2025
0f94517
3.0 wip
nathhB Dec 8, 2025
7b09fa8
refine API, custom message allocation
Jan 24, 2026
106a3ad
inlude nbnet.h in drivers
Jan 25, 2026
162969c
statically allocated messages
Jan 25, 2026
07a7753
move code around
Jan 25, 2026
9424054
update nbnet api
Jan 27, 2026
164d8d8
update examples
Jan 27, 2026
caa187f
update soak test
Jan 27, 2026
49d4a38
update drivers
Jan 27, 2026
84d136c
fix issues with net drivers
nathhB Jan 27, 2026
d0c5990
Merge branch 'master' into 3.0
nathhB Jan 27, 2026
d1cddeb
fix examples cmake file
nathhB Jan 27, 2026
d9c8252
fix unit tests
nathhB Jan 27, 2026
58c5d7a
include arpa/inet.h
nathhB Jan 27, 2026
8ad25c9
attempt to fix cpp compilation issues
nathhB Jan 27, 2026
0c5a3d2
fix more cpp issues
nathhB Jan 27, 2026
e8d3bc1
remive wincrypt.h, fix FreeBSD issue
nathhB Jan 28, 2026
fd852c3
include winsock2.h before windows.h
nathhB Jan 28, 2026
6a193c4
fix windows name collision
nathhB Jan 28, 2026
0cd0eb9
define WIN32_LEAN_AND_MEAN on windows
nathhB Jan 28, 2026
10134d2
prevent winnt.h inclusion
nathhB Jan 28, 2026
97bdb65
define WIN32_LEAN_AND_MEAN in the right place
nathhB Jan 28, 2026
e351a29
fix webrtc js driver
nathhB Jan 28, 2026
642fa46
fix get time when compiling with emscripten
nathhB Jan 28, 2026
9144a2b
remove experimental arguments from node commands
nathhB Jan 28, 2026
814bb35
update npm dependencies
nathhB Jan 28, 2026
b91aaef
fix issue in webrtc driver js code
nathhB Jan 28, 2026
989e04d
fix run soak pipeline script
nathhB Jan 28, 2026
815f2c9
WIP: rework driver architecture
nathhB Jan 29, 2026
3a96955
WIP: re-organize library
nathhB Jan 30, 2026
b3c41af
fix issue with unreliable channel
nathhB Jan 30, 2026
85acfc7
rework API wip
nathhB Feb 6, 2026
f3331e4
remove driver events
Feb 6, 2026
6fb1b7a
use strsep for ip address parsing
Feb 6, 2026
1db2281
reintroduce *CreateReliableMessage and *CreateUnreliableMessage funct…
nathhB Feb 6, 2026
1ca4bff
update echo example
nathhB Feb 6, 2026
0fa1cf9
rework logging
Feb 7, 2026
50b3aea
fix issue with connection user data
Feb 7, 2026
bb2f43f
update raylib example
Feb 7, 2026
567d0d2
update soak test
Feb 7, 2026
ca2bd16
pipelines: enable udp driver for soak tests
Feb 7, 2026
d4f4ec5
fix some windows compilation errors
Feb 8, 2026
bea84b9
fixes
Feb 8, 2026
2acfb40
pipelines: compile examples with UDP driver
Feb 8, 2026
a44fa4d
reintroduce webrtc emscripten driver
Feb 8, 2026
7c95abd
fix packet simulator
Feb 8, 2026
2a85873
fix channel mode config
Feb 8, 2026
f8ff567
add serialization functions
nathhB Feb 9, 2026
2070fc1
replace non-standard htonll and ntohll
Feb 11, 2026
3d45b5a
organization stuff
Feb 11, 2026
6201a16
add extern "C" when compiling as cpp
Feb 11, 2026
7a6220e
webrtc native wip
Feb 14, 2026
9274b89
webrtc native driver
nathhB Feb 14, 2026
35bd6ff
plug in webrtc native driver
nathhB Feb 14, 2026
3d53894
remove net_drivers folder
nathhB Feb 14, 2026
3bb6d76
fix soak cmake script
nathhB Feb 14, 2026
c4dd73c
move webrtc js code in webrtc folder
nathhB Feb 14, 2026
fe2e50d
fix webrtc native driver
nathhB Feb 14, 2026
93e0ccb
fix soak webrtc native
nathhB Feb 14, 2026
5d0e390
update webrtc native pipeline
nathhB Feb 14, 2026
3c63051
fix pipelines
nathhB Feb 14, 2026
72e9da0
readd webrtc js code removed by mistake
nathhB Feb 14, 2026
2f96007
add serialization functions
nathhB Feb 14, 2026
6e02adf
fix conn stale if empty packets + log formatting
nathhB Feb 15, 2026
b1fda6a
update echo example
nathhB Feb 15, 2026
ee4c9d7
rework channel configuration
nathhB Mar 6, 2026
54f7b29
fix bug in packet reading code
nathhB Mar 6, 2026
2f7fd86
include time.h in soak test
Mar 7, 2026
d5f91f7
fix soak test compilation
Mar 7, 2026
42f910c
increase msg count to 5000 in soak test pipeline
nathhB Mar 13, 2026
d26d258
simplify API
nathhB Mar 13, 2026
5e065fc
improve channel capacity check
nathhB Mar 13, 2026
f9ae635
take channel capacity into account in soak test
nathhB Mar 13, 2026
539952e
fix examples
nathhB Mar 13, 2026
1044494
remove incorrect asserts
nathhB Mar 27, 2026
4208d3c
rename stuff and fix warnings
nathhB Apr 6, 2026
210a4c5
remove global state, update API
nathhB Apr 8, 2026
893f6f6
fix emscripten driver issues
nathhB Apr 8, 2026
4b312b1
remove usage of static variables
nathhB Apr 12, 2026
505acec
fix segfault: initialize server->clients to NULL
nathhB Apr 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions .github/workflows/nbnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
cd tests
cmake -G "NMake Makefiles" .
nmake
# FIXME: string_tests hangs forever
# - name: Run tests
# run: ctest

soak-test-linux-c:
runs-on: ubuntu-latest
Expand All @@ -67,7 +64,7 @@ jobs:
cd soak
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_BUILD_TYPE=Debug -DUDP=ON ..
make
- name: Run soak test
run: timeout 240 ./bin/github-actions/run_soak.sh
Expand All @@ -83,7 +80,7 @@ jobs:
cd soak
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCPP_COMPILE=ON ..
cmake -DCMAKE_BUILD_TYPE=Debug -DUDP=ON -DCPP_COMPILE=ON ..
make
- name: Run soak test
run: timeout 240 ./bin/github-actions/run_soak.sh
Expand All @@ -101,7 +98,7 @@ jobs:
npm update
npm install -g node-pre-gyp
npm install -g node-gyp
cd net_drivers/webrtc
cd webrtc
npm install --build-from-resource
- name: Compile soak test
run: ./bin/github-actions/build_soak_web.sh
Expand All @@ -123,7 +120,7 @@ jobs:
cd soak
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_BUILD_TYPE=Debug -DUDP=ON ..
make
- name: Run soak test
run: gtimeout 240 ./bin/github-actions/run_soak.sh
Expand All @@ -139,7 +136,7 @@ jobs:
cd soak
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCPP_COMPILE=ON ..
cmake -DCMAKE_BUILD_TYPE=Debug -DUDP=ON -DCPP_COMPILE=ON ..
make
- name: Run soak test
run: gtimeout 240 ./bin/github-actions/run_soak.sh
Expand All @@ -157,7 +154,7 @@ jobs:
npm update
npm install -g node-pre-gyp
npm install -g node-gyp
cd net_drivers/webrtc
cd webrtc
npm install --build-from-resource
- name: Compile soak test
run: ./bin/github-actions/build_soak_web.sh
Expand All @@ -178,7 +175,7 @@ jobs:
cd soak
mkdir build
cd build
cmake -G "NMake Makefiles" ..
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DUDP=ON ..
nmake
- name: Run soak test
run: ./bin/github-actions/run_soak.sh
Expand All @@ -198,14 +195,16 @@ jobs:
npm update
npm install -g node-pre-gyp
npm install -g node-gyp
cd net_drivers/webrtc
cd webrtc
npm install --build-from-resource
- name: Compile soak test (native)
run: |
cd soak
mkdir build
cd build
cmake -DLIBDATACHANNEL_LIBRARY_PATH=${{ github.workspace }}/libdatachannel/build/libdatachannel.so -DLIBDATACHANNEL_INCLUDE_PATH=${{ github.workspace }}/libdatachannel/include -DWEBRTC_NATIVE=ON ..
cmake -DLIBDATACHANNEL_LIBRARY_PATH=${{ github.workspace }}/libdatachannel/build/libdatachannel.so \
-DLIBDATACHANNEL_INCLUDE_PATH=${{ github.workspace }}/libdatachannel/include \
-DWEBRTC_NATIVE=ON -DUDP=ON -DCMAKE_BUILD_TYPE=Debug ..
make
- name: Compile soak test (web)
run: ./bin/github-actions/build_soak_web.sh
Expand All @@ -216,7 +215,7 @@ jobs:
cd ..
WEBRTC_NATIVE=1 timeout 240 ./bin/github-actions/run_soak.sh

compile-examples-linux-c:
compile-examples-udp-linux-c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -225,10 +224,10 @@ jobs:
- name: Compile examples
run: |
cd examples
cmake .
cmake -DEXAMPLES_UDP=ON .
make

compile-examples-linux-cpp:
compile-examples-udp-linux-cpp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -237,10 +236,10 @@ jobs:
- name: Compile examples
run: |
cd examples
cmake -DCPP_COMPILE=ON .
cmake -DEXAMPLES_UDP=ON -DCPP_COMPILE=ON .
make

compile-examples-osx-c:
compile-examples-udp-osx-c:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -249,10 +248,10 @@ jobs:
- name: Compile examples
run: |
cd examples
cmake .
cmake -DEXAMPLES_UDP=ON .
make

compile-examples-osx-cpp:
compile-examples-udp-osx-cpp:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -261,27 +260,27 @@ jobs:
- name: Compile examples
run: |
cd examples
cmake -DCPP_COMPILE=ON .
cmake -DEXAMPLES_UDP=ON -DCPP_COMPILE=ON .
make

compile-examples-windows-c:
compile-examples-udp-windows-c:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- name: Compile examples
run: |
cd examples
cmake -G "NMake Makefiles" .
cmake -G "NMake Makefiles" -DEXAMPLES_UDP=ON .
nmake

compile-examples-windows-cpp:
compile-examples-udp-windows-cpp:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- name: Compile examples
run: |
cd examples
cmake -G "NMake Makefiles" -DCPP_COMPILE=ON .
cmake -G "NMake Makefiles" -DEXAMPLES_UDP=ON -DCPP_COMPILE=ON .
nmake
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.js
*.wasm
.vscode
.ccls
Expand All @@ -18,3 +17,7 @@ _deps
build
build_web
.DS_Store
.clangd
.clang-format
.cache
compile_flags.txt
2 changes: 1 addition & 1 deletion bin/github-actions/build_soak_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source ./emsdk_env.sh
cd ../soak
mkdir build_web
cd build_web
emcmake cmake ..
emcmake cmake -DCMAKE_BUILD_TYPE=Debug ..
make
cd ..
npm install
132 changes: 62 additions & 70 deletions bin/github-actions/run_soak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,87 @@ PACKET_DUPLICATION=0.2
PING=0.15
JITTER=0.1
CHANNEL_COUNT=3
MESSAGE_COUNT=500
MESSAGE_COUNT=5000
NODE_CMD="$EMSDK_NODE"

run_client () {
node_client=$1
echo "Running soak client (run in mode: $node_client)..."

if [ $node_client -eq 1 ]
then
# WASM WebRTC client
$NODE_CMD build_web/client.js --message_count=$MESSAGE_COUNT --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &> soak_cli_out
elif [ $node_client -eq 2 ]
then
# native WebRTC client
./build/client --webrtc --message_count=$MESSAGE_COUNT --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &> soak_cli_out
else
# UDP client
./build/client --message_count=$MESSAGE_COUNT --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &> soak_cli_out
fi

RESULT=$?

# when running the soak test in the latest version of emscripten with node 16
# the client aborts at the end when calling emscripten_force_exit
# I could not figure out why, hence the condition
[[ $node_client -eq 1 ]] && EXPECTED_RESULT=7 || EXPECTED_RESULT=0

if [ $RESULT -eq $EXPECTED_RESULT ]
then
echo "Soak test completed with success!"
echo "Printing the end of client logs..."

tail -n 150 soak_cli_out

return 0
else
echo "Soak test failed! (code: $RESULT)"
echo "Printing the end of client logs..."
tail -n 150 soak_cli_out
echo "Printing the end of server logs..."
tail -n 150 soak_serv_out

return 1
fi
run_client() {
client_mode=$1
echo "Running soak client (run in mode: $client_mode)..."

if [ "$client_mode" = "WEBRTC_EMSCRIPTEN" ]; then
# WASM WebRTC client
$NODE_CMD build_web/client.js --message_count=$MESSAGE_COUNT --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &>soak_cli_out
elif [ "$client_mode" = "UDP" ]; then
# UDP client
./build/client --message_count=$MESSAGE_COUNT --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &>soak_cli_out
else
echo "Unknown client mode"
return 1
fi

RESULT=$?

# when running the soak test in the latest version of emscripten with node 16
# the client aborts at the end when calling emscripten_force_exit
# I could not figure out why, hence the condition
[[ "$client_mode" = "WEBRTC_EMSCRIPTEN" ]] && EXPECTED_RESULT=7 || EXPECTED_RESULT=0

if [ $RESULT -eq $EXPECTED_RESULT ]; then
echo "Soak test completed with success!"

return 0
else
echo "Soak test failed! (code: $RESULT)"
echo "Printing the end of client logs..."
tail -n 150 soak_cli_out
echo "Printing the end of server logs..."
tail -n 150 soak_serv_out

return 1
fi
}

exit_soak () {
kill -SIGINT $SERV_PID 2> /dev/null
exit_soak() {
kill -SIGINT $SERV_PID 2>/dev/null

exit $1
exit $1
}

cd soak
echo "Starting soak server..."

if [ -n "$WEBRTC" ]
then
$NODE_CMD build_web/server.js --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &> soak_serv_out &
if [ -n "$WEBRTC" ]; then
$NODE_CMD build_web/server.js --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &>soak_serv_out &
else
./build/server --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &> soak_serv_out &
./build/server --channel_count=$CHANNEL_COUNT --packet_loss=$PACKET_LOSS --packet_duplication=$PACKET_DUPLICATION --ping=$PING --jitter=$JITTER &>soak_serv_out &
fi

if [ $? -eq 0 ]
then
SERV_PID=$!
if [ $? -eq 0 ]; then
SERV_PID=$!

echo "Server started (PID: $SERV_PID)"
echo "Running soak test..."
echo "Server started (PID: $SERV_PID)"
echo "Running soak test..."
else
echo "Failed to start soak server!"
exit 1
echo "Failed to start soak server!"
exit 1
fi

sleep 3

if [ -n "$WEBRTC" ]
then
run_client 1
if [ -n "$WEBRTC" ]; then
run_client "WEBRTC_EMSCRIPTEN"

exit_soak $?
exit_soak $?
elif [ -n "$WEBRTC_NATIVE" ]; then
# run a UDP client, a webrtc WASM client (emscripten) and a native webrtc client (all connecting to the same server)

if run_client "UDP" && run_client "WEBRTC_EMSCRIPTEN"; then
exit_soak 0
else
exit_soak 1
fi
else
if [ -n "$WEBRTC_NATIVE" ]
then
# run a UDP client, a webrtc WASM client (emscripten) and a native webrtc client (all connecting to the same server)

if run_client 0 && run_client 1 && run_client 2; then
exit_soak 0
else
exit_soak 1
fi
fi
run_client "UDP"

exit_soak $?
fi
12 changes: 6 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(nbnet_examples)

add_subdirectory(echo)
add_subdirectory(echo_bytes)
option(EXAMPLES_UDP OFF)

if (EXAMPLES_UDP)
set(UDP ON)
endif (EXAMPLES_UDP)

if (NOT DEFINED CPP_COMPILE)
# not supported in CPP
add_subdirectory(rpc)
endif (NOT DEFINED CPP_COMPILE)
add_subdirectory(echo)
Loading
Loading