带宽不足 (NEB) — Fabric 移植版
适用于 Minecraft 1.21.4 的 Fabric 模组 —— 通过数据包头部索引、聚合与 Zstd 压缩、延迟区块缓存以及持久化客户端区块去重,实现网络带宽优化。
需要支持或为其他版本移植? 请在 GitHub Issues 提交问题,加入 QQ 群 362669270 (邀请链接),或发送邮件至 support@rms.net.cn。
这是由 USS_Shenzhou 开发的原始 NeoForge 模组 的非官方 Fabric 移植版。 如果您希望参与上游项目的开发,请先在 Discord 上与 USS_Shenzhou 讨论。
简介
NEB 使用多种方法在《Minecraft》游戏过程中尽可能节省网络流量,同时对模组和玩家保持透明。
在 TeaCon Jiachen 数据集中,与未压缩的原始数据相比,NEB 理论上可将服务器的出站流量降低至原始大小的 7.6%。作为对比,《Minecraft》原版默认压缩机制的出站流量为原始数据大小的 39%。
在 Vanilla 环境下的测试中,服务器出站流量被降低至原始大小的 18%。随着已安装模组数量的增加,压缩性能会进一步提升。
在游戏中按下 Alt+N 可查看网络流量状态。
主要功能
紧凑的数据包头部
通过用紧凑的 VarInt 索引替换数据包头部 Identifier(数据包类型),优化了 CustomPacketPayload 的编码和解码过程。这将模组网络数据包头部的开销固定为 3-4 字节,而不是对应网络数据包类型的字符串长度。
[!NOTE]
固定的 8 位头部
+------------- 1 byte (8 bits) ---------------+ | function flags | +---+---+--------------------------------------+ | i | t | reserved (6 bits) | +---+---+--------------------------------------+
- i = indexed(已索引,1 位)
- t = tight_indexed(紧密索引,1 位,仅在 i=1 时有效)
- reserved = 保留位(6 位,供将来使用)
索引式数据包类型
- 如果 i=0(未索引):随后跟随完整的 UTF-8
Identifier。- 如果 i=1 且 t=0(已索引,非紧密):3 字节 — 12 位命名空间 ID + 12 位路径 ID(每个容量为 4096)。
- 如果 i=1 且 t=1(已索引,紧密):2 字节 — 8 位命名空间 ID + 8 位路径 ID(每个容量为 256)。
聚合与压缩
优化了原版经常产生大量小型网络数据包的情况。在 Connection 级别拦截传输,每 20ms 将它们组装成一个大型网络数据包,并在经过 Zstd 压缩后发送。
[!NOTE]
+---+-----+----+----+----+----+----+----... | B | (S) | p0 | s0 | d0 | p1 | s1 | d1 ... +---+-----+----+----+----+----+----+----... +--packet 1---++--packet 2---+ +---------compressed---------+
- B = bool,是否已压缩
- S = varint,未压缩数据的大小(仅在压缩时存在)
- p = prefix(前缀,medium/int/utf-8),此子数据包的类型
- s = varint,此子数据包的大小
- d = bytes,此子数据包的数据
延迟区块缓存 (DCC)
在 Vanilla 中,当玩家移动时,服务器会指示客户端立即遗忘其身后的区块;如果玩家回到原来的位置,则必须再次发送完整的区块数据。通过延迟这种“遗忘”行为,可以节省来回移动时产生的区块传输流量。
持久化区块缓存 (PCC)
使用本地 LevelDB 数据库,以 64 位内容哈希为键,在客户端持久化缓存区块数据。每次连接时,客户端将所有缓存区块哈希的布隆过滤器发送给服务器。当服务器准备发送一个哈希存在于过滤器中的区块时,它只发送 20 字节的哈希值,而不是完整的数据包(约 10–20 KB)。客户端从其本地数据库中加载该区块。在布隆过滤器出现误报时,客户端请求完整数据作为回退。布隆过滤器每新增 64 个缓存区块刷新一次,以便在同一会话内生效。
配置
修改位于 config/NotEnoughBandwidthConfig.json 的配置文件。
compatibleMode
在客户端和服务端独立工作。
是否启用兼容模式。如果设置为 true,将使用下面的 blackList。
blackList
在客户端和服务端独立工作。
兼容模式的黑名单。此处列出的数据包将被 NEB 跳过。您可以根据需要添加数据包。
[!WARNING] 为确保数据包顺序,黑名单中的数据包的到达将中断正在进行的聚合。如果黑名单中有许多数据包,或者对应的数据包发送过于频繁,聚合压缩的效率会降低。
compressionLevel
在客户端和服务端独立工作。
Zstd 压缩级别(整数 1-19)。默认为 6。较高的值会产生更好的压缩效果,但会使用更多的 CPU。
contextLevel
在客户端和服务端独立工作。
Zstd 上下文窗口大小(整数 21-25,代表 2-32MB)。默认为 23(8MB)。较大的值会导致更好的压缩效果,但会消耗更多内存。
[!TIP] 对于拥有 100 名玩家的服务器,设置为 25 将导致大约 3200MB 的额外内存占用。
dccSizeLimit, dccDistance, dccTimeout
仅限服务端。
延迟区块缓存 (DCC) 参数:最大缓存区块数、缓存距离、缓存超时时间(秒)。较大的值可能会消耗更多内存,而较小的值可能会更频繁地触发更新。
chunkCacheEnabled
仅限客户端。
是否启用持久化区块缓存。默认为 true。
chunkCacheMaxSizeMB
仅限客户端。
本地区块缓存数据库的最大大小(以 MB 为单位)。默认值为 2048(2 GB)。
安装
依赖:
- Minecraft 1.21.4
- Fabric Loader >= 0.18.0
- Fabric API
客户端和服务器都必须安装 NEB。 当没有安装 NEB 的客户端连接时,服务器对该连接将回退到原版行为。
许可证
版权所有 (C) 2025 USS_Shenzhou
本模组是 GNU GPL 3.0 下的自由软件。详情请参阅 LICENSE。
额外许可
作为游戏玩家,当您在 Minecraft 中加载并运行此程序时,本许可证自动授予您所有必要的权利,这些权利未被 GPL-3.0 许可证涵盖,或被 GPL-3.0 许可证所禁止,但属于在 Minecraft 中正常加载和运行此程序所需的权利。若 GPL-3.0 许可证与 Minecraft EULA 或其他 Mojang/Microsoft 条款发生冲突,以后者为准。
Not Enough Bandwidth (NEB) — Fabric Port
Fabric mod for Minecraft 1.21.4 — Network bandwidth optimization through packet header indexing, aggregation + Zstd compression, delayed chunk caching, and persistent client-side chunk deduplication.
Need support or a port for another version? Open an issue, join QQ group 362669270 (invite link), or email support@rms.net.cn.
This is an unofficial Fabric port of the original NeoForge mod by USS_Shenzhou. If you want to contribute to the upstream project, please discuss with USS_Shenzhou on Discord first.
Introduction
NEB uses various methods to save as much network traffic as possible during Minecraft gameplay, while remaining transparent to both mods and players.
In the TeaCon Jiachen dataset, compared to raw uncompressed data, NEB can theoretically reduce the server's outbound traffic to 7.6% of its original size. For comparison, the outbound traffic of Vanilla's default compression mechanism is 39% of the original data size.
In tests conducted in a Vanilla environment, the server outbound traffic was reduced to 18% of its original size. As the number of installed mods increases, compression performance improves.
Press Alt+N in-game to view the network traffic status.
Main Features
Compact Packet Header
Optimizes CustomPacketPayload encoding and decoding by replacing the packet header Identifier (Packet Type) with a compact VarInt index. This reduces the mod network packet header overhead to a fixed 3-4 bytes, instead of the length of the string corresponding to the network packet type.
[!NOTE]
Fixed 8 bits header
+------------- 1 byte (8 bits) ---------------+ | function flags | +---+---+--------------------------------------+ | i | t | reserved (6 bits) | +---+---+--------------------------------------+
- i = indexed (1 bit)
- t = tight_indexed (1 bit, only valid if i=1)
- reserved = 6 bits (for future use)
Indexed packet type
- If i=0 (not indexed): full
Identifierin UTF-8 follows.- If i=1 and t=0 (indexed, NOT tight): 3 bytes — 12-bit namespace-id + 12-bit path-id (capacity 4096 each).
- If i=1 and t=1 (indexed, tight): 2 bytes — 8-bit namespace-id + 8-bit path-id (capacity 256 each).
Aggregation and Compression
Optimizes the situation where vanilla often produces a large number of small network packets. Intercepts transmission at the Connection level, assembles them into one large network packet every 20ms, and sends it after Zstd compression.
[!NOTE]
+---+-----+----+----+----+----+----+----... | B | (S) | p0 | s0 | d0 | p1 | s1 | d1 ... +---+-----+----+----+----+----+----+----... +--packet 1---++--packet 2---+ +---------compressed---------+
- B = bool, whether compressed
- S = varint, size of uncompressed data (only present if compressed)
- p = prefix (medium/int/utf-8), type of this subpacket
- s = varint, size of this subpacket
- d = bytes, data of this subpacket
Delayed Chunk Cache (DCC)
In Vanilla, when a player moves, the server instructs the client to immediately forget the chunks behind them; if the player returns to the original position, the full chunk data must be sent again. By delaying this "forgetting", the chunk transmission traffic generated when moving back and forth can be saved.
Persistent Chunk Cache (PCC)
Caches chunk data persistently on the client side using a local LevelDB database, keyed by a 64-bit content hash. On each connection, the client sends a Bloom Filter of all cached chunk hashes to the server. When the server is about to send a chunk whose hash is in the filter, it sends only the 20-byte hash instead of the full packet (~10–20 KB). The client loads the chunk from its local database. On a Bloom Filter false positive, the client requests the full data as a fallback. The Bloom Filter is refreshed every 64 newly cached chunks so the optimization takes effect within the same session.
Configuration
Modify the configuration file at config/NotEnoughBandwidthConfig.json.
compatibleMode
Works independently on client and server.
Whether to enable compatibility mode. If set to true, the blackList below will be used.
blackList
Works independently on client and server.
The blacklist for compatibility mode. Packets listed here will be skipped by NEB. You can add packets as needed.
[!WARNING] To ensure packet ordering, packets in the blacklist will interrupt the ongoing aggregation. If there are many packets in the blacklist, or if the corresponding packets are sent too frequently, the efficiency of aggregation-compression will decrease.
compressionLevel
Works independently on client and server.
The Zstd compression level (integer 1-19). Default is 6. Higher values produce better compression but use more CPU.
contextLevel
Works independently on client and server.
The Zstd context window size (integer 21-25, representing 2-32MB). Default is 23 (8MB). Larger values result in better compression but consume more memory.
[!TIP] For a server with 100 players, a setting of 25 will result in approximately 3200MB of additional memory usage.
dccSizeLimit, dccDistance, dccTimeout
Server only.
Delayed Chunk Cache (DCC) parameters: max cached chunks, cache distance, cache timeout (seconds). Larger values may consume more memory, while smaller values may trigger updates more frequently.
chunkCacheEnabled
Client only.
Whether to enable the Persistent Chunk Cache. Default is true.
chunkCacheMaxSizeMB
Client only.
Maximum size of the local chunk cache database in megabytes. Default is 2048 (2 GB).
Installation
Requires:
- Minecraft 1.21.4
- Fabric Loader >= 0.18.0
- Fabric API
Both client and server must install NEB. When a client without NEB connects, the server falls back to vanilla behavior for that connection.
License
Copyright (C) 2025 USS_Shenzhou
This mod is free software under the GNU GPL 3.0. See LICENSE for details.
Additional Permissions
As a game player, when you load and play this program in Minecraft, this license automatically grants you all rights necessary, which are not covered in the GPL-3.0 license, or are prohibited by the GPL-3.0 license, for the normal loading and playing of this program in Minecraft. In case of conflicts between the GPL-3.0 license and the Minecraft EULA or other Mojang/Microsoft terms, the latter shall prevail.
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
下载 Not Enough Bandwidth Fabric
更改
- chore: v1.0.4 (6a82dd9)
- fix(network): 客户端发送 neb: 载荷前需先完成握手 (30efebe)
- chore(domain): 将 rms.net.cn 引用迁移至 cxu.org.cn (ac3179c)
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
评论 0
登录后参与评分
还没有评论,来抢沙发吧