NetStats_PacketLossPercent()
#1

I was testing this function to implement a packetloss kicker and found it to be completely unreliable here is the code.

pawn Код:
#include <YSI\y_hooks>

#define         PACKET_LOSS_DELAY           60000
#define         PACKET_LOSS_INFRACTIONS     3

static Float:LastPacketLoss[MAX_PLAYERS];
static PacketLossTime[MAX_PLAYERS];
static PacketLossInfractions[MAX_PLAYERS];

hook OnGameModeInit()
{
    SetTimer("LossChecker", 1000, true);
    return 1;
}

hook OnPlayerConnect(playerid)
{
    LastPacketLoss[playerid] = 0.0;
    PacketLossTime[playerid] = GetTickCount();
    PacketLossInfractions[playerid] = 0;
    return 1;
}

LossChecker();
public LossChecker()
{
    new Float:loss;
    foreach(new i : Player)
    {
        loss = NetStats_PacketLossPercent(i);

        // Loss detected
        if(loss > LastPacketLoss[i])
        {
            if(GetTickCount() - PacketLossTime[i] > PACKET_LOSS_DELAY) PacketLossInfractions[i] = 1;
            else PacketLossInfractions[i]++;
            PacketLossTime[i] = GetTickCount();
           
            if(PacketLossInfractions[i] == PACKET_LOSS_INFRACTIONS)
            {
                Disconnect_Reason[i] = DISCONNECT_PACKETLOSS;
                DelayKick(i);
            }
        }
        LastPacketLoss[i] = loss;
    }
    return 1;
}
Reply
#2

Hey Pottus i saw it on Wiki: This function has been found to be currently unreliable the output is not as expected when compared to the client. Therefore this function should not be used as a packet loss kicker.
Reply
#3

Quote:
Originally Posted by n0minal
Посмотреть сообщение
Hey Pottus i saw it on Wiki: This function has been found to be currently unreliable the output is not as expected when compared to the client. Therefore this function should not be used as a packet loss kicker.
That was added there at a very recent day I guess.

The function is indeed unreliable. I've seen players with %15.0 of packetloss and their gameplay was pretty good.
Reply
#4

I put that on the Wiki lol.
Reply
#5

It's always seemed reliable for me. someone can have a net spike and lose all packets for a certain time then their internet goes back to normal. explaining a 15% total packetloss but normal gameplay afterward.
Reply
#6

Yep - same experience here, I made a thread about a month ago. It never goes back to normal once it slightly jumps, even with a perfect connection to the server (~30ms latency and 9 hops to the server) the function randomly shows 15% packetloss.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)