Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/enet-1.1/design.txt @ 13

Last change on this file since 13 was 13, checked in by landauf, 16 years ago

added enet

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