A network library for client/server games written in C++

Overview

Travis Build Status Coverity Scan Build Status

yojimbo

yojimbo is a network library for client/server games written in C++.

It's designed around the networking requirements of competitive multiplayer games like first person shooters.

It has the following features:

  • Cryptographically secure authentication via connect tokens
  • Client/server connection management and timeouts
  • Encrypted and signed packets sent over UDP
  • Packet fragmentation and reassembly
  • Reliable-ordered messages and data blocks
  • Estimates of packet loss, latency and bandwidth usage

yojimbo is stable and production ready.

Source Code

You can get the latest source code by cloning it from github:

  git clone https://github.com/networkprotocol/yojimbo.git

After cloning, make sure to run this command to populate the netcode.io and reliable.io submodules:

  git submodule update --init --recursive

Alternatively, you can download one of the latest releases

Author

The author of this library is Glenn Fiedler.

Other open source libraries by the same author include: netcode and reliable

Glenn is now the founder and CEO of Network Next. Network Next is a radically new way to link networks together, it's a new internet for games, one where networks compete on performance and price to carry your game's traffic. Check it out at https://networknext.com

Sponsors

yojimbo was generously sponsored by:

And by individual supporters on Patreon. Thank you. You made this possible!

License

BSD 3-Clause license.

Comments
  • Problem with Unreal

    Problem with Unreal

    Hi Glenn, I tried to integrate libyojimbo with unreal engine, after successfuly sending/receiving message with bare windows client to linux server, it's failed doing excactling the same thing in Unreal Engine tutorial scene. I did some network sniffing with Wireshark, it's weird the client side sends 10 UDP packets of 18 bytes payload to server, and server logged with "ignored encrypted packet, no read packet key for this address", any ideas? Here's my code (in Unreal).

    // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
    
    #include "physxClient.h"
    #include "physxClientGameMode.h"
    #include "physxClientHUD.h"
    #include "physxClientCharacter.h"
    #include "../ThirdParty/libyojimbo/include/yojimbo.h"
    #include "../ThirdParty/libyojimbo/include/shared.h"
    #include <signal.h>
    
    using namespace yojimbo;
    
    AphysxClientGameMode::AphysxClientGameMode()
    	: Super()
    {
    	// set default pawn class to our Blueprinted character
    	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/FirstPersonCPP/Blueprints/FirstPersonCharacter"));
    	DefaultPawnClass = PlayerPawnClassFinder.Class;
    
    	// use our custom HUD class
    	HUDClass = AphysxClientHUD::StaticClass();
    }
    double ti = 100.0;
    
    Client* client ;
    
    void AphysxClientGameMode::StartPlay() {
    	Super::StartPlay();
    	InitializeYojimbo();
    	OgameMessageFactory messageFactory(GetDefaultAllocator());
    	uint64_t clientId = 1;
    
    	Address clientAddress("0.0.0.0", 6667);
    	Address serverAddress("192.168.0.8", 6666);
    		 
    	ClientServerConfig config;
    	config.numChannels = 1;
    	config.channel[0].type = CHANNEL_TYPE_UNRELIABLE_UNORDERED;
    
    	client = new Client(GetDefaultAllocator(), clientAddress, config, adapter, ti);
    
    	uint8_t privateKey[KeyBytes];
    	memset(privateKey, 0, KeyBytes);
    	client->InsecureConnect(privateKey, clientId, serverAddress);
    	client->AdvanceTime(ti);
    }
    
    void AphysxClientGameMode::Tick(float f) {
    	Super::Tick(f);
    	
    	const double deltaTime = 0.1;
    
    	JoinMessage* message = (JoinMessage*)(client->CreateMessage(JOIN_MESSAGE));
    	message->teamId = 1;
    	client->SendMessage(0, message);
    	client->SendPackets();
    	client->ReceivePackets();
    	ti += deltaTime;
    	client->AdvanceTime(ti);
    	//messageFactory.ReleaseMessage(message);
    
    	yojimbo_sleep(deltaTime);
    
    	return;
    }
    
    
    opened by shanyang 41
  • round trip time slowly increases?

    round trip time slowly increases?

    If you checkout a fresh copy of yojimbo and add the following to the end of the while() loop in the loopback.cpp example, you'll see the round trip time value increases slowly (screenshot attached)

    NetworkInfo networkInfo;
    client.GetNetworkInfo(networkInfo);
    printf("RTT: %f\n", networkInfo.RTT);
    

    rtt

    (This is running on windows btw)

    Max

    help wanted 
    opened by maxweisel 32
  • [server endpoint] packet too large to send. packet is 8330 bytes, maximum is 8192

    [server endpoint] packet too large to send. packet is 8330 bytes, maximum is 8192

    I spent a few hours digging through reliable.io and yojimbo source code, and I can't seem to find the cause of this error: [server endpoint] packet too large to send. packet is 8330 bytes, maximum is 8192

    As far as I can tell, yojimbo has a buffer for a single packet. When SendPackets() is called, it loops through each channel and asks it to fill the buffer up with as many messages as it can without going over the packet size limit.

    However, reliable.io seems to think it's still going over. The few times I've been able to trigger this error, it's only ever over by ~150 bytes. That seems too high for something like the header size not being taken into account, but I can't figure out what's causing it exactly.

    Any ideas?

    Max

    opened by maxweisel 28
  • Building Yojimbo with CMake and a custom Vcpkg port

    Building Yojimbo with CMake and a custom Vcpkg port

    I made a little first version of a CMake script to build Yojimbo with CMake. It works on Windows and Linux. Improvements are surely possible. However - I'm dropping it here in case someone finds it useful. If there is an interest in CMakeifying Yojimbo I'm willing to help with that and work on a PR.

    Instructions are below this comment

    Cheers

    Provided -as-is-: No guarantees whatsoever

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.16)
    
    include(FetchContent)
    
    MESSAGE(STATUS "***")
    MESSAGE(STATUS "***  Yojimbo -- START --")
    MESSAGE(STATUS "***")
    
    #############################################################
    ## Project Definition
    #############################################################
    project(Yojimbo C CXX)
    
    ############################################################
    ## Settings
    ############################################################
    
    ## Where to install yojimbo
    #SET(YOJIMBO_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/install/${CMAKE_BUILD_TYPE}")
    ## Want Tests?
    #SET(YOJIMBO_TESTS TRUE )
    ## Where to put the .git clone
    #SET( YOJIMBO_SOURCE_DIR     "${CMAKE_CURRENT_LIST_DIR}/download/yojimbo"                   )
    ## Git tag to check out. 
    ## Can be a branch ("master"), tag ("v1.2.1") or commit hash ("af30b7c3ab3329e69d0c5cfe22b7644a13e7c838")
    #SET( YOJIMBO_TAG "master")
    ## Root of your vcpkg installation
    # SET(VCPKG_ROOT "F:/vcpkg")
    
    ############################################################
    ## Derived Settings
    ############################################################
    ##
      if(NOT DEFINED YOJIMBO_INSTALL_DIR)
          SET(YOJIMBO_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} )
      endif()
      
      if(NOT DEFINED YOJIMBO_TESTS)
          SET(YOJIMBO_TESTS FALSE)
      endif()
    
      if(NOT DEFINED YOJIMBO_SOURCE_DIR)
          SET(YOJIMBO_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/download/yojimbo")
      endif()
      
      if(NOT DEFINED YOJIMBO_TAG)
          SET(YOJIMBO_TAG "master")
      endif()
    
      if(NOT DEFINED VCPKG_ROOT)
        MESSAGE(      "Cannot proceed without VCPKG_ROOT being defined. Please correct your settings.")
        MESSAGE(FATAL "You can get vcpkg from https://github.com/Microsoft/vcpkg")
      endif()
    
      ## Debug output
      MESSAGE("YOJIMBO_INSTALL_DIR = " ${YOJIMBO_INSTALL_DIR})
      MESSAGE("YOJIMBO_TESTS       = " ${YOJIMBO_TESTS})
      MESSAGE("YOJIMBO_SOURCE_DIR  = " ${YOJIMBO_SOURCE_DIR})
      MESSAGE("YOJIMBO_TAG         = " ${YOJIMBO_TAG})
      MESSAGE("VCPKG_ROOT          = " ${VCPKG_ROOT})
    
    
    #############################################################
    ## Fetch Yojimbo
    #############################################################
    ##
      FetchContent_Declare( YojimboGit )
      FetchContent_Populate(YojimboGit
          SOURCE_DIR     ${YOJIMBO_SOURCE_DIR}
          GIT_REPOSITORY "https://github.com/networkprotocol/yojimbo.git"
          GIT_TAG        ${YOJIMBO_TAG}
      )
    
    ############################################################
    ## External imports: libsodium and mbedtls
    ############################################################
    ##
      ## We require an installation of VCPKG here and VCPKG_ROOT set to the installation folder
      ## The dependecies are installed with vcpkg as follows (Windows x64):
      ## cd ${VCPKG_ROOT}
      ## vcpkg install libsodium:x64-windows-static
      ## vcpkg install mbedtls:x64-windows-static
      ## On Linux the triplet distinction between static and dynamic libraries is not existent
      
      # External library paths
      if(WIN32)
        SET(VCPKG_LIBSODIUM_BASE "${VCPKG_ROOT}/packages/libsodium_x64-windows-static" )
        SET(VCPKG_MBEDTLS_BASE   "${VCPKG_ROOT}/packages/mbedtls_x64-windows-static" )
      elseif(UNIX)
        SET(VCPKG_LIBSODIUM_BASE "${VCPKG_ROOT}/installed/x64-linux")
        SET(VCPKG_MBEDTLS_BASE   "${VCPKG_ROOT}/installed/x64-linux")
      else()
        MESSAGE(FATAL "Inrecognized Operating System. I understand either WIN32 or UNIX to be set to true.")
      endif()
      
      ## External libraries and headers
      add_library( sodium STATIC IMPORTED)
      target_include_directories( sodium INTERFACE "${VCPKG_LIBSODIUM_BASE}/include"  )
      
      add_library( mbedtls STATIC IMPORTED)  
      target_include_directories( mbedtls INTERFACE "${VCPKG_MBEDTLS_BASE}/include"  )
        
      add_library( mbedx509 STATIC IMPORTED)  
      target_include_directories( mbedx509 INTERFACE "${VCPKG_MBEDTLS_BASE}/include"  )
      
      add_library( mbedcrypto STATIC IMPORTED)  
      target_include_directories( mbedcrypto INTERFACE "${VCPKG_MBEDTLS_BASE}/include"  )
      
      ## External library binaries
      if(WIN32)
        set_target_properties(sodium     PROPERTIES IMPORTED_LOCATION ${VCPKG_LIBSODIUM_BASE}/lib/libsodium.lib )
        set_target_properties(mbedtls    PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/mbedtls.lib     )
        set_target_properties(mbedx509   PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/mbedx509.lib    )
        set_target_properties(mbedcrypto PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/mbedcrypto.lib  )
      ELSEIF(UNIX)
        set_target_properties(sodium     PROPERTIES IMPORTED_LOCATION ${VCPKG_LIBSODIUM_BASE}/lib/libsodium.a   )
        set_target_properties(mbedtls    PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/libmbedtls.a    )
        set_target_properties(mbedx509   PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/libmbedx509.a   )
        set_target_properties(mbedcrypto PROPERTIES IMPORTED_LOCATION ${VCPKG_MBEDTLS_BASE}/lib/libmbedcrypto.a )
      ENDIF()
      
    
    
    ############################################################
    ## Yojimbo Static Library
    ############################################################
    ##
      add_library(yojimbo STATIC
          ${YOJIMBO_SOURCE_DIR}/yojimbo.cpp
          ${YOJIMBO_SOURCE_DIR}/tlsf/tlsf.c
          ${YOJIMBO_SOURCE_DIR}/netcode.io/netcode.c
          ${YOJIMBO_SOURCE_DIR}/reliable.io/reliable.c
      )
      target_link_libraries( yojimbo sodium mbedtls mbedx509 mbedcrypto )
      target_compile_definitions( yojimbo PUBLIC NETCODE_ENABLE_TESTS=0 RELIABLE_ENABLE_TESTS=0 )      
      target_include_directories( yojimbo 
        INTERFACE
            $<BUILD_INTERFACE:${YOJIMBO_SOURCE_DIR}> 
            $<INSTALL_INTERFACE:${YOJIMBO_INSTALL_DIR}/include> 
        PRIVATE 
            ${YOJIMBO_SOURCE_DIR}/netcode.io 
            ${YOJIMBO_SOURCE_DIR}/reliable.io 
      )
    
    ############################################################
    ## Yojimbo Static TEST Library and Test App
    ############################################################
    ##
      if(${YOJIMBO_TESTS})  
            ## library
            add_library(yojimbo_test STATIC
              ${YOJIMBO_SOURCE_DIR}/yojimbo.cpp
              ${YOJIMBO_SOURCE_DIR}/tlsf/tlsf.c
              ${YOJIMBO_SOURCE_DIR}/netcode.io/netcode.c
              ${YOJIMBO_SOURCE_DIR}/reliable.io/reliable.c
            )
            target_link_libraries( yojimbo_test sodium mbedtls mbedx509 mbedcrypto )    
            target_compile_definitions( yojimbo_test PUBLIC NETCODE_ENABLE_TESTS=1 RELIABLE_ENABLE_TESTS=1 )    
            target_include_directories( yojimbo_test 
              INTERFACE
                  $<BUILD_INTERFACE:${YOJIMBO_SOURCE_DIR}> 
                  $<INSTALL_INTERFACE:${YOJIMBO_INSTALL_DIR}/include> 
              PRIVATE 
                  "${YOJIMBO_SOURCE_DIR}/netcode.io" 
                  "${YOJIMBO_SOURCE_DIR}/reliable.io" 
            )
            
            target_include_directories( yojimbo PRIVATE "${VCPKG_LIBSODIUM_BASE}/include"  )
            target_include_directories( yojimbo PRIVATE "${VCPKG_MBEDTLS_BASE}/include"  )
                    
            ## executable
            add_executable(testapp ${YOJIMBO_SOURCE_DIR}/test.cpp )
            target_link_libraries(testapp yojimbo_test)    
            ##
      endif()  
    
    ############################################################
    ## Client App Target
    ############################################################
    ##
      add_executable(client ${YOJIMBO_SOURCE_DIR}/client.cpp )
      target_link_libraries( client yojimbo )
    
    ############################################################
    ## Server App Target
    ############################################################
    ##
      add_executable(server ${YOJIMBO_SOURCE_DIR}/server.cpp )
      target_link_libraries( server yojimbo )
    
    ############################################################
    ## Secure Client App Target
    ############################################################
    ##
      add_executable(secure_client ${YOJIMBO_SOURCE_DIR}/secure_client.cpp )
      target_link_libraries( secure_client yojimbo )
    
    ############################################################
    ## Secure Server App Target
    ############################################################
    ##
      add_executable(secure_server ${YOJIMBO_SOURCE_DIR}/secure_server.cpp )
      target_link_libraries( secure_server yojimbo )
    
    ############################################################
    ## Client Server App Target
    ############################################################
    ##
      add_executable(client_server ${YOJIMBO_SOURCE_DIR}/client_server.cpp )
      target_link_libraries( client_server yojimbo )
    
    ############################################################
    ## Loopback App Target
    ############################################################
    ##
      add_executable(loopback ${YOJIMBO_SOURCE_DIR}/loopback.cpp )
      target_link_libraries( loopback yojimbo )
    
    ############################################################
    ## Soak App Target
    ############################################################
    ##
      add_executable(soak ${YOJIMBO_SOURCE_DIR}/soak.cpp )
      target_link_libraries( soak yojimbo )
    
    ############################################################
    ## Install
    ############################################################
    ##
      if(YOJIMBO_TESTS)
          SET(TEST_INSTALL testapp)
      endif()
      
      ## yojimbo + EXPORT
      install(
          TARGETS
              yojimbo
          EXPORT yojimboConfig 
          RUNTIME  DESTINATION ${YOJIMBO_INSTALL_DIR}/bin
          LIBRARY  DESTINATION ${YOJIMBO_INSTALL_DIR}/lib
          ARCHIVE  DESTINATION ${YOJIMBO_INSTALL_DIR}/lib     
          INCLUDES DESTINATION ${YOJIMBO_INSTALL_DIR}/include  
      )
      ## The rest
      install(
          TARGETS
              ${TEST_INSTALL}
              client
              server
              secure_client
              secure_server
              client_server
              loopback
              soak
          RUNTIME  DESTINATION ${YOJIMBO_INSTALL_DIR}/bin
          LIBRARY  DESTINATION ${YOJIMBO_INSTALL_DIR}/lib
          ARCHIVE  DESTINATION ${YOJIMBO_INSTALL_DIR}/lib     
          INCLUDES DESTINATION ${YOJIMBO_INSTALL_DIR}/include  
      )
      install(  FILES   ${YOJIMBO_SOURCE_DIR}/yojimbo.h 
                        ${YOJIMBO_SOURCE_DIR}/shared.h 
                DESTINATION 
                        ${YOJIMBO_INSTALL_DIR}/include  
      )
      ## install cmake files for find_package
      install(EXPORT yojimboConfig DESTINATION ${YOJIMBO_INSTALL_DIR}/lib/cmake  )
    
    #### DONE ####
    
    
    MESSAGE(STATUS "***")
    MESSAGE(STATUS "***  Yojimbo -- DONE --")
    MESSAGE(STATUS "***")
    

    EDIT: Changed EXPORT name to work with find_package( yojimbo ) when yojimbo_DIR is set to /lib/cmake in the install destination.

    opened by McKillroy 24
  • No notification when messages are dropped due to budget

    No notification when messages are dropped due to budget

    Currently, if you try to send a message with a size that happens to exceed the packet budget on it's channel, then the message itself will be silently dropped after failing to fit into a packet. This is impossible to see from the applications point of view, as no counters are affected, no error state is set, and the packet itself sends correctly - albeit without the oversized message.

    Some kind of notification when this happens would be appreciated, instead of the oversized message silently disappearing into the ether.

    opened by ananace 21
  • Wrapper for 3D engine: enhancement for Unity 3D

    Wrapper for 3D engine: enhancement for Unity 3D

    I think that is very important to create a wrapper for 3D Engine: Unity 3D will be the perfect 3D engine to start.

    It is possible to start a Patreon campaign where I would like to contribute.

    opened by Vytek 19
  • Cmake?

    Cmake?

    Would you accept a cmake version of the build system? If I made one? Not sure how to deal with two versions of the build system though because one be outdated.

    opened by fire 18
  • Documentation on how to use the library

    Documentation on how to use the library

    Is there any documentation on how to integrate yojimbo into cocos2d-x or any other c++ game engine? I'm talking about a basic scenario including send/receive/serialize. Thanks!

    help wanted 
    opened by ChristianHohlfeld 16
  • Avoid swap function redefinition

    Avoid swap function redefinition

    The following code:

    rce->server->yj_transport = std::make_unique<yojimbo::NetworkTransport>(
                yojimbo::GetDefaultAllocator(),
                yojimbo::Address(),
                PROTOCOL_VERSION,
                cur_time
        );
    

    yields this error in GCC 6.3.1 on Linux error: call of overloaded ‘swap(yojimbo::NetworkTransport*&, yojimbo::NetworkTransport*&)’ is ambiguous

    It looks like the swap function in yojimbo_common.h is interfering with the swap function from the standard library.

    This PR just removes the definition on C++11 or newer compilers using the __cplusplus macro. That being said, it's totally possible I'm doing something wrong, as both my C++ and knowledge of the standard are a little rusty these days.

    Any thoughts?

    Also thanks so much for this library, I expect to learn tons by studying and using it!

    opened by lukesanantonio 16
  • How to make a server listen on localhost and internet ?

    How to make a server listen on localhost and internet ?

    Hello everyone, here is my issue, I'm trying to make a server for a video game project so I tested my server in localhost and everything is working but when I want a friend to connect to my server that's not working ! Just to be clear I opened the server port on my internet box !

    So my server code is like that:

    if (!InitializeYojimbo())
    {
    	printf("Failed to initialize 'Yojimbo'\n");
    
    	return EXIT_FAILURE;
    }
    
    yojimbo_log_level(YOJIMBO_LOG_LEVEL_INFO);
    
    yojimbo::Address serverAddress("127.0.0.1", 4674); // <---- Server ip & port to listen.
    
    GameConnectionConfig config;
    
    GameServer gameServer(serverAddress, config);
    
    gameServer.Run();
    

    When I have 127.0.0.1 in server address I can connect with my client in localhost without any issues but when I put my internet box IP my friend can connect but I can no longer on my side !

    I don't really understand why we need to put an IP Address to create the server, why just not only a port, and the server listen for all IP (Localhost & Internet at same time !).

    Sorry in advance for my english, I'm not a native english speaker.

    Thx for your help !

    opened by K3rhos 15
  • Custom socket

    Custom socket

    I was wondering what the feasibility is of being able to use a custom socket implementation, i.e. I am working on a restricted hardware platform where instead of normal sockets, there is a vendor provided socket implementation (different functions/params but very similar), which has the same properties of UDP (however I'd like to have reliable, ordered packets). Essentially, rather than passing in an address for yojimbo to open, I'd like to open the socket myself, and then pass yojimbo my socket (as a void* or whatever), and then register functions with yojimbo for sending, receiving and closing said socket.

    What are your thoughts?

    opened by Scraft 15
  • Large messages can clog ReliableOrderedChannel indefinitely

    Large messages can clog ReliableOrderedChannel indefinitely

    This occurred on a configuration with .maxPacketSize == 8192. A message was generated, which serialized to 119500 bits. In Connection::GeneratePacket(), the availableBits is 65520, and as that makes the call to ReliableOrderedChannel::GetMessagesToSend(), the condition at https://github.com/networkprotocol/yojimbo/blob/master/yojimbo.cpp#L1828 never fires since entry->messageBits is 119500 and so availableBits >= (int) entry->measuredBits always evaluates to false.

    What do you think the behavior should be here? That packet is too large, but an early error would be much preferred to a quiet clog of the channel for the rest of the connection's lifetime.

    opened by sherief 1
  • Improve vcpkg usage experience

    Improve vcpkg usage experience

    You already have a port made but it's not findable here https://vcpkg.io/en/packages.html and it's harder to consume than all the other vcpkg libraries. Ideally it should reside in this repo https://github.com/microsoft/vcpkg/tree/master/ports so yojimbo would become available to install right after installing vcpkg. For example GameNetworkingSockets by Valve is easily findable there and much easier to consume than yojimbo.

    image image

    opened by bugproof 3
  • Yojimbo linkage

    Yojimbo linkage

    While working on the cmake/vcpkg port of yojimbo I stumbled over the fact that yojimbo is built as a static library only. Is there a reason for that? Or could yojimbo be built as a .dll/.so as well? On Windows cmake could export all symbols by default like:

    SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)
    
    opened by McKillroy 0
  • Added support for using a custom registry with vcpkg and also hiding …

    Added support for using a custom registry with vcpkg and also hiding …

    Extended the vcpkg possibilities. Adding a variant using a custom vcpkg registry and hiding away the transitive dependencies when consuming yojimbo. See the readme files in /vcpkg directory Should make consumption of yojimbo with vcpkg even easier. Signed-off-by: Yorlik [email protected]

    opened by McKillroy 0
Releases(v1.2.1)
  • v1.2.1(Apr 18, 2019)

    This release updates to the latest netcode.io and reliable.io libraries.

    This fixes several bugs and resolves a security vulnerability in relay protection.

    You should update to this release!

    Source code(tar.gz)
    Source code(zip)
  • v1.1(Aug 16, 2017)

    New features in this release:

    1. You can now set the timeout value in ClientServerConfig
    2. Negative timeout values disable timeouts (useful for debugging)
    3. Client::GetAddress and Server::GetAddress now return the correct port when you bind to port 0
    4. Added callbacks in adapter when clients connect and disconnect to the server (see Adapter::OnServerClientConnected and Adapter::OnServerClientDisconnected)

    In order to implement the timeouts, this release updates to NETCODE 1.01 spec.

    Source code(tar.gz)
    Source code(zip)
  • v1.0(Jul 26, 2017)

  • v0.6.0(Jul 16, 2017)

    New features:

    • Client/server completely rebuilt on top of netcode.io and reliable.io
    • Added support for packet fragmentation and reassembly
    • Added detailed logging support with log levels (none, error, info, debug)
    • Users can now override logging printf function and assert payload function
    • matcher.go now uses netcode.io golang implementation to generate connect tokens
    • Updated yojimbo.lib to use multithreaded DLL CRT on Windows so it works with UE4
    • You can now disable mbedtls use with #define YOJIMBO_WITH_MBEDTLS 0
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jun 1, 2017)

  • v0.4.0(Jan 5, 2017)

    This release adds doxygen documentation for yojimbo.

    To build and view the documentation, install doxygen then run:

    premake5 docs
    

    It also fixes two critical security issues:

    1. The challenge token sent back to clients on connection request was encrypted with an AEAD primititive, but the code neglected to increase the nonce each time a new challenge was generated. This made it theoretically possible for an attacker to recover the private key shared between the matcher and dedicated servers.
    2. When multiple dedicated server instances are running they reuse the same nonce values, starting at 0 and increasing with each challenge token generated, again risking the private key. To fix this issue the challenge token is now encrypted with a random key rolled in Server::Start instead of the private key shared between matcher and dedicated servers.

    Please upgrade immediately or you risk an attacker being able to discover your private key.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.4.0.tar.gz(2.45 MB)
    libyojimbo-0.4.0.zip(2.57 MB)
  • v0.3.0-preview10(Nov 15, 2016)

    This is a significant new release and contains major new features and bugfixes. I recommend everybody using libyojimbo update to this release right away. Please be aware that the API is slightly changed in this release.

    New features:

    1. Per-client allocator, packet and message factories on the server. This is a security measure to make sure that clients cannot spoil or exhaust a resource shared with other clients, but can only exhaust their own resources. When a client's resources are exhausted on the server, that client is disconnected.
    2. Security fix so that replay attacks with stale connect tokens can be quickly discarded with AEAD signature check vs. having to decrypt the whole connect token just to find out the timestamp is old. This is a much faster reject because signature check is significantly faster than decrypt.
    3. Replay packet attack fix. Malicious clients can no longer sniff your connection packets and replay them to try to corrupt your internal connection state (eg. reliable messages, uint16_t sequence # after wrapping). This would have been a hard attack to pull off due to timing, but it was possible. Now it's impossible.
    4. Client can now pass multiple servers in to secure and insecure connects. Client tries each server in turn, up to MaxServersPerConnect in an array, until the first connect succeeds. This is the intended behavior for connecting via connect token returned from the matcher, and now it's as simple as passing an array of server addresses to the connect function.
    5. Expanded test coverage and bugfixes. I've added test coverage for client reconnecting, switching between insecure connect to secure connect and back to insecure, plus a bunch more stuff. In doing so I found many issues, mostly caused by rare situations or use cases like reconnecting that weren't picked up by previous test coverage.

    The nature of these new features and bugfixes required changes to the API. Please refer to shared.h and client.cpp, connect.cpp and server.cpp for examples showing how to setup yojimbo client and server classes with the new API.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.3.0-Preview10.tar.gz(2.45 MB)
    libyojimbo-0.3.0-Preview10.zip(2.56 MB)
  • v0.3.0-preview9(Oct 21, 2016)

    This release fixes an issue where client connect via matcher failed with this error on Windows:

    error: request match failed. is the matcher running?
    

    Which seemed to be caused by the matcher.go HTTPS response getting MTU split somewhere in the networking stack from a recent version of Docker on Windows, whereas in previous versions of Docker on Windows it was not.

    The fix was to extend the mbedtls example code I derived from in yojimbo_matcher.cpp so it properly handles responses that require multiple calls to mbedtls_ssl_read. This bug seem did not affect MacOS or Linux platforms, but if for some reason the HTTPS response was MTU split, it would have broken there too.

    I also added a workaround on MacOS for the clock getting out of sync in the docker VM instance, which was causing client connects through matcher.go running in docker to fail to connect when pointed to a server instance outside of docker:

    For example, the following sequence of commands worked:

    premake5 matcher
    premake5 docker           // run server on port 40000 inside docker
    premake5 connect
    

    Because both matcher and server were running inside docker with the same skewed clock, but the following sequence failed:

    premake5 matcher
    premake5 server           // run server on port 40000 *outside* docker
    premake5 connect
    

    because matcher.go generated connect tokens wrt. skewed time, which were then passed to a server running outside of docker (with correct, unskewed time), causing the server to deny these connection requests because they were stale (connect tokens are only valid for a short 30 second window...). I'm not 100% sure, but I suspect these issues are new with the latest MacOS Sierra release. I recently upgraded, and didn't notice any clock skew before this.

    The solution in production environments is of course to always make sure your matcher and dedicated server instances are synced to the same time via NTP. For development on MacOS, I added the following workaround to sync up the docker VM clock to local time:

    docker run --rm --privileged alpine hwclock -s
    

    Which is described here:

    https://docs.docker.com/docker-for-mac/troubleshoot/#issues

    Docker... sigh :)

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.3.0-Preview9.7z(1.42 MB)
    libyojimbo-0.3.0-Preview9.tar.gz(2.43 MB)
    libyojimbo-0.3.0-Preview9.zip(2.54 MB)
  • v0.3.0-preview8(Aug 3, 2016)

    This release adds per-client silos for allocators, packet factories and message factories on the server. This is a security measure so a malicious client can exhaust only their own resources (leading to disconnection) and cannot affect resources for other clients. Previously, allocators and factories were shared by all clients on the server. This release also includes a bunch of fixes to get libyojimbo passing Coverity with zero defects. See this page for details.

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0-preview7(Jul 21, 2016)

  • v0.3.0-preview6(Jul 18, 2016)

    This release fixes an issue where profile.cpp sometimes would not connect all clients. What was going on was that on some OS's (windows...) the default socket send and receive buffer sizes were so small that only packets from the first n clients would actually get through. Now SO_RCVBUF and SO_SNDBUF are each set to 1mb on socket create so this doesn't happen anymore. If you would like larger or smaller buffers, pass the value you want into the "bufferSize" parameter of the socket or socket transport constructor.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.3.0-Preview6.tar.gz(2.42 MB)
    libyojimbo-0.3.0-Preview6.zip(2.51 MB)
  • v0.3.0-preview5(Jul 17, 2016)

    This release adds support for unreliable unordered message channels. You can select between CHANNEL_TYPE_RELIABLE_ORDERED (default) and CHANNEL_TYPE_UNRELIABLE_UNORDERED via the "type" parameter in ChannelConfig. See test_connection_unreliable_unordered_messages for an example of usage.

    You can send both messages and blocks over an unreliable unordered channel, but blocks are serialized all at once rather than fragmented like they are in the reliable ordered channel. This is because unreliable unordered data is usually time critical so there is no point resending unacked fragments.

    This is OK for small blocks right now, but large blocks that are too big to fit in the packet will be discarded. In the next release I will add support for packet fragmentation and reassembly, so you can bump up the maximum packet size to send large blocks unreliably, and packet fragmentation and reassembly will take care of fragmenting and reassembling any packets larger than MTU. This is a great strategy for large state update messages like snapshot deltas.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.3.0-Preview5.tar.gz(2.41 MB)
    libyojimbo-0.3.0-Preview5.zip(2.51 MB)
  • v0.3.0-preview4(Jul 15, 2016)

  • v0.3.0-preview3(Jul 13, 2016)

  • v0.3.0-preview2(Jul 11, 2016)

    This release adds support for sending blocks of data (larger than MTU) in the same ordered stream as reliable ordered messages. These blocks are sliced up and reassembled on the other side transparently to the user and received in the same order they were sent relative to other messages. Block messages can also serialize message data in the serialization function to act a header for their block data.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.3.0-Preview2.tar.gz(2.40 MB)
    libyojimbo-0.3.0-Preview2.zip(2.49 MB)
  • v0.3.0-preview1(Jul 6, 2016)

  • 0.2.0(Jul 1, 2016)

  • v0.2.0-preview5(Jun 29, 2016)

  • v0.2.0-Preview4(Jun 29, 2016)

    This release adds a matchmaker web microservice written in go. The matcher can be run via docker with the command "premake5 matcher". There is also a new "connect" program that opens a HTTPS connection (via mbedtls) to this matcher service to receive a connect token as JSON.

    In the next release, the connect program will take this connect token and use it to establish a secure connection to a dedicated server. For the moment, it just prints out the JSON.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.2.0-preview4.tar.gz(2.37 MB)
    libyojimbo-0.2.0-preview4.zip(2.45 MB)
  • v0.2.0-preview3(Jun 24, 2016)

  • v0.2.0-preview2(Jun 24, 2016)

  • v0.2.0-preview1(Jun 23, 2016)

    This release an example showing how to run a yojimbo server inside a Docker container.

    This is a preview release because there is much more Docker yojimbo goodness is on its way.

    libyojimbo 0.2.0 will contain a full matchmaker web backend and server cloud running inside Docker as an example showing how to setup a secure client/server connections via connect tokens. This will become the foundation behind the "Basic Matchmaking" article in Building a Game Network Protocol, and, thanks to Docker, you'll be soon be able to run this entire web backend example inside docker on your Mac or Windows machine. Amazing!

    The latest version of Docker requires MacOS X or Windows 10 64bit (or of course, Linux).

    I've tested the Docker yojimbo server working fine on Windows 10 and MacOS X.

    If you are running under Windows 10, you need to check "Expose container ports on localhost" under Docker Network settings in order to get the yojimbo client connecting to 127.0.0.1:50000, but otherwise it works pretty much out of the box.

    See docker.com for more information about Docker.

    Source code(tar.gz)
    Source code(zip)
    libyojimbo-0.2.0-preview1.tar.gz(70.41 KB)
    libyojimbo-0.2.0-preview1.zip(127.05 KB)
  • v0.1.0(Jun 16, 2016)

