Exemple #1
0
        private void UpdateStats(int i, int j, GGPONetworkStats stats)
        {
            /*
             * Random graphs
             */
            if (j == 0)
            {
                _remote_queue_graph[i] = stats.recv_queue_len;
                _send_queue_graph[i]   = stats.send_queue_len;
            }

            /*
             * Ping
             */
            _ping_graph[j][i] = stats.ping;

            /*
             * Frame Advantage
             */
            _local_fairness_graph[j][i]  = stats.local_frames_behind;
            _remote_fairness_graph[j][i] = stats.remote_frames_behind;
            if (stats.local_frames_behind < 0 && stats.remote_frames_behind < 0)
            {
                /*
                 * Both think it's unfair (which, ironically, is fair).  Scale both and subtrace.
                 */
                _fairness_graph[i] = Mathf.Abs(Mathf.Abs(stats.local_frames_behind) - Mathf.Abs(stats.remote_frames_behind));
            }
            else if (stats.local_frames_behind > 0 && stats.remote_frames_behind > 0)
            {
                /*
                 * Impossible!  Unless the network has negative transmit time.  Odd....
                 */
                _fairness_graph[i] = 0;
            }
            else
            {
                /*
                 * They disagree.  Add.
                 */
                _fairness_graph[i] = Mathf.Abs(stats.local_frames_behind) + Mathf.Abs(stats.remote_frames_behind);
            }

            int now = Utils.TimeGetTime();

            if (now > _last_text_update_time + 500)
            {
                networkLag             = $"{stats.ping} ms";
                frameLag               = $"{((stats.ping != 0) ? stats.ping * 60f / 1000f : 0f)} frames";
                bandwidth              = $"{stats.kbps_sent / 8f} kilobytes/sec";
                localAhead             = $"{stats.local_frames_behind} frames";
                remoteAhead            = $"{stats.remote_frames_behind} frames";
                _last_text_update_time = now;
            }
        }
Exemple #2
0
            public static int GetNetworkStats(int phandle, out GGPONetworkStats stats)
            {
                stats = new GGPONetworkStats();
                var result = GGPO.GetNetworkStats(ggpo, phandle,
                                                  out stats.send_queue_len,
                                                  out stats.recv_queue_len,
                                                  out stats.ping,
                                                  out stats.kbps_sent,
                                                  out stats.local_frames_behind,
                                                  out stats.remote_frames_behind
                                                  );

                return(result);
            }