This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Getting Info on Connection with NetworkStatistics

NetworkStatistics Class

NetworkStatistics class allows for collecting network statistics. All the statistic values are calculated starting from the previous call of network.getNetworkStatistics() function.

  • float getKBytesSent() — gets the total amount of data sent during the current session (in Kbytes)
  • float getKBytesRecvd() — gets the total amount of data received during the current session (in Kbytes)
  • float getBpsSent() — gets the current upload speed during the last second (b/s)
  • float getBpsRecvd() — gets the current download speed during the last second (b/s)
  • int getSessionTime() — gets session duration (in ms). On the server side, it is measured from the moment of its start; on the client side – after connection was established.
  • float getPacketloss() — gets the degree of packet loss (%)

Connection Information Functions

  • int network.getNodeType() — gets the current type of the network node. Possible values are:
    • NETWORK_NODE_UNINITIALIZED — the node is not initialized (no connection is established and therefore the node type is unknown)
    • NETWORK_NODE_SERVER — the node acts as a server
    • NETWORK_NODE_CLIENT — the node acts as a client
  • NetworkAddress network.getMyAddress() — gets the computer's own network address:
    • if a server, returns the address passed to the startServer() function
    • if a client, returns the address through which connection to the server was established by calling connectToServer()
  • NeworkAddress network.getMyAddress(NetworkAddress target_address) — gets the computer's own network address as seen by another network node (a client or a server) specified by the target_address.
  • NetworkStatistics network.getNetworkStatistics() — gets the current network statistics (updated by each call of the network_update() function). For a server, total//summed statistics on all clients is returned.
  • NetworkStatistics network.getNetworkStatistics(NetworkAddress network_address) — gets the current network statistics for the specified connection.
    • network_address — an address of the connected network node
  • int network.getAvgPing(Variable target) — returns the average ping time to the node with specified address, or -1 if no packets were sent to the node.
    • target — a node address. It can be one of the following types:

Samples

Example of network statistics usage can be found in all network samples. See <UnigineSDK>/data/network/samples/common/scripts/statistics.h.

Last update: 2017-07-03
Build: ()