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