3 ENet evolved specifically as a UDP networking layer for the multiplayer
\r
4 first person shooter Cube. Cube necessitated low latency communcation with
\r
5 data sent out very frequently, so TCP was an unsuitable choice due to its
\r
6 high latency and stream orientation. UDP, however, lacks many sometimes
\r
7 necessary features from TCP such as reliability, sequencing, unrestricted
\r
8 packet sizes, and connection management. So UDP by itself was not suitable
\r
9 as a network protocol either. No suitable freely available networking
\r
10 libraries existed at the time of ENet's creation to fill this niche.
\r
12 UDP and TCP could have been used together in Cube to benefit somewhat
\r
13 from both of their features, however, the resulting combinations of protocols
\r
14 still leaves much to be desired. TCP lacks multiple streams of communication
\r
15 without resorting to opening many sockets and complicates delineation of
\r
16 packets due to its buffering behavior. UDP lacks sequencing, connection
\r
17 management, management of bandwidth resources, and imposes limitations on
\r
18 the size of packets. A significant investment is required to integrate these
\r
19 two protocols, and the end result is worse off in features and performance
\r
20 than the uniform protocol presented by ENet.
\r
22 ENet thus attempts to address these issues and provide a single, uniform
\r
23 protocol layered over UDP to the developer with the best features of UDP and
\r
24 TCP as well as some useful features neither provide, with a much cleaner
\r
25 integration than any resulting from a mixture of UDP and TCP.
\r
27 * Connection management
\r
29 ENet provides a simple connection interface over which to communicate
\r
30 with a foreign host. The liveness of the connection is actively monitored
\r
31 by pinging the foreign host at frequent intervals, and also monitors the
\r
32 network conditions from the local host to the foreign host such as the
\r
33 mean round trip time and packet loss in this fashion.
\r
37 Rather than a single byte stream that complicates the delineation
\r
38 of packets, ENet presents connections as multiple, properly sequenced packet
\r
39 streams that simplify the transfer of various types of data.
\r
41 ENet provides sequencing for all packets by assigning to each sent
\r
42 packet a sequence number that is incremented as packets are sent. ENet
\r
43 guarentees that no packet with a higher sequence number will be delivered
\r
44 before a packet with a lower sequence number, thus ensuring packets are
\r
45 delivered exactly in the order they are sent.
\r
47 For unreliable packets, ENet will simply discard the lower sequence
\r
48 number packet if a packet with a higher sequence number has already been
\r
49 delivered. This allows the packets to be dispatched immediately as they
\r
50 arrive, and reduce latency of unreliable packets to an absolute minimum.
\r
51 For reliable packets, if a higher sequence number packet arrives, but the
\r
52 preceding packets in the sequence have not yet arrived, ENet will stall
\r
53 delivery of the higher sequence number packets until its predecessors
\r
58 Since ENet will stall delivery of reliable packets to ensure proper
\r
59 sequencing, and consequently any packets of higher sequence number whether
\r
60 reliable or unreliable, in the event the reliable packet's predecessors
\r
61 have not yet arrived, this can introduce latency into the delivery of other
\r
62 packets which may not need to be as strictly ordered with respect to the
\r
63 packet that stalled their delivery.
\r
65 To combat this latency and reduce the ordering restrictions on packets,
\r
66 ENet provides multiple channels of communication over a given connection.
\r
67 Each channel is independently sequenced, and so the delivery status of
\r
68 a packet in one channel will not stall the delivery of other packets
\r
73 ENet provides optional reliability of packet delivery by ensuring the
\r
74 foreign host acknowledges receipt of all reliable packets. ENet will attempt
\r
75 to resend the packet up to a reasonable amount of times, if no acknowledgement
\r
76 of the packet's receipt happens within a specified timeout. Retry timeouts
\r
77 are progressive and become more lenient with every failed attempt to allow
\r
78 for temporary turbulence in network conditions.
\r
80 * Fragmentation and reassembly
\r
82 ENet will send and deliver packets regardless of size. Large packets are
\r
83 fragmented into many smaller packets of suitable size, and reassembled on
\r
84 the foreign host to recover the original packet for delivery. The process
\r
85 is entirely transparent to the developer.
\r
89 ENet aggregates all protocol commands, including acknowledgements and
\r
90 packet transfer, into larger protocol packets to ensure the proper utilization
\r
91 of the connection and to limit the opportunities for packet loss that might
\r
92 otherwise result in further delivery latency.
\r
96 ENet provides an in-flight data window for reliable packets to ensure
\r
97 connections are not overwhelmed by volumes of packets. It also provides a
\r
98 static bandwidth allocation mechanism to ensure the total volume of packets
\r
99 sent and received to a host don't exceed the host's capabilities. Further,
\r
100 ENet also provides a dynamic throttle that responds to deviations from normal
\r
101 network connections to rectify various types of network congestion by further
\r
102 limiting the volume of packets sent.
\r
106 ENet works on Windows and any other Unix or Unix-like platform providing
\r
107 a BSD sockets interface. The library has a small and stable code base that
\r
108 can easily be extended to support other platforms and integrates easily.
\r
112 ENet demands no royalties and doesn't carry a viral license that would
\r
113 restrict you in how you might use it in your programs. ENet is licensed under
\r
114 a short-and-sweet MIT-style license, which gives you the freedom to do anything
\r
115 you want with it (well, almost anything).
\r