design.dox 5.9 KB

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