Owner
The Network Protocol Company
The Network Protocol Company
The Network Protocol Company
Realtime Client/Server app for Linux allowing joystick (and other HID) data to be transferred over a local network

netstick What is it? Netstick enables HID devices to be remotely connected between a "client" and "server" over a network connection. It allows the ke

null 33 Nov 6, 2022
A virtual network Differential GNSS server-client project using Precise Point Positioning (PPP). Global coverage. Without physical base station construction needed. An open-source virtual base station approach.

Virtual-Network-DGNSS-Project This project is the software implementation for a publicly available, open-source, client/server VN-DGNSS implementation

null 13 Oct 24, 2022
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Qihoo 360 3.1k Nov 18, 2022
Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Oct 17, 2022
Netif - Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Oct 17, 2022
Micro http server and client written in C++

httpp Micro http server and client written in C++ The motivation behind this little piece of code is to provide a really simple, yet efficient HTTP se

Thomas Sanchez 156 Nov 13, 2022
Simple Tcp Chat Client / Server written in C++

What this TcpXat TcpXat Is A Simple Tcp Chat Setup TcpXat sudo apt install make;make client;make serv;echo "done by FuryM3m0ry"; How To Run TcpXat Ter

sami 1 Dec 28, 2021
Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

null 17 Nov 9, 2022
XMap is a fast network scanner designed for performing Internet-wide IPv6 & IPv4 network research scanning.

