国庆假期了,翻译了ENet官网对ENet特性的简介。
翻译的不好,能看懂大概意思。
/************************************
Features and Architecture************************************/
ENet evolved specifically as a UDP networking layer for the multiplayer first
person shooter Cube.
ENet的明确发展目标是,成为多人第一视角射击游戏的UDP网络层模型。
Cube necessitated low latency communcation with data sent out very frequently,
so TCP was an unsuitable choice due to its high latency and stream orientation.
这个模型要求在频繁的数据交换情况下实现低延迟,所以TCP不合适,因为TCP高延迟,
以及stream orientation。
UDP, however, lacks many sometimes necessary features from TCP such as
reliability, sequencing, unrestricted packet sizes, and connection management.
So UDP by itself was not suitable as a network protocol either.
由于UDP缺乏TCP的优点,例如“可靠”,“有序”,“不受限制的包大小”,“连接管理”。
所以UDP本身也不适合。
No suitable freely available networking libraries existed at the time of ENet's
creation to fill this niche.
在ENet创建之前,没有合适的免费的网络库。
UDP and TCP could have been used together in Cube to benefit somewhat from both
of their features, however, the resulting combinations of protocols still
leaves much to be desired.
或许能够把UDP和TCP组合起来一起工作,发挥两者各自的优势。但是,这个组合仍然
有很多地方需要改进。
TCP lacks multiple streams of communication without resorting to opening many
sockets and complicates delineation of packets due to its buffering behavior.
由于TCP的“buffering behavior”,如果不建立多个socket,TCP就不能实现多个节点同时通信。
UDP lacks sequencing, connection management, management of bandwidth resources,
and imposes limitations on the size of packets.
UDP缺乏“有序”,“连接管理”,“带宽管理”,并且对包大小有限制。
A significant investment is required to integrate these two protocols, and the
end result is worse off in features and performance than the uniform protocol
presented by ENet.
需要花一笔投入来整合这两种协议,但是结果比ENet提供的“uniform protocol”要糟糕。
ENet thus attempts to address these issues and provide a single, uniform protocol
layered over UDP to the developer with the best features of UDP and TCP as well as
some useful features neither provide, with a much cleaner integration than any
resulting from a mixture of UDP and TCP.
ENet尝试提供一个独立的,建立在UDP之上的,带有UDP和TCP诸多优点的“uniform protocol”,
它比任何UDP和TCP的组合体都要干净。
/*****************************************************
Connection Management
*****************************************************/
ENet provides a simple connection interface over which to communicate with a
foreign host. The liveness of the connection is actively monitored by pinging
the foreign host at frequent intervals, and also monitors the network conditions
from the local host to the foreign host such as the mean round trip time and
packet loss in this fashion.
ENet提供一个简单的连接接口来和远端host通信。ENet会监控这个连接的状态,为了保证
连接不断开,ENet会与远端host做频繁的ping操作;还会监控协议包来回一次花费的时长,
和丢包率。
/*****************************************************
Sequencing
*****************************************************/
Rather than a single byte stream that complicates the delineation of packets,
ENet presents connections as multiple, properly sequenced packet streams that
simplify the transfer of various types of data.
相比在协议描述上面花费力气的单条数据流,ENet提供了多条并且对协议包排序的数据流,
这样简化了类型多种多样的数据的传输。
ENet provides sequencing for all packets by assigning to each sent packet a
sequence number that is incremented as packets are sent. ENet guarentees that
no packet with a higher sequence number will be delivered before a packet
with a lower sequence number, thus ensuring packets are delivered exactly
in the order they are sent.
ENet对每一个协议包分配一个序列号码,序列号码逐一增长。ENet保证序列号码大的协议
不会比序列号码小的协议先发送,这样就能保证协议包的发送顺序与用户希望的发送顺序
保持一致。
For unreliable packets, ENet will simply discard the lower sequence number
packet if a packet with a higher sequence number has already been delivered.
This allows the packets to be dispatched immediately as they arrive, and
reduce latency of unreliable packets to an absolute minimum.
在不可靠模式下,如果ENet已经接收了一个序列号码大的协议包,然后接收到一个序列
号码小的协议包,ENet会丢掉序列号码小的协议包。这样做能够实现“接收到消息后
尽快分发,降低延迟”。
For reliable packets, if a higher sequence number packet arrives, but the
preceding packets in the sequence have not yet arrived, ENet will stall
delivery of the higher sequence number packets until its predecessors have
arrived.
在可靠模式下,如果已经接收到序列号码为N的协议包,但是序列号码为(N-1)的
协议包还没到,则ENet不会分发N协议包,直到(N-1)协议包被接收到。
/*****************************************************
Channels
*****************************************************/
Since ENet will stall delivery of reliable packets to ensure proper sequencing,
and consequently any packets of higher sequence number whether reliable or unreliable,
in the event the reliable packet's predecessors have not yet arrived, this can
introduce latency into the delivery of other packets which may not need to be as
strictly ordered with respect to the packet that stalled their delivery.
由于ENet会暂停协议的分发,以保证可靠协议的有序性,所以在(N-1)可靠协议包到达前,
即使接收到了(N+1),(N+2)等等协议包,并且不管它们是否要求可靠,是否要求有序,
都会被卡主不能分发。
To combat this latency and reduce the ordering restrictions on packets, ENet
provides multiple channels of communication over a given connection. Each channel
is independently sequenced, and so the delivery status of a packet in one channel
will not stall the delivery of other packets in another channel.
为了改善这种情况,ENet针对一个连接提供了多条通信通道。每个通信通道都独立的进行
排序操作,这样,当一个通信通道暂停分发时,不会对其他的通信通道造成影响。
/*****************************************************
Reliability
*****************************************************/
ENet provides optional reliability of packet delivery by ensuring the foreign host
acknowledges receipt of all reliable packets. ENet will attempt to resend the packet
up to a reasonable amount of times, if no acknowledgement of the packet's receipt
happens within a specified timeout. Retry timeouts are progressive and become more
lenient with every failed attempt to allow for temporary turbulence in network conditions.
ENet提供一个可选的协议包可靠传递操作,在可靠方式下,接收方提供“已读回执”,用来保证
远端host接收到可靠的协议包(有序并且不丢包)。如果在指定的超时范围内没有收到
远端host的回执,则ENet会重新发送协议包。
/*****************************************************
Fragmentation and Reassembly
*****************************************************/
ENet will send and deliver packets regardless of size. Large packets are fragmented into
many smaller packets of suitable size, and reassembled on the foreign host to recover the
original packet for delivery. The process is entirely transparent to the developer.
ENet发送和转发协议包时不考虑协议包的大小。大协议包会切分成小块进行发送,并在远端host那里
重新组装成原来的协议包。这个过程对开发者是透明的。
/*****************************************************
Aggregation
*****************************************************/
ENet aggregates all protocol commands, including acknowledgements and packet transfer,
into larger protocol packets to ensure the proper utilization of the connection and to
limit the opportunities for packet loss that might otherwise result in further delivery latency.
ENet整合了很多特性,包括“回执”,“packet transfer”,小协议包合并成大协议包一次性传递,
降低丢包风险。如果丢包,会造成进一步的网络延迟。
/*****************************************************
Adaptability
*****************************************************/
ENet provides an in-flight data window for reliable packets to ensure connections are not
overwhelmed by volumes of packets. It also provides a static bandwidth allocation mechanism to
ensure the total volume of packets sent and received to a host don't exceed the host's capabilities.
Further, ENet also provides a dynamic throttle that responds to deviations from normal network
connections to rectify various types of network congestion by further limiting the volume of
packets sent.
ENet有带宽流量控制,保证连接畅通。
/*****************************************************
Portability
*****************************************************/
ENet works on Windows and any other Unix or Unix-like platform providing a BSD sockets interface.
The library has a small and stable code base that can easily be extended to support other platforms
and integrates easily.
ENet makes no assumptions about the underlying platform's endianess or word size.
ENet支持跨平台。
/*****************************************************
Freedom
*****************************************************/
ENet demands no royalties and doesn't carry a viral license that would restrict you in how you might
use it in your programs. ENet is licensed under a short-and-sweet MIT-style license, which gives you
the freedom to do anything you want with it (well, almost anything).
ENet完全免费,可以自由使用。