From d93918dc3a4118e43bb56e38f0a0a9d622e92573 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Wed, 1 Mar 2017 20:44:16 -0800 Subject: [PATCH] Add Transmission control protocol (TCP) section --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 2e015122..19fc7956 100644 --- a/README.md +++ b/README.md @@ -1472,3 +1472,27 @@ HTTP is an application layer protocol relying on lower-level protocols such as * * [HTTP](https://www.nginx.com/resources/glossary/http/) * [README](https://www.quora.com/What-is-the-difference-between-HTTP-protocol-and-TCP-protocol) + +### Transmission control protocol (TCP) + +

+ +
+ Source: How to make a multiplayer game +

+ +TCP is a connection-oriented protocol over an [IP network](https://en.wikipedia.org/wiki/Internet_Protocol). Connection is established and terminated using a [handshake](https://en.wikipedia.org/wiki/Handshaking). All packets sent are guaranteed to reach the destination in the original order and without corruption through: + +* Sequence numbers and [checksum fields](https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Checksum_computation) for each packet +* [Acknowledgement](https://en.wikipedia.org/wiki/Acknowledgement_(data_networks)) packets and automatic retransmission + +If the sender does not receive a correct response, it will resend the packets. If there are multiple timeouts, the connection is dropped. TCP also implements [flow control](https://en.wikipedia.org/wiki/Flow_control_(data)) and [congestion control](https://en.wikipedia.org/wiki/Network_congestion#Congestion_control). These guarantees cause delays and generally results in less efficient transmission than UDP. + +To ensure high throughput, web servers can keep a large number of TCP connections open, resulting in high memory usage. It can be expensive to have a large number of open connections between web server threads and say, a [memcached](#memcached) server. [Connection pooling](https://en.wikipedia.org/wiki/Connection_pool) can help in addition to switching to UDP where applicable. + +TCP is useful for applications that require high reliability but are less time critical. Some examples include web servers, database info, SMTP, FTP, and SSH. + +Use TCP over UDP when: + +* You need all of the data to arrive in tact +* You want to automatically make a best estimate use of the network throughput