XMap is reimplemented and improved thoroughly from ZMap and is fully compatible with ZMap, armed with the "5 minutes" probing speed and novel scanning techniques. XMap is capable of scanning the 32-bits address space in under 45 minutes.

idealeer 189 Nov 23, 2022
Event-driven network library for multi-threaded Linux server in C++11

Muduo is a multithreaded C++ network library based on the reactor pattern. http://github.com/chenshuo/muduo Copyright (c) 2010, Shuo Chen. All righ

Shuo Chen 12.3k Nov 27, 2022
A software C library designed to extract data attributes from network packets, server logs, and from structured events in general, in order to make them available for analysis

MMT-DPI A software C library desinged to extract data attributes from network packets, server logs, and from structured events in general, in odrder t

Montimage 3 Nov 9, 2022
A cross-platform network learning demos. Like high-performance http server

Network-Learn A cross-platform network learning demos (toys). And I try not to use 3rd-party libraries. Welcome to try it out and leave your comments.

Ho 229 24 Sep 6, 2022
A C++ header-only HTTP/HTTPS server and client library

cpp-httplib A C++11 single-file header-only cross platform HTTP/HTTPS library. It's extremely easy to setup. Just include the httplib.h file in your c

null 8.2k Nov 28, 2022
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 938 Nov 29, 2022
C++ websocket client/server library

WebSocket++ (0.8.2) WebSocket++ is a header only C++ library that implements RFC6455 The WebSocket Protocol. It allows integrating WebSocket client an

Peter Thorson 5.9k Nov 27, 2022
Ole Christian Eidheim 741 Nov 2, 2022
websocket and http client and server library, coming with ws, a command line swiss army knife utility

Hello world IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use an

Machine Zone, Inc. 358 Nov 19, 2022
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio.

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Ole Christian Eidheim 2.4k Nov 22, 2022
BingBing 60 Nov 4, 2022