TCP flags

TCP flags

(Reference Source: https://blog.csdn.net/ltstud/article/details/73995933 )

Six flags

SYN: (synchronous synchronization, establish a connection)

ACK: (acknowledgement confirmation)

PSH: (push transmission)

FIN (finish end)

RST (reset reset)

URG (urgent emergency)

 

3-way handshake

Host A-> Host B (first handshake): (? It can establish a connection) is transmitted code bits syn = 1, seq number = 1234567 (randomly generated) data packets to a server (host B); host B receives after syn = 1 is known to establish a connection;

Host B-> Host A (second handshake) to establish a connection :() transmitting ack number = (seq host A + 1), syn = 1, ack = 1, seq = 7654321 (randomly generated).;

Host A-> Host B (third handshake) :( connected Start -> the connection is successful) (check ack number = (the first handshake seq?) Seq + 1, ack = 1), if equal, transmits ACK? number = (seq host B (second handshake) a + 1), ack = 1; after host B receives the acknowledgment (check ack number = (second handshake seq) seq + 1, ack = 1??) the connection is established

 

Four waving

Since a TCP connection is full-duplex, so each direction must be shut down separately.

But data transmission task after a party, the other party sends a FIN (data here I finished, I want to close my transmit channels), (after receiving fin can still continue to send, but closed the connection their income, does not receive data); return determined after receiving the fin. (FIN identified by identifying the last data transfer FIN is set at the time when the last data transfer by setting)

 

a-> b: (a: Hey, I ran out of data packet 200. The finished tell me 500) fin: 200, ack: 500 (sign: ACK = 1, FIN = 1)

b-> a: (b: amount, you send it finished off close 201.b this connection, send a close this connection) ack: 201 (ACK = 1)

b-> a: (b: Hey, I made over packet 500.) fin: 500, ack: 201 (sign: ACK = 1, FIN = 1)

a-> b: (a: amount, you send it finished off close this connection 501.a, b closing this connection hair) ack: 501 (ACK = 1)

 

 

Guess you like

Origin www.cnblogs.com/baixinL/p/11967112.html