Not Enough Bandwidth Legacy (NEBL)
这是 Not Enough Bandwidth 的移植版本。在原作者许可下,我们将其移植到了较旧版本的 Minecraft,其功能与原版 NEB 基本一致。

简介
NEBL 采用多种方法,在 Minecraft 游戏过程中尽可能节省网络流量,同时对模组和玩家保持透明。
根据 TeaCon Jiachen 提供的 ZZZZ 数据集对比,与原始未压缩数据相比,NEBL 理论上可将服务器的出站流量减少至原大小的 7.6%,实际测量值约为 13.8%。

在 Vanilla 环境下的测试中,服务器出站流量被减少至原大小的 18%。理论上,随着已安装模组的数量增加,通过网络传输的内容会变得更大、更复杂,从而带来更好的压缩效果。
在游戏中,NEBL 提供了一个简单的流量状态界面。你可以在按键绑定中查看绑定的按键,并使用它打开此界面。

主要特性
紧凑的数据包头部
通过用紧凑索引替换数据包头部 Identifier(数据包类型),优化 CustomPacketPayload 的编码和解码。这将模组网络数据包头部的开销固定为 3-4 字节,而不是对应于网络数据包类型的字符串长度。
索引结构如下:
固定的 8 位头部
┌------------- 1 byte (8 bits) ---------------┐
│ function flags │
├---┬---┬-------------------------------------┤
│ i │ t │ reserved (6 bits) │
└---┴---┴-------------------------------------┘
- i = indexed(已索引,1 bit)
- t = tight_indexed(紧密索引,1 bit,仅在 i=1 时有效)
- reserved = 6 bits(保留用于未来扩展)
索引化的数据包类型
┌---------------- N bytes ----------------
│ Identifier (packet type) in UTF-8
└-----------------------------------------
┌-------- 1 byte ---------┬-------- 1 byte --------┬-------- 1 byte --------┐
┌------------- 12 bits ---------------┬-------------- 12 bits --------------┐
│ namespace-id (capacity 4096) │ path-id (capacity 4096) │
└-------------------------------------┴-------------------------------------┘
┌--------- 1 byte ----------┬--------- 1 byte ---------┐
┌--------- 8 bits ----------┬--------- 8 bits ---------┐
│namespace-id (capacity 256)│ path-id (capacity 256) │
└---------------------------┴--------------------------┘
随后是数据包数据。
当网络数据包的命名空间及其对应的路径少于 256 时,占用 3 字节;大于 256 时,占用 4 字节。这支持最多 4096 个模组,每个模组拥有 4096 个通道。
聚合与压缩
优化 Vanilla 经常产生大量小型网络数据包的情况。在 Connection 级别拦截传输,每 20ms 将它们组装成一个大型网络数据包,并在压缩后发送。
┌---┬----┬----┬----┬----┬----┬----...
│ S │ p0 │ s0 │ d0 │ p1 │ s1 │ d1 ...
└---┴----┴----┴----┴----┴----┴----...
└--packet 1---┘└--packet 2---┘
└----------compressed----------┘
- S = varint,压缩缓冲区的大小
- p = prefix(前缀,medium/int/utf-8),子数据包的类型
- s = varint,该子数据包的大小
- d = bytes,该子数据包的数据
延迟区块缓存
在 Vanilla 中,当玩家移动时,服务器会指示客户端立即忘记他们身后的区块;如果玩家回到原来的位置,必须再次发送完整的区块数据。通过延迟这种“遗忘”,可以节省在周围探索时产生的区块传输流量。
配置
修改位于 config/NotEnoughBandwidthLegacyConfig.json 的配置文件。
compatibleMode
在客户端和服务端独立生效。
是否启用兼容模式。如果设置为 true,将使用下面的 blackList。
blackList
在客户端和服务端独立生效。
兼容模式的黑名单。此处列出的数据包将被 NEBL 跳过。默认情况下,它包含一个与 Velocity 相关的数据包列表,但你可以根据需要添加新的数据包。
为了确保数据包顺序,黑名单中的数据包会中断正在进行的聚合。如果黑名单中有许多数据包,或者相应的数据包发送过于频繁,聚合压缩的效率会降低。
contextLevel
在客户端和服务端独立生效。
用于压缩的上下文窗口大小。有效值为 21 到 25 之间的整数,分别代表 2MB 到 32MB。默认值为 23(8MB)。
更大的上下文窗口意味着更好的压缩效果和带宽节省,但会消耗更多内存。
对于拥有 100 名玩家的服务器,设置为 25 会导致大约 3200MB 的额外内存使用。
dccSizeLimit, dccDistance, dccTimeout
仅在服务端生效。
延迟区块缓存(DCC)允许的最大缓存区块数、缓存区块距离以及缓存超时时间。较大的值可能会消耗更多内存,而较小的值可能会更频繁地触发更新。
Not Enough Bandwidth Legacy (NEBL)
This is a backport of Not Enough Bandwidth. With the original author's permission, we have ported it to an older version of Minecraft, and its functionality is basically the same as the original NEB.

