Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two general agreement and TCP handshake

Tags:

tcp

handshake

So the two general problem states that there is no deterministic way of knowing if the other party - to whom we communicate via a unreliable channel - has received our messages. This is quite analogous to the TCP handshake where we send a syn syn ack ack and establish a connection. Isn't this opposing the two general problem claim?

like image 375
Faiz Halde Avatar asked Apr 01 '16 09:04

Faiz Halde


People also ask

Why is TCP Reliable two generals problem?

Two Generals Problem shows that Transmission Control Protocol (TCP) can not guarantee state consistency between endpoints and why, though it applies to any type of two party communication where failures of communication are possible.

What is TCP handshake?

The TCP handshakeTCP uses a three-way handshake to establish a reliable connection. The connection is full duplex, and both sides synchronize (SYN) and acknowledge (ACK) each other. The exchange of these four flags is performed in three steps: SYN, SYN-ACK, ACK, as shown in Figure 5.8.

What does the three-way handshake process allow two hosts to do?

A three-way handshake is primarily used to create a TCP socket connection to reliably transmit data between devices. For example, it supports communication between a web browser on the client side and a server every time a user navigates the Internet.

Why does TCP need two double handshakes?

6 Answers. Show activity on this post. The handshaking mechanism used in TCP is designed so that two hosts, attempting to communicate, can negotiate the parameters of the network connection before beginning the communication. Both sides can assume that the other computer is ready and start to reliably send data.


1 Answers

The two general problem is indeed the asynchronous model for TCP, which is why (as the theoretical result shows) the two endpoints cannot simultaneously have common knowledge about the state of the connection.

The way every distributed agreement protocol deals with this issue is to always promise safety (nothing bad will happen), but cannot guarantee liveness (that progress will eventually be made). Liveness is not in your hands. In good times, one can try to do ones best and hope to make progress.

In TCP it means that an endpoint can make an assumption (such as "connection established") without definitely knowing the other's state. However, it is not an unsafe assumption to make; at worst, it is a benign misunderstanding. After a timeout, it will change its opinion. It is no different from being on one end of a long-distance telephone and continuing to talk thinking the connection is still on; after a while, you may have to ask "hello, you still there?", and time out. Real world protocols must always have timeouts (unlike asynchronous formal models) because somewhere up the stack they serve some human function, and human patience is limited. In practice, there are sufficiently good stretches of time that progress can be made, so we just have to pick appropriate timeouts that don't time out too early either.

That said, even benign misunderstandings can have undesirable consequences. For example, after a server responds to the syn, it allocates resources for the connection in the hope that the client will finish the protocol. This is a classic denial of service attack because a rogue client can simply start off the handshake sequence but never finish it, leaving an unprepared server with millions of state machines allocated. Care is required.

like image 117
Sriram Srinivasan Avatar answered Sep 20 '22 18:09

Sriram Srinivasan