Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet reordering can cause a wrong client-side map #14506

Open
HybridDog opened this issue Mar 30, 2024 · 1 comment
Open

Packet reordering can cause a wrong client-side map #14506

HybridDog opened this issue Mar 30, 2024 · 1 comment
Labels
Bug Issues that were confirmed to be a bug @ Network Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible).

Comments

@HybridDog
Copy link
Contributor

Minetest version

Minetest 5.9.0-dev-e8a8525bc (Linux)
Using LuaJIT 2.1.0-beta3
Built by GCC 13.2
Running on Linux/6.8.1-arch1-1 x86_64
BUILD_TYPE=Release
RUN_IN_PLACE=0
USE_CURL=1
USE_GETTEXT=1
USE_SOUND=1
STATIC_SHAREDIR="/usr/local/share/minetest"
STATIC_LOCALEDIR="/usr/local/share/locale"

Irrlicht device

X11

Operating system and version

Arch Linux

CPU model

dual core Intel Core i5-6200U [MT MCP]

GPU model

No response

Active renderer

No response

Summary

Minetest detects and fixes network packet reordering if the packets are in the same channel (as far as I know).
TOCLIENT_BLOCKDATA, TOCLIENT_ADDNODE and TOCLIENT_REMOVENODE packets all modify the client-side map but TOCLIENT_BLOCKDATA is in a different channel than the other two:

{ "TOCLIENT_BLOCKDATA", 2, true }, // 0x20
{ "TOCLIENT_ADDNODE", 0, true }, // 0x21
{ "TOCLIENT_REMOVENODE", 0, true }, // 0x22

If TOCLIENT_BLOCKDATA and TOCLIENT_ADDNODE (or TOCLIENT_REMOVENODE) packets arrive in the wrong order, the client-side map can contain different nodes than the server-side map although the server has sent all map updates (if I understand the code correctly).

Steps to reproduce

  • Use minetest_game and add this chatcommand:
local nplace_state = false
minetest.register_chatcommand("nplace", {
	description = "set_node and voxel_manip in the same mapblock",
	privs = {server = true},
	func = function(name)
		local node_vm = "default:wood"
		local node_set = "default:stone"
		if nplace_state then
			node_vm, node_set = node_set, node_vm
		end
		nplace_state = not nplace_state
		local pos = vector.new(0, 511, 0)

		minetest.set_node(pos, {name = node_set})

		local vm = minetest.get_voxel_manip()
		local area_p1, area_p2 = vm:read_from_map(pos, pos)
		local data = vm:get_data()
		local node_vm_id = minetest.get_content_id(node_vm)
		for i = 1, #data do
			data[i] = node_vm_id
		end
		vm:set_data(data)
		vm:write_to_map()

		return true, ("Nodes changed: Set %s at %s and afterwards filled " ..
			"the mapblock with %s"):format(
			node_set, minetest.pos_to_string(pos), node_vm)
	end
})
  • Configure the operating system to apply random delays to network packets on localhost. On Linux, this can be done with, for example, the traffic control command:
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc qdisc add dev lo root netem delay 700ms 500ms

This adds 700 ms delay to packets with 500 ms jitter, which often leads to packet reordering.
To undo the traffic control manipulation later, execute sudo tc qdisc del dev lo root.

  • Join a world in singleplayer, teleport to (0, 511, 0) and execute the nplace chat command. Without packet reordering, the client-side map and the server-side one are the same. Otherwise, the TOCLIENT_ADDNODE packet from minetest.set_node and the TOCLIENT_BLOCKDATA packet from voxel manipuation arrive in the wrong order, so the client map has a wrong node in the corner.

Here's a video of the problem:

vm_setnode_packet_reordering.mp4
@HybridDog HybridDog added the Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible label Mar 30, 2024
@sfan5 sfan5 added Bug Issues that were confirmed to be a bug and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels Mar 30, 2024
@sfan5
Copy link
Member

sfan5 commented Mar 30, 2024

touched by this proposal: #14431 (comment)

@sfan5 sfan5 added Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible). @ Network and removed Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible). labels Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Network Non-trivial A large amount of work is required to address this (sometimes to the point of being infeasible).
Projects
None yet
Development

No branches or pull requests

2 participants