Introduction
NEBL uses various methods to save as much network traffic as possible during Minecraft gameplay, while remaining transparent to both mods and players.
In the ZZZZ Dataset from TeaCon Jiachen, compared to raw uncompressed data, NEBL can theoretically reduce the server's outbound traffic to 7.6% of its original size, with an actual measured value of approximately 13.8%.

In tests conducted in a Vanilla environment, the server outbound traffic was reduced to 18% of its original size. Theoretically, as the number of installed mods increases, the content transmitted over the network becomes larger and more complex, leading to better compression performance.
In the game, NEBL has a simple traffic status screen. You can check the bound key in the key controls and use it to open this screen.

Main Features
Compact Packet Header
Optimize CustomPacketPayload encoding and decoding by replacing the packet header Identifier (Packet Type) with a compact 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.
The index structure is as follows:
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
┌---------------- N bytes ----------------
│ Identifier (packet type) in UTF-8
└-----------------------------------------
- If i=1 and t=0 (indexed, NOT tight):
┌-------- 1 byte ---------┬-------- 1 byte --------┬-------- 1 byte --------┐
┌------------- 12 bits ---------------┬-------------- 12 bits --------------┐
│ namespace-id (capacity 4096) │ path-id (capacity 4096) │
└-------------------------------------┴-------------------------------------┘
- If i=1 and t=1 (indexed, tight):
┌--------- 1 byte ----------┬--------- 1 byte ---------┐
┌--------- 8 bits ----------┬--------- 8 bits ---------┐
│namespace-id (capacity 256)│ path-id (capacity 256) │
└---------------------------┴--------------------------┘
Then packet data.
It occupies 3 bytes when the network packet namespace and its corresponding path are fewer than 256, and 4 bytes when greater than 256. This supports up to 4096 mods, with 4096 channels per mod.
Aggregation and Compress
Optimize the situation where vanilla often produces a large number of small network packets. Intercept transmission at the Connection level, assemble them into one large network packet every 20ms, and send it after compression.
┌---┬----┬----┬----┬----┬----┬----...
│ S │ p0 │ s0 │ d0 │ p1 │ s1 │ d1 ...
└---┴----┴----┴----┴----┴----┴----...
└--packet 1---┘└--packet 2---┘
└----------compressed----------┘
- S = varint, size of compressed buf
- 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
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 poking around can be saved.
Config
Modify the configuration file at config/NotEnoughBandwidthLegacyConfig.json.
compatibleMode
WORK INDEPENDENTLY ON CLIENT AND SERVER.
Whether to enable compatibility mode. If set to true, the blackList below will be used.
blackList
WORK INDEPENDENTLY ON CLIENT AND SERVER.
The blacklist for compatibility mode. Packets listed here will be skipped by NEBL. By default, it includes a list of Velocity-related packets, but you can add new packets as needed.
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.
contextLevel
WORK INDEPENDENTLY ON CLIENT AND SERVER.
The context window size used for compression. Valid values are integers from 21 to 25, representing 2MB to 32MB respectively. The default is 23 (8MB).
A larger context window results in better compression and bandwidth savings, but consumes more memory.
For a server with 100 players, a setting of 25 will result in approximately 3200MB of additional memory usage.
dccSizeLimit, dccDistance, dccTimeout
ONLY WORK ON SERVER.
The maximum number of cached chunks, cached chunk distance, and cache timeout allowed by the Delayed Chunk Cache (DCC). Larger values may consume more memory, while smaller values may trigger updates more frequently.
评论 0
登录后参与评分
还没有评论,来抢沙发吧