Skip to content

Commit

Permalink
add network info
Browse files Browse the repository at this point in the history
  • Loading branch information
gafferongames committed Dec 25, 2023
1 parent f05e7c0 commit 2e39807
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
18 changes: 1 addition & 17 deletions yojimbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "yojimbo_connection.h"
#include "yojimbo_network_simulator.h"
#include "yojimbo_adaptor.h"
#include "yojimbo_network_info.h"

/** @file */

Expand Down Expand Up @@ -80,23 +81,6 @@ void ShutdownYojimbo();

namespace yojimbo
{
/**
Network information for a connection.
Contains statistics like round trip time (RTT), packet loss %, bandwidth estimates, number of packets sent, received and acked.
*/

struct NetworkInfo
{
float RTT; ///< Round trip time estimate (milliseconds).
float packetLoss; ///< Packet loss percent.
float sentBandwidth; ///< Sent bandwidth (kbps).
float receivedBandwidth; ///< Received bandwidth (kbps).
float ackedBandwidth; ///< Acked bandwidth (kbps).
uint64_t numPacketsSent; ///< Number of packets sent.
uint64_t numPacketsReceived; ///< Number of packets received.
uint64_t numPacketsAcked; ///< Number of packets acked.
};

/**
The server interface.
*/
Expand Down
50 changes: 50 additions & 0 deletions yojimbo_network_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Yojimbo Client/Server Network Library.
Copyright © 2016 - 2024, Mas Bandwidth LLC.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef YOJIMBO_NETWORK_INFO_H
#define YOJIMBO_NETWORK_INFO_H

#include "yojimbo_config.h"

namespace yojimbo
{
/**
Network information for a connection.
Contains statistics like round trip time (RTT), packet loss %, bandwidth estimates, number of packets sent, received and acked.
*/

struct NetworkInfo
{
float RTT; ///< Round trip time estimate (milliseconds).
float packetLoss; ///< Packet loss percent.
float sentBandwidth; ///< Sent bandwidth (kbps).
float receivedBandwidth; ///< Received bandwidth (kbps).
float ackedBandwidth; ///< Acked bandwidth (kbps).
uint64_t numPacketsSent; ///< Number of packets sent.
uint64_t numPacketsReceived; ///< Number of packets received.
uint64_t numPacketsAcked; ///< Number of packets acked.
};
}

#endif // #ifndef YOJIMBO_NETWORK_INFO_H

0 comments on commit 2e39807

Please sign in to comment.