|Introduction • Terms • Clients|
|Datatypes • FLAP • SNAC • TLV|
|UUIDs • Errors • Tool IDs|
|Rate Limits • Migration • Messages|
|ADMIN • ADVERT • ALERT|
|BART • BOS • BUCP • CHAT|
|Sign On • BART • Rendezvous|
|ICBM • Locate • Buddies|
To protect the server and other users from abusive clients, the server implements SNAC rate limiting. Rate limiting is done with a simple formula that calculates the average time between SNACs over the last few SNACs sent from the client to the server.
A client can optionally subscribe to notifications about its rates so that it can warn the user ahead of time or show UI about the rates. Even if the client does not subscribe, it will receive notifications when the rate limit has been reached and the server has started dropping SNACs. If the client continues to send SNACs, it will eventually be disconnected.
All SNACs are assigned to a Rate Class which controls the parameters to the rate limit forumla. Most SNACs are in the most lenient rate class by default, with SNACs like IM sending being in more strict classes. The rate formula is currentAvg = ((currentAvg * (windowSize -1)) + delta)/windowSize.
The currentAvg falling below certain thresholds causes the server to warn the client that it is about to be rate limited or disconnected. Once a client is rate limited, its average has to fall above the clear threshold before it can start sending SNACs again.
The actual parameters for the formula are not published in this document since they can change from time to time and are different depending on the current warning level and other things. A client can average around one IM every two seconds without being rate limited.
Client sends OSERVICE__RATE_PARAMS_QUERY
Server responds OSERVICE__RATE_PARAMS_REPLY
Client can send OSERVICE__RATE_ADD_PARAM_SUB to subscribe to specific rate changes.
Client can send OSERVICE__RATE_DEL_PARAM_SUB to unsubscribe to specific rate changes.
Server sends OSERVICE__RATE_PARAM_CHANGE when changes occur to any subscribed rate classes.
Datatype: Rate Parameters
Describes the rate parameters for a single rate class.
|classId||uint16 (word)||Rate class being described|
|windowSize||uint32 (dword)||Number of events to count|
|clearThreshold||uint32 (dword)||Once rate limited the average has to reach this value in order to clear|
|alertThreshold||uint32 (dword)||Server will tell the client it is getting close to the limit|
|limitThreshold||uint32 (dword)||SNACs will be dropped below this value|
|disconnectThreshold||uint32 (dword)||Server will disconnect below this value|
|currentAverage||uint32 (dword)||Current value for the class; higher is better|
|maxAverage||uint32 (dword)||The maximum rate value; if the current value rises about this value it should be reset|
|lastArrivalDelta||uint32 (dword)||Last message was received this long ago|
|droppingSNACs||uint8 (byte)||Is the server dropping SNACs for this rate class|
Datatype: Rate Class Members
Describes all the SNACs in a single rate class.
|id||uint16 (word)||Rate class being described|
|numMembers||uint16 (word)||Number of SNACs in this rate class|
|snacIds||Array of SNAC__ID length numMembers||SNACs in this rate class|
These are the codes used in OSERVICE__RATE_PARAM_CHANGE to describe the state of the rate class.
|OSERVICE__RATE_CODE_CHANGE||0x01||Rate parameters have changed|
|OSERVICE__RATE_CODE_WARNING||0x02||Rate limit warning reached; if client does not slow down LIMIT state will be hit|
|OSERVICE__RATE_CODE_LIMIT||0x03||Rate limit reached; if client does not slow down client will be disconnected|
|OSERVICE__RATE_CODE_CLEAR||0x04||Rate limit cleared; client can send SNACs normally now|
From Aleksandr Shutko: Rate-limits description