Repository navigation
Let a host keep out players whose ping is over a limit - #6
Draft
medic-code wants to merge 10 commits into
Draft
medic-code wants to merge 10 commits into
medic-code wants to merge 10 commits into
Conversation
medic-code
force-pushed
the
feat/host-ping-limit
branch
from
October 25, 2026 16:40
0394519 to
eedada1
Compare
medic-code
force-pushed
the
feat/host-ping-limit
branch
from
November 8, 2026 06:49
0461012 to
c072a45
Compare
Hosts asked to keep players with a high ping out of their games. This is the judgement the host will make, not yet called: one round trip a second from the internet play tunnel (the same ping the server browser's PING column shows), the median of the latest five once there are three, over the limit or not. One slow round trip kicks no one. A machine is judged in the lobby and in its first ten seconds in a game it joined in progress, never while it downloads the maps, and never if the tunnel does not reach it (a system link machine). Checked: tools/harness/tests/test_ping_limit.py, 17 cases and 10 negative controls, in the halo-toolchain container.
Hosts asked to keep players with a high ping out of their games. With network.host_ping_limit set (milliseconds; 0, the default, is no limit), the host's server judges each joined client machine not its own once a second, in the lobby until the start is sent and in a machine's first ten seconds in a game it joined in progress, and kicks one whose median round trip is over the limit as the host's kick does: told _rejection_code_blacklisted_machine, dropped, free to join again. A notice names the players, their ping and the limit, sent as a kick's is. No player is kicked mid-match, where it would lose a match it is playing. Nothing new is sent: the kick is the existing message and value, so the network version stays 41. Checked: test_ping_limit.py (17 cases, 10 negative controls, the default and the server's guards) and ninja linux in the halo-toolchain container; two copies on loopback with the client's tunnel delayed 200 ms by netem: at a limit of 100 the client was kicked 2 s after joining the lobby and 2 s after joining a game in progress, and the notice reached its console; at 300, or off, it stayed; a system link client at 200 ms stayed; a client whose ping rose at the match's start stayed in the match.
A host sets network.host_ping_limit in the menus: OFF, 100, 150, 200, 250 or 300 MS. Server Setup has no free row (its twelve fill the screen, as do Teamplay Options'), so the row goes on Network Setup with this machine's other network settings; its pages in a game are unchanged. With it the desktop's Network Setup has ten places, and at the 30px step the last (DISCORD ACCOUNT, 343 to 371) would cover the help (from 350). Network Setup steps 28px with the help at 358, as Video Setup does since 860c8d5: its last place ends at 353, the help at 412, clear of the buttons (414). Checked: tools/ce_menus.py --settings-only reproduces origin/main's XML unchanged, and after the change writes only network_setup.xml.
The ring kept a count and a next place that every reset had to clear together. One count of round trips taken gives both (the place is the count modulo five, the number judged at most five), so each reset is one line. The round trips are kept as longs, as the tunnel gives them, so the 9999 ms cap and its casts go, and the median is worked out once before it is judged against the limit. Checked: test_ping_limit.py gives the same results as before the change (built 64-bit on macOS, where the byte-order cases fail before and after; the 32-bit run is on the NAS).
recovery-download and recovery-disabled cover the reset when a machine starts downloading the maps or the limit is turned off, but no fault showed they would see it removed. pause-keeps-samples drops the reset and expects recovery-download to fail.
The header keeps why a machine is judged only early in a game, why a system link machine has none, why downloads pause it and why the kick reuses the blacklisted reason; the byte order and the notice length keep theirs. Comments that restated names, fields or parameters go, and the port: markers in network_server_manager.c are shortened.
peer_send reset sent_time on every send, so a connected peer was pinged only after a second with nothing sent. With a client joined, the host timed a round trip about every 14 s in the lobby and none in a match, and the ping limit judged one stale value five times over. Connected peers now ping once a second regardless. Checked on the NAS with a host and a joined client, counting the host's pongs before and after. The packets are unchanged and every build already answers pings, so the network version stays 41.
The in-game admission window ran from the machine's join, so a machine that joined the lobby shortly before the start was still judged through loading and its first seconds of the match. A machine seen in the lobby is now judged there only; a machine that joins a match in progress keeps its first 10 seconds. lobby-into-game covers it, with a negative control.
The README and config.toml said the median of 5 seconds, but a player is judged from the third round trip, so a host got about 3 s of grace, not 5. The config text also said every player's first 10 seconds in a match, which holds only for a player who joins in progress.
A dedicated server reads network.host_ping_limit from its config.toml
like the other network.* keys, and it is the only ping check such a
server has: the server browser does not ping master-listed servers.
Its operator changes the other hosting limits, the vote kick's and
the chat's, live with sv_set and the web page's settings. This adds
the ping limit to that list, to the docs' list and to server_sim.py's
copy of it. A dedicated server's own machine has no player, so the
limit's exemption for the host's machine skips no one there.
Checked before the rebase, as 81d80e98e: ninja linux; in the
halo-toolchain container, a dedicated server and a client joining by
its invite over the tunnel, the client's tunnel delayed 200 ms by netem:
with host_ping_limit = 100 in config.toml the client was removed 1.7 s
after joining ("ping 207 ms, over the host's limit of 100 ms"); with 0
it stayed until "sv_set network.host_ping_limit 100", then was removed
2.6 s later; after "sv_set network.host_ping_limit 300" a client stayed
20 s, and sv_settings listed 300; test_server_sim.py passes (44).
Re-applied by hand on the rebased branch (the settings list had grown):
test_server_sim.py passes (45).
medic-code
force-pushed
the
feat/host-ping-limit
branch
from
November 8, 2026 12:29
c072a45 to
7f8dbb7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Hosts cannot keep players with a high ping out of their games. Today a host has to spot the number and kick each player by hand.
Hosts asked for a limit (wacko, on the OpenCE Discord).
What it does
sv_set network.host_ping_limit 150.Screenshots
Look at the HOST PING LIMIT row in Network Setup: set to 150 MS, with its help line below.
Details
network_game_server_handle_client_machines(each frame, on the host) →network_ping_limit_checkfor each joined client machine not on the host's machine → once a second, the tunnel's round trip for that machine's stand-in address → the median of the latest five → over the limit: the console line, then the existing kick path (_rejection_code_blacklisted_machine, drop).port/linux/game/network_ping_limit.c(new): the samples per machine slot, the median and the threshold, and when a machine is judged (lobby; first 10 s of a join in progress, unless the machine was in the lobby; not while downloading). It finds the round trip throughp2p_peer_key_hashandp2p_peer_ping, which already exist; stand-in addresses are 100.64.0.0/10, so a LAN address is never asked about. The notice is sent asnetwork_distributed_kicksends a kick's.source/networking/network_server_manager.c: threeport:additions. The declarations; resetting the slot's samples when a machine joins (next to the vote kick's and voice chat's resets); and in the per-machine loop, the call, which sets_kick_rejoinableso that the existing kick branch tells and drops the machine in the same pass.port/linux/src/p2p.c: a peer is pinged every second whether or not traffic flows, so its round trip stays current in a match.port/linux/game/server_commands.c,docs/dedicated_server.md,tools/server_sim.py:sv_setaccepts the setting on a dedicated server.port/linux/src/port_config.c,port/linux/README.md: the setting (0,HALO_NET_HOST_PING_LIMIT) and its row in the settings table.tools/port_settings.py,network_setup.xml: the HOST PING LIMIT row. The XML is regenerated fromsettings_files(); onlynetwork_setup.xmlchanged.tools/harness/tests/ping_limit.c,test_ping_limit.py: the decision as compiled from the source against a fake tunnel, clock and setting, and a check thatpeer_sendleaves the ping timer alone.User experience
Player removed: ping 201 ms, over the host's limit of 150 ms.How to test
python3 configure.py && ninja linuxpython3 -m pytest -q tools/harness/tests/test_ping_limit.pynetwork.address127.0.0.2 and 127.0.0.3): the host setsHALO_NET_HOST_PING_LIMIT=100and creates a public internet game; the client setsHALO_NET_TUNNEL_PORT=40003and joins from the server browser. Delay the client's tunnel by 200 ms:tc qdisc add dev lo root handle 1: prio && tc qdisc add dev lo parent 1:3 handle 30: netem delay 200ms && tc filter add dev lo protocol ip parent 1:0 prio 3 u32 match ip protocol 17 0xff match ip dport 40003 0xffff flowid 1:3(the tunnel reaches the client at the machine's own address, so a filter on 127.0.0.3 misses it).removed: ping; the client returns to the main menu.Tested
ninja linuxat each of the 10 commits, in the halo-toolchain container on the NAS.tools/harness/tests/test_ping_limit.py: 18 cases (median, one spike, at the limit, off, kicked at the third second, staying under, once a second, byte order, LAN exempt, no round trip, first 10 s of a join in progress, after them, from the lobby into the match, downloading, a new machine at the slot, a slow first sample, recovery after a download, recovery after the limit is turned off) and 12 negative controls, each failing its case; the default, the server's guards, andpeer_sendleaving the ping timer alone.tools/harness,tools/test_touch_menu.pyandtools/test_server_sim.py: 1679 passed, 1 skipped.python3 -m pytest -q tools/test_linux_port.py tools/test_web_build.py tools/harness: 913 passed, 2 skipped, 2 failed. The two failures (test_retail_maps_need_no_corrections,test_tag_validator_survives_damaged_maps: "map_validate: the Custom Edition tag cache's address (40440000) is taken") fail the same way on origin/main in the same container.port_settings.settings_files()reproduces the committed files on origin/main; after the change onlynetwork_setup.xmldiffers.p2p.cchange the host timed 0 round trips during the match (about 14 s apart in the lobby); after it, 85 round trips 1000 to 1009 ms apart, 34 in the lobby and 51 in the match.network_testhost andbrowse, a local MQTT broker), the client's tunnel port delayed 200 ms withtc netem, the host's samples logged by a throwaway instrumented copy:the host: Player removed: ping 201 ms, over the host's limit of 100 msandreason= #6/_rejection_code_blacklisted_machine.ninja android,ninja web: built by fork CI at 7f8dbb7, not